improve welcome screens
This commit is contained in:
parent
53f8384412
commit
da896e202d
6 changed files with 50 additions and 19 deletions
|
@ -41,7 +41,6 @@ import org.openintents.openpgp.util.OpenPgpUtils;
|
|||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
@ -55,7 +54,6 @@ import de.pixart.messenger.databinding.DialogPresenceBinding;
|
|||
import de.pixart.messenger.entities.Account;
|
||||
import de.pixart.messenger.entities.Presence;
|
||||
import de.pixart.messenger.entities.PresenceTemplate;
|
||||
import de.pixart.messenger.entities.ServiceDiscoveryResult;
|
||||
import de.pixart.messenger.services.BarcodeProvider;
|
||||
import de.pixart.messenger.services.QuickConversationsService;
|
||||
import de.pixart.messenger.services.XmppConnectionService;
|
||||
|
@ -68,7 +66,6 @@ import de.pixart.messenger.ui.util.PendingItem;
|
|||
import de.pixart.messenger.ui.util.SoftKeyboardUtils;
|
||||
import de.pixart.messenger.utils.CryptoHelper;
|
||||
import de.pixart.messenger.utils.MenuDoubleTabUtil;
|
||||
import de.pixart.messenger.utils.Namespace;
|
||||
import de.pixart.messenger.utils.Resolver;
|
||||
import de.pixart.messenger.utils.SignupUtils;
|
||||
import de.pixart.messenger.utils.TorServiceUtils;
|
||||
|
@ -103,6 +100,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
|||
private boolean mInitMode = false;
|
||||
private boolean mUsernameMode = Config.DOMAIN_LOCK != null;
|
||||
private boolean mShowOptions = false;
|
||||
private boolean useOwnProvider = false;
|
||||
private Account mAccount;
|
||||
private String messageFingerprint;
|
||||
|
||||
|
@ -731,6 +729,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
|||
}
|
||||
}
|
||||
boolean init = intent.getBooleanExtra("init", false);
|
||||
boolean existing = intent.getBooleanExtra("existing", false);
|
||||
useOwnProvider = intent.getBooleanExtra("useownprovider", false);
|
||||
boolean openedFromNotification = intent.getBooleanExtra(EXTRA_OPENED_FROM_NOTIFICATION, false);
|
||||
this.mInitMode = init || this.jidToEdit == null;
|
||||
this.messageFingerprint = intent.getStringExtra("fingerprint");
|
||||
|
@ -742,7 +742,13 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
|||
this.binding.yourNameBox.setVisibility(View.GONE);
|
||||
this.binding.avater.setVisibility(View.GONE);
|
||||
configureActionBar(getSupportActionBar(), !(init && Config.MAGIC_CREATE_DOMAIN == null));
|
||||
setTitle(R.string.action_add_account);
|
||||
if (existing) {
|
||||
setTitle(R.string.action_add_existing_account);
|
||||
this.binding.accountRegisterNew.setVisibility(View.GONE);
|
||||
} else {
|
||||
setTitle(R.string.action_add_new_account);
|
||||
this.binding.accountRegisterNew.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
SharedPreferences preferences = getPreferences();
|
||||
|
@ -793,7 +799,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
|||
xmppConnectionService.reconnectAccountInBackground(mAccount);
|
||||
}
|
||||
this.mInitMode |= this.mAccount.isOptionSet(Account.OPTION_REGISTER);
|
||||
this.mUsernameMode |= mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) && mAccount.isOptionSet(Account.OPTION_REGISTER);
|
||||
this.mUsernameMode |= mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) && mAccount.isOptionSet(Account.OPTION_REGISTER) && !useOwnProvider;
|
||||
if (this.mAccount.getPrivateKeyAlias() != null) {
|
||||
binding.accountPassword.setHint(R.string.authenticate_with_certificate);
|
||||
if (this.mInitMode) {
|
||||
|
@ -1101,7 +1107,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
|||
if (this.mAccount.isOptionSet(Account.OPTION_REGISTER)) {
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setTitle(R.string.create_account);
|
||||
setTitle(R.string.action_add_new_account);
|
||||
}
|
||||
}
|
||||
this.binding.accountRegisterNew.setVisibility(View.GONE);
|
||||
|
|
|
@ -10,6 +10,8 @@ import android.view.View;
|
|||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
@ -25,11 +27,13 @@ import de.pixart.messenger.entities.Account;
|
|||
import de.pixart.messenger.utils.CryptoHelper;
|
||||
import rocks.xmpp.addr.Jid;
|
||||
|
||||
public class MagicCreateActivity extends XmppActivity implements TextWatcher, AdapterView.OnItemSelectedListener {
|
||||
public class MagicCreateActivity extends XmppActivity implements TextWatcher, AdapterView.OnItemSelectedListener, CompoundButton.OnCheckedChangeListener {
|
||||
|
||||
private TextView mFullJidDisplay;
|
||||
private EditText mUsername;
|
||||
private CheckBox mUseOwnProvider;
|
||||
private Spinner mServer;
|
||||
private boolean useOwnProvider = false;
|
||||
String domain = null;
|
||||
|
||||
@Override
|
||||
|
@ -66,16 +70,18 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher, Ad
|
|||
final ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_selectable_list_item, domains);
|
||||
int defaultServer = adapter.getPosition("blabber.im");
|
||||
mUsername = findViewById(R.id.username);
|
||||
mUseOwnProvider = findViewById(R.id.use_own);
|
||||
mUseOwnProvider.setOnCheckedChangeListener(this);
|
||||
mServer = findViewById(R.id.server);
|
||||
mServer.setAdapter(adapter);
|
||||
mServer.setSelection(defaultServer);
|
||||
mServer.setOnItemSelectedListener(this);
|
||||
adapter.setDropDownViewResource(android.R.layout.select_dialog_singlechoice);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
Button next = findViewById(R.id.create_account);
|
||||
next.setOnClickListener(v -> {
|
||||
try {
|
||||
String username = mUsername.getText().toString();
|
||||
if (domain == null) {
|
||||
if (domain == null || useOwnProvider) {
|
||||
domain = Config.MAGIC_CREATE_DOMAIN;
|
||||
}
|
||||
Jid jid = Jid.of(username.toLowerCase(), domain, null);
|
||||
|
@ -96,6 +102,8 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher, Ad
|
|||
Intent intent = new Intent(MagicCreateActivity.this, EditAccountActivity.class);
|
||||
intent.putExtra("jid", account.getJid().asBareJid().toString());
|
||||
intent.putExtra("init", true);
|
||||
intent.putExtra("existing", false);
|
||||
intent.putExtra("useownprovider", useOwnProvider);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
|
@ -170,4 +178,17 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher, Ad
|
|||
mFullJidDisplay.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (mUseOwnProvider.isChecked()) {
|
||||
mServer.setEnabled(false);
|
||||
mFullJidDisplay.setVisibility(View.GONE);
|
||||
useOwnProvider = true;
|
||||
} else {
|
||||
mServer.setEnabled(true);
|
||||
mFullJidDisplay.setVisibility(View.VISIBLE);
|
||||
useOwnProvider = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,14 +81,9 @@ public class WelcomeActivity extends XmppActivity {
|
|||
});
|
||||
final Button useExistingAccount = findViewById(R.id.use_existing_account);
|
||||
useExistingAccount.setOnClickListener(v -> {
|
||||
List<Account> accounts = xmppConnectionService.getAccounts();
|
||||
Intent intent = new Intent(WelcomeActivity.this, EditAccountActivity.class);
|
||||
if (accounts.size() == 1) {
|
||||
intent.putExtra("jid", accounts.get(0).getJid().asBareJid().toString());
|
||||
intent.putExtra("init", true);
|
||||
} else if (accounts.size() >= 1) {
|
||||
intent = new Intent(WelcomeActivity.this, ManageAccountActivity.class);
|
||||
}
|
||||
intent.putExtra("init", true);
|
||||
intent.putExtra("existing", true);
|
||||
addInviteUri(intent);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<include layout="@layout/toolbar" />
|
||||
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
@ -74,6 +74,12 @@
|
|||
android:prompt="@string/server_hint"
|
||||
android:spinnerMode="dialog" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/use_own"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/use_own_provider" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/full_jid"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -99,6 +105,7 @@
|
|||
android:layout_gravity="end"
|
||||
android:text="@string/next"
|
||||
android:textColor="?attr/colorAccent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<item
|
||||
android:id="@+id/action_add_account"
|
||||
android:icon="?attr/icon_add_person"
|
||||
android:title="@string/action_add_account"
|
||||
android:title="@string/action_add_new_account"
|
||||
app:showAsAction="always" />
|
||||
<item
|
||||
android:id="@+id/action_import_backup"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<string name="action_end_conversation">End this conversation</string>
|
||||
<string name="action_contact_details">Contact details</string>
|
||||
<string name="action_secure">Secure conversation</string>
|
||||
<string name="action_add_account">Add account</string>
|
||||
<string name="action_add_new_account">Add new account</string>
|
||||
<string name="action_edit_contact">Edit name</string>
|
||||
<string name="action_add_phone_book">Add to address book</string>
|
||||
<string name="action_delete_contact">Delete from roster</string>
|
||||
|
@ -908,4 +908,6 @@
|
|||
<string name="search_channels">Search channels</string>
|
||||
<string name="channel_discovery_opt_in_title">Privacy notice</string>
|
||||
<string name="channel_discover_opt_in_message"><![CDATA[Channel discovery uses a third party service called <a href="https://search.jabbercat.org">search.jabbercat.org</a>.<br><br>Using this feature will transmit your IP address and search terms to that service. See their <a href="https://search.jabbercat.org/privacy">Privacy Policy</a> for more information.]]></string>
|
||||
<string name="action_add_existing_account">Add existing account</string>
|
||||
<string name="use_own_provider">Use own provider</string>
|
||||
</resources>
|
||||
|
|
Reference in a new issue