Skip to content

Commit

Permalink
Merge branch 'master' into coverity_scan
Browse files Browse the repository at this point in the history
  • Loading branch information
ruleant committed Oct 20, 2014
2 parents a2faf21 + c857ca9 commit 1bfd253
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 40 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
API 19 (Kitkat), thanks to Олег Нощенко for reporting
- CID 72849 : fix Coverity issue : dereference null return value
- translated to Japanese, thanks to naofum and J.S.Sebastian
- issue #16, #162 : add a name to a destination
- issue #157 : display compass rose when orientation is accurate

v0.3 (released on 07Jul2014)
- CID 60865 : fix Coverity issue : dereference null return value
Expand All @@ -28,7 +30,6 @@
- issue #128 : Draw a compass rose pointing North
- translated to French, thanks to Pierre Barre and an anonymous contributor
- CID 68697 : fix Coverity issue : dereference null return value, when getting package info
- issue #16, #162 : add a name to a destination

v0.2 (released on 26Apr2014)
- issue #112 : update ic_launcher-web.png icon
Expand Down
7 changes: 6 additions & 1 deletion res/values-be/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
<item quantity="one">%d хвіліна</item>
<item quantity="few">%d хвіліны</item>
<item quantity="many">%d хвіліны</item>
<item quantity="other"></item>
<item quantity="other"/>
</plurals>
<string name="dialog_store_location_name">Калі ласка, увядзіце назву для вашага бягучага месцазнаходжання:</string>
<string name="location_name">Назва месцазнаходжання</string>
<string name="cancel">Скасаваць</string>
<string name="location_name_stored">Месцазнаходжанне \"%s\" захавана</string>
<string name="no_location_name">Назва месцазнаходжання не пазначана</string>
</resources>
10 changes: 7 additions & 3 deletions res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,21 @@ Kopii Obecné veřejné licence GNU jste měli obdržet spolu s tímto programem
<string name="travel_direction_backwards">Zpět</string>
<plurals name="distance_meter">
<item quantity="one">%d metr</item>
<item quantity="other">%d metry</item>
<item quantity="few">%d metry</item>
<item quantity="other">%d metrů</item>
</plurals>
<plurals name="time_seconds">
<item quantity="one">%d sekunda</item>
<item quantity="other">%d sekundy</item>
<item quantity="few">%d sekundy</item>
<item quantity="other">%d sekund</item>
</plurals>
<plurals name="time_minutes">
<item quantity="one">%d minuta</item>
<item quantity="other">%d minuty</item>
<item quantity="few">%d minuty</item>
<item quantity="other">%d minut</item>
</plurals>
<string name="dialog_rename_destination">Zadejte nový název pro cíl:</string>
<string name="rename_destination">Přejmenovat cíl</string>
<string name="rename_destination_disabled">Nelze přejmenovat cíl, nejprve umístění uložte</string>
<string name="destination_renamed">Cíl byl přejmenován</string>
</resources>
2 changes: 1 addition & 1 deletion res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Usted ha debido de recibir una copia de la Licencia General Pública de GNU junt
<string name="current_bearing">Rumbo actual</string>
<string name="destination_reached">En destino</string>
<string name="to_dest">En camino</string>
<string name="sensors_enabled">Habilitado: actualizaciones más rápidas y giros más precisos; Habilitado: actualizaciones más rápidas y movimientos más precisos</string>
<string name="sensors_enabled">Habilitado: actualizaciones más rápidas y giros más precisos</string>
<string name="about">Acerca de</string>
<string name="build_time">Compilado en %s.</string>
<string name="dialog_store_location_name">Poner un nombre a la ubicación actual:</string>
Expand Down
23 changes: 10 additions & 13 deletions res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
<resources><string name="direction">方向</string>
<string name="copyright">著作権</string>
<plurals name="distance_meter">
<item quantity="one">%d メートル</item>
<item quantity="other"/>
</plurals>
<item quantity="other">%d メートル</item>
</plurals>
<plurals name="time_seconds">
<item quantity="one">%d 秒</item>
<item quantity="other"/>
</plurals>
<item quantity="other">%d 秒</item>
</plurals>
<plurals name="time_minutes">
<item quantity="one">%d 分</item>
<item quantity="other"/>
</plurals>
<item quantity="other">%d 分</item>
</plurals>
<string name="speed">速度</string>
<string name="latitude">緯度</string>
<string name="longitude">経度</string>
Expand Down Expand Up @@ -90,10 +87,10 @@
<string name="version">バージョン</string>
<string name="build_time">%s にビルド。</string>
<string name="app_website">詳細は &lt;a href=%1$s&gt;webサイト&lt;/a&gt; を参照してください。</string>
<string name="license">This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

