diff --git a/res/layout/accounts.xml b/res/layout/accounts.xml
new file mode 100644
index 000000000..c0065ef70
--- /dev/null
+++ b/res/layout/accounts.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
diff --git a/res/layout/dialer.xml b/res/layout/dialer.xml
index 1fd16bce0..116c4435f 100644
--- a/res/layout/dialer.xml
+++ b/res/layout/dialer.xml
@@ -1,4 +1,5 @@
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/wizard_confirm.xml b/res/layout/wizard_confirm.xml
new file mode 100644
index 000000000..c3020b989
--- /dev/null
+++ b/res/layout/wizard_confirm.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index bd55d666f..2543d421b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -243,4 +243,6 @@
Your password is not valid (6 characters min).
Passwords entered are different.
You need to activate your account with the link that was send to your email.
+Confirmation
+Check
diff --git a/src/org/linphone/DialerActivity.java b/src/org/linphone/DialerActivity.java
index 97df4a686..342e0d128 100644
--- a/src/org/linphone/DialerActivity.java
+++ b/src/org/linphone/DialerActivity.java
@@ -18,10 +18,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone;
+import java.util.ArrayList;
+import java.util.HashMap;
+
import org.linphone.LinphoneService.LinphoneGuiListener;
import org.linphone.core.LinphoneCall;
-import org.linphone.core.Log;
import org.linphone.core.LinphoneCall.State;
+import org.linphone.core.LinphoneCore.RegistrationState;
+import org.linphone.core.LinphoneProxyConfig;
+import org.linphone.core.Log;
import org.linphone.ui.AddressAware;
import org.linphone.ui.AddressText;
import org.linphone.ui.CallButton;
@@ -32,6 +37,12 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
+import android.widget.Adapter;
+import android.widget.ListAdapter;
+import android.widget.ListView;
+import android.widget.SimpleAdapter;
+import android.widget.SlidingDrawer;
+import android.widget.SlidingDrawer.OnDrawerScrollListener;
import android.widget.TextView;
import android.widget.Toast;
@@ -67,6 +78,37 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
public static DialerActivity instance() {
return instance;
}
+
+ private String getStatusIcon(RegistrationState state) {
+ if (state == RegistrationState.RegistrationOk)
+ return Integer.toString(R.drawable.status_green);
+
+ else if (state == RegistrationState.RegistrationNone)
+ return Integer.toString(R.drawable.status_red);
+
+ else if (state == RegistrationState.RegistrationProgress)
+ return Integer.toString(R.drawable.status_orange);
+
+ else
+ return Integer.toString(R.drawable.status_offline);
+ }
+
+ private void displayRegisterStatus() {
+ ListView accounts = (ListView) findViewById(R.id.accounts);
+ accounts.setDividerHeight(0);
+ ArrayList> hashMapAccountsStateList = new ArrayList>();
+ for (LinphoneProxyConfig lpc : LinphoneManager.getLc().getProxyConfigList()) {
+ HashMap entitiesHashMap = new HashMap();
+ entitiesHashMap.put("Identity", lpc.getIdentity().split("sip:")[1]);
+ entitiesHashMap.put("State", getStatusIcon(lpc.getState()));
+ hashMapAccountsStateList.add(entitiesHashMap);
+ }
+ Adapter adapterForList = new SimpleAdapter(this, hashMapAccountsStateList, R.layout.accounts,
+ new String[] {"Identity", "State"},
+ new int[] { R.id.Identity, R.id.State });
+ accounts.setAdapter((ListAdapter) adapterForList);
+ accounts.invalidate();
+ }
public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.dialer);
@@ -79,6 +121,17 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
mCall.setAddressWidget(mAddress);
mStatus = (TextView) findViewById(R.id.status_label);
+
+ SlidingDrawer drawer = (SlidingDrawer) findViewById(R.id.drawer);
+ drawer.setOnDrawerScrollListener(new OnDrawerScrollListener() {
+ public void onScrollEnded() {
+
+ }
+
+ public void onScrollStarted() {
+ displayRegisterStatus();
+ }
+ });
AddressAware numpad = (AddressAware) findViewById(R.id.Dialer);
if (numpad != null)
@@ -98,6 +151,7 @@ public class DialerActivity extends Activity implements LinphoneGuiListener {
instance = this;
super.onCreate(savedInstanceState);
+ displayRegisterStatus();
}
diff --git a/src/org/linphone/LinphonePreferencesActivity.java b/src/org/linphone/LinphonePreferencesActivity.java
index 74fbe1c1c..87e6ad1bb 100644
--- a/src/org/linphone/LinphonePreferencesActivity.java
+++ b/src/org/linphone/LinphonePreferencesActivity.java
@@ -69,7 +69,6 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
-import android.widget.Toast;
import de.timroes.axmlrpc.XMLRPCCallback;
import de.timroes.axmlrpc.XMLRPCClient;
import de.timroes.axmlrpc.XMLRPCException;
@@ -91,9 +90,11 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
private Button createAccount;
private TextView errorMessage;
private PreferenceCategory accounts;
+ private String username;
private static final int ADD_SIP_ACCOUNT = 0x666;
private static final int WIZARD_ID = 0x667;
+ private static final int CONFIRM_ID = 0x668;
private SharedPreferences prefs() {
return getPreferenceManager().getSharedPreferences();
@@ -253,6 +254,33 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
wizardDialog = builder.create();
return wizardDialog;
}
+ else if (id == CONFIRM_ID) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(LinphonePreferencesActivity.this);
+ builder.setTitle(R.string.wizard_confirmation);
+
+ LayoutInflater inflater = LayoutInflater.from(LinphonePreferencesActivity.this);
+ View v = inflater.inflate(R.layout.wizard_confirm, null);
+ builder.setView(v);
+
+ Button check = (Button) v.findViewById(R.id.wizardCheckAccount);
+ check.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ if (isAccountVerified(username)) {
+ wizardDialog.dismiss();
+ }
+ }
+ });
+
+ Button cancel = (Button) v.findViewById(R.id.wizardCancel);
+ cancel.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ wizardDialog.dismiss();
+ }
+ });
+
+ wizardDialog = builder.create();
+ return wizardDialog;
+ }
return null;
}
@@ -260,6 +288,19 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
return username.matches("^[a-zA-Z]+[a-zA-Z0-9.\\-_]{2,}$");
}
+ private boolean isAccountVerified(String username) {
+ try {
+ XMLRPCClient client = new XMLRPCClient(new URL("https://www.linphone.org/wizard.php"));
+ Object resultO = client.call("check_account_validated", "sip:" + username + "@sip.linphone.org");
+ Integer result = Integer.parseInt(resultO.toString());
+
+ return result == 1;
+ } catch(Exception ex) {
+
+ }
+ return false;
+ }
+
private void isUsernameRegistred(String username, final ImageView icon) {
final Runnable runNotReachable = new Runnable() {
public void run() {
@@ -346,12 +387,13 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
Runnable runOk = new Runnable() {
public void run() {
addExtraAccountPreferencesButton(accounts, nbAccounts, true);
+ LinphonePreferencesActivity.this.username = username;
fillLinphoneAccount(nbAccounts, username, password);
nbAccounts++;
createDynamicAccountsPreferences();
wizardDialog.dismiss();
- Toast.makeText(LinphonePreferencesActivity.this, R.string.wizard_need_activation, Toast.LENGTH_LONG).show();
+ showDialog(CONFIRM_ID);
}
};