Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
weblate committed Jul 7, 2014
2 parents 17c7558 + e7b6a1e commit da54d91
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- translated to Chinese (Traditional), thanks to Ezjerry Liao
- 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

v0.2 (released on 26Apr2014)
- issue #112 : update ic_launcher-web.png icon
Expand Down
28 changes: 22 additions & 6 deletions src/java/com/github/ruleant/getback_gps/AboutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.os.Build;
Expand Down Expand Up @@ -58,19 +59,15 @@ protected final void onCreate(final Bundle savedInstanceState) {
DateFormat formatter = SimpleDateFormat.getDateTimeInstance();
String versionInfo = res.getString(R.string.app_name);
String buildTime = "";
PackageInfo packageInfo;

try {
packageInfo
= getPackageManager().getPackageInfo(getPackageName(), 0);
PackageInfo packageInfo = getPackageInfo();
if (packageInfo != null) {
versionInfo += " v" + packageInfo.versionName;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
Date date = new Date(packageInfo.lastUpdateTime);
buildTime = String.format(res.getString(R.string.build_time),
formatter.format(date));
}
} catch (NameNotFoundException e) {
e.printStackTrace();
}

// Version text view
Expand Down Expand Up @@ -117,4 +114,23 @@ protected final void onCreate(final Bundle savedInstanceState) {
// enable HTML links
tvLicense.setMovementMethod(LinkMovementMethod.getInstance());
}

/**
* Retrieve Package info (build timestamp, version, ...).
*
* @return Package info
*/
private PackageInfo getPackageInfo() {
PackageManager pm = getPackageManager();
if (pm == null) {
return null;
}

try {
return pm.getPackageInfo(getPackageName(), 0);
} catch (NameNotFoundException e) {
e.printStackTrace();
return null;
}
}
}
8 changes: 3 additions & 5 deletions src/java/com/github/ruleant/getback_gps/NavigationView.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public enum NavigationMode {
/**
* Navigation mode.
*/
private NavigationMode mMode;
private NavigationMode mMode = NavigationMode.Disabled;

/**
* Attribute layout_height.
Expand Down Expand Up @@ -361,11 +361,11 @@ public final void onDraw(final Canvas canvas) {
// and mRotationConverter to mArrowLines, mArrowBodyLeft/Right,
// the instances were assigned in init().

// draw circle
// draw circle with diameter scaled to length of compass rose arrow
canvas.drawCircle(
mRotationCenter.getCartesianX(),
mRotationCenter.getCartesianY(),
(getHeight() / 2) * (float) ROSE_LENGTH,
((float) getHeight() / 2) * (float) ROSE_LENGTH,
mPaintRoseLines);

// draw compass rose
Expand Down Expand Up @@ -401,8 +401,6 @@ public final void onDraw(final Canvas canvas) {
*/
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void init() {
mMode = NavigationMode.Disabled;

Resources res = getResources();

// Get the screen's density scale
Expand Down
2 changes: 1 addition & 1 deletion src/java/com/github/ruleant/getback_gps/lib/Navigator.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public enum TravelDirection {
/**
* Detected travel direction.
*/
private TravelDirection mTravelDirection;
private TravelDirection mTravelDirection = TravelDirection.Unknown;

/**
* Constructor.
Expand Down

0 comments on commit da54d91

Please sign in to comment.