Implement new method for handling SMS/MMS on the platform
Multi project change: The changes in this project update the settings app to support the new default SMS app setting. I have also updated the order of the wireless settings in the UX as per request from rachelg. Bug: 10449618 Change-Id: Iba1ac6ea3f29c2a72af83b122ec5ea3a16a28e58
This commit is contained in:
@@ -1642,6 +1642,16 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".SmsDefaultDialog"
|
||||||
|
android:label="@string/sms_application_title"
|
||||||
|
android:excludeFromRecents="true"
|
||||||
|
android:theme="@*android:style/Theme.Holo.Light.Dialog.Alert">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.provider.Telephony.ACTION_CHANGE_DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity android:name="Settings$NotificationAccessSettingsActivity"
|
<activity android:name="Settings$NotificationAccessSettingsActivity"
|
||||||
android:label="@string/manage_notification_access"
|
android:label="@string/manage_notification_access"
|
||||||
android:taskAffinity=""
|
android:taskAffinity=""
|
||||||
|
41
res/layout/sms_preference_item.xml
Executable file
41
res/layout/sms_preference_item.xml
Executable file
@@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
/*
|
||||||
|
** Copyright 2013, 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="?android:attr/listPreferredItemHeight"
|
||||||
|
android:padding="6dip">
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/sms_image"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="6dip"
|
||||||
|
/>
|
||||||
|
<CheckedTextView
|
||||||
|
android:id="@+id/sms_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
|
android:textColor="?android:attr/textColorAlertDialogListItem"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingEnd="7dip"
|
||||||
|
android:checkMark="?android:attr/listChoiceIndicatorSingle"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
@@ -400,7 +400,7 @@
|
|||||||
<string name="intent_sender_account_label">Account: </string>
|
<string name="intent_sender_account_label">Account: </string>
|
||||||
|
|
||||||
<!-- HTTP proxy settings title -->
|
<!-- HTTP proxy settings title -->
|
||||||
<string name="proxy_settings_title">Proxy settings</string>
|
<string name="proxy_settings_title">Proxy</string>
|
||||||
<!-- HTTP proxy settings. Button to clear the proxy box. -->
|
<!-- HTTP proxy settings. Button to clear the proxy box. -->
|
||||||
<string name="proxy_clear_text">Clear</string>
|
<string name="proxy_clear_text">Clear</string>
|
||||||
<!-- HTTP proxy settings. The port number label. -->
|
<!-- HTTP proxy settings. The port number label. -->
|
||||||
@@ -2380,8 +2380,13 @@
|
|||||||
<!-- Wireless controls, item title to go into the network settings -->
|
<!-- Wireless controls, item title to go into the network settings -->
|
||||||
<string name="network_settings_title">Mobile networks</string>
|
<string name="network_settings_title">Mobile networks</string>
|
||||||
|
|
||||||
<!-- Manage mobile plan [CHAR LIMIT=35]-->
|
<!-- Mobile plan [CHAR LIMIT=35]-->
|
||||||
<string name="manage_mobile_plan_title" translatable="true">Manage mobile plan</string>
|
<string name="manage_mobile_plan_title" translatable="true">Mobile plan</string>
|
||||||
|
|
||||||
|
<!-- SMS Application [CHAR LIMIT=35]-->
|
||||||
|
<string name="sms_application_title" translatable="true">Default SMS app</string>
|
||||||
|
<string name="sms_change_default_dialog_title" translatable="true">Change SMS app?</string>
|
||||||
|
<string name="sms_change_default_dialog_text" translatable="true">Use <xliff:g id="new_app">%s</xliff:g> instead of <xliff:g id="current_app">%s</xliff:g> as your SMS application?</string>
|
||||||
|
|
||||||
<!-- The SIM operator is not known [CHAR_ LIMIT=50]-->
|
<!-- The SIM operator is not known [CHAR_ LIMIT=50]-->
|
||||||
<string name="mobile_unknown_sim_operator" translatable="true">Uknown SIM operator</string>
|
<string name="mobile_unknown_sim_operator" translatable="true">Uknown SIM operator</string>
|
||||||
@@ -4175,8 +4180,7 @@
|
|||||||
<!-- Messaage shown in dialog when you can't manually sync -->
|
<!-- Messaage shown in dialog when you can't manually sync -->
|
||||||
<string name="cant_sync_dialog_message">Sync for this item is currently disabled. To change this setting, temporarily turn on background data and automatic sync.</string>
|
<string name="cant_sync_dialog_message">Sync for this item is currently disabled. To change this setting, temporarily turn on background data and automatic sync.</string>
|
||||||
|
|
||||||
<string name="wimax_settings">4G settings</string>
|
<string name="wimax_settings">4G</string>
|
||||||
<string name="wimax_settings_summary">Set up & manage 4G network and modem</string>
|
|
||||||
<string name="status_wimax_mac_address">4G MAC address</string>
|
<string name="status_wimax_mac_address">4G MAC address</string>
|
||||||
<!-- This is displayed to the user when the device needs to be decrypted -->
|
<!-- This is displayed to the user when the device needs to be decrypted -->
|
||||||
<string name="enter_password">Type password to decrypt storage</string>
|
<string name="enter_password">Type password to decrypt storage</string>
|
||||||
@@ -4802,8 +4806,6 @@
|
|||||||
|
|
||||||
<!-- Cell Broadcast settings title [CHAR LIMIT=50] -->
|
<!-- Cell Broadcast settings title [CHAR LIMIT=50] -->
|
||||||
<string name="cell_broadcast_settings">Cell broadcasts</string>
|
<string name="cell_broadcast_settings">Cell broadcasts</string>
|
||||||
<!-- Cell Broadcast settings description [CHAR LIMIT=100] -->
|
|
||||||
<string name="cell_broadcast_settings_summary">Select the types of emergency alerts to display.</string>
|
|
||||||
|
|
||||||
<!-- User app limits screen title [CHAR LIMIT=35] -->
|
<!-- User app limits screen title [CHAR LIMIT=35] -->
|
||||||
<string name="user_restrictions_title">Application and content restrictions</string>
|
<string name="user_restrictions_title">Application and content restrictions</string>
|
||||||
|
@@ -23,25 +23,10 @@
|
|||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:disableDependentsState="true" />
|
android:disableDependentsState="true" />
|
||||||
|
|
||||||
<PreferenceScreen
|
<com.android.settings.SmsListPreference
|
||||||
android:fragment="com.android.settings.vpn2.VpnSettings"
|
android:key="sms_application"
|
||||||
android:key="vpn_settings"
|
android:title="@string/sms_application_title"
|
||||||
android:title="@string/vpn_settings_title" />
|
android:persistent="false" />
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
android:fragment="com.android.settings.TetherSettings"
|
|
||||||
android:key="tether_settings"
|
|
||||||
android:title="@string/tether_settings_title_all" />
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
android:key="wimax_settings"
|
|
||||||
android:title="@string/wimax_settings"
|
|
||||||
android:summary="@string/wimax_settings_summary" >
|
|
||||||
<intent
|
|
||||||
android:action="android.intent.action.MAIN"
|
|
||||||
android:targetPackage="com.android.settings.wimax"
|
|
||||||
android:targetClass="com.android.settings.wimax.WimaxSettings" />
|
|
||||||
</PreferenceScreen>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="toggle_nfc"
|
android:key="toggle_nfc"
|
||||||
@@ -54,6 +39,16 @@
|
|||||||
android:key="android_beam_settings"
|
android:key="android_beam_settings"
|
||||||
android:title="@string/android_beam_settings_title" />
|
android:title="@string/android_beam_settings_title" />
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:fragment="com.android.settings.TetherSettings"
|
||||||
|
android:key="tether_settings"
|
||||||
|
android:title="@string/tether_settings_title_all" />
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:fragment="com.android.settings.vpn2.VpnSettings"
|
||||||
|
android:key="vpn_settings"
|
||||||
|
android:title="@string/vpn_settings_title" />
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:key="mobile_network_settings"
|
android:key="mobile_network_settings"
|
||||||
android:title="@string/network_settings_title"
|
android:title="@string/network_settings_title"
|
||||||
@@ -69,6 +64,15 @@
|
|||||||
android:title="@string/manage_mobile_plan_title"
|
android:title="@string/manage_mobile_plan_title"
|
||||||
android:persistent="false" />
|
android:persistent="false" />
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="wimax_settings"
|
||||||
|
android:title="@string/wimax_settings" >
|
||||||
|
<intent
|
||||||
|
android:action="android.intent.action.MAIN"
|
||||||
|
android:targetPackage="com.android.settings.wimax"
|
||||||
|
android:targetClass="com.android.settings.wimax.WimaxSettings" />
|
||||||
|
</PreferenceScreen>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="toggle_nsd"
|
android:key="toggle_nsd"
|
||||||
android:title="@string/nsd_quick_toggle_title"
|
android:title="@string/nsd_quick_toggle_title"
|
||||||
@@ -82,8 +86,7 @@
|
|||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:key="cell_broadcast_settings"
|
android:key="cell_broadcast_settings"
|
||||||
android:title="@string/cell_broadcast_settings"
|
android:title="@string/cell_broadcast_settings" >
|
||||||
android:summary="@string/cell_broadcast_settings_summary" >
|
|
||||||
<intent
|
<intent
|
||||||
android:action="android.intent.action.MAIN"
|
android:action="android.intent.action.MAIN"
|
||||||
android:targetPackage="com.android.cellbroadcastreceiver"
|
android:targetPackage="com.android.cellbroadcastreceiver"
|
||||||
|
@@ -1453,7 +1453,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
obj.transact(IBinder.SYSPROPS_TRANSACTION, data, null, 0);
|
obj.transact(IBinder.SYSPROPS_TRANSACTION, data, null, 0);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.i(TAG, "Somone wrote a bad service '" + service
|
Log.i(TAG, "Someone wrote a bad service '" + service
|
||||||
+ "' that doesn't like to be poked: " + e);
|
+ "' that doesn't like to be poked: " + e);
|
||||||
}
|
}
|
||||||
data.recycle();
|
data.recycle();
|
||||||
|
90
src/com/android/settings/SmsDefaultDialog.java
Normal file
90
src/com/android/settings/SmsDefaultDialog.java
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 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;
|
||||||
|
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.provider.Telephony.Sms.Intents;
|
||||||
|
|
||||||
|
import com.android.internal.app.AlertActivity;
|
||||||
|
import com.android.internal.app.AlertController;
|
||||||
|
import com.android.internal.telephony.SmsApplication;
|
||||||
|
import com.android.internal.telephony.SmsApplication.SmsApplicationData;
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
public final class SmsDefaultDialog extends AlertActivity implements
|
||||||
|
DialogInterface.OnClickListener {
|
||||||
|
private ComponentName mNewDefault;
|
||||||
|
private SmsApplicationData mNewSmsApplicationData;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
String packageName = intent.getStringExtra(Intents.EXTRA_PACKAGE_NAME);
|
||||||
|
|
||||||
|
setResult(RESULT_CANCELED);
|
||||||
|
if (!buildDialog(packageName)) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
switch (which) {
|
||||||
|
case BUTTON_POSITIVE:
|
||||||
|
SmsApplication.setDefaultApplication(mNewSmsApplicationData.mPackageName, this);
|
||||||
|
setResult(RESULT_OK);
|
||||||
|
break;
|
||||||
|
case BUTTON_NEGATIVE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean buildDialog(String packageName) {
|
||||||
|
mNewSmsApplicationData = SmsApplication.getSmsApplicationData(packageName, this);
|
||||||
|
if (mNewSmsApplicationData == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ComponentName oldSmsComponent = SmsApplication.getDefaultSmsApplication(this, true);
|
||||||
|
SmsApplicationData oldSmsApplicationData =
|
||||||
|
SmsApplication.getSmsApplicationData(oldSmsComponent.getPackageName(), this);
|
||||||
|
if (oldSmsApplicationData.mPackageName.equals(mNewSmsApplicationData.mPackageName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compose dialog; get
|
||||||
|
final AlertController.AlertParams p = mAlertParams;
|
||||||
|
p.mTitle = getString(R.string.sms_change_default_dialog_title);
|
||||||
|
p.mMessage = getString(R.string.sms_change_default_dialog_text,
|
||||||
|
mNewSmsApplicationData.mApplicationName, oldSmsApplicationData.mApplicationName);
|
||||||
|
p.mPositiveButtonText = getString(R.string.yes);
|
||||||
|
p.mNegativeButtonText = getString(R.string.no);
|
||||||
|
p.mPositiveButtonListener = this;
|
||||||
|
p.mNegativeButtonListener = this;
|
||||||
|
setupAlert();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
86
src/com/android/settings/SmsListPreference.java
Normal file
86
src/com/android/settings/SmsListPreference.java
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 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;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog.Builder;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.preference.ListPreference;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.CheckedTextView;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ListAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extends ListPreference to allow us to show the icons for the available SMS applications. We do
|
||||||
|
* this because the names of SMS applications are very similar and the user may not be able to
|
||||||
|
* determine what app they are selecting without an icon.
|
||||||
|
*/
|
||||||
|
public class SmsListPreference extends ListPreference {
|
||||||
|
private Drawable[] mEntryDrawables;
|
||||||
|
|
||||||
|
public class SmsArrayAdapter extends ArrayAdapter<CharSequence> {
|
||||||
|
private Drawable[] mImageDrawables = null;
|
||||||
|
private int mSelectedIndex = 0;
|
||||||
|
|
||||||
|
public SmsArrayAdapter(Context context, int textViewResourceId,
|
||||||
|
CharSequence[] objects, Drawable[] imageDrawables, int selectedIndex) {
|
||||||
|
super(context, textViewResourceId, objects);
|
||||||
|
mSelectedIndex = selectedIndex;
|
||||||
|
mImageDrawables = imageDrawables;
|
||||||
|
}
|
||||||
|
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
LayoutInflater inflater = ((Activity)getContext()).getLayoutInflater();
|
||||||
|
View view = inflater.inflate(R.layout.sms_preference_item, parent, false);
|
||||||
|
CheckedTextView checkedTextView = (CheckedTextView)view.findViewById(R.id.sms_text);
|
||||||
|
checkedTextView.setText(getItem(position));
|
||||||
|
if (position == mSelectedIndex) {
|
||||||
|
checkedTextView.setChecked(true);
|
||||||
|
}
|
||||||
|
ImageView imageView = (ImageView)view.findViewById(R.id.sms_image);
|
||||||
|
imageView.setImageDrawable(mImageDrawables[position]);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SmsListPreference(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntryDrawables(Drawable[] entries) {
|
||||||
|
mEntryDrawables = entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Drawable[] getEntryDrawables() {
|
||||||
|
return mEntryDrawables;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPrepareDialogBuilder(Builder builder) {
|
||||||
|
int selectedIndex = findIndexOfValue(getValue());
|
||||||
|
ListAdapter adapter = new SmsArrayAdapter(getContext(),
|
||||||
|
R.layout.sms_preference_item, getEntries(), mEntryDrawables, selectedIndex);
|
||||||
|
builder.setAdapter(adapter, this);
|
||||||
|
super.onPrepareDialogBuilder(builder);
|
||||||
|
}
|
||||||
|
}
|
@@ -21,11 +21,14 @@ import android.app.Activity;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.nfc.NfcAdapter;
|
import android.nfc.NfcAdapter;
|
||||||
@@ -34,17 +37,23 @@ import android.os.SystemProperties;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
|
import android.preference.Preference.OnPreferenceChangeListener;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.internal.telephony.SmsApplication;
|
||||||
|
import com.android.internal.telephony.SmsApplication.SmsApplicationData;
|
||||||
import com.android.internal.telephony.TelephonyIntents;
|
import com.android.internal.telephony.TelephonyIntents;
|
||||||
import com.android.internal.telephony.TelephonyProperties;
|
import com.android.internal.telephony.TelephonyProperties;
|
||||||
import com.android.settings.nfc.NfcEnabler;
|
import com.android.settings.nfc.NfcEnabler;
|
||||||
import com.android.settings.NsdEnabler;
|
|
||||||
|
|
||||||
public class WirelessSettings extends RestrictedSettingsFragment {
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class WirelessSettings extends RestrictedSettingsFragment
|
||||||
|
implements OnPreferenceChangeListener {
|
||||||
private static final String TAG = "WirelessSettings";
|
private static final String TAG = "WirelessSettings";
|
||||||
|
|
||||||
private static final String KEY_TOGGLE_AIRPLANE = "toggle_airplane";
|
private static final String KEY_TOGGLE_AIRPLANE = "toggle_airplane";
|
||||||
@@ -56,6 +65,7 @@ public class WirelessSettings extends RestrictedSettingsFragment {
|
|||||||
private static final String KEY_PROXY_SETTINGS = "proxy_settings";
|
private static final String KEY_PROXY_SETTINGS = "proxy_settings";
|
||||||
private static final String KEY_MOBILE_NETWORK_SETTINGS = "mobile_network_settings";
|
private static final String KEY_MOBILE_NETWORK_SETTINGS = "mobile_network_settings";
|
||||||
private static final String KEY_MANAGE_MOBILE_PLAN = "manage_mobile_plan";
|
private static final String KEY_MANAGE_MOBILE_PLAN = "manage_mobile_plan";
|
||||||
|
private static final String KEY_SMS_APPLICATION = "sms_application";
|
||||||
private static final String KEY_TOGGLE_NSD = "toggle_nsd"; //network service discovery
|
private static final String KEY_TOGGLE_NSD = "toggle_nsd"; //network service discovery
|
||||||
private static final String KEY_CELL_BROADCAST_SETTINGS = "cell_broadcast_settings";
|
private static final String KEY_CELL_BROADCAST_SETTINGS = "cell_broadcast_settings";
|
||||||
|
|
||||||
@@ -74,6 +84,8 @@ public class WirelessSettings extends RestrictedSettingsFragment {
|
|||||||
private static final int MANAGE_MOBILE_PLAN_DIALOG_ID = 1;
|
private static final int MANAGE_MOBILE_PLAN_DIALOG_ID = 1;
|
||||||
private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage";
|
private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage";
|
||||||
|
|
||||||
|
private SmsListPreference mSmsApplicationPreference;
|
||||||
|
|
||||||
public WirelessSettings() {
|
public WirelessSettings() {
|
||||||
super(null);
|
super(null);
|
||||||
}
|
}
|
||||||
@@ -152,6 +164,52 @@ public class WirelessSettings extends RestrictedSettingsFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateSmsApplicationSetting() {
|
||||||
|
log("updateSmsApplicationSetting:");
|
||||||
|
ComponentName appName = SmsApplication.getDefaultSmsApplication(getActivity(), true);
|
||||||
|
if (appName != null) {
|
||||||
|
String packageName = appName.getPackageName();
|
||||||
|
|
||||||
|
CharSequence[] values = mSmsApplicationPreference.getEntryValues();
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
if (packageName.contentEquals(values[i])) {
|
||||||
|
mSmsApplicationPreference.setValueIndex(i);
|
||||||
|
mSmsApplicationPreference.setSummary(mSmsApplicationPreference.getEntries()[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initSmsApplicationSetting() {
|
||||||
|
log("initSmsApplicationSetting:");
|
||||||
|
Collection<SmsApplicationData> smsApplications =
|
||||||
|
SmsApplication.getApplicationCollection(getActivity());
|
||||||
|
|
||||||
|
// If the list is empty the dialog will be empty, but we will not crash.
|
||||||
|
int count = smsApplications.size();
|
||||||
|
CharSequence[] entries = new CharSequence[count];
|
||||||
|
CharSequence[] entryValues = new CharSequence[count];
|
||||||
|
Drawable[] entryImages = new Drawable[count];
|
||||||
|
|
||||||
|
PackageManager packageManager = getPackageManager();
|
||||||
|
int i = 0;
|
||||||
|
for (SmsApplicationData smsApplicationData : smsApplications) {
|
||||||
|
entries[i] = smsApplicationData.mApplicationName;
|
||||||
|
entryValues[i] = smsApplicationData.mPackageName;
|
||||||
|
try {
|
||||||
|
entryImages[i] = packageManager.getApplicationIcon(smsApplicationData.mPackageName);
|
||||||
|
} catch (NameNotFoundException e) {
|
||||||
|
entryImages[i] = packageManager.getDefaultActivityIcon();
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
mSmsApplicationPreference.setEntries(entries);
|
||||||
|
mSmsApplicationPreference.setEntryValues(entryValues);
|
||||||
|
mSmsApplicationPreference.setEntryDrawables(entryImages);
|
||||||
|
updateSmsApplicationSetting();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(int dialogId) {
|
public Dialog onCreateDialog(int dialogId) {
|
||||||
log("onCreateDialog: dialogId=" + dialogId);
|
log("onCreateDialog: dialogId=" + dialogId);
|
||||||
@@ -187,6 +245,16 @@ public class WirelessSettings extends RestrictedSettingsFragment {
|
|||||||
return toggleable != null && toggleable.contains(type);
|
return toggleable != null && toggleable.contains(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isSmsSupported() {
|
||||||
|
// Some tablet has sim card but could not do telephony operations. Skip those.
|
||||||
|
if (mTm.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int simState = mTm.getSimState();
|
||||||
|
return simState != TelephonyManager.SIM_STATE_ABSENT &&
|
||||||
|
simState != TelephonyManager.SIM_STATE_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -211,6 +279,9 @@ public class WirelessSettings extends RestrictedSettingsFragment {
|
|||||||
mAirplaneModeEnabler = new AirplaneModeEnabler(activity, mAirplaneModePreference);
|
mAirplaneModeEnabler = new AirplaneModeEnabler(activity, mAirplaneModePreference);
|
||||||
mNfcEnabler = new NfcEnabler(activity, nfc, androidBeam);
|
mNfcEnabler = new NfcEnabler(activity, nfc, androidBeam);
|
||||||
|
|
||||||
|
mSmsApplicationPreference = (SmsListPreference) findPreference(KEY_SMS_APPLICATION);
|
||||||
|
mSmsApplicationPreference.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
// Remove NSD checkbox by default
|
// Remove NSD checkbox by default
|
||||||
getPreferenceScreen().removePreference(nsd);
|
getPreferenceScreen().removePreference(nsd);
|
||||||
//mNsdEnabler = new NsdEnabler(activity, nsd);
|
//mNsdEnabler = new NsdEnabler(activity, nsd);
|
||||||
@@ -269,6 +340,11 @@ public class WirelessSettings extends RestrictedSettingsFragment {
|
|||||||
protectByRestrictions(KEY_MOBILE_NETWORK_SETTINGS);
|
protectByRestrictions(KEY_MOBILE_NETWORK_SETTINGS);
|
||||||
protectByRestrictions(KEY_MANAGE_MOBILE_PLAN);
|
protectByRestrictions(KEY_MANAGE_MOBILE_PLAN);
|
||||||
|
|
||||||
|
// Remove SMS Application if the device does not support SMS
|
||||||
|
if (!isSmsSupported()) {
|
||||||
|
removePreference(KEY_SMS_APPLICATION);
|
||||||
|
}
|
||||||
|
|
||||||
// Remove Airplane Mode settings if it's a stationary device such as a TV.
|
// Remove Airplane Mode settings if it's a stationary device such as a TV.
|
||||||
if (getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION)) {
|
if (getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION)) {
|
||||||
removePreference(KEY_TOGGLE_AIRPLANE);
|
removePreference(KEY_TOGGLE_AIRPLANE);
|
||||||
@@ -315,6 +391,13 @@ public class WirelessSettings extends RestrictedSettingsFragment {
|
|||||||
protectByRestrictions(KEY_CELL_BROADCAST_SETTINGS);
|
protectByRestrictions(KEY_CELL_BROADCAST_SETTINGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
|
||||||
|
initSmsApplicationSetting();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -365,4 +448,14 @@ public class WirelessSettings extends RestrictedSettingsFragment {
|
|||||||
protected int getHelpResource() {
|
protected int getHelpResource() {
|
||||||
return R.string.help_url_more_networks;
|
return R.string.help_url_more_networks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
if (preference == mSmsApplicationPreference && newValue != null) {
|
||||||
|
SmsApplication.setDefaultApplication(newValue.toString(), getActivity());
|
||||||
|
updateSmsApplicationSetting();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user