Support autoclick secondary action (3/n)

Changeed autoclick preference summary unit from ms to second.

Bug: 146019277
Test: manual
Change-Id: Ib5dcc2459716277cd278c1e19dbb99bb540b25ce
This commit is contained in:
ChenJean
2020-02-07 16:30:47 +08:00
parent 978b19ec63
commit b30e394305
3 changed files with 35 additions and 30 deletions

View File

@@ -5028,28 +5028,28 @@
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] --> <!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
<plurals name="accessibilty_autoclick_preference_subtitle_extremely_short_delay"> <plurals name="accessibilty_autoclick_preference_subtitle_extremely_short_delay">
<item quantity="one">Extremely short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item> <item quantity="one">Extremely short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> second)</item>
<item quantity="other">Extremely short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item> <item quantity="other">Extremely short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> seconds)</item>
</plurals> </plurals>
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] --> <!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
<plurals name="accessibilty_autoclick_preference_subtitle_very_short_delay"> <plurals name="accessibilty_autoclick_preference_subtitle_very_short_delay">
<item quantity="one">Very short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item> <item quantity="one">Very short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> second)</item>
<item quantity="other">Very short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item> <item quantity="other">Very short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> seconds)</item>
</plurals> </plurals>
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] --> <!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
<plurals name="accessibilty_autoclick_preference_subtitle_short_delay"> <plurals name="accessibilty_autoclick_preference_subtitle_short_delay">
<item quantity="one">Short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item> <item quantity="one">Short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> second)</item>
<item quantity="other">Short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item> <item quantity="other">Short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> seconds)</item>
</plurals> </plurals>
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] --> <!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
<plurals name="accessibilty_autoclick_preference_subtitle_long_delay"> <plurals name="accessibilty_autoclick_preference_subtitle_long_delay">
<item quantity="one">Long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item> <item quantity="one">Long delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> second)</item>
<item quantity="other">Long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item> <item quantity="other">Long delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> seconds)</item>
</plurals> </plurals>
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] --> <!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
<plurals name="accessibilty_autoclick_preference_subtitle_very_long_delay"> <plurals name="accessibilty_autoclick_preference_subtitle_very_long_delay">
<item quantity="one">Very long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item> <item quantity="one">Very long delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> second)</item>
<item quantity="other">Very long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item> <item quantity="other">Very long delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> seconds)</item>
</plurals> </plurals>
<!-- Summary for autoclick seekbar settings preference when user selected custom item. [CHAR LIMIT=35] --> <!-- Summary for autoclick seekbar settings preference when user selected custom item. [CHAR LIMIT=35] -->

View File

@@ -19,10 +19,8 @@ package com.android.settings.accessibility;
import static android.content.Context.MODE_PRIVATE; import static android.content.Context.MODE_PRIVATE;
import static com.android.settings.accessibility.ToggleAutoclickPreferenceController.KEY_DELAY_MODE; import static com.android.settings.accessibility.ToggleAutoclickPreferenceController.KEY_DELAY_MODE;
import static com.android.settings.accessibility.ToggleAutoclickPreferenceFragment.Quantity;
import static java.lang.annotation.RetentionPolicy.SOURCE;
import android.annotation.IntDef;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@@ -42,8 +40,6 @@ import com.android.settingslib.core.lifecycle.events.OnPause;
import com.android.settingslib.core.lifecycle.events.OnResume; import com.android.settingslib.core.lifecycle.events.OnResume;
import com.android.settingslib.widget.LayoutPreference; import com.android.settingslib.widget.LayoutPreference;
import java.lang.annotation.Retention;
/** /**
* Controller class that controls accessibility autoclick seekbar settings. * Controller class that controls accessibility autoclick seekbar settings.
*/ */
@@ -51,16 +47,6 @@ public class ToggleAutoclickCustomSeekbarController extends BasePreferenceContro
implements LifecycleObserver, OnResume, OnPause, implements LifecycleObserver, OnResume, OnPause,
SharedPreferences.OnSharedPreferenceChangeListener { SharedPreferences.OnSharedPreferenceChangeListener {
@Retention(SOURCE)
@IntDef({
Quantity.OTHER,
Quantity.ONE
})
@interface Quantity {
int OTHER = 0;
int ONE = 1;
}
private static final String CONTROL_AUTOCLICK_DELAY_SECURE = private static final String CONTROL_AUTOCLICK_DELAY_SECURE =
Settings.Secure.ACCESSIBILITY_AUTOCLICK_DELAY; Settings.Secure.ACCESSIBILITY_AUTOCLICK_DELAY;
private static final String KEY_CUSTOM_DELAY_VALUE = "custom_delay_value"; private static final String KEY_CUSTOM_DELAY_VALUE = "custom_delay_value";

View File

@@ -19,6 +19,9 @@ package com.android.settings.accessibility;
import static com.android.settings.accessibility.ToggleAutoclickCustomSeekbarController.MAX_AUTOCLICK_DELAY_MS; import static com.android.settings.accessibility.ToggleAutoclickCustomSeekbarController.MAX_AUTOCLICK_DELAY_MS;
import static com.android.settings.accessibility.ToggleAutoclickCustomSeekbarController.MIN_AUTOCLICK_DELAY_MS; import static com.android.settings.accessibility.ToggleAutoclickCustomSeekbarController.MIN_AUTOCLICK_DELAY_MS;
import static java.lang.annotation.RetentionPolicy.SOURCE;
import android.annotation.IntDef;
import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
@@ -32,6 +35,7 @@ import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.search.SearchIndexable; import com.android.settingslib.search.SearchIndexable;
import java.lang.annotation.Retention;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -46,6 +50,16 @@ public class ToggleAutoclickPreferenceFragment extends DashboardFragment
private static final String TAG = "AutoclickPrefFragment"; private static final String TAG = "AutoclickPrefFragment";
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>(); private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
@Retention(SOURCE)
@IntDef({
Quantity.OTHER,
Quantity.ONE
})
@interface Quantity {
int OTHER = 0;
int ONE = 1;
}
/** /**
* Resource ids from which autoclick preference summaries should be derived. The strings have * Resource ids from which autoclick preference summaries should be derived. The strings have
* placeholder for integer delay value. * placeholder for integer delay value.
@@ -63,12 +77,17 @@ public class ToggleAutoclickPreferenceFragment extends DashboardFragment
* delay. * delay.
* *
* @param resources Resources from which string should be retrieved. * @param resources Resources from which string should be retrieved.
* @param delay Delay for whose value summary should be retrieved. * @param delayMillis Delay for whose value summary should be retrieved.
*/ */
static CharSequence getAutoclickPreferenceSummary(Resources resources, int delay) { static CharSequence getAutoclickPreferenceSummary(Resources resources, int delayMillis) {
int summaryIndex = getAutoclickPreferenceSummaryIndex(delay); final int summaryIndex = getAutoclickPreferenceSummaryIndex(delayMillis);
return resources.getQuantityString( final int quantity = (delayMillis == 1000) ? Quantity.ONE : Quantity.OTHER;
mAutoclickPreferenceSummaries[summaryIndex], delay, delay); final float delaySecond = (float) delayMillis / 1000;
// Only show integer when delay time is 1.
final String decimalFormat = (delaySecond == 1) ? "%.0f" : "%.1f";
return resources.getQuantityString(mAutoclickPreferenceSummaries[summaryIndex],
quantity, String.format(decimalFormat, delaySecond));
} }
/** /**