improve theming 1
This commit is contained in:
parent
c75ca89775
commit
625fbb1aa9
@ -5,33 +5,24 @@ package acr.browser.lightning;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class AboutSettingsActivity extends ActionBarActivity {
|
||||
public class AboutSettingsActivity extends ThemableActivity {
|
||||
|
||||
// mPreferences variables
|
||||
private SharedPreferences mPreferences;
|
||||
private int mEasterEggCounter;
|
||||
private Context mContext;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
|
||||
this.setTheme(R.style.Theme_SettingsTheme_Dark);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.about_settings);
|
||||
|
||||
@ -41,11 +32,6 @@ public class AboutSettingsActivity extends ActionBarActivity {
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
|
||||
mContext = this;
|
||||
initialize();
|
||||
}
|
||||
|
@ -9,12 +9,10 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
@ -22,7 +20,7 @@ import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class AdvancedSettingsActivity extends ActionBarActivity {
|
||||
public class AdvancedSettingsActivity extends ThemableActivity {
|
||||
|
||||
private SharedPreferences mPreferences;
|
||||
private CheckBox cbAllowPopups, cbAllowCookies, cbAllowIncognitoCookies, cbRestoreTabs;
|
||||
@ -34,10 +32,6 @@ public class AdvancedSettingsActivity extends ActionBarActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
|
||||
this.setTheme(R.style.Theme_SettingsTheme_Dark);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.advanced_settings);
|
||||
|
||||
@ -47,11 +41,6 @@ public class AdvancedSettingsActivity extends ActionBarActivity {
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
|
||||
mContext = this;
|
||||
mActivity = this;
|
||||
initialize();
|
||||
@ -64,6 +53,7 @@ public class AdvancedSettingsActivity extends ActionBarActivity {
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
|
||||
RelativeLayout rAllowPopups, rAllowCookies, rAllowIncognitoCookies, rRestoreTabs;
|
||||
LinearLayout lRenderPicker, lUrlContent;
|
||||
|
@ -11,7 +11,6 @@ import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -19,7 +18,7 @@ import android.view.View.OnClickListener;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class BookmarkActivity extends ActionBarActivity implements OnClickListener {
|
||||
public class BookmarkActivity extends ThemableActivity implements OnClickListener {
|
||||
|
||||
private BookmarkManager mBookmarkManager;
|
||||
private boolean mSystemBrowser;
|
||||
@ -31,10 +30,6 @@ public class BookmarkActivity extends ActionBarActivity implements OnClickListen
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
|
||||
this.setTheme(R.style.Theme_SettingsTheme_Dark);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.bookmark_settings);
|
||||
|
||||
@ -52,6 +47,8 @@ public class BookmarkActivity extends ActionBarActivity implements OnClickListen
|
||||
|
||||
mBookmarkManager = new BookmarkManager(this);
|
||||
|
||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
|
||||
mSystemBrowser = mPreferences.getBoolean(PreferenceConstants.SYSTEM_BROWSER_PRESENT, false);
|
||||
|
||||
exportBackup.setOnClickListener(this);
|
||||
@ -63,7 +60,6 @@ public class BookmarkActivity extends ActionBarActivity implements OnClickListen
|
||||
} else {
|
||||
importBookmarks.setText(getResources().getString(R.string.stock_browser_unavailable));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,18 +8,16 @@ import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
public class DisplaySettingsActivity extends ActionBarActivity {
|
||||
public class DisplaySettingsActivity extends ThemableActivity {
|
||||
|
||||
// mPreferences variables
|
||||
private SharedPreferences mPreferences;
|
||||
@ -29,25 +27,19 @@ public class DisplaySettingsActivity extends ActionBarActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
|
||||
this.setTheme(R.style.Theme_SettingsTheme_Dark);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.display_settings);
|
||||
|
||||
mActivity = this;
|
||||
|
||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
|
||||
// set up ActionBar
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
initialize();
|
||||
}
|
||||
|
||||
|
@ -10,14 +10,12 @@ import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
@ -26,7 +24,7 @@ import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class GeneralSettingsActivity extends ActionBarActivity {
|
||||
public class GeneralSettingsActivity extends ThemableActivity {
|
||||
|
||||
// mPreferences variables
|
||||
private static final int API = android.os.Build.VERSION.SDK_INT;
|
||||
@ -44,10 +42,6 @@ public class GeneralSettingsActivity extends ActionBarActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
|
||||
this.setTheme(R.style.Theme_SettingsTheme_Dark);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.general_settings);
|
||||
|
||||
@ -57,13 +51,9 @@ public class GeneralSettingsActivity extends ActionBarActivity {
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
|
||||
// TODO WARNING: SharedPreferences.edit() without a corresponding
|
||||
// commit() or apply() call
|
||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
mEditPrefs = mPreferences.edit();
|
||||
|
||||
mActivity = this;
|
||||
|
@ -4,10 +4,8 @@
|
||||
package acr.browser.lightning;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -17,14 +15,10 @@ import android.view.View;
|
||||
*under which this code is licensed. Unless you plan on providing other attribution in the app to
|
||||
*the original source in another visible way, it is advised against the removal of this Activity.
|
||||
*/
|
||||
public class LicenseActivity extends ActionBarActivity implements View.OnClickListener {
|
||||
public class LicenseActivity extends ThemableActivity implements View.OnClickListener {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
SharedPreferences preferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
if (preferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
|
||||
this.setTheme(R.style.Theme_SettingsTheme_Dark);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.license_activity);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
|
@ -12,12 +12,10 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.provider.Browser;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.*;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
@ -25,7 +23,7 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class PrivacySettingsActivity extends ActionBarActivity {
|
||||
public class PrivacySettingsActivity extends ThemableActivity {
|
||||
|
||||
// mPreferences variables
|
||||
private static final int API = android.os.Build.VERSION.SDK_INT;
|
||||
@ -39,10 +37,6 @@ public class PrivacySettingsActivity extends ActionBarActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
|
||||
this.setTheme(R.style.Theme_SettingsTheme_Dark);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.privacy_settings);
|
||||
|
||||
@ -52,13 +46,9 @@ public class PrivacySettingsActivity extends ActionBarActivity {
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
|
||||
// TODO WARNING: SharedPreferences.edit() without a corresponding
|
||||
// commit() or apply() call
|
||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
mEditPrefs = mPreferences.edit();
|
||||
|
||||
mSystemBrowser = mPreferences.getBoolean(PreferenceConstants.SYSTEM_BROWSER_PRESENT, false);
|
||||
|
@ -15,12 +15,10 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
@ -28,24 +26,18 @@ import android.widget.EditText;
|
||||
import android.widget.RelativeLayout;
|
||||
import info.guardianproject.onionkit.ui.OrbotHelper;
|
||||
|
||||
public class SettingsActivity extends ActionBarActivity {
|
||||
public class SettingsActivity extends ThemableActivity {
|
||||
|
||||
private static int API = android.os.Build.VERSION.SDK_INT;
|
||||
private SharedPreferences.Editor mEditPrefs;
|
||||
private SharedPreferences mPreferences;
|
||||
private Context mContext;
|
||||
private Activity mActivity;
|
||||
private boolean mDark;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
if (mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)) {
|
||||
this.setTheme(R.style.Theme_SettingsTheme_Dark);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.settings);
|
||||
mDark = mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false);
|
||||
mContext = this;
|
||||
mActivity = this;
|
||||
init();
|
||||
@ -57,15 +49,6 @@ public class SettingsActivity extends ActionBarActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (mPreferences != null
|
||||
&& mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false) != mDark) {
|
||||
this.recreate();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public void init() {
|
||||
// set up ActionBar
|
||||
@ -75,11 +58,7 @@ public class SettingsActivity extends ActionBarActivity {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
// mPreferences storage
|
||||
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
|
||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
mEditPrefs = mPreferences.edit();
|
||||
|
||||
// initialize UI
|
||||
|
42
src/acr/browser/lightning/ThemableActivity.java
Normal file
42
src/acr/browser/lightning/ThemableActivity.java
Normal file
@ -0,0 +1,42 @@
|
||||
package acr.browser.lightning;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.WindowManager;
|
||||
|
||||
public abstract class ThemableActivity extends ActionBarActivity {
|
||||
|
||||
private SharedPreferences mPreferences;
|
||||
private boolean mDark;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
mDark = mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false);
|
||||
|
||||
// set the theme
|
||||
if (mDark) {
|
||||
setTheme(R.style.Theme_SettingsTheme_Dark);
|
||||
}
|
||||
|
||||
// set window params
|
||||
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
} else {
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (mPreferences != null
|
||||
&& mPreferences.getBoolean(PreferenceConstants.DARK_THEME,
|
||||
false) != mDark) {
|
||||
this.recreate();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user