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

Commit a5a44f32 authored by Weng Su's avatar Weng Su
Browse files

Refine Spinner style in Mobile data usage settings

- Use setSelectedPosition() to show the check icon

- Since the default dropDownVerticalOffset of SettingsSpinnerAdapter is 72dp, which is suitable for Preference layout, it needs to be adjusted to 48dp to be suitable for the standard Spinner.

Bug: 409888634
Flag: EXEMPT refactor
Test: Manual testing

Change-Id: Id53f5f19df034fd2ad3ab55ce749d18fb389544a
parent fdc069e0
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -26,7 +26,8 @@
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_centerHorizontal="true"
        android:theme="@style/Widget.PopupWindow.Settings"/>
        android:theme="@style/Widget.PopupWindow.Settings"
        android:dropDownVerticalOffset="@dimen/min_tap_target_size"/>

    <ImageView
        android:id="@+id/filter_settings"
+2 −1
Original line number Diff line number Diff line
@@ -24,7 +24,8 @@
        android:id="@+id/cycles_spinner"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_centerInParent="true"/>
        android:layout_centerInParent="true"
        android:dropDownVerticalOffset="@dimen/min_tap_target_size"/>

</RelativeLayout>
+15 −0
Original line number Diff line number Diff line
@@ -15,6 +15,12 @@ package com.android.settings.datausage;

import android.content.Context;
import android.util.Range;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Spinner;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.settings.Utils;
import com.android.settingslib.widget.SettingsSpinnerAdapter;
@@ -31,6 +37,15 @@ public class CycleAdapter extends SettingsSpinnerAdapter<CycleAdapter.CycleItem>
        mSpinner.setAdapter(this);
    }

    @Override
    public View getDropDownView(int position, @Nullable View convertView,
            @NonNull ViewGroup parent) {
        if (parent instanceof Spinner) {
            setSelectedPosition(((Spinner) parent).getSelectedItemPosition());
        }
        return super.getDropDownView(position, convertView, parent);
    }

    /**
     * Find position of {@link CycleItem} in this adapter which is nearest
     * the given {@link CycleItem}.