This repository has been archived by the owner on Feb 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Version Preference for Settings activity
- Loading branch information
Showing
4 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...sealnote/internal/PasswordPreference.java → ...sealnote/settings/PasswordPreference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
Sealnote/src/main/java/com/twistedplane/sealnote/settings/VersionPreference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.twistedplane.sealnote.settings; | ||
|
||
import android.content.Context; | ||
import android.content.pm.PackageInfo; | ||
import android.content.pm.PackageManager; | ||
import android.preference.Preference; | ||
import android.util.AttributeSet; | ||
import com.twistedplane.sealnote.R; | ||
|
||
public class VersionPreference extends Preference { | ||
public VersionPreference(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
String version = ""; | ||
|
||
final PackageManager packageManager = context.getPackageManager(); | ||
if (packageManager != null) { | ||
try { | ||
PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0); | ||
version = String.format("%s (#%d)", packageInfo.versionName, packageInfo.versionCode); | ||
} catch (PackageManager.NameNotFoundException e) { | ||
// | ||
} | ||
setSummary(version); | ||
setTitle(R.string.version); | ||
setPersistent(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters