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

Commit 7a7b4242 authored by Stanley Wang's avatar Stanley Wang Committed by Automerger Merge Worker
Browse files

Merge "Fix the problem that the "Turn off SIM" dialog will be displayed when...

Merge "Fix the problem that the "Turn off SIM" dialog will be displayed when the MobileNetwork page is slid to to top." into sc-dev am: d0adfa7b am: 6cb273d8

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/14964824

Change-Id: Id3a3a1ef3cbb15bb06a92bc6bf406b2b723b4351
parents 3cc252d0 6cb273d8
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -82,15 +82,15 @@ public class SettingsMainSwitchPreference extends TwoStatePreference implements
        holder.setDividerAllowedAbove(false);
        holder.setDividerAllowedBelow(false);

        mMainSwitchBar = (SettingsMainSwitchBar) holder.findViewById(R.id.main_switch_bar);
        mMainSwitchBar.show();
        if (mRestrictedHelper != null) {
            mEnforcedAdmin = mRestrictedHelper.checkRestrictionEnforced();
        }
        mMainSwitchBar = (SettingsMainSwitchBar) holder.findViewById(R.id.main_switch_bar);
        if (mIsVisible) {
            mMainSwitchBar.show();
            updateStatus(isChecked());
            registerListenerToSwitchBar();

        if (!mIsVisible) {
        } else {
            mMainSwitchBar.hide();
        }
    }
+26 −0
Original line number Diff line number Diff line
@@ -24,6 +24,10 @@ import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import androidx.preference.PreferenceViewHolder;

import com.android.settings.R;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -39,6 +43,7 @@ public class SettingsMainSwitchPreferenceTest {
    @Mock
    private EnforcedAdmin mEnforcedAdmin;
    private SettingsMainSwitchPreference mPreference;
    private PreferenceViewHolder mHolder;

    @Before
    public void setUp() {
@@ -48,6 +53,9 @@ public class SettingsMainSwitchPreferenceTest {
        mPreference = new SettingsMainSwitchPreference(context);
        ReflectionHelpers.setField(mPreference, "mEnforcedAdmin", mEnforcedAdmin);
        ReflectionHelpers.setField(mPreference, "mMainSwitchBar", switchBar);
        final View rootView = View.inflate(context, R.layout.preference_widget_main_switch,
                null /* parent */);
        mHolder = PreferenceViewHolder.createInstanceForTests(rootView);
    }

    @Test
@@ -60,4 +68,22 @@ public class SettingsMainSwitchPreferenceTest {

        assertThat(restrictedIcon.getVisibility() == View.VISIBLE).isTrue();
    }

    @Test
    public void show_preferenceShouldDisplay() {
        mPreference.show();

        mPreference.onBindViewHolder(mHolder);

        assertThat(mPreference.isShowing()).isTrue();
    }

    @Test
    public void hide_preferenceShouldNotDisplay() {
        mPreference.hide();

        mPreference.onBindViewHolder(mHolder);

        assertThat(mPreference.isShowing()).isFalse();
    }
}