Make settings cog animate back to original button

Provide the appropriate itemInfo so that launcherBackAnimation would play correctly.

bug:324569690
Test manual video: https://drive.google.com/file/d/1GfjL4PhdGOxs2KfDpieTNiFiKQ61aCgh/view?usp=sharing
Flag: ACONFIG com.android.launcher3.Flags.enable_private_space trunkfood

Change-Id: I1a9458643e932b279bf4ba4ea33e3dc0a2c121c2
This commit is contained in:
Brandon Dayauon committed 2024-04-18 14:32:33 -07:00
1 parent f15a96608a
commit 120838b04d
6 files changed
+35 -7

No files matched your search

@@ -21,6 +21,7 @@ import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_PRIVATESPACE;
import static com.android.launcher3.allapps.ActivityAllAppsContainerView.AdapterHolder.MAIN;
import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_ICON;
import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_PRIVATE_SPACE_HEADER;
@@ -216,11 +217,27 @@ public class PrivateProfileManager extends UserProfileManager {
resetPrivateSpaceDecorator(updatedState);
}
/** Opens the Private Space Settings Page. */
public void openPrivateSpaceSettings() {
/**
* Opens the Private Space Settings Page.
*
* @param view the view that was clicked to open the settings page and which will be the same
* view to animate back. Otherwise if there is no view, simply start the activity.
*/
public void openPrivateSpaceSettings(View view) {
if (mPrivateSpaceSettingsAvailable) {
mAllApps.getContext().startActivity(
ApiWrapper.INSTANCE.get(mAllApps.getContext()).getPrivateSpaceSettingsIntent());
Context context = mAllApps.getContext();
Intent intent = ApiWrapper.INSTANCE.get(context).getPrivateSpaceSettingsIntent();
if (view == null) {
context.startActivity(intent);
return;
}
ActivityContext activityContext = ActivityContext.lookupContext(context);
AppInfo itemInfo = new AppInfo();
itemInfo.id = CONTAINER_PRIVATESPACE;
itemInfo.componentName = intent.getComponent();
itemInfo.container = CONTAINER_PRIVATESPACE;
view.setTag(itemInfo);
activityContext.startActivitySafely(view, intent, itemInfo);
}
}
@@ -423,7 +440,7 @@ public class PrivateProfileManager extends UserProfileManager {
settingsButton.setOnClickListener(
view -> {
logEvents(LAUNCHER_PRIVATE_SPACE_SETTINGS_TAP);
openPrivateSpaceSettings();
openPrivateSpaceSettings(view);
});
} else {
settingsButton.setVisibility(GONE);