Enable auto fill for 2fa password

close #71
This commit is contained in:
NekoInverter 2020-04-05 14:24:22 +08:00
parent f211fc8450
commit 0288ef7831
No known key found for this signature in database
GPG Key ID: 280D6CCCF95715F9
3 changed files with 29 additions and 2 deletions

View File

@ -118,6 +118,7 @@ import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import tw.nekomimi.nekogram.EditTextAutoFill;
import tw.nekomimi.nekogram.NekoConfig;
@SuppressLint("HardwareIds")
@ -2884,7 +2885,7 @@ public class LoginActivity extends BaseFragment {
confirmTextView.setText(LocaleController.getString("LoginPasswordText", R.string.LoginPasswordText));
addView(confirmTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
codeField = new EditTextBoldCursor(context);
codeField = new EditTextAutoFill(context);
codeField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
codeField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
codeField.setCursorSize(AndroidUtilities.dp(20));

View File

@ -70,6 +70,8 @@ import java.math.BigInteger;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import tw.nekomimi.nekogram.EditTextAutoFill;
public class TwoStepVerificationActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
private ListAdapter listAdapter;
@ -225,7 +227,7 @@ public class TwoStepVerificationActivity extends BaseFragment implements Notific
titleTextView.setPadding(AndroidUtilities.dp(40), 0, AndroidUtilities.dp(40), 0);
linearLayout.addView(titleTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 0, 38, 0, 0));
passwordEditText = new EditTextBoldCursor(context);
passwordEditText = new EditTextAutoFill(context);
passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
passwordEditText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
passwordEditText.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));

View File

@ -0,0 +1,24 @@
package tw.nekomimi.nekogram;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.view.View;
import org.telegram.ui.Components.EditTextBoldCursor;
public class EditTextAutoFill extends EditTextBoldCursor {
public EditTextAutoFill(Context context) {
super(context);
if (Build.VERSION.SDK_INT >= 26) {
setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_YES);
setAutofillHints(View.AUTOFILL_HINT_PASSWORD);
}
}
@TargetApi(Build.VERSION_CODES.O)
@Override
public int getAutofillType() {
return AUTOFILL_TYPE_TEXT;
}
}