Skip to content

Commit

Permalink
Toggleable new bouncy consolidated popup (MATERIAL_U_POPUP)
Browse files Browse the repository at this point in the history
  • Loading branch information
validcube committed Jan 30, 2024
1 parent 385e4ad commit 2a18dff
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 14 deletions.
1 change: 1 addition & 0 deletions lawnchair/res/values/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<bool name="config_default_smartspace_show_time">false</bool>
<bool name="config_default_perform_wide_search">true</bool>
<bool name="config_default_enable_dot_pagination">true</bool>
<bool name="config_default_enable_material_u_popup">true</bool>

<item name="config_default_home_icon_size_factor" type="dimen" format="float">1.0</item>
<item name="config_default_folder_preview_background_opacity" type="dimen" format="float">1.0</item>
Expand Down
6 changes: 4 additions & 2 deletions lawnchair/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,10 @@
<string name="home_screen_lock_description">Prevents changes to the home screen layout.</string>
<string name="home_screen_unlock">Unlock Home Screen</string> <!-- used in popup menu-->
<string name="home_screen_locked">Home Screen is locked.</string>
<string name="show_dot_pagination_label">Show dot pagination</string>
<string name="show_dot_pagination_description">Enable showing dot pagination in workspace</string>
<string name="show_dot_pagination_label">Show dot pagination</string>
<string name="show_dot_pagination_description">Enable showing dot pagination in workspace.</string>
<string name="show_material_u_popup_label">Show Material U Popup</string>
<string name="show_material_u_popup_description">Enable bouncy and slightly consolidated popup.</string>


<string name="popup_menu">Pop-up Menu</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,12 @@ class PreferenceManager2 private constructor(private val context: Context) : Pre
onSet = { reloadHelper.recreate() },
)

val enableMaterialUPopUp = preference(
key = booleanPreferencesKey(name = "enable_material_u_popup"),
defaultValue = context.resources.getBoolean(R.bool.config_default_enable_material_u_popup),
onSet = { reloadHelper.recreate() },
)