<string name="license">This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.\n
\n
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n
\n
You should have received a copy of the GNU General Public License along with this program. If not, see <a href="http://www.gnu.org/licenses/">www.gnu.org/licenses</a>.</string>
<string name="bearing">方角</string>
<string name="destination_renamed">場所の名前を変更しました</string>
Expand Down
3 changes: 0 additions & 3 deletions res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,16 @@
<string name="disabled">Выключено</string>
<plurals name="distance_meter">
<item quantity="one">%d метр</item>
<item quantity="few">%d метров</item>
<item quantity="many">%d метров</item>
<item quantity="other"/>
</plurals>
<plurals name="time_seconds">
<item quantity="one">%d секунда</item>
<item quantity="few">%d секунд</item>
<item quantity="many">%d секунд</item>
<item quantity="other"/>
</plurals>
<plurals name="time_minutes">
<item quantity="one">%d минута</item>
<item quantity="few">%d минут</item>
<item quantity="many">%d минут</item>
<item quantity="other"/>
</plurals>
Expand Down
20 changes: 13 additions & 7 deletions src/java/com/github/ruleant/getback_gps/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ protected final boolean refreshDisplay() {
String toDestinationDistanceText = res.getString(R.string.unknown);
String toDestinationDirectionText = res.getString(R.string.unknown);
String toDestinationMessage = res.getString(R.string.unknown);
NavigationView.NavigationMode nvMode
= NavigationView.NavigationMode.Disabled;
NavigationView.Mode nvNavigationMode = NavigationView.Mode.Disabled;
NavigationView.Mode nvOrientationMode = NavigationView.Mode.Disabled;
Boolean displayToDest = false;

if (destination == null) {
Expand Down Expand Up @@ -223,17 +223,22 @@ protected final boolean refreshDisplay() {
if (navigator.isBearingAccurate()) {
nvToDestination.setDirection(
navigator.getRelativeDirection());
nvToDestination.setAzimuth(
navigator.getCurrentBearing());
nvMode = NavigationView.NavigationMode.Accurate;
nvNavigationMode = NavigationView.Mode.Accurate;
} else {
nvToDestination.setDirection(
navigator.getAbsoluteDirection());
nvMode = NavigationView.NavigationMode.Inaccurate;
nvNavigationMode = NavigationView.Mode.Inaccurate;
}
}
}

// if orientation is accurate, display compass rose
if (navigator.isBearingAccurate()) {
nvToDestination.setAzimuth(
navigator.getCurrentBearing());
nvOrientationMode = NavigationView.Mode.Accurate;
}

if (displayToDest) {
// show 'to Destination' info, hide message
sectionToDestination.setVisibility(LinearLayout.VISIBLE);
Expand All @@ -253,7 +258,8 @@ protected final boolean refreshDisplay() {
}

// update views
nvToDestination.setMode(nvMode);
nvToDestination.setNavigationMode(nvNavigationMode);
nvToDestination.setOrientationMode(nvOrientationMode);
nvToDestination.invalidate();

return true;
Expand Down
56 changes: 45 additions & 11 deletions src/java/com/github/ruleant/getback_gps/NavigationView.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public class NavigationView extends ImageView {
/**
* Navigation mode enum.
*/
public enum NavigationMode {
public enum Mode {
/**
* Mode disabled.
*/
Expand All @@ -147,7 +147,12 @@ public enum NavigationMode {
/**
* Navigation mode.
*/
private NavigationMode mMode = NavigationMode.Disabled;
private Mode mNavigationMode = Mode.Disabled;

/**
* Orientation mode.
*/
private Mode mOrientationMode = Mode.Disabled;

/**
* Attribute layout_height.
Expand Down Expand Up @@ -251,7 +256,7 @@ public final void setDirection(final double direction) {
* @return Direction to destination (0-360°)
*/
public final double getDirection() {
if (getMode() == NavigationMode.Disabled) {
if (getNavigationMode() == Mode.Disabled) {
return 0;
} else {
return mDirection;
Expand All @@ -273,7 +278,7 @@ public final void setAzimuth(final double azimuth) {
* @return Angle to azimuth (0-360°)
*/
public final double getAzimuth() {
if (getMode() == NavigationMode.Disabled) {
if (getOrientationMode() == Mode.Disabled) {
return 0;
} else {
return mAzimuth;
Expand All @@ -286,18 +291,18 @@ public final double getAzimuth() {
* @param mode Navigation mode : DISABLED, INACCURATE, ACCURATE
*/
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public final void setMode(final NavigationMode mode) {
public final void setNavigationMode(final Mode mode) {
Resources res = getResources();

switch (mode) {
default:
case Disabled:
this.mMode = NavigationMode.Disabled;
this.mNavigationMode = Mode.Disabled;
mPaintLines.setColor(Color.GRAY);
mPaintSolids.setColor(Color.LTGRAY);
break;
case Inaccurate:
this.mMode = mode;
this.mNavigationMode = mode;
if (Build.VERSION.SDK_INT
>= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
mPaintLines.setColor(
Expand All @@ -310,7 +315,7 @@ public final void setMode(final NavigationMode mode) {
}
break;
case Accurate:
this.mMode = mode;
this.mNavigationMode = mode;
if (Build.VERSION.SDK_INT
>= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
mPaintLines.setColor(
Expand All @@ -330,8 +335,37 @@ public final void setMode(final NavigationMode mode) {
*
* @return Navigation mode : DISABLED, INACCURATE, ACCURATE
*/
public final NavigationMode getMode() {
return mMode;
public final Mode getNavigationMode() {
return mNavigationMode;
}

/**
* Sets orientation mode.
*
* @param mode Orientation mode : DISABLED, INACCURATE, ACCURATE
*/
public final void setOrientationMode(final Mode mode) {
switch (mode) {
default:
case Disabled:
this.mOrientationMode = Mode.Disabled;
break;
case Inaccurate:
this.mOrientationMode = mode;
break;
case Accurate:
this.mOrientationMode = mode;
break;
}
}

/**
* Get orientation mode.
*
* @return Orientation mode : DISABLED, INACCURATE, ACCURATE
*/
public final Mode getOrientationMode() {
return mOrientationMode;
}

@Override
Expand Down Expand Up @@ -369,7 +403,7 @@ public final void onDraw(final Canvas canvas) {
mPaintRoseLines);

// draw compass rose
if (getMode() == NavigationMode.Accurate) {
if (getOrientationMode() == Mode.Accurate) {
mRoseRotationConverter.setRotationAngle(mRoseRotation);
canvas.drawPath(mCompassRoseBody.toPath(), mPaintRoseSolidNorth);
canvas.drawLines(mCompassRose.toLinesArray(), mPaintRoseLines);
Expand Down

0 comments on commit 1bfd253

Please sign in to comment.