Fixed One-Handed preference item’s second line should show on/off
status in Settings > System > Gesture > One-Handed. To override getSummary() method to display on/off status in One-Handed preference item’s second line. Bug: 154600203 Test: manual Change-Id: Ic9a5b74fbca041a08e712d5529b66e672f0c74ab
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.settings.gestures;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
@@ -46,4 +47,11 @@ public class OneHandedEnablePreferenceController extends TogglePreferenceControl
|
||||
public boolean isChecked() {
|
||||
return OneHandedSettingsUtils.isOneHandedModeEnabled(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return OneHandedSettingsUtils.isOneHandedModeEnabled(mContext)
|
||||
? mContext.getText(R.string.switch_on_text)
|
||||
: mContext.getText(R.string.switch_off_text);
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -60,4 +61,20 @@ public class OneHandedEnablePreferenceControllerTest {
|
||||
assertThat(mController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummary_enabledOneHanded_shouldDisplayOnSummary() {
|
||||
OneHandedSettingsUtils.setSettingsOneHandedModeEnabled(mContext, true);
|
||||
|
||||
assertThat(mController.getSummary())
|
||||
.isEqualTo(mContext.getText(R.string.switch_on_text));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummary_disabledOneHanded_shouldDisplayOffSummary() {
|
||||
OneHandedSettingsUtils.setSettingsOneHandedModeEnabled(mContext, false);
|
||||
|
||||
assertThat(mController.getSummary())
|
||||
.isEqualTo(mContext.getText(R.string.switch_off_text));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user