mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Show POEditor link if language is not fully translated
This commit is contained in:
@@ -23,10 +23,12 @@ import android.app.backup.BackupManager;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
|
import android.preference.PreferenceCategory;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
|
|
||||||
import org.isoron.uhabits.MainActivity;
|
import org.isoron.uhabits.MainActivity;
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
|
import org.isoron.uhabits.helpers.UIHelper;
|
||||||
|
|
||||||
public class SettingsFragment extends PreferenceFragment
|
public class SettingsFragment extends PreferenceFragment
|
||||||
implements SharedPreferences.OnSharedPreferenceChangeListener
|
implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||||
@@ -41,12 +43,22 @@ public class SettingsFragment extends PreferenceFragment
|
|||||||
setResultOnPreferenceClick("exportCSV", MainActivity.RESULT_EXPORT_CSV);
|
setResultOnPreferenceClick("exportCSV", MainActivity.RESULT_EXPORT_CSV);
|
||||||
setResultOnPreferenceClick("exportDB", MainActivity.RESULT_EXPORT_DB);
|
setResultOnPreferenceClick("exportDB", MainActivity.RESULT_EXPORT_DB);
|
||||||
setResultOnPreferenceClick("bugReport", MainActivity.RESULT_BUG_REPORT);
|
setResultOnPreferenceClick("bugReport", MainActivity.RESULT_BUG_REPORT);
|
||||||
|
|
||||||
|
if(UIHelper.isLocaleFullyTranslated())
|
||||||
|
removePreference("translate", "linksCategory");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removePreference(String preferenceKey, String categoryKey)
|
||||||
|
{
|
||||||
|
PreferenceCategory cat = (PreferenceCategory) findPreference(categoryKey);
|
||||||
|
Preference pref = findPreference(preferenceKey);
|
||||||
|
cat.removePreference(pref);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setResultOnPreferenceClick(String key, final int result)
|
private void setResultOnPreferenceClick(String key, final int result)
|
||||||
{
|
{
|
||||||
Preference exportCSV = findPreference(key);
|
Preference pref = findPreference(key);
|
||||||
exportCSV.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener()
|
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference)
|
public boolean onPreferenceClick(Preference preference)
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import android.os.Looper;
|
|||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
@@ -36,6 +37,8 @@ import android.view.inputmethod.InputMethodManager;
|
|||||||
import org.isoron.uhabits.BuildConfig;
|
import org.isoron.uhabits.BuildConfig;
|
||||||
import org.isoron.uhabits.commands.Command;
|
import org.isoron.uhabits.commands.Command;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public abstract class UIHelper
|
public abstract class UIHelper
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -146,4 +149,19 @@ public abstract class UIHelper
|
|||||||
{
|
{
|
||||||
Debug.stopMethodTracing();
|
Debug.stopMethodTracing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isLocaleFullyTranslated()
|
||||||
|
{
|
||||||
|
String fullyTranslatedLanguages[] = { "en", "ar", "cs", "de", "it", "ja", "ko", "po", "pl",
|
||||||
|
"pt", "ru", "sv", "zh" };
|
||||||
|
|
||||||
|
final String currentLanguage = Locale.getDefault().getLanguage();
|
||||||
|
|
||||||
|
Log.d("UIHelper", String.format("lang=%s", currentLanguage));
|
||||||
|
|
||||||
|
for(String lang : fullyTranslatedLanguages)
|
||||||
|
if(currentLanguage.equals(lang)) return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,4 +23,5 @@
|
|||||||
<string name="feedbackURL" formatted="false">mailto:dev@loophabits.org?subject=Feedback%20about%20Loop%20Habit%20Tracker</string>
|
<string name="feedbackURL" formatted="false">mailto:dev@loophabits.org?subject=Feedback%20about%20Loop%20Habit%20Tracker</string>
|
||||||
<string name="bugReportURL" formatted="false">mailto:dev@loophabits.org?subject=Bug%20Report%20-%20Loop%20Habit%20Tracker</string>
|
<string name="bugReportURL" formatted="false">mailto:dev@loophabits.org?subject=Bug%20Report%20-%20Loop%20Habit%20Tracker</string>
|
||||||
<string name="sourceCodeURL">https://github.com/iSoron/uhabits</string>
|
<string name="sourceCodeURL">https://github.com/iSoron/uhabits</string>
|
||||||
|
<string name="translateURL">https://poeditor.com/join/project/8DWX5pfjS0</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
<string name="pref_toggle_title">Toggle with short press</string>
|
<string name="pref_toggle_title">Toggle with short press</string>
|
||||||
<string name="pref_toggle_description">Put checkmarks with a single tap instead of press-and-hold. More convenient, but might cause accidental toggles.</string>
|
<string name="pref_toggle_description">Put checkmarks with a single tap instead of press-and-hold. More convenient, but might cause accidental toggles.</string>
|
||||||
<string name="pref_snooze_interval_title">Snooze interval on reminders</string>
|
<string name="pref_snooze_interval_title">Snooze interval on reminders</string>
|
||||||
<string name="pref_rate_this_app">Rate this app in Google Play</string>
|
<string name="pref_rate_this_app">Rate this app on Google Play</string>
|
||||||
<string name="pref_send_feedback">Send feedback to developer</string>
|
<string name="pref_send_feedback">Send feedback to developer</string>
|
||||||
<string name="pref_view_source_code">View source code at GitHub</string>
|
<string name="pref_view_source_code">View source code at GitHub</string>
|
||||||
<string name="pref_view_app_introduction">View app introduction</string>
|
<string name="pref_view_app_introduction">View app introduction</string>
|
||||||
@@ -155,4 +155,5 @@
|
|||||||
<string name="bug_report_failed">Failed to generate bug report.</string>
|
<string name="bug_report_failed">Failed to generate bug report.</string>
|
||||||
<string name="generate_bug_report">Generate bug report</string>
|
<string name="generate_bug_report">Generate bug report</string>
|
||||||
<string name="troubleshooting">Troubleshooting</string>
|
<string name="troubleshooting">Troubleshooting</string>
|
||||||
|
<string name="help_translate">Help translate this app</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="pref_key_behaviour_settings"
|
android:key="behaviorCategory"
|
||||||
android:title="@string/behavior">
|
android:title="@string/behavior">
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
@@ -36,13 +36,13 @@
|
|||||||
android:entries="@array/snooze_interval_names"
|
android:entries="@array/snooze_interval_names"
|
||||||
android:entryValues="@array/snooze_interval_values"
|
android:entryValues="@array/snooze_interval_values"
|
||||||
android:key="pref_snooze_interval"
|
android:key="pref_snooze_interval"
|
||||||
android:title="@string/pref_snooze_interval_title"
|
android:summary="%s"
|
||||||
android:summary="%s"/>
|
android:title="@string/pref_snooze_interval_title"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="pref_key_links"
|
android:key="databaseCategory"
|
||||||
android:title="Database">
|
android:title="Database">
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="pref_key_links"
|
android:key="linksCategory"
|
||||||
android:title="@string/links">
|
android:title="@string/links">
|
||||||
|
|
||||||
<Preference android:title="@string/help">
|
<Preference android:title="@string/help">
|
||||||
@@ -98,6 +98,14 @@
|
|||||||
android:data="@string/feedbackURL"/>
|
android:data="@string/feedbackURL"/>
|
||||||
</Preference>
|
</Preference>
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="translate"
|
||||||
|
android:title="@string/help_translate">
|
||||||
|
<intent
|
||||||
|
android:action="android.intent.action.VIEW"
|
||||||
|
android:data="@string/feedbackURL"/>
|
||||||
|
</Preference>
|
||||||
|
|
||||||
<Preference android:title="@string/about">
|
<Preference android:title="@string/about">
|
||||||
<intent
|
<intent
|
||||||
android:action="android.intent.action.VIEW"
|
android:action="android.intent.action.VIEW"
|
||||||
|
|||||||
Reference in New Issue
Block a user