mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-17 07:22:45 +00:00
Add descriptions of hidden features to the "About" section (#227)
- icons added in this section - translation in French done
This commit is contained in:
parent
c0597a46bc
commit
ecadcce08d
10 changed files with 162 additions and 6 deletions
|
@ -6,13 +6,22 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.latin.settings;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spanned;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.BuildConfig;
|
||||
import org.dslul.openboard.inputmethod.latin.R;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.utils.SpannableStringUtils;
|
||||
|
||||
/**
|
||||
* "About" sub screen.
|
||||
*/
|
||||
|
@ -21,7 +30,36 @@ public final class AboutFragment extends SubScreenFragment {
|
|||
public void onCreate(final Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
addPreferencesFromResource(R.xml.prefs_screen_about);
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
// need to set icon tint because old android versions don't use the vector drawables
|
||||
for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
|
||||
final Preference p = getPreferenceScreen().getPreference(0);
|
||||
final Drawable icon = p.getIcon();
|
||||
if (icon != null)
|
||||
DrawableCompat.setTint(icon, Color.WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
Preference versionPreference = findPreference("pref_key_version");
|
||||
versionPreference.setSummary(BuildConfig.VERSION_NAME);
|
||||
|
||||
Preference hiddenFeaturesPreference = findPreference("hidden_features");
|
||||
hiddenFeaturesPreference.setOnPreferenceClickListener(preference -> {
|
||||
final String link = "<a href=\"https://developer.android.com/reference/android/content/Context#createDeviceProtectedStorageContext()\">"
|
||||
+ getString(R.string.hidden_features_text) + "</a>";
|
||||
final String message = getContext().getString(R.string.hidden_features_message, link);
|
||||
final Spanned dialogMessage = SpannableStringUtils.fromHtml(message);
|
||||
|
||||
final AlertDialog builder = new AlertDialog.Builder(getContext())
|
||||
.setIcon(R.drawable.ic_settings_about_hidden_features)
|
||||
.setTitle(R.string.hidden_features_title)
|
||||
.setMessage(dialogMessage)
|
||||
.setPositiveButton(R.string.dialog_close, null)
|
||||
.create();
|
||||
builder.show();
|
||||
((TextView)builder.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue