VirusTotal: use text input layout for API key

This commit is contained in:
M66B 2022-11-06 10:02:21 +01:00
parent 4dd3d19439
commit 6982b635ae
2 changed files with 20 additions and 12 deletions

View File

@ -135,7 +135,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private ImageButton ibDeepL;
private SwitchCompat swVirusTotal;
private TextView tvVirusTotalPrivacy;
private EditText etVirusTotal;
private TextInputLayout tilVirusTotal;
private ImageButton ibVirusTotal;
private SwitchCompat swSend;
private EditText etSend;
@ -352,7 +352,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
ibDeepL = view.findViewById(R.id.ibDeepL);
swVirusTotal = view.findViewById(R.id.swVirusTotal);
tvVirusTotalPrivacy = view.findViewById(R.id.tvVirusTotalPrivacy);
etVirusTotal = view.findViewById(R.id.etVirusTotal);
tilVirusTotal = view.findViewById(R.id.tilVirusTotal);
ibVirusTotal = view.findViewById(R.id.ibVirusTotal);
swSend = view.findViewById(R.id.swSend);
etSend = view.findViewById(R.id.etSend);
@ -791,7 +791,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
etVirusTotal.addTextChangedListener(new TextWatcher() {
tilVirusTotal.getEditText().addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// Do nothing
@ -2140,7 +2140,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tilLanguageToolKey.getEditText().setText(prefs.getString("lt_key", null));
swDeepL.setChecked(prefs.getBoolean("deepl_enabled", false));
swVirusTotal.setChecked(prefs.getBoolean("vt_enabled", false));
etVirusTotal.setText(prefs.getString("vt_apikey", null));
tilVirusTotal.getEditText().setText(prefs.getString("vt_apikey", null));
swSend.setChecked(prefs.getBoolean("send_enabled", false));
etSend.setText(prefs.getString("send_host", null));
swUpdates.setChecked(prefs.getBoolean("updates", true));

View File

@ -500,17 +500,25 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swVirusTotal" />
<EditText
android:id="@+id/etVirusTotal"
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilVirusTotal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:hint="API key"
android:inputType="text"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:endIconMode="password_toggle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvVirusTotalPrivacy" />
app:layout_constraintTop_toBottomOf="@+id/tvVirusTotalPrivacy">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="password"
android:hint="API key"
android:inputType="textPassword"
android:textAppearance="@style/TextAppearance.AppCompat.Small" />
</com.google.android.material.textfield.TextInputLayout>
<ImageButton
android:id="@+id/ibVirusTotal"
@ -520,7 +528,7 @@
android:contentDescription="@string/title_info"
android:tooltipText="@string/title_info"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etVirusTotal"
app:layout_constraintTop_toBottomOf="@id/tilVirusTotal"
app:srcCompat="@drawable/twotone_info_24" />
<androidx.appcompat.widget.SwitchCompat
@ -758,7 +766,7 @@
android:id="@+id/grpVirusTotal"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="swVirusTotal,tvVirusTotalPrivacy,ibVirusTotal,etVirusTotal" />
app:constraint_referenced_ids="swVirusTotal,tvVirusTotalPrivacy,ibVirusTotal,tilVirusTotal" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpSend"