mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-26 00:48:51 -05:00
get rid of two consolidate number preferences
This commit is contained in:
parent
a91468565f
commit
04c8d42436
@ -80,8 +80,6 @@ public final class Constants {
|
|||||||
public static final String FIRST_TIME = "firstTime";
|
public static final String FIRST_TIME = "firstTime";
|
||||||
public static final String SHOW_ADVANCED_TABS = "showAdvancedTabs";
|
public static final String SHOW_ADVANCED_TABS = "showAdvancedTabs";
|
||||||
public static final String CACHED_CONSOLIDATE = "cachedConsolidate";
|
public static final String CACHED_CONSOLIDATE = "cachedConsolidate";
|
||||||
public static final String CACHED_CONSOLIDATE_SECRETS = "cachedConsolidateSecrets";
|
|
||||||
public static final String CACHED_CONSOLIDATE_PUBLICS = "cachedConsolidatePublics";
|
|
||||||
public static final String SEARCH_KEYSERVER = "search_keyserver_pref";
|
public static final String SEARCH_KEYSERVER = "search_keyserver_pref";
|
||||||
public static final String SEARCH_KEYBASE = "search_keybase_pref";
|
public static final String SEARCH_KEYBASE = "search_keybase_pref";
|
||||||
public static final String USE_DEFAULT_YUBIKEY_PIN = "useDefaultYubikeyPin";
|
public static final String USE_DEFAULT_YUBIKEY_PIN = "useDefaultYubikeyPin";
|
||||||
|
@ -925,8 +925,6 @@ public class ProviderHelper {
|
|||||||
return new ConsolidateResult(ConsolidateResult.RESULT_ERROR, mLog);
|
return new ConsolidateResult(ConsolidateResult.RESULT_ERROR, mLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
Preferences.getPreferences(mContext).setCachedConsolidateNumSecrets(cursor.getCount());
|
|
||||||
|
|
||||||
ParcelableFileCache<ParcelableKeyRing> cache =
|
ParcelableFileCache<ParcelableKeyRing> cache =
|
||||||
new ParcelableFileCache<ParcelableKeyRing>(mContext, "consolidate_secret.pcl");
|
new ParcelableFileCache<ParcelableKeyRing>(mContext, "consolidate_secret.pcl");
|
||||||
cache.writeCache(cursor.getCount(), new Iterator<ParcelableKeyRing>() {
|
cache.writeCache(cursor.getCount(), new Iterator<ParcelableKeyRing>() {
|
||||||
@ -987,8 +985,6 @@ public class ProviderHelper {
|
|||||||
return new ConsolidateResult(ConsolidateResult.RESULT_ERROR, mLog);
|
return new ConsolidateResult(ConsolidateResult.RESULT_ERROR, mLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
Preferences.getPreferences(mContext).setCachedConsolidateNumPublics(cursor.getCount());
|
|
||||||
|
|
||||||
ParcelableFileCache<ParcelableKeyRing> cache =
|
ParcelableFileCache<ParcelableKeyRing> cache =
|
||||||
new ParcelableFileCache<ParcelableKeyRing>(mContext, "consolidate_public.pcl");
|
new ParcelableFileCache<ParcelableKeyRing>(mContext, "consolidate_public.pcl");
|
||||||
cache.writeCache(cursor.getCount(), new Iterator<ParcelableKeyRing>() {
|
cache.writeCache(cursor.getCount(), new Iterator<ParcelableKeyRing>() {
|
||||||
@ -1057,16 +1053,8 @@ public class ProviderHelper {
|
|||||||
try {
|
try {
|
||||||
Preferences prefs = Preferences.getPreferences(mContext);
|
Preferences prefs = Preferences.getPreferences(mContext);
|
||||||
|
|
||||||
// Set flag that we have a cached consolidation here
|
|
||||||
int numSecrets = prefs.getCachedConsolidateNumSecrets();
|
|
||||||
int numPublics = prefs.getCachedConsolidateNumPublics();
|
|
||||||
|
|
||||||
if (recovery) {
|
if (recovery) {
|
||||||
if (numSecrets >= 0 && numPublics >= 0) {
|
log(LogType.MSG_CON_RECOVER);
|
||||||
log(LogType.MSG_CON_RECOVER, numSecrets, numPublics);
|
|
||||||
} else {
|
|
||||||
log(LogType.MSG_CON_RECOVER_UNKNOWN);
|
|
||||||
}
|
|
||||||
mIndent += 1;
|
mIndent += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1084,14 +1072,24 @@ public class ProviderHelper {
|
|||||||
ParcelableFileCache<ParcelableKeyRing> cachePublic =
|
ParcelableFileCache<ParcelableKeyRing> cachePublic =
|
||||||
new ParcelableFileCache<ParcelableKeyRing>(mContext, "consolidate_public.pcl");
|
new ParcelableFileCache<ParcelableKeyRing>(mContext, "consolidate_public.pcl");
|
||||||
|
|
||||||
// 3. Re-Import secret keyrings from cache
|
// Set flag that we have a cached consolidation here
|
||||||
if (numSecrets > 0) try {
|
try {
|
||||||
|
Iterator<ParcelableKeyRing> itSecrets = cacheSecret.readCache(false);
|
||||||
|
int numSecrets = cacheSecret.getNumEntries();
|
||||||
|
|
||||||
log(LogType.MSG_CON_REIMPORT_SECRET, numSecrets);
|
log(LogType.MSG_CON_REIMPORT_SECRET, numSecrets);
|
||||||
mIndent += 1;
|
mIndent += 1;
|
||||||
|
|
||||||
|
// 3. Re-Import secret keyrings from cache
|
||||||
|
if (numSecrets > 0) {
|
||||||
|
|
||||||
new PgpImportExport(mContext, this,
|
new PgpImportExport(mContext, this,
|
||||||
new ProgressFixedScaler(progress, 10, 25, 100, R.string.progress_con_reimport))
|
new ProgressFixedScaler(progress, 10, 25, 100, R.string.progress_con_reimport))
|
||||||
.importKeyRings(cacheSecret.readCache(false), numSecrets);
|
.importKeyRings(itSecrets, numSecrets);
|
||||||
|
} else {
|
||||||
|
log(LogType.MSG_CON_REIMPORT_SECRET_SKIP);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(Constants.TAG, "error importing secret", e);
|
Log.e(Constants.TAG, "error importing secret", e);
|
||||||
log(LogType.MSG_CON_ERROR_SECRET);
|
log(LogType.MSG_CON_ERROR_SECRET);
|
||||||
@ -1099,18 +1097,25 @@ public class ProviderHelper {
|
|||||||
} finally {
|
} finally {
|
||||||
mIndent -= 1;
|
mIndent -= 1;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
log(LogType.MSG_CON_REIMPORT_SECRET_SKIP);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. Re-Import public keyrings from cache
|
try {
|
||||||
if (numPublics > 0) try {
|
|
||||||
|
Iterator<ParcelableKeyRing> itPublics = cachePublic.readCache();
|
||||||
|
int numPublics = cachePublic.getNumEntries();
|
||||||
|
|
||||||
log(LogType.MSG_CON_REIMPORT_PUBLIC, numPublics);
|
log(LogType.MSG_CON_REIMPORT_PUBLIC, numPublics);
|
||||||
mIndent += 1;
|
mIndent += 1;
|
||||||
|
|
||||||
|
// 4. Re-Import public keyrings from cache
|
||||||
|
if (numPublics > 0) {
|
||||||
|
|
||||||
new PgpImportExport(mContext, this,
|
new PgpImportExport(mContext, this,
|
||||||
new ProgressFixedScaler(progress, 25, 99, 100, R.string.progress_con_reimport))
|
new ProgressFixedScaler(progress, 25, 99, 100, R.string.progress_con_reimport))
|
||||||
.importKeyRings(cachePublic.readCache(false), numPublics);
|
.importKeyRings(itPublics, numPublics);
|
||||||
|
} else {
|
||||||
|
log(LogType.MSG_CON_REIMPORT_PUBLIC_SKIP);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(Constants.TAG, "error importing public", e);
|
Log.e(Constants.TAG, "error importing public", e);
|
||||||
log(LogType.MSG_CON_ERROR_PUBLIC);
|
log(LogType.MSG_CON_ERROR_PUBLIC);
|
||||||
@ -1118,9 +1123,6 @@ public class ProviderHelper {
|
|||||||
} finally {
|
} finally {
|
||||||
mIndent -= 1;
|
mIndent -= 1;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
log(LogType.MSG_CON_REIMPORT_PUBLIC_SKIP);
|
|
||||||
}
|
|
||||||
|
|
||||||
log(LogType.MSG_CON_CRITICAL_OUT);
|
log(LogType.MSG_CON_CRITICAL_OUT);
|
||||||
Preferences.getPreferences(mContext).setCachedConsolidate(false);
|
Preferences.getPreferences(mContext).setCachedConsolidate(false);
|
||||||
|
@ -439,7 +439,6 @@ public abstract class OperationResult implements Parcelable {
|
|||||||
MSG_CON_ERROR_PUBLIC (LogLevel.ERROR, R.string.msg_con_error_public),
|
MSG_CON_ERROR_PUBLIC (LogLevel.ERROR, R.string.msg_con_error_public),
|
||||||
MSG_CON_ERROR_SECRET (LogLevel.ERROR, R.string.msg_con_error_secret),
|
MSG_CON_ERROR_SECRET (LogLevel.ERROR, R.string.msg_con_error_secret),
|
||||||
MSG_CON_RECOVER (LogLevel.DEBUG, R.plurals.msg_con_recover),
|
MSG_CON_RECOVER (LogLevel.DEBUG, R.plurals.msg_con_recover),
|
||||||
MSG_CON_RECOVER_UNKNOWN (LogLevel.DEBUG, R.string.msg_con_recover_unknown),
|
|
||||||
MSG_CON_REIMPORT_PUBLIC (LogLevel.DEBUG, R.plurals.msg_con_reimport_public),
|
MSG_CON_REIMPORT_PUBLIC (LogLevel.DEBUG, R.plurals.msg_con_reimport_public),
|
||||||
MSG_CON_REIMPORT_PUBLIC_SKIP (LogLevel.DEBUG, R.string.msg_con_reimport_public_skip),
|
MSG_CON_REIMPORT_PUBLIC_SKIP (LogLevel.DEBUG, R.string.msg_con_reimport_public_skip),
|
||||||
MSG_CON_REIMPORT_SECRET (LogLevel.DEBUG, R.plurals.msg_con_reimport_secret),
|
MSG_CON_REIMPORT_SECRET (LogLevel.DEBUG, R.plurals.msg_con_reimport_secret),
|
||||||
|
@ -177,26 +177,6 @@ public class Preferences {
|
|||||||
editor.commit();
|
editor.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCachedConsolidateNumPublics() {
|
|
||||||
return mSharedPreferences.getInt(Pref.CACHED_CONSOLIDATE_PUBLICS, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCachedConsolidateNumPublics(int value) {
|
|
||||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
|
||||||
editor.putInt(Pref.CACHED_CONSOLIDATE_PUBLICS, value);
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCachedConsolidateNumSecrets() {
|
|
||||||
return mSharedPreferences.getInt(Pref.CACHED_CONSOLIDATE_SECRETS, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCachedConsolidateNumSecrets(int value) {
|
|
||||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
|
||||||
editor.putInt(Pref.CACHED_CONSOLIDATE_SECRETS, value);
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFirstTime() {
|
public boolean isFirstTime() {
|
||||||
return mSharedPreferences.getBoolean(Constants.Pref.FIRST_TIME, true);
|
return mSharedPreferences.getBoolean(Constants.Pref.FIRST_TIME, true);
|
||||||
}
|
}
|
||||||
|
@ -790,10 +790,7 @@
|
|||||||
<string name="msg_con_error_io_secret">"IO error writing secret keys to cache!"</string>
|
<string name="msg_con_error_io_secret">"IO error writing secret keys to cache!"</string>
|
||||||
<string name="msg_con_error_public">"Error reimporting public keys!"</string>
|
<string name="msg_con_error_public">"Error reimporting public keys!"</string>
|
||||||
<string name="msg_con_error_secret">"Error reimporting secret keys!"</string>
|
<string name="msg_con_error_secret">"Error reimporting secret keys!"</string>
|
||||||
<plurals name="msg_con_recover">
|
<string name="msg_con_recover">"Recovering consolidation"</string>
|
||||||
<item quantity="one">"Recovering consolidation with %1$d secret and %2$d public keys"</item>
|
|
||||||
<item quantity="other">"Recovering consolidation with %1$d secret and %2$d public keys"</item>
|
|
||||||
</plurals>
|
|
||||||
<string name="msg_con_recover_unknown">"Recovering from unknown state"</string>
|
<string name="msg_con_recover_unknown">"Recovering from unknown state"</string>
|
||||||
<plurals name="msg_con_reimport_public">
|
<plurals name="msg_con_reimport_public">
|
||||||
<item quantity="one">"Reimporting one public key"</item>
|
<item quantity="one">"Reimporting one public key"</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user