summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/drawable-hdpi/stat_navbar_edit_off.pngbin0 -> 1227 bytes
-rw-r--r--res/drawable-hdpi/stat_navbar_edit_on.pngbin0 -> 1217 bytes
-rw-r--r--res/drawable-mdpi/stat_navbar_edit_off.pngbin0 -> 1135 bytes
-rw-r--r--res/drawable-mdpi/stat_navbar_edit_on.pngbin0 -> 1142 bytes
-rw-r--r--res/drawable-xhdpi/ic_settings_security.pngbin865 -> 730 bytes
-rw-r--r--res/drawable-xhdpi/stat_navbar_edit_off.pngbin0 -> 1271 bytes
-rw-r--r--res/drawable-xhdpi/stat_navbar_edit_on.pngbin0 -> 1283 bytes
-rw-r--r--res/drawable/navbar_tut.pngbin0 -> 19915 bytes
-rw-r--r--res/layout/nav_bar.xml40
-rw-r--r--res/values/strings.xml11
-rw-r--r--res/xml/system_settings.xml5
-rw-r--r--src/com/android/settings/cyanogenmod/NavBar.java149
-rw-r--r--src/com/android/settings/cyanogenmod/SystemSettings.java17
13 files changed, 221 insertions, 1 deletions
diff --git a/res/drawable-hdpi/stat_navbar_edit_off.png b/res/drawable-hdpi/stat_navbar_edit_off.png
new file mode 100644
index 0000000..d796bde
--- /dev/null
+++ b/res/drawable-hdpi/stat_navbar_edit_off.png
Binary files differ
diff --git a/res/drawable-hdpi/stat_navbar_edit_on.png b/res/drawable-hdpi/stat_navbar_edit_on.png
new file mode 100644
index 0000000..263c0ed
--- /dev/null
+++ b/res/drawable-hdpi/stat_navbar_edit_on.png
Binary files differ
diff --git a/res/drawable-mdpi/stat_navbar_edit_off.png b/res/drawable-mdpi/stat_navbar_edit_off.png
new file mode 100644
index 0000000..0520768
--- /dev/null
+++ b/res/drawable-mdpi/stat_navbar_edit_off.png
Binary files differ
diff --git a/res/drawable-mdpi/stat_navbar_edit_on.png b/res/drawable-mdpi/stat_navbar_edit_on.png
new file mode 100644
index 0000000..8c93091
--- /dev/null
+++ b/res/drawable-mdpi/stat_navbar_edit_on.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_settings_security.png b/res/drawable-xhdpi/ic_settings_security.png
index b5a383a..6ea7562 100644
--- a/res/drawable-xhdpi/ic_settings_security.png
+++ b/res/drawable-xhdpi/ic_settings_security.png
Binary files differ
diff --git a/res/drawable-xhdpi/stat_navbar_edit_off.png b/res/drawable-xhdpi/stat_navbar_edit_off.png
new file mode 100644
index 0000000..d0c63a0
--- /dev/null
+++ b/res/drawable-xhdpi/stat_navbar_edit_off.png
Binary files differ
diff --git a/res/drawable-xhdpi/stat_navbar_edit_on.png b/res/drawable-xhdpi/stat_navbar_edit_on.png
new file mode 100644
index 0000000..1bfee82
--- /dev/null
+++ b/res/drawable-xhdpi/stat_navbar_edit_on.png
Binary files differ
diff --git a/res/drawable/navbar_tut.png b/res/drawable/navbar_tut.png
new file mode 100644
index 0000000..44578f5
--- /dev/null
+++ b/res/drawable/navbar_tut.png
Binary files differ
diff --git a/res/layout/nav_bar.xml b/res/layout/nav_bar.xml
new file mode 100644
index 0000000..e2a93c1
--- /dev/null
+++ b/res/layout/nav_bar.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/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:layout_margin="8dip"
+ android:padding="4dip"
+ android:layout_weight="1"
+ android:text="@string/navigation_bar_help_text"
+ android:textSize="13sp" />
+ <ImageView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_margin="8dip"
+ android:padding="4dip"
+ android:src="@drawable/navbar_tut" />
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="@android:color/holo_blue_light"
+ android:gravity="center_horizontal"
+ android:layout_marginLeft="8dip"
+ android:layout_marginRight="8dip"
+ android:padding="4dip"
+ android:textColor="#FFFFFF"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/navigation_bar_tips_title" />
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dip"
+ android:padding="4dip"
+ android:textSize="13sp"
+ android:text="@string/navigation_bar_tips" />
+</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a361e4a..8e6f5d7 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4883,6 +4883,17 @@
<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>
+ <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">&#8226; Actions can only be assigned to one button at a time\n\n&#8226; The home button cannot be re-assigned\n\n&#8226; Side buttons cannot be rearranged</string>
+ <string name="navigation_bar_tips_title">Quick tips</string>
+ <string name="navigation_bar_reset_message">Delete current settings and restore to default?</string>
+ <string name="navigation_bar_save_message">Navigation bar settings saved</string>
+ <string name="navigation_bar_reset_toast">Navigation bar reset to default</string>
+ <string name="navigation_bar_menu_editable">Editable</string>
+ <string name="navigation_bar_menu_locked">Locked</string>
+
<!-- Power Widget -->
<string name="power_widget_title">Power widget</string>
<string name="title_expanded_widget">Power widget</string>
diff --git a/res/xml/system_settings.xml b/res/xml/system_settings.xml
index 703c6f7..f20f190 100644
--- a/res/xml/system_settings.xml
+++ b/res/xml/system_settings.xml
@@ -50,6 +50,11 @@
</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" />
diff --git a/src/com/android/settings/cyanogenmod/NavBar.java b/src/com/android/settings/cyanogenmod/NavBar.java
new file mode 100644
index 0000000..bee3cb4
--- /dev/null
+++ b/src/com/android/settings/cyanogenmod/NavBar.java
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2011 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.Activity;
+import android.app.AlertDialog;
+import android.app.Fragment;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.os.Bundle;
+import android.provider.Settings;
+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 com.android.settings.R;
+import com.android.settings.Utils;
+
+public class NavBar extends Fragment {
+
+ private boolean mEditMode;
+ private ViewGroup mContainer;
+ private Activity mActivity;
+ private MenuItem mEditMenu;
+ private final static Intent mIntent = new Intent("android.intent.action.NAVBAR_EDIT");
+ private static final int MENU_RESET = Menu.FIRST;
+ private static final int MENU_EDIT = Menu.FIRST + 1;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.nav_bar, container, false);
+ setHasOptionsMenu(true);
+ mContainer = container;
+ mActivity = getActivity();
+ mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+ return view;
+ }
+
+ /**
+ * Toggles navbar edit mode
+ * @param on True to enter edit mode / false to exit
+ * @param save True to save changes / false to discard them
+ */
+ private void toggleEditMode(boolean on, boolean save) {
+ mIntent.putExtra("edit", on);
+ mIntent.putExtra("save", save);
+ mActivity.sendBroadcast(mIntent);
+ if (mEditMenu != null) {
+ mEditMenu.setTitle(on ? R.string.navigation_bar_menu_editable : R.string.navigation_bar_menu_locked)
+ .setIcon(on ? R.drawable.stat_navbar_edit_on : R.drawable.stat_navbar_edit_off);
+ }
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ // If running on a phone, remove padding around container
+ if (Utils.isPhone(mActivity)) {
+ 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);
+ mEditMenu = menu.add(0, MENU_EDIT, 0, R.string.navigation_bar_menu_locked);
+ mEditMenu.setIcon(R.drawable.stat_navbar_edit_off)
+ .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:
+ new AlertDialog.Builder(mActivity)
+ .setTitle(R.string.lockscreen_target_reset_title)
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .setMessage(R.string.navigation_bar_reset_message)
+ .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ if (mEditMode) {
+ toggleEditMode(false, false);
+ }
+ Settings.System.putString(getActivity().getContentResolver(),
+ Settings.System.NAV_BUTTONS, null);
+ toggleEditMode(true, false);
+ toggleEditMode(false, false);
+ mEditMode = false;
+ Toast.makeText(mActivity, R.string.navigation_bar_reset_toast, Toast.LENGTH_LONG).show();
+ }
+ }).setNegativeButton(R.string.cancel, null)
+ .create().show();
+ return true;
+ case MENU_EDIT:
+ mEditMode = !mEditMode;
+ toggleEditMode(mEditMode, true);
+ if (!mEditMode) {
+ Toast.makeText(mActivity, R.string.navigation_bar_save_message, Toast.LENGTH_LONG).show();
+ }
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ @Override
+ public void onPause() {
+ toggleEditMode(false, false);
+ super.onPause();
+ }
+
+ @Override
+ public void onStop() {
+ toggleEditMode(false, false);
+ super.onStop();
+ }
+
+ @Override
+ public void onDestroy() {
+ toggleEditMode(false, false);
+ super.onDestroy();
+ }
+}
diff --git a/src/com/android/settings/cyanogenmod/SystemSettings.java b/src/com/android/settings/cyanogenmod/SystemSettings.java
index 06a7bdf..5343fd1 100644
--- a/src/com/android/settings/cyanogenmod/SystemSettings.java
+++ b/src/com/android/settings/cyanogenmod/SystemSettings.java
@@ -29,6 +29,7 @@ import android.view.IWindowManager;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.Utils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -39,6 +40,7 @@ public class SystemSettings extends SettingsPreferenceFragment {
private static final String KEY_NOTIFICATION_PULSE = "notification_pulse";
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_LOCK_CLOCK = "lock_clock";
private PreferenceScreen mNotificationPulse;
@@ -75,15 +77,28 @@ public class SystemSettings extends SettingsPreferenceFragment {
}
// Only show the hardware keys config on a device that does not have a navbar
+ // Only show the navigation bar config on phones that has a navigation bar
+ boolean removeKeys = false;
+ boolean removeNavbar = false;
IWindowManager windowManager = IWindowManager.Stub.asInterface(
ServiceManager.getService(Context.WINDOW_SERVICE));
try {
if (windowManager.hasNavigationBar()) {
- getPreferenceScreen().removePreference(findPreference(KEY_HARDWARE_KEYS));
+ removeKeys = true;
+ } else {
+ removeNavbar = true;
}
} catch (RemoteException e) {
// Do nothing
}
+
+ // Act on the above
+ if (removeKeys) {
+ getPreferenceScreen().removePreference(findPreference(KEY_HARDWARE_KEYS));
+ }
+ if (removeNavbar) {
+ getPreferenceScreen().removePreference(findPreference(KEY_NAVIGATION_BAR));
+ }
}
private void updateLightPulseDescription() {