reworked edit account dialog. advanced options are now gone. tls option available instead
This commit is contained in:
parent
c01f2cedb6
commit
4670585e7a
|
@ -41,25 +41,22 @@ public final class R {
|
||||||
}
|
}
|
||||||
public static final class id {
|
public static final class id {
|
||||||
public static final int account_confirm_password_desc=0x7f0a0011;
|
public static final int account_confirm_password_desc=0x7f0a0011;
|
||||||
public static final int account_delete=0x7f0a002c;
|
public static final int account_delete=0x7f0a0025;
|
||||||
public static final int account_disable=0x7f0a002d;
|
public static final int account_disable=0x7f0a0026;
|
||||||
public static final int account_enable=0x7f0a002e;
|
public static final int account_enable=0x7f0a0027;
|
||||||
public static final int account_jid=0x7f0a0000;
|
public static final int account_jid=0x7f0a0000;
|
||||||
public static final int account_list=0x7f0a0021;
|
public static final int account_list=0x7f0a001a;
|
||||||
public static final int account_password=0x7f0a000f;
|
public static final int account_password=0x7f0a000e;
|
||||||
public static final int account_password_confirm2=0x7f0a0012;
|
public static final int account_password_confirm2=0x7f0a0012;
|
||||||
public static final int account_server=0x7f0a0017;
|
|
||||||
public static final int account_show_advanced=0x7f0a0013;
|
|
||||||
public static final int account_status=0x7f0a0002;
|
public static final int account_status=0x7f0a0002;
|
||||||
public static final int account_username=0x7f0a000d;
|
public static final int account_usetls=0x7f0a000f;
|
||||||
public static final int action_accounts=0x7f0a0029;
|
public static final int action_accounts=0x7f0a0022;
|
||||||
public static final int action_add=0x7f0a0025;
|
public static final int action_add=0x7f0a001e;
|
||||||
public static final int action_add_account=0x7f0a002b;
|
public static final int action_add_account=0x7f0a0024;
|
||||||
public static final int action_archive=0x7f0a0028;
|
public static final int action_archive=0x7f0a0021;
|
||||||
public static final int action_details=0x7f0a0027;
|
public static final int action_details=0x7f0a0020;
|
||||||
public static final int action_security=0x7f0a0026;
|
public static final int action_security=0x7f0a001f;
|
||||||
public static final int action_settings=0x7f0a002a;
|
public static final int action_settings=0x7f0a0023;
|
||||||
public static final int advanced_options=0x7f0a0014;
|
|
||||||
public static final int contactList=0x7f0a0005;
|
public static final int contactList=0x7f0a0005;
|
||||||
public static final int contact_display_name=0x7f0a0007;
|
public static final int contact_display_name=0x7f0a0007;
|
||||||
public static final int contact_jid=0x7f0a0008;
|
public static final int contact_jid=0x7f0a0008;
|
||||||
|
@ -69,24 +66,20 @@ public final class R {
|
||||||
public static final int conversation_lastmsg=0x7f0a000b;
|
public static final int conversation_lastmsg=0x7f0a000b;
|
||||||
public static final int conversation_lastupdate=0x7f0a000c;
|
public static final int conversation_lastupdate=0x7f0a000c;
|
||||||
public static final int conversation_name=0x7f0a000a;
|
public static final int conversation_name=0x7f0a000a;
|
||||||
public static final int editText3=0x7f0a0019;
|
|
||||||
public static final int edit_account_register_new=0x7f0a0010;
|
public static final int edit_account_register_new=0x7f0a0010;
|
||||||
public static final int list=0x7f0a001f;
|
public static final int list=0x7f0a0018;
|
||||||
public static final int message_body=0x7f0a0023;
|
public static final int message_body=0x7f0a001c;
|
||||||
public static final int message_photo=0x7f0a0022;
|
public static final int message_photo=0x7f0a001b;
|
||||||
public static final int message_time=0x7f0a0024;
|
public static final int message_time=0x7f0a001d;
|
||||||
public static final int messages_view=0x7f0a001d;
|
public static final int messages_view=0x7f0a0016;
|
||||||
public static final int new_conversation_search=0x7f0a0003;
|
public static final int new_conversation_search=0x7f0a0003;
|
||||||
public static final int selected_conversation=0x7f0a0020;
|
public static final int selected_conversation=0x7f0a0019;
|
||||||
public static final int server_input_layout=0x7f0a0015;
|
public static final int slidingpanelayout=0x7f0a0017;
|
||||||
public static final int slidingpanelayout=0x7f0a001e;
|
public static final int textSendButton=0x7f0a0015;
|
||||||
public static final int textSendButton=0x7f0a001c;
|
public static final int textView1=0x7f0a000d;
|
||||||
public static final int textView1=0x7f0a000e;
|
|
||||||
public static final int textView2=0x7f0a0001;
|
public static final int textView2=0x7f0a0001;
|
||||||
public static final int textView3=0x7f0a0016;
|
public static final int textinput=0x7f0a0014;
|
||||||
public static final int textView4=0x7f0a0018;
|
public static final int textsend=0x7f0a0013;
|
||||||
public static final int textinput=0x7f0a001b;
|
|
||||||
public static final int textsend=0x7f0a001a;
|
|
||||||
}
|
}
|
||||||
public static final class layout {
|
public static final class layout {
|
||||||
public static final int account_row=0x7f030000;
|
public static final int account_row=0x7f030000;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
@ -12,15 +11,7 @@
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:text="Jabber ID:" />
|
android:text="Jabber ID:" />
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/account_username"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:ems="10"
|
|
||||||
android:inputType="textEmailAddress"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:hint="Username">
|
|
||||||
</EditText>
|
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/account_jid"
|
android:id="@+id/account_jid"
|
||||||
|
@ -52,6 +43,15 @@
|
||||||
android:fontFamily="sans-serif" />
|
android:fontFamily="sans-serif" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/account_usetls"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Use Transport Layer Security (TLS)"
|
||||||
|
android:checked="true"/>
|
||||||
|
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/edit_account_register_new"
|
android:id="@+id/edit_account_register_new"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -78,66 +78,4 @@
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:fontFamily="sans-serif" />
|
android:fontFamily="sans-serif" />
|
||||||
|
|
||||||
<CheckBox
|
|
||||||
android:id="@+id/account_show_advanced"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Show advanced options" />
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/advanced_options"
|
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/server_input_layout"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical" >
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:paddingTop="8dp"
|
|
||||||
android:id="@+id/textView3"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Server:"
|
|
||||||
android:textSize="14sp"/>
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/account_server"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:ems="10"
|
|
||||||
android:hint="Server"
|
|
||||||
android:inputType="textUri"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_width="144dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_toRightOf="@+id/server_input_layout">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:paddingTop="8dp"
|
|
||||||
android:id="@+id/textView4"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Port:"
|
|
||||||
android:textSize="14sp"/>
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/editText3"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:ems="10"
|
|
||||||
android:hint="Port"
|
|
||||||
android:inputType="number"
|
|
||||||
android:text="5222"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</RelativeLayout>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -43,35 +43,9 @@ public class EditAccount extends DialogFragment {
|
||||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
View view = inflater.inflate(R.layout.edit_account_dialog, null);
|
View view = inflater.inflate(R.layout.edit_account_dialog, null);
|
||||||
final EditText jidText = (EditText) view.findViewById(R.id.account_jid);
|
final EditText jidText = (EditText) view.findViewById(R.id.account_jid);
|
||||||
final EditText usernameText = (EditText) view
|
final TextView confirmPwDesc = (TextView) view
|
||||||
.findViewById(R.id.account_username);
|
.findViewById(R.id.account_confirm_password_desc);
|
||||||
final EditText serverText = (EditText) view
|
CheckBox useTLS = (CheckBox) view.findViewById(R.id.account_usetls);
|
||||||
.findViewById(R.id.account_server);
|
|
||||||
final TextView usernameDesc = (TextView) view
|
|
||||||
.findViewById(R.id.textView2);
|
|
||||||
final TextView confirmPwDesc = (TextView) view.findViewById(R.id.account_confirm_password_desc);
|
|
||||||
CheckBox showAdvanced = (CheckBox) view
|
|
||||||
.findViewById(R.id.account_show_advanced);
|
|
||||||
final RelativeLayout advancedOptions = (RelativeLayout) view
|
|
||||||
.findViewById(R.id.advanced_options);
|
|
||||||
showAdvanced.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
|
||||||
boolean isChecked) {
|
|
||||||
if (isChecked) {
|
|
||||||
advancedOptions.setVisibility(View.VISIBLE);
|
|
||||||
usernameDesc.setText("Username");
|
|
||||||
usernameText.setVisibility(View.VISIBLE);
|
|
||||||
jidText.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
advancedOptions.setVisibility(View.GONE);
|
|
||||||
usernameDesc.setText("Jabber ID");
|
|
||||||
usernameText.setVisibility(View.GONE);
|
|
||||||
jidText.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final EditText password = (EditText) view
|
final EditText password = (EditText) view
|
||||||
.findViewById(R.id.account_password);
|
.findViewById(R.id.account_password);
|
||||||
|
@ -87,9 +61,12 @@ public class EditAccount extends DialogFragment {
|
||||||
registerAccount.setVisibility(View.GONE);
|
registerAccount.setVisibility(View.GONE);
|
||||||
jidText.setText(account.getJid());
|
jidText.setText(account.getJid());
|
||||||
password.setText(account.getPassword());
|
password.setText(account.getPassword());
|
||||||
usernameText.setText(account.getUsername());
|
|
||||||
serverText.setText(account.getServer());
|
|
||||||
okButtonDesc = "Edit";
|
okButtonDesc = "Edit";
|
||||||
|
if (account.isOptionSet(Account.OPTION_USETLS)) {
|
||||||
|
useTLS.setChecked(true);
|
||||||
|
} else {
|
||||||
|
useTLS.setChecked(false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
builder.setTitle("Add account");
|
builder.setTitle("Add account");
|
||||||
okButtonDesc = "Add";
|
okButtonDesc = "Add";
|
||||||
|
@ -102,7 +79,8 @@ public class EditAccount extends DialogFragment {
|
||||||
public void onCheckedChanged(CompoundButton buttonView,
|
public void onCheckedChanged(CompoundButton buttonView,
|
||||||
boolean isChecked) {
|
boolean isChecked) {
|
||||||
AlertDialog d = (AlertDialog) getDialog();
|
AlertDialog d = (AlertDialog) getDialog();
|
||||||
Button positiveButton = (Button) d.getButton(Dialog.BUTTON_POSITIVE);
|
Button positiveButton = (Button) d
|
||||||
|
.getButton(Dialog.BUTTON_POSITIVE);
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
positiveButton.setText("Register");
|
positiveButton.setText("Register");
|
||||||
passwordConfirm.setVisibility(View.VISIBLE);
|
passwordConfirm.setVisibility(View.VISIBLE);
|
||||||
|
@ -129,41 +107,31 @@ public class EditAccount extends DialogFragment {
|
||||||
positiveButton.setOnClickListener(new View.OnClickListener() {
|
positiveButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
boolean showAdvanced = ((CheckBox) d.findViewById(R.id.account_show_advanced)).isChecked();
|
|
||||||
EditText jidEdit = (EditText) d.findViewById(R.id.account_jid);
|
EditText jidEdit = (EditText) d.findViewById(R.id.account_jid);
|
||||||
String jid = jidEdit.getText().toString();
|
String jid = jidEdit.getText().toString();
|
||||||
EditText usernameEdit = (EditText) d.findViewById(R.id.account_username);
|
EditText passwordEdit = (EditText) d
|
||||||
String username = usernameEdit.getText().toString();
|
.findViewById(R.id.account_password);
|
||||||
EditText serverEdit = (EditText) d.findViewById(R.id.account_server);
|
|
||||||
String server = serverEdit.getText().toString();
|
|
||||||
EditText passwordEdit = (EditText) d.findViewById(R.id.account_password);
|
|
||||||
String password = passwordEdit.getText().toString();
|
String password = passwordEdit.getText().toString();
|
||||||
if (!showAdvanced) {
|
CheckBox useTLS = (CheckBox) d.findViewById(R.id.account_usetls);
|
||||||
if (Validator.isValidJid(jid)) {
|
String username;
|
||||||
String[] parts = jid.split("@");
|
String server;
|
||||||
username = parts[0];
|
if (Validator.isValidJid(jid)) {
|
||||||
server = parts[1];
|
String[] parts = jid.split("@");
|
||||||
} else {
|
username = parts[0];
|
||||||
jidEdit.setError("Invalid Jabber ID");
|
server = parts[1];
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (username.length()==0) {
|
jidEdit.setError("Invalid Jabber ID");
|
||||||
usernameEdit.setError("username is too short");
|
return;
|
||||||
return;
|
|
||||||
} else if (server.length()==0) {
|
|
||||||
serverEdit.setError("server is too short");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (account!=null) {
|
if (account != null) {
|
||||||
account.setPassword(password);
|
account.setPassword(password);
|
||||||
account.setUsername(username);
|
account.setUsername(username);
|
||||||
account.setServer(server);
|
account.setServer(server);
|
||||||
} else {
|
} else {
|
||||||
account = new Account(username, server, password);
|
account = new Account(username, server, password);
|
||||||
}
|
}
|
||||||
if (listener!=null) {
|
account.setOption(Account.OPTION_USETLS, useTLS.isChecked());
|
||||||
|
if (listener != null) {
|
||||||
listener.onAccountEdited(account);
|
listener.onAccountEdited(account);
|
||||||
d.dismiss();
|
d.dismiss();
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,9 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
account.setStatus(Account.STATUS_SERVER_NOT_FOUND);
|
account.setStatus(Account.STATUS_SERVER_NOT_FOUND);
|
||||||
|
if (statusListener!=null) {
|
||||||
|
statusListener.onStatusChanged(account);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (shouldConnect) {
|
if (shouldConnect) {
|
||||||
|
|
Loading…
Reference in New Issue