Revert "Edit account name on reviewing account"

This reverts commit 114fe7e236.
pull/194/merge
M66B 3 years ago
parent a0cec9bbdb
commit d77c3301c6

@ -27,13 +27,9 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.annotation.NonNull;
@ -55,7 +51,7 @@ public class FragmentDialogAccount extends FragmentDialogBase {
final Context context = getContext();
final View dview = LayoutInflater.from(context).inflate(R.layout.dialog_review_account, null);
final EditText etName = dview.findViewById(R.id.etName);
final TextView tvName = dview.findViewById(R.id.tvName);
final TextView tvInbox = dview.findViewById(R.id.tvInbox);
final TextView tvDrafts = dview.findViewById(R.id.tvDrafts);
final TextView tvSent = dview.findViewById(R.id.tvSent);
@ -81,8 +77,7 @@ public class FragmentDialogAccount extends FragmentDialogBase {
tvJunk.setCompoundDrawablesRelative(null, null, null, null);
tvArchive.setCompoundDrawablesRelative(null, null, null, null);
etName.setText(null);
etName.setEnabled(false);
tvName.setText(null);
tvLeft.setText(null);
tvRight.setText(null);
@ -92,52 +87,6 @@ public class FragmentDialogAccount extends FragmentDialogBase {
Bundle args = getArguments();
final long account = args.getLong("account");
Runnable update = new Runnable() {
@Override
public void run() {
try {
String tag = (String) etName.getTag();
String name = etName.getText().toString();
if (!TextUtils.isEmpty(name) && !name.equals(tag)) {
args.putString("name", name);
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) throws Throwable {
long id = args.getLong("account");
String name = args.getString("name");
DB db = DB.getInstance(context);
db.account().setAccountName(id, name);
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
// Ignored
}
}.execute(FragmentDialogAccount.this, args, "account:name");
}
} catch (Throwable ex) {
Log.e(ex);
}
}
};
etName.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
update.run();
dismiss();
return true;
}
return false;
}
});
btnAccount.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -166,11 +115,7 @@ public class FragmentDialogAccount extends FragmentDialogBase {
db.account().liveAccount(account).observe(this, new Observer<EntityAccount>() {
@Override
public void onChanged(EntityAccount account) {
if (!etName.isEnabled()) {
etName.setTag(account.name);
etName.setText(account.name);
etName.setEnabled(true);
}
tvName.setText(account.name);
btnGmail.setVisibility(
hasGmail && account.auth_type == AUTH_TYPE_GMAIL
? View.VISIBLE : View.GONE);
@ -234,7 +179,6 @@ public class FragmentDialogAccount extends FragmentDialogBase {
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
update.run();
sendResult(RESULT_OK);
}
})

@ -10,18 +10,14 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<eu.faircode.email.FixedEditText
android:id="@+id/etName"
android:layout_width="0dp"
<eu.faircode.email.FixedTextView
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableStart="@drawable/twotone_edit_24"
android:drawableStart="@drawable/twotone_account_circle_24"
android:drawablePadding="6dp"
android:imeOptions="actionDone"
android:inputType="text"
android:singleLine="true"
android:text="Name"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toEndOf="parent"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@ -34,7 +30,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/etName" />
app:layout_constraintTop_toBottomOf="@+id/tvName" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvInbox"

Loading…
Cancel
Save