diff options
author | Chihhang Chuang <chihhangchuang@google.com> | 2021-06-24 16:59:16 +0800 |
---|---|---|
committer | Chihhang Chuang <chihhangchuang@google.com> | 2021-06-24 18:26:32 +0800 |
commit | 0e66ec9aa4c641c86499a829faa3892f7579fd11 (patch) | |
tree | 9cda62eee25fa6733d4b46dca004f9a56b4164c0 /src/com/android | |
parent | ab4c46aac05250120155732e1246ad142f6e6012 (diff) | |
download | ThemePicker-0e66ec9aa4c641c86499a829faa3892f7579fd11.tar.gz |
Update the bottom sheet usage of BottomActionBar
Fixes: 191940562
Test: Manually
Change-Id: I3097ae43902864d3acc36e634c0829962562131c
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/customization/picker/theme/ThemeFragment.java | 27 | ||||
-rw-r--r-- | src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java | 25 |
2 files changed, 45 insertions, 7 deletions
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java index 3537c36d..f5d56ca5 100644 --- a/src/com/android/customization/picker/theme/ThemeFragment.java +++ b/src/com/android/customization/picker/theme/ThemeFragment.java @@ -52,6 +52,7 @@ import com.android.wallpaper.module.InjectorProvider; import com.android.wallpaper.picker.AppbarFragment; import com.android.wallpaper.widget.BottomActionBar; import com.android.wallpaper.widget.BottomActionBar.AccessibilityCallback; +import com.android.wallpaper.widget.BottomActionBar.BottomSheetContent; import java.util.List; @@ -147,9 +148,9 @@ public class ThemeFragment extends AppbarFragment { mBottomActionBar.disableActions(); applyTheme(); }); - mThemeInfoView = (ThemeInfoView) LayoutInflater.from(getContext()).inflate( - R.layout.theme_info_view, /* root= */ null); - mBottomActionBar.attachViewToBottomSheetAndBindAction(mThemeInfoView, INFORMATION); + + mBottomActionBar.bindBottomSheetContentWithAction( + new ThemeInfoContent(getContext()), INFORMATION); mBottomActionBar.setActionClickListener(CUSTOMIZE, this::onCustomizeClicked); // Update target view's accessibility param since it will be blocked by the bottom sheet @@ -378,4 +379,24 @@ public class ThemeFragment extends AppbarFragment { themeToEdit.getSerializedPackages()); startActivityForResult(intent, CustomThemeActivity.REQUEST_CODE_CUSTOM_THEME); } + + private final class ThemeInfoContent extends BottomSheetContent<ThemeInfoView> { + + private ThemeInfoContent(Context context) { + super(context); + } + + @Override + public int getViewId() { + return R.layout.theme_info_view; + } + + @Override + public void onViewCreated(ThemeInfoView view) { + mThemeInfoView = view; + if (mSelectedTheme != null) { + mThemeInfoView.populateThemeInfo(mSelectedTheme); + } + } + } } diff --git a/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java b/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java index 5ea84ce8..3ba64ecc 100644 --- a/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java +++ b/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java @@ -21,6 +21,7 @@ import static com.android.wallpaper.widget.BottomActionBar.BottomAction.APPLY; import static com.android.wallpaper.widget.BottomActionBar.BottomAction.INFORMATION; import android.app.Activity; +import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.util.Log; @@ -42,6 +43,7 @@ import com.android.wallpaper.model.WallpaperInfo; import com.android.wallpaper.module.InjectorProvider; import com.android.wallpaper.picker.AppbarFragment; import com.android.wallpaper.widget.BottomActionBar; +import com.android.wallpaper.widget.BottomActionBar.BottomSheetContent; import com.bumptech.glide.Glide; @@ -131,10 +133,8 @@ public class ThemeFullPreviewFragment extends AppbarFragment { } else { bottomActionBar.showActionsOnly(INFORMATION); } - ThemeInfoView themeInfoView = (ThemeInfoView) LayoutInflater.from(getContext()).inflate( - R.layout.theme_info_view, /* root= */ null); - themeInfoView.populateThemeInfo(mThemeBundle); - bottomActionBar.attachViewToBottomSheetAndBindAction(themeInfoView, INFORMATION); + bottomActionBar.bindBottomSheetContentWithAction( + new ThemeInfoContent(getContext()), INFORMATION); bottomActionBar.show(); } @@ -145,4 +145,21 @@ public class ThemeFullPreviewFragment extends AppbarFragment { activity.setResult(RESULT_OK, intent); activity.finish(); } + + private final class ThemeInfoContent extends BottomSheetContent<ThemeInfoView> { + + private ThemeInfoContent(Context context) { + super(context); + } + + @Override + public int getViewId() { + return R.layout.theme_info_view; + } + + @Override + public void onViewCreated(ThemeInfoView view) { + view.populateThemeInfo(mThemeBundle); + } + } } |