summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaj Yengisetty <rajesh@cyngn.com>2014-12-08 12:35:46 -0800
committerRajesh Yengisetty <rajesh@cyngn.com>2014-12-08 20:37:53 +0000
commit735ed91ec5c35024969c57153c8bba69315ae291 (patch)
tree8e68817c0573aa86477d92db9902a1fd6ee90d53
parent8d5c4458f2900ab94f154ec620ed75e64da43a55 (diff)
downloadandroid_packages_apps_ContactsCommon-735ed91ec5c35024969c57153c8bba69315ae291.tar.gz
android_packages_apps_ContactsCommon-735ed91ec5c35024969c57153c8bba69315ae291.tar.bz2
android_packages_apps_ContactsCommon-735ed91ec5c35024969c57153c8bba69315ae291.zip
Import feature - auto prompt for importing SIM contacts
Change-Id: I1c24094c3d588edf2d1182d8369882523e6f6512
-rw-r--r--res/values/cm_strings.xml5
-rwxr-xr-xsrc/com/android/contacts/common/interactions/ImportSIMContactsDialogFragment.java36
-rw-r--r--src/com/android/contacts/common/preference/ContactsPreferences.java28
3 files changed, 69 insertions, 0 deletions
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 75b9f0ab..e014ca4e 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -18,4 +18,9 @@
<!-- Virtual local storage account name -->
<string name="local_storage_account" product="tablet">Local tablet account</string>
<string name="local_storage_account" product="default">Local phone account</string>
+
+ <!-- CMCC -->
+ <string name="import_contacts_sim">Import contacts from SIM?</string>
+ <string name="import_contacts_sim_confirm">Import</string>
+ <string name="import_contacts_sim_cancel">Cancel</string>
</resources>
diff --git a/src/com/android/contacts/common/interactions/ImportSIMContactsDialogFragment.java b/src/com/android/contacts/common/interactions/ImportSIMContactsDialogFragment.java
new file mode 100755
index 00000000..5cf1d08a
--- /dev/null
+++ b/src/com/android/contacts/common/interactions/ImportSIMContactsDialogFragment.java
@@ -0,0 +1,36 @@
+package com.android.contacts.common.interactions;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import com.android.contacts.common.R;
+
+/**
+ * An dialog invoked to import/export contacts.
+ */
+public class ImportSIMContactsDialogFragment extends DialogFragment {
+ public static final String TAG = "ImportSIMContactsDialogFragment";
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ // Use the Builder class for convenient dialog construction
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+ builder.setMessage(R.string.import_contacts_sim)
+ .setPositiveButton(R.string.import_contacts_sim_confirm,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ ImportExportDialogFragment.show(getFragmentManager(),
+ false, ImportSIMContactsDialogFragment.class);
+ }})
+ .setNegativeButton(R.string.import_contacts_sim_cancel,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ // Nothing to do
+ dismiss();
+ }});
+ // Create the AlertDialog object and return it
+ return builder.create();
+ }
+}
diff --git a/src/com/android/contacts/common/preference/ContactsPreferences.java b/src/com/android/contacts/common/preference/ContactsPreferences.java
index 311d0075..5c07f83f 100644
--- a/src/com/android/contacts/common/preference/ContactsPreferences.java
+++ b/src/com/android/contacts/common/preference/ContactsPreferences.java
@@ -27,6 +27,7 @@ import android.provider.ContactsContract;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
+import android.text.TextUtils;
import com.android.contacts.common.R;
/**
@@ -54,6 +55,11 @@ public final class ContactsPreferences implements OnSharedPreferenceChangeListen
public static final String SORT_ORDER_KEY = "android.contacts.SORT_ORDER";
/**
+ * The values of SIMs serial numbers that have been imported
+ */
+ public static final String IMPORTED_SIMS_SNS = "android.contacts.IMPORTED_SIMS";
+
+ /**
* The value for the SORT_ORDER key corresponding to sort by family name first.
*/
public static final int SORT_ORDER_ALTERNATIVE = 2;
@@ -105,6 +111,28 @@ public final class ContactsPreferences implements OnSharedPreferenceChangeListen
editor.commit();
}
+ public String[] getImportedSims() {
+ String imported = mPreferences.getString(IMPORTED_SIMS_SNS, "");
+ if (!TextUtils.isEmpty(imported)) {
+ return imported.split("\\|");
+ } else {
+ return new String[0];
+ }
+ }
+
+ public void addImportedSims(String simSN) {
+ String imported = mPreferences.getString(IMPORTED_SIMS_SNS, "");
+ if (!TextUtils.isEmpty(imported)) {
+ imported += "|" + simSN;
+ } else {
+ imported = simSN;
+ }
+
+ final Editor editor = mPreferences.edit();
+ editor.putString(IMPORTED_SIMS_SNS, imported);
+ editor.commit();
+ }
+
public boolean isDisplayOrderUserChangeable() {
return mContext.getResources().getBoolean(R.bool.config_display_order_user_changeable);
}