diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 657ddba4912260e8d864526a9224c0d0290c5b9f..677b4fe216c2499eb0f143bda3585dd066d51104 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -53,7 +53,7 @@ as that of the covered work. <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 @@ as that of the covered work. android:name="android.hardware.screen.portrait" android:required="false" /> - - - - <application android:allowBackup="true" android:icon="@drawable/ic_launcher" @@ -128,19 +124,24 @@ as that of the covered work. <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> - </activity> - - <!-- <receiver --> - <!-- android:name="org.sflphone.receivers.ExternalCallReceiver" --> - <!-- android:exported="true" > --> - <!-- <intent-filter> --> - <!-- <action android:name="android.intent.action.NEW_OUTGOING_CALL" /> --> + <intent-filter> + <action android:name="android.intent.action.CALL" /> + <category android:name="android.intent.category.DEFAULT" /> - <!-- <category android:name="android.intent.category.DEFAULT" /> --> - <!-- </intent-filter> --> - <!-- </receiver> --> + <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> <service android:name="org.sflphone.service.SipService" diff --git a/res/values-fr/strings_account.xml b/res/values-fr/strings_account.xml index 481af33f164f7c786ddd564e30033a1ce4dcd62f..2401499acaa0828ae9e44234e122e70d0f7bb1af 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 b0aa059916b0b890d8864a503f851eef51b8edf6..1b836a383f3d2a68502ae9520b0437b209099764 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 d3d0c8bfcb7bf8b0b2f6ed4a58b13d56abdc9013..833b306f00afe2261d694eddda214a10c783a76f 100644 --- a/res/xml/account_general_prefs.xml +++ b/res/xml/account_general_prefs.xml @@ -53,7 +53,7 @@ as that of the covered work. 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 b1075d0113cef411d01fa29c928f063ca98c1fb6..8cf5ab021c2d4901f184a43f96c721c54f38ccd7 100644 --- a/src/org/sflphone/fragments/GeneralAccountFragment.java +++ b/src/org/sflphone/fragments/GeneralAccountFragment.java @@ -3,6 +3,7 @@ package org.sflphone.fragments; 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 @@ public class GeneralAccountFragment extends PreferenceFragment { 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 97% rename from src/org/sflphone/receivers/ExternalCallReceiver.java rename to src/org/sflphone/receivers/OutgoingCallReceiver.java index c4f7527c71f06820f45e0ec899590109b44535ed..2e4c77d009df13634e803b1b6878eba789d6f163 100644 --- a/src/org/sflphone/receivers/ExternalCallReceiver.java +++ b/src/org/sflphone/receivers/OutgoingCallReceiver.java @@ -42,7 +42,7 @@ import android.util.Log; * @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 0000000000000000000000000000000000000000..a8636a31533cfbab29cbd2fac849588063f39a84 --- /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