From c6b25745b7cf1d540a380a84658db1f0111dda3c Mon Sep 17 00:00:00 2001 From: AndyScherzinger Date: Wed, 15 Aug 2018 16:27:48 +0200 Subject: [PATCH] cleanup code, use own preference manager --- .../authentication/AuthenticatorActivity.java | 2 -- .../android/ui/activity/FirstRunActivity.java | 13 ++++--------- .../android/ui/activity/WhatsNewActivity.java | 4 ++-- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java index ee42a4436e..7089788f9c 100644 --- a/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -1192,7 +1192,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity * * @param hasFocus 'True' if focus is received, 'false' if is lost */ - private void onPasswordFocusChanged(boolean hasFocus) { if (hasFocus) { showViewPasswordButton(); @@ -1202,7 +1201,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity } } - private void showViewPasswordButton() { int drawable = R.drawable.ic_view; if (isPasswordVisible()) { diff --git a/src/main/java/com/owncloud/android/ui/activity/FirstRunActivity.java b/src/main/java/com/owncloud/android/ui/activity/FirstRunActivity.java index f3f69c5814..f6ab93c9a0 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FirstRunActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FirstRunActivity.java @@ -26,12 +26,10 @@ import android.accounts.Account; import android.accounts.AccountManager; import android.content.Context; import android.content.Intent; -import android.content.SharedPreferences; import android.content.res.Configuration; import android.graphics.Color; import android.net.Uri; import android.os.Bundle; -import android.preference.PreferenceManager; import android.support.v4.view.ViewPager; import android.view.View; import android.view.ViewGroup; @@ -43,6 +41,7 @@ import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.authentication.AuthenticatorActivity; +import com.owncloud.android.db.PreferenceManager; import com.owncloud.android.features.FeatureItem; import com.owncloud.android.ui.adapter.FeaturesViewAdapter; import com.owncloud.android.ui.whatsnew.ProgressIndicator; @@ -53,7 +52,6 @@ import com.owncloud.android.utils.DisplayUtils; */ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageChangeListener { - public static final String KEY_LAST_SEEN_VERSION_CODE = "lastSeenVersionCode"; public static final String EXTRA_ALLOW_CLOSE = "ALLOW_CLOSE"; public static final int FIRST_RUN_RESULT_CODE = 199; @@ -162,17 +160,14 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh } private void onFinish() { - SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); - SharedPreferences.Editor editor = pref.edit(); - editor.putInt(KEY_LAST_SEEN_VERSION_CODE, MainApp.getVersionCode()); - editor.apply(); + PreferenceManager.setLastSeenVersionCode(this, MainApp.getVersionCode()); } - static private boolean isFirstRun(Context context) { + private static boolean isFirstRun(Context context) { return AccountUtils.getCurrentOwnCloudAccount(context) == null; } - static public boolean runIfNeeded(Context context) { + public static boolean runIfNeeded(Context context) { if (context instanceof FirstRunActivity) { return false; } diff --git a/src/main/java/com/owncloud/android/ui/activity/WhatsNewActivity.java b/src/main/java/com/owncloud/android/ui/activity/WhatsNewActivity.java index 5dbc88817f..773d70595e 100644 --- a/src/main/java/com/owncloud/android/ui/activity/WhatsNewActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/WhatsNewActivity.java @@ -138,7 +138,7 @@ public class WhatsNewActivity extends FragmentActivity implements ViewPager.OnPa PreferenceManager.setLastSeenVersionCode(this, MainApp.getVersionCode()); } - static public void runIfNeeded(Context context) { + public static void runIfNeeded(Context context) { if (!context.getResources().getBoolean(R.bool.show_whats_new) || context instanceof WhatsNewActivity) { return; @@ -149,7 +149,7 @@ public class WhatsNewActivity extends FragmentActivity implements ViewPager.OnPa } } - static private boolean shouldShow(Context context) { + private static boolean shouldShow(Context context) { return !(context instanceof PassCodeActivity) && getWhatsNew(context).length > 0; }