changed spacing in create dialogs and notify user when no accounts are activated
This commit is contained in:
parent
3ff40a9733
commit
77c0fb0b2a
|
@ -19,8 +19,8 @@ import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
|
|
||||||
public class EnterJidDialog {
|
public class EnterJidDialog {
|
||||||
public static interface OnEnterJidDialogPositiveListener {
|
public interface OnEnterJidDialogPositiveListener {
|
||||||
public boolean onEnterJidDialogPositive(Jid account, Jid contact) throws EnterJidDialog.JidError;
|
boolean onEnterJidDialogPositive(Jid account, Jid contact) throws EnterJidDialog.JidError;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class JidError extends Exception {
|
public static class JidError extends Exception {
|
||||||
|
@ -40,7 +40,7 @@ public class EnterJidDialog {
|
||||||
protected OnEnterJidDialogPositiveListener listener = null;
|
protected OnEnterJidDialogPositiveListener listener = null;
|
||||||
|
|
||||||
public EnterJidDialog(
|
public EnterJidDialog(
|
||||||
final Context context, List<String> knownHosts, List<String> activatedAccounts,
|
final Context context, List<String> knownHosts, final List<String> activatedAccounts,
|
||||||
final String title, final String positiveButton,
|
final String title, final String positiveButton,
|
||||||
final String prefilledJid, final String account, boolean allowEditJid
|
final String prefilledJid, final String account, boolean allowEditJid
|
||||||
) {
|
) {
|
||||||
|
@ -60,17 +60,17 @@ public class EnterJidDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayAdapter<String> adapter;
|
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
adapter = new ArrayAdapter<>(context,
|
StartConversationActivity.populateAccountSpinner(context, activatedAccounts, spinner);
|
||||||
android.R.layout.simple_spinner_item, activatedAccounts);
|
|
||||||
} else {
|
} else {
|
||||||
adapter = new ArrayAdapter<>(context,
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(context,
|
||||||
android.R.layout.simple_spinner_item, new String[] { account });
|
android.R.layout.simple_spinner_item,
|
||||||
|
new String[] { account });
|
||||||
spinner.setEnabled(false);
|
spinner.setEnabled(false);
|
||||||
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
spinner.setAdapter(adapter);
|
||||||
}
|
}
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
|
||||||
spinner.setAdapter(adapter);
|
|
||||||
|
|
||||||
builder.setView(dialogView);
|
builder.setView(dialogView);
|
||||||
builder.setNegativeButton(R.string.cancel, null);
|
builder.setNegativeButton(R.string.cancel, null);
|
||||||
|
@ -81,6 +81,9 @@ public class EnterJidDialog {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(final View v) {
|
public void onClick(final View v) {
|
||||||
final Jid accountJid;
|
final Jid accountJid;
|
||||||
|
if (!spinner.isEnabled() && account == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (Config.DOMAIN_LOCK != null) {
|
if (Config.DOMAIN_LOCK != null) {
|
||||||
accountJid = Jid.fromParts((String) spinner.getSelectedItem(), Config.DOMAIN_LOCK, null);
|
accountJid = Jid.fromParts((String) spinner.getSelectedItem(), Config.DOMAIN_LOCK, null);
|
||||||
|
|
|
@ -393,7 +393,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
if (prefilledJid != null) {
|
if (prefilledJid != null) {
|
||||||
jid.append(prefilledJid);
|
jid.append(prefilledJid);
|
||||||
}
|
}
|
||||||
populateAccountSpinner(spinner);
|
populateAccountSpinner(this, mActivatedAccounts, spinner);
|
||||||
final Checkable bookmarkCheckBox = (CheckBox) dialogView
|
final Checkable bookmarkCheckBox = (CheckBox) dialogView
|
||||||
.findViewById(R.id.bookmark);
|
.findViewById(R.id.bookmark);
|
||||||
builder.setView(dialogView);
|
builder.setView(dialogView);
|
||||||
|
@ -411,7 +411,6 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
}
|
}
|
||||||
final Account account = getSelectedAccount(spinner);
|
final Account account = getSelectedAccount(spinner);
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
dialog.dismiss();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Jid conferenceJid;
|
final Jid conferenceJid;
|
||||||
|
@ -459,6 +458,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
}
|
}
|
||||||
|
|
||||||
private Account getSelectedAccount(Spinner spinner) {
|
private Account getSelectedAccount(Spinner spinner) {
|
||||||
|
if (!spinner.isEnabled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
Jid jid;
|
Jid jid;
|
||||||
try {
|
try {
|
||||||
if (Config.DOMAIN_LOCK != null) {
|
if (Config.DOMAIN_LOCK != null) {
|
||||||
|
@ -479,11 +481,21 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
switchToConversation(conversation);
|
switchToConversation(conversation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateAccountSpinner(Spinner spinner) {
|
public static void populateAccountSpinner(Context context, List<String> accounts, Spinner spinner) {
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
|
if (accounts.size() > 0) {
|
||||||
android.R.layout.simple_spinner_item, mActivatedAccounts);
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(context,
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
android.R.layout.simple_spinner_item, accounts);
|
||||||
spinner.setAdapter(adapter);
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
spinner.setAdapter(adapter);
|
||||||
|
spinner.setEnabled(true);
|
||||||
|
} else {
|
||||||
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(context,
|
||||||
|
android.R.layout.simple_spinner_item,
|
||||||
|
Arrays.asList(new String[]{context.getString(R.string.no_accounts)}));
|
||||||
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
spinner.setAdapter(adapter);
|
||||||
|
spinner.setEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
android:id="@+id/jabber_id"
|
android:id="@+id/jabber_id"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="8dp"
|
||||||
android:text="@string/account_settings_jabber_id"
|
android:text="@string/account_settings_jabber_id"
|
||||||
android:textColor="@color/black87"
|
android:textColor="@color/black87"
|
||||||
android:textSize="?attr/TextSizeBody"/>
|
android:textSize="?attr/TextSizeBody"/>
|
||||||
|
@ -37,6 +37,7 @@
|
||||||
android:hint="@string/account_settings_example_jabber_id"
|
android:hint="@string/account_settings_example_jabber_id"
|
||||||
android:inputType="textEmailAddress"
|
android:inputType="textEmailAddress"
|
||||||
android:textColor="@color/black87"
|
android:textColor="@color/black87"
|
||||||
android:textColorHint="@color/black54"/>
|
android:textColorHint="@color/black54"
|
||||||
|
android:textSize="?attr/TextSizeBody" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -25,7 +25,7 @@
|
||||||
android:id="@+id/jabber_id"
|
android:id="@+id/jabber_id"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="8dp"
|
||||||
android:text="@string/conference_address"
|
android:text="@string/conference_address"
|
||||||
android:textColor="@color/black87"
|
android:textColor="@color/black87"
|
||||||
android:textSize="?attr/TextSizeBody" />
|
android:textSize="?attr/TextSizeBody" />
|
||||||
|
@ -37,14 +37,17 @@
|
||||||
android:hint="@string/conference_address_example"
|
android:hint="@string/conference_address_example"
|
||||||
android:inputType="textEmailAddress"
|
android:inputType="textEmailAddress"
|
||||||
android:textColor="@color/black87"
|
android:textColor="@color/black87"
|
||||||
android:textColorHint="@color/black54" />
|
android:textColorHint="@color/black54"
|
||||||
|
android:textSize="?attr/TextSizeBody"/>
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/bookmark"
|
android:id="@+id/bookmark"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="8dp"
|
||||||
android:checked="true"
|
android:checked="true"
|
||||||
android:text="@string/save_as_bookmark" />
|
android:text="@string/save_as_bookmark"
|
||||||
|
android:textColor="@color/black87"
|
||||||
|
android:textSize="?attr/TextSizeBody"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -580,4 +580,5 @@
|
||||||
<string name="battery_optimizations_enabled_dialog">Your device is doing some heavy battery optimizations on Conversations that might lead to delayed notifications or even message loss.\n\nYou will now be asked to disable those.</string>
|
<string name="battery_optimizations_enabled_dialog">Your device is doing some heavy battery optimizations on Conversations that might lead to delayed notifications or even message loss.\n\nYou will now be asked to disable those.</string>
|
||||||
<string name="disable">Disable</string>
|
<string name="disable">Disable</string>
|
||||||
<string name="selection_too_large">The selected area is too large</string>
|
<string name="selection_too_large">The selected area is too large</string>
|
||||||
|
<string name="no_accounts">(No activated accounts)</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue