Permalink
Browse files

Merge remote-tracking branch 'cyanogen/gingerbread' into gingerbread

  • Loading branch information...
2 parents f8bafab + 76872df commit bdfe477a07f570965a786f7b2f68356bf07baa3e @fjfalcon fjfalcon committed Jun 19, 2012
View
16 core/java/android/view/inputmethod/InputMethodManager.java
@@ -1330,14 +1330,16 @@ public void dispatchKeyEvent(Context context, int seq, KeyEvent key,
return;
}
- if (key.getAction() == KeyEvent.ACTION_DOWN
- && key.getKeyCode() == KeyEvent.KEYCODE_SYM) {
- showInputMethodPicker();
- try {
- callback.finishedEvent(seq, true);
- } catch (RemoteException e) {
+ if (context.getResources().getBoolean(com.android.internal.R.bool.config_symKeyShowsImePicker)) {
+ if (key.getAction() == KeyEvent.ACTION_DOWN
+ && key.getKeyCode() == KeyEvent.KEYCODE_SYM) {
+ showInputMethodPicker();
+ try {
+ callback.finishedEvent(seq, true);
+ } catch (RemoteException e) {
+ }
+ return;
}
- return;
}
try {
if (DEBUG) Log.v(TAG, "DISPATCH KEY: " + mCurMethod);
View
3 core/res/res/values/config.xml
@@ -639,4 +639,7 @@
<!-- Location of the Authentec framework jar -->
<string name="config_authentecJarLocation"></string>
+
+ <!-- True if the Sym key should open the InputMethodPicker (deault) -->
+ <bool name="config_symKeyShowsImePicker">true</bool>
</resources>
View
22 packages/SystemUI/src/com/android/systemui/statusbar/powerwidget/PowerButton.java
@@ -13,6 +13,7 @@
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
+import android.os.Vibrator;
import android.util.Log;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -66,6 +67,11 @@
private View.OnClickListener mExternalClickListener;
private View.OnLongClickListener mExternalLongClickListener;
+ protected boolean mHapticFeedback;
+ protected Vibrator mVibrator;
+ private long[] mClickPattern;
+ private long[] mLongClickPattern;
+
// we use this to ensure we update our views on the UI thread
private Handler mViewUpdateHandler = new Handler() {
@Override
@@ -122,6 +128,13 @@ protected void onChangeUri(ContentResolver resolver, Uri uri) {
// to a changed setting
}
+ /* package */ void setHapticFeedback(boolean enabled,
+ long[] clickPattern, long[] longClickPattern) {
+ mHapticFeedback = enabled;
+ mClickPattern = clickPattern;
+ mLongClickPattern = longClickPattern;
+ }
+
protected IntentFilter getBroadcastIntentFilter() {
return new IntentFilter();
}
@@ -139,6 +152,7 @@ protected void setupButton(View view) {
mIconView = (ImageView) mView.findViewById(R.id.power_widget_button_image);
mIndicatorView = (ImageView) mView.findViewById(R.id.power_widget_button_indic);
+ mVibrator = (Vibrator) mView.getContext().getSystemService(Context.VIBRATOR_SERVICE);
} else {
mIconView = null;
mIndicatorView = null;
@@ -151,6 +165,10 @@ protected void updateView() {
private View.OnClickListener mClickListener = new View.OnClickListener() {
public void onClick(View v) {
+ if (mHapticFeedback && mClickPattern != null) {
+ mVibrator.vibrate(mClickPattern, -1);
+ }
+
toggleState(v.getContext());
update(v.getContext());
@@ -164,6 +182,10 @@ public void onClick(View v) {
public boolean onLongClick(View v) {
boolean result = handleLongClick(v.getContext());
+ if (result && mHapticFeedback && mLongClickPattern != null) {
+ mVibrator.vibrate(mLongClickPattern, -1);
+ }
+
if (result && mExternalLongClickListener != null) {
mExternalLongClickListener.onLongClick(v);
}
View
43 packages/SystemUI/src/com/android/systemui/statusbar/powerwidget/PowerWidget.java
@@ -167,6 +167,7 @@ public void setupWidget() {
}
}
recreateButtonLayout();
+ updateHapticFeedbackSetting();
// set up a broadcast receiver for our intents, based off of what our power buttons have been loaded
setupBroadcastReceiver();
@@ -353,6 +354,32 @@ private void updateScrollbar() {
mScrollView.setHorizontalScrollBarEnabled(!hideScrollBar);
}
+ private void updateHapticFeedbackSetting() {
+ ContentResolver cr = mContext.getContentResolver();
+ int expandedHapticFeedback = Settings.System.getInt(cr,
+ Settings.System.EXPANDED_HAPTIC_FEEDBACK, 2);
+ long[] clickPattern = null, longClickPattern = null;
+ boolean hapticFeedback;
+
+ if (expandedHapticFeedback == 2) {
+ hapticFeedback = Settings.System.getInt(cr,
+ Settings.System.HAPTIC_FEEDBACK_ENABLED, 1) == 1;
+ } else {
+ hapticFeedback = (expandedHapticFeedback == 1);
+ }
+
+ if (hapticFeedback) {
+ clickPattern = Settings.System.getLongArray(cr,
+ Settings.System.HAPTIC_DOWN_ARRAY, null);
+ longClickPattern = Settings.System.getLongArray(cr,
+ Settings.System.HAPTIC_LONG_ARRAY, null);
+ }
+
+ for (PowerButton button : mButtons.values()) {
+ button.setHapticFeedback(hapticFeedback, clickPattern, longClickPattern);
+ }
+ }
+
// our own broadcast receiver :D
private class WidgetBroadcastReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
@@ -399,6 +426,15 @@ public void observe() {
resolver.registerContentObserver(
Settings.System.getUriFor(Settings.System.EXPANDED_HAPTIC_FEEDBACK),
false, this);
+ resolver.registerContentObserver(
+ Settings.System.getUriFor(Settings.System.HAPTIC_FEEDBACK_ENABLED),
+ false, this);
+ resolver.registerContentObserver(
+ Settings.System.getUriFor(Settings.System.HAPTIC_DOWN_ARRAY),
+ false, this);
+ resolver.registerContentObserver(
+ Settings.System.getUriFor(Settings.System.HAPTIC_LONG_ARRAY),
+ false, this);
// watch for changes in buttons
resolver.registerContentObserver(
@@ -438,6 +474,13 @@ public void onChangeUri(Uri uri, boolean selfChange) {
updateScrollbar();
}
+ if (uri.equals(Settings.System.getUriFor(Settings.System.HAPTIC_FEEDBACK_ENABLED))
+ || uri.equals(Settings.System.getUriFor(Settings.System.HAPTIC_DOWN_ARRAY))
+ || uri.equals(Settings.System.getUriFor(Settings.System.HAPTIC_LONG_ARRAY))
+ || uri.equals(Settings.System.getUriFor(Settings.System.EXPANDED_HAPTIC_FEEDBACK))) {
+ updateHapticFeedbackSetting();
+ }
+
// do whatever the individual buttons must
for (PowerButton button : mButtons.values()) {
if (button.getObservedUris().contains(uri)) {
View
20 packages/SystemUI/src/com/android/systemui/statusbar/powerwidget/SoundButton.java
@@ -9,7 +9,6 @@
import android.content.IntentFilter;
import android.media.AudioManager;
import android.net.Uri;
-import android.os.Vibrator;
import android.preference.MultiSelectListPreference;
import android.provider.Settings;
import android.view.View;
@@ -21,7 +20,7 @@
private static final String TAG = "SoundButton";
- private static final int VIBRATE_DURATION = 500; // 0.5s
+ private static final int VIBRATE_DURATION = 250; // 0.25s
private static final IntentFilter INTENT_FILTER = new IntentFilter();
static {
@@ -32,8 +31,6 @@
private static final List<Uri> OBSERVED_URIS = new ArrayList<Uri>();
static {
OBSERVED_URIS.add(Settings.System.getUriFor(Settings.System.EXPANDED_RING_MODE));
- OBSERVED_URIS.add(Settings.System.getUriFor(Settings.System.EXPANDED_HAPTIC_FEEDBACK));
- OBSERVED_URIS.add(Settings.System.getUriFor(Settings.System.HAPTIC_FEEDBACK_ENABLED));
}
private final Ringer mSilentRinger = new Ringer(false, AudioManager.VIBRATE_SETTING_OFF,
@@ -54,10 +51,7 @@
};
private int mRingerValuesIndex = 2;
- private boolean mHapticFeedbackEnabled = false;
-
private AudioManager mAudioManager;
- private Vibrator mVibrator;
public SoundButton() {
mType = BUTTON_SOUND;
@@ -69,7 +63,6 @@ protected void setupButton(View view) {
if (mView != null) {
Context context = mView.getContext();
mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
- mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
updateSettings(context.getContentResolver());
}
}
@@ -142,15 +135,6 @@ protected IntentFilter getBroadcastIntentFilter() {
}
private void updateSettings(ContentResolver resolver) {
- int expandedHapticFeedback = Settings.System.getInt(resolver,
- Settings.System.EXPANDED_HAPTIC_FEEDBACK, 2);
- if (expandedHapticFeedback == 2) {
- mHapticFeedbackEnabled = (Settings.System.getInt(resolver,
- Settings.System.HAPTIC_FEEDBACK_ENABLED, 1) == 1);
- } else {
- mHapticFeedbackEnabled = (expandedHapticFeedback == 1);
- }
-
String[] modes = MultiSelectListPreference.parseStoredValue(Settings.System.getString(
resolver, Settings.System.EXPANDED_RING_MODE));
if (modes == null || modes.length == 0) {
@@ -222,7 +206,7 @@ void execute(Context context) {
ensureAudioManager(context);
mAudioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, mVibrateSetting);
mAudioManager.setRingerMode(mRingerMode);
- if (mDoHapticFeedback && mHapticFeedbackEnabled) {
+ if (mDoHapticFeedback && mHapticFeedback) {
mVibrator.vibrate(VIBRATE_DURATION);
}
}

0 comments on commit bdfe477

Please sign in to comment.