Small improvements

This commit is contained in:
M66B 2019-01-02 08:37:21 +01:00
parent cf6ee7630f
commit ca79bfc990
3 changed files with 50 additions and 3 deletions

View File

@ -1138,6 +1138,7 @@ public class FragmentAccount extends FragmentEx {
Log.i("Accounts=" + accounts.length);
for (final Account account : accounts)
if (name.equals(account.name)) {
btnAuthorize.setEnabled(false);
final Snackbar snackbar = Snackbar.make(view, R.string.title_authorizing, Snackbar.LENGTH_SHORT);
snackbar.show();
@ -1157,15 +1158,17 @@ public class FragmentAccount extends FragmentEx {
authorized = token;
etUser.setText(account.name);
tilPassword.getEditText().setText(token);
} catch (Throwable ex) {
Log.e(ex);
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
} finally {
btnAuthorize.setEnabled(true);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
snackbar.dismiss();
}
}, 1000);
} catch (Throwable ex) {
Log.e(ex);
snackbar.setText(Helper.formatThrowable(ex));
}
}
},

View File

@ -38,11 +38,14 @@ import android.net.ConnectivityManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.text.Editable;
import android.text.Html;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.method.LinkMovementMethod;
import android.util.Patterns;
import android.view.LayoutInflater;
@ -215,6 +218,24 @@ public class FragmentSetup extends FragmentEx {
}
});
TextWatcher credentialsWatcher = 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) {
auth_type = Helper.AUTH_TYPE_PASSWORD;
}
@Override
public void afterTextChanged(Editable s) {
}
};
etEmail.addTextChangedListener(credentialsWatcher);
tilPassword.getEditText().addTextChangedListener(credentialsWatcher);
tilPassword.setHintEnabled(false);
btnQuick.setOnClickListener(new View.OnClickListener() {
@ -833,6 +854,10 @@ public class FragmentSetup extends FragmentEx {
Log.i("Accounts=" + accounts.length);
for (final Account account : accounts)
if (name.equals(account.name)) {
btnAuthorize.setEnabled(false);
final Snackbar snackbar = Snackbar.make(view, R.string.title_authorizing, Snackbar.LENGTH_SHORT);
snackbar.show();
am.getAuthToken(
account,
Helper.getAuthTokenType(type),
@ -852,6 +877,14 @@ public class FragmentSetup extends FragmentEx {
} catch (Throwable ex) {
Log.e(ex);
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
} finally {
btnAuthorize.setEnabled(true);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
snackbar.dismiss();
}
}, 1000);
}
}
},

View File

@ -45,6 +45,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etName" />
<TextView
android:id="@+id/tvAuthorizeRemark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:text="@string/title_optional"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintBottom_toBottomOf="@id/btnAuthorize"
app:layout_constraintStart_toEndOf="@id/btnAuthorize"
app:layout_constraintTop_toTopOf="@id/btnAuthorize" />
<EditText
android:id="@+id/etEmail"
android:layout_width="match_parent"