mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
finally read APG version dynamicly, so the version name doesn't have to be changed anywhere but the manifest
This commit is contained in:
parent
ce1120b66e
commit
315093c5bc
@ -40,6 +40,7 @@ import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
import java.util.regex.Pattern;
|
||||
@ -91,14 +92,18 @@ import org.thialfihar.android.apg.utils.IterableIterator;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class Apg {
|
||||
private static final String mApgPackageName = "org.thialfihar.android.apg";
|
||||
|
||||
public static class Intent {
|
||||
public static final String DECRYPT = "org.thialfihar.android.apg.intent.DECRYPT";
|
||||
public static final String ENCRYPT = "org.thialfihar.android.apg.intent.ENCRYPT";
|
||||
@ -150,8 +155,8 @@ public class Apg {
|
||||
public static final Uri CONTENT_URI_PUBLIC_KEY_RING_BY_EMAILS =
|
||||
Uri.parse("content://" + AUTHORITY + "/key_rings/public/emails/");
|
||||
|
||||
public static String VERSION = "1.0.1";
|
||||
public static String FULL_VERSION = "APG v" + VERSION;
|
||||
private static String VERSION = null;
|
||||
private static String FULL_VERSION = null;
|
||||
|
||||
private static final int[] PREFERRED_SYMMETRIC_ALGORITHMS =
|
||||
new int[] {
|
||||
@ -1831,4 +1836,30 @@ public class Apg {
|
||||
|
||||
return nlBytes;
|
||||
}
|
||||
|
||||
public static String getVersion(Context context) {
|
||||
if (VERSION != null) {
|
||||
return VERSION;
|
||||
}
|
||||
List<PackageInfo> packs = context.getPackageManager().getInstalledPackages(0);
|
||||
for (int i = 0; i < packs.size(); ++i) {
|
||||
PackageInfo p = packs.get(i);
|
||||
if (!p.packageName.equals(mApgPackageName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
VERSION = p.versionName;
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
// unpossible!
|
||||
return "0.0.0";
|
||||
}
|
||||
|
||||
public static String getFullVersion(Context context) {
|
||||
if (FULL_VERSION == null) {
|
||||
FULL_VERSION = "APG v" + getVersion(context);
|
||||
}
|
||||
return FULL_VERSION;
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ public class BaseActivity extends Activity
|
||||
case Id.dialog.about: {
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
|
||||
alert.setTitle("About " + Apg.FULL_VERSION);
|
||||
alert.setTitle("About " + Apg.getFullVersion(this));
|
||||
|
||||
LayoutInflater inflater =
|
||||
(LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
@ -448,12 +448,13 @@ public class BaseActivity extends Activity
|
||||
}
|
||||
|
||||
public boolean hasSeenChangeLog() {
|
||||
return mPreferences.getBoolean(Constants.pref.has_seen_change_log, false);
|
||||
return mPreferences.getBoolean(Constants.pref.has_seen_change_log + Apg.getVersion(this),
|
||||
false);
|
||||
}
|
||||
|
||||
public void setHasSeenChangeLog(boolean value) {
|
||||
SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(Constants.pref.has_seen_change_log, value);
|
||||
editor.putBoolean(Constants.pref.has_seen_change_log + Apg.getVersion(this), value);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ public final class Constants {
|
||||
}
|
||||
|
||||
public static final class pref {
|
||||
public static final String has_seen_change_log = "seenChangeLogDialog" + Apg.VERSION;
|
||||
public static final String has_seen_change_log = "seenChangeLogDialog";
|
||||
public static final String default_encryption_algorithm = "defaultEncryptionAlgorithm";
|
||||
public static final String default_hash_algorithm = "defaultHashAlgorithm";
|
||||
public static final String default_ascii_armour = "defaultAsciiArmour";
|
||||
|
@ -183,7 +183,7 @@ public class MainActivity extends BaseActivity {
|
||||
case Id.dialog.change_log: {
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
|
||||
alert.setTitle("Changes " + Apg.FULL_VERSION);
|
||||
alert.setTitle("Changes " + Apg.getFullVersion(this));
|
||||
LayoutInflater inflater =
|
||||
(LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View layout = inflater.inflate(R.layout.info, null);
|
||||
|
Loading…
Reference in New Issue
Block a user