DeepL: format usage

pull/199/head
M66B 3 years ago
parent 2e04662f36
commit 50f7dac456

@ -127,7 +127,6 @@ public class DeepL {
} }
} }
private static String getBaseUri(Context context) { private static String getBaseUri(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String domain = prefs.getString("deepl_domain", "api-free.deepl.com"); String domain = prefs.getString("deepl_domain", "api-free.deepl.com");

@ -100,7 +100,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.view.menu.MenuBuilder;
import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.PopupMenu;
import androidx.appcompat.widget.SwitchCompat; import androidx.appcompat.widget.SwitchCompat;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
@ -6784,7 +6783,8 @@ public class FragmentCompose extends FragmentBase {
tvUsage.setVisibility(View.GONE); tvUsage.setVisibility(View.GONE);
if (!TextUtils.isEmpty(key)) { if (!TextUtils.isEmpty(key) &&
(domain == null || domain.equals("api-free.deepl.com"))) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString("key", key); args.putString("key", key);
@ -6796,9 +6796,10 @@ public class FragmentCompose extends FragmentBase {
@Override @Override
protected void onExecuted(Bundle args, Integer[] usage) { protected void onExecuted(Bundle args, Integer[] usage) {
tvUsage.setText( tvUsage.setText(getString(R.string.title_translate_usage,
Helper.humanReadableByteCount(usage[0]) + "/" + Helper.humanReadableByteCount(usage[0]),
Helper.humanReadableByteCount(usage[1])); Helper.humanReadableByteCount(usage[1]),
Math.round(100f * usage[0] / usage[1])));
tvUsage.setVisibility(View.VISIBLE); tvUsage.setVisibility(View.VISIBLE);
} }

@ -1112,6 +1112,7 @@
<string name="title_translate_key">Enter key</string> <string name="title_translate_key">Enter key</string>
<string name="title_translating">Translating &#8230;</string> <string name="title_translating">Translating &#8230;</string>
<string name="title_translate_small">Use a small font for the source text</string> <string name="title_translate_small">Use a small font for the source text</string>
<string name="title_translate_usage">Usage: %1$s / %2$s (%3$d %%)</string>
<string name="title_edit_plain_text">Edit as plain text</string> <string name="title_edit_plain_text">Edit as plain text</string>
<string name="title_edit_formatted_text">Edit as reformatted text</string> <string name="title_edit_formatted_text">Edit as reformatted text</string>
<string name="title_select_certificate">Select public key</string> <string name="title_select_certificate">Select public key</string>

Loading…
Cancel
Save