This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository say-my-texts. See http://git.chorem.org/say-my-texts.git commit 3fd3da4529df4fa8d0175c5d30cf7bba238bd5e2 Author: Kevin Morin <morin@codelutin.com> Date: Mon Jun 16 13:41:50 2014 +0200 fixes #1034 [Settings] Error retrieving the user's phone number --- AndroidManifest.xml | 4 +-- res/values-fr/strings.xml | 5 ++- res/values/strings.xml | 3 ++ .../android/saymytexts/SettingsActivity.java | 38 +++++++++++++++++++--- 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 84fbd01..9df3374 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.chorem.android.saymytexts" - android:versionCode="4" - android:versionName="2.0.1" + android:versionCode="5" + android:versionName="2.0.2" android:description="@string/app_description" android:installLocation="auto"> diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 38f31b2..ad19591 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -10,7 +10,7 @@ <!-- Preferences --> <string name="preferences_settings_label">Paramètres</string> <string name="preference_reading_profile_label">Lecture des SMS</string> - <string name="preference_enable_interaction_label">Intéraction (appel ou réponse)</string> + <string name="preference_enable_interaction_label">Interaction (appel ou réponse)</string> <string name="preference_voice_recognizer_max_attempt_number_label">Nombre maximum d\'essais</string> <string name="preference_enable_heisendroid_mode_label">Mode Heisendroid</string> <string name="preference_test_sms_label">Tester en m\'envoyant un SMS</string> @@ -23,6 +23,9 @@ <string name="preference_issue_tracker_label">Rapporter un bug</string> <string name="preference_issue_tracker_url">http://forge.chorem.org/projects/say-my-texts/issues</string> + <string name="preference_ask_phone_number_title">Votre numéro</string> + <string name="preference_ask_phone_number_message">Veuillez saisir votre numéro pour l\'envoi du SMS de test</string> + <!--ACRA--> <string name="crash_toast_text">Erreur innatendue, préparation du rapport de bug</string> <string name="crash_dialog_title">Say My Texts a planté</string> diff --git a/res/values/strings.xml b/res/values/strings.xml index 2f0c3db..d0a3ba0 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -23,6 +23,9 @@ <string name="preference_issue_tracker_label">Bug report</string> <string name="preference_issue_tracker_url">http://forge.chorem.org/projects/say-my-texts/issues</string> + <string name="preference_ask_phone_number_title">Your phone number</string> + <string name="preference_ask_phone_number_message">Enter your phone number to send the text</string> + <!--ACRA--> <string name="crash_toast_text">Ooooops ! the application crashed, but a report has been sent to my developer to help fix the issue !</string> <string name="crash_dialog_title">say My Texts has crashed</string> diff --git a/src/org/chorem/android/saymytexts/SettingsActivity.java b/src/org/chorem/android/saymytexts/SettingsActivity.java index d738a9d..668cb67 100644 --- a/src/org/chorem/android/saymytexts/SettingsActivity.java +++ b/src/org/chorem/android/saymytexts/SettingsActivity.java @@ -25,8 +25,10 @@ package org.chorem.android.saymytexts; */ import android.app.Activity; +import android.app.AlertDialog; import android.app.PendingIntent; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; @@ -40,7 +42,9 @@ import android.preference.SwitchPreference; import android.speech.tts.TextToSpeech; import android.telephony.SmsManager; import android.telephony.TelephonyManager; +import android.text.InputType; import android.util.Log; +import android.widget.EditText; /** * Activity to set settings @@ -201,15 +205,39 @@ public class SettingsActivity extends Activity { protected void sendSMS() { final Context context = getActivity(); + final String message = getString(R.string.test_sms_content); + + final PendingIntent pi = PendingIntent.getActivity(context, -1, new Intent(context, SettingsActivity.class), 0); + final SmsManager sms = SmsManager.getDefault(); + TelephonyManager tMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String phoneNumber = tMgr.getLine1Number(); - String message = getString(R.string.test_sms_content); - PendingIntent pi = PendingIntent.getActivity(context, -1, new Intent(context, SettingsActivity.class), 0); - SmsManager sms = SmsManager.getDefault(); - sms.sendTextMessage(phoneNumber, null, message, pi, null); + if (phoneNumber != null) { + sms.sendTextMessage(phoneNumber, null, message, pi, null); - } + } else { + AlertDialog.Builder alert = new AlertDialog.Builder(context); + alert.setTitle(R.string.preference_ask_phone_number_title); + alert.setMessage(R.string.preference_ask_phone_number_message); + + final EditText input = new EditText(context); + input.setInputType(InputType.TYPE_CLASS_PHONE); + alert.setView(input); + + alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + String value = input.getText().toString(); + sms.sendTextMessage(value, null, message, pi, null); + // Do something with value! + } + }); + + alert.setNegativeButton(android.R.string.cancel, null); + + alert.show(); + } + } } } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.