Fix that once the phone is rotated to portrait orientation, the "Use TalkBack" toggle is truncated.
Goals: 1. Extends the api of apply partner's customization padding style in the Settings widget "SettingsMainSwitchPreference" to dynamically adjust the padding depending on the SetupWizard library. 2. Use the function to avoid the button being truncated. Bug: 231512916 Test: manual test Change-Id: I951776185eb1616136d9caf3a60f9daea4da191a
This commit is contained in:
@@ -49,6 +49,8 @@ public class ToggleScreenReaderPreferenceFragmentForSetupWizard
|
|||||||
if (mTopIntroPreference != null) {
|
if (mTopIntroPreference != null) {
|
||||||
mTopIntroPreference.setVisible(false);
|
mTopIntroPreference.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mToggleServiceSwitchPreference.applyPartnerCustomizationPaddingStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -22,6 +22,7 @@ import android.content.Context;
|
|||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
|
|
||||||
import androidx.core.content.res.TypedArrayUtils;
|
import androidx.core.content.res.TypedArrayUtils;
|
||||||
@@ -33,6 +34,8 @@ import com.android.settings.widget.SettingsMainSwitchBar.OnBeforeCheckedChangeLi
|
|||||||
import com.android.settingslib.RestrictedPreferenceHelper;
|
import com.android.settingslib.RestrictedPreferenceHelper;
|
||||||
import com.android.settingslib.widget.OnMainSwitchChangeListener;
|
import com.android.settingslib.widget.OnMainSwitchChangeListener;
|
||||||
|
|
||||||
|
import com.google.android.setupdesign.util.LayoutStyler;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -48,6 +51,7 @@ public class SettingsMainSwitchPreference extends TwoStatePreference implements
|
|||||||
new ArrayList<>();
|
new ArrayList<>();
|
||||||
private final List<OnMainSwitchChangeListener> mSwitchChangeListeners = new ArrayList<>();
|
private final List<OnMainSwitchChangeListener> mSwitchChangeListeners = new ArrayList<>();
|
||||||
|
|
||||||
|
private boolean mApplyPartnerCustomizationPaddingStyle;
|
||||||
private SettingsMainSwitchBar mMainSwitchBar;
|
private SettingsMainSwitchBar mMainSwitchBar;
|
||||||
private CharSequence mTitle;
|
private CharSequence mTitle;
|
||||||
private EnforcedAdmin mEnforcedAdmin;
|
private EnforcedAdmin mEnforcedAdmin;
|
||||||
@@ -95,6 +99,12 @@ public class SettingsMainSwitchPreference extends TwoStatePreference implements
|
|||||||
} else {
|
} else {
|
||||||
mMainSwitchBar.hide();
|
mMainSwitchBar.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mApplyPartnerCustomizationPaddingStyle) {
|
||||||
|
// TODO(b/232494666): Replace all margins of the root view with the padding
|
||||||
|
final ViewGroup parentView = (ViewGroup) mMainSwitchBar.getParent();
|
||||||
|
LayoutStyler.applyPartnerCustomizationLayoutPaddingStyle(parentView);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(Context context, AttributeSet attrs) {
|
private void init(Context context, AttributeSet attrs) {
|
||||||
@@ -241,6 +251,14 @@ public class SettingsMainSwitchPreference extends TwoStatePreference implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apples the padding style of the partner's customization. It's used in the SetupWizard.
|
||||||
|
*/
|
||||||
|
public void applyPartnerCustomizationPaddingStyle() {
|
||||||
|
mApplyPartnerCustomizationPaddingStyle = true;
|
||||||
|
notifyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
private void initMainSwitchBar() {
|
private void initMainSwitchBar() {
|
||||||
if (mMainSwitchBar != null) {
|
if (mMainSwitchBar != null) {
|
||||||
mMainSwitchBar.setTitle(mTitle);
|
mMainSwitchBar.setTitle(mTitle);
|
||||||
|
Reference in New Issue
Block a user