Fix theme bugs
This commit is contained in:
parent
483d5ab495
commit
d14e0b2ed3
|
@ -56,9 +56,6 @@ public class HelpAboutFragment extends Fragment {
|
|||
Log.e(Constants.TAG, "IOException", e);
|
||||
}
|
||||
|
||||
// no flickering when clicking textview for Android < 4
|
||||
aboutTextView.setTextColor(getResources().getColor(android.R.color.black));
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,9 +73,6 @@ public class HelpMarkdownFragment extends Fragment {
|
|||
Log.e(Constants.TAG, "IOException", e);
|
||||
}
|
||||
|
||||
// no flickering when clicking textview for Android < 4
|
||||
text.setTextColor(getResources().getColor(android.R.color.black));
|
||||
|
||||
return scroller;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
|||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseNfcActivity;
|
||||
import org.sufficientlysecure.keychain.ui.util.ThemeChanger;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
|
@ -64,6 +65,14 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
|||
|
||||
private CryptoInputParcel mInputParcel;
|
||||
|
||||
@Override
|
||||
protected void initTheme() {
|
||||
mThemeChanger = new ThemeChanger(this);
|
||||
mThemeChanger.setThemes(R.style.Theme_Keychain_Light_Dialog_SecurityToken,
|
||||
R.style.Theme_Keychain_Dark_Dialog_SecurityToken);
|
||||
mThemeChanger.changeTheme();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
|
@ -65,8 +65,8 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
sPreferences = Preferences.getPreferences(this);
|
||||
|
||||
mThemeChanger = new ThemeChanger(this);
|
||||
mThemeChanger.setThemes(R.style.Theme_Keychain_Light, R.style.Theme_Keychain_Dark);
|
||||
mThemeChanger.changeTheme();
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
@ -126,7 +126,9 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
if (mThemeChanger.changeTheme()) {
|
||||
Intent intent = getIntent();
|
||||
finish();
|
||||
overridePendingTransition(0, 0);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -506,6 +508,9 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
mTheme.setValue((String) newValue);
|
||||
mTheme.setSummary(mTheme.getEntry());
|
||||
sPreferences.setTheme((String) newValue);
|
||||
|
||||
((SettingsActivity) mTheme.getContext()).recreate();
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -42,8 +42,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mThemeChanger = new ThemeChanger(this);
|
||||
mThemeChanger.changeTheme();
|
||||
initTheme();
|
||||
super.onCreate(savedInstanceState);
|
||||
initLayout();
|
||||
initToolbar();
|
||||
|
@ -56,7 +55,9 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
if (mThemeChanger.changeTheme()) {
|
||||
Intent intent = getIntent();
|
||||
finish();
|
||||
overridePendingTransition(0, 0);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,6 +74,15 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
mStatusBar = findViewById(R.id.status_bar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override if you want a different theme!
|
||||
*/
|
||||
protected void initTheme() {
|
||||
mThemeChanger = new ThemeChanger(this);
|
||||
mThemeChanger.setThemes(R.style.Theme_Keychain_Light, R.style.Theme_Keychain_Dark);
|
||||
mThemeChanger.changeTheme();
|
||||
}
|
||||
|
||||
protected void setActionBarIcon(int iconRes) {
|
||||
mToolbar.setNavigationIcon(iconRes);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.sufficientlysecure.keychain.ui.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.ContextThemeWrapper;
|
||||
|
||||
|
@ -25,10 +26,13 @@ import org.sufficientlysecure.keychain.R;
|
|||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
|
||||
public class ThemeChanger {
|
||||
private Context mContext;
|
||||
private Activity mContext;
|
||||
private Preferences mPreferences;
|
||||
private String mCurrentTheme = null;
|
||||
|
||||
private int mLightResId;
|
||||
private int mDarkResId;
|
||||
|
||||
static public ContextThemeWrapper getDialogThemeWrapper(Context context) {
|
||||
Preferences preferences = Preferences.getPreferences(context);
|
||||
|
||||
|
@ -42,7 +46,12 @@ public class ThemeChanger {
|
|||
}
|
||||
}
|
||||
|
||||
public ThemeChanger(Context context) {
|
||||
public void setThemes(int lightResId, int darkResId) {
|
||||
mLightResId = lightResId;
|
||||
mDarkResId = darkResId;
|
||||
}
|
||||
|
||||
public ThemeChanger(Activity context) {
|
||||
mContext = context;
|
||||
mPreferences = Preferences.getPreferences(mContext);
|
||||
}
|
||||
|
@ -59,9 +68,9 @@ public class ThemeChanger {
|
|||
return false;
|
||||
}
|
||||
|
||||
int themeId = R.style.Theme_Keychain_Light;
|
||||
int themeId = mLightResId;
|
||||
if (Constants.Pref.Theme.DARK.equals(newTheme)) {
|
||||
themeId = R.style.Theme_Keychain_Dark;
|
||||
themeId = mDarkResId;
|
||||
}
|
||||
|
||||
ContextThemeWrapper w = new ContextThemeWrapper(mContext, themeId);
|
||||
|
@ -70,4 +79,5 @@ public class ThemeChanger {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
<item name="colorAccent">#7bad45</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Keychain.Dark.Dialog" parent="Base.Theme.AppCompat.Light.Dialog.Alert">
|
||||
<style name="Theme.Keychain.Dark.Dialog" parent="Base.Theme.AppCompat.Dialog.Alert">
|
||||
<item name="colorAccent">#268bd2</item>
|
||||
</style>
|
||||
|
||||
|
@ -123,4 +123,9 @@
|
|||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Keychain.Dark.Dialog.SecurityToken" parent="Theme.AppCompat.Dialog.MinWidth">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue