Merge "Clean up logic in onUserLoggingConsent"

This commit is contained in:
Kurt Partridge 2013-03-05 16:43:07 +00:00 committed by Android (Google) Code Review
commit 60f51684f1
2 changed files with 17 additions and 17 deletions

View file

@ -125,7 +125,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
/* package */ static boolean sIsLogging = false;
private static final int OUTPUT_FORMAT_VERSION = 5;
private static final String PREF_USABILITY_STUDY_MODE = "usability_study_mode";
private static final String PREF_RESEARCH_HAS_SEEN_SPLASH = "pref_research_has_seen_splash";
/* package */ static final String LOG_FILENAME_PREFIX = "researchLog";
private static final String LOG_FILENAME_SUFFIX = ".txt";
/* package */ static final String USER_RECORDING_FILENAME_PREFIX = "recording";
@ -321,14 +320,10 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
}
}
private boolean hasSeenSplash() {
return mPrefs.getBoolean(PREF_RESEARCH_HAS_SEEN_SPLASH, false);
}
private Dialog mSplashDialog = null;
private void maybeShowSplashScreen() {
if (hasSeenSplash()) {
if (ResearchSettings.readHasSeenSplash(mPrefs)) {
return;
}
if (mSplashDialog != null && mSplashDialog.isShowing()) {
@ -381,22 +376,16 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
}
public void onUserLoggingConsent() {
setLoggingAllowed(true);
if (mPrefs == null) {
return;
mPrefs = PreferenceManager.getDefaultSharedPreferences(mLatinIME);
if (mPrefs == null) return;
}
final Editor e = mPrefs.edit();
e.putBoolean(PREF_RESEARCH_HAS_SEEN_SPLASH, true);
e.apply();
sIsLogging = true;
ResearchSettings.writeResearchLoggerEnabledFlag(mPrefs, true);
ResearchSettings.writeHasSeenSplash(mPrefs, true);
restart();
}
private void setLoggingAllowed(final boolean enableLogging) {
if (mPrefs == null) return;
ResearchSettings.writeResearchLoggerEnabledFlag(mPrefs, enableLogging);
sIsLogging = enableLogging;
}
private static int sLogFileCounter = 0;
private File createLogFile(final File filesDir) {

View file

@ -24,6 +24,8 @@ public final class ResearchSettings {
public static final String PREF_RESEARCH_LOGGER_UUID = "pref_research_logger_uuid";
public static final String PREF_RESEARCH_LOGGER_ENABLED_FLAG =
"pref_research_logger_enabled_flag";
public static final String PREF_RESEARCH_LOGGER_HAS_SEEN_SPLASH =
"pref_research_logger_has_seen_splash";
private ResearchSettings() {
// Intentional empty constructor for singleton.
@ -47,4 +49,13 @@ public final class ResearchSettings {
final boolean isEnabled) {
prefs.edit().putBoolean(PREF_RESEARCH_LOGGER_ENABLED_FLAG, isEnabled).apply();
}
public static boolean readHasSeenSplash(final SharedPreferences prefs) {
return prefs.getBoolean(PREF_RESEARCH_LOGGER_HAS_SEEN_SPLASH, false);
}
public static void writeHasSeenSplash(final SharedPreferences prefs,
final boolean hasSeenSplash) {
prefs.edit().putBoolean(PREF_RESEARCH_LOGGER_HAS_SEEN_SPLASH, hasSeenSplash).apply();
}
}