diff options
author | 2024-01-23 18:00:21 +0000 | |
---|---|---|
committer | 2024-02-04 16:56:56 +0000 | |
commit | 8ca82d1fad5bec1def90bce3021e21887731067a (patch) | |
tree | 06583f46e0f31c3e1dc2db62c0759dfc23a47dd8 /tools | |
parent | 6be9626850ff752222a1598ff0f63a72fca1c723 (diff) |
Set picker accent color
Enable apps to set a picker accent color which will change the color of
the primary picker elements: add butto, view-selected button, selected
media icons and selected tab colors. Colors of buttons in Preview mode
will also be changed. All the other colors will be set to Material3 baseline
theme.
Demo: https://drive.google.com/drive/folders/1yxn0KmkosZi21Pk26S9rNAll1QiKdkJw?usp=sharing
Test: atest PhotoPickerTests
Bug: b/303784053
Change-Id: I1afa71c60fb1cc4aa468ff37c2bdbd41150aac2c
Diffstat (limited to 'tools')
-rw-r--r-- | tools/photopicker/res/layout/activity_main.xml | 23 | ||||
-rw-r--r-- | tools/photopicker/src/com/android/providers/media/tools/photopicker/PhotoPickerToolActivity.java | 20 |
2 files changed, 43 insertions, 0 deletions
diff --git a/tools/photopicker/res/layout/activity_main.xml b/tools/photopicker/res/layout/activity_main.xml index d5db47d0c..9f92ac143 100644 --- a/tools/photopicker/res/layout/activity_main.xml +++ b/tools/photopicker/res/layout/activity_main.xml @@ -138,6 +138,29 @@ </LinearLayout> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + + <CheckBox + android:id="@+id/cbx_set_accent_color" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="SET ACCENT COLOR" + android:textSize="16sp" /> + + <EditText + android:id="@+id/edittext_accent_color" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="center" + android:enabled="false" + android:hint="Color hex code(for ex: #000000)" + android:textSize="16sp" /> + </LinearLayout> + <Button android:id="@+id/launch_button" diff --git a/tools/photopicker/src/com/android/providers/media/tools/photopicker/PhotoPickerToolActivity.java b/tools/photopicker/src/com/android/providers/media/tools/photopicker/PhotoPickerToolActivity.java index 98e58c0db..b8f8c2f53 100644 --- a/tools/photopicker/src/com/android/providers/media/tools/photopicker/PhotoPickerToolActivity.java +++ b/tools/photopicker/src/com/android/providers/media/tools/photopicker/PhotoPickerToolActivity.java @@ -48,6 +48,9 @@ public class PhotoPickerToolActivity extends Activity { private static final String TAG = "PhotoPickerToolActivity"; private static final String EXTRA_PICK_IMAGES_MAX = "android.provider.extra.PICK_IMAGES_MAX"; + public static final String EXTRA_PICK_IMAGES_ACCENT_COLOR = + "android.provider.extra.PICK_IMAGES_ACCENT_COLOR"; + private static final String ACTION_PICK_IMAGES = "android.provider.action.PICK_IMAGES"; private static final String EXTRA_PICK_IMAGES_LAUNCH_TAB = "android.provider.extra.PICK_IMAGES_LAUNCH_TAB"; @@ -70,9 +73,11 @@ public class PhotoPickerToolActivity extends Activity { private CheckBox mOrderedSelectionCheckBox; private CheckBox mPickerLaunchTabCheckBox; + private CheckBox mPickerAccentColorCheckBox; private EditText mMaxCountText; private EditText mMimeTypeText; + private EditText mAccentColorText; private RadioButton mAlbumsRadioButton; private RadioButton mPhotosRadioButton; @@ -95,6 +100,8 @@ public class PhotoPickerToolActivity extends Activity { mPickerLaunchTabCheckBox = findViewById(R.id.cbx_set_picker_launch_tab); mAlbumsRadioButton = findViewById(R.id.rb_albums); mPhotosRadioButton = findViewById(R.id.rb_photos); + mPickerAccentColorCheckBox = findViewById(R.id.cbx_set_accent_color); + mAccentColorText = findViewById(R.id.edittext_accent_color); mSetImageOnlyCheckBox.setOnCheckedChangeListener(this::onShowImageOnlyCheckedChanged); mSetVideoOnlyCheckBox.setOnCheckedChangeListener(this::onShowVideoOnlyCheckedChanged); @@ -103,6 +110,8 @@ public class PhotoPickerToolActivity extends Activity { this::onSetSelectionCountCheckedChanged); mPickerLaunchTabCheckBox.setOnCheckedChangeListener( this::onSetPickerLaunchTabCheckedChanged); + mPickerAccentColorCheckBox.setOnCheckedChangeListener( + this::onSetPickerAccentColorCheckedChanged); mMaxCountText.addTextChangedListener(new TextWatcher() { @Override @@ -177,6 +186,10 @@ public class PhotoPickerToolActivity extends Activity { mPhotosRadioButton.setEnabled(isChecked); } + private void onSetPickerAccentColorCheckedChanged(View view, boolean isChecked) { + mAccentColorText.setEnabled(isChecked); + } + private void onLaunchButtonClicked(View view) { final Intent intent; if (mGetContentCheckBox.isChecked()) { @@ -184,6 +197,7 @@ public class PhotoPickerToolActivity extends Activity { intent.setType("*/*"); } else { intent = new Intent(ACTION_PICK_IMAGES); + // This extra is not permitted in GET_CONTENT if (mPickerLaunchTabCheckBox.isChecked()) { int launchTab; @@ -194,6 +208,11 @@ public class PhotoPickerToolActivity extends Activity { } intent.putExtra(EXTRA_PICK_IMAGES_LAUNCH_TAB, launchTab); } + + if (mPickerAccentColorCheckBox.isChecked()) { + String accentColor = mAccentColorText.getText().toString(); + intent.putExtra(EXTRA_PICK_IMAGES_ACCENT_COLOR, accentColor); + } } if (mAllowMultipleCheckBox.isChecked()) { @@ -205,6 +224,7 @@ public class PhotoPickerToolActivity extends Activity { if (mOrderedSelectionCheckBox.isChecked()) { intent.putExtra(MediaStore.EXTRA_PICK_IMAGES_IN_ORDER, true); } + } } |