Use text input layout for DeepL API key

pull/210/head
M66B 2 years ago
parent e0011221cf
commit 0ce614f01b

@ -33,7 +33,6 @@ import android.text.style.RelativeSizeSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
@ -42,6 +41,8 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.PreferenceManager;
import com.google.android.material.textfield.TextInputLayout;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@ -354,7 +355,7 @@ public class DeepL {
View view = LayoutInflater.from(context).inflate(R.layout.dialog_deepl, null);
final ImageButton ibInfo = view.findViewById(R.id.ibInfo);
final EditText etKey = view.findViewById(R.id.etKey);
final TextInputLayout tilKey = view.findViewById(R.id.tilKey);
final CheckBox cbPro = view.findViewById(R.id.cbPro);
final CheckBox cbFormal = view.findViewById(R.id.cbFormal);
final TextView tvFormal = view.findViewById(R.id.tvFormal);
@ -385,7 +386,7 @@ public class DeepL {
}
});
etKey.setText(key);
tilKey.getEditText().setText(key);
cbPro.setChecked(pro);
cbFormal.setChecked(formal);
@ -455,7 +456,7 @@ public class DeepL {
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String key = etKey.getText().toString().trim();
String key = tilKey.getEditText().getText().toString().trim();
SharedPreferences.Editor editor = prefs.edit();
if (TextUtils.isEmpty(key))
editor.remove("deepl_key");

@ -37,21 +37,28 @@
app:srcCompat="@drawable/twotone_info_24"
app:tint="?attr/colorAccent" />
<eu.faircode.email.EditTextPlain
android:id="@+id/etKey"
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilKey"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:hint="@string/title_translate_key"
android:imeOptions="actionDone"
android:inputType="text"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:layout_marginTop="12dp"
app:endIconMode="password_toggle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDeepL">
app:layout_constraintTop_toBottomOf="@+id/tvDeepL">
<requestFocus />
</eu.faircode.email.EditTextPlain>
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="password"
android:hint="@string/title_translate_key"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:textAppearance="@style/TextAppearance.AppCompat.Medium">
<requestFocus />
</com.google.android.material.textfield.TextInputEditText>
</com.google.android.material.textfield.TextInputLayout>
<CheckBox
android:id="@+id/cbPro"
@ -60,7 +67,7 @@
android:layout_marginTop="12dp"
android:text="DeepL API Pro"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etKey" />
app:layout_constraintTop_toBottomOf="@id/tilKey" />
<CheckBox
android:id="@+id/cbFormal"
@ -128,10 +135,10 @@
android:layout_marginTop="24dp"
android:drawableEnd="@drawable/twotone_open_in_new_12"
android:drawablePadding="6dp"
app:drawableTint="?android:attr/textColorLink"
android:text="@string/title_privacy_policy"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
app:drawableTint="?android:attr/textColorLink"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvUsage" />
</androidx.constraintlayout.widget.ConstraintLayout>

Loading…
Cancel
Save