Claude Monet

pull/194/merge
M66B 3 years ago
parent 6a3d5ac24c
commit 1ddc79e950

@ -6,11 +6,13 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Paint;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
@ -24,6 +26,7 @@ import androidx.preference.PreferenceManager;
public class FragmentDialogTheme extends FragmentDialogBase {
private RadioGroup rgTheme;
private SwitchCompat swReverse;
private RadioButton rbThemeYou;
private RadioGroup rgThemeOptions;
private TextView tvSystem;
private SwitchCompat swBlack;
@ -36,13 +39,14 @@ public class FragmentDialogTheme extends FragmentDialogBase {
int checkedId = rgTheme.getCheckedRadioButtonId();
boolean grey = (checkedId == R.id.rbThemeGrey);
boolean solarized = (checkedId == R.id.rbThemeSolarized);
boolean colored = (grey || solarized ||
boolean you = (checkedId == R.id.rbThemeYou);
boolean colored = (grey || solarized || you ||
checkedId == R.id.rbThemeBlueOrange ||
checkedId == R.id.rbThemeRedGreen ||
checkedId == R.id.rbThemeYellowPurple);
int optionId = rgThemeOptions.getCheckedRadioButtonId();
swReverse.setEnabled(colored && !grey && !solarized);
swReverse.setEnabled(colored && !grey && !solarized && !you);
rgThemeOptions.setEnabled(colored);
for (int i = 0; i < rgThemeOptions.getChildCount(); i++)
@ -70,6 +74,7 @@ public class FragmentDialogTheme extends FragmentDialogBase {
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_theme, null);
rgTheme = dview.findViewById(R.id.rgTheme);
rbThemeYou = dview.findViewById(R.id.rbThemeYou);
swReverse = dview.findViewById(R.id.swReverse);
rgThemeOptions = dview.findViewById(R.id.rgThemeOptions);
tvSystem = dview.findViewById(R.id.tvSystem);
@ -86,6 +91,8 @@ public class FragmentDialogTheme extends FragmentDialogBase {
}
});
rbThemeYou.setVisibility((Build.VERSION.SDK_INT < Build.VERSION_CODES.S ? View.GONE : View.VISIBLE));
swReverse.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@ -188,6 +195,13 @@ public class FragmentDialogTheme extends FragmentDialogBase {
case "black_and_white":
rgTheme.check(R.id.rbThemeBlackAndWhite);
break;
case "you_light":
case "you_dark":
case "you_black":
case "you_system":
case "you_system_black":
rgTheme.check(R.id.rbThemeYou);
break;
}
tvMore.setPaintFlags(tvMore.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
@ -272,6 +286,13 @@ public class FragmentDialogTheme extends FragmentDialogBase {
editor.putString("theme", "black").apply();
} else if (checkedRadioButtonId == R.id.rbThemeBlackAndWhite) {
editor.putString("theme", "black_and_white").apply();
} else if (checkedRadioButtonId == R.id.rbThemeYou) {
if (system)
editor.putString("theme", "you_system" +
(black ? "_black" : "")).apply();
else
editor.putString("theme", "you" +
(black ? "_black" : dark ? "_dark" : "_light")).apply();
}
editor.putBoolean("default_light", swHtmlLight.isChecked());
@ -458,6 +479,22 @@ public class FragmentDialogTheme extends FragmentDialogBase {
return (night
? R.style.AppThemeSolarizedDark : R.style.AppThemeSolarizedLight);
case "you_light":
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
return R.style.AppThemeYouLight;
case "you_dark":
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
return (light ? R.style.AppThemeYouLight : R.style.AppThemeYouDark);
case "you_black":
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
return (light ? R.style.AppThemeYouLight : R.style.AppThemeYouBlack);
case "you_system":
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
return (night ? R.style.AppThemeYouDark : R.style.AppThemeYouLight);
case "you_system_black":
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
return (night ? R.style.AppThemeYouBlack : R.style.AppThemeYouLight);
default:
Log.e("Unknown theme=" + theme);
return R.style.AppThemeBlueOrangeLight;

@ -87,6 +87,14 @@
android:padding="6dp"
android:text="@string/title_setup_theme_black_and_white"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<RadioButton
android:id="@+id/rbThemeYou"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp"
android:text="@string/title_setup_theme_you"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
</RadioGroup>
<androidx.appcompat.widget.SwitchCompat

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppThemeYouLight" parent="AppThemeBaseLight">
<item name="colorPrimary">@android:color/system_accent1_500</item>
<item name="colorPrimaryDark">@android:color/system_accent1_700</item>
<item name="colorAccent">@android:color/system_accent3_500</item>
<item name="colorUnreadHighlight">@android:color/system_accent3_700</item>
<item name="colorFabBackground">@android:color/system_accent3_500</item>
<item name="colorInfoForeground">@android:color/system_accent1_0</item>
<item name="colorInfoBackground">@android:color/system_accent1_500</item>
<item name="android:textColorLink">@android:color/system_accent3_700</item>
</style>
<style name="AppThemeYouDark" parent="AppThemeBaseDark">
<item name="colorPrimary">@android:color/system_accent1_500</item>
<item name="colorPrimaryDark">@android:color/system_accent1_700</item>
<item name="colorAccent">@android:color/system_accent3_500</item>
<item name="colorUnreadHighlight">@android:color/system_accent3_300</item>
<item name="colorFabBackground">@android:color/system_accent3_500</item>
<item name="colorInfoForeground">@android:color/system_accent1_0</item>
<item name="colorInfoBackground">@android:color/system_accent1_500</item>
<item name="android:textColorLink">@android:color/system_accent3_300</item>
</style>
<style name="AppThemeYouBlack" parent="AppThemeYouDark">
<item name="themeName">black</item>
<item name="android:windowBackground">@drawable/background_black</item>
<item name="colorDrawerBackground">@color/black</item>
</style>
</resources>

@ -285,9 +285,10 @@
<string name="title_setup_theme_yellow_purple">Yellow/purple</string>
<string name="title_setup_theme_red_green">Red/green</string>
<string name="title_setup_theme_grey">Grey</string>
<string name="title_setup_theme_solarized" translatable="false">Solarized</string>
<string name="title_setup_theme_black">Black</string>
<string name="title_setup_theme_black_and_white">Black and white</string>
<string name="title_setup_theme_solarized" translatable="false">Solarized</string>
<string name="title_setup_theme_you" translatable="false">Material You</string>
<string name="title_setup_theme_reverse">Swap colors</string>
<string name="title_setup_theme_light">Light</string>

Loading…
Cancel
Save