Cleaning up settings
This commit is contained in:
parent
0183a66e1e
commit
7521415e94
@ -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 {
|
||||
@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 {
|
||||
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
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user