Browse Source

Cleaning up settings

master
anthony restaino 8 years ago
parent
commit
7521415e94
  1. 12
      app/src/main/java/acr/browser/lightning/settings/activity/SettingsActivity.java
  2. 14
      app/src/main/java/acr/browser/lightning/settings/fragment/AboutSettingsFragment.java

12
app/src/main/java/acr/browser/lightning/settings/activity/SettingsActivity.java

@ -23,12 +23,12 @@ import acr.browser.lightning.BrowserApp; @@ -23,12 +23,12 @@ import acr.browser.lightning.BrowserApp;
public class SettingsActivity extends ThemableSettingsActivity {
@NonNull private static final List<String> mFragments = new ArrayList<>(7);
@NonNull private static final List<String> 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 { @@ -46,7 +46,7 @@ public class SettingsActivity extends ThemableSettingsActivity {
@Override
public void onBuildHeaders(List<Header> target) {
loadHeadersFromResource(R.xml.preferences_headers, target);
mFragments.clear();
sFragments.clear();
Iterator<Header> headerIterator = target.iterator();
while (headerIterator.hasNext()) {
Header header = headerIterator.next();
@ -59,17 +59,17 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -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

14
app/src/main/java/acr/browser/lightning/settings/fragment/AboutSettingsFragment.java

@ -9,13 +9,13 @@ import android.content.pm.PackageManager; @@ -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 { @@ -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";
}
}

Loading…
Cancel
Save