* #36666: new PasswordPreference based on CyanogenMod source code
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 657ddba..677b4fe 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -53,7 +53,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
-
+
<uses-feature
android:name="android.hardware.wifi"
android:required="false" />
@@ -70,10 +70,6 @@
android:name="android.hardware.screen.portrait"
android:required="false" />
-
-
-
-
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
@@ -128,20 +124,25 @@
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel" />
+ <data android:mimeType="vnd.android.cursor.item/phone" />
+ <data android:mimeType="vnd.android.cursor.item/phone_v2" />
+ <data android:mimeType="vnd.android.cursor.item/person" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.CALL" />
+
+ <category android:name="android.intent.category.DEFAULT" />
+
+ <data android:scheme="tel" />
+ <data android:mimeType="vnd.android.cursor.item/phone" />
+ <data android:mimeType="vnd.android.cursor.item/phone_v2" />
+ <data android:mimeType="vnd.android.cursor.item/person" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</activity>
- <!-- <receiver -->
- <!-- android:name="org.sflphone.receivers.ExternalCallReceiver" -->
- <!-- android:exported="true" > -->
- <!-- <intent-filter> -->
- <!-- <action android:name="android.intent.action.NEW_OUTGOING_CALL" /> -->
-
-
- <!-- <category android:name="android.intent.category.DEFAULT" /> -->
- <!-- </intent-filter> -->
- <!-- </receiver> -->
-
<service
android:name="org.sflphone.service.SipService"
android:exported="false" >
diff --git a/res/values-fr/strings_account.xml b/res/values-fr/strings_account.xml
index 481af33..2401499 100644
--- a/res/values-fr/strings_account.xml
+++ b/res/values-fr/strings_account.xml
@@ -27,6 +27,7 @@
<string name="account_useragent_label">User-agent</string>
<string name="account_proxy_field">Proxy</string>
<string name="account_autoanswer_label">Décroche automatiquement l\'appel</string>
+ <string name="show_password">Voir mot de passe</string>
<!-- Audio Details -->
<string name="account_preferences_audio_tab">Audio</string>
diff --git a/res/values/strings_account.xml b/res/values/strings_account.xml
index b0aa059..1b836a3 100644
--- a/res/values/strings_account.xml
+++ b/res/values/strings_account.xml
@@ -27,6 +27,7 @@
<string name="account_useragent_label">User Agent</string>
<string name="account_autoanswer_label">Auto Answer</string>
<string name="account_proxy_field">Proxy</string>
+ <string name="show_password">Show password</string>
<!-- Audio Details -->
<string name="account_preferences_audio_tab">Audio</string>
diff --git a/res/xml/account_general_prefs.xml b/res/xml/account_general_prefs.xml
index d3d0c8b..833b306 100644
--- a/res/xml/account_general_prefs.xml
+++ b/res/xml/account_general_prefs.xml
@@ -53,7 +53,7 @@
android:persistent="false"
android:summary=""
android:title="@string/account_username_label" />
- <EditTextPreference
+ <org.sflphone.views.PasswordPreference
android:id="@+id/account_password"
android:key="Account.password"
android:persistent="false"
diff --git a/src/org/sflphone/fragments/GeneralAccountFragment.java b/src/org/sflphone/fragments/GeneralAccountFragment.java
index b1075d0..8cf5ab0 100644
--- a/src/org/sflphone/fragments/GeneralAccountFragment.java
+++ b/src/org/sflphone/fragments/GeneralAccountFragment.java
@@ -3,6 +3,7 @@
import org.sflphone.R;
import org.sflphone.account.AccountDetail;
import org.sflphone.model.Account;
+import org.sflphone.views.PasswordPreference;
import android.app.Activity;
import android.os.Bundle;
@@ -66,7 +67,16 @@
if (pref != null) {
if (!p.isTwoState) {
((EditTextPreference) pref).setText(p.mValue);
- pref.setSummary(p.mValue);
+ if (pref instanceof PasswordPreference) {
+ String tmp = new String();
+ for (int i = 0; i < p.mValue.length(); ++i) {
+ tmp += "*";
+
+ }
+ pref.setSummary(tmp);
+ } else {
+ pref.setSummary(p.mValue);
+ }
} else {
((CheckBoxPreference) pref).setChecked(p.isChecked());
}
diff --git a/src/org/sflphone/receivers/ExternalCallReceiver.java b/src/org/sflphone/receivers/OutgoingCallReceiver.java
similarity index 96%
rename from src/org/sflphone/receivers/ExternalCallReceiver.java
rename to src/org/sflphone/receivers/OutgoingCallReceiver.java
index c4f7527..2e4c77d 100644
--- a/src/org/sflphone/receivers/ExternalCallReceiver.java
+++ b/src/org/sflphone/receivers/OutgoingCallReceiver.java
@@ -42,7 +42,7 @@
* @author lisional
*
*/
-public class ExternalCallReceiver extends BroadcastReceiver
+public class OutgoingCallReceiver extends BroadcastReceiver
{
@Override
diff --git a/src/org/sflphone/views/PasswordPreference.java b/src/org/sflphone/views/PasswordPreference.java
new file mode 100644
index 0000000..a8636a3
--- /dev/null
+++ b/src/org/sflphone/views/PasswordPreference.java
@@ -0,0 +1,121 @@
+package org.sflphone.views;
+
+import org.sflphone.R;
+import org.sflphone.utils.Compatibility;
+
+import android.content.Context;
+import android.view.View.OnClickListener;
+import android.preference.EditTextPreference;
+import android.text.Editable;
+import android.text.InputType;
+import android.text.TextUtils;
+import android.text.TextWatcher;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewParent;
+import android.widget.CheckBox;
+import android.widget.EditText;
+
+public class PasswordPreference extends EditTextPreference implements OnClickListener, TextWatcher {
+
+ private static final String THIS_FILE = "PasswordPreference";
+ private CheckBox showPwdCheckbox;
+
+ private boolean canShowPassword = false;
+
+ public PasswordPreference(Context context) {
+ this(context, null);
+ }
+
+ public PasswordPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onAddEditTextToDialogView(View dialogView, EditText editText) {
+ super.onAddEditTextToDialogView(dialogView, editText);
+ editText.addTextChangedListener(this);
+ }
+
+ @Override
+ protected void onBindDialogView(View view) {
+ super.onBindDialogView(view);
+ try {
+ if (showPwdCheckbox == null) {
+ showPwdCheckbox = new CheckBox(getContext());
+ showPwdCheckbox.setText(R.string.show_password);
+ showPwdCheckbox.setOnClickListener(this);
+ }
+
+ canShowPassword = TextUtils.isEmpty(getText());
+ getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
+ updateCanShowPassword();
+ ViewParent oldParent = showPwdCheckbox.getParent();
+ if (oldParent != view) {
+ if (oldParent != null) {
+ ((ViewGroup) oldParent).removeView(showPwdCheckbox);
+ }
+ }
+
+ ViewGroup container = (ViewGroup) view;
+ if (Compatibility.isCompatible(8)) {
+ container = (ViewGroup) container.getChildAt(0);
+ }
+ if (container != null) {
+ container.addView(showPwdCheckbox, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+ }
+ } catch (Exception e) {
+ // Just do nothing in case weird ROM in use
+ Log.w(THIS_FILE, "Unsupported device for enhanced password", e);
+ }
+ }
+
+ @Override
+ public void onClick(View view) {
+ if (!canShowPassword) {
+ // Even if not shown, be very very sure we never come here
+ return;
+ }
+ getEditText().setInputType(
+ InputType.TYPE_CLASS_TEXT
+ | (((CheckBox) view).isChecked() ? InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD : InputType.TYPE_TEXT_VARIATION_PASSWORD));
+ }
+
+ @Override
+ public void setText(String text) {
+ super.setText(text);
+ setCanShowPassword(TextUtils.isEmpty(text));
+ }
+
+ private void updateCanShowPassword() {
+ if (showPwdCheckbox != null) {
+ showPwdCheckbox.setVisibility(canShowPassword ? View.VISIBLE : View.GONE);
+ }
+ }
+
+ private void setCanShowPassword(boolean canShow) {
+ canShowPassword = canShow;
+ updateCanShowPassword();
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ if (s.length() == 0) {
+ setCanShowPassword(true);
+ }
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ // Nothing to do
+
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ // Nothing to do
+ }
+
+}
\ No newline at end of file