Skip to content

Commit

Permalink
Bump version, add version display to settings menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Klaus Weidner committed Nov 21, 2018
1 parent e3179ce commit 9a3695d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId 'org.pocketworkstation.pckeyboard'
minSdkVersion 14
targetSdkVersion 26
versionCode 1040001
versionName "v1.40.1"
versionCode 1040002
versionName "v1.40.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import android.app.backup.BackupManager;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.content.res.Resources;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
Expand Down Expand Up @@ -55,6 +58,8 @@ public class LatinIMESettings extends PreferenceActivity
private ListPreference mKeyboardModePortraitPreference;
private ListPreference mKeyboardModeLandscapePreference;
private Preference mInputConnectionInfo;
private Preference mLabelVersion;

private boolean mVoiceOn;

private boolean mOkClicked = false;
Expand All @@ -68,6 +73,8 @@ protected void onCreate(Bundle icicle) {
mVoicePreference = (ListPreference) findPreference(VOICE_SETTINGS_KEY);
mSettingsKeyPreference = (ListPreference) findPreference(PREF_SETTINGS_KEY);
mInputConnectionInfo = (Preference) findPreference(INPUT_CONNECTION_INFO);
mLabelVersion = (Preference) findPreference("label_version");


// TODO(klausw): remove these when no longer needed
mKeyboardModePortraitPreference = (ListPreference) findPreference("pref_keyboard_mode_portrait");
Expand Down Expand Up @@ -105,6 +112,30 @@ protected void onResume() {
}

updateSummaries();

String version = "";
try {
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
version = info.versionName;
boolean isOfficial = false;
for (Signature sig : info.signatures) {
byte[] b = sig.toByteArray();
int out = 0;
for (int i = 0; i < b.length; ++i) {
int pos = i % 4;
out ^= b[i] << (pos * 4);
}
if (out == -466825) {
isOfficial = true;
}
//version += " [" + Integer.toHexString(out) + "]";
}
version += isOfficial ? " official" : " custom";
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Could not find version info.");
}

mLabelVersion.setSummary(version);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;

public class PrefScreenView extends PreferenceActivity
Expand Down Expand Up @@ -54,6 +55,5 @@ protected void onResume() {
mRenderModePreference.setEnabled(false);
mRenderModePreference.setSummary(R.string.render_mode_unavailable);
}

}
}

0 comments on commit 9a3695d

Please sign in to comment.