From 7521415e942a383de95ba078b6a68a6ac23de78d Mon Sep 17 00:00:00 2001 From: anthony restaino Date: Mon, 26 Jun 2017 23:09:47 -0400 Subject: [PATCH] Cleaning up settings --- .../settings/activity/SettingsActivity.java | 12 ++++++------ .../settings/fragment/AboutSettingsFragment.java | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/settings/activity/SettingsActivity.java b/app/src/main/java/acr/browser/lightning/settings/activity/SettingsActivity.java index 8671c5b..687e9a3 100644 --- a/app/src/main/java/acr/browser/lightning/settings/activity/SettingsActivity.java +++ b/app/src/main/java/acr/browser/lightning/settings/activity/SettingsActivity.java @@ -23,12 +23,12 @@ import acr.browser.lightning.BrowserApp; public class SettingsActivity extends ThemableSettingsActivity { - @NonNull private static final List mFragments = new ArrayList<>(7); + @NonNull private static final List sFragments = new ArrayList<>(7); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // this is a workaround for the Toolbar in PreferenceActitivty + // this is a workaround for the Toolbar in PreferenceActivity ViewGroup root = findViewById(android.R.id.content); LinearLayout content = (LinearLayout) root.getChildAt(0); LinearLayout toolbarContainer = (LinearLayout) View.inflate(this, R.layout.toolbar_settings, null); @@ -46,7 +46,7 @@ public class SettingsActivity extends ThemableSettingsActivity { @Override public void onBuildHeaders(List
target) { loadHeadersFromResource(R.xml.preferences_headers, target); - mFragments.clear(); + sFragments.clear(); Iterator
headerIterator = target.iterator(); while (headerIterator.hasNext()) { Header header = headerIterator.next(); @@ -59,17 +59,17 @@ public class SettingsActivity extends ThemableSettingsActivity { if (BrowserApp.isRelease()) { headerIterator.remove(); } else { - mFragments.add(header.fragment); + sFragments.add(header.fragment); } } else { - mFragments.add(header.fragment); + sFragments.add(header.fragment); } } } @Override protected boolean isValidFragment(String fragmentName) { - return mFragments.contains(fragmentName); + return sFragments.contains(fragmentName); } @Override diff --git a/app/src/main/java/acr/browser/lightning/settings/fragment/AboutSettingsFragment.java b/app/src/main/java/acr/browser/lightning/settings/fragment/AboutSettingsFragment.java index 2cf9bf1..483e253 100644 --- a/app/src/main/java/acr/browser/lightning/settings/fragment/AboutSettingsFragment.java +++ b/app/src/main/java/acr/browser/lightning/settings/fragment/AboutSettingsFragment.java @@ -9,13 +9,13 @@ import android.content.pm.PackageManager; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceFragment; +import android.util.Log; import acr.browser.lightning.R; public class AboutSettingsFragment extends PreferenceFragment { - private Activity mActivity; - + private static final String TAG = "AboutSettingsFragment"; private static final String SETTINGS_VERSION = "pref_version"; @Override @@ -24,18 +24,18 @@ public class AboutSettingsFragment extends PreferenceFragment { // Load the preferences from an XML resource addPreferencesFromResource(R.xml.preference_about); - mActivity = getActivity(); - Preference version = findPreference(SETTINGS_VERSION); version.setSummary(getVersion()); } private String getVersion() { try { - PackageInfo p = mActivity.getPackageManager().getPackageInfo(mActivity.getPackageName(), 0); - return p.versionName; + Activity activity = getActivity(); + String packageName = activity.getPackageName(); + PackageInfo packageInfo = activity.getPackageManager().getPackageInfo(packageName, 0); + return packageInfo.versionName; } catch (PackageManager.NameNotFoundException e) { - e.printStackTrace(); + Log.e(TAG, "getVersion: error", e); return "1.0"; } }