mirror of https://github.com/M66B/FairEmail.git
DeepL: enter auth key
This commit is contained in:
parent
8190f0348d
commit
88bf6840ce
|
@ -1939,8 +1939,8 @@ public class FragmentCompose extends FragmentBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onMenuTranslateKey() {
|
private void onMenuTranslateKey() {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
FragmentDialogDeepL fragment = new FragmentDialogDeepL();
|
||||||
prefs.edit().putString("deepl", "").apply();
|
fragment.show(getParentFragmentManager(), "deepl");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onMenuTranslate(String target) {
|
private void onMenuTranslate(String target) {
|
||||||
|
@ -6683,6 +6683,35 @@ public class FragmentCompose extends FragmentBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class FragmentDialogDeepL extends FragmentDialogBase {
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
final Context context = getContext();
|
||||||
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
|
||||||
|
View view = LayoutInflater.from(context).inflate(R.layout.dialog_deepl, null);
|
||||||
|
final EditText etKey = view.findViewById(R.id.etKey);
|
||||||
|
etKey.setText(prefs.getString("deepl", null));
|
||||||
|
|
||||||
|
return new AlertDialog.Builder(context)
|
||||||
|
.setView(view)
|
||||||
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
String key = etKey.getText().toString().trim();
|
||||||
|
if (TextUtils.isEmpty(key))
|
||||||
|
prefs.edit().remove("deepl").apply();
|
||||||
|
else
|
||||||
|
prefs.edit().putString("deepl", key).apply();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static UriInfo getInfo(Uri uri, Context context) {
|
private static UriInfo getInfo(Uri uri, Context context) {
|
||||||
UriInfo result = new UriInfo();
|
UriInfo result = new UriInfo();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="24dp">
|
||||||
|
|
||||||
|
<eu.faircode.email.FixedTextView
|
||||||
|
android:id="@+id/tvDeepL"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:labelFor="@+id/etKey"
|
||||||
|
android:text="DeepL"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<eu.faircode.email.EditTextPlain
|
||||||
|
android:id="@+id/etKey"
|
||||||
|
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.Medium"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tvDeepL">
|
||||||
|
|
||||||
|
<requestFocus />
|
||||||
|
</eu.faircode.email.EditTextPlain>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -1108,7 +1108,7 @@
|
||||||
<string name="title_insert_template">Insert template</string>
|
<string name="title_insert_template">Insert template</string>
|
||||||
<string name="title_create_template">Create template</string>
|
<string name="title_create_template">Create template</string>
|
||||||
<string name="title_translate" translatable="false">Translate</string>
|
<string name="title_translate" translatable="false">Translate</string>
|
||||||
<string name="title_translate_key" translatable="false">Set key</string>
|
<string name="title_translate_key" translatable="false">Enter auth key</string>
|
||||||
<string name="title_translate_english" translatable="false">English</string>
|
<string name="title_translate_english" translatable="false">English</string>
|
||||||
<string name="title_translate_french" translatable="false">French</string>
|
<string name="title_translate_french" translatable="false">French</string>
|
||||||
<string name="title_translate_german" translatable="false">German</string>
|
<string name="title_translate_german" translatable="false">German</string>
|
||||||
|
|
Loading…
Reference in New Issue