Skip to content

Commit

Permalink
Move high touch sensitivity and hovering to InputService
Browse files Browse the repository at this point in the history
Doing so allows us to keep track of user changes and restore
preferences.
CYNGNOS-1166

Change-Id: I5a6af73129acefa6530ceb3f73cc4cd83a19a676
  • Loading branch information
Danesh committed Mar 11, 2016
1 parent 1292e86 commit 7348be7
Showing 1 changed file with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
import java.util.List;
import java.util.Locale;

import cyanogenmod.hardware.CMHardwareManager;
import cyanogenmod.providers.CMSettings;

import org.cyanogenmod.internal.util.QSUtils;
Expand Down Expand Up @@ -239,6 +240,7 @@ public void onQSChanged() {
private boolean mShowOngoingImeSwitcherForPhones;
private boolean mNotificationShown;
private final boolean mImeSelectedOnBoot;
private CMHardwareManager mCMHardware;

static class SessionState {
final ClientState client;
Expand Down Expand Up @@ -506,15 +508,32 @@ public void onChange(boolean selfChange) {
}
}, userId);

if (mCMHardware.isSupported(CMHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY)) {
resolver.registerContentObserver(CMSettings.System.getUriFor(
CMSettings.System.HIGH_TOUCH_SENSITIVITY_ENABLE), false, this, userId);
}
if (mCMHardware.isSupported(CMHardwareManager.FEATURE_TOUCH_HOVERING)) {
resolver.registerContentObserver(CMSettings.Secure.getUriFor(
CMSettings.Secure.FEATURE_TOUCH_HOVERING), false, this, userId);
}

mRegistered = true;
}

@Override public void onChange(boolean selfChange, Uri uri) {
final Uri showImeUri =
Settings.Secure.getUriFor(Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD);
final Uri touchSensitivityUri =
CMSettings.System.getUriFor(CMSettings.System.HIGH_TOUCH_SENSITIVITY_ENABLE);
final Uri touchHoveringUri =
CMSettings.Secure.getUriFor(CMSettings.Secure.FEATURE_TOUCH_HOVERING);
synchronized (mMethodMap) {
if (showImeUri.equals(uri)) {
updateKeyboardFromSettingsLocked();
} else if (touchSensitivityUri.equals(uri)) {
updateTouchSensitivity();
} else if (touchHoveringUri.equals(uri)) {
updateTouchHovering();
} else {
boolean enabledChanged = false;
String newEnabled = mSettings.getEnabledInputMethodsStr();
Expand Down Expand Up @@ -943,11 +962,17 @@ public String[] getPackages(int userId) {
}
}

// Must happen before registerContentObserverLocked
mCMHardware = CMHardwareManager.getInstance(mContext);

synchronized (mMethodMap) {
mSettingsObserver.registerContentObserverLocked(userId);
updateFromSettingsLocked(true);
}

updateTouchHovering();
updateTouchSensitivity();

// IMMS wants to receive Intent.ACTION_LOCALE_CHANGED in order to update the current IME
// according to the new system locale.
final IntentFilter filter = new IntentFilter();
Expand Down Expand Up @@ -1072,6 +1097,9 @@ private void switchUserLocked(int newUserId) {
mContext.getBasePackageName());
}

updateTouchHovering();
updateTouchSensitivity();

if (DEBUG) Slog.d(TAG, "Switching user stage 3/3. newUserId=" + newUserId
+ " selectedIme=" + mSettings.getSelectedInputMethod());
}
Expand Down Expand Up @@ -1970,6 +1998,26 @@ void updateInputMethodsFromSettingsLocked(boolean enabledMayChange) {

}

private void updateTouchSensitivity() {
if (!mCMHardware.isSupported(CMHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY)) {
return;
}
boolean touchSensitivityEnable = CMSettings.System.getInt(mContext.getContentResolver(),
CMSettings.System.HIGH_TOUCH_SENSITIVITY_ENABLE, 0) == 1;
mCMHardware.set(CMHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY,
touchSensitivityEnable);
}

private void updateTouchHovering() {
if (!mCMHardware.isSupported(CMHardwareManager.FEATURE_TOUCH_HOVERING)) {
return;
}
boolean touchHovering = CMSettings.Secure.getInt(mContext.getContentResolver(),
CMSettings.Secure.FEATURE_TOUCH_HOVERING, 0) == 1;
mCMHardware.set(CMHardwareManager.FEATURE_TOUCH_HOVERING,
touchHovering);
}

public void updateKeyboardFromSettingsLocked() {
mShowImeWithHardKeyboard = mSettings.isShowImeWithHardKeyboardEnabled();
if (mSwitchingDialog != null
Expand Down

0 comments on commit 7348be7

Please sign in to comment.