help translations
This commit is contained in:
parent
4e5796ea3e
commit
c8c7e1546f
11 changed files with 1044 additions and 347 deletions
|
|
@ -3,12 +3,14 @@ package io.github.sspanak.tt9.preferences;
|
|||
import android.content.res.AssetManager;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import io.github.sspanak.tt9.ui.WebViewActivity;
|
||||
import io.github.sspanak.tt9.util.Logger;
|
||||
import io.github.sspanak.tt9.util.SystemSettings;
|
||||
|
||||
public class HelpActivity extends WebViewActivity {
|
||||
@Override
|
||||
|
|
@ -18,9 +20,8 @@ public class HelpActivity extends WebViewActivity {
|
|||
|
||||
@Override
|
||||
protected String getText() {
|
||||
AssetManager assets = getAssets();
|
||||
try {
|
||||
InputStream stream = assets.open("help.html");
|
||||
InputStream stream = getHelpFileStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String line;
|
||||
|
|
@ -29,8 +30,19 @@ public class HelpActivity extends WebViewActivity {
|
|||
}
|
||||
return builder.toString();
|
||||
} catch (Exception e) {
|
||||
Logger.e(getClass().getSimpleName(), "Failed opening the help.html file.");
|
||||
Logger.e(getClass().getSimpleName(), "Failed opening the help HTML document.");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private InputStream getHelpFileStream() throws IOException {
|
||||
AssetManager assets = getAssets();
|
||||
String systemLanguage = SystemSettings.getLocale().replaceFirst("_\\w+$", "");
|
||||
|
||||
try {
|
||||
return assets.open("help/help." + systemLanguage + ".html");
|
||||
} catch (IOException ignored) {
|
||||
return assets.open("help/help.en.html");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ public class MainSettingsScreen extends BaseScreenFragment {
|
|||
public void onCreate() {
|
||||
createSettingsSection();
|
||||
createAboutSection();
|
||||
updateHelpButtonDescription();
|
||||
resetFontSize(false);
|
||||
}
|
||||
|
||||
|
|
@ -51,6 +52,18 @@ public class MainSettingsScreen extends BaseScreenFragment {
|
|||
}
|
||||
|
||||
|
||||
private void updateHelpButtonDescription() {
|
||||
Preference help = findPreference("screen_help");
|
||||
if (help == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String systemLanguage = SystemSettings.getLocale().replaceAll("_\\w+$", "");
|
||||
boolean missingLanguage = !systemLanguage.equals("en") && !systemLanguage.equals("es") && !systemLanguage.equals("ru");
|
||||
help.setSummary(missingLanguage ? "English only" : "");
|
||||
}
|
||||
|
||||
|
||||
private void createSettingsSection() {
|
||||
boolean isTT9On = SystemSettings.isTT9Enabled(activity);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import android.provider.Settings;
|
|||
import android.view.inputmethod.InputMethodInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
|
@ -41,6 +42,7 @@ public class SystemSettings {
|
|||
return false;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static String getLocale() {
|
||||
Locale locale = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? LocaleList.getDefault().get(0) : Locale.getDefault();
|
||||
String country = locale.getCountry();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
<Preference
|
||||
app:key="screen_help"
|
||||
app:summary="English only"
|
||||
app:title="@string/pref_help">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue