mirror of
https://github.com/gsantner/dandelion
synced 2025-09-10 10:49:42 +02:00
Update to latest opoc version
* Move various clases * Especially improve language preference, backported from compat lib
This commit is contained in:
parent
1bb061b563
commit
dd0432f718
10 changed files with 281 additions and 115 deletions
|
@ -29,7 +29,6 @@ import android.graphics.Canvas;
|
|||
import android.graphics.Color;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
@ -47,7 +46,6 @@ import android.support.annotation.StringRes;
|
|||
import android.support.graphics.drawable.VectorDrawableCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.AppCompatButton;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
|
@ -58,11 +56,12 @@ import android.util.DisplayMetrics;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.gsantner.opoc.format.markdown.SimpleMarkdownParser;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -152,7 +151,11 @@ public class ContextUtils {
|
|||
Uri uri = Uri.parse(url);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
_context.startActivity(intent);
|
||||
try {
|
||||
_context.startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -232,16 +235,6 @@ public class ContextUtils {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
public void showDialogWithRawFileInWebView(String fileInRaw, @StringRes int resTitleId) {
|
||||
WebView wv = new WebView(_context);
|
||||
wv.loadUrl("file:///android_res/raw/" + fileInRaw);
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(_context)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.setTitle(resTitleId)
|
||||
.setView(wv);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
@SuppressWarnings("RestrictedApi")
|
||||
public void setTintColorOfButton(AppCompatButton button, @ColorRes int resColor) {
|
||||
|
@ -519,11 +512,7 @@ public class ContextUtils {
|
|||
public ContextUtils tintMenuItems(Menu menu, boolean recurse, @ColorInt int iconColor) {
|
||||
for (int i = 0; i < menu.size(); i++) {
|
||||
MenuItem item = menu.getItem(i);
|
||||
Drawable drawable = item.getIcon();
|
||||
if (drawable != null) {
|
||||
drawable.mutate();
|
||||
drawable.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
tintDrawable(item.getIcon(), iconColor);
|
||||
if (item.hasSubMenu() && recurse) {
|
||||
tintMenuItems(item.getSubMenu(), recurse, iconColor);
|
||||
}
|
||||
|
@ -531,6 +520,18 @@ public class ContextUtils {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Drawable tintDrawable(@DrawableRes int drawableRes, @ColorInt int color) {
|
||||
return tintDrawable(_context.getResources().getDrawable(drawableRes), color);
|
||||
}
|
||||
|
||||
public Drawable tintDrawable(@Nullable Drawable drawable, @ColorInt int color) {
|
||||
if (drawable != null) {
|
||||
drawable = DrawableCompat.wrap(drawable);
|
||||
DrawableCompat.setTint(drawable.mutate(), color);
|
||||
}
|
||||
return drawable;
|
||||
}
|
||||
|
||||
@SuppressLint("PrivateApi")
|
||||
public ContextUtils setSubMenuIconsVisiblity(Menu menu, boolean visible) {
|
||||
if (menu.getClass().getSimpleName().equals("MenuBuilder")) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue