mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #1254 from deltachat/enter-displayname
Enter displayname
This commit is contained in:
@@ -13,6 +13,18 @@
|
||||
android:layout_marginTop="20dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/login_success_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:gravity="start"
|
||||
android:text=""
|
||||
android:textSize="16sp"
|
||||
android:textColor="?android:attr/textColorPrimary" />
|
||||
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
@@ -41,6 +53,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/status_text_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
|
||||
@@ -14,10 +14,7 @@ import android.provider.MediaStore;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
@@ -63,7 +60,7 @@ public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
|
||||
private static final String TAG = CreateProfileActivity.class.getSimpleName();
|
||||
|
||||
public static final String NEXT_INTENT = "next_intent";
|
||||
public static final String FROM_WELCOME = "from_welcome";
|
||||
|
||||
private static final int REQUEST_CODE_AVATAR = 1;
|
||||
|
||||
@@ -76,9 +73,9 @@ public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
private EmojiDrawer emojiDrawer;
|
||||
private TextInputEditText statusView;
|
||||
private View reveal;
|
||||
private MenuItem finishMenuItem;
|
||||
|
||||
private Intent nextIntent;
|
||||
private boolean fromWelcome;
|
||||
|
||||
private byte[] avatarBytes;
|
||||
private File captureFile;
|
||||
|
||||
@@ -86,6 +83,7 @@ public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
this.fromWelcome = getIntent().getBooleanExtra(FROM_WELCOME, false);
|
||||
|
||||
dynamicTheme.onCreate(this);
|
||||
dynamicLanguage.onCreate(this);
|
||||
@@ -93,7 +91,7 @@ public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
setContentView(R.layout.profile_create_activity);
|
||||
|
||||
getSupportActionBar().setTitle(R.string.pref_profile_info_headline);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(!this.fromWelcome);
|
||||
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_close_white_24dp);
|
||||
|
||||
initializeResources();
|
||||
@@ -107,7 +105,6 @@ public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = this.getMenuInflater();
|
||||
inflater.inflate(R.menu.preferences_create_profile_menu, menu);
|
||||
finishMenuItem = menu.findItem(R.id.menu_create_profile);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -135,8 +132,14 @@ public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (container.isInputOpen()) container.hideCurrentInput(name);
|
||||
else super.onBackPressed();
|
||||
if (container.isInputOpen()) {
|
||||
container.hideCurrentInput(name);
|
||||
} else if (fromWelcome) {
|
||||
startActivity(new Intent(getApplicationContext(), ConversationListActivity.class));
|
||||
finish();
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -213,14 +216,13 @@ public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
|
||||
private void initializeResources() {
|
||||
TextView passwordAccountSettings = ViewUtil.findById(this, R.id.password_account_settings_button);
|
||||
|
||||
TextView loginSuccessText = ViewUtil.findById(this, R.id.login_success_text);
|
||||
this.avatar = ViewUtil.findById(this, R.id.avatar);
|
||||
this.name = ViewUtil.findById(this, R.id.name_text);
|
||||
this.emojiDrawer = ViewUtil.findById(this, R.id.emoji_drawer);
|
||||
this.container = ViewUtil.findById(this, R.id.container);
|
||||
this.reveal = ViewUtil.findById(this, R.id.reveal);
|
||||
this.statusView = ViewUtil.findById(this, R.id.status_text);
|
||||
this.nextIntent = getIntent().getParcelableExtra(NEXT_INTENT);
|
||||
this.statusView = ViewUtil.findById(this, R.id.status_text);
|
||||
|
||||
this.avatar.setImageDrawable(new ResourceContactPhoto(R.drawable.ic_camera_alt_white_24dp).asDrawable(this, getResources().getColor(R.color.grey_400)));
|
||||
|
||||
@@ -230,25 +232,23 @@ public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
.onAnyResult(this::handleAvatarSelectionWithPermissions)
|
||||
.execute());
|
||||
|
||||
this.name.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if(finishMenuItem != null){
|
||||
if (name.getError() != null || !finishMenuItem.isEnabled()) {
|
||||
name.setError(null);
|
||||
finishMenuItem.setEnabled(true);
|
||||
}
|
||||
}}
|
||||
});
|
||||
|
||||
passwordAccountSettings.setOnClickListener(view -> {
|
||||
Intent intent = new Intent(this, RegistrationActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
if (fromWelcome) {
|
||||
String addr = DcHelper.get(this, "addr");
|
||||
loginSuccessText.setText(String.format(
|
||||
"Login successfull - your email address is %1$s\n\n" +
|
||||
"If you like, you can now enter a name and an avatar image " +
|
||||
"that will be displayed to people you write to.", addr));
|
||||
ViewUtil.findById(this, R.id.status_text_layout).setVisibility(View.GONE);
|
||||
ViewUtil.findById(this, R.id.information_label).setVisibility(View.GONE);
|
||||
passwordAccountSettings.setVisibility(View.GONE);
|
||||
} else {
|
||||
loginSuccessText.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeProfileName() {
|
||||
@@ -393,7 +393,10 @@ public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
|
||||
if (result) {
|
||||
if (captureFile != null) captureFile.delete();
|
||||
handleFinishedLegacy();
|
||||
if (fromWelcome) {
|
||||
startActivity(new Intent(getApplicationContext(), ConversationListActivity.class));
|
||||
}
|
||||
finish();
|
||||
} else {
|
||||
Toast.makeText(CreateProfileActivity.this, R.string.error, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
@@ -405,9 +408,4 @@ public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
String newStatus = statusView.getText().toString().trim();
|
||||
DcHelper.set(this, DcHelper.CONFIG_SELF_STATUS, newStatus);
|
||||
}
|
||||
|
||||
private void handleFinishedLegacy() {
|
||||
if (nextIntent != null) startActivity(nextIntent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,11 +165,18 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
||||
progressDialog.setMessage(getResources().getString(R.string.one_moment)+String.format(" %d%%", percent));
|
||||
}
|
||||
|
||||
private void progressSuccess() {
|
||||
private void progressSuccess(boolean enterDisplayname) {
|
||||
dcContext.endCaptureNextError();
|
||||
progressDialog.dismiss();
|
||||
Intent conversationList = new Intent(getApplicationContext(), ConversationListActivity.class);
|
||||
startActivity(conversationList);
|
||||
|
||||
if (enterDisplayname) {
|
||||
Intent intent = new Intent(getApplicationContext(), CreateProfileActivity.class);
|
||||
intent.putExtra(CreateProfileActivity.FROM_WELCOME, true);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
startActivity(new Intent(getApplicationContext(), ConversationListActivity.class));
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -184,7 +191,7 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
||||
progressUpdate((int)progress);
|
||||
}
|
||||
else if (progress==1000/*done*/) {
|
||||
progressSuccess();
|
||||
progressSuccess(false);
|
||||
}
|
||||
}
|
||||
else if (manualConfigure && eventId==DcContext.DC_EVENT_CONFIGURE_PROGRESS) {
|
||||
@@ -202,7 +209,7 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
||||
progressUpdate((int)progress);
|
||||
}
|
||||
else if (progress==1000/*done*/) {
|
||||
progressSuccess();
|
||||
progressSuccess(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user