summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/profiles/actions/item
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/settings/profiles/actions/item')
-rw-r--r--src/com/android/settings/profiles/actions/item/AirplaneModeItem.java81
-rw-r--r--src/com/android/settings/profiles/actions/item/ConnectionOverrideItem.java110
-rw-r--r--src/com/android/settings/profiles/actions/item/Header.java58
-rw-r--r--src/com/android/settings/profiles/actions/item/Item.java28
-rw-r--r--src/com/android/settings/profiles/actions/item/LockModeItem.java74
-rw-r--r--src/com/android/settings/profiles/actions/item/ProfileNameItem.java59
-rw-r--r--src/com/android/settings/profiles/actions/item/RingModeItem.java89
-rw-r--r--src/com/android/settings/profiles/actions/item/VolumeStreamItem.java98
8 files changed, 597 insertions, 0 deletions
diff --git a/src/com/android/settings/profiles/actions/item/AirplaneModeItem.java b/src/com/android/settings/profiles/actions/item/AirplaneModeItem.java
new file mode 100644
index 0000000..ed589d5
--- /dev/null
+++ b/src/com/android/settings/profiles/actions/item/AirplaneModeItem.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2014 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.profiles.actions.item;
+
+import android.app.AirplaneModeSettings;
+import android.app.RingModeSettings;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+import com.android.settings.R;
+import com.android.settings.profiles.actions.ItemListAdapter;
+
+public class AirplaneModeItem implements Item {
+ AirplaneModeSettings mSettings;
+
+ public AirplaneModeItem(AirplaneModeSettings airplaneModeSettings) {
+ if (airplaneModeSettings == null) {
+ airplaneModeSettings = new AirplaneModeSettings();
+ }
+ mSettings = airplaneModeSettings;
+ }
+
+ @Override
+ public ItemListAdapter.RowType getRowType() {
+ return ItemListAdapter.RowType.AIRPLANEMODE_ITEM;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ @Override
+ public View getView(LayoutInflater inflater, View convertView, ViewGroup parent) {
+ View view;
+ if (convertView == null) {
+ view = inflater.inflate(R.layout.list_two_line_item, parent, false);
+ // Do some initialization
+ } else {
+ view = convertView;
+ }
+
+ TextView text = (TextView) view.findViewById(R.id.title);
+ text.setText(R.string.profile_airplanemode_title);
+
+ TextView desc = (TextView) view.findViewById(R.id.summary);
+ desc.setText(getModeString(mSettings));
+
+ return view;
+ }
+
+ public AirplaneModeSettings getSettings() {
+ return mSettings;
+ }
+
+ public static int getModeString(AirplaneModeSettings settings) {
+ if (settings.isOverride()) {
+ if (settings.getValue() == 1) {
+ return R.string.profile_action_enable;
+ } else {
+ return R.string.profile_action_disable;
+ }
+ } else {
+ return R.string.profile_action_none;
+ }
+ }
+}
diff --git a/src/com/android/settings/profiles/actions/item/ConnectionOverrideItem.java b/src/com/android/settings/profiles/actions/item/ConnectionOverrideItem.java
new file mode 100644
index 0000000..74efd27
--- /dev/null
+++ b/src/com/android/settings/profiles/actions/item/ConnectionOverrideItem.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2014 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.profiles.actions.item;
+
+import android.app.ConnectionSettings;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settings.profiles.actions.ItemListAdapter;
+
+public class ConnectionOverrideItem implements Item {
+ int mConnectionId;
+ ConnectionSettings mConnectionSettings;
+
+ public ConnectionOverrideItem(int connectionId, ConnectionSettings settings) {
+ mConnectionId = connectionId;
+ if (settings == null) {
+ settings = new ConnectionSettings(connectionId);
+ }
+ this.mConnectionSettings = settings;
+ }
+
+ @Override
+ public ItemListAdapter.RowType getRowType() {
+ return ItemListAdapter.RowType.CONNECTION_ITEM;
+ }
+
+ @Override
+ public View getView(LayoutInflater inflater, View convertView, ViewGroup parent) {
+ View view;
+ if (convertView == null) {
+ view = inflater.inflate(R.layout.list_two_line_item, parent, false);
+ // Do some initialization
+ } else {
+ view = convertView;
+ }
+
+ TextView title = (TextView) view.findViewById(R.id.title);
+ TextView summary = (TextView) view.findViewById(R.id.summary);
+
+ title.setText(getConnectionTitle(mConnectionId));
+ summary.setText(getSummary());
+
+ return view;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ public static int getConnectionTitle(int connectionId) {
+ switch (connectionId) {
+ case ConnectionSettings.PROFILE_CONNECTION_BLUETOOTH:
+ return R.string.toggleBluetooth;
+ case ConnectionSettings.PROFILE_CONNECTION_MOBILEDATA:
+ return R.string.toggleData;
+ case ConnectionSettings.PROFILE_CONNECTION_2G3G:
+ return R.string.toggle2g3g;
+ case ConnectionSettings.PROFILE_CONNECTION_GPS:
+ return R.string.toggleGPS;
+ case ConnectionSettings.PROFILE_CONNECTION_NFC:
+ return R.string.toggleNfc;
+ case ConnectionSettings.PROFILE_CONNECTION_SYNC:
+ return R.string.toggleSync;
+ case ConnectionSettings.PROFILE_CONNECTION_WIFI:
+ return R.string.toggleWifi;
+ case ConnectionSettings.PROFILE_CONNECTION_WIFIAP:
+ return R.string.toggleWifiAp;
+ default:
+ return 0;
+ }
+ }
+
+ public int getSummary() {
+ if (mConnectionSettings != null && mConnectionSettings.isOverride()) {
+ if (mConnectionSettings.getValue() == 1) {
+ return R.string.profile_action_enable;
+ } else {
+ return R.string.profile_action_disable;
+ }
+ } else {
+ return R.string.profile_action_none;
+ }
+ }
+
+ public ConnectionSettings getSettings() {
+ return mConnectionSettings;
+ }
+
+ public int getConnectionType() {
+ return mConnectionId;
+ }
+}
diff --git a/src/com/android/settings/profiles/actions/item/Header.java b/src/com/android/settings/profiles/actions/item/Header.java
new file mode 100644
index 0000000..7d08508
--- /dev/null
+++ b/src/com/android/settings/profiles/actions/item/Header.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2014 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.profiles.actions.item;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settings.profiles.actions.ItemListAdapter;
+
+public class Header implements Item {
+ private final String name;
+
+ public Header(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public ItemListAdapter.RowType getRowType() {
+ return ItemListAdapter.RowType.HEADER_ITEM;
+ }
+
+ @Override
+ public View getView(LayoutInflater inflater, View convertView, ViewGroup parent) {
+ View view;
+ if (convertView == null) {
+ view = inflater.inflate(R.layout.profile_list_header, parent, false);
+ // Do some initialization
+ } else {
+ view = convertView;
+ }
+
+ TextView text = (TextView) view.findViewById(R.id.title);
+ text.setText(name);
+
+ return view;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return false;
+ }
+}
diff --git a/src/com/android/settings/profiles/actions/item/Item.java b/src/com/android/settings/profiles/actions/item/Item.java
new file mode 100644
index 0000000..c468e11
--- /dev/null
+++ b/src/com/android/settings/profiles/actions/item/Item.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2014 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.profiles.actions.item;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.android.settings.profiles.actions.ItemListAdapter;
+
+public interface Item {
+ public ItemListAdapter.RowType getRowType();
+ public View getView(LayoutInflater inflater, View convertView, ViewGroup parent);
+ public boolean isEnabled();
+}
diff --git a/src/com/android/settings/profiles/actions/item/LockModeItem.java b/src/com/android/settings/profiles/actions/item/LockModeItem.java
new file mode 100644
index 0000000..e9e93b5
--- /dev/null
+++ b/src/com/android/settings/profiles/actions/item/LockModeItem.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2014 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.profiles.actions.item;
+
+import android.app.Profile;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settings.profiles.actions.ItemListAdapter;
+
+public class LockModeItem implements Item {
+ Profile mProfile;
+
+ public LockModeItem(Profile profile) {
+ mProfile = profile;
+ }
+
+ @Override
+ public ItemListAdapter.RowType getRowType() {
+ return ItemListAdapter.RowType.LOCKSCREENMODE_ITEM;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ @Override
+ public View getView(LayoutInflater inflater, View convertView, ViewGroup parent) {
+ View view;
+ if (convertView == null) {
+ view = inflater.inflate(R.layout.list_two_line_item, parent, false);
+ // Do some initialization
+ } else {
+ view = convertView;
+ }
+
+ TextView text = (TextView) view.findViewById(R.id.title);
+ text.setText(R.string.profile_lockmode_title);
+
+ TextView desc = (TextView) view.findViewById(R.id.summary);
+ desc.setText(getSummaryString(mProfile));
+
+ return view;
+ }
+
+ public static int getSummaryString(Profile profile) {
+ switch (profile.getScreenLockMode()) {
+ case Profile.LockMode.DEFAULT:
+ return R.string.profile_lockmode_default_summary;
+ case Profile.LockMode.DISABLE:
+ return R.string.profile_lockmode_disabled_summary;
+ case Profile.LockMode.INSECURE:
+ return R.string.profile_lockmode_insecure_summary;
+ default: return 0;
+ }
+ }
+}
diff --git a/src/com/android/settings/profiles/actions/item/ProfileNameItem.java b/src/com/android/settings/profiles/actions/item/ProfileNameItem.java
new file mode 100644
index 0000000..a31ac32
--- /dev/null
+++ b/src/com/android/settings/profiles/actions/item/ProfileNameItem.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2014 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.profiles.actions.item;
+
+import android.app.Profile;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settings.profiles.actions.ItemListAdapter;
+
+public class ProfileNameItem implements Item {
+ Profile mProfile;
+
+ public ProfileNameItem(Profile profile) {
+ this.mProfile = profile;
+ }
+
+ @Override
+ public ItemListAdapter.RowType getRowType() {
+ return ItemListAdapter.RowType.NAME_ITEM;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ @Override
+ public View getView(LayoutInflater inflater, View convertView, ViewGroup parent) {
+ View view;
+ if (convertView == null) {
+ view = inflater.inflate(R.layout.profile_list_item, parent, false);
+ // Do some initialization
+ } else {
+ view = convertView;
+ }
+
+ TextView text = (TextView) view.findViewById(R.id.title);
+ text.setText(mProfile.getName());
+
+ return view;
+ }
+}
diff --git a/src/com/android/settings/profiles/actions/item/RingModeItem.java b/src/com/android/settings/profiles/actions/item/RingModeItem.java
new file mode 100644
index 0000000..1874909
--- /dev/null
+++ b/src/com/android/settings/profiles/actions/item/RingModeItem.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2014 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.profiles.actions.item;
+
+import android.app.AlertDialog;
+import android.app.RingModeSettings;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settings.profiles.actions.ItemListAdapter;
+
+public class RingModeItem implements Item {
+ RingModeSettings mSettings;
+
+ public RingModeItem(RingModeSettings ringModeSettings) {
+ if (ringModeSettings == null) {
+ ringModeSettings = new RingModeSettings();
+ }
+ mSettings = ringModeSettings;
+ }
+
+ @Override
+ public ItemListAdapter.RowType getRowType() {
+ return ItemListAdapter.RowType.RINGMODE_ITEM;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ @Override
+ public View getView(LayoutInflater inflater, View convertView, ViewGroup parent) {
+ View view;
+ if (convertView == null) {
+ view = inflater.inflate(R.layout.list_two_line_item, parent, false);
+ // Do some initialization
+ } else {
+ view = convertView;
+ }
+
+ TextView text = (TextView) view.findViewById(R.id.title);
+ text.setText(R.string.ring_mode_title);
+
+ TextView desc = (TextView) view.findViewById(R.id.summary);
+ desc.setText(getModeString(mSettings));
+
+ return view;
+ }
+
+ public static int getModeString(RingModeSettings settings) {
+ if (settings == null) {
+ return R.string.ring_mode_normal;
+ }
+ if (settings.isOverride()) {
+ if (settings.getValue().equals("vibrate")) {
+ return R.string.ring_mode_vibrate;
+ } else if (settings.getValue().equals("normal")) {
+ return R.string.ring_mode_normal;
+ } else {
+ return R.string.ring_mode_mute;
+ }
+ } else {
+ return R.string.ring_mode_unchanged;
+ }
+ }
+
+ public RingModeSettings getSettings() {
+ return mSettings;
+ }
+}
diff --git a/src/com/android/settings/profiles/actions/item/VolumeStreamItem.java b/src/com/android/settings/profiles/actions/item/VolumeStreamItem.java
new file mode 100644
index 0000000..25db5e0
--- /dev/null
+++ b/src/com/android/settings/profiles/actions/item/VolumeStreamItem.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2014 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.profiles.actions.item;
+
+import android.app.StreamSettings;
+import android.content.Context;
+import android.media.AudioManager;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settings.profiles.actions.ItemListAdapter;
+
+public class VolumeStreamItem implements Item {
+ private int mStreamId;
+ private StreamSettings mStreamSettings;
+
+ public VolumeStreamItem(int streamId, StreamSettings streamSettings) {
+ mStreamId = streamId;
+ mStreamSettings = streamSettings;
+ }
+
+ @Override
+ public ItemListAdapter.RowType getRowType() {
+ return ItemListAdapter.RowType.VOLUME_STREAM_ITEM;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ @Override
+ public View getView(LayoutInflater inflater, View convertView, ViewGroup parent) {
+ View view;
+ if (convertView == null) {
+ view = inflater.inflate(R.layout.list_two_line_item, parent, false);
+ // Do some initialization
+ } else {
+ view = convertView;
+ }
+
+ Context context = inflater.getContext();
+ final AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
+
+ TextView text = (TextView) view.findViewById(R.id.title);
+ text.setText(getNameForStream(mStreamId));
+
+ TextView desc = (TextView) view.findViewById(R.id.summary);
+ int denominator = mStreamSettings.getValue();
+ int numerator = am.getStreamMaxVolume(mStreamId);
+ if (mStreamSettings.isOverride()) {
+ desc.setText(context.getResources().getString(R.string.volume_override_summary,
+ denominator, numerator));
+ } else {
+ desc.setText(context.getString(R.string.volume_override_summary_no_override));
+ }
+
+ return view;
+ }
+
+ public static int getNameForStream(int stream) {
+ switch (stream) {
+ case AudioManager.STREAM_ALARM:
+ return R.string.alarm_volume_title;
+ case AudioManager.STREAM_MUSIC:
+ return R.string.media_volume_title;
+ case AudioManager.STREAM_RING:
+ return R.string.incoming_call_volume_title;
+ case AudioManager.STREAM_NOTIFICATION:
+ return R.string.notification_volume_title;
+ default: return 0;
+ }
+ }
+
+ public int getStreamType() {
+ return mStreamId;
+ }
+
+ public StreamSettings getSettings() {
+ return mStreamSettings;
+ }
+}