DeepL: format usage

This commit is contained in:
M66B 2021-05-21 07:38:56 +02:00
parent 2e04662f36
commit 50f7dac456
3 changed files with 7 additions and 6 deletions

View File

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

View File

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

View File

@ -1112,6 +1112,7 @@
<string name="title_translate_key">Enter key</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_usage">Usage: %1$s / %2$s (%3$d %%)</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_select_certificate">Select public key</string>