Bug: 185400417 Test: manual (the autoclick location has changed to Settings > System > Trackpad & mouse > Pointer & touch accessibility > Autoclick) Flag: EXEMPT low risk localization fix Change-Id: Iee63b87513550a6758db9dce376e88a12a51d9f8
71 lines
2.6 KiB
Java
71 lines
2.6 KiB
Java
/*
|
|
* Copyright (C) 2022 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package com.android.settings.accessibility;
|
|
|
|
import android.annotation.StringRes;
|
|
import android.content.Context;
|
|
|
|
import com.android.settingslib.utils.StringUtil;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
/** Provides utility methods related auto click. */
|
|
public final class AutoclickUtils {
|
|
|
|
/** Used for autoclick mode in the preferences editor. */
|
|
static final String KEY_DELAY_MODE = "delay_mode";
|
|
|
|
/** Used for autoclick custom delay in the preferences editor. */
|
|
static final String KEY_CUSTOM_DELAY_VALUE = "custom_delay_value";
|
|
|
|
/** Min allowed autoclick delay value. */
|
|
static final int MIN_AUTOCLICK_DELAY_MS = 200;
|
|
|
|
/** Max allowed autoclick delay value. */
|
|
static final int MAX_AUTOCLICK_DELAY_MS = 1000;
|
|
|
|
/**
|
|
* Allowed autoclick delay values are discrete. This is the difference between two allowed
|
|
* values.
|
|
*/
|
|
static final int AUTOCLICK_DELAY_STEP = 100;
|
|
|
|
/**
|
|
* Gets string that should be used for provided autoclick delay.
|
|
*
|
|
* @param context context from which string should be retrieved.
|
|
* @param id The desired resource identifier, as generated by the aapt
|
|
* tool. This integer encodes the package, type, and resource
|
|
* entry. The value 0 is an invalid identifier.
|
|
* @param delayMillis Delay for whose value summary should be retrieved.
|
|
*/
|
|
public static CharSequence getAutoclickDelaySummary(Context context,
|
|
@StringRes int id, int delayMillis) {
|
|
final float delaySecond = (float) delayMillis / 1000;
|
|
// Only show integer when delay time is 1.
|
|
final String decimalFormat = (delaySecond == 1) ? "%.0f" : "%.1f";
|
|
|
|
Map<String, Object> arguments = new HashMap<>();
|
|
arguments.put("count", delaySecond);
|
|
arguments.put("time", String.format(decimalFormat, delaySecond));
|
|
return StringUtil.getIcuPluralsString(context, arguments, id);
|
|
}
|
|
|
|
private AutoclickUtils(){}
|
|
}
|