Fine tunes the color correction layout

Bug: 145968068
Test: Manual test
Change-Id: I291f2669c110ff6571039da2d224015dfef85488
This commit is contained in:
menghanli
2020-02-12 20:26:41 +08:00
parent c359bdf884
commit 0922c5a292
5 changed files with 23 additions and 10 deletions

View File

@@ -22,10 +22,12 @@
<TextView <TextView
android:id="@+id/item_textview" android:id="@+id/item_textview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="42dp"
android:paddingLeft="10dp" android:fontFamily="roboto-bold"
android:textSize="20dp" android:gravity="center_vertical"
android:maxLength="20" android:maxLength="20"
android:singleLine="true"/> android:paddingLeft="@dimen/accessibility_layout_margin_start_end"
android:singleLine="true"
android:textSize="14dp" />
</FrameLayout> </FrameLayout>

View File

@@ -266,7 +266,7 @@
<dimen name="message_metadata_top_padding">4dp</dimen> <dimen name="message_metadata_top_padding">4dp</dimen>
<!-- Accessibility Settings --> <!-- Accessibility Settings -->
<dimen name="accessibility_layout_margin_start_end">24dp</dimen> <dimen name="accessibility_layout_margin_start_end">16dp</dimen>
<dimen name="accessibility_button_preference_padding_top_bottom">18dp</dimen> <dimen name="accessibility_button_preference_padding_top_bottom">18dp</dimen>
<!-- Accessibility, Screen magnification. These values are meant to be relative values and the actual layout value will be set programmatically. --> <!-- Accessibility, Screen magnification. These values are meant to be relative values and the actual layout value will be set programmatically. -->

View File

@@ -20,6 +20,7 @@ import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.provider.Settings; import android.provider.Settings;
import android.view.View;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import androidx.lifecycle.LifecycleObserver; import androidx.lifecycle.LifecycleObserver;
@@ -122,6 +123,7 @@ public class DaltonizerRadioButtonPreferenceController extends BasePreferenceCon
mPreference = (RadioButtonPreference) mPreference = (RadioButtonPreference)
screen.findPreference(getPreferenceKey()); screen.findPreference(getPreferenceKey());
mPreference.setOnClickListener(this); mPreference.setOnClickListener(this);
mPreference.setAppendixVisibility(View.GONE);
updateState(mPreference); updateState(mPreference);
} }

View File

@@ -26,7 +26,7 @@ import android.widget.ListView;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder; import androidx.preference.PreferenceViewHolder;
import com.android.settingslib.widget.R; import com.android.settings.R;
/** Preference that easier preview by matching name to color. */ /** Preference that easier preview by matching name to color. */
public class PaletteListPreference extends Preference { public class PaletteListPreference extends Preference {

View File

@@ -35,7 +35,7 @@ import android.widget.TextView;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import com.android.settingslib.widget.R; import com.android.settings.R;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@@ -55,13 +55,13 @@ import java.util.List;
* display also the view background shows the color beside the text variable end point. * display also the view background shows the color beside the text variable end point.
*/ */
public class PaletteListView extends ListView { public class PaletteListView extends ListView {
private static final float VIEW_PITCH = 0.05f;
private final Context mContext; private final Context mContext;
private final DisplayAdapter mDisplayAdapter; private final DisplayAdapter mDisplayAdapter;
private final LayoutInflater mLayoutInflater; private final LayoutInflater mLayoutInflater;
private final String mDefaultGradientColorCodeString; private final String mDefaultGradientColorCodeString;
private final int mDefaultGradientColor; private final int mDefaultGradientColor;
private float mTextBound; private float mTextBound;
private static final float LANDSCAPE_MAX_WIDTH_PERCENTAGE = 100f;
public PaletteListView(Context context) { public PaletteListView(Context context) {
this(context, null); this(context, null);
@@ -206,8 +206,17 @@ public class PaletteListView extends ListView {
final float textWidth = textView.getPaint().measureText(textView.getText().toString()); final float textWidth = textView.getPaint().measureText(textView.getText().toString());
// Computes rate of text width compare to screen width, and measures the round the double // Computes rate of text width compare to screen width, and measures the round the double
// to two decimal places manually. // to two decimal places manually.
final float textBound = Math.round(textWidth / getScreenWidth(windowManager) * 100) / 100f; final float textBound = Math.round(
mTextBound = textBound + VIEW_PITCH; textWidth / getScreenWidth(windowManager) * LANDSCAPE_MAX_WIDTH_PERCENTAGE)
/ LANDSCAPE_MAX_WIDTH_PERCENTAGE;
// Left padding and right padding with color preview.
final float paddingPixel = getResources().getDimension(
R.dimen.accessibility_layout_margin_start_end);
final float paddingWidth =
Math.round(paddingPixel / getScreenWidth(windowManager)
* LANDSCAPE_MAX_WIDTH_PERCENTAGE) / LANDSCAPE_MAX_WIDTH_PERCENTAGE;
mTextBound = textBound + paddingWidth + paddingWidth;
} }
private static class ViewHolder { private static class ViewHolder {