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

Commit 175275c9 authored by Amin Shaikh's avatar Amin Shaikh
Browse files

Theme picker polish fixes.

- Do not show Previous on first custom screen
- Show a toast instead of exiting the activity when
applying the clock
- Mutate drawables in custom theme icon preview thumbnails

Fixes: 132282403
Fixes: 132282415
Test: visual
Change-Id: If230c5c95ba92b787b9e6580261b0a662c159549
parent b7be6514
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -105,6 +105,9 @@
    <!-- Message shown when a theme has been applied successfully in the system [CHAR LIMIT=NONE] -->
    <string name="applied_theme_msg">Style applied</string>

    <!-- Message shown when a clock has been applied successfully in the system [CHAR LIMIT=NONE] -->
    <string name="applied_clock_msg">Clock applied</string>

    <!-- Message shown when a theme couldn't be applied in the system because of an error
        [CHAR LIMIT=NONE] -->
    <string name="apply_theme_error_msg">There was a problem applying the style</string>
+2 −1
Original line number Diff line number Diff line
@@ -150,7 +150,8 @@ public abstract class ThemeComponentOption implements CustomizationOption<ThemeC
        @Override
        public void bindThumbnailTile(View view) {
            Resources res = view.getContext().getResources();
            Drawable icon = mIcons.get(THUMBNAIL_ICON_POSITION).mutate();
            Drawable icon = mIcons.get(THUMBNAIL_ICON_POSITION)
                    .getConstantState().newDrawable().mutate();
            icon.setTint(res.getColor(R.color.icon_thumbnail_color, null));
            ((ImageView) view.findViewById(R.id.option_icon)).setImageDrawable(
                    icon);
+4 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -87,7 +88,9 @@ public class ClockFragment extends ToolbarFragment {
            mClockManager.apply(mSelectedOption, new Callback() {
                @Override
                public void onSuccess() {
                    getActivity().finish();
                    mOptionsController.setAppliedOption(mSelectedOption);
                    Toast.makeText(getContext(), R.string.applied_clock_msg,
                            Toast.LENGTH_SHORT).show();
                }

                @Override
+5 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

@@ -152,7 +153,7 @@ public class CustomThemeActivity extends FragmentActivity implements
        }
        fragmentTransaction.commit();
        fragmentManager.executePendingTransactions();
        updateApplyButtonLabel();
        updateNavigationButtonLabels();
    }

    private void initSteps(int currentStep) {
@@ -245,10 +246,11 @@ public class CustomThemeActivity extends FragmentActivity implements
    @Override
    public void setCurrentStep(int i) {
        mCurrentStep = i;
        updateApplyButtonLabel();
        updateNavigationButtonLabels();
    }

    private void updateApplyButtonLabel() {
    private void updateNavigationButtonLabels() {
        mPreviousButton.setVisibility(mCurrentStep == 0 ? View.INVISIBLE : View.VISIBLE);
        mNextButton.setText((mCurrentStep < mSteps.size() -1) ? R.string.custom_theme_next
                : R.string.apply_btn);
    }
+5 −0
Original line number Diff line number Diff line
@@ -111,7 +111,12 @@ public class OptionSelectorController<T extends CustomizationOption<T>> {
        if (!mOptions.contains(option)) {
            throw new IllegalArgumentException("Invalid option");
        }
        CustomizationOption lastAppliedOption = mAppliedOption;
        mAppliedOption = option;
        mAdapter.notifyItemChanged(mOptions.indexOf(option));
        if (lastAppliedOption != null) {
            mAdapter.notifyItemChanged(mOptions.indexOf(lastAppliedOption));
        }
    }

    private void updateActivatedStatus(CustomizationOption option, boolean isActivated) {