Loading res/values-ja/strings.xml +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ <string name="accessibility_custom_color_title" msgid="4124246598886320663">"カスタム色"</string> <string name="accessibility_custom_shape_title" msgid="7708408259374643129">"カスタムの形状"</string> <string name="accessibility_custom_name_title" msgid="5494460518085463262">"カスタム スタイル名"</string> <string name="mode_title" msgid="2394873501427436055">"ダークテーマ"</string> <string name="mode_title" msgid="2394873501427436055">"ダークモード"</string> <string name="mode_disabled_msg" msgid="9196245518435936512">"バッテリー セーバーにより一時的に無効になりました"</string> <string name="themed_icon_title" msgid="7312460430471956558">"テーマアイコン"</string> <string name="gird_picker_entry_content_description" msgid="9087651470212293439">"アプリグリッドを変更します"</string> Loading res/values-km/strings.xml +1 −1 Original line number Diff line number Diff line Loading @@ -80,6 +80,6 @@ <string name="accessibility_custom_name_title" msgid="5494460518085463262">"ឈ្មោះរចនាប័ទ្មផ្ទាល់ខ្លួន"</string> <string name="mode_title" msgid="2394873501427436055">"រចនាប័ទ្មងងឹត"</string> <string name="mode_disabled_msg" msgid="9196245518435936512">"បានបិទជាបណ្តោះអាសន្ន ដោយសារមុខងារសន្សំថ្ម"</string> <string name="themed_icon_title" msgid="7312460430471956558">"រូបកំណត់រចនាប័ទ្ម"</string> <string name="themed_icon_title" msgid="7312460430471956558">"រូបតំណាងប្ដូររចនាប័ទ្ម"</string> <string name="gird_picker_entry_content_description" msgid="9087651470212293439">"ប្ដូរក្រឡាកម្មវិធី"</string> </resources> src/com/android/customization/model/mode/DarkModeSectionController.java +6 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Handler; import android.os.Looper; import android.os.PowerManager; import android.text.TextUtils; import android.view.LayoutInflater; Loading Loading @@ -124,7 +126,10 @@ public class DarkModeSectionController implements return; } UiModeManager uiModeManager = context.getSystemService(UiModeManager.class); uiModeManager.setNightModeActivated(viewActivated); int shortDelay = context.getResources().getInteger(android.R.integer.config_shortAnimTime); new Handler(Looper.getMainLooper()).postDelayed( () -> uiModeManager.setNightModeActivated(viewActivated), /* delayMillis= */ shortDelay); } private class BatterySaverStateReceiver extends BroadcastReceiver { Loading src/com/android/customization/model/themedicon/ThemedIconSectionController.java +2 −9 Original line number Diff line number Diff line Loading @@ -25,9 +25,6 @@ import com.android.wallpaper.R; import com.android.wallpaper.model.CustomizationSectionController; import com.android.wallpaper.model.WorkspaceViewModel; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; /** The {@link CustomizationSectionController} for themed icon section. */ public class ThemedIconSectionController implements CustomizationSectionController<ThemedIconSectionView> { Loading @@ -35,7 +32,6 @@ public class ThemedIconSectionController implements private final ThemedIconSwitchProvider mThemedIconOptionsProvider; private final WorkspaceViewModel mWorkspaceViewModel; private static ExecutorService sExecutorService = Executors.newSingleThreadExecutor(); public ThemedIconSectionController(ThemedIconSwitchProvider themedIconOptionsProvider, WorkspaceViewModel workspaceViewModel) { Loading @@ -54,11 +50,8 @@ public class ThemedIconSectionController implements (ThemedIconSectionView) LayoutInflater.from(context).inflate( R.layout.themed_icon_section_view, /* root= */ null); themedIconColorSectionView.setViewListener(this::onViewActivated); sExecutorService.submit(() -> { boolean themedIconEnabled = mThemedIconOptionsProvider.fetchThemedIconEnabled(); themedIconColorSectionView.post(() -> themedIconColorSectionView.getSwitch().setChecked(themedIconEnabled)); }); mThemedIconOptionsProvider.fetchThemedIconEnabled( enabled -> themedIconColorSectionView.getSwitch().setChecked(enabled)); return themedIconColorSectionView; } Loading src/com/android/customization/model/themedicon/ThemedIconSwitchProvider.java +91 −22 Original line number Diff line number Diff line Loading @@ -19,49 +19,118 @@ import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.os.Handler; import android.os.Looper; import androidx.annotation.WorkerThread; import androidx.annotation.Nullable; import com.android.customization.module.CustomizationPreferences; import com.android.wallpaper.R; import com.android.wallpaper.module.InjectorProvider; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; /** * Retrieves the themed icon switch by {@link ContentResolver} from the current launcher */ public class ThemedIconSwitchProvider { private static ThemedIconSwitchProvider sThemedIconSwitchProvider; private static final String ICON_THEMED = "icon_themed"; private static final int ENABLED = 1; private static final String COL_ICON_THEMED_VALUE = "boolean_value"; private static final int ENABLED = 1; private static final int RESULT_SUCCESS = 1; private final Context mContext; private final ExecutorService mExecutorService = Executors.newSingleThreadExecutor(); private final ContentResolver mContentResolver; private final ThemedIconUtils mThemedIconUtils; private final CustomizationPreferences mCustomizationPreferences; /** Callback for the themed icon enabled state fetching result. */ public interface FetchThemedIconEnabledCallback { /** Gets called when the result is available. */ void onResult(boolean isEnabled); } /** Returns the {@link ThemedIconSwitchProvider} instance. */ public static ThemedIconSwitchProvider getInstance(Context context) { if (sThemedIconSwitchProvider == null) { Context appContext = context.getApplicationContext(); sThemedIconSwitchProvider = new ThemedIconSwitchProvider( appContext.getContentResolver(), new ThemedIconUtils(appContext, appContext.getString(R.string.themed_icon_metadata_key)), (CustomizationPreferences) InjectorProvider.getInjector() .getPreferences(appContext)); } return sThemedIconSwitchProvider; } public ThemedIconSwitchProvider(Context context, ThemedIconUtils themedIconUtils) { mContext = context; private ThemedIconSwitchProvider(ContentResolver contentResolver, ThemedIconUtils themedIconUtils, CustomizationPreferences customizationPreferences) { mContentResolver = contentResolver; mThemedIconUtils = themedIconUtils; mCustomizationPreferences = customizationPreferences; } /** Returns {@code true} if themed icon feature is available. */ public boolean isThemedIconAvailable() { return mThemedIconUtils.isThemedIconAvailable(); } @WorkerThread public boolean fetchThemedIconEnabled() { ContentResolver contentResolver = mContext.getContentResolver(); try (Cursor cursor = contentResolver.query( mThemedIconUtils.getUriForPath(ICON_THEMED), /* projection= */ null, /* selection= */ null, /* selectionArgs= */ null, /* sortOrder= */ null)) { /** Gets the themed icon feature enabled state from SharedPreferences. */ public boolean isThemedIconEnabled() { return mCustomizationPreferences.getThemedIconEnabled(); } /** * Fetches the themed icon feature enabled state and stores in SharedPreferences, or returns the * SharedPreferences result if the fetching failed. */ public void fetchThemedIconEnabled(@Nullable FetchThemedIconEnabledCallback callback) { mExecutorService.submit(() -> { try (Cursor cursor = mContentResolver.query( mThemedIconUtils.getUriForPath(ICON_THEMED), /* projection= */ null, /* selection= */ null, /* selectionArgs= */ null, /* sortOrder= */ null)) { if (cursor != null && cursor.moveToNext()) { int themedIconEnabled = cursor.getInt(cursor.getColumnIndex(COL_ICON_THEMED_VALUE)); return themedIconEnabled == ENABLED; boolean isEnabled = cursor.getInt(cursor.getColumnIndex(COL_ICON_THEMED_VALUE)) == ENABLED; if (mCustomizationPreferences.getThemedIconEnabled() != isEnabled) { mCustomizationPreferences.setThemedIconEnabled(isEnabled); } if (callback != null) { postMainThread(() -> callback.onResult(isEnabled)); } return; } return false; } if (callback != null) { postMainThread( () -> callback.onResult(mCustomizationPreferences.getThemedIconEnabled())); } }); } protected int setThemedIconEnabled(boolean enabled) { /** * Enables themed icon feature or not. * * <p>The value would also be stored in SharedPreferences. */ protected void setThemedIconEnabled(boolean enabled) { mExecutorService.submit(() -> { ContentValues values = new ContentValues(); values.put(COL_ICON_THEMED_VALUE, enabled); return mContext.getContentResolver().update( mThemedIconUtils.getUriForPath(ICON_THEMED), values, /* where= */ null, /* selectionArgs= */ null); int result = mContentResolver.update(mThemedIconUtils.getUriForPath(ICON_THEMED), values, /* where= */ null, /* selectionArgs= */ null); if (result == RESULT_SUCCESS) { mCustomizationPreferences.setThemedIconEnabled(enabled); } }); } private void postMainThread(Runnable runnable) { new Handler(Looper.getMainLooper()).post(runnable); } } Loading
res/values-ja/strings.xml +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ <string name="accessibility_custom_color_title" msgid="4124246598886320663">"カスタム色"</string> <string name="accessibility_custom_shape_title" msgid="7708408259374643129">"カスタムの形状"</string> <string name="accessibility_custom_name_title" msgid="5494460518085463262">"カスタム スタイル名"</string> <string name="mode_title" msgid="2394873501427436055">"ダークテーマ"</string> <string name="mode_title" msgid="2394873501427436055">"ダークモード"</string> <string name="mode_disabled_msg" msgid="9196245518435936512">"バッテリー セーバーにより一時的に無効になりました"</string> <string name="themed_icon_title" msgid="7312460430471956558">"テーマアイコン"</string> <string name="gird_picker_entry_content_description" msgid="9087651470212293439">"アプリグリッドを変更します"</string> Loading
res/values-km/strings.xml +1 −1 Original line number Diff line number Diff line Loading @@ -80,6 +80,6 @@ <string name="accessibility_custom_name_title" msgid="5494460518085463262">"ឈ្មោះរចនាប័ទ្មផ្ទាល់ខ្លួន"</string> <string name="mode_title" msgid="2394873501427436055">"រចនាប័ទ្មងងឹត"</string> <string name="mode_disabled_msg" msgid="9196245518435936512">"បានបិទជាបណ្តោះអាសន្ន ដោយសារមុខងារសន្សំថ្ម"</string> <string name="themed_icon_title" msgid="7312460430471956558">"រូបកំណត់រចនាប័ទ្ម"</string> <string name="themed_icon_title" msgid="7312460430471956558">"រូបតំណាងប្ដូររចនាប័ទ្ម"</string> <string name="gird_picker_entry_content_description" msgid="9087651470212293439">"ប្ដូរក្រឡាកម្មវិធី"</string> </resources>
src/com/android/customization/model/mode/DarkModeSectionController.java +6 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Handler; import android.os.Looper; import android.os.PowerManager; import android.text.TextUtils; import android.view.LayoutInflater; Loading Loading @@ -124,7 +126,10 @@ public class DarkModeSectionController implements return; } UiModeManager uiModeManager = context.getSystemService(UiModeManager.class); uiModeManager.setNightModeActivated(viewActivated); int shortDelay = context.getResources().getInteger(android.R.integer.config_shortAnimTime); new Handler(Looper.getMainLooper()).postDelayed( () -> uiModeManager.setNightModeActivated(viewActivated), /* delayMillis= */ shortDelay); } private class BatterySaverStateReceiver extends BroadcastReceiver { Loading
src/com/android/customization/model/themedicon/ThemedIconSectionController.java +2 −9 Original line number Diff line number Diff line Loading @@ -25,9 +25,6 @@ import com.android.wallpaper.R; import com.android.wallpaper.model.CustomizationSectionController; import com.android.wallpaper.model.WorkspaceViewModel; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; /** The {@link CustomizationSectionController} for themed icon section. */ public class ThemedIconSectionController implements CustomizationSectionController<ThemedIconSectionView> { Loading @@ -35,7 +32,6 @@ public class ThemedIconSectionController implements private final ThemedIconSwitchProvider mThemedIconOptionsProvider; private final WorkspaceViewModel mWorkspaceViewModel; private static ExecutorService sExecutorService = Executors.newSingleThreadExecutor(); public ThemedIconSectionController(ThemedIconSwitchProvider themedIconOptionsProvider, WorkspaceViewModel workspaceViewModel) { Loading @@ -54,11 +50,8 @@ public class ThemedIconSectionController implements (ThemedIconSectionView) LayoutInflater.from(context).inflate( R.layout.themed_icon_section_view, /* root= */ null); themedIconColorSectionView.setViewListener(this::onViewActivated); sExecutorService.submit(() -> { boolean themedIconEnabled = mThemedIconOptionsProvider.fetchThemedIconEnabled(); themedIconColorSectionView.post(() -> themedIconColorSectionView.getSwitch().setChecked(themedIconEnabled)); }); mThemedIconOptionsProvider.fetchThemedIconEnabled( enabled -> themedIconColorSectionView.getSwitch().setChecked(enabled)); return themedIconColorSectionView; } Loading
src/com/android/customization/model/themedicon/ThemedIconSwitchProvider.java +91 −22 Original line number Diff line number Diff line Loading @@ -19,49 +19,118 @@ import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.os.Handler; import android.os.Looper; import androidx.annotation.WorkerThread; import androidx.annotation.Nullable; import com.android.customization.module.CustomizationPreferences; import com.android.wallpaper.R; import com.android.wallpaper.module.InjectorProvider; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; /** * Retrieves the themed icon switch by {@link ContentResolver} from the current launcher */ public class ThemedIconSwitchProvider { private static ThemedIconSwitchProvider sThemedIconSwitchProvider; private static final String ICON_THEMED = "icon_themed"; private static final int ENABLED = 1; private static final String COL_ICON_THEMED_VALUE = "boolean_value"; private static final int ENABLED = 1; private static final int RESULT_SUCCESS = 1; private final Context mContext; private final ExecutorService mExecutorService = Executors.newSingleThreadExecutor(); private final ContentResolver mContentResolver; private final ThemedIconUtils mThemedIconUtils; private final CustomizationPreferences mCustomizationPreferences; /** Callback for the themed icon enabled state fetching result. */ public interface FetchThemedIconEnabledCallback { /** Gets called when the result is available. */ void onResult(boolean isEnabled); } /** Returns the {@link ThemedIconSwitchProvider} instance. */ public static ThemedIconSwitchProvider getInstance(Context context) { if (sThemedIconSwitchProvider == null) { Context appContext = context.getApplicationContext(); sThemedIconSwitchProvider = new ThemedIconSwitchProvider( appContext.getContentResolver(), new ThemedIconUtils(appContext, appContext.getString(R.string.themed_icon_metadata_key)), (CustomizationPreferences) InjectorProvider.getInjector() .getPreferences(appContext)); } return sThemedIconSwitchProvider; } public ThemedIconSwitchProvider(Context context, ThemedIconUtils themedIconUtils) { mContext = context; private ThemedIconSwitchProvider(ContentResolver contentResolver, ThemedIconUtils themedIconUtils, CustomizationPreferences customizationPreferences) { mContentResolver = contentResolver; mThemedIconUtils = themedIconUtils; mCustomizationPreferences = customizationPreferences; } /** Returns {@code true} if themed icon feature is available. */ public boolean isThemedIconAvailable() { return mThemedIconUtils.isThemedIconAvailable(); } @WorkerThread public boolean fetchThemedIconEnabled() { ContentResolver contentResolver = mContext.getContentResolver(); try (Cursor cursor = contentResolver.query( mThemedIconUtils.getUriForPath(ICON_THEMED), /* projection= */ null, /* selection= */ null, /* selectionArgs= */ null, /* sortOrder= */ null)) { /** Gets the themed icon feature enabled state from SharedPreferences. */ public boolean isThemedIconEnabled() { return mCustomizationPreferences.getThemedIconEnabled(); } /** * Fetches the themed icon feature enabled state and stores in SharedPreferences, or returns the * SharedPreferences result if the fetching failed. */ public void fetchThemedIconEnabled(@Nullable FetchThemedIconEnabledCallback callback) { mExecutorService.submit(() -> { try (Cursor cursor = mContentResolver.query( mThemedIconUtils.getUriForPath(ICON_THEMED), /* projection= */ null, /* selection= */ null, /* selectionArgs= */ null, /* sortOrder= */ null)) { if (cursor != null && cursor.moveToNext()) { int themedIconEnabled = cursor.getInt(cursor.getColumnIndex(COL_ICON_THEMED_VALUE)); return themedIconEnabled == ENABLED; boolean isEnabled = cursor.getInt(cursor.getColumnIndex(COL_ICON_THEMED_VALUE)) == ENABLED; if (mCustomizationPreferences.getThemedIconEnabled() != isEnabled) { mCustomizationPreferences.setThemedIconEnabled(isEnabled); } if (callback != null) { postMainThread(() -> callback.onResult(isEnabled)); } return; } return false; } if (callback != null) { postMainThread( () -> callback.onResult(mCustomizationPreferences.getThemedIconEnabled())); } }); } protected int setThemedIconEnabled(boolean enabled) { /** * Enables themed icon feature or not. * * <p>The value would also be stored in SharedPreferences. */ protected void setThemedIconEnabled(boolean enabled) { mExecutorService.submit(() -> { ContentValues values = new ContentValues(); values.put(COL_ICON_THEMED_VALUE, enabled); return mContext.getContentResolver().update( mThemedIconUtils.getUriForPath(ICON_THEMED), values, /* where= */ null, /* selectionArgs= */ null); int result = mContentResolver.update(mThemedIconUtils.getUriForPath(ICON_THEMED), values, /* where= */ null, /* selectionArgs= */ null); if (result == RESULT_SUCCESS) { mCustomizationPreferences.setThemedIconEnabled(enabled); } }); } private void postMainThread(Runnable runnable) { new Handler(Looper.getMainLooper()).post(runnable); } }