Settings: Add a toggle for long press on navbar to search [3/3]
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
This commit is contained in:
@@ -302,4 +302,8 @@
|
|||||||
<!-- fingerprint lockout -->
|
<!-- fingerprint lockout -->
|
||||||
<string name="fingerprint_lockout_title">Disable fingerprint lockout</string>
|
<string name="fingerprint_lockout_title">Disable fingerprint lockout</string>
|
||||||
<string name="fingerprint_lockout_summary">Deactivates 30 second timeout as well as permanent lockout after multiple failed fingerprint unlock attempts</string>
|
<string name="fingerprint_lockout_summary">Deactivates 30 second timeout as well as permanent lockout after multiple failed fingerprint unlock attempts</string>
|
||||||
|
|
||||||
|
<!-- Long press navbar to search -->
|
||||||
|
<string name="navbar_long_press_gesture_title">Long press to search</string>
|
||||||
|
<string name="navbar_long_press_gesture_summary">Touch and hold the Home button or the navigation handle to search using the content on your screen</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -67,6 +67,12 @@
|
|||||||
settings:controller="com.android.settings.gestures.GestureNavigationSettingsAssistController"
|
settings:controller="com.android.settings.gestures.GestureNavigationSettingsAssistController"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:key="navbar_long_press_gesture"
|
||||||
|
android:title="@string/navbar_long_press_gesture_title"
|
||||||
|
android:summary="@string/navbar_long_press_gesture_summary"
|
||||||
|
settings:controller="com.android.settings.gestures.GestureNavigationLongPressController" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Yet Another AOSP 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.gestures;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.provider.Settings;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.core.TogglePreferenceController;
|
||||||
|
|
||||||
|
public class GestureNavigationLongPressController extends TogglePreferenceController {
|
||||||
|
|
||||||
|
private static final String GSA_PACKAGE = "com.google.android.googlequicksearchbox";
|
||||||
|
|
||||||
|
public GestureNavigationLongPressController(Context context, String key) {
|
||||||
|
super(context, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isChecked() {
|
||||||
|
return Settings.System.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.System.NAVBAR_LONG_PRESS_GESTURE, 1) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setChecked(boolean isChecked) {
|
||||||
|
return Settings.System.putInt(mContext.getContentResolver(),
|
||||||
|
Settings.System.NAVBAR_LONG_PRESS_GESTURE, isChecked ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
|
PackageManager pm = mContext.getPackageManager();
|
||||||
|
if (pm == null) {
|
||||||
|
return UNSUPPORTED_ON_DEVICE;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ApplicationInfo ai = pm.getApplicationInfo(GSA_PACKAGE, 0);
|
||||||
|
if (ai.enabled && ai.isProduct()) {
|
||||||
|
return AVAILABLE;
|
||||||
|
}
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
return UNSUPPORTED_ON_DEVICE;
|
||||||
|
}
|
||||||
|
return UNSUPPORTED_ON_DEVICE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSliceHighlightMenuRes() {
|
||||||
|
return R.string.menu_key_system;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user