Wizard's working + possibility to add detailled user-agent
This commit is contained in:
parent
398e77d93b
commit
460f878b69
6 changed files with 114 additions and 19 deletions
|
@ -2,12 +2,41 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ImageView
|
||||
android:paddingTop="40dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/setup_title_assistant"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/setup_validate_account"
|
||||
android:textColor="@android:color/black" />
|
||||
android:paddingTop="40dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/setup_validate_account"
|
||||
android:textColor="@android:color/black" />
|
||||
|
||||
<RelativeLayout
|
||||
android:paddingTop="20dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/setup_check"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/button"
|
||||
android:layout_centerInParent="true" />
|
||||
|
||||
<TextView
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/setup_check_account_validation"
|
||||
android:textColor="@android:color/black" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -307,5 +307,8 @@
|
|||
<string name="setup_password_confirm_hint">confirm password</string>
|
||||
<string name="setup_email_hint">email</string>
|
||||
<string name="setup_create">Create Account</string>
|
||||
<string name="setup_validate_account">Waiting for account activation</string>
|
||||
<string name="setup_validate_account">An email has been sent to the address you gave. In order to activate your account, you need to click on the link inside it. Once it is done, come back here and click on the button above.</string>
|
||||
<string name="setup_check_account_validation">Check</string>
|
||||
<string name="setup_account_not_validated">Your account has not been validated yet.</string>
|
||||
<string name="setup_account_validated">Your account has been validated.</string>
|
||||
</resources>
|
||||
|
|
|
@ -53,8 +53,7 @@ public class LinphoneLoginFragment extends Fragment implements OnClickListener {
|
|||
int id = v.getId();
|
||||
|
||||
if (id == R.id.setup_apply) {
|
||||
if (login.getText() == null || login.length() == 0
|
||||
|| password.getText() == null || password.length() == 0) {
|
||||
if (login.getText() == null || login.length() == 0 || password.getText() == null || password.length() == 0) {
|
||||
Toast.makeText(getActivity().getApplicationContext(), getString(R.string.first_launch_no_login_password), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -187,13 +187,23 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
|||
}
|
||||
}
|
||||
|
||||
public void displayWizardConfirm() {
|
||||
public void displayWizardConfirm(String username) {
|
||||
WizardConfirmFragment fragment = new WizardConfirmFragment();
|
||||
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("Username", username);
|
||||
fragment.setArguments(extras);
|
||||
changeFragment(fragment);
|
||||
|
||||
currentFragment = SetupFragments.WIZARD_CONFIRM;
|
||||
|
||||
next.setVisibility(View.VISIBLE);
|
||||
next.setEnabled(false);
|
||||
back.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void isAccountVerified() {
|
||||
next.setEnabled(true);
|
||||
Toast.makeText(this, getString(R.string.setup_account_validated), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,34 +22,88 @@ import java.net.URL;
|
|||
import org.linphone.R;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
import de.timroes.axmlrpc.XMLRPCCallback;
|
||||
import de.timroes.axmlrpc.XMLRPCClient;
|
||||
import de.timroes.axmlrpc.XMLRPCException;
|
||||
import de.timroes.axmlrpc.XMLRPCServerException;
|
||||
/**
|
||||
* @author Sylvain Berfini
|
||||
*/
|
||||
public class WizardConfirmFragment extends Fragment {
|
||||
|
||||
private String username;
|
||||
private Handler mHandler = new Handler();
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.setup_wizard_confirm, container, false);
|
||||
|
||||
username = getArguments().getString("Username");
|
||||
|
||||
ImageView checkAccount = (ImageView) view.findViewById(R.id.setup_check);
|
||||
checkAccount.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
isAccountVerified(username);
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isAccountVerified(String username) {
|
||||
private void isAccountVerified(String username) {
|
||||
final Runnable runNotReachable = new Runnable() {
|
||||
public void run() {
|
||||
Toast.makeText(getActivity(), getString(R.string.wizard_server_unavailable), Toast.LENGTH_LONG);
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
XMLRPCClient client = new XMLRPCClient(new URL(getString(R.string.wizard_url)));
|
||||
Object resultO = client.call("check_account_validated", "sip:" + username + "@" + getString(R.string.default_domain));
|
||||
Integer result = Integer.parseInt(resultO.toString());
|
||||
|
||||
return result == 1;
|
||||
} catch(Exception ex) {
|
||||
|
||||
XMLRPCCallback listener = new XMLRPCCallback() {
|
||||
Runnable runNotOk = new Runnable() {
|
||||
public void run() {
|
||||
Toast.makeText(getActivity(), getString(R.string.setup_account_not_validated), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
};
|
||||
|
||||
Runnable runOk = new Runnable() {
|
||||
public void run() {
|
||||
SetupActivity.instance().isAccountVerified();
|
||||
}
|
||||
};
|
||||
|
||||
public void onResponse(long id, Object result) {
|
||||
int answer = (Integer) result;
|
||||
if (answer != 1) {
|
||||
mHandler.post(runNotOk);
|
||||
} else {
|
||||
mHandler.post(runOk);
|
||||
}
|
||||
}
|
||||
|
||||
public void onError(long id, XMLRPCException error) {
|
||||
mHandler.post(runNotReachable);
|
||||
}
|
||||
|
||||
public void onServerError(long id, XMLRPCServerException error) {
|
||||
mHandler.post(runNotReachable);
|
||||
}
|
||||
};
|
||||
|
||||
client.callAsync(listener, "check_account_validated", "sip:" + username + "@" + getString(R.string.default_domain));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
mHandler.post(runNotReachable);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ public class WizardFragment extends Fragment {
|
|||
Runnable runOk = new Runnable() {
|
||||
public void run() {
|
||||
SetupActivity.instance().saveCreatedAccount(username, password, getString(R.string.default_domain));
|
||||
SetupActivity.instance().displayWizardConfirm();
|
||||
SetupActivity.instance().displayWizardConfirm(username);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -194,7 +194,7 @@ public class WizardFragment extends Fragment {
|
|||
}
|
||||
};
|
||||
|
||||
client.callAsync(listener, "create_account", username, password, email, suscribe ? 1 : 0);
|
||||
client.callAsync(listener, "create_account_with_useragent", username, password, email, "linphone-wizard-android");
|
||||
}
|
||||
catch(Exception ex) {
|
||||
mHandler.post(runNotReachable);
|
||||
|
|
Loading…
Reference in a new issue