Fixes #2786 : Certificate dialogue not respecting dark theme solved

This commit is contained in:
vikiCoder 2018-02-14 16:19:26 +05:30
parent d3e755ceb1
commit 88866d99fa
4 changed files with 36 additions and 4 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ConversationsTheme" parent="@android:style/Theme.Material.Light.DarkActionBar" />
<style name="ConversationsTheme.Dark" parent="android:Theme.Material" />
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="theme">light</string>
</resources>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ConversationsTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar" />
<style name="ConversationsTheme.Dark" parent="@android:style/Theme.Holo" />
</resources>

View file

@ -24,20 +24,24 @@
package de.duenndns.ssl; package de.duenndns.ssl;
import java.util.logging.Level;
import java.util.logging.Logger;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.*; import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager;
import java.util.logging.Level;
import java.util.logging.Logger;
public class MemorizingActivity extends Activity public class MemorizingActivity extends Activity
implements OnClickListener,OnCancelListener { implements OnClickListener,OnCancelListener {
private final static Logger LOGGER = Logger.getLogger(MemorizingActivity.class.getName()); private final static Logger LOGGER = Logger.getLogger(MemorizingActivity.class.getName());
public static final String THEME = "theme";
int decisionId; int decisionId;
@ -46,6 +50,7 @@ public class MemorizingActivity extends Activity
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
LOGGER.log(Level.FINE, "onCreate"); LOGGER.log(Level.FINE, "onCreate");
setTheme(findTheme());
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
} }
@ -80,6 +85,15 @@ public class MemorizingActivity extends Activity
finish(); finish();
} }
protected int findTheme() {
return getPreferences().getString(THEME, getResources().getString(R.string.theme)).equals("dark") ? R.style.ConversationsTheme_Dark : R.style.ConversationsTheme;
}
protected SharedPreferences getPreferences() {
return PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
}
// react on AlertDialog button press // react on AlertDialog button press
public void onClick(DialogInterface dialog, int btnId) { public void onClick(DialogInterface dialog, int btnId) {
int decision; int decision;