Merge \"Added new setting for gestures.\" into nyc-mr1-dev
am: 8b8a012913
Change-Id: I3bec17fcf1130c4948abeef256a169105d7ad464
This commit is contained in:
@@ -2927,6 +2927,24 @@
|
||||
android:value="com.android.settings.deletionhelper.DeletionHelperFragment" />
|
||||
</activity>
|
||||
|
||||
<!-- activity for gesture settings -->
|
||||
<activity android:name="Settings$GestureSettingsActivity"
|
||||
android:label="@string/gesture_preference_title"
|
||||
android:icon="@drawable/ic_settings_gestures"
|
||||
android:taskAffinity="">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="com.android.settings.SHORTCUT" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="com.android.settings.action.SETTINGS" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.category"
|
||||
android:value="com.android.settings.category.device" />
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.gestures.GestureSettings" />
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name=".SettingsDumpService"
|
||||
android:exported="true"
|
||||
|
25
res/drawable/ic_settings_gestures.xml
Normal file
25
res/drawable/ic_settings_gestures.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<!--
|
||||
Copyright (C) 2016 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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?android:attr/colorAccent">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M9,11.24L9,7.5C9,6.12 10.12,5 11.5,5S14,6.12 14,7.5v3.74c1.21,-0.81 2,-2.18 2,-3.74C16,5.01 13.99,3 11.5,3S7,5.01 7,7.5c0,1.56 0.79,2.93 2,3.74zM18.84,15.87l-4.54,-2.26c-0.17,-0.07 -0.35,-0.11 -0.54,-0.11L13,13.5v-6c0,-0.83 -0.67,-1.5 -1.5,-1.5S10,6.67 10,7.5v10.74l-3.43,-0.72c-0.08,-0.01 -0.15,-0.03 -0.24,-0.03 -0.31,0 -0.59,0.13 -0.79,0.33l-0.79,0.8 4.94,4.94c0.27,0.27 0.65,0.44 1.06,0.44h6.79c0.75,0 1.33,-0.55 1.44,-1.28l0.75,-5.27c0.01,-0.07 0.02,-0.14 0.02,-0.2 0,-0.62 -0.38,-1.16 -0.91,-1.38z"/>
|
||||
</vector>
|
93
res/layout/gesture_preference.xml
Normal file
93
res/layout/gesture_preference.xml
Normal file
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2016 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.
|
||||
-->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:gravity="center_vertical"
|
||||
android:background="?android:attr/activatedBackgroundIndicator"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
android:ellipsize="marquee"/>
|
||||
|
||||
<Switch
|
||||
android:id="@android:id/switch_widget"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="end|center_vertical"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/gestures_setting_backgroud_color"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="@dimen/gestures_settings_video_width"
|
||||
android:layout_height="@dimen/gestures_settings_video_height">
|
||||
|
||||
<TextureView
|
||||
android:id="@+id/gesture_video"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/gesture_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="@dimen/gestures_settings_summary_width"
|
||||
android:layout_height="@dimen/gestures_settings_summary_height"
|
||||
android:layout_weight="1"
|
||||
android:paddingTop="@dimen/gestures_settings_padding_top_bottom"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:maxLines="10"
|
||||
android:ellipsize="end"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
0
res/raw/gesture_ambient_move_lift.mp4
Normal file
0
res/raw/gesture_ambient_move_lift.mp4
Normal file
0
res/raw/gesture_ambient_tap.mp4
Normal file
0
res/raw/gesture_ambient_tap.mp4
Normal file
0
res/raw/gesture_double_tap.mp4
Normal file
0
res/raw/gesture_double_tap.mp4
Normal file
0
res/raw/gesture_fingerprint_swipe.mp4
Normal file
0
res/raw/gesture_fingerprint_swipe.mp4
Normal file
0
res/raw/gesture_twist.mp4
Normal file
0
res/raw/gesture_twist.mp4
Normal file
@@ -137,4 +137,10 @@
|
||||
<attr name="allowDividerAbove" format="boolean" />
|
||||
<attr name="allowDividerBelow" format="boolean" />
|
||||
</declare-styleable>
|
||||
|
||||
<!-- For GesturePreference -->
|
||||
<declare-styleable name="GesturePreference">
|
||||
<attr name="animation" format="reference" />
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
||||
|
@@ -131,4 +131,7 @@
|
||||
<color name="accent_color">@color/accent_material_light</color>
|
||||
<color name="accent_color_lighter">#ff7fcac3</color>
|
||||
|
||||
<!-- Gestures settings -->
|
||||
<color name="gestures_setting_backgroud_color">#f5f5f5</color>
|
||||
|
||||
</resources>
|
||||
|
@@ -296,4 +296,11 @@
|
||||
<!-- Padding between the radio buttons/checkbox and text on the redaction interstitial -->
|
||||
<dimen name="redaction_padding_start">16dp</dimen>
|
||||
|
||||
<!-- Padding for Gestures settings screen -->
|
||||
<dimen name="gestures_settings_title_height">56dp</dimen>
|
||||
<dimen name="gestures_settings_video_height">206dp</dimen>
|
||||
<dimen name="gestures_settings_video_width">206dp</dimen>
|
||||
<dimen name="gestures_settings_summary_height">206dp</dimen>
|
||||
<dimen name="gestures_settings_summary_width">206dp</dimen>
|
||||
<dimen name="gestures_settings_padding_top_bottom">20dp</dimen>
|
||||
</resources>
|
||||
|
@@ -7660,4 +7660,35 @@
|
||||
<!-- Automatic storage management service label. [CHAR LIMIT=40]-->
|
||||
<string name="automatic_storage_manager_service_label">Automatic Storage Management Service</string>
|
||||
|
||||
<!-- Preference title for gesture settings [CHAR LIMIT=25]-->
|
||||
<string name="gesture_preference_title">Gestures</string>
|
||||
|
||||
<!-- Title text for double tap power for camera [CHAR LIMIT=60]-->
|
||||
<string name="double_tap_power_for_camera_title">Jump to Camera</string>
|
||||
|
||||
<!-- Summary text for double tap power for camera [CHAR LIMIT=160]-->
|
||||
<string name="double_tap_power_for_camera_summary">To quickly open camera, just double-tap the power button. Works from any screen.</string>
|
||||
|
||||
<!-- Title text for double twist for camera mode [CHAR LIMIT=60]-->
|
||||
<string name="double_twist_for_camera_mode_title">Flip camera</string>
|
||||
|
||||
<!-- Summary text for double twist for camera mode [CHAR LIMIT=160]-->
|
||||
<string name="double_twist_for_camera_mode_summary">To switch between front and back cameras, double-twist.</string>
|
||||
|
||||
<!-- Title text for ambient display [CHAR LIMIT=60]-->
|
||||
<string name="ambient_display_title">Quick screen check</string>
|
||||
|
||||
<!-- Summary text for ambient display [CHAR LIMIT=160]-->
|
||||
<string name="ambient_display_summary">To check your phone without waking it up fully, nudge or pick it up.</string>
|
||||
|
||||
<!-- Title text for fingerprint swipe for notifications [CHAR LIMIT=60]-->
|
||||
<string name="fingerprint_swipe_for_notifications_title">Swipe for notifications</string>
|
||||
|
||||
<!-- Summary text for fingerprint swipe for notifications [CHAR LIMIT=160]-->
|
||||
<string name="fingerprint_swipe_for_notifications_summary">To check your notifications from any screen, swipe down on the fingerprint sensor.</string>
|
||||
|
||||
<!-- Switch text for each gesture setting state -->
|
||||
<string name="gesture_setting_on">On</string>
|
||||
<string name="gesture_setting_off">Off</string>
|
||||
|
||||
</resources>
|
||||
|
45
res/xml/gesture_settings.xml
Normal file
45
res/xml/gesture_settings.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2016 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.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/gesture_preference_title">
|
||||
|
||||
<com.android.settings.gestures.GesturePreference
|
||||
android:key="gesture_double_tap_power"
|
||||
android:title="@string/double_tap_power_for_camera_title"
|
||||
android:summary="@string/double_tap_power_for_camera_summary"
|
||||
settings:animation="@raw/gesture_double_tap"/>
|
||||
|
||||
<com.android.settings.gestures.GesturePreference
|
||||
android:key="gesture_double_twist"
|
||||
android:title="@string/double_twist_for_camera_mode_title"
|
||||
android:summary="@string/double_twist_for_camera_mode_summary"
|
||||
settings:animation="@raw/gesture_twist"/>
|
||||
|
||||
<com.android.settings.gestures.GesturePreference
|
||||
android:key="gesture_swipe_down_fingerprint"
|
||||
android:title="@string/fingerprint_swipe_for_notifications_title"
|
||||
android:summary="@string/fingerprint_swipe_for_notifications_summary"
|
||||
settings:animation="@raw/gesture_fingerprint_swipe"/>
|
||||
|
||||
<com.android.settings.gestures.GesturePreference
|
||||
android:key="gesture_pick_up_and_nudge"
|
||||
android:title="@string/ambient_display_title"
|
||||
android:summary="@string/ambient_display_summary"
|
||||
settings:animation="@raw/gesture_ambient_move_lift"/>
|
||||
|
||||
</PreferenceScreen>
|
@@ -84,6 +84,7 @@ public class Settings extends SettingsActivity {
|
||||
public static class AccountSyncSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class AccountSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class AccountSyncSettingsInAddAccountActivity extends SettingsActivity { /* empty */ }
|
||||
public static class GestureSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class CryptKeeperSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class DeviceAdminSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class DataUsageSummaryActivity extends SettingsActivity { /* empty */ }
|
||||
|
@@ -85,6 +85,7 @@ import com.android.settings.deviceinfo.StorageSettings;
|
||||
import com.android.settings.fuelgauge.BatterySaverSettings;
|
||||
import com.android.settings.fuelgauge.PowerUsageDetail;
|
||||
import com.android.settings.fuelgauge.PowerUsageSummary;
|
||||
import com.android.settings.gestures.GestureSettings;
|
||||
import com.android.settings.inputmethod.AvailableVirtualKeyboardFragment;
|
||||
import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
|
||||
import com.android.settings.inputmethod.KeyboardLayoutPickerFragment;
|
||||
@@ -242,6 +243,7 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
Settings.StorageSettingsActivity.class.getName(),
|
||||
Settings.ManageApplicationsActivity.class.getName(),
|
||||
Settings.PowerUsageSummaryActivity.class.getName(),
|
||||
Settings.GestureSettingsActivity.class.getName(),
|
||||
//personal_section
|
||||
Settings.LocationSettingsActivity.class.getName(),
|
||||
Settings.SecuritySettingsActivity.class.getName(),
|
||||
@@ -301,6 +303,7 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
PowerUsageSummary.class.getName(),
|
||||
AccountSyncSettings.class.getName(),
|
||||
AccountSettings.class.getName(),
|
||||
GestureSettings.class.getName(),
|
||||
CryptKeeperSettings.class.getName(),
|
||||
DataUsageSummary.class.getName(),
|
||||
DreamSettings.class.getName(),
|
||||
|
139
src/com/android/settings/gestures/GesturePreference.java
Normal file
139
src/com/android/settings/gestures/GesturePreference.java
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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.gestures;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.media.MediaMetadataRetriever;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.Surface;
|
||||
import android.view.TextureView;
|
||||
import android.widget.ImageView;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
/**
|
||||
* Preference item for a gesture with a switch to signify if it should be enabled.
|
||||
* This shows the title and description of the gesture along with an animation showing how to do
|
||||
* the gesture
|
||||
*/
|
||||
public class GesturePreference extends SwitchPreference {
|
||||
private static final String TAG = "GesturePreference";
|
||||
private Uri mVideoPath;
|
||||
private Context mContext;
|
||||
private MediaPlayer mMediaPlayer;
|
||||
private MediaMetadataRetriever mMediaMetadata;
|
||||
|
||||
public GesturePreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mContext = context;
|
||||
setLayoutResource(R.layout.gesture_preference);
|
||||
TypedArray attributes = context.getTheme().obtainStyledAttributes(
|
||||
attrs,
|
||||
R.styleable.GesturePreference,
|
||||
0, 0);
|
||||
try {
|
||||
int animation = attributes.getResourceId(R.styleable.GesturePreference_animation, 0);
|
||||
mVideoPath = Uri.parse(
|
||||
"android.resource://" + context.getPackageName() + "/" + animation);
|
||||
mMediaMetadata = new MediaMetadataRetriever();
|
||||
mMediaMetadata.setDataSource(mContext, mVideoPath);
|
||||
} catch (Exception e) {
|
||||
// resource not available, show blank view
|
||||
} finally {
|
||||
attributes.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||
super.onBindViewHolder(holder);
|
||||
final TextureView video = (TextureView) holder.findViewById(R.id.gesture_video);
|
||||
final ImageView imageView = (ImageView) holder.findViewById(R.id.gesture_image);
|
||||
|
||||
video.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
if (mMediaPlayer != null) {
|
||||
if (mMediaPlayer.isPlaying()) {
|
||||
mMediaPlayer.pause();
|
||||
} else {
|
||||
mMediaPlayer.start();
|
||||
imageView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
video.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
|
||||
@Override
|
||||
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) {
|
||||
mMediaPlayer = MediaPlayer.create(mContext, mVideoPath);
|
||||
if (mMediaPlayer != null) {
|
||||
mMediaPlayer.setSurface(new Surface(surfaceTexture));
|
||||
mMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
|
||||
@Override
|
||||
public void onPrepared(MediaPlayer mediaPlayer) {
|
||||
mediaPlayer.setLooping(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width, int height) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
if (mMediaPlayer != null) {
|
||||
mMediaPlayer.stop();
|
||||
mMediaPlayer.reset();
|
||||
mMediaPlayer.release();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
|
||||
}
|
||||
});
|
||||
|
||||
if (mMediaPlayer == null) {
|
||||
Bitmap bitmap = mMediaMetadata.getFrameAtTime(0);
|
||||
if (bitmap != null) {
|
||||
imageView.setImageDrawable(new BitmapDrawable(bitmap));
|
||||
}
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
73
src/com/android/settings/gestures/GestureSettings.java
Normal file
73
src/com/android/settings/gestures/GestureSettings.java
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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.gestures;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
|
||||
/**
|
||||
* Top level fragment for gesture settings.
|
||||
* This will create individual switch preference for each gesture and handle updates when each
|
||||
* preference is updated
|
||||
*/
|
||||
public class GestureSettings extends SettingsPreferenceFragment implements
|
||||
Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String TAG = "GestureSettings";
|
||||
private static final String PREF_KEY_DOUBLE_TAP_POWER = "gesture_double_tap_power";
|
||||
private static final String PREF_KEY_DOUBLE_TWIST = "gesture_double_twist";
|
||||
private static final String PREF_KEY_PICK_UP_AND_NUDGE = "gesture_pick_up_and_nudge";
|
||||
private static final String PREF_KEY_SWIPE_DOWN_FINGERPRINT = "gesture_swipe_down_fingerprint";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.gesture_settings);
|
||||
|
||||
// Double tap power for camera
|
||||
int cameraDisabled = Settings.Secure.getInt(getActivity().getContentResolver(),
|
||||
Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 1);
|
||||
GesturePreference preference =
|
||||
(GesturePreference) findPreference(PREF_KEY_DOUBLE_TAP_POWER);
|
||||
preference.setChecked(cameraDisabled == 0);
|
||||
preference.setOnPreferenceChangeListener(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
boolean enabled = (boolean) newValue;
|
||||
if (PREF_KEY_DOUBLE_TAP_POWER.equals(preference.getKey())) {
|
||||
Settings.Secure.putInt(getActivity().getContentResolver(),
|
||||
Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, enabled ? 0 : 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMetricsCategory() {
|
||||
return MetricsEvent.SETTINGS_GESTURES;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user