fix theme on BrowserActivity
there should be only one ThemableActivity but there are two dark themes - one for settings and on for BrowserActivity
This commit is contained in:
parent
2551b3dc27
commit
addaa3b2b3
@ -16,7 +16,7 @@ import android.view.View.OnClickListener;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class AboutSettingsActivity extends ThemableActivity {
|
||||
public class AboutSettingsActivity extends ThemableSettingsActivity {
|
||||
|
||||
private int mEasterEggCounter;
|
||||
private Context mContext;
|
||||
|
@ -20,7 +20,7 @@ import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class AdvancedSettingsActivity extends ThemableActivity {
|
||||
public class AdvancedSettingsActivity extends ThemableSettingsActivity {
|
||||
|
||||
private SharedPreferences mPreferences;
|
||||
private CheckBox cbAllowPopups, cbAllowCookies, cbAllowIncognitoCookies, cbRestoreTabs;
|
||||
|
@ -18,7 +18,7 @@ import android.view.View.OnClickListener;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class BookmarkActivity extends ThemableActivity implements OnClickListener {
|
||||
public class BookmarkActivity extends ThemableSettingsActivity implements OnClickListener {
|
||||
|
||||
private BookmarkManager mBookmarkManager;
|
||||
private boolean mSystemBrowser;
|
||||
|
@ -641,6 +641,12 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
|
||||
mBrowserFrame.removeView(mToolbarLayout);
|
||||
mUiLayout.addView(mToolbarLayout, 0);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
switch (mPreferences.getInt(PreferenceConstants.SEARCH, 1)) {
|
||||
case 0:
|
||||
@ -1374,6 +1380,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
supportInvalidateOptionsMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,6 @@
|
||||
*/
|
||||
package acr.browser.lightning;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
@ -17,21 +16,18 @@ import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
public class DisplaySettingsActivity extends ThemableActivity {
|
||||
public class DisplaySettingsActivity extends ThemableSettingsActivity {
|
||||
|
||||
// mPreferences variables
|
||||
private SharedPreferences mPreferences;
|
||||
private CheckBox cbHideStatusBar, cbFullScreen, cbWideViewPort, cbOverView, cbTextReflow,
|
||||
cbDarkTheme;
|
||||
private Activity mActivity;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.display_settings);
|
||||
|
||||
mActivity = this;
|
||||
|
||||
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||
|
||||
// set up ActionBar
|
||||
|
@ -24,7 +24,7 @@ import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class GeneralSettingsActivity extends ThemableActivity {
|
||||
public class GeneralSettingsActivity extends ThemableSettingsActivity {
|
||||
|
||||
// mPreferences variables
|
||||
private static final int API = android.os.Build.VERSION.SDK_INT;
|
||||
|
@ -15,7 +15,7 @@ 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 ThemableActivity implements View.OnClickListener {
|
||||
public class LicenseActivity extends ThemableSettingsActivity implements View.OnClickListener {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -23,7 +23,7 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class PrivacySettingsActivity extends ThemableActivity {
|
||||
public class PrivacySettingsActivity extends ThemableSettingsActivity {
|
||||
|
||||
// mPreferences variables
|
||||
private static final int API = android.os.Build.VERSION.SDK_INT;
|
||||
|
@ -26,7 +26,7 @@ import android.widget.EditText;
|
||||
import android.widget.RelativeLayout;
|
||||
import info.guardianproject.onionkit.ui.OrbotHelper;
|
||||
|
||||
public class SettingsActivity extends ThemableActivity {
|
||||
public class SettingsActivity extends ThemableSettingsActivity {
|
||||
|
||||
private static int API = android.os.Build.VERSION.SDK_INT;
|
||||
private SharedPreferences.Editor mEditPrefs;
|
||||
|
@ -4,7 +4,6 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.WindowManager;
|
||||
|
||||
public abstract class ThemableActivity extends ActionBarActivity {
|
||||
|
||||
@ -18,15 +17,7 @@ public abstract class ThemableActivity extends ActionBarActivity {
|
||||
|
||||
// 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);
|
||||
setTheme(R.style.Theme_DarkTheme);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
43
src/acr/browser/lightning/ThemableSettingsActivity.java
Normal file
43
src/acr/browser/lightning/ThemableSettingsActivity.java
Normal file
@ -0,0 +1,43 @@
|
||||
package acr.browser.lightning;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
|
||||
public abstract class ThemableSettingsActivity 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);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (mPreferences != null
|
||||
&& mPreferences.getBoolean(PreferenceConstants.DARK_THEME,
|
||||
false) != mDark) {
|
||||
restart();
|
||||
}
|
||||
}
|
||||
|
||||
protected void restart() {
|
||||
final Bundle outState = new Bundle();
|
||||
onSaveInstanceState(outState);
|
||||
final Intent intent = new Intent(this, getClass());
|
||||
finish();
|
||||
overridePendingTransition(0, 0);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user