18 | * Android 7.0 为了后台优化,推荐使用 JobScheduler 代替 BroadcastReceiver 来监听网络变化。 19 | * 20 | * @author Wizos on 2018/6/5. 21 | */ 22 | 23 | public class NetworkStateReceiver extends BroadcastReceiver { 24 | @Override 25 | public void onReceive(Context context, Intent intent) { 26 | KLog.e("接收到网络变化" + intent.getAction() + " . " + NetworkUtil.getNetWorkState()); 27 | if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) { 28 | NetworkUtil.getNetWorkState(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/me/wizos/loread/utils/EncryptUtil.java: -------------------------------------------------------------------------------- 1 | package me.wizos.loread.utils; 2 | 3 | import java.nio.charset.StandardCharsets; 4 | import java.security.MessageDigest; 5 | import java.security.NoSuchAlgorithmException; 6 | /** 7 | * 加密工具类 8 | * @author by Wizos on 2020/2/26. 9 | */ 10 | public class EncryptUtil { 11 | /** 12 | * 将字符串转成MD5值 13 | * 14 | * @param string 字符串 15 | * @return MD5 后的字符串 16 | */ 17 | public static String MD5(String string) { 18 | byte[] hash; 19 | try { 20 | hash = MessageDigest.getInstance("MD5").digest(string.getBytes(StandardCharsets.UTF_8)); 21 | } catch (NoSuchAlgorithmException e) { 22 | e.printStackTrace(); 23 | return null; 24 | } 25 | StringBuilder hex = new StringBuilder(hash.length * 2); 26 | for (byte b : hash) { 27 | if ((b & 0xFF) < 0x10) { 28 | hex.append("0"); 29 | } 30 | hex.append(Integer.toHexString(b & 0xFF)); 31 | } 32 | return hex.toString(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/me/wizos/loread/utils/ImgFileType.java: -------------------------------------------------------------------------------- 1 | package me.wizos.loread.utils; 2 | 3 | /** 4 | * Created by jiangzeyin on 2017/3/15. 5 | */ 6 | public enum ImgFileType { 7 | 8 | /** 9 | * JPEG,JPG 10 | */ 11 | JPEG("FFD8FF", "jpg"), 12 | 13 | /** 14 | * PNG 15 | */ 16 | PNG("89504E47", "png"), 17 | 18 | /** 19 | * GIF 20 | */ 21 | GIF("47494638", "gif"), 22 | 23 | /** 24 | * TIFF 25 | */ 26 | TIFF("49492A00"), 27 | 28 | /** 29 | * Windows bitmap 30 | */ 31 | BMP("424D"), 32 | 33 | 34 | WEBP("52494646"), 35 | 36 | /** 37 | * svg,还有一种是xml文件头 38 | */ 39 | SVG("3C73766720"); 40 | 41 | private String value = ""; 42 | private String ext = ""; 43 | 44 | ImgFileType(String value) { 45 | this.value = value; 46 | } 47 | 48 | ImgFileType(String value, String ext) { 49 | this(value); 50 | this.ext = ext; 51 | } 52 | 53 | public String getExt() { 54 | return ext; 55 | } 56 | 57 | public String getValue() { 58 | return value; 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /app/src/main/java/me/wizos/loread/utils/RGB.java: -------------------------------------------------------------------------------- 1 | package me.wizos.loread.utils; 2 | 3 | /** 4 | * Created by Wizos on 2018/7/10. 5 | */ 6 | 7 | public class RGB { 8 | int r; 9 | int g; 10 | int b; 11 | 12 | public RGB(int r, int g, int b) { 13 | this.r = r; 14 | this.g = g; 15 | this.b = b; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return "RGB{" + 21 | "r=" + r + 22 | ", g=" + g + 23 | ", b=" + b + 24 | '}'; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/me/wizos/loread/utils/ScriptUtil.java: -------------------------------------------------------------------------------- 1 | package me.wizos.loread.utils; 2 | 3 | import com.socks.library.KLog; 4 | 5 | import javax.script.Bindings; 6 | import javax.script.ScriptEngine; 7 | import javax.script.ScriptEngineManager; 8 | import javax.script.ScriptException; 9 | 10 | 11 | public class ScriptUtil { 12 | private static ScriptUtil instance; 13 | private static ScriptEngine engine; 14 | private ScriptUtil() { } 15 | 16 | public static synchronized ScriptUtil init() { 17 | if (instance == null) { 18 | synchronized (ScriptUtil.class) { 19 | if (instance == null) { 20 | instance = new ScriptUtil(); 21 | engine = new ScriptEngineManager().getEngineByName("rhino"); 22 | } 23 | } 24 | } 25 | return instance; 26 | } 27 | 28 | public static ScriptUtil i(){ 29 | if( instance == null ){ 30 | init(); 31 | } 32 | return instance; 33 | } 34 | 35 | public boolean eval(String js, Bindings bindings){ 36 | try { 37 | engine.eval(js, bindings); 38 | return true; 39 | } catch (ScriptException e) { 40 | KLog.e("脚本执行错误" + e.getMessage() + "," +e.getFileName() + ","+ e.getColumnNumber() + "," + e.getLineNumber() ); 41 | e.printStackTrace(); 42 | return false; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/me/wizos/loread/utils/VideoInjectUtil.java: -------------------------------------------------------------------------------- 1 | package me.wizos.loread.utils; 2 | 3 | import me.wizos.loread.bridge.WebBridge; 4 | 5 | /** 6 | * @author by Wizos on 2018/6/29. 7 | */ 8 | 9 | public class VideoInjectUtil { 10 | /** 11 | * 注入全屏Js,对不同的视频网站分析相应的全屏控件——class标识 12 | * 13 | * @param url 加载的网页地址 14 | * @return 注入的js内容,若不是需要适配的网址则返回空javascript 15 | */ 16 | public static String fullScreenJsFun(String url) { 17 | String fullScreenFlags = null; 18 | // http://v.qq.com/txp/iframe/player.html?vid=v0151eygqka、http://v.qq.com/iframe/player.html?vid=v0151eygqka 19 | if (url.contains("qq.com/txp/iframe/player.html")) { 20 | fullScreenFlags = "txp_btn_fullscreen"; 21 | } else if (url.contains("sohu")) { 22 | fullScreenFlags = "x-fs-btn"; 23 | } else if (url.contains("letv")) { 24 | fullScreenFlags = "hv_ico_screen"; 25 | } 26 | if (null != fullScreenFlags) { 27 | return "javascript:document.getElementsByClassName('" + fullScreenFlags + "')[0].addEventListener('click',function(){" + WebBridge.TAG + ".toggleScreenOrientation();return false;});"; 28 | } else { 29 | return "javascript:"; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/me/wizos/loread/view/IconFontView.java: -------------------------------------------------------------------------------- 1 | package me.wizos.loread.view; 2 | 3 | import android.content.Context; 4 | import android.graphics.Typeface; 5 | import android.util.AttributeSet; 6 | 7 | import androidx.appcompat.widget.AppCompatTextView; 8 | 9 | 10 | /** 11 | * Created by Wizos on 2016/11/6. 12 | */ 13 | 14 | public class IconFontView extends AppCompatTextView { 15 | 16 | public IconFontView(Context context) { 17 | super(context); 18 | init(); 19 | } 20 | 21 | public IconFontView(Context context, AttributeSet attrs) { 22 | super(context, attrs); 23 | init(); 24 | } 25 | 26 | public IconFontView(Context context, AttributeSet attrs, int defStyleAttr) { 27 | super(context, attrs, defStyleAttr); 28 | init(); 29 | } 30 | 31 | private void init() { 32 | Typeface iconFont = Typeface.createFromAsset(getContext().getAssets(), "iconfont.ttf"); 33 | this.setTypeface(iconFont); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/me/wizos/loread/view/colorful/StatusBarView.java: -------------------------------------------------------------------------------- 1 | package me.wizos.loread.view.colorful; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.View; 6 | 7 | /** 8 | * Created by Jaeger on 16/6/8. 9 | *
10 | * Email: chjie.jaeger@gmail.com
11 | * GitHub: https://github.com/laobie
12 | */
13 | public class StatusBarView extends View {
14 | public StatusBarView(Context context, AttributeSet attrs) {
15 | super(context, attrs);
16 | }
17 |
18 | public StatusBarView(Context context) {
19 | super(context);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wizos/loread/view/colorful/setter/TextColorSetter.java:
--------------------------------------------------------------------------------
1 | package me.wizos.loread.view.colorful.setter;
2 |
3 | import android.content.res.Resources.Theme;
4 | import android.widget.TextView;
5 |
6 | /**
7 | * TextView 文本颜色Setter
8 | *
9 | * @author mrsimple
10 | */
11 | public class TextColorSetter extends ViewSetter {
12 |
13 | public TextColorSetter(TextView textView, int resId) {
14 | super(textView, resId);
15 | }
16 |
17 | public TextColorSetter(int viewId, int resId) {
18 | super(viewId, resId);
19 | }
20 |
21 | @Override
22 | public void setValue(Theme newTheme, int themeId) {
23 | if (mView == null) {
24 | return;
25 | }
26 | ((TextView) mView).setTextColor(getColor(newTheme));
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wizos/loread/view/colorful/setter/ViewBackgroundColorSetter.java:
--------------------------------------------------------------------------------
1 | package me.wizos.loread.view.colorful.setter;
2 |
3 | import android.content.res.Resources.Theme;
4 | import android.view.View;
5 |
6 | /**
7 | * View的背景色Setter
8 | *
9 | * @author mrsimple
10 | */
11 | public class ViewBackgroundColorSetter extends ViewSetter {
12 |
13 | public ViewBackgroundColorSetter(View target, int resId) {
14 | super(target, resId);
15 | }
16 |
17 | public ViewBackgroundColorSetter(int viewId, int resId) {
18 | super(viewId, resId);
19 | }
20 |
21 | @Override
22 | public void setValue(Theme newTheme, int themeId) {
23 | if (mView != null) {
24 | int alpha = 255;
25 | if (mView.getBackground() != null) {
26 | alpha = mView.getBackground().getAlpha();// 自加。保留透明度信息。
27 | }
28 | mView.setBackgroundColor(getColor(newTheme));
29 | mView.getBackground().setAlpha(alpha);// 自加。保留透明度信息。
30 | }
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wizos/loread/view/colorful/setter/ViewBackgroundDrawableSetter.java:
--------------------------------------------------------------------------------
1 | package me.wizos.loread.view.colorful.setter;
2 |
3 | import android.content.res.Resources.Theme;
4 | import android.content.res.TypedArray;
5 | import android.graphics.drawable.Drawable;
6 | import android.view.View;
7 |
8 | /**
9 | * View的背景Drawabler Setter
10 | *
11 | * @author mrsimple
12 | */
13 | public final class ViewBackgroundDrawableSetter extends ViewSetter {
14 |
15 | public ViewBackgroundDrawableSetter(View targetView, int resId) {
16 | super(targetView, resId);
17 | }
18 |
19 |
20 | public ViewBackgroundDrawableSetter(int viewId, int resId) {
21 | super(viewId, resId);
22 | }
23 |
24 | @SuppressWarnings("deprecation")
25 | @Override
26 | public void setValue(Theme newTheme, int themeId) {
27 | if (mView == null) {
28 | return;
29 | }
30 | TypedArray a = newTheme.obtainStyledAttributes(themeId,
31 | new int[]{mAttrResId});
32 | int attributeResourceId = a.getResourceId(0, 0);
33 | Drawable drawable = mView.getResources().getDrawable(
34 | attributeResourceId);
35 | a.recycle();
36 | mView.setBackgroundDrawable(drawable);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wizos/loread/view/slideback/callback/SlideBackCallBack.java:
--------------------------------------------------------------------------------
1 | package me.wizos.loread.view.slideback.callback;
2 |
3 | public interface SlideBackCallBack {
4 | void onSlideBack();
5 | // void onViewSlideUpdate(int offset);
6 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/wizos/loread/view/slideback/callback/SlideCallBack.java:
--------------------------------------------------------------------------------
1 | package me.wizos.loread.view.slideback.callback;
2 |
3 | public abstract class SlideCallBack implements SlideBackCallBack {
4 | private SlideBackCallBack callBack;
5 |
6 | public SlideCallBack() {
7 | }
8 |
9 | public SlideCallBack(SlideBackCallBack callBack) {
10 | this.callBack = callBack;
11 | }
12 |
13 | @Override
14 | public void onSlideBack() {
15 | if (null != callBack) {
16 | callBack.onSlideBack();
17 | }
18 | }
19 | // @Override
20 | // public void onViewSlideUpdate(int offset) {
21 | // if (null != callBack) {
22 | // callBack.onViewSlideUpdate(offset);
23 | // }
24 | // }
25 |
26 | /**
27 | * 滑动来源:
28 | * EDGE_LEFT 左侧侧滑
29 | * EDGE_RIGHT 右侧侧滑
30 | */
31 | public abstract void onSlide(int edgeFrom);
32 |
33 | public abstract void onViewSlide(int edgeFrom, int offset);
34 | }
--------------------------------------------------------------------------------
/app/src/main/res/anim/fade_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 | * A functional interface (callback) that returns true or false for the given input path should be compressed. 9 | */ 10 | 11 | public interface CompressionPredicate { 12 | 13 | /** 14 | * Determine the given input path should be compressed and return a boolean. 15 | * 16 | * @param path input path 17 | * @return the boolean result 18 | */ 19 | // boolean apply(String path); 20 | boolean apply(String path,InputStreamProvider inputStreamProvider); 21 | } 22 | -------------------------------------------------------------------------------- /luban/src/main/java/top/zibin/luban/FileProvider.java: -------------------------------------------------------------------------------- 1 | package top.zibin.luban; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | * 自己增加的,为的是最后能在回调中区分文件到底有没有压缩 7 | * @author Wizos on 2018/12/27. 8 | */ 9 | 10 | public class FileProvider { 11 | public boolean hasCompressed = false; 12 | public File file; 13 | } 14 | -------------------------------------------------------------------------------- /luban/src/main/java/top/zibin/luban/InputStreamProvider.java: -------------------------------------------------------------------------------- 1 | package top.zibin.luban; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | /** 7 | * 通过此接口获取输入流,以兼容文件、FileProvider方式获取到的图片 8 | *
9 | * Get the input stream through this interface, and obtain the picture using compatible files and FileProvider 10 | */ 11 | public interface InputStreamProvider { 12 | 13 | InputStream open() throws IOException; 14 | 15 | String getPath(); 16 | } 17 | -------------------------------------------------------------------------------- /luban/src/main/java/top/zibin/luban/OnCompressListener.java: -------------------------------------------------------------------------------- 1 | package top.zibin.luban; 2 | 3 | import java.io.File; 4 | 5 | public interface OnCompressListener { 6 | 7 | /** 8 | * Fired when the compression is started, override to handle in your own code 9 | */ 10 | void onStart(); 11 | 12 | /** 13 | * Fired when a compression returns successfully, override to handle in your own code 14 | */ 15 | void onSuccess(File file); 16 | 17 | /** 18 | * 自己增加的 19 | * 条件不符合,最后没有压缩 20 | */ 21 | void onUnChange(File file); 22 | /** 23 | * Fired when a compression fails to complete, override to handle in your own code 24 | */ 25 | void onError(Throwable e); 26 | } 27 | -------------------------------------------------------------------------------- /luban/src/main/java/top/zibin/luban/OnRenameListener.java: -------------------------------------------------------------------------------- 1 | package top.zibin.luban; 2 | 3 | /** 4 | * Author: zibin 5 | * Datetime: 2018/5/18 6 | *
7 | * 提供修改压缩图片命名接口 8 | *
9 | * A functional interface (callback) that used to rename the file after compress. 10 | */ 11 | public interface OnRenameListener { 12 | 13 | /** 14 | * 压缩前调用该方法用于修改压缩后文件名 15 | *
16 | * Call before compression begins.
17 | *
18 | * @param filePath 传入文件路径/ file path
19 | * @return 返回重命名后的字符串/ file name
20 | */
21 | String rename(String filePath);
22 | }
23 |
--------------------------------------------------------------------------------
/luban/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |