diff --git a/createRawResources.py b/createRawResources.py
index 44248914e..7fb8be4ab 100755
--- a/createRawResources.py
+++ b/createRawResources.py
@@ -7,6 +7,7 @@ drawable_res_dir = "res/drawable"
tree_icons_dir = "icons/tree"
menu_icons_dir = "icons/menu"
tabs_icons_dir = "icons/tabs"
+others_icons_dir = "icons/others"
text_search_icons_dir = "icons/text_search"
data_dir = "data"
@@ -35,4 +36,5 @@ shutil.copyfile("icons/fbreader.png", drawable_res_dir + "/fbreader.png")
process_data_dir("", tree_icons_dir, drawable_res_dir, 0)
process_data_dir("", menu_icons_dir, drawable_res_dir, 0)
process_data_dir("", tabs_icons_dir, drawable_res_dir, 0)
+process_data_dir("", others_icons_dir, drawable_res_dir, 0)
process_data_dir("text_search_", text_search_icons_dir, drawable_res_dir, 0)
diff --git a/icons/others/dropdown.xml b/icons/others/dropdown.xml
new file mode 100644
index 000000000..e5a7b68a0
--- /dev/null
+++ b/icons/others/dropdown.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/icons/others/dropdown_normal.png b/icons/others/dropdown_normal.png
new file mode 100644
index 000000000..73bbbccbc
Binary files /dev/null and b/icons/others/dropdown_normal.png differ
diff --git a/icons/others/dropdown_pressed.png b/icons/others/dropdown_pressed.png
new file mode 100644
index 000000000..c5897fa9d
Binary files /dev/null and b/icons/others/dropdown_pressed.png differ
diff --git a/icons/others/dropdown_selected.png b/icons/others/dropdown_selected.png
new file mode 100644
index 000000000..aeb1fe18d
Binary files /dev/null and b/icons/others/dropdown_selected.png differ
diff --git a/res/layout/network_register_user_dialog.xml b/res/layout/network_register_user_dialog.xml
index dbe40c10b..852d324fd 100644
--- a/res/layout/network_register_user_dialog.xml
+++ b/res/layout/network_register_user_dialog.xml
@@ -58,13 +58,28 @@
android:singleLine="true"
android:layout_marginTop="5dp"
/>
-
+ >
+
+
+
mySystemEmails = new ArrayList();
+
public RegisterUserDialog() {
super("RegisterUserDialog");
}
@Override
protected void clearData() {
- myLogin = myPassword = myEmail = null;
+ myLogin = myPassword = myConfirmPassword = myEmail = null;
}
@Override
@@ -59,6 +69,46 @@ class RegisterUserDialog extends NetworkDialog {
((TextView) layout.findViewById(R.id.network_register_confirm_password_text)).setText(myResource.getResource("confirmPassword").getValue());
((TextView) layout.findViewById(R.id.network_register_email_text)).setText(myResource.getResource("email").getValue());
+ mySystemEmails.clear();
+ collectEMails(myActivity.getApplicationContext(), mySystemEmails);
+
+ if (!mySystemEmails.isEmpty()) {
+ final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ if (which >= 0 && which < mySystemEmails.size()) {
+ myEmail = mySystemEmails.get(which);
+ }
+ dialog.dismiss();
+ }
+ };
+
+ ((Button) layout.findViewById(R.id.network_register_email_button)).setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ myLogin = ((TextView) layout.findViewById(R.id.network_register_login)).getText().toString().trim();
+ myPassword = ((TextView) layout.findViewById(R.id.network_register_password)).getText().toString();
+ myConfirmPassword = ((TextView) layout.findViewById(R.id.network_register_confirm_password)).getText().toString();
+ myEmail = ((TextView) layout.findViewById(R.id.network_register_email)).getText().toString().trim();
+
+ final int selected = mySystemEmails.indexOf(myEmail);
+ final ZLResource buttonResource = ZLResource.resource("dialog").getResource("button");
+ final AlertDialog dialog = new AlertDialog.Builder(myActivity)
+ .setSingleChoiceItems(mySystemEmails.toArray(new String[mySystemEmails.size()]), selected, listener)
+ .setTitle(myResource.getResource("email").getValue())
+ .setNegativeButton(buttonResource.getResource("cancel").getValue(), null)
+ .create();
+
+ dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
+ public void onDismiss(DialogInterface dialog) {
+ myActivity.showDialog(myId);
+ }
+ });
+
+ myActivity.dismissDialog(myId);
+ dialog.show();
+ }
+ });
+ }
+
return layout;
}
@@ -67,7 +117,7 @@ class RegisterUserDialog extends NetworkDialog {
AlertDialog alert = (AlertDialog) dialog;
myLogin = ((TextView) alert.findViewById(R.id.network_register_login)).getText().toString().trim();
myPassword = ((TextView) alert.findViewById(R.id.network_register_password)).getText().toString();
- final String confirmPassword = ((TextView) alert.findViewById(R.id.network_register_confirm_password)).getText().toString();
+ myConfirmPassword = ((TextView) alert.findViewById(R.id.network_register_confirm_password)).getText().toString();
myEmail = ((TextView) alert.findViewById(R.id.network_register_email)).getText().toString().trim();
if (myLogin.length() == 0) {
@@ -76,9 +126,10 @@ class RegisterUserDialog extends NetworkDialog {
sendError(true, false, err);
return;
}
- if (!myPassword.equals(confirmPassword)) {
+ if (!myPassword.equals(myConfirmPassword)) {
final String err = myResource.getResource("differentPasswords").getValue();
myPassword = null;
+ myConfirmPassword = null;
sendError(true, false, err);
return;
}
@@ -123,11 +174,16 @@ class RegisterUserDialog extends NetworkDialog {
}
@Override
- public void prepareDialog(Dialog dialog) {
- ((TextView) dialog.findViewById(R.id.network_register_login)).setText((myLogin != null) ? myLogin : "");
- ((TextView) dialog.findViewById(R.id.network_register_password)).setText((myPassword != null) ? myPassword : "");
- ((TextView) dialog.findViewById(R.id.network_register_confirm_password)).setText((myPassword != null) ? myPassword : "");
- ((TextView) dialog.findViewById(R.id.network_register_email)).setText((myEmail != null) ? myEmail : "");
+ public void prepareDialogInternal(Dialog dialog) {
+ dialog.findViewById(R.id.network_register_email_button).setVisibility((mySystemEmails.size() > 1) ? View.VISIBLE : View.GONE);
+ if (mySystemEmails.size() == 1 && (myEmail == null || myEmail.length() == 0)) {
+ myEmail = mySystemEmails.get(0);
+ }
+
+ ((TextView) dialog.findViewById(R.id.network_register_login)).setText(myLogin);
+ ((TextView) dialog.findViewById(R.id.network_register_password)).setText(myPassword);
+ ((TextView) dialog.findViewById(R.id.network_register_confirm_password)).setText(myConfirmPassword);
+ ((TextView) dialog.findViewById(R.id.network_register_email)).setText(myEmail);
final TextView error = (TextView) dialog.findViewById(R.id.network_register_error);
if (myErrorMessage == null) {
@@ -142,4 +198,35 @@ class RegisterUserDialog extends NetworkDialog {
dlgView.invalidate();
dlgView.requestLayout();
}
+
+
+ private static void collectEMails(Context context, List emails) {
+ try {
+ final Class> cls$AccountManager = Class.forName("android.accounts.AccountManager");
+ final Class> cls$Account = Class.forName("android.accounts.Account");
+
+ final Method meth$AccountManager$get = cls$AccountManager.getMethod("get", Context.class);
+ final Method meth$AccountManager$getAccountsByType = cls$AccountManager.getMethod("getAccountsByType", String.class);
+ final Field fld$Account$name = cls$Account.getField("name");
+
+ if (meth$AccountManager$get.getReturnType() == cls$AccountManager
+ && meth$AccountManager$getAccountsByType.getReturnType().getComponentType() == cls$Account
+ && fld$Account$name.getType() == String.class) {
+ final Object mgr = meth$AccountManager$get.invoke(null, context);
+ final Object[] accountsByType = (Object[]) meth$AccountManager$getAccountsByType.invoke(mgr, "com.google");
+ for (Object a: accountsByType) {
+ final String value = (String) fld$Account$name.get(a);
+ if (value != null && value.length() > 0) {
+ emails.add(value);
+ }
+ }
+ }
+ } catch (ClassNotFoundException e) {
+ } catch (NoSuchMethodException e) {
+ } catch (NoSuchFieldException e) {
+ } catch (IllegalAccessException e) {
+ } catch (IllegalArgumentException e) {
+ } catch (InvocationTargetException e) {
+ }
+ }
}