diff --git a/DialogX/src/main/java/com/kongzue/dialogx/dialogs/WaitDialog.java b/DialogX/src/main/java/com/kongzue/dialogx/dialogs/WaitDialog.java index a6317f9..8d6d6aa 100644 --- a/DialogX/src/main/java/com/kongzue/dialogx/dialogs/WaitDialog.java +++ b/DialogX/src/main/java/com/kongzue/dialogx/dialogs/WaitDialog.java @@ -43,21 +43,21 @@ import java.lang.ref.WeakReference; * @createTime: 2020/9/27 14:50 */ public class WaitDialog extends BaseDialog { - + public static int overrideEnterDuration = -1; public static int overrideExitDuration = -1; public static int overrideEnterAnimRes = 0; public static int overrideExitAnimRes = 0; public static BOOLEAN overrideCancelable; protected OnBindView onBindView; - + public enum TYPE { NONE, SUCCESS, WARNING, ERROR } - + protected static WeakReference me; protected CharSequence message; protected long tipShowDuration = 1500; @@ -66,20 +66,20 @@ public class WaitDialog extends BaseDialog { protected TextInfo messageTextInfo; protected int maskColor = -1; protected BOOLEAN privateCancelable; - + private DialogLifecycleCallback dialogLifecycleCallback; - + protected WaitDialog() { super(); me = new WeakReference<>(this); cancelable = DialogX.cancelableTipDialog; } - + public static WaitDialog show(CharSequence message) { DialogImpl dialogImpl = me().dialogImpl; me().message = message; me().showType = -1; - if (dialogImpl != null) { + if (dialogImpl != null && dialogImpl.progressView != null) { dialogImpl.progressView.loading(); setMessage(message); return me(); @@ -90,12 +90,12 @@ public class WaitDialog extends BaseDialog { return waitDialog; } } - + public static WaitDialog show(Activity activity, CharSequence message) { DialogImpl dialogImpl = me().dialogImpl; me().message = message; me().showType = -1; - if (dialogImpl != null && dialogImpl.bkg.getContext() == activity) { + if (dialogImpl != null&& dialogImpl.progressView != null && dialogImpl.bkg.getContext() == activity) { dialogImpl.progressView.loading(); setMessage(message); return me(); @@ -106,12 +106,12 @@ public class WaitDialog extends BaseDialog { return waitDialog; } } - + public static WaitDialog show(int messageResId) { DialogImpl dialogImpl = me().dialogImpl; me().preMessage(messageResId); me().showType = -1; - if (dialogImpl != null) { + if (dialogImpl != null&& dialogImpl.progressView != null) { dialogImpl.progressView.loading(); setMessage(messageResId); return me(); @@ -122,12 +122,12 @@ public class WaitDialog extends BaseDialog { return waitDialog; } } - + public static WaitDialog show(Activity activity, int messageResId) { DialogImpl dialogImpl = me().dialogImpl; me().preMessage(messageResId); me().showType = -1; - if (dialogImpl != null && dialogImpl.bkg.getContext() == activity) { + if (dialogImpl != null&& dialogImpl.progressView != null && dialogImpl.bkg.getContext() == activity) { dialogImpl.progressView.loading(); setMessage(messageResId); return me(); @@ -138,12 +138,12 @@ public class WaitDialog extends BaseDialog { return waitDialog; } } - + public static WaitDialog show(CharSequence message, float progress) { DialogImpl dialogImpl = me().dialogImpl; me().showType = -1; me().preMessage(message); - if (dialogImpl != null) { + if (dialogImpl != null&& dialogImpl.progressView != null) { setMessage(message); me().setProgress(progress); return me(); @@ -155,12 +155,12 @@ public class WaitDialog extends BaseDialog { return waitDialog; } } - + public static WaitDialog show(Activity activity, CharSequence message, float progress) { DialogImpl dialogImpl = me().dialogImpl; me().showType = -1; me().preMessage(message); - if (dialogImpl != null && dialogImpl.bkg.getContext() == activity) { + if (dialogImpl != null && dialogImpl.progressView != null&& dialogImpl.bkg.getContext() == activity) { setMessage(message); me().setProgress(progress); return me(); @@ -172,12 +172,12 @@ public class WaitDialog extends BaseDialog { return waitDialog; } } - + public static WaitDialog show(int messageResId, float progress) { DialogImpl dialogImpl = me().dialogImpl; me().showType = -1; me().preMessage(messageResId); - if (dialogImpl != null) { + if (dialogImpl != null&& dialogImpl.progressView != null) { setMessage(messageResId); me().setProgress(progress); return me(); @@ -189,12 +189,12 @@ public class WaitDialog extends BaseDialog { return waitDialog; } } - + public static WaitDialog show(Activity activity, int messageResId, float progress) { DialogImpl dialogImpl = me().dialogImpl; me().showType = -1; me().preMessage(messageResId); - if (dialogImpl != null && dialogImpl.bkg.getContext() == activity) { + if (dialogImpl != null&& dialogImpl.progressView != null && dialogImpl.bkg.getContext() == activity) { setMessage(messageResId); me().setProgress(progress); return me(); @@ -206,11 +206,11 @@ public class WaitDialog extends BaseDialog { return waitDialog; } } - + public static WaitDialog show(Activity activity, float progress) { DialogImpl dialogImpl = me().dialogImpl; me().showType = -1; - if (dialogImpl != null && dialogImpl.bkg.getContext() == activity) { + if (dialogImpl != null&& dialogImpl.progressView != null && dialogImpl.bkg.getContext() == activity) { me().setProgress(progress); return me(); } else { @@ -220,11 +220,11 @@ public class WaitDialog extends BaseDialog { return waitDialog; } } - + public static WaitDialog show(float progress) { DialogImpl dialogImpl = me().dialogImpl; me().showType = -1; - if (dialogImpl != null) { + if (dialogImpl != null&& dialogImpl.progressView != null) { me().setProgress(progress); return me(); } else { @@ -234,19 +234,19 @@ public class WaitDialog extends BaseDialog { return waitDialog; } } - + public float getProgress() { return waitProgress; } - + public WaitDialog setProgress(float waitProgress) { this.waitProgress = waitProgress; refreshUI(); return this; } - + private View dialogView; - + public WaitDialog show() { super.beforeShow(); int layoutResId = R.layout.layout_dialogx_wait; @@ -264,7 +264,7 @@ public class WaitDialog extends BaseDialog { }); return this; } - + public WaitDialog show(final Activity activity) { super.beforeShow(); int layoutResId = R.layout.layout_dialogx_wait; @@ -282,9 +282,9 @@ public class WaitDialog extends BaseDialog { }); return this; } - + protected DialogImpl dialogImpl; - + public class DialogImpl implements DialogConvertViewInterface { public DialogXBaseRelativeLayout boxRoot; public MaxRelativeLayout bkg; @@ -293,14 +293,14 @@ public class WaitDialog extends BaseDialog { public ProgressViewInterface progressView; public RelativeLayout boxCustomView; public TextView txtInfo; - + private int layoutResId; - + public DialogImpl(int layoutResId) { this.layoutResId = layoutResId; } - - public void lazyCreate(){ + + public void lazyCreate() { dialogView = createView(layoutResId); boxRoot = dialogView.findViewById(R.id.box_root); bkg = dialogView.findViewById(R.id.bkg); @@ -318,7 +318,7 @@ public class WaitDialog extends BaseDialog { dialogImpl = this; refreshView(); } - + public DialogImpl(View convertView) { boxRoot = convertView.findViewById(R.id.box_root); bkg = convertView.findViewById(R.id.bkg); @@ -336,18 +336,18 @@ public class WaitDialog extends BaseDialog { dialogImpl = this; refreshView(); } - + public void init() { if (messageTextInfo == null) messageTextInfo = DialogX.tipTextInfo; if (backgroundColor == -1) backgroundColor = DialogX.tipBackgroundColor; - + if (style.overrideWaitTipRes() == null) { blurView.setRadiusPx(dip2px(15)); } else { blurView.setRadiusPx(style.overrideWaitTipRes().overrideRadiusPx() < 0 ? dip2px(15) : style.overrideWaitTipRes().overrideRadiusPx()); } boxRoot.setClickable(true); - + boxRoot.setParentDialog(me.get()); boxRoot.setOnLifecycleCallBack(new DialogXBaseRelativeLayout.OnLifecycleCallBack() { @Override @@ -372,18 +372,18 @@ public class WaitDialog extends BaseDialog { } enterAnim.setDuration(enterAnimDurationTemp); bkg.startAnimation(enterAnim); - + boxRoot.animate() .setDuration(enterAnimDurationTemp) .alpha(1f) .setInterpolator(new DecelerateInterpolator()) .setListener(null); - + getDialogLifecycleCallback().onShow(me()); } }); } - + @Override public void onDismiss() { isShow = false; @@ -392,7 +392,7 @@ public class WaitDialog extends BaseDialog { me.clear(); } }); - + if (readyTipType != null) { progressView.noLoading(); ((View) progressView).postDelayed(new Runnable() { @@ -402,7 +402,7 @@ public class WaitDialog extends BaseDialog { } }, 100); } - + boxRoot.setOnBackPressedListener(new OnBackPressedListener() { @Override public boolean onBackPressed() { @@ -417,9 +417,9 @@ public class WaitDialog extends BaseDialog { } }); } - + private float oldProgress; - + public void refreshView() { if (style.overrideWaitTipRes() != null) { int overrideBackgroundColorRes = style.overrideWaitTipRes().overrideBackgroundColorRes(isLightTheme()); @@ -446,17 +446,17 @@ public class WaitDialog extends BaseDialog { } } if (DialogX.tipProgressColor != -1) progressView.setColor(DialogX.tipProgressColor); - + if (waitProgress >= 0 && waitProgress <= 1 && oldProgress != waitProgress) { progressView.progress(waitProgress); oldProgress = waitProgress; } - + showText(txtInfo, message); useTextInfo(txtInfo, messageTextInfo); - + if (maskColor != -1) boxRoot.setBackgroundColor(maskColor); - + if (onBindView != null && onBindView.getCustomView() != null) { onBindView.bindParent(boxCustomView, me.get()); boxCustomView.setVisibility(View.VISIBLE); @@ -466,13 +466,13 @@ public class WaitDialog extends BaseDialog { boxProgress.setVisibility(View.VISIBLE); } } - + public void doDismiss(final View v) { boxRoot.post(new Runnable() { @Override public void run() { if (v != null) v.setEnabled(false); - + int exitAnimResId = R.anim.anim_dialogx_default_exit; if (overrideExitAnimRes != 0) { exitAnimResId = overrideExitAnimRes; @@ -488,12 +488,12 @@ public class WaitDialog extends BaseDialog { exitAnim.setDuration(exitAnimDurationTemp); exitAnim.setInterpolator(new AccelerateInterpolator()); bkg.startAnimation(exitAnim); - + boxRoot.animate() .alpha(0f) .setInterpolator(new AccelerateInterpolator()) .setDuration(exitAnimDurationTemp); - + new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { @Override public void run() { @@ -503,7 +503,7 @@ public class WaitDialog extends BaseDialog { } }); } - + public void showTip(final TYPE tip) { runOnMain(new Runnable() { @Override @@ -524,7 +524,7 @@ public class WaitDialog extends BaseDialog { progressView.error(); break; } - + //此事件是在完成衔接动画绘制后执行的逻辑 progressView.whenShowTick(new Runnable() { @Override @@ -545,12 +545,12 @@ public class WaitDialog extends BaseDialog { }); } } - + @Override public String dialogKey() { return getClass().getSimpleName() + "(" + Integer.toHexString(hashCode()) + ")"; } - + @Override public boolean isLightTheme() { if (DialogX.tipTheme == null) { @@ -559,7 +559,7 @@ public class WaitDialog extends BaseDialog { return DialogX.tipTheme == DialogX.THEME.LIGHT; } } - + public void refreshUI() { runOnMain(new Runnable() { @Override @@ -568,67 +568,67 @@ public class WaitDialog extends BaseDialog { } }); } - + public void doDismiss() { if (dialogImpl == null) return; dialogImpl.doDismiss(null); } - + public static void dismiss() { me().doDismiss(); } - + protected static WaitDialog me() { if (me == null || me.get() == null) me = new WeakReference<>(new WaitDialog()); return me.get(); } - + protected TYPE readyTipType; - + protected void showTip(CharSequence message, TYPE type) { showType = type.ordinal(); this.message = message; readyTipType = type; show(); } - + protected void showTip(Activity activity, CharSequence message, TYPE type) { showType = type.ordinal(); this.message = message; readyTipType = type; show(activity); } - + protected void showTip(int messageResId, TYPE type) { showType = type.ordinal(); this.message = getString(messageResId); readyTipType = type; show(); } - + protected void showTip(Activity activity, int messageResId, TYPE type) { showType = type.ordinal(); this.message = getString(messageResId); readyTipType = type; show(activity); } - + public static CharSequence getMessage() { return me().message; } - + public static WaitDialog setMessage(CharSequence message) { me().preMessage(message); me().refreshUI(); return me(); } - + public static WaitDialog setMessage(int messageResId) { me().preMessage(messageResId); me().refreshUI(); return me(); } - + public boolean isCancelable() { if (privateCancelable != null) { return privateCancelable == BOOLEAN.TRUE; @@ -638,12 +638,12 @@ public class WaitDialog extends BaseDialog { } return cancelable; } - + public WaitDialog setCancelable(boolean cancelable) { privateCancelable = cancelable ? BOOLEAN.TRUE : BOOLEAN.FALSE; return this; } - + /** * 用于从 WaitDialog 到 TipDialog 的消息设置 * 此方法不会立即执行,而是等到动画衔接完成后由事件设置 @@ -655,95 +655,95 @@ public class WaitDialog extends BaseDialog { me().message = message; return me(); } - + protected WaitDialog preMessage(int messageResId) { me().message = getString(messageResId); return me(); } - + public DialogLifecycleCallback getDialogLifecycleCallback() { return dialogLifecycleCallback == null ? new DialogLifecycleCallback() { } : dialogLifecycleCallback; } - + public WaitDialog setDialogLifecycleCallback(DialogLifecycleCallback dialogLifecycleCallback) { this.dialogLifecycleCallback = dialogLifecycleCallback; if (isShow) dialogLifecycleCallback.onShow(me.get()); return this; } - + public DialogImpl getDialogImpl() { return dialogImpl; } - + public WaitDialog setCustomView(OnBindView onBindView) { this.onBindView = onBindView; refreshUI(); return this; } - + public View getCustomView() { if (onBindView == null) return null; return onBindView.getCustomView(); } - + public WaitDialog removeCustomView() { this.onBindView.clean(); refreshUI(); return this; } - + public OnBackPressedListener getOnBackPressedListener() { return onBackPressedListener; } - + public WaitDialog setOnBackPressedListener(OnBackPressedListener onBackPressedListener) { this.onBackPressedListener = onBackPressedListener; refreshUI(); return this; } - + public int getBackgroundColor() { return backgroundColor; } - + public WaitDialog setBackgroundColor(@ColorInt int backgroundColor) { this.backgroundColor = backgroundColor; refreshUI(); return this; } - + public WaitDialog setBackgroundColorRes(@ColorRes int backgroundColorResId) { this.backgroundColor = getColor(backgroundColorResId); refreshUI(); return this; } - + public WaitDialog setMaskColor(@ColorInt int maskColor) { this.maskColor = maskColor; refreshUI(); return this; } - + public WaitDialog setEnterAnimDuration(long enterAnimDuration) { this.enterAnimDuration = enterAnimDuration; return this; } - + public long getExitAnimDuration() { return exitAnimDuration; } - + public WaitDialog setExitAnimDuration(long exitAnimDuration) { this.exitAnimDuration = exitAnimDuration; return this; } - + @Override public void onUIModeChange(Configuration newConfig) { refreshUI(); } - + public static WaitDialog getInstance() { return me(); } diff --git a/DialogX/src/main/java/com/kongzue/dialogx/interfaces/BaseDialog.java b/DialogX/src/main/java/com/kongzue/dialogx/interfaces/BaseDialog.java index fda8d9f..5e3d02b 100644 --- a/DialogX/src/main/java/com/kongzue/dialogx/interfaces/BaseDialog.java +++ b/DialogX/src/main/java/com/kongzue/dialogx/interfaces/BaseDialog.java @@ -298,7 +298,10 @@ public abstract class BaseDialog { } public static FrameLayout getRootFrameLayout() { - if (rootFrameLayout == null) return null; + if (rootFrameLayout == null) { + error("DialogX 未初始化。\n请检查是否在启动对话框前进行初始化操作,使用以下代码进行初始化:\nDialogX.init(context);\n\n另外建议您前往查看 DialogX 的文档进行使用:https://github.com/kongzue/DialogX"); + return null; + } return rootFrameLayout.get(); } diff --git a/DialogX/src/main/java/com/kongzue/dialogx/util/views/NoArticulatedProgressView.java b/DialogX/src/main/java/com/kongzue/dialogx/util/views/NoArticulatedProgressView.java index 0f767f6..9899f0d 100644 --- a/DialogX/src/main/java/com/kongzue/dialogx/util/views/NoArticulatedProgressView.java +++ b/DialogX/src/main/java/com/kongzue/dialogx/util/views/NoArticulatedProgressView.java @@ -19,6 +19,7 @@ import android.view.animation.LinearInterpolator; import androidx.annotation.Nullable; +import com.kongzue.dialogx.DialogX; import com.kongzue.dialogx.R; import com.kongzue.dialogx.interfaces.ProgressViewInterface; @@ -188,7 +189,7 @@ public class NoArticulatedProgressView extends View implements ProgressViewInter } if (tickShowRunnable != null) { tickShowRunnable.run(); - performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + if (DialogX.useHaptic)performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); tickShowRunnable = null; } switch (status) { diff --git a/app/src/main/assets/updatelog.fy b/app/src/main/assets/updatelog.fy index cd57edd..f6cf891 100644 --- a/app/src/main/assets/updatelog.fy +++ b/app/src/main/assets/updatelog.fy @@ -1,6 +1,10 @@ +2021.06.04 风月读书v2.0.8 更新内容: 1、优化书籍、书源拖拽移动效果 +2、重做书籍长按菜单 +3、修复部分字体无法下载的问题 +4、修复其他已知bug 2021.06.03 风月读书v2.0.7 diff --git a/app/src/main/java/xyz/fycz/myreader/enums/Font.java b/app/src/main/java/xyz/fycz/myreader/enums/Font.java index b33c1c1..052f5ad 100644 --- a/app/src/main/java/xyz/fycz/myreader/enums/Font.java +++ b/app/src/main/java/xyz/fycz/myreader/enums/Font.java @@ -1,31 +1,33 @@ package xyz.fycz.myreader.enums; +import xyz.fycz.myreader.common.URLCONST; + public enum Font { 默认字体( "默认字体"), 本地字体( "默认字体"), - 方正楷体( "https://fycz.lanzousi.com/ilLFMe6kefe"), - 方正行楷( "https://fycz.lanzousi.com/imFvne6keji"), - 经典宋体("https://fycz.lanzousi.com/idhI5e6keqf"), - 方正硬笔行书("https://fycz.lanzousi.com/ilVh6ep9xja"), - 包图小白体("https://fycz.lanzoui.com/i5qgAicrirc"), - 仓耳非白W02("https://fycz.lanzoui.com/iHwRnicriuf"), - 仓耳舒圆体W02("https://fycz.lanzoui.com/i3GVPicrj3e"), - 仓耳与墨W02("https://fycz.lanzoui.com/ivhv9icrj7i"), - 方正仿宋简体("https://fycz.lanzoui.com/iEcCHicrjef"), - 方正黑体简体("https://fycz.lanzoui.com/iw8kKicrjij"), - 方正书宋简体("https://fycz.lanzoui.com/i5976icrjmd"), - 品如手写体("https://fycz.lanzoui.com/iZccuicrjyf"), - 千图小兔体("https://fycz.lanzoui.com/iOONMicrkda"), - 手书体("https://fycz.lanzoui.com/iqbmdicrkvi"), - 演示春风楷("https://fycz.lanzoui.com/ioRJSicrldg"), - 演示秋鸿楷("https://fycz.lanzoui.com/i8qnzicrlsb"), - 演示夏行楷("https://fycz.lanzoui.com/iyYUTicrm6f"), - 演示悠然小楷("https://fycz.lanzoui.com/ikKq7icrmrg"), - 杨任东竹石体("https://fycz.lanzoui.com/iiWdVicrnbg"), - 站酷仓耳渔阳体("https://fycz.lanzoui.com/if5weicrnje"), - 迷你隶书( "https://fycz.lanzousi.com/ihaXVe6kekj"), - 方正黄草("https://fycz.lanzousi.com/iQg67e6keed"); + 方正楷体( URLCONST.LAN_ZOUS_URL + " /ilLFMe6kefe"), + 方正行楷( URLCONST.LAN_ZOUS_URL + "/imFvne6keji"), + 经典宋体(URLCONST.LAN_ZOUS_URL + "/idhI5e6keqf"), + 方正硬笔行书(URLCONST.LAN_ZOUS_URL + "/ilVh6ep9xja"), + 包图小白体(URLCONST.LAN_ZOUS_URL + "/i5qgAicrirc"), + 仓耳非白W02(URLCONST.LAN_ZOUS_URL + "/iHwRnicriuf"), + 仓耳舒圆体W02(URLCONST.LAN_ZOUS_URL + "/i3GVPicrj3e"), + 仓耳与墨W02(URLCONST.LAN_ZOUS_URL + "/ivhv9icrj7i"), + 方正仿宋简体(URLCONST.LAN_ZOUS_URL + "/iEcCHicrjef"), + 方正黑体简体(URLCONST.LAN_ZOUS_URL + "/iw8kKicrjij"), + 方正书宋简体(URLCONST.LAN_ZOUS_URL + "/i5976icrjmd"), + 品如手写体(URLCONST.LAN_ZOUS_URL + "/iZccuicrjyf"), + 千图小兔体(URLCONST.LAN_ZOUS_URL + "/iOONMicrkda"), + 手书体(URLCONST.LAN_ZOUS_URL + "/iqbmdicrkvi"), + 演示春风楷(URLCONST.LAN_ZOUS_URL + "/ioRJSicrldg"), + 演示秋鸿楷(URLCONST.LAN_ZOUS_URL + "/i8qnzicrlsb"), + 演示夏行楷(URLCONST.LAN_ZOUS_URL + "/iyYUTicrm6f"), + 演示悠然小楷(URLCONST.LAN_ZOUS_URL + "/ikKq7icrmrg"), + 杨任东竹石体(URLCONST.LAN_ZOUS_URL + "/iiWdVicrnbg"), + 站酷仓耳渔阳体(URLCONST.LAN_ZOUS_URL + "/if5weicrnje"), + 迷你隶书( URLCONST.LAN_ZOUS_URL + "/ihaXVe6kekj"), + 方正黄草(URLCONST.LAN_ZOUS_URL + "/iQg67e6keed"); public String downloadPath; diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/AboutActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/AboutActivity.java index 979a87b..917abef 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/AboutActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/AboutActivity.java @@ -14,6 +14,7 @@ import java.io.File; import io.reactivex.Observable; import io.reactivex.ObservableOnSubscribe; +import io.reactivex.disposables.Disposable; import xyz.fycz.myreader.R; import xyz.fycz.myreader.application.App; import xyz.fycz.myreader.base.BaseActivity; @@ -22,6 +23,7 @@ import xyz.fycz.myreader.common.APPCONST; import xyz.fycz.myreader.common.URLCONST; import xyz.fycz.myreader.databinding.ActivityAboutBinding; import xyz.fycz.myreader.ui.dialog.DialogCreator; +import xyz.fycz.myreader.ui.dialog.LoadingDialog; import xyz.fycz.myreader.util.ShareUtils; import xyz.fycz.myreader.util.SharedPreUtils; import xyz.fycz.myreader.util.ToastUtils; @@ -73,7 +75,9 @@ public class AboutActivity extends BaseActivity { SharedPreUtils.getInstance().getString(getString(R.string.downloadLink), URLCONST.LAN_ZOUS_URL))); binding.il.vwUpdate.setOnClickListener(v -> App.checkVersionByServer(this, true)); binding.il.vwUpdateLog.setOnClickListener(v -> DialogCreator.createAssetTipDialog(this, "更新日志", "updatelog.fy")); - binding.il.vwShareLog.setOnClickListener(v -> shareCrashLog()); + binding.il.vwShareLog.setOnClickListener(v -> DialogCreator.createCommonDialog(this, "分享崩溃日志", + "你是希望将日志上传到服务器,还是直接分享给他人?", true, + "上传服务器", "直接分享", (dialog, which) -> uploadCrashLog(), (dialog, which) -> shareCrashLog())); binding.il.vwQq.setOnClickListener(v -> { if (!App.joinQQGroup(this, "8PIOnHFuH6A38hgxvD_Rp2Bu-Ke1ToBn")) { //数据 @@ -99,16 +103,21 @@ public class AboutActivity extends BaseActivity { } - private void updateCrashLog() { + private void uploadCrashLog() { File logDir = new File(APPCONST.LOG_DIR); if (!logDir.exists() || logDir.listFiles() == null || logDir.listFiles().length == 0) { ToastUtils.showWarring("没有日志文件"); return; } + final Disposable[] disposable = new Disposable[1]; + LoadingDialog dialog = new LoadingDialog(this, "正在上传", () -> { + if (disposable[0] != null) disposable[0].dispose(); + }); + dialog.show(); + String time = String.valueOf(System.currentTimeMillis()); + String fileName = "log-" + time + ".zip"; + String logZip = FileUtils.getCachePath() + File.separator + fileName; Observable.create((ObservableOnSubscribe) emitter -> { - String time = String.valueOf(System.currentTimeMillis()); - String fileName = "log-" + time + ".zip"; - String logZip = FileUtils.getCachePath() + File.separator + fileName; File zipFile = FileUtils.getFile(logZip); if (ZipUtils.zipFile(logDir, zipFile)) { emitter.onNext(OkHttpUtils.upload(URLCONST.LOG_UPLOAD_URL, logZip, fileName)); @@ -117,14 +126,24 @@ public class AboutActivity extends BaseActivity { } emitter.onComplete(); }).compose(RxUtils::toSimpleSingle).subscribe(new MyObserver() { + @Override + public void onSubscribe(Disposable d) { + disposable[0] = d; + } + @Override public void onNext(@NotNull String s) { ToastUtils.showInfo(s); + FileUtils.deleteFile(APPCONST.LOG_DIR); + FileUtils.deleteFile(logZip); + dialog.dismiss(); } @Override public void onError(Throwable e) { ToastUtils.showError(e.getLocalizedMessage()); + FileUtils.deleteFile(logZip); + dialog.dismiss(); } }); @@ -150,7 +169,7 @@ public class AboutActivity extends BaseActivity { }).compose(RxUtils::toSimpleSingle).subscribe(new MyObserver() { @Override public void onNext(@NotNull File file) { - ShareUtils.share(AboutActivity.this, file, file.getName(), "application/x-zip-compressed"); + ShareUtils.share(AboutActivity.this, file, "分享日志文件", "application/x-zip-compressed"); } @Override diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookInfoEditActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookInfoEditActivity.java index 6d47afe..8c0691e 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/BookInfoEditActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/BookInfoEditActivity.java @@ -8,6 +8,8 @@ import android.view.MenuItem; import androidx.appcompat.widget.Toolbar; +import java.util.Objects; + import xyz.fycz.myreader.R; import xyz.fycz.myreader.application.App; import xyz.fycz.myreader.base.BaseActivity; @@ -154,9 +156,9 @@ public class BookInfoEditActivity extends BaseActivity { } private boolean hasChange() { - return !bookName.equals(binding.tieBookName.getText().toString()) || - !author.equals(binding.tieBookAuthor.getText().toString()) || - !imgUrl.equals(binding.tieCoverUrl.getText().toString()) || - !desc.equals(binding.tieBookDesc.getText().toString()); + return !Objects.equals(bookName, binding.tieBookName.getText().toString()) || + !Objects.equals(author, binding.tieBookAuthor.getText().toString()) || + !Objects.equals(imgUrl, binding.tieCoverUrl.getText().toString()) || + !Objects.equals(desc, binding.tieBookDesc.getText().toString()); } } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java index fbef284..750c1e8 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/MainActivity.java @@ -143,7 +143,10 @@ public class MainActivity extends BaseActivity { super.initClick(); mToolbar.setOnLongClickListener(v -> { - if (binding.viewPagerMain.getCurrentItem() == 0 && !BookGroupService.getInstance().curGroupIsPrivate()) { + if (binding.viewPagerMain.getCurrentItem() == 0 && + !BookGroupService.getInstance().curGroupIsPrivate() && + (mBookcaseFragment.getmBookcasePresenter() != null && + !mBookcaseFragment.getmBookcasePresenter().ismEditState())) { goPrivateBookcase(); return true; } diff --git a/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java b/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java index d01db4c..2102244 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/presenter/BookcasePresenter.java @@ -554,6 +554,9 @@ public class BookcasePresenter implements BasePresenter { if (canEditBookcase()) { mMainActivity.getViewPagerMain().setEnableScroll(false); mBookcaseFragment.getSrlContent().setEnableRefresh(false); + if (mSetting.getSortStyle() == 0){ + ToastUtils.showInfo("长按可移动书籍哦!"); + } itemTouchCallback.setLongPressDragEnable(mSetting.getSortStyle() == 0); mBookcaseAdapter.setmEditState(true); mBookcaseFragment.getRlBookEdit().setVisibility(View.VISIBLE); diff --git a/app/src/main/java/xyz/fycz/myreader/util/UriFileUtil.java b/app/src/main/java/xyz/fycz/myreader/util/UriFileUtil.java index e173ef7..d461ffa 100644 --- a/app/src/main/java/xyz/fycz/myreader/util/UriFileUtil.java +++ b/app/src/main/java/xyz/fycz/myreader/util/UriFileUtil.java @@ -93,113 +93,72 @@ public class UriFileUtil { */ public static String getPath(final Context context, final Uri uri) { - - final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; - // DocumentProvider - if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) { - // ExternalStorageProvider - if (isExternalStorageDocument(uri)) { - final String docId = DocumentsContract.getDocumentId(uri); - final String[] split = docId.split(":"); - final String type = split[0]; - if ("primary".equalsIgnoreCase(type)) { - return Environment.getExternalStorageDirectory() + "/" + split[1]; - } - - // TODO handle non-primary volumes - } - // DownloadsProvider - else if (isDownloadsDocument(uri)) { - - final String id = DocumentsContract.getDocumentId(uri); + final String[] split = id.split(":"); + final String type = split[0]; + if ("raw".equalsIgnoreCase(type)) { //处理某些机型(比如Goole Pixel )ID是raw:/storage/emulated/0/Download/c20f8664da05ab6b4644913048ea8c83.mp4 + return split[1]; + } final Uri contentUri = ContentUris.withAppendedId( - Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); - return getDataColumn(context, contentUri, null, null); - } - // MediaProvider - else if (isMediaDocument(uri)) { - final String docId = DocumentsContract.getDocumentId(uri); - final String[] split = docId.split(":"); - final String type = split[0]; - Uri contentUri = null; - if ("image".equals(type)) { - contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; - } else if ("video".equals(type)) { - contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; - } else if ("audio".equals(type)) { - contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; - } - final String selection = "_id=?"; - final String[] selectionArgs = new String[]{ - split[1] - }; - return getDataColumn(context, contentUri, selection, selectionArgs); - } - } - // MediaStore (and general) - else if ("content".equalsIgnoreCase(uri.getScheme())) { - return getDataColumn(context, uri, null, null); + // Return the remote address + if (isGooglePhotosUri(uri)) + return uri.getLastPathSegment(); + return getDataColumn(context, uri, null, null); } - // File - else if ("file".equalsIgnoreCase(uri.getScheme())) { - return uri.getPath(); - } - return null; } @@ -218,45 +177,21 @@ public class UriFileUtil { */ public static String getDataColumn(Context context, Uri uri, String selection, - String[] selectionArgs) { - - - Cursor cursor = null; - final String column = "_data"; - final String[] projection = { - column - }; - - - try { - - cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, - - null); - + try (Cursor cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, + null)) { if (cursor != null && cursor.moveToFirst()) { - - final int column_index = cursor.getColumnIndexOrThrow(column); - - return cursor.getString(column_index); - + final int index = cursor.getColumnIndexOrThrow(column); + return cursor.getString(index); } - - } finally { - - if (cursor != null) - - cursor.close(); - + } catch (Exception e) { + e.printStackTrace(); } - return null; - } @@ -294,4 +229,12 @@ public class UriFileUtil { return "com.android.providers.media.documents".equals(uri.getAuthority()); } + + /** + * @param uri The Uri to check. + * @return Whether the Uri authority is Google Photos. + */ + public static boolean isGooglePhotosUri(Uri uri) { + return "com.google.android.apps.photos.content".equals(uri.getAuthority()); + } } diff --git a/app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java b/app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java index 56aec1b..c58f9bd 100644 --- a/app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java +++ b/app/src/main/java/xyz/fycz/myreader/util/utils/OkHttpUtils.java @@ -331,8 +331,7 @@ public class OkHttpUtils { OkHttpClient client = getOkHttpClient(); RequestBody requestBody = new MultipartBody.Builder() .setType(MultipartBody.FORM) - .addFormDataPart("file", fileName, - RequestBody.create(MediaType.parse("multipart/form-data"), new File(filePath))) + .addFormDataPart("file", fileName, RequestBody.create(MediaType.parse("multipart/form-data"), new File(filePath))) .build(); Request request = new Request.Builder() diff --git a/app/src/main/res/drawable/ic_edit.xml b/app/src/main/res/drawable/ic_edit.xml index 94df902..2d249dd 100644 --- a/app/src/main/res/drawable/ic_edit.xml +++ b/app/src/main/res/drawable/ic_edit.xml @@ -1,12 +1,14 @@ + - - - + android:viewportWidth="24" + android:viewportHeight="24"> + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_share.xml b/app/src/main/res/drawable/ic_share.xml index 3ce5e52..962f615 100644 --- a/app/src/main/res/drawable/ic_share.xml +++ b/app/src/main/res/drawable/ic_share.xml @@ -1,9 +1,11 @@ + android:width="20dp" + android:height="20dp" + android:viewportWidth="24" + android:viewportHeight="24"> + + android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z" + android:fillColor="#FFFFFF" /> + diff --git a/app/src/main/res/drawable/ic_top.xml b/app/src/main/res/drawable/ic_top.xml index aa0c2e6..0b19c9c 100644 --- a/app/src/main/res/drawable/ic_top.xml +++ b/app/src/main/res/drawable/ic_top.xml @@ -1,9 +1,14 @@ + - - + android:viewportWidth="24" + android:viewportHeight="24"> + + + + \ No newline at end of file diff --git a/app/version_code.properties b/app/version_code.properties index 39ff7ff..3866553 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Thu Jun 03 14:18:11 CST 2021 -VERSION_CODE=207 +#Fri Jun 04 20:20:53 CST 2021 +VERSION_CODE=208