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

Orbot install dialog implemented with Alert Dialog Builder

parent 07db7c83
......@@ -14,14 +14,12 @@
*/
package com.xabber.android.ui;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
......@@ -40,8 +38,6 @@ import com.xabber.androiddev.R;
public class AccountAdd extends ManagedActivity implements View.OnClickListener {
private static final int ORBOT_DIALOG_ID = 9050;
private CheckBox storePasswordView;
private CheckBox useOrbotView;
private CheckBox createAccount;
......@@ -98,7 +94,7 @@ public class AccountAdd extends ManagedActivity implements View.OnClickListener
private void addAccount() {
if (useOrbotView.isChecked() && !OrbotHelper.isOrbotInstalled()) {
showDialog(ORBOT_DIALOG_ID);
OrbotInstallerDialogBuilder.show(this);
return;
}
......@@ -128,14 +124,6 @@ public class AccountAdd extends ManagedActivity implements View.OnClickListener
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) {
return new Intent(context, AccountAdd.class);
}
......
......@@ -15,6 +15,7 @@
package com.xabber.android.ui.dialog;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
......@@ -27,26 +28,25 @@ import com.xabber.androiddev.R;
*
* @author alexander.ivanov
*/
public class OrbotInstallerDialogBuilder extends DialogBuilder {
public class OrbotInstallerDialogBuilder {
private final static String MARKET_SEARCH = "market://search?q=pname:%s";
public OrbotInstallerDialogBuilder(final Activity activity, int dialogId) {
super(activity, dialogId);
setIcon(android.R.drawable.ic_dialog_alert);
setTitle(R.string.orbot_required_title);
setMessage(R.string.orbot_required_message);
setPositiveButton(android.R.string.yes,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int w) {
Uri uri = Uri.parse(String.format(MARKET_SEARCH,
OrbotHelper.URI_ORBOT));
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
activity.startActivity(intent);
}
});
setNegativeButton(android.R.string.no, null);
public static void show(final Activity activity) {
new AlertDialog.Builder(activity)
.setTitle(R.string.orbot_required_title)
.setMessage(R.string.orbot_required_message)
.setPositiveButton(android.R.string.yes,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int w) {
Uri uri = Uri.parse(String.format(MARKET_SEARCH, OrbotHelper.URI_ORBOT));
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
activity.startActivity(intent);
}
})
.setNegativeButton(android.R.string.no, null)
.show();
}
}
......@@ -14,7 +14,6 @@
*/
package com.xabber.android.ui.preferences;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
......@@ -41,8 +40,6 @@ public class AccountEditor extends ManagedActivity implements
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 AccountItem accountItem;
......@@ -122,14 +119,6 @@ public class AccountEditor extends ManagedActivity implements
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) {
return AccountIntentBuilder.getAccount(intent);
}
......@@ -161,7 +150,7 @@ public class AccountEditor extends ManagedActivity implements
@Override
public void showOrbotDialog() {
showDialog(ORBOT_DIALOG_ID);
OrbotInstallerDialogBuilder.show(this);
}
@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