Cherish:Import ThemePicker Browser
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -105,4 +105,8 @@
|
||||
<string name="accent_summary">Gradient Maker</string>
|
||||
<string name="gradient_color">Gradient picker</string>
|
||||
<string name="gradient_summary">Gradient effect maker</string>
|
||||
|
||||
<!--ThemePicker-->
|
||||
<string name="theme_select_title">Styles and Wallpapers</string>
|
||||
<string name="theme_select_summary">Browse and select installed themes</string>
|
||||
</resources>
|
||||
|
||||
@@ -18,6 +18,21 @@
|
||||
android:title="@string/theme_title"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="system_theme_category"
|
||||
android:title="@string/theme_type_title">
|
||||
|
||||
<Preference
|
||||
android:key="theme_select_activity"
|
||||
android:title="@string/theme_select_title"
|
||||
android:icon="@drawable/ic_system_theme"
|
||||
android:summary="@string/theme_select_summary"
|
||||
android:persistent="false" >
|
||||
<intent android:action="android.intent.action.MAIN"
|
||||
android:targetPackage="com.android.customization"
|
||||
android:targetClass="com.android.customization.picker.CustomizationPickerActivity" />
|
||||
</Preference>
|
||||
|
||||
<net.margaritov.preference.colorpicker.ColorPickerPreference
|
||||
android:key="accent_color"
|
||||
android:icon="@drawable/ic_accent_picker"
|
||||
@@ -43,4 +58,5 @@
|
||||
android:entries="@array/theme_type_titles"
|
||||
android:entryValues="@array/theme_type_values"
|
||||
android:defaultValue="1"/>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
@@ -13,10 +13,14 @@ import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.UserHandle;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.ServiceManager;
|
||||
import android.content.om.IOverlayManager;
|
||||
import android.content.om.OverlayInfo;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.res.Resources;
|
||||
import androidx.preference.ListPreference;
|
||||
@@ -26,8 +30,14 @@ import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||
import androidx.preference.SwitchPreference;
|
||||
import com.cherish.settings.preferences.CustomSeekBarPreference;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import com.android.settings.display.OverlayCategoryPreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import android.provider.Settings;
|
||||
import com.android.settings.R;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import java.util.Locale;
|
||||
import android.text.TextUtils;
|
||||
@@ -48,6 +58,7 @@ public class ThemeSettings extends SettingsPreferenceFragment implements
|
||||
private static final String ACCENT_COLOR_PROP = "persist.sys.theme.accentcolor";
|
||||
private static final String GRADIENT_COLOR = "gradient_color";
|
||||
private static final String GRADIENT_COLOR_PROP = "persist.sys.theme.gradientcolor";
|
||||
private static final String CUSTOM_THEME_BROWSE = "theme_select_activity";
|
||||
static final int DEFAULT_QS_PANEL_COLOR = 0xffffffff;
|
||||
|
||||
private IOverlayManager mOverlayService;
|
||||
@@ -55,6 +66,7 @@ public class ThemeSettings extends SettingsPreferenceFragment implements
|
||||
private ColorPickerPreference mThemeColor;
|
||||
private ColorPickerPreference mGradientColor;
|
||||
private ListPreference mThemeSwitch;
|
||||
private Preference mThemeBrowse;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
@@ -227,6 +239,13 @@ public class ThemeSettings extends SettingsPreferenceFragment implements
|
||||
mGradientColor.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
private boolean isBrowseThemesAvailable() {
|
||||
PackageManager pm = getPackageManager();
|
||||
Intent browse = new Intent();
|
||||
browse.setClassName("com.android.customization", "com.android.customization.picker.CustomizationPickerActivity");
|
||||
return pm.resolveActivity(browse, 0) != null;
|
||||
}
|
||||
|
||||
private void handleBackgrounds(Boolean state, Context context, int mode, String[] overlays) {
|
||||
if (context != null) {
|
||||
Objects.requireNonNull(context.getSystemService(UiModeManager.class))
|
||||
@@ -246,5 +265,4 @@ public class ThemeSettings extends SettingsPreferenceFragment implements
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user