Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 692c2ba5 authored by chihhangchuang's avatar chihhangchuang
Browse files

Apply BottomActionBar to grid page

Video: https://drive.google.com/a/google.com/file/d/1EhYS7kl73tVw9NX6tfA4-F8_nrvkk-RL/view?usp=sharing

Test: Manually
Bug: 151287328
Change-Id: I3d23d29a11eb116e92e3d8c7e4bc27c3bdfd1f2a
parent 1754f33a
Loading
Loading
Loading
Loading
+1 −14
Original line number Diff line number Diff line
@@ -64,24 +64,11 @@
                android:id="@+id/placeholder"
                android:layout_width="match_parent"
                android:layout_height="@dimen/min_taptarget_height"
                app:layout_constraintBottom_toTopOf="@id/apply_button"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/options_container"
                app:layout_constraintVertical_bias="1.0"/>

            <Button
                android:id="@+id/apply_button"
                style="@style/ActionPrimaryButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="end"
                android:layout_marginEnd="10dp"
                android:layout_marginVertical="10dp"
                android:layout_weight="1"
                android:text="@string/apply_theme_btn"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"/>

        </androidx.constraintlayout.widget.ConstraintLayout>

        <androidx.core.widget.ContentLoadingProgressBar
+10 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ import com.android.wallpaper.picker.MyPhotosStarter.PermissionChangedListener;
import com.android.wallpaper.picker.TopLevelPickerActivity;
import com.android.wallpaper.picker.WallpaperPickerDelegate;
import com.android.wallpaper.picker.WallpapersUiContainer;
import com.android.wallpaper.widget.BottomActionBar;

import com.google.android.material.bottomnavigation.BottomNavigationView;

@@ -287,9 +288,18 @@ public class CustomizationPickerActivity extends FragmentActivity implements Wal

    @Override
    public void onBackPressed() {
        // For wallpaper tab, since it had child fragment.
        if (mWallpaperCategoryFragment != null && mWallpaperCategoryFragment.popChildFragment()) {
            return;
        }

        // For other tabs without child fragment. Hide the BottomActionBar if back key is pressed.
        BottomActionBar bottomActionBar = findViewById(R.id.bottom_actionbar);
        if (bottomActionBar != null && bottomActionBar.isVisible()) {
            bottomActionBar.hide();
            return;
        }

        if (getSupportFragmentManager().popBackStackImmediate()) {
            return;
        }
+25 −13
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@ package com.android.customization.picker.grid;

import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;

import static com.android.wallpaper.widget.BottomActionBar.BottomAction.APPLY;
import static com.android.wallpaper.widget.BottomActionBar.BottomAction.CANCEL;

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
@@ -57,11 +60,13 @@ import com.android.wallpaper.module.CurrentWallpaperInfoFactory;
import com.android.wallpaper.module.InjectorProvider;
import com.android.wallpaper.picker.ToolbarFragment;
import com.android.wallpaper.util.SurfaceViewUtils;
import com.android.wallpaper.widget.BottomActionBar;
import com.android.wallpaper.widget.PreviewPager;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;

import java.util.EnumSet;
import java.util.List;

/**
@@ -100,6 +105,7 @@ public class GridFragment extends ToolbarFragment {
    private ContentLoadingProgressBar mLoading;
    private View mContent;
    private View mError;
    private BottomActionBar mBottomActionBar;
    private ThemesUserEventLogger mEventLogger;

    @Override
@@ -141,20 +147,7 @@ public class GridFragment extends ToolbarFragment {
        // Clear memory cache whenever grid fragment view is being loaded.
        Glide.get(getContext()).clearMemory();
        setUpOptions();
        view.findViewById(R.id.apply_button).setOnClickListener(v -> {
            mGridManager.apply(mSelectedOption,  new Callback() {
                @Override
                public void onSuccess() {
                    getActivity().finish();
                }

                @Override
                public void onError(@Nullable Throwable throwable) {
                    //TODO(santie): handle
                }
            });

        });
        CurrentWallpaperInfoFactory factory = InjectorProvider.getInjector()
                .getCurrentWallpaperFactory(getContext().getApplicationContext());

@@ -174,6 +167,24 @@ public class GridFragment extends ToolbarFragment {
                loadWallpaperBackground();
            }
        });

        mBottomActionBar = getActivity().findViewById(R.id.bottom_actionbar);
        mBottomActionBar.showActionsOnly(EnumSet.of(CANCEL, APPLY));
        mBottomActionBar.setActionClickListener(CANCEL, unused -> getActivity().onBackPressed());
        mBottomActionBar.setActionClickListener(APPLY, unused -> {
            mBottomActionBar.disableActions();
            mGridManager.apply(mSelectedOption, new Callback() {
                @Override
                public void onSuccess() {
                    getActivity().finish();
                }

                @Override
                public void onError(@Nullable Throwable throwable) {
                    //TODO(santie): handle
                }
            });
        });
        return view;
    }

@@ -207,6 +218,7 @@ public class GridFragment extends ToolbarFragment {

                mOptionsController.addListener(selected -> {
                    mSelectedOption = (GridOption) selected;
                    mBottomActionBar.show();
                    mEventLogger.logGridSelected(mSelectedOption);
                    createAdapter();
                });