Commit 822f8cb9 authored by Grigory Fedorov's avatar Grigory Fedorov

Orbot install dialog implemented with Alert Dialog Builder

parent 07db7c83
...@@ -14,14 +14,12 @@ ...@@ -14,14 +14,12 @@
*/ */
package com.xabber.android.ui; package com.xabber.android.ui;
import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
...@@ -40,8 +38,6 @@ import com.xabber.androiddev.R; ...@@ -40,8 +38,6 @@ import com.xabber.androiddev.R;
public class AccountAdd extends ManagedActivity implements View.OnClickListener { public class AccountAdd extends ManagedActivity implements View.OnClickListener {
private static final int ORBOT_DIALOG_ID = 9050;
private CheckBox storePasswordView; private CheckBox storePasswordView;
private CheckBox useOrbotView; private CheckBox useOrbotView;
private CheckBox createAccount; private CheckBox createAccount;
...@@ -98,7 +94,7 @@ public class AccountAdd extends ManagedActivity implements View.OnClickListener ...@@ -98,7 +94,7 @@ public class AccountAdd extends ManagedActivity implements View.OnClickListener
private void addAccount() { private void addAccount() {
if (useOrbotView.isChecked() && !OrbotHelper.isOrbotInstalled()) { if (useOrbotView.isChecked() && !OrbotHelper.isOrbotInstalled()) {
showDialog(ORBOT_DIALOG_ID); OrbotInstallerDialogBuilder.show(this);
return; return;
} }
...@@ -128,14 +124,6 @@ public class AccountAdd extends ManagedActivity implements View.OnClickListener ...@@ -128,14 +124,6 @@ public class AccountAdd extends ManagedActivity implements View.OnClickListener
finish(); finish();
} }
@Override
protected Dialog onCreateDialog(int id) {
if (id == ORBOT_DIALOG_ID) {
return new OrbotInstallerDialogBuilder(this, ORBOT_DIALOG_ID).create();
}
return super.onCreateDialog(id);
}
public static Intent createIntent(Context context) { public static Intent createIntent(Context context) {
return new Intent(context, AccountAdd.class); return new Intent(context, AccountAdd.class);
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
package com.xabber.android.ui.dialog; package com.xabber.android.ui.dialog;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
...@@ -27,26 +28,25 @@ import com.xabber.androiddev.R; ...@@ -27,26 +28,25 @@ import com.xabber.androiddev.R;
* *
* @author alexander.ivanov * @author alexander.ivanov
*/ */
public class OrbotInstallerDialogBuilder extends DialogBuilder { public class OrbotInstallerDialogBuilder {
private final static String MARKET_SEARCH = "market://search?q=pname:%s"; private final static String MARKET_SEARCH = "market://search?q=pname:%s";
public OrbotInstallerDialogBuilder(final Activity activity, int dialogId) { public static void show(final Activity activity) {
super(activity, dialogId); new AlertDialog.Builder(activity)
setIcon(android.R.drawable.ic_dialog_alert); .setTitle(R.string.orbot_required_title)
setTitle(R.string.orbot_required_title); .setMessage(R.string.orbot_required_message)
setMessage(R.string.orbot_required_message); .setPositiveButton(android.R.string.yes,
setPositiveButton(android.R.string.yes,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int w) { public void onClick(DialogInterface dialog, int w) {
Uri uri = Uri.parse(String.format(MARKET_SEARCH, Uri uri = Uri.parse(String.format(MARKET_SEARCH, OrbotHelper.URI_ORBOT));
OrbotHelper.URI_ORBOT));
Intent intent = new Intent(Intent.ACTION_VIEW, uri); Intent intent = new Intent(Intent.ACTION_VIEW, uri);
activity.startActivity(intent); activity.startActivity(intent);
} }
}); })
setNegativeButton(android.R.string.no, null); .setNegativeButton(android.R.string.no, null)
.show();
} }
} }
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
*/ */
package com.xabber.android.ui.preferences; package com.xabber.android.ui.preferences;
import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
...@@ -41,8 +40,6 @@ public class AccountEditor extends ManagedActivity implements ...@@ -41,8 +40,6 @@ public class AccountEditor extends ManagedActivity implements
public static final String INVALIDATED_TOKEN = "com.xabber.android.ui.preferences.AccountEditor.INVALIDATED"; public static final String INVALIDATED_TOKEN = "com.xabber.android.ui.preferences.AccountEditor.INVALIDATED";
private static final int ORBOT_DIALOG_ID = 9050;
private String account; private String account;
private AccountItem accountItem; private AccountItem accountItem;
...@@ -122,14 +119,6 @@ public class AccountEditor extends ManagedActivity implements ...@@ -122,14 +119,6 @@ public class AccountEditor extends ManagedActivity implements
return false; return false;
} }
@Override
protected Dialog onCreateDialog(int id) {
if (id == ORBOT_DIALOG_ID) {
return new OrbotInstallerDialogBuilder(this, ORBOT_DIALOG_ID).create();
}
return super.onCreateDialog(id);
}
private static String getAccount(Intent intent) { private static String getAccount(Intent intent) {
return AccountIntentBuilder.getAccount(intent); return AccountIntentBuilder.getAccount(intent);
} }
...@@ -161,7 +150,7 @@ public class AccountEditor extends ManagedActivity implements ...@@ -161,7 +150,7 @@ public class AccountEditor extends ManagedActivity implements
@Override @Override
public void showOrbotDialog() { public void showOrbotDialog() {
showDialog(ORBOT_DIALOG_ID); OrbotInstallerDialogBuilder.show(this);
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment