diff options
18 files changed, 638 insertions, 7 deletions
diff --git a/res/drawable-hdpi/ic_navigation_ring_hint_activated.png b/res/drawable-hdpi/ic_navigation_ring_hint_activated.png Binary files differnew file mode 100644 index 0000000..c8b5a2e --- /dev/null +++ b/res/drawable-hdpi/ic_navigation_ring_hint_activated.png diff --git a/res/drawable-hdpi/ic_navigation_ring_hint_normal.png b/res/drawable-hdpi/ic_navigation_ring_hint_normal.png Binary files differnew file mode 100644 index 0000000..c8b5a2e --- /dev/null +++ b/res/drawable-hdpi/ic_navigation_ring_hint_normal.png diff --git a/res/drawable-mdpi/ic_navigation_ring_hint_activated.png b/res/drawable-mdpi/ic_navigation_ring_hint_activated.png Binary files differnew file mode 100644 index 0000000..4b5b2a4 --- /dev/null +++ b/res/drawable-mdpi/ic_navigation_ring_hint_activated.png diff --git a/res/drawable-mdpi/ic_navigation_ring_hint_normal.png b/res/drawable-mdpi/ic_navigation_ring_hint_normal.png Binary files differnew file mode 100644 index 0000000..4b5b2a4 --- /dev/null +++ b/res/drawable-mdpi/ic_navigation_ring_hint_normal.png diff --git a/res/drawable-xhdpi/ic_navigation_ring_hint_activated.png b/res/drawable-xhdpi/ic_navigation_ring_hint_activated.png Binary files differnew file mode 100644 index 0000000..3aa890f --- /dev/null +++ b/res/drawable-xhdpi/ic_navigation_ring_hint_activated.png diff --git a/res/drawable-xhdpi/ic_navigation_ring_hint_normal.png b/res/drawable-xhdpi/ic_navigation_ring_hint_normal.png Binary files differnew file mode 100644 index 0000000..3aa890f --- /dev/null +++ b/res/drawable-xhdpi/ic_navigation_ring_hint_normal.png diff --git a/res/drawable/ic_navigation_ring_hint.xml b/res/drawable/ic_navigation_ring_hint.xml new file mode 100644 index 0000000..d962db5 --- /dev/null +++ b/res/drawable/ic_navigation_ring_hint.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2012 The Android Open Source Project + Copyright (C) 2013 The Cyanogenmod 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. +--> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + + <item + android:state_enabled="true" + android:state_active="false" + android:state_focused="false" + android:drawable="@drawable/ic_navigation_ring_hint_normal" /> + + <item + android:state_enabled="true" + android:state_active="true" + android:state_focused="false" + android:drawable="@drawable/ic_navigation_ring_hint_activated" /> + + <item + android:state_enabled="true" + android:state_active="false" + android:state_focused="true" + android:drawable="@drawable/ic_navigation_ring_hint_activated" /> + +</selector> diff --git a/res/drawable/navbar_search_outerring.xml b/res/drawable/navbar_search_outerring.xml new file mode 100644 index 0000000..250e335 --- /dev/null +++ b/res/drawable/navbar_search_outerring.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2008 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. +--> + +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="oval"> + <size android:height="@dimen/navbar_search_outerring_diameter" + android:width="@dimen/navbar_search_outerring_diameter" /> + <solid android:color="#00000000" /> + <stroke android:color="#40ffffff" android:width="2dp" /> +</shape> + diff --git a/res/layout-land/navigation_ring_targets.xml b/res/layout-land/navigation_ring_targets.xml new file mode 100644 index 0000000..e72bd0a --- /dev/null +++ b/res/layout-land/navigation_ring_targets.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:prvandroid="http://schemas.android.com/apk/prv/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@android:color/holo_blue_light" + android:layout_marginRight="8dip" + android:layout_marginLeft="8dip" + android:padding="4dip" + android:gravity="center_horizontal" + android:textColor="#FFFFFF" + android:textAppearance="?android:attr/textAppearanceSmall" + android:text="@string/lockscreen_target_info" /> + + <View + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" /> + + <com.android.internal.widget.multiwaveview.GlowPadView + android:id="@+id/navring_target" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:orientation="horizontal" + android:gravity="@*android:integer/kg_selector_gravity" + android:contentDescription="@*android:string/keyguard_accessibility_slide_area" + prvandroid:targetDrawables="@*android:array/lockscreen_targets_unlock_only" + prvandroid:targetDescriptions="@*android:array/lockscreen_target_descriptions_unlock_only" + prvandroid:directionDescriptions="@*android:array/lockscreen_direction_descriptions" + prvandroid:handleDrawable="@drawable/ic_navigation_ring_hint" + prvandroid:outerRingDrawable="@drawable/navbar_search_outerring" + prvandroid:outerRadius="@dimen/navbar_search_outerring_radius" + prvandroid:innerRadius="@*android:dimen/glowpadview_inner_radius" + prvandroid:snapMargin="@dimen/navbar_search_snap_margin" + prvandroid:firstItemOffset="@*android:integer/kg_glowpad_rotation_offset" + prvandroid:magneticTargets="false" + prvandroid:feedbackCount="1" + prvandroid:vibrationDuration="20" + prvandroid:glowRadius="@*android:dimen/glowpadview_glow_radius" + prvandroid:pointDrawable="@*android:drawable/ic_lockscreen_glowdot" + prvandroid:allowScaling="true" /> + +</LinearLayout> diff --git a/res/layout-sw600dp-land/navigation_ring_targets.xml b/res/layout-sw600dp-land/navigation_ring_targets.xml new file mode 100644 index 0000000..e72bd0a --- /dev/null +++ b/res/layout-sw600dp-land/navigation_ring_targets.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:prvandroid="http://schemas.android.com/apk/prv/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@android:color/holo_blue_light" + android:layout_marginRight="8dip" + android:layout_marginLeft="8dip" + android:padding="4dip" + android:gravity="center_horizontal" + android:textColor="#FFFFFF" + android:textAppearance="?android:attr/textAppearanceSmall" + android:text="@string/lockscreen_target_info" /> + + <View + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" /> + + <com.android.internal.widget.multiwaveview.GlowPadView + android:id="@+id/navring_target" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:orientation="horizontal" + android:gravity="@*android:integer/kg_selector_gravity" + android:contentDescription="@*android:string/keyguard_accessibility_slide_area" + prvandroid:targetDrawables="@*android:array/lockscreen_targets_unlock_only" + prvandroid:targetDescriptions="@*android:array/lockscreen_target_descriptions_unlock_only" + prvandroid:directionDescriptions="@*android:array/lockscreen_direction_descriptions" + prvandroid:handleDrawable="@drawable/ic_navigation_ring_hint" + prvandroid:outerRingDrawable="@drawable/navbar_search_outerring" + prvandroid:outerRadius="@dimen/navbar_search_outerring_radius" + prvandroid:innerRadius="@*android:dimen/glowpadview_inner_radius" + prvandroid:snapMargin="@dimen/navbar_search_snap_margin" + prvandroid:firstItemOffset="@*android:integer/kg_glowpad_rotation_offset" + prvandroid:magneticTargets="false" + prvandroid:feedbackCount="1" + prvandroid:vibrationDuration="20" + prvandroid:glowRadius="@*android:dimen/glowpadview_glow_radius" + prvandroid:pointDrawable="@*android:drawable/ic_lockscreen_glowdot" + prvandroid:allowScaling="true" /> + +</LinearLayout> diff --git a/res/layout-sw600dp/navigation_ring_targets.xml b/res/layout-sw600dp/navigation_ring_targets.xml new file mode 100644 index 0000000..3fc6c6f --- /dev/null +++ b/res/layout-sw600dp/navigation_ring_targets.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:prvandroid="http://schemas.android.com/apk/prv/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@android:color/holo_blue_light" + android:layout_marginEnd="8dip" + android:layout_marginStart="8dip" + android:padding="4dip" + android:gravity="center_horizontal" + android:textColor="#FFFFFF" + android:textAppearance="?android:attr/textAppearanceSmall" + android:text="@string/lockscreen_target_info" /> + + <View + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="0.6" /> + + <com.android.internal.widget.multiwaveview.GlowPadView + android:id="@+id/navring_target" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="0.4" + android:orientation="horizontal" + android:layout_alignParentBottom="true" + android:gravity="top" + android:contentDescription="@*android:string/keyguard_accessibility_slide_area" + prvandroid:targetDrawables="@*android:array/lockscreen_targets_unlock_only" + prvandroid:targetDescriptions="@*android:array/lockscreen_target_descriptions_unlock_only" + prvandroid:directionDescriptions="@*android:array/lockscreen_direction_descriptions" + prvandroid:handleDrawable="@drawable/ic_navigation_ring_hint" + prvandroid:outerRingDrawable="@drawable/navbar_search_outerring" + prvandroid:outerRadius="@dimen/navbar_search_outerring_radius" + prvandroid:innerRadius="@*android:dimen/glowpadview_inner_radius" + prvandroid:snapMargin="@dimen/navbar_search_snap_margin" + prvandroid:firstItemOffset="@*android:integer/kg_glowpad_rotation_offset" + prvandroid:magneticTargets="false" + prvandroid:feedbackCount="1" + prvandroid:vibrationDuration="20" + prvandroid:glowRadius="@*android:dimen/glowpadview_glow_radius" + prvandroid:pointDrawable="@*android:drawable/ic_lockscreen_glowdot" + prvandroid:allowScaling="true" /> + +</LinearLayout> diff --git a/res/layout/navigation_ring_targets.xml b/res/layout/navigation_ring_targets.xml new file mode 100644 index 0000000..9fb0db8 --- /dev/null +++ b/res/layout/navigation_ring_targets.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:prvandroid="http://schemas.android.com/apk/prv/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@android:color/holo_blue_light" + android:layout_marginEnd="8dip" + android:layout_marginStart="8dip" + android:padding="4dip" + android:gravity="center_horizontal" + android:textColor="#FFFFFF" + android:textAppearance="?android:attr/textAppearanceSmall" + android:text="@string/lockscreen_target_info" /> + + <View + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="0.4" /> + + <com.android.internal.widget.multiwaveview.GlowPadView + android:id="@+id/navring_target" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="0.6" + android:orientation="horizontal" + android:layout_alignParentBottom="true" + android:gravity="top" + android:contentDescription="@*android:string/keyguard_accessibility_slide_area" + prvandroid:targetDrawables="@*android:array/lockscreen_targets_unlock_only" + prvandroid:targetDescriptions="@*android:array/lockscreen_target_descriptions_unlock_only" + prvandroid:directionDescriptions="@*android:array/lockscreen_direction_descriptions" + prvandroid:handleDrawable="@drawable/ic_navigation_ring_hint" + prvandroid:outerRingDrawable="@drawable/navbar_search_outerring" + prvandroid:outerRadius="@dimen/navbar_search_outerring_radius" + prvandroid:innerRadius="@*android:dimen/glowpadview_inner_radius" + prvandroid:snapMargin="@dimen/navbar_search_snap_margin" + prvandroid:firstItemOffset="@*android:integer/kg_glowpad_rotation_offset" + prvandroid:magneticTargets="false" + prvandroid:feedbackCount="1" + prvandroid:vibrationDuration="20" + prvandroid:glowRadius="@*android:dimen/glowpadview_glow_radius" + prvandroid:pointDrawable="@*android:drawable/ic_lockscreen_glowdot" + prvandroid:allowScaling="false" /> + +</LinearLayout> diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml index 1374efd..557fe27 100755 --- a/res/values-sw600dp/dimens.xml +++ b/res/values-sw600dp/dimens.xml @@ -38,4 +38,11 @@ <dimen name="keyguard_appwidget_picker_margin_left">2dip</dimen> <dimen name="keyguard_appwidget_picker_margin_right">2dip</dimen> <integer name="keyguard_appwidget_picker_cols">2</integer> + + <!-- Diameter of outer shape drawable shown in navbar search. Should be 1/2 of above value --> + <dimen name="navbar_search_outerring_radius">215dp</dimen> + <!-- Diameter of outer shape drawable shown in navbar search--> + <dimen name="navbar_search_outerring_diameter">430dp</dimen> + <!-- Height of search panel including navigation bar height --> + <dimen name="navbar_search_panel_height">280dip</dimen> </resources> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 2f0f859..a2dd145 100755 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -72,5 +72,14 @@ <!-- height of an expanded list item in edit playlist mode --> <dimen name="expanded_height">128dip</dimen> + <!-- Default distance beyond which snaps to the matching target --> + <dimen name="navbar_search_snap_margin">40dip</dimen> + <!-- Diameter of outer shape drawable shown in navbar search. Should be 1/2 of above value --> + <dimen name="navbar_search_outerring_radius">170dp</dimen> + <!-- Diameter of outer shape drawable shown in navbar search--> + <dimen name="navbar_search_outerring_diameter">340dp</dimen> + <!-- Height of search panel including navigation bar height --> + <dimen name="navbar_search_panel_height">230dip</dimen> + <!-- **** CYANOGENMOD ADDITIONS END **** --> </resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index 9972b13..877222b 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -4895,8 +4895,8 @@ <string name="hardware_keys_action_voice_search">Voice search</string> <string name="hardware_keys_action_in_app_search">In-app search</string> - <!-- Navigation Bar #CM --> - <string name="navigation_bar_title">Navigation bar</string> + <!-- Navigation Bar --> + <string name="navigation_bar_title">Buttons and layout</string> <string name="navigation_bar_help_text">1 - To begin editing, tap the lock icon\n\n2 - Tap any button to assign or change functionality\n\n3 - Long press any button to rearrange the order\n\n4 - To save, tap the lock icon again\n\n5 - To restore system default, tap the reset button\n\n</string> <string name="navigation_bar_tips">• Actions can only be assigned to one button at a time\n\n• The home button cannot be re-assigned\n\n• Side buttons cannot be rearranged</string> <string name="navigation_bar_tips_title">Quick tips</string> @@ -5174,5 +5174,25 @@ <string name="advanced_reboot_title">Advanced reboot</string> <string name="advanced_reboot_summary">When unlocked, include options in the power menu for rebooting into recovery or bootloader</string> + <!-- Navigation bar buttons and shortcuts category title --> + <string name="navigation_bar_category">Navigation bar</string> + + <!-- Navigation ring shortcuts --> + <string name="navigation_ring_title">Quick launch shortcuts</string> + <string name="navring_target_reset_message">Delete all user created navigation bar shortcuts and restore to default?</string> + <string name="navring_target_reset">Navigation bar shortcuts reset to default</string> + <string name="navring_target_save">Navigation bar shortcuts saved</string> + <string name="navring_action_open_ime_switcher">Open IME Switcher</string> + <string name="navring_action_kill_app">Kill app</string> + <string name="navring_action_none">None</string> + <string name="navring_action_take_screenshot">Take screenshot</string> + <string name="navring_action_ring_vibrate">Ring/Vibration</string> + <string name="navring_action_ring_silent">Ring/Silent</string> + <string name="navring_action_ring_vibrate_silent">Ring/Vibration/Silent</string> + <string name="navring_action_screen_off">Screen off</string> + <string name="navring_action_torch">Toggle torch</string> + <string name="navring_action_google_now">Google Now</string> + <string name="navring_choose_action_title">Choose action</string> + <!-- **** CYANOGENMOD ADDITIONS END **** --> </resources> diff --git a/res/xml/system_settings.xml b/res/xml/system_settings.xml index f20f190..2009767 100644 --- a/res/xml/system_settings.xml +++ b/res/xml/system_settings.xml @@ -50,11 +50,6 @@ </PreferenceScreen> <PreferenceScreen - android:key="navigation_bar" - android:fragment="com.android.settings.cyanogenmod.NavBar" - android:title="@string/navigation_bar_title" /> - - <PreferenceScreen android:key="notification_pulse" android:title="@string/notification_pulse_title" android:fragment="com.android.settings.notificationlight.NotificationLightSettings" /> @@ -69,4 +64,19 @@ android:fragment="com.android.settings.cyanogenmod.HardwareKeys" android:title="@string/hardware_keys_title" /> + <PreferenceCategory + android:key="navigation_bar_category" + android:title="@string/navigation_bar_category" > + + <PreferenceScreen + android:key="navigation_bar" + android:fragment="com.android.settings.cyanogenmod.NavBar" + android:title="@string/navigation_bar_title" /> + + <PreferenceScreen + android:key="navigation_ring" + android:fragment="com.android.settings.cyanogenmod.NavRing" + android:title="@string/navigation_ring_title" /> + </PreferenceCategory> + </PreferenceScreen> diff --git a/src/com/android/settings/cyanogenmod/NavRing.java b/src/com/android/settings/cyanogenmod/NavRing.java new file mode 100644 index 0000000..6eba01d --- /dev/null +++ b/src/com/android/settings/cyanogenmod/NavRing.java @@ -0,0 +1,316 @@ +/* + * Copyright (C) 2013 The CyanogenMod 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.cyanogenmod; + +import android.app.AlertDialog; +import android.app.Fragment; +import android.content.ContentResolver; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.Intent.ShortcutIconResource; +import android.content.res.Configuration; +import android.os.Bundle; +import android.os.Vibrator; +import android.provider.Settings; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Toast; + +import static com.android.internal.util.cm.NavigationRingConstants.*; +import com.android.internal.util.cm.NavigationRingHelpers; +import com.android.internal.widget.multiwaveview.GlowPadView; +import com.android.internal.widget.multiwaveview.TargetDrawable; +import com.android.settings.R; +import com.android.settings.Utils; + +import java.util.ArrayList; + +public class NavRing extends Fragment implements + ShortcutPickHelper.OnPickListener, GlowPadView.OnTriggerListener { + private GlowPadView mGlowPadView; + private ShortcutPickHelper mPicker; + private String[] mTargetActivities; + private ViewGroup mContainer; + + private int mTargetIndex = 0; + private int mStartPosOffset; + private int mEndPosOffset; + + private boolean mIsLandscape; + private boolean mIsScreenLarge; + + private ActionHolder mActions; + + private static final int MENU_RESET = Menu.FIRST; + private static final int MENU_SAVE = Menu.FIRST + 1; + + private class ActionHolder { + private ArrayList<CharSequence> mAvailableEntries = new ArrayList<CharSequence>(); + private ArrayList<String> mAvailableValues = new ArrayList<String>(); + + public void addAction(String action, int entryResId) { + mAvailableEntries.add(getString(entryResId)); + mAvailableValues.add(action); + } + public int getActionIndex(String action) { + int count = mAvailableValues.size(); + for (int i = 0; i < count; i++) { + if (TextUtils.equals(mAvailableValues.get(i), action)) { + return i; + } + } + return -1; + } + public String getAction(int index) { + if (index > mAvailableValues.size()) { + return null; + } + return mAvailableValues.get(index); + } + public CharSequence[] getEntries() { + return mAvailableEntries.toArray(new CharSequence[mAvailableEntries.size()]); + } + }; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + mContainer = container; + setHasOptionsMenu(true); + createActionList(); + + mIsScreenLarge = !Utils.isPhone(getActivity()); + mIsLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; + + mPicker = new ShortcutPickHelper(getActivity(), this); + + return inflater.inflate(R.layout.navigation_ring_targets, container, false); + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + mGlowPadView = ((GlowPadView) getActivity().findViewById(R.id.navring_target)); + mGlowPadView.setOnTriggerListener(this); + updateDrawables(); + } + + private void createActionList() { + mActions = new ActionHolder(); + mActions.addAction(ACTION_NONE, R.string.navring_action_none); + + if (NavigationRingHelpers.isAssistantAvailable(getActivity())) { + mActions.addAction(ACTION_ASSIST, R.string.navring_action_google_now); + } + if (NavigationRingHelpers.isTorchAvailable(getActivity())) { + mActions.addAction(ACTION_TORCH, R.string.navring_action_torch); + } + + mActions.addAction(ACTION_SCREENSHOT, R.string.navring_action_take_screenshot); + mActions.addAction(ACTION_IME, R.string.navring_action_open_ime_switcher); + mActions.addAction(ACTION_SILENT, R.string.navring_action_ring_silent); + + Vibrator vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE); + if (vibrator != null && vibrator.hasVibrator()) { + mActions.addAction(ACTION_VIBRATE, R.string.navring_action_ring_vibrate); + mActions.addAction(ACTION_RING_SILENT_VIBRATE, R.string.navring_action_ring_vibrate_silent); + } + + mActions.addAction(ACTION_KILL, R.string.navring_action_kill_app); + mActions.addAction(ACTION_POWER, R.string.navring_action_screen_off); + + mActions.addAction(ACTION_APP, R.string.select_application); + } + + private void setDrawables() { + final ArrayList<TargetDrawable> targets = new ArrayList<TargetDrawable>(); + final Context context = getActivity(); + + if (!mIsLandscape || mIsScreenLarge) { + mStartPosOffset = 1; + mEndPosOffset = 4; + } else { + mStartPosOffset = 3; + mEndPosOffset = 2; + } + + // Add Initial Place Holder Targets + for (int i = 0; i < mStartPosOffset; i++) { + targets.add(NavigationRingHelpers.getTargetDrawable(context, null)); + } + // Add User Targets + for (int i = 0; i < mTargetActivities.length; i++) { + final TargetDrawable drawable = + NavigationRingHelpers.getTargetDrawable(context, mTargetActivities[i]); + // we also want empty targets to be selectable here + drawable.setEnabled(true); + targets.add(drawable); + } + + // Add End Place Holder Targets + for (int i = 0; i < mEndPosOffset; i++) { + targets.add(NavigationRingHelpers.getTargetDrawable(context, null)); + } + + mGlowPadView.setTargetResources(targets); + NavigationRingHelpers.swapSearchIconIfNeeded(context, mGlowPadView); + } + + @Override + public void onResume() { + super.onResume(); + + // If running on a phone, remove padding around container + if (!mIsScreenLarge) { + mContainer.setPadding(0, 0, 0, 0); + } + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + menu.add(0, MENU_RESET, 0, R.string.profile_reset_title) + .setIcon(R.drawable.ic_settings_backup) + .setAlphabeticShortcut('r') + .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | + MenuItem.SHOW_AS_ACTION_WITH_TEXT); + menu.add(0, MENU_SAVE, 0, R.string.wifi_save) + .setIcon(R.drawable.ic_menu_save) + .setAlphabeticShortcut('s') + .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | + MenuItem.SHOW_AS_ACTION_WITH_TEXT); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case MENU_RESET: + resetAll(); + return true; + case MENU_SAVE: + saveAll(); + Toast.makeText(getActivity(), R.string.navring_target_save, Toast.LENGTH_LONG).show(); + return true; + default: + return false; + } + } + + private void resetAll() { + final AlertDialog d = new AlertDialog.Builder(getActivity()) + .setTitle(R.string.lockscreen_target_reset_title) + .setIconAttribute(android.R.attr.alertDialogIcon) + .setMessage(R.string.navring_target_reset_message) + .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + NavigationRingHelpers.resetActionsToDefaults(getActivity()); + updateDrawables(); + Toast.makeText(getActivity(), + R.string.navring_target_reset, + Toast.LENGTH_LONG).show(); + } + }) + .setNegativeButton(R.string.cancel, null) + .create(); + + d.show(); + } + + private void saveAll() { + final ContentResolver cr = getActivity().getContentResolver(); + for (int i = 0; i < mTargetActivities.length; i++) { + Settings.System.putString(cr, + Settings.System.NAVIGATION_RING_TARGETS[i], mTargetActivities[i]); + } + updateDrawables(); + } + + @Override + public void shortcutPicked(String uri, String friendlyName, boolean isApplication) { + mTargetActivities[mTargetIndex] = uri; + setDrawables(); + } + + public void onActivityResult(int requestCode, int resultCode, Intent data) { + mPicker.onActivityResult(requestCode, resultCode, data); + super.onActivityResult(requestCode, resultCode, data); + } + + public void updateDrawables() { + mTargetActivities = NavigationRingHelpers.getTargetActions(getActivity()); + setDrawables(); + } + + public void onTargetChange(String uri) { + if (uri.equals(ACTION_APP)) { + final String label = getResources().getString(R.string.lockscreen_target_empty); + final ShortcutIconResource iconResource = + ShortcutIconResource.fromContext(getActivity(), android.R.drawable.ic_delete); + mPicker.pickShortcut( + new String[] { label }, + new ShortcutIconResource[] { iconResource }, + getId()); + } else { + mTargetActivities[mTargetIndex] = uri; + setDrawables(); + } + } + + @Override + public void onTrigger(View v, final int target) { + mTargetIndex = target - mStartPosOffset; + + final DialogInterface.OnClickListener l = new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int item) { + onTargetChange(mActions.getAction(item)); + dialog.dismiss(); + } + }; + + final int selection = mActions.getActionIndex(mTargetActivities[mTargetIndex]); + final AlertDialog dialog = new AlertDialog.Builder(getActivity()) + .setTitle(R.string.navring_choose_action_title) + .setSingleChoiceItems(mActions.getEntries(), selection, l) + .create(); + + dialog.show(); + } + + @Override + public void onGrabbed(View v, int handle) { + } + + @Override + public void onReleased(View v, int handle) { + } + + @Override + public void onGrabbedStateChange(View v, int handle) { + } + + @Override + public void onFinishFinalAnimation() { + } +} diff --git a/src/com/android/settings/cyanogenmod/SystemSettings.java b/src/com/android/settings/cyanogenmod/SystemSettings.java index d34b00d..1c07877 100644 --- a/src/com/android/settings/cyanogenmod/SystemSettings.java +++ b/src/com/android/settings/cyanogenmod/SystemSettings.java @@ -41,6 +41,8 @@ public class SystemSettings extends SettingsPreferenceFragment { private static final String KEY_BATTERY_LIGHT = "battery_light"; private static final String KEY_HARDWARE_KEYS = "hardware_keys"; private static final String KEY_NAVIGATION_BAR = "navigation_bar"; + private static final String KEY_NAVIGATION_RING = "navigation_ring"; + private static final String KEY_NAVIGATION_BAR_CATEGORY = "navigation_bar_category"; private static final String KEY_LOCK_CLOCK = "lock_clock"; private static final String KEY_STATUS_BAR = "status_bar"; private static final String KEY_QUICK_SETTINGS = "quick_settings_panel"; @@ -95,12 +97,16 @@ public class SystemSettings extends SettingsPreferenceFragment { } if (removeNavbar) { prefScreen.removePreference(findPreference(KEY_NAVIGATION_BAR)); + prefScreen.removePreference(findPreference(KEY_NAVIGATION_RING)); + prefScreen.removePreference(findPreference(KEY_NAVIGATION_BAR_CATEGORY)); } } else { // Secondary user is logged in, remove all primary user specific preferences prefScreen.removePreference(findPreference(KEY_BATTERY_LIGHT)); prefScreen.removePreference(findPreference(KEY_HARDWARE_KEYS)); prefScreen.removePreference(findPreference(KEY_NAVIGATION_BAR)); + prefScreen.removePreference(findPreference(KEY_NAVIGATION_RING)); + prefScreen.removePreference(findPreference(KEY_NAVIGATION_BAR_CATEGORY)); prefScreen.removePreference(findPreference(KEY_STATUS_BAR)); prefScreen.removePreference(findPreference(KEY_QUICK_SETTINGS)); prefScreen.removePreference(findPreference(KEY_POWER_MENU)); |