1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2025-09-10 10:49:42 +02:00

Update and improve buildscript

This commit is contained in:
Gregor Santner 2017-11-18 20:04:59 +01:00
parent 255c6d650e
commit 28dac50d84
No known key found for this signature in database
GPG key ID: 7E83A7834AECB009
5 changed files with 90 additions and 46 deletions

View file

@ -51,6 +51,7 @@ import android.content.Context;
import android.os.Build;
import android.preference.ListPreference;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.AttributeSet;
import net.gsantner.opoc.util.ContextUtils;
@ -155,7 +156,9 @@ public class LanguagePreference extends ListPreference {
@Override
public CharSequence getSummary() {
Locale locale = new ContextUtils(getContext()).getLocaleByAndroidCode(getValue());
return super.getSummary() + "\n\n" + summarizeLocale(locale);
String prefix = TextUtils.isEmpty(super.getSummary())
? "" : super.getSummary() + "\n\n";
return prefix + summarizeLocale(locale);
}
public String getSystemLanguageName() {

View file

@ -12,8 +12,11 @@
package net.gsantner.opoc.util;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.support.annotation.StringRes;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AlertDialog;
@ -96,6 +99,13 @@ public class ActivityUtils extends net.gsantner.opoc.util.ContextUtils {
}
}
public void showSoftKeyboard() {
InputMethodManager inputMethodManager = (InputMethodManager) _activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
if (_activity.getCurrentFocus() != null && _activity.getCurrentFocus().getWindowToken() != null) {
inputMethodManager.showSoftInput(_activity.getCurrentFocus(), InputMethodManager.SHOW_FORCED);
}
}
public void showDialogWithHtmlTextView(@StringRes int resTitleId, String html) {
showDialogWithHtmlTextView(resTitleId, html, true, null);
}
@ -129,4 +139,18 @@ public class ActivityUtils extends net.gsantner.opoc.util.ContextUtils {
}
_activity.getWindow().setAttributes(attrs);
}
public void showRateOnGplayDialog() {
String pkgId = "details?id=" + _activity.getPackageName();
Intent goToMarket = new Intent(Intent.ACTION_VIEW, Uri.parse("market://" + pkgId));
goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |
(Build.VERSION.SDK_INT >= 21 ? Intent.FLAG_ACTIVITY_NEW_DOCUMENT : Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) |
Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
try {
_activity.startActivity(goToMarket);
} catch (ActivityNotFoundException e) {
_activity.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/" + pkgId)));
}
}
}

View file

@ -543,18 +543,4 @@ public class ContextUtils {
}
return this;
}
public void showRateOnGplayDialog() {
String pkgId = "details?id=" + _context.getPackageName();
Intent goToMarket = new Intent(Intent.ACTION_VIEW, Uri.parse("market://" + pkgId));
goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |
(Build.VERSION.SDK_INT >= 21 ? Intent.FLAG_ACTIVITY_NEW_DOCUMENT : Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) |
Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
try {
_context.startActivity(goToMarket);
} catch (ActivityNotFoundException e) {
_context.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/" + pkgId)));
}
}
}