parent
93598d3a51
commit
ef2e02098d
@ -18,6 +18,7 @@ import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -45,7 +46,7 @@ public class AboutActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
String theme = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme", "");
|
||||
Logger.dev("AboutActivity: Theme is " + theme);
|
||||
if (theme.equals("Dark")) {
|
||||
if (Utils.isDarkTheme(theme, this)) {
|
||||
setTheme(R.style.AppTheme_dh);
|
||||
}
|
||||
setContentView(R.layout.activity_about);
|
||||
@ -76,7 +77,7 @@ public class AboutActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
appChangelog.removeSummary();
|
||||
if (theme.equals("Dark")) {
|
||||
if (Utils.isDarkTheme(theme, this)) {
|
||||
builder = new AlertDialog.Builder(this, R.style.AlertDialog_dh);
|
||||
} else {
|
||||
builder = new AlertDialog.Builder(this);
|
||||
|
@ -27,6 +27,7 @@ import android.view.View;
|
||||
import com.topjohnwu.magisk.utils.CallbackHandler;
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.utils.Shell;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
@ -55,7 +56,7 @@ public class MainActivity extends AppCompatActivity
|
||||
|
||||
String theme = prefs.getString("theme", "");
|
||||
Logger.dev("MainActivity: Theme is " + theme);
|
||||
if (theme.equals("Dark")) {
|
||||
if (Utils.isDarkTheme(theme, this)) {
|
||||
setTheme(R.style.AppTheme_dh);
|
||||
alertBuilder = new AlertDialog.Builder(this, R.style.AlertDialog_dh);
|
||||
} else {
|
||||
|
@ -30,7 +30,7 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
String theme = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme", "");
|
||||
Logger.dev("AboutActivity: Theme is " + theme);
|
||||
if (theme.equals("Dark")) {
|
||||
if (Utils.isDarkTheme(theme, this)) {
|
||||
setTheme(R.style.AppTheme_dh);
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
String theme = prefs.getString(key, "");
|
||||
|
||||
themePreference.setSummary(theme);
|
||||
if (theme.equals("Dark")) {
|
||||
if (Utils.isDarkTheme(theme, getActivity())) {
|
||||
getActivity().getApplication().setTheme(R.style.AppTheme_dh);
|
||||
} else {
|
||||
getActivity().getApplication().setTheme(R.style.AppTheme);
|
||||
|
@ -17,7 +17,7 @@ public class SplashActivity extends AppCompatActivity {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplication());
|
||||
if (prefs.getString("theme", "").equals("Dark")) {
|
||||
if (Utils.isDarkTheme(prefs.getString("theme", null), this)) {
|
||||
setTheme(R.style.AppTheme_dh);
|
||||
}
|
||||
|
||||
|
@ -164,6 +164,10 @@ public class Utils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isDarkTheme(String theme, Context resources) {
|
||||
return theme != null && theme.equalsIgnoreCase(resources.getString(R.string.theme_dark_value));
|
||||
}
|
||||
|
||||
public static class ByteArrayInOutStream extends ByteArrayOutputStream {
|
||||
public ByteArrayInputStream getInputStream() {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(buf, 0, count);
|
||||
|
@ -14,7 +14,7 @@ public class WebWindow {
|
||||
public WebWindow(String title, String url, Context context) {
|
||||
AlertDialog.Builder alert;
|
||||
String theme = PreferenceManager.getDefaultSharedPreferences(context).getString("theme", "");
|
||||
if (theme.equals("Dark")) {
|
||||
if (Utils.isDarkTheme(theme, context)) {
|
||||
alert = new AlertDialog.Builder(context, R.style.AlertDialog_dh);
|
||||
} else {
|
||||
alert = new AlertDialog.Builder(context);
|
||||
|
@ -4,4 +4,8 @@
|
||||
<item>"Default"</item>
|
||||
<item>"Dark"</item>
|
||||
</string-array>
|
||||
<string-array name="themes_values">
|
||||
<item>@string/theme_default_value</item>
|
||||
<item>@string/theme_dark_value</item>
|
||||
</string-array>
|
||||
</resources>
|
@ -130,4 +130,8 @@
|
||||
|
||||
<string name="settings_reboot_toast">Reboot to apply settings</string>
|
||||
|
||||
<!-- Themes -->
|
||||
<string name="theme_default_value" translatable="false">default</string>
|
||||
<string name="theme_dark_value" translatable="false">dark</string>
|
||||
|
||||
</resources>
|
||||
|
@ -8,9 +8,9 @@
|
||||
android:key="theme"
|
||||
android:title="@string/settings_theme_title"
|
||||
android:summary="@string/settings_theme_summary"
|
||||
android:defaultValue="Default"
|
||||
android:defaultValue="@string/theme_default_value"
|
||||
android:entries="@array/themes"
|
||||
android:entryValues="@array/themes"/>
|
||||
android:entryValues="@array/themes_values"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user