Skip to content

Commit 1345edc

Browse files
D3nesyanMocaRafee
authored andcommitted
Launcher3: Add toggle to enable scroll vibration
* It may leads to poor UX on devices don't have a good vibration motor Change-Id: Ie1b3532f2aae00b90fd39ac8f6294c79b8bc67a5
1 parent f0fd09b commit 1345edc

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

quickstep/src/com/android/quickstep/views/RecentsView.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
import android.content.Context;
8181
import android.content.Intent;
8282
import android.content.LocusId;
83+
import android.content.SharedPreferences;
8384
import android.content.res.Configuration;
8485
import android.graphics.Bitmap;
8586
import android.graphics.BlendMode;
@@ -132,6 +133,7 @@
132133
import com.android.launcher3.DeviceProfile;
133134
import com.android.launcher3.Insettable;
134135
import com.android.launcher3.InvariantDeviceProfile;
136+
import com.android.launcher3.LauncherPrefs;
135137
import com.android.launcher3.PagedView;
136138
import com.android.launcher3.R;
137139
import com.android.launcher3.Utilities;
@@ -449,6 +451,8 @@ public Float get(RecentsView view) {
449451
// mTaskGridVerticalDiff and mTopBottomRowHeightDiff summed together provides the top
450452
// position for bottom row of grid tasks.
451453

454+
private static final String KEY_SCROLL_VIBRATION = "pref_scroll_vibration";
455+
452456
@Nullable
453457
protected RemoteTargetHandle[] mRemoteTargetHandles;
454458
protected final Rect mLastComputedTaskSize = new Rect();
@@ -1473,6 +1477,9 @@ protected void onScrollOverPageChanged() {
14731477
}
14741478

14751479
private void vibrateForScroll() {
1480+
if (!LauncherPrefs.getPrefs(mContext).getBoolean(KEY_SCROLL_VIBRATION, true)) {
1481+
return;
1482+
}
14761483
long now = SystemClock.uptimeMillis();
14771484
if (now - mScrollLastHapticTimestamp > mScrollHapticMinGapMillis) {
14781485
mScrollLastHapticTimestamp = now;

res/values/bianca_strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,7 @@
7171
<string name="icon_pack_add">Install more</string>
7272
<string name="icon_pack_no_market">There\'s no available app store</string>
7373

74+
<!-- Scroll Vibration -->
75+
<string name="pref_scroll_vibration_title">Scroll Vibration</string>
76+
<string name="pref_scroll_vibration_summary">Haptic feedback while scrolling through recent apps, if supported</string>
7477
</resources>

res/xml/launcher_preferences.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@
8181
android:defaultValue="false"
8282
android:persistent="true" />
8383

84+
<SwitchPreference
85+
android:key="pref_scroll_vibration"
86+
android:title="@string/pref_scroll_vibration_title"
87+
android:summary="@string/pref_scroll_vibration_summary"
88+
android:defaultValue="false"
89+
android:persistent="true" />
90+
8491
</androidx.preference.PreferenceCategory>
8592

8693
<androidx.preference.PreferenceCategory

0 commit comments

Comments
 (0)