val enableFeed = preference(
key = booleanPreferencesKey(name = "enable_feed"),
defaultValue = context.resources.getBoolean(R.bool.config_default_enable_feed),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,16 @@ fun HomeScreenPreferences() {
label = stringResource(id = R.string.home_screen_lock),
description = stringResource(id = R.string.home_screen_lock_description),
)

SwitchPreference(
adapter = prefs2.enableDotPagination.getAdapter(),
label = stringResource(id = R.string.show_dot_pagination_label),
description = stringResource(id = R.string.show_dot_pagination_description),
)
SwitchPreference(
adapter = prefs2.enableMaterialUPopUp.getAdapter(),
label = stringResource(id = R.string.show_material_u_popup_label),
description = stringResource(id = R.string.show_material_u_popup_description),
)
}
}
PreferenceGroup(heading = stringResource(id = R.string.popup_menu)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public PopupContainerWithArrow<BaseTaskbarContext> showForIcon(BubbleTextView ic
.filter(Objects::nonNull)
.collect(Collectors.toList());

if (ENABLE_MATERIAL_U_POPUP.get()) {
if (FeatureFlags.showMaterialUPopup(this)) {
container = (PopupContainerWithArrow) context.getLayoutInflater().inflate(
R.layout.popup_container_material_u, context.getDragLayer(), false);
container.populateAndShowRowsMaterialU(icon, deepShortcutCount, systemShortcuts);
Expand Down
5 changes: 5 additions & 0 deletions src/com/android/launcher3/config/FeatureFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public static boolean showDotPagination(Context context) {
PreferenceManager2 preferenceManager2 = PreferenceManager2.getInstance(context);
return PreferenceExtensionsKt.firstBlocking(preferenceManager2.getEnableDotPagination());
}

public static boolean showMaterialUPopup(Context context) {
PreferenceManager2 preferenceManager2 = PerferenceManager2.getInstance(context);
return PreferenceExtensionsKt.firstBlocking(preferenceManager2.getEnableMaterialUPopUp());
}
/**
* Feature flag to handle define config changes dynamically instead of killing the process.
* <p>
Expand Down
12 changes: 6 additions & 6 deletions src/com/android/launcher3/popup/ArrowPopup.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public ArrowPopup(Context context, AttributeSet attrs, int defStyleAttr) {

mIterateChildrenTag = getContext().getString(R.string.popup_container_iterate_children);

if (!ENABLE_MATERIAL_U_POPUP.get() && mActivityContext.canUseMultipleShadesForPopup()) {
if (!FeatureFlags.showMaterialUPopup(this) && mActivityContext.canUseMultipleShadesForPopup()) {
mColors = new int[] {
ColorTokens.PopupShadeFirst.resolveColor(context),
ColorTokens.PopupShadeSecond.resolveColor(context),
Expand Down Expand Up @@ -266,18 +266,18 @@ protected void assignMarginsAndBackgrounds(ViewGroup viewGroup, int backgroundCo
mlp.bottomMargin = 0;

if (colors != null) {
if (!ENABLE_MATERIAL_U_POPUP.get()) {
if (!FeatureFlags.showMaterialUPopup(this)) {
backgroundColor = colors[numVisibleChild % colors.length];
}

if (ENABLE_MATERIAL_U_POPUP.get() && isShortcutContainer(view)) {
if (FeatureFlags.showMaterialUPopup(this) && isShortcutContainer(view)) {
setChildColor(view, colors[0], colorAnimator);
mArrowColor = colors[0];
}
}

// Arrow color matches the first child or the last child.
if (!ENABLE_MATERIAL_U_POPUP.get()
if (!FeatureFlags.showMaterialUPopup(this)
&& (mIsAboveIcon || (numVisibleChild == 0 && viewGroup == this))) {
mArrowColor = backgroundColor;
}
Expand Down Expand Up @@ -591,7 +591,7 @@ protected View getAccessibilityInitialFocusView() {

protected void animateOpen() {
setVisibility(View.VISIBLE);
mOpenCloseAnimator = ENABLE_MATERIAL_U_POPUP.get()
mOpenCloseAnimator = FeatureFlags.showMaterialUPopup(this)
? getMaterialUOpenCloseAnimator(
true,
OPEN_DURATION_U,
Expand Down Expand Up @@ -691,7 +691,7 @@ protected void animateClose() {
}
mIsOpen = false;

mOpenCloseAnimator = ENABLE_MATERIAL_U_POPUP.get()
mOpenCloseAnimator = FeatureFlags.showMaterialUPopup(this)
? getMaterialUOpenCloseAnimator(
false,
CLOSE_DURATION_U,
Expand Down
4 changes: 2 additions & 2 deletions src/com/android/launcher3/popup/PopupContainerWithArrow.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public static PopupContainerWithArrow<Launcher> showForIcon(BubbleTextView icon)
.map(s -> s.getShortcut(launcher, item, icon))
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (ENABLE_MATERIAL_U_POPUP.get()) {
if (FeatureFlags.showMaterialUPopup(this)) {
container = (PopupContainerWithArrow) launcher.getLayoutInflater().inflate(
R.layout.popup_container_material_u, launcher.getDragLayer(), false);
container.configureForLauncher(launcher);
Expand Down Expand Up @@ -504,7 +504,7 @@ private void addSystemShortcutsIconsOnly(List<SystemShortcut> systemShortcuts) {
return;
}

mSystemShortcutContainer = ENABLE_MATERIAL_U_POPUP.get()
mSystemShortcutContainer = FeatureFlags.showMaterialUPopup(this)
? inflateAndAdd(R.layout.system_shortcut_icons_container_material_u, this)
: inflateAndAdd(R.layout.system_shortcut_icons_container, this, 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ boolean onIconLongClicked(View v) {
}
int deepShortcutCount = popupDataProvider.getShortcutCountForItem(item);
final PopupContainerWithArrow<SecondaryDisplayLauncher> container;
if (ENABLE_MATERIAL_U_POPUP.get()) {
if (FeatureFlags.showMaterialUPopup(this)) {
container = (PopupContainerWithArrow) mActivity.getLayoutInflater().inflate(
R.layout.popup_container_material_u, mActivity.getDragLayer(), false);
container.populateAndShowRowsMaterialU((BubbleTextView) v, deepShortcutCount,
Expand Down
2 changes: 1 addition & 1 deletion src/com/android/launcher3/views/OptionsPopupView.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected void getTargetObjectLocation(Rect outPos) {

@Override
public void assignMarginsAndBackgrounds(ViewGroup viewGroup) {
if (ENABLE_MATERIAL_U_POPUP.get()) {
if (FeatureFlags.showMaterialUPopup(this)) {
assignMarginsAndBackgrounds(viewGroup,
mColors[0]);
} else {
Expand Down

0 comments on commit 2a18dff

Please sign in to comment.