修复bug
huangwei 11 months ago
parent ef78de301c
commit 4956327c2a
  1. 83
      app/src/main/java/com/bingce/controlnetwork/activity/SettingsActivity.java
  2. 20
      app/src/main/res/xml/prefs.xml

@ -2,7 +2,6 @@ package com.bingce.controlnetwork.activity;
import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
@ -16,13 +15,11 @@ import androidx.preference.ListPreference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.SwitchPreferenceCompat;
import com.bingce.AppChannel;
import com.bingce.controlapphelper.surveyor.surveyor.ISurveyorConstants;
import com.bingce.controlnetwork.App;
import com.bingce.controlnetwork.R;
import com.bingce.controlnetwork.controller.KeyEventAction;
import org.polaric.colorful.ColorPickerPreference;
import org.polaric.colorful.Colorful;
import org.polaric.colorful.ColorfulActivity;
@ -72,7 +69,7 @@ public class SettingsActivity extends ColorfulActivity {
public static class SettingsFragment extends PreferenceFragmentCompat {
private SwitchPreferenceCompat nightModePrefs;
private SwitchPreferenceCompat isOpenAtr;
private ColorPickerPreference themePrimaryColor, themeAccentColor;
// private ColorPickerPreference themePrimaryColor, themeAccentColor;
private ListPreference volume_plus_prefs, volume_minus_prefs;
@ -81,8 +78,8 @@ public class SettingsActivity extends ColorfulActivity {
setPreferencesFromResource(R.xml.prefs, rootKey);
nightModePrefs = findPreference("key_is_night_mode");
themePrimaryColor = findPreference("key_theme_primary_color");
themeAccentColor = findPreference("key_theme_accent_color");
// themePrimaryColor = findPreference("key_theme_primary_color");
// themeAccentColor = findPreference("key_theme_accent_color");
volume_plus_prefs = findPreference("key_volume_plus_function");
@ -108,38 +105,38 @@ public class SettingsActivity extends ColorfulActivity {
});
//主色
themePrimaryColor.setOnPreferenceChangeListener((preference, newValue) -> {
new AlertDialog.Builder(getActivity())
.setMessage(R.string.please_restart_to_apply_new_theme)
.setPositiveButton(R.string.confirm, null)
.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
Intent intent = new Intent();
intent.putExtra("isThemeChanged", true);
getActivity().setResult(RESULT_OK, intent);
getActivity().finish();
}
}).show();
return true;
});
//配色
themeAccentColor.setOnPreferenceChangeListener((preference, newValue) -> {
new AlertDialog.Builder(getActivity())
.setMessage(R.string.please_restart_to_apply_new_theme)
.setPositiveButton(R.string.confirm, null)
.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
Intent intent = new Intent();
intent.putExtra("isThemeChanged", true);
getActivity().setResult(RESULT_OK, intent);
getActivity().finish();
}
}).show();
return true;
});
// //主色
// themePrimaryColor.setOnPreferenceChangeListener((preference, newValue) -> {
// new AlertDialog.Builder(getActivity())
// .setMessage(R.string.please_restart_to_apply_new_theme)
// .setPositiveButton(R.string.confirm, null)
// .setOnDismissListener(new DialogInterface.OnDismissListener() {
// @Override
// public void onDismiss(DialogInterface dialogInterface) {
// Intent intent = new Intent();
// intent.putExtra("isThemeChanged", true);
// getActivity().setResult(RESULT_OK, intent);
// getActivity().finish();
// }
// }).show();
// return true;
// });
// //配色
// themeAccentColor.setOnPreferenceChangeListener((preference, newValue) -> {
// new AlertDialog.Builder(getActivity())
// .setMessage(R.string.please_restart_to_apply_new_theme)
// .setPositiveButton(R.string.confirm, null)
// .setOnDismissListener(new DialogInterface.OnDismissListener() {
// @Override
// public void onDismiss(DialogInterface dialogInterface) {
// Intent intent = new Intent();
// intent.putExtra("isThemeChanged", true);
// getActivity().setResult(RESULT_OK, intent);
// getActivity().finish();
// }
// }).show();
// return true;
// });
volume_plus_prefs.setOnPreferenceChangeListener((preference, newValue) -> {
setKeyEvent(newValue, volume_plus_prefs);
@ -155,11 +152,11 @@ public class SettingsActivity extends ColorfulActivity {
return true;
});
if (AppChannel.customChannel != AppChannel.CUSTOM_CONTROL_PUBLIC) {
//主配色隐藏
themePrimaryColor.setVisible(false);
themeAccentColor.setVisible(false);
}
// if (AppChannel.customChannel != AppChannel.CUSTOM_CONTROL_PUBLIC) {
// //主配色隐藏
// themePrimaryColor.setVisible(false);
// themeAccentColor.setVisible(false);
// }
}

@ -9,16 +9,16 @@
android:summaryOff="@string/daytime_mode"
android:summaryOn="@string/night_mode"
android:title="@string/is_open_night_mode" />
<org.polaric.colorful.ColorPickerPreference
android:key="key_theme_primary_color"
android:summary="@string/primary_color_desc"
android:title="@string/primary_color"
colorpicker:primary_color="true" />
<org.polaric.colorful.ColorPickerPreference
android:key="key_theme_accent_color"
android:summary="@string/accent_color_desc"
android:title="@string/accent_color"
colorpicker:accent_color="true" />
<!-- <org.polaric.colorful.ColorPickerPreference-->
<!-- android:key="key_theme_primary_color"-->
<!-- android:summary="@string/primary_color_desc"-->
<!-- android:title="@string/primary_color"-->
<!-- colorpicker:primary_color="true" />-->
<!-- <org.polaric.colorful.ColorPickerPreference-->
<!-- android:key="key_theme_accent_color"-->
<!-- android:summary="@string/accent_color_desc"-->
<!-- android:title="@string/accent_color"-->
<!-- colorpicker:accent_color="true" />-->
<androidx.preference.SwitchPreferenceCompat
android:defaultValue="false"
android:key="key_is_wake_lock"

Loading…
Cancel
Save