├── app ├── .gitignore ├── src │ ├── main │ │ ├── aidl │ │ │ └── com │ │ │ │ └── chumu │ │ │ │ └── dt │ │ │ │ └── io │ │ │ │ ├── User.aidl │ │ │ │ └── IMyAidlInterface.aidl │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── layout │ │ │ │ └── activity_main.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── chumu │ │ │ │ └── dt │ │ │ │ └── io │ │ │ │ ├── User.java │ │ │ │ └── ChuMuMainActivity.java │ │ └── AndroidManifest.xml │ └── test │ │ └── java │ │ └── com │ │ └── chumu │ │ └── dt │ │ └── io │ │ └── ExampleUnitTest.java ├── build.gradle └── proguard-rules.pro ├── magic-box ├── .gitignore ├── libs │ └── BASE64Decoder.jar ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ │ ├── drawable │ │ │ │ ├── shadow_bottom.png │ │ │ │ ├── shadow_left.png │ │ │ │ └── shadow_right.png │ │ │ ├── anim │ │ │ │ ├── chumu_dialog_ui_exit.xml │ │ │ │ ├── chumu_dialog_ui_enter.xml │ │ │ │ ├── anim_bottom_in.xml │ │ │ │ ├── anim_bottom_out.xml │ │ │ │ ├── anim_left_in.xml │ │ │ │ ├── anim_left_out.xml │ │ │ │ ├── anim_right_in.xml │ │ │ │ ├── anim_right_out.xml │ │ │ │ ├── anim_top_in.xml │ │ │ │ └── anim_top_out.xml │ │ │ ├── layout │ │ │ │ └── swipeback_layout.xml │ │ │ └── values │ │ │ │ ├── styles.xml │ │ │ │ └── attrs.xml │ │ └── java │ │ │ └── com │ │ │ └── chumu │ │ │ └── dt │ │ │ └── v24 │ │ │ └── magicbox │ │ │ ├── appbox │ │ │ ├── NotSingOnEvent.java │ │ │ ├── NotSignException.java │ │ │ ├── ChuMuAppUtils.java │ │ │ ├── ChuMuAppLogMessageManager.java │ │ │ ├── GlobalCrashCapture.java │ │ │ ├── ChumuVersionUtil.java │ │ │ ├── ChuMuAppInfoManager.java │ │ │ ├── ChuMuAppCleanManager.java │ │ │ ├── ChuMuPermission.java │ │ │ ├── ChuMuTimeRefresher.java │ │ │ └── ChuMuDisplayUtils.java │ │ │ ├── basedialogframgent │ │ │ ├── aosp │ │ │ │ └── ChuMuDialogFragment.java │ │ │ ├── utils │ │ │ │ ├── weakproxy │ │ │ │ │ ├── WeakOnShowListener.java │ │ │ │ │ ├── WeakOnCancelListener.java │ │ │ │ │ └── WeakOnDismissListener.java │ │ │ │ └── Weak.java │ │ │ ├── BaseDialogFragment.md │ │ │ ├── dialog │ │ │ │ ├── WeakDialog.java │ │ │ │ └── CancelableDialog.java │ │ │ └── androidx │ │ │ │ └── ChuMuBaseDialogFragment.java │ │ │ ├── swipeback │ │ │ ├── ChuMuSwipeBack.java │ │ │ ├── util │ │ │ │ ├── SwipeBackActivityBase.java │ │ │ │ ├── SwipeBackListenerActivityAdapter.java │ │ │ │ ├── SwipeBackActivityHelper.java │ │ │ │ └── SwipeBackUtil.java │ │ │ ├── SwipeBack.md │ │ │ └── ChuMuSwipeBackActivity.java │ │ │ ├── livedatabus │ │ │ ├── event │ │ │ │ ├── ChuMuEvent.kt │ │ │ │ ├── ChuMuDefaultChuMuEvent.kt │ │ │ │ └── ChuMuStickinessEvent.kt │ │ │ ├── LiveDataBus.md │ │ │ └── ChuMuLiveDataBus.kt │ │ │ ├── ChuMuRandomColor.java │ │ │ ├── klog │ │ │ ├── ChuMuKLogUtil.java │ │ │ └── base │ │ │ │ ├── JsonLog.java │ │ │ │ ├── ChuMuBaseLog.java │ │ │ │ ├── XmlLog.java │ │ │ │ └── FileLog.java │ │ │ ├── encryption │ │ │ ├── ChuMuSHAUtils.java │ │ │ ├── ChuMuDESUtils.java │ │ │ ├── ChuMuTripleDESUtils.java │ │ │ ├── ChuMuAESUtils.java │ │ │ ├── ChuMuMD5Utils.java │ │ │ ├── ChuMuCipherUtils.java │ │ │ └── ChuMuConvertUtils.java │ │ │ ├── base │ │ │ └── ChuMuBaseActivity.java │ │ │ ├── ChuMuFramgentManager.java │ │ │ ├── ChuMuDynamicPermissions.java │ │ │ ├── wiget │ │ │ └── WIGET.md │ │ │ └── anim │ │ │ └── RxAnimationTool.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── chumu │ │ │ └── dt │ │ │ └── v24 │ │ │ └── magicbox │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── chumu │ │ └── dt │ │ └── v24 │ │ └── magicbox │ │ └── ExampleInstrumentedTest.java ├── build.gradle └── proguard-rules.pro ├── _config.yml ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea ├── encodings.xml ├── vcs.xml ├── runConfigurations.xml ├── misc.xml ├── gradle.xml └── codeStyles │ └── Project.xml ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── README.md └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /magic-box/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-leap-day -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':magic-box' 2 | -------------------------------------------------------------------------------- /app/src/main/aidl/com/chumu/dt/io/User.aidl: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.io; 2 | parcelable User; -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ChuMuYa 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15335179243/ChuMuYa/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /magic-box/libs/BASE64Decoder.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15335179243/ChuMuYa/HEAD/magic-box/libs/BASE64Decoder.jar -------------------------------------------------------------------------------- /magic-box/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15335179243/ChuMuYa/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15335179243/ChuMuYa/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15335179243/ChuMuYa/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15335179243/ChuMuYa/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15335179243/ChuMuYa/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /magic-box/src/main/res/drawable/shadow_bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15335179243/ChuMuYa/HEAD/magic-box/src/main/res/drawable/shadow_bottom.png -------------------------------------------------------------------------------- /magic-box/src/main/res/drawable/shadow_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15335179243/ChuMuYa/HEAD/magic-box/src/main/res/drawable/shadow_left.png -------------------------------------------------------------------------------- /magic-box/src/main/res/drawable/shadow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15335179243/ChuMuYa/HEAD/magic-box/src/main/res/drawable/shadow_right.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15335179243/ChuMuYa/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15335179243/ChuMuYa/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15335179243/ChuMuYa/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15335179243/ChuMuYa/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/15335179243/ChuMuYa/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /magic-box/src/main/res/anim/chumu_dialog_ui_exit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | -------------------------------------------------------------------------------- /magic-box/src/main/res/anim/chumu_dialog_ui_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Jun 11 00:04:29 CST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /magic-box/src/main/res/layout/swipeback_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/appbox/NotSingOnEvent.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.appbox; 2 | 3 | /** 4 | * ChuMuYa 5 | *

6 | * Created by ChuMu on 2020/8/14 7 | * Copyright © 2020年 ChuMu. All rights reserved. 8 | *

9 | * Describe :未登录回调 10 | */ 11 | 12 | public interface NotSingOnEvent { 13 | void onSingEvent (); 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /magic-box/src/main/res/anim/anim_bottom_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 11 | -------------------------------------------------------------------------------- /magic-box/src/main/res/anim/anim_bottom_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 11 | -------------------------------------------------------------------------------- /magic-box/src/main/res/anim/anim_left_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 11 | -------------------------------------------------------------------------------- /magic-box/src/main/res/anim/anim_left_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 11 | -------------------------------------------------------------------------------- /magic-box/src/main/res/anim/anim_right_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 11 | -------------------------------------------------------------------------------- /magic-box/src/main/res/anim/anim_right_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 11 | -------------------------------------------------------------------------------- /magic-box/src/main/res/anim/anim_top_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 11 | -------------------------------------------------------------------------------- /magic-box/src/main/res/anim/anim_top_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/appbox/NotSignException.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.appbox; 2 | 3 | /** 4 | * ChuMuYa 5 | *

6 | * Created by ChuMu on 2020/8/14 7 | * Copyright © 2020年 ChuMu. All rights reserved. 8 | *

9 | * Describe 没有登录抛出的异常: 10 | */ 11 | 12 | public class NotSignException extends RuntimeException{ 13 | 14 | public NotSignException(String e) { 15 | super(e); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/test/java/com/chumu/dt/io/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.io; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /magic-box/src/test/java/com/chumu/dt/v24/magicbox/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/aidl/com/chumu/dt/io/IMyAidlInterface.aidl: -------------------------------------------------------------------------------- 1 | // IMyAidlInterface.aidl 2 | package com.chumu.dt.io; 3 | import com.chumu.dt.io.User; 4 | // Declare any non-default types here with import statements 5 | 6 | interface IMyAidlInterface { 7 | //定义与自定义类型相关的业务 8 | void getWorkInfo(); 9 | /** 10 | * Demonstrates some basic types that you can use as parameters 11 | * and return values in AIDL. 12 | */ 13 | User getUser(String name); 14 | void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat, 15 | double aDouble, String aString); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/basedialogframgent/aosp/ChuMuDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.basedialogframgent.aosp; 2 | 3 | import android.app.Dialog; 4 | import android.os.Bundle; 5 | 6 | 7 | import androidx.fragment.app.FixDialogFragment; 8 | import com.chumu.dt.v24.magicbox.basedialogframgent.dialog.WeakDialog; 9 | 10 | import org.jetbrains.annotations.NotNull; 11 | 12 | 13 | public class ChuMuDialogFragment extends FixDialogFragment { 14 | @NotNull 15 | @Override 16 | public Dialog onCreateDialog(Bundle savedInstanceState) { 17 | return new WeakDialog(getActivity(), getTheme()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/swipeback/ChuMuSwipeBack.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.swipeback; 2 | 3 | 4 | import java.lang.annotation.Documented; 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * ChuMuYa 12 | *

13 | * Created by ChuMu on 2020/8/4 14 | * Copyright © 2020年 ChuMu. All rights reserved. 15 | *

16 | * Describe: 侧滑返回 17 | * @version: v11-2.0.6-beta 18 | */ 19 | @Target(ElementType.TYPE) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Documented 22 | public @interface ChuMuSwipeBack { 23 | boolean value() default false; 24 | } 25 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/swipeback/util/SwipeBackActivityBase.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.swipeback.util; 2 | 3 | /** 4 | * ChuMuYa 5 | *

6 | * Created by ChuMu on 2020/8/4 7 | * Copyright © 2020年 ChuMu. All rights reserved. 8 | *

9 | * Describe: 侧滑返回 10 | * @version: v11-2.0.6-beta 11 | */ 12 | public interface SwipeBackActivityBase { 13 | /** 14 | * @return the SwipeBackLayout associated with this activity. 15 | */ 16 | SwipeBackLayout getSwipeBackLayout(); 17 | 18 | void setSwipeBackEnable(boolean enable); 19 | 20 | /** 21 | * Scroll out contentView and finish the activity 22 | */ 23 | void scrollToFinishActivity(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 20 | 21 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/basedialogframgent/utils/weakproxy/WeakOnShowListener.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.basedialogframgent.utils.weakproxy; 2 | 3 | import android.content.DialogInterface; 4 | 5 | import java.lang.ref.WeakReference; 6 | 7 | public class WeakOnShowListener implements DialogInterface.OnShowListener { 8 | private WeakReference mRef; 9 | 10 | public WeakOnShowListener(DialogInterface.OnShowListener real) { 11 | this.mRef = new WeakReference<>(real); 12 | } 13 | 14 | @Override 15 | public void onShow(DialogInterface dialog) { 16 | DialogInterface.OnShowListener real = mRef.get(); 17 | if (real != null) { 18 | real.onShow(dialog); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/basedialogframgent/utils/weakproxy/WeakOnCancelListener.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.basedialogframgent.utils.weakproxy; 2 | 3 | import android.content.DialogInterface; 4 | 5 | import java.lang.ref.WeakReference; 6 | 7 | public class WeakOnCancelListener implements DialogInterface.OnCancelListener { 8 | private WeakReference mRef; 9 | 10 | public WeakOnCancelListener(DialogInterface.OnCancelListener real) { 11 | this.mRef = new WeakReference<>(real); 12 | } 13 | 14 | @Override 15 | public void onCancel(DialogInterface dialog) { 16 | DialogInterface.OnCancelListener real = mRef.get(); 17 | if (real != null) { 18 | real.onCancel(dialog); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/basedialogframgent/utils/weakproxy/WeakOnDismissListener.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.basedialogframgent.utils.weakproxy; 2 | 3 | import android.content.DialogInterface; 4 | 5 | import java.lang.ref.WeakReference; 6 | 7 | public class WeakOnDismissListener implements DialogInterface.OnDismissListener { 8 | private WeakReference mRef; 9 | 10 | public WeakOnDismissListener(DialogInterface.OnDismissListener real) { 11 | this.mRef = new WeakReference<>(real); 12 | } 13 | 14 | @Override 15 | public void onDismiss(DialogInterface dialog) { 16 | DialogInterface.OnDismissListener real = mRef.get(); 17 | if (real != null) { 18 | real.onDismiss(dialog); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | 15 | 16 | android.useAndroidX=true 17 | android.enableJetifier=true -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/livedatabus/event/ChuMuEvent.kt: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.livedatabus.event 2 | 3 | import androidx.activity.ComponentActivity 4 | import androidx.fragment.app.Fragment 5 | import androidx.lifecycle.Observer 6 | 7 | interface ChuMuEvent { 8 | 9 | /** 10 | * 仅更新处于活动生命周期状态的应用程序组件观察者 11 | */ 12 | fun observe(activity: ComponentActivity, observer: Observer) 13 | 14 | /** 15 | * 仅更新处于活动生命周期状态的应用程序组件观察者 16 | */ 17 | fun observe(fragment: Fragment, observer: Observer) 18 | 19 | /** 20 | * 不受生命周期的影响,只要数据更新就会收到通知 21 | */ 22 | fun observeForever(activity: ComponentActivity, observer: Observer) 23 | 24 | /** 25 | * 不受生命周期的影响,只要数据更新就会收到通知 26 | */ 27 | fun observeForever(fragment: Fragment, observer: Observer) 28 | } -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 20 | 21 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/ChuMuRandomColor.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox; 2 | 3 | import android.graphics.Color; 4 | 5 | import java.util.Random; 6 | 7 | /** 8 | * 随机获取一款颜色值 9 | * */ 10 | public class ChuMuRandomColor { 11 | 12 | private static String getRandColorCode() { 13 | String r, g, b; 14 | Random random = new Random(); 15 | r = Integer.toHexString(random.nextInt(256)).toUpperCase(); 16 | g = Integer.toHexString(random.nextInt(256)).toUpperCase(); 17 | b = Integer.toHexString(random.nextInt(256)).toUpperCase(); 18 | 19 | r = r.length() == 1 ? "0" + r : r; 20 | g = g.length() == 1 ? "0" + g : g; 21 | b = b.length() == 1 ? "0" + b : b; 22 | 23 | return "#"+r + g + b; 24 | } 25 | public static int onRandomColor() { 26 | return Color.parseColor(getRandColorCode()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /magic-box/src/androidTest/java/com/chumu/dt/v24/magicbox/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox; 2 | 3 | import android.content.Context; 4 | 5 | 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | 9 | import androidx.test.InstrumentationRegistry; 10 | import androidx.test.ext.junit.runners.AndroidJUnit4; 11 | 12 | import static org.junit.Assert.*; 13 | 14 | /** 15 | * Instrumented test, which will execute on an Android device. 16 | * 17 | * @see Testing documentation 18 | */ 19 | @RunWith(AndroidJUnit4.class) 20 | public class ExampleInstrumentedTest { 21 | @Test 22 | public void useAppContext() { 23 | // Context of the app under test. 24 | Context appContext = InstrumentationRegistry.getTargetContext(); 25 | 26 | assertEquals("com.chumu.dt.v24.permissions.test", appContext.getPackageName()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/chumu/dt/io/User.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.io; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | /** 7 | * ChuMuYa 8 | *

9 | * Created by ChuMu on 2020/8/12 10 | * Copyright © 2020年 ChuMu. All rights reserved. 11 | *

12 | * Describe: 13 | */ 14 | 15 | public class User implements Parcelable { 16 | protected User(Parcel in) { 17 | } 18 | 19 | public static final Creator CREATOR = new Creator() { 20 | @Override 21 | public User createFromParcel(Parcel in) { 22 | return new User(in); 23 | } 24 | 25 | @Override 26 | public User[] newArray(int size) { 27 | return new User[size]; 28 | } 29 | }; 30 | 31 | @Override 32 | public int describeContents() { 33 | return 0; 34 | } 35 | 36 | @Override 37 | public void writeToParcel(Parcel dest, int flags) { 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/basedialogframgent/utils/Weak.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.basedialogframgent.utils; 2 | 3 | import android.content.DialogInterface; 4 | 5 | import com.chumu.dt.v24.magicbox.basedialogframgent.utils.weakproxy.WeakOnCancelListener; 6 | import com.chumu.dt.v24.magicbox.basedialogframgent.utils.weakproxy.WeakOnDismissListener; 7 | import com.chumu.dt.v24.magicbox.basedialogframgent.utils.weakproxy.WeakOnShowListener; 8 | 9 | 10 | public class Weak { 11 | public static WeakOnCancelListener proxy(DialogInterface.OnCancelListener real) { 12 | return new WeakOnCancelListener(real); 13 | } 14 | 15 | public static WeakOnDismissListener proxy(DialogInterface.OnDismissListener real) { 16 | return new WeakOnDismissListener(real); 17 | } 18 | 19 | public static WeakOnShowListener proxy(DialogInterface.OnShowListener real) { 20 | return new WeakOnShowListener(real); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/swipeback/SwipeBack.md: -------------------------------------------------------------------------------- 1 | # ChuMuSwipeBack侧滑返回 2 | ## 使用方式: 3 | 1. 继承[ChuMuBaseActivity](https://github.com/15335179243/ChuMuYa/blob/master/magic-box/src/main/java/com/chumu/dt/v24/magicbox/base/ChuMuBaseActivity.java) 4 | ,然后在你需要侧滑返回的Activity中使用注解,如果你所有类里面都需要注解的话你可以直接继承 [ChuMuSwipeBackActivity](https://github.com/15335179243/ChuMuYa/blob/master/magic-box/src/main/java/com/chumu/dt/v24/magicbox/swipeback/ChuMuSwipeBackActivity.java) 5 | 6 | ```java 7 | /** 8 | *像这样写到你需要侧滑返回的Activity类上面 9 | */ 10 | @ChuMuSwipeBack(true) 11 | public class ChuMuMainActivity extends AppCompatActivity { 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_main); 17 | 18 | } 19 | } 20 | 21 | ``` 22 | 23 | 此效果使用到的框架来源于开源的 @ikew0ng 的 SwipeBackLayout() 开源协议为 Apache License2.0 -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/klog/ChuMuKLogUtil.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.klog; 2 | 3 | /** 4 | * @Description:主要功能: 5 | * @Prject: magic-box 6 | * @date: 2017年05月16日 16:54 7 | * @Copyright: 共有开源知识版权 8 | * @Company: 9 | * @version: v11-2.0.6-beta 10 | */ 11 | 12 | import android.text.TextUtils; 13 | 14 | 15 | /** 16 | * Created byChuMU on 15/12/11. 17 | */ 18 | public class ChuMuKLogUtil { 19 | 20 | public static boolean isEmpty(String line) { 21 | return TextUtils.isEmpty(line) || line.equals("\n") || line.equals("\t") || TextUtils.isEmpty(line.trim()); 22 | } 23 | 24 | public static void printLine(String tag, boolean isTop) { 25 | if (isTop) { 26 | ChuMuKLog.e(tag, "╔═══════════════════════════════════════════════════════════════════════════════════════"); 27 | } else { 28 | ChuMuKLog.e(tag, "╚═══════════════════════════════════════════════════════════════════════════════════════"); 29 | } 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/basedialogframgent/BaseDialogFragment.md: -------------------------------------------------------------------------------- 1 | # DialogFragment内存泄漏解决方案 2 | 3 | ![](https://upload-images.jianshu.io/upload_images/172542-bf69455807784805.png?imageMogr2/auto-orient/strip|imageView2/2/w/273/format/webp) 4 | 5 | ​ **内存泄漏引用链** 6 | 7 | 上图是DialogFragment泄露的典型路径,引用链根部的HandlerThread可能是app中任何一个HandlerThread。DialogFragment内存泄漏问题覆盖Android全部版本(目前最高版本Q),其泄漏的根源与Dialog有关,也就是说,Dialog导致的内存泄漏同样覆盖了Android全部版本。 8 | 9 | (源码参考AOSP android-9.0.0_r34分支) 10 | 11 | 这边进行源码的修改 [FixDialogFragment](https://github.com/15335179243/ChuMuYa/blob/master/magic-box/src/main/java/androidx/fragment/app/FixDialogFragment.java) 12 | 13 | 使用可以直接继承[ChuMuBaseDialogFragment](https://github.com/15335179243/ChuMuYa/blob/master/magic-box/src/main/java/com/chumu/dt/v24/magicbox/basedialogframgent/androidx/ChuMuBaseDialogFragment.java) 14 | 15 | 也可以继承[ChuMuDialogFragment](https://github.com/15335179243/ChuMuYa/blob/master/magic-box/src/main/java/com/chumu/dt/v24/magicbox/basedialogframgent/aosp/ChuMuDialogFragment.java) 16 | 17 | 前者是已经封装好的写布局就可以,后者需要自己写. -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/livedatabus/LiveDataBus.md: -------------------------------------------------------------------------------- 1 | # ChuMuLiveDataBus 2 | 3 | ##### 基于LiveData实现事件总线, 4 | 5 | 6 | 7 | ##### 具备生命周期感知,感知确保LiveData仅更新处于活动生命周期状态的应用程序组件观察者, 8 | 9 | ##### 支持粘性,消息发送后订阅也能收到发出的消息,但是只能收到订阅前发送的最后一条消息 10 | 11 | ### 阅普通事件消息 12 | 13 | ``` 14 | //仅更新处于活动生命周期状态的应用程序组件观察者 15 | ChuMuLiveDataBus.with("tag") 16 | .observe(this, Observer { 17 | toast("收到普通事件消息:${it.toString()}") 18 | }) 19 | 20 | //不受生命周期的影响,只要数据更新就会收到通知 21 | ChuMuLiveDataBus.with("tag") 22 | .observeForever(this, Observer { 23 | toast("收到普通事件消息:${it.toString()}") 24 | }) 25 | ``` 26 | 27 | ### 发送普通事件消息 28 | 29 | ``` 30 | ChuMuLiveDataBus.send("tag", "发送一条消息") 31 | ``` 32 | 33 | ## 订阅粘性事件消息 34 | 35 | ``` 36 | //仅更新处于活动生命周期状态的应用程序组件观察者 37 | ChuMuLiveDataBus.withStickiness("tag") 38 | .observe(this, Observer { 39 | toast("收到粘性事件消息:${it.toString()}") 40 | }) 41 | 42 | //不受生命周期的影响,只要数据更新就会收到通知 43 | ChuMuLiveDataBus.withStickiness("tag") 44 | .observeForever(this, Observer { 45 | toast("收到粘性事件消息:${it.toString()}") 46 | }) 47 | ``` 48 | 49 | ### 发送粘性事件消息 50 | 51 | ``` 52 | ChuMuLiveDataBus.sendStickiness("tag", "发送一条消息") 53 | ``` -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | compileSdkVersion 28 7 | defaultConfig { 8 | applicationId "com.chumu.dt.io" 9 | // applicationId "adb uninstall com.chumu.dt.io" 10 | minSdkVersion 15 11 | targetSdkVersion 28 12 | versionCode 1 13 | versionName "1.0" 14 | 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | implementation fileTree(dir: 'libs', include: ['*.jar']) 26 | implementation 'androidx.appcompat:appcompat:1.1.0' 27 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 28 | testImplementation 'junit:junit:4.12' 29 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 30 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 31 | implementation project(path: ':magic-box') 32 | implementation 'androidx.constraintlayout:constraintlayout:2.0.0-rc1' 33 | // implementation 'com.sunfusheng:MarqueeView:1.4.1' 34 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 35 | } 36 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/basedialogframgent/dialog/WeakDialog.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.basedialogframgent.dialog; 2 | 3 | import android.app.Dialog; 4 | import android.content.Context; 5 | 6 | import com.chumu.dt.v24.magicbox.basedialogframgent.utils.Weak; 7 | 8 | import androidx.annotation.NonNull; 9 | import androidx.annotation.Nullable; 10 | 11 | 12 | 13 | 14 | public class WeakDialog extends Dialog { 15 | public WeakDialog(@NonNull Context context) { 16 | super(context); 17 | } 18 | 19 | public WeakDialog(@NonNull Context context, int themeResId) { 20 | super(context, themeResId); 21 | } 22 | 23 | protected WeakDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) { 24 | super(context, cancelable, cancelListener); 25 | } 26 | 27 | @Override 28 | public void setOnCancelListener(@Nullable OnCancelListener listener) { 29 | super.setOnCancelListener(Weak.proxy(listener)); 30 | } 31 | 32 | @Override 33 | public void setOnDismissListener(@Nullable OnDismissListener listener) { 34 | super.setOnDismissListener(Weak.proxy(listener)); 35 | } 36 | 37 | @Override 38 | public void setOnShowListener(@Nullable OnShowListener listener) { 39 | super.setOnShowListener(Weak.proxy(listener)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/encryption/ChuMuSHAUtils.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.encryption; 2 | 3 | import java.security.MessageDigest; 4 | import java.security.NoSuchAlgorithmException; 5 | 6 | /** 7 | * @Description:主要功能:SHA-1 加密 不可逆(Secure Hash Algorithm,安全散列算法) 8 | * @Prject: magic-box 9 | * @date: 2017年05月16日 15:57 10 | * @Copyright: 共有开源知识版权 11 | * @Company: 12 | * @version: v11-2.0.6-beta 13 | */ 14 | 15 | public class ChuMuSHAUtils { 16 | 17 | private ChuMuSHAUtils() { 18 | throw new UnsupportedOperationException("cannot be instantiated"); 19 | } 20 | 21 | /** 22 | * SHA-512 加密 23 | * @param data 24 | * @return 25 | */ 26 | public static String encryptSHA(byte[] data) { 27 | MessageDigest sha = null; 28 | try { 29 | sha = MessageDigest.getInstance("SHA-512"); 30 | sha.update(data); 31 | } catch (NoSuchAlgorithmException e) { 32 | e.printStackTrace(); 33 | } 34 | byte[] resultBytes = sha.digest(); 35 | StringBuilder builder = new StringBuilder(); 36 | for (int i = 0; i < resultBytes.length; i++) { 37 | if (Integer.toHexString(0xFF & resultBytes[i]).length() == 1) { 38 | builder.append("0").append( 39 | Integer.toHexString(0xFF & resultBytes[i])); 40 | } else { 41 | builder.append(Integer.toHexString(0xFF & resultBytes[i])); 42 | } 43 | } 44 | return builder.toString(); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/swipeback/util/SwipeBackListenerActivityAdapter.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.swipeback.util; 2 | 3 | import android.app.Activity; 4 | 5 | 6 | import androidx.annotation.NonNull; 7 | 8 | import java.lang.ref.WeakReference; 9 | 10 | 11 | /** 12 | * ChuMuYa 13 | *

14 | * Created by ChuMu on 2020/8/4 15 | * Copyright © 2020年 ChuMu. All rights reserved. 16 | *

17 | * Describe: 侧滑返回 18 | * @version: v11-2.0.6-beta 19 | */ 20 | public class SwipeBackListenerActivityAdapter implements SwipeBackLayout.SwipeListenerEx { 21 | private final WeakReference mActivity; 22 | 23 | public SwipeBackListenerActivityAdapter(@NonNull Activity activity) { 24 | mActivity = new WeakReference<>(activity); 25 | } 26 | 27 | @Override 28 | public void onScrollStateChange(int state, float scrollPercent) { 29 | 30 | } 31 | 32 | @Override 33 | public void onEdgeTouch(int edgeFlag) { 34 | Activity activity = mActivity.get(); 35 | if (null != activity) { 36 | SwipeBackUtil.convertActivityToTranslucent(activity); 37 | } 38 | } 39 | 40 | @Override 41 | public void onScrollOverThreshold() { 42 | 43 | } 44 | 45 | @Override 46 | public void onContentViewSwipedBack() { 47 | Activity activity = mActivity.get(); 48 | if (null != activity && !activity.isFinishing()) { 49 | activity.finish(); 50 | activity.overridePendingTransition(0, 0); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/swipeback/util/SwipeBackActivityHelper.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.swipeback.util; 2 | 3 | import android.app.Activity; 4 | import android.graphics.Color; 5 | import android.graphics.drawable.ColorDrawable; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | 9 | import com.chumu.dt.v24.magicbox.R; 10 | 11 | 12 | 13 | /** 14 | * ChuMuYa 15 | *

16 | * Created by ChuMu on 2020/8/4 17 | * Copyright © 2020年 ChuMu. All rights reserved. 18 | *

19 | * Describe: 侧滑返回 20 | * @version: v11-2.0.6-beta 21 | */ 22 | public class SwipeBackActivityHelper { 23 | private Activity mActivity; 24 | 25 | private SwipeBackLayout mSwipeBackLayout; 26 | 27 | public SwipeBackActivityHelper(Activity activity) { 28 | mActivity = activity; 29 | } 30 | 31 | 32 | public void onActivityCreate() { 33 | mActivity.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); 34 | mActivity.getWindow().getDecorView().setBackgroundDrawable(null); 35 | mSwipeBackLayout = (SwipeBackLayout) LayoutInflater.from(mActivity).inflate( 36 | R.layout.swipeback_layout, null); 37 | } 38 | 39 | public void onPostCreate() { 40 | mSwipeBackLayout.attachToActivity(mActivity); 41 | } 42 | 43 | public View findViewById(int id) { 44 | if (mSwipeBackLayout != null) { 45 | return mSwipeBackLayout.findViewById(id); 46 | } 47 | return null; 48 | } 49 | 50 | public SwipeBackLayout getSwipeBackLayout() { 51 | return mSwipeBackLayout; 52 | } 53 | } -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/klog/base/JsonLog.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.klog.base; 2 | 3 | /** 4 | * @Description:主要功能: 5 | * @Prject: magic-box 6 | * @date: 2017年05月16日 16:56 7 | * @Copyright: 共有开源知识版权 8 | * @Company: 9 | * @version: v11-2.0.6-beta 10 | */ 11 | 12 | 13 | 14 | import android.util.Log; 15 | 16 | import com.chumu.dt.v24.magicbox.klog.ChuMuKLog; 17 | import com.chumu.dt.v24.magicbox.klog.ChuMuKLogUtil; 18 | 19 | import org.json.JSONArray; 20 | import org.json.JSONException; 21 | import org.json.JSONObject; 22 | 23 | /** 24 | * Created by ChuMu on 15/11/18. 25 | */ 26 | public class JsonLog { 27 | 28 | public static void printJson(String tag, String msg, String headString) { 29 | 30 | String message; 31 | 32 | try { 33 | if (msg.startsWith("{")) { 34 | JSONObject jsonObject = new JSONObject(msg); 35 | message = jsonObject.toString(ChuMuKLog.JSON_INDENT); 36 | } else if (msg.startsWith("[")) { 37 | JSONArray jsonArray = new JSONArray(msg); 38 | message = jsonArray.toString(ChuMuKLog.JSON_INDENT); 39 | } else { 40 | message = msg; 41 | } 42 | } catch (JSONException e) { 43 | message = msg; 44 | } 45 | 46 | ChuMuKLogUtil.printLine(tag, true); 47 | message = headString + ChuMuKLog.LINE_SEPARATOR + message; 48 | String[] lines = message.split(ChuMuKLog.LINE_SEPARATOR); 49 | for (String line : lines) { 50 | Log.d(tag, "║ " + line); 51 | } 52 | ChuMuKLogUtil.printLine(tag, false); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /magic-box/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 26 | 27 | 33 | 34 | -------------------------------------------------------------------------------- /magic-box/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/swipeback/ChuMuSwipeBackActivity.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.swipeback; 2 | 3 | import android.os.Bundle; 4 | 5 | 6 | import androidx.appcompat.app.AppCompatActivity; 7 | 8 | import com.chumu.dt.v24.magicbox.swipeback.util.SwipeBackActivityBase; 9 | import com.chumu.dt.v24.magicbox.swipeback.util.SwipeBackActivityHelper; 10 | import com.chumu.dt.v24.magicbox.swipeback.util.SwipeBackLayout; 11 | import com.chumu.dt.v24.magicbox.swipeback.util.SwipeBackUtil; 12 | 13 | 14 | /** 15 | * ChuMuYa 16 | *

17 | * Created by ChuMu on 2020/8/4 18 | * Copyright © 2020年 ChuMu. All rights reserved. 19 | *

20 | * Describe: 侧滑返回 21 | * 22 | * @version: v11-2.0.6-beta 23 | */ 24 | public class ChuMuSwipeBackActivity extends AppCompatActivity implements SwipeBackActivityBase { 25 | private SwipeBackActivityHelper mHelper; 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | mHelper = new SwipeBackActivityHelper(this); 31 | mHelper.onActivityCreate(); 32 | } 33 | 34 | @Override 35 | protected void onPostCreate(Bundle savedInstanceState) { 36 | super.onPostCreate(savedInstanceState); 37 | mHelper.onPostCreate(); 38 | } 39 | 40 | @Override 41 | public SwipeBackLayout getSwipeBackLayout() { 42 | return mHelper.getSwipeBackLayout(); 43 | } 44 | 45 | @Override 46 | public void setSwipeBackEnable(boolean enable) { 47 | getSwipeBackLayout().setEnableGesture(enable); 48 | } 49 | 50 | @Override 51 | public void scrollToFinishActivity() { 52 | SwipeBackUtil.convertActivityToTranslucent(this); 53 | getSwipeBackLayout().scrollToFinishActivity(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/encryption/ChuMuDESUtils.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.encryption; 2 | 3 | import javax.crypto.Cipher; 4 | import javax.crypto.KeyGenerator; 5 | import javax.crypto.SecretKey; 6 | import javax.crypto.spec.SecretKeySpec; 7 | 8 | /** 9 | * @Description:主要功能:DES对称加密(Data Encryption Standard,数据加密标准,对称加密算法) 10 | * @Prject: magic-box 11 | * @date: 2017年05月16日 15:56 12 | * @Copyright: 共有开源知识版权 13 | * @Company: 14 | * @version: v11-2.0.6-beta 15 | */ 16 | 17 | public class ChuMuDESUtils { 18 | 19 | private ChuMuDESUtils() { 20 | throw new UnsupportedOperationException("cannot be instantiated"); 21 | } 22 | 23 | /* 24 | * 生成密钥 25 | */ 26 | public static byte[] initKey() throws Exception { 27 | KeyGenerator keyGen = KeyGenerator.getInstance("DES"); 28 | keyGen.init(56); 29 | SecretKey secretKey = keyGen.generateKey(); 30 | return secretKey.getEncoded(); 31 | } 32 | 33 | /* 34 | * DES 加密 35 | */ 36 | public static byte[] encrypt(byte[] data, byte[] key) throws Exception { 37 | SecretKey secretKey = new SecretKeySpec(key, "DES"); 38 | 39 | Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); 40 | cipher.init(Cipher.ENCRYPT_MODE, secretKey); 41 | byte[] cipherBytes = cipher.doFinal(data); 42 | return cipherBytes; 43 | } 44 | 45 | /* 46 | * DES 解密 47 | */ 48 | public static byte[] decrypt(byte[] data, byte[] key) throws Exception { 49 | SecretKey secretKey = new SecretKeySpec(key, "DES"); 50 | 51 | Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); 52 | cipher.init(Cipher.DECRYPT_MODE, secretKey); 53 | byte[] plainBytes = cipher.doFinal(data); 54 | return plainBytes; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/klog/base/ChuMuBaseLog.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.klog.base; 2 | 3 | /** 4 | * @Description:主要功能: 5 | * @Prject: magic-box 6 | * @date: 2017年05月16日 16:55 7 | * @Copyright: 共有开源知识版权 8 | * @Company: 9 | * @version: v11-2.0.6-beta 10 | */ 11 | 12 | 13 | import android.util.Log; 14 | 15 | import com.chumu.dt.v24.magicbox.klog.ChuMuKLog; 16 | 17 | /** 18 | * Created by ChuMu on 15/11/18. 19 | */ 20 | public class ChuMuBaseLog { 21 | 22 | private static final int MAX_LENGTH = 4000; 23 | 24 | public static void printDefault(int type, String tag, String msg) { 25 | 26 | int index = 0; 27 | int length = msg.length(); 28 | int countOfSub = length / MAX_LENGTH; 29 | 30 | if (countOfSub > 0) { 31 | for (int i = 0; i < countOfSub; i++) { 32 | String sub = msg.substring(index, index + MAX_LENGTH); 33 | printSub(type, tag, sub); 34 | index += MAX_LENGTH; 35 | } 36 | printSub(type, tag, msg.substring(index, length)); 37 | } else { 38 | printSub(type, tag, msg); 39 | } 40 | } 41 | 42 | private static void printSub(int type, String tag, String sub) { 43 | switch (type) { 44 | case ChuMuKLog.V: 45 | Log.v(tag, sub); 46 | break; 47 | case ChuMuKLog.D: 48 | Log.d(tag, sub); 49 | break; 50 | case ChuMuKLog.I: 51 | Log.i(tag, sub); 52 | break; 53 | case ChuMuKLog.W: 54 | Log.w(tag, sub); 55 | break; 56 | case ChuMuKLog.E: 57 | Log.e(tag, sub); 58 | break; 59 | case ChuMuKLog.A: 60 | Log.wtf(tag, sub); 61 | break; 62 | } 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/encryption/ChuMuTripleDESUtils.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.encryption; 2 | 3 | import javax.crypto.Cipher; 4 | import javax.crypto.KeyGenerator; 5 | import javax.crypto.SecretKey; 6 | import javax.crypto.spec.SecretKeySpec; 7 | import java.security.NoSuchAlgorithmException; 8 | 9 | /** 10 | * @Description:主要功能:3DES对称加密(Triple DES、DESede,进行了三重DES加密的算法,对称加密算法) 11 | * @Prject: magic-box 12 | * @date: 2017年05月16日 15:58 13 | * @Copyright: 共有开源知识版权 14 | * @Company: 15 | * @version: v11-2.0.6-beta 16 | */ 17 | 18 | public class ChuMuTripleDESUtils { 19 | 20 | private ChuMuTripleDESUtils() { 21 | throw new UnsupportedOperationException("cannot be instantiated"); 22 | } 23 | 24 | /* 25 | * 生成密钥 26 | */ 27 | public static byte[] initKey() throws NoSuchAlgorithmException { 28 | KeyGenerator keyGen = KeyGenerator.getInstance("DESede"); 29 | keyGen.init(168); //112 168 30 | SecretKey secretKey = keyGen.generateKey(); 31 | return secretKey.getEncoded(); 32 | } 33 | 34 | /* 35 | * 3DES 加密 36 | */ 37 | public static byte[] encrypt(byte[] data, byte[] key) throws Exception { 38 | SecretKey secretKey = new SecretKeySpec(key, "DESede"); 39 | 40 | Cipher cipher = Cipher.getInstance("DESede/ECB/PKCS5Padding"); 41 | cipher.init(Cipher.ENCRYPT_MODE, secretKey); 42 | byte[] cipherBytes = cipher.doFinal(data); 43 | return cipherBytes; 44 | } 45 | 46 | /* 47 | * 3DES 解密 48 | */ 49 | public static byte[] decrypt(byte[] data, byte[] key) throws Exception { 50 | SecretKey secretKey = new SecretKeySpec(key, "DESede"); 51 | 52 | Cipher cipher = Cipher.getInstance("DESede/ECB/PKCS5Padding"); 53 | cipher.init(Cipher.DECRYPT_MODE, secretKey); 54 | byte[] plainBytes = cipher.doFinal(data); 55 | return plainBytes; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/livedatabus/event/ChuMuDefaultChuMuEvent.kt: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.livedatabus.event 2 | import androidx.activity.ComponentActivity 3 | import androidx.fragment.app.Fragment 4 | import androidx.lifecycle.* 5 | import androidx.lifecycle.Observer 6 | import java.util.* 7 | 8 | /** 9 | * 普通事件 10 | */ 11 | class ChuMuDefaultChuMuEvent( 12 | private val liveDataMap: HashMap>, 13 | private val tag: String 14 | ) : ChuMuEvent { 15 | 16 | 17 | override fun observe(activity: ComponentActivity, observer: Observer) { 18 | subscribe(activity, observer) 19 | } 20 | 21 | override fun observe(fragment: Fragment, observer: Observer) { 22 | subscribe(fragment, observer) 23 | } 24 | 25 | override fun observeForever(activity: ComponentActivity, observer: Observer) { 26 | subscribeForever(activity, observer) 27 | } 28 | 29 | override fun observeForever(fragment: Fragment, observer: Observer) { 30 | subscribeForever(fragment, observer) 31 | } 32 | 33 | private fun subscribe(owner: LifecycleOwner, observer: Observer) { 34 | liveDataMap[tag] = MutableLiveData() 35 | liveDataMap[tag]?.observe(owner, Observer { o -> 36 | observer.onChanged(o) 37 | }) 38 | } 39 | 40 | private fun subscribeForever(owner: LifecycleOwner, observer: Observer) { 41 | liveDataMap[tag] = MutableLiveData() 42 | 43 | val mObserver= Observer {o -> 44 | observer.onChanged(o) 45 | } 46 | 47 | liveDataMap[tag]?.observeForever(mObserver) 48 | 49 | //onDestroy时解绑 50 | owner.lifecycle.addObserver(object : LifecycleObserver{ 51 | @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) 52 | fun onDestroy() { 53 | liveDataMap[tag]?.removeObserver(mObserver) 54 | } 55 | }) 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/appbox/ChuMuAppUtils.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.appbox; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.app.Application; 5 | import android.content.Context; 6 | 7 | import com.chumu.dt.v24.magicbox.klog.ChuMuKLog; 8 | import com.chumu.dt.v24.magicbox.klog.ChuMuKLogUtil; 9 | 10 | /** 11 | * @Description:主要功能:初始化在application中获取context 12 | * @Prject: magic-box 13 | * @date: 2017年05月19日 14:09 14 | * @Copyright: 共有开源知识版权 15 | * @Company: 16 | * @version: v11-2.0.6-beta 17 | */ 18 | 19 | public class ChuMuAppUtils extends Application { 20 | private static Context context; 21 | 22 | private ChuMuAppUtils() { 23 | throw new UnsupportedOperationException("u can't instantiate me..."); 24 | } 25 | 26 | /** 27 | * 初始化工具类 28 | * 29 | * @param context 上下文 30 | */ 31 | public static void init(final Context context) { 32 | if (context!=null) { 33 | ChuMuAppUtils.context = context.getApplicationContext(); 34 | ChuMuDisplayUtils.init(context); 35 | for (int i = 0; i < 2; i++) { 36 | ChuMuKLogUtil.printLine(context.getPackageName(), true); 37 | ChuMuKLog.e(context.getPackageName(), "\t" + "欢迎使用ChuMu(快速开发工具包)" + "\n" + "载入正常,如有什么使用问题,欢迎GitHub留言,项目地址 : https://github.com/15335179243/ChuMuYa" + 38 | "\n" + "感谢您的意见和反馈,祝您生活愉快!!!"); 39 | ChuMuKLogUtil.printLine(context.getPackageName(), false); 40 | } 41 | 42 | }else { 43 | throw new NullPointerException("Please pass into the context"); 44 | } 45 | } 46 | 47 | /** 48 | * 获取ApplicationContext 49 | * 50 | * @return ApplicationContext 51 | */ 52 | public static Context getContext() { 53 | if (context != null) return context; 54 | throw new NullPointerException("u should init first"); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/klog/base/XmlLog.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.klog.base; 2 | 3 | 4 | import android.util.Log; 5 | 6 | import com.chumu.dt.v24.magicbox.klog.ChuMuKLog; 7 | import com.chumu.dt.v24.magicbox.klog.ChuMuKLogUtil; 8 | 9 | import javax.xml.transform.OutputKeys; 10 | import javax.xml.transform.Source; 11 | import javax.xml.transform.Transformer; 12 | import javax.xml.transform.TransformerFactory; 13 | import javax.xml.transform.stream.StreamResult; 14 | import javax.xml.transform.stream.StreamSource; 15 | import java.io.StringReader; 16 | import java.io.StringWriter; 17 | 18 | /*** 19 | * @Description:主要功能: 20 | * @Prject: magic-box 21 | * @date: 2017年05月16日 16:56 22 | * @Copyright: 共有开源知识版权 23 | * @Company: 24 | * @version: v11-2.0.6-beta 25 | */ 26 | public class XmlLog { 27 | 28 | public static void printXml(String tag, String xml, String headString) { 29 | 30 | if (xml != null) { 31 | xml = XmlLog.formatXML(xml); 32 | xml = headString + "\n" + xml; 33 | } else { 34 | xml = headString + ChuMuKLog.NULL_TIPS; 35 | } 36 | 37 | ChuMuKLogUtil.printLine(tag, true); 38 | String[] lines = xml.split(ChuMuKLog.LINE_SEPARATOR); 39 | for (String line : lines) { 40 | if (!ChuMuKLogUtil.isEmpty(line)) { 41 | Log.d(tag, "║ " + line); 42 | } 43 | } 44 | ChuMuKLogUtil.printLine(tag, false); 45 | } 46 | 47 | private static String formatXML(String inputXML) { 48 | try { 49 | Source xmlInput = new StreamSource(new StringReader(inputXML)); 50 | StreamResult xmlOutput = new StreamResult(new StringWriter()); 51 | Transformer transformer = TransformerFactory.newInstance().newTransformer(); 52 | transformer.setOutputProperty(OutputKeys.INDENT, "yes"); 53 | transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); 54 | transformer.transform(xmlInput, xmlOutput); 55 | return xmlOutput.getWriter().toString().replaceFirst(">", ">\n"); 56 | } catch (Exception e) { 57 | e.printStackTrace(); 58 | return inputXML; 59 | } 60 | } 61 | 62 | } -------------------------------------------------------------------------------- /magic-box/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android-extensions' 3 | apply plugin: 'kotlin-android' 4 | //apply plugin: 'com.github.dcendents.android-maven' 5 | //group = 'com.github.username' 6 | apply plugin: 'com.novoda.bintray-release'//添加 bintray-release 配置 7 | android { 8 | compileSdkVersion 29 9 | defaultConfig { 10 | minSdkVersion 15 11 | targetSdkVersion 28 12 | versionCode 1 13 | versionName "1.0" 14 | 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | zipAlignEnabled true 21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | compileOptions { 25 | sourceCompatibility JavaVersion.VERSION_1_8 26 | targetCompatibility JavaVersion.VERSION_1_8 27 | } 28 | } 29 | 30 | dependencies { 31 | implementation fileTree(include: ['*.jar'], dir: 'libs') 32 | implementation 'androidx.appcompat:appcompat:1.1.0' 33 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 34 | testImplementation 'junit:junit:4.12' 35 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 36 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 37 | implementation 'androidx.recyclerview:recyclerview:1.1.0' 38 | api 'pub.devrel:easypermissions:2.0.1' 39 | implementation 'com.github.bumptech.glide:glide:4.11.0' 40 | implementation files('libs/BASE64Decoder.jar') 41 | implementation "androidx.core:core-ktx:1.3.2" 42 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 43 | } 44 | 45 | publish { 46 | userOrg = '1970874029'//bintray.com用户名 47 | repoName = 'ChuMuMagicBox' // bintray上仓库的名字 48 | groupId = 'com.chumu.magic-box'//jcenter上的路径 49 | artifactId = 'ChuMuMagicBox'//项目名称 50 | publishVersion = 'v11-2.0.0'//版本号 51 | desc = '\t\n' + 52 | 'Chumu rapid development kit, our service purpose is to make the world no difficult to develop the application.(楚木快速开发工具包,我们的服务宗旨是,让天下没有难开发的应。)'// 描述 53 | website = 'https://github.com/15335179243/ChuMuYa'//一般填github 项目地址,一定是要有效的地址 54 | } 55 | repositories { 56 | mavenCentral() 57 | } 58 | -------------------------------------------------------------------------------- /magic-box/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | 23 | -optimizationpasses 5 24 | # 指定不去忽略非公共的库的类的成员 25 | -dontskipnonpubliclibraryclassmembers 26 | # 指定混淆是采用的算法 27 | -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/* 28 | # 指定外部模糊字典 proguard-chinese.txt 改为混淆文件名,下同 29 | -obfuscationdictionary proguard-socialism.txt 30 | # 指定class模糊字典 31 | -classobfuscationdictionary proguard-socialism.txt 32 | # 指定package模糊字典 33 | -packageobfuscationdictionary proguard-socialism.txt 34 | 35 | 36 | -optimizationpasses 5 # 设置混淆的压缩比率 0 ~ 7 37 | -dontusemixedcaseclassnames # 混淆时不使用大小写混合,混淆后的类名为小写 38 | -dontskipnonpubliclibraryclasses # 指定不去忽略非公共库的类 39 | -dontskipnonpubliclibraryclassmembers # 指定不去忽略非公共库的成员 40 | -dontpreverify # 混淆时不做预校验 41 | -verbose # 混淆时不记录日志 42 | -ignorewarning # 忽略警告 43 | -dontshrink # 代码优化 44 | -dontoptimize # 不优化输入的类文件 45 | -keepattributes Signature # 避免混淆泛型 46 | -keepattributes SourceFile,LineNumberTable # 保留 47 | 48 | #Android 的注释不能混淆 49 | -keepattributes *Annotation* 50 | -keep class com.chumu.dt.v24.magicbox.** { **; } 51 | -keep class com.chumu.dt.v24.magicbox.** { *; } 52 | -keep class com.chumu.dt.v24.magicbox.** { public *; 53 | } 54 | -keepclassmembers class com.chumu.dt.v24.magicbox.** { *; } 55 | -dontwarn com.chumu.dt.v24.magicbox.** 56 | -keep public class * extends android.app.Activity 57 | -keep class * implements Android.os.Parcelable { # 保持Parcelable不被混淆 58 | public static final Android.os.Parcelable$Creator *; 59 | } -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/livedatabus/event/ChuMuStickinessEvent.kt: -------------------------------------------------------------------------------- 1 | 2 | package com.chumu.dt.v24.magicbox.livedatabus.event 3 | import androidx.activity.ComponentActivity 4 | import androidx.fragment.app.Fragment 5 | import androidx.lifecycle.* 6 | import androidx.lifecycle.Observer 7 | 8 | import java.util.* 9 | 10 | 11 | /** 12 | * 粘性事件 13 | */ 14 | class ChuMuStickinessEvent( 15 | private val liveDataMap: HashMap>, 16 | private val tag: String 17 | ) : ChuMuEvent { 18 | 19 | 20 | override fun observe(activity: ComponentActivity, observer: Observer) { 21 | subscribe(activity, observer) 22 | } 23 | 24 | override fun observe(fragment: Fragment, observer: Observer) { 25 | subscribe(fragment, observer) 26 | } 27 | 28 | override fun observeForever(activity: ComponentActivity, observer: Observer) { 29 | subscribeForever(activity, observer) 30 | } 31 | 32 | override fun observeForever(fragment: Fragment, observer: Observer) { 33 | subscribeForever(fragment, observer) 34 | } 35 | 36 | private fun subscribe(owner: LifecycleOwner, observer: Observer) { 37 | if (!liveDataMap.containsKey(tag) || liveDataMap[tag] == null) { 38 | liveDataMap[tag] = MutableLiveData() 39 | } 40 | liveDataMap[tag]?.observe(owner, Observer { o -> 41 | observer.onChanged(o) 42 | liveDataMap[tag] = MutableLiveData() 43 | subscribe(owner, observer) 44 | }) 45 | } 46 | 47 | 48 | private fun subscribeForever(owner: LifecycleOwner, observer: Observer) { 49 | if (!liveDataMap.containsKey(tag) || liveDataMap[tag] == null) { 50 | liveDataMap[tag] = MutableLiveData() 51 | } 52 | 53 | val mObserver= Observer {o -> 54 | observer.onChanged(o) 55 | liveDataMap[tag] = MutableLiveData() 56 | subscribeForever(owner, observer) 57 | } 58 | 59 | liveDataMap[tag]?.observeForever(mObserver) 60 | 61 | //onDestroy时解绑 62 | owner.lifecycle.addObserver(object : LifecycleObserver{ 63 | @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) 64 | fun onDestroy() { 65 | liveDataMap[tag]?.removeObserver(mObserver) 66 | } 67 | }) 68 | } 69 | 70 | } -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -optimizationpasses 5 23 | # 指定不去忽略非公共的库的类的成员 24 | -dontskipnonpubliclibraryclassmembers 25 | # 指定混淆是采用的算法 26 | -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/* 27 | # 指定外部模糊字典 proguard-chinese.txt 改为混淆文件名,下同 28 | -obfuscationdictionary proguard-socialism.txt 29 | # 指定class模糊字典 30 | -classobfuscationdictionary proguard-socialism.txt 31 | # 指定package模糊字典 32 | -packageobfuscationdictionary proguard-socialism.txt 33 | 34 | 35 | -optimizationpasses 5 # 设置混淆的压缩比率 0 ~ 7 36 | -dontusemixedcaseclassnames # 混淆时不使用大小写混合,混淆后的类名为小写 37 | -dontskipnonpubliclibraryclasses # 指定不去忽略非公共库的类 38 | -dontskipnonpubliclibraryclassmembers # 指定不去忽略非公共库的成员 39 | -dontpreverify # 混淆时不做预校验 40 | -verbose # 混淆时不记录日志 41 | -ignorewarning # 忽略警告 42 | -dontshrink # 代码优化 43 | -dontoptimize # 不优化输入的类文件 44 | -keepattributes Signature # 避免混淆泛型 45 | -keepattributes SourceFile,LineNumberTable # 保留 46 | 47 | #Android 的注释不能混淆 48 | -keepattributes *Annotation* 49 | -keep class com.chumu.dt.v24.magicbox.** { **; } 50 | -keep class com.chumu.dt.v24.magicbox.** { *; } 51 | -keep class com.chumu.dt.v24.magicbox.** { public *; 52 | } 53 | -keep class androidx.fragment.app.FixDialogFragment { **; } 54 | -keep class androidx.fragment.app.FixDialogFragment { *; } 55 | 56 | -keep class androidx.fragment.app.FixDialogFragment { public *; 57 | } 58 | -keepclassmembers class com.chumu.dt.v24.magicbox.** { *; } 59 | -dontwarn com.chumu.dt.v24.magicbox.** 60 | -keep public class * extends android.app.Activity 61 | -keep class * implements Android.os.Parcelable { # 保持Parcelable不被混淆 62 | public static final Android.os.Parcelable$Creator *; 63 | } -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/base/ChuMuBaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.base; 2 | 3 | import android.os.Bundle; 4 | 5 | 6 | import androidx.appcompat.app.AppCompatActivity; 7 | 8 | import com.chumu.dt.v24.magicbox.appbox.GlobalCrashCapture; 9 | import com.chumu.dt.v24.magicbox.appbox.NotSingOnEvent; 10 | import com.chumu.dt.v24.magicbox.swipeback.ChuMuSwipeBack; 11 | import com.chumu.dt.v24.magicbox.swipeback.util.SwipeBackActivityBase; 12 | import com.chumu.dt.v24.magicbox.swipeback.util.SwipeBackActivityHelper; 13 | import com.chumu.dt.v24.magicbox.swipeback.util.SwipeBackLayout; 14 | import com.chumu.dt.v24.magicbox.swipeback.util.SwipeBackUtil; 15 | 16 | /** 17 | * ChuMuYa 18 | *

19 | * Created by ChuMu on 2020/8/4 20 | * Copyright © 2020年 ChuMu. All rights reserved. 21 | *

22 | * Describe: 主要是用来侧滑返回的功能 23 | * @version: v11-2.0.6-beta 24 | */ 25 | 26 | 27 | public class ChuMuBaseActivity extends AppCompatActivity implements SwipeBackActivityBase, NotSingOnEvent { 28 | 29 | private SwipeBackActivityHelper mHelper; 30 | 31 | //加载注解设置 32 | private void initAttributes() { 33 | ChuMuSwipeBack chuMuSwipeBack = getClass().getAnnotation(ChuMuSwipeBack.class); 34 | 35 | if (chuMuSwipeBack != null) { 36 | setSwipeBackEnable(chuMuSwipeBack.value()); 37 | } else { 38 | setSwipeBackEnable(false); 39 | } 40 | 41 | 42 | } 43 | @Override 44 | protected void onCreate(Bundle savedInstanceState) { 45 | super.onCreate(savedInstanceState); 46 | mHelper = new SwipeBackActivityHelper(this); 47 | mHelper.onActivityCreate(); 48 | initAttributes(); 49 | GlobalCrashCapture.onNotSignEvent(this); 50 | 51 | } 52 | @Override 53 | public SwipeBackLayout getSwipeBackLayout() { 54 | return mHelper.getSwipeBackLayout(); 55 | } 56 | 57 | @Override 58 | public void setSwipeBackEnable(boolean enable) { 59 | getSwipeBackLayout().setEnableGesture(enable); 60 | } 61 | 62 | @Override 63 | public void scrollToFinishActivity() { 64 | SwipeBackUtil.convertActivityToTranslucent(this); 65 | getSwipeBackLayout().scrollToFinishActivity(); 66 | } 67 | 68 | 69 | @Override 70 | protected void onPostCreate(Bundle savedInstanceState) { 71 | super.onPostCreate(savedInstanceState); 72 | mHelper.onPostCreate(); 73 | } 74 | 75 | 76 | @Override 77 | public void onSingEvent() { 78 | //做你的处理未登录操作 79 | 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /magic-box/src/main/java/com/chumu/dt/v24/magicbox/klog/base/FileLog.java: -------------------------------------------------------------------------------- 1 | package com.chumu.dt.v24.magicbox.klog.base; 2 | 3 | /** 4 | * @Description:主要功能: 5 | * @Prject: magic-box 6 | * @date: 2017年05月16日 16:56 7 | * @Copyright: 共有开源知识版权 8 | * @Company: 9 | * @version: v11-2.0.6-beta 10 | */ 11 | 12 | 13 | 14 | 15 | import android.util.Log; 16 | 17 | 18 | import java.io.File; 19 | import java.io.FileNotFoundException; 20 | import java.io.FileOutputStream; 21 | import java.io.IOException; 22 | import java.io.OutputStream; 23 | import java.io.OutputStreamWriter; 24 | import java.io.UnsupportedEncodingException; 25 | import java.util.Random; 26 | 27 | import androidx.annotation.NonNull; 28 | import androidx.annotation.Nullable; 29 | 30 | /** 31 | * Created by ChuMu on 15/11/18. 32 | */ 33 | public class FileLog { 34 | 35 | private static final String FILE_PREFIX = "KChuMuKLog_"; 36 | private static final String FILE_FORMAT = ".ChuMuKLog"; 37 | 38 | public static void printFile(String tag, File targetDirectory, @Nullable String fileName, String headString, String msg) { 39 | 40 | fileName = (fileName == null) ? getFileName() : fileName; 41 | if (save(targetDirectory, fileName, msg)) { 42 | Log.d(tag, headString + " save ChuMuKLog success ! location is >>>" + targetDirectory.getAbsolutePath() + "/" + fileName); 43 | } else { 44 | Log.e(tag, headString + "save ChuMuKLog fails !"); 45 | } 46 | } 47 | 48 | private static boolean save(File dic, @NonNull String fileName, String msg) { 49 | 50 | File file = new File(dic, fileName); 51 | 52 | try { 53 | OutputStream outputStream = new FileOutputStream(file); 54 | OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream, "UTF-8"); 55 | outputStreamWriter.write(msg); 56 | outputStreamWriter.flush(); 57 | outputStream.close(); 58 | return true; 59 | } catch (FileNotFoundException e) { 60 | e.printStackTrace(); 61 | return false; 62 | } catch (UnsupportedEncodingException e) { 63 | e.printStackTrace(); 64 | return false; 65 | } catch (IOException e) { 66 | e.printStackTrace(); 67 | return false; 68 | } catch (Exception e) { 69 | e.printStackTrace(); 70 | return false; 71 | } 72 | 73 | } 74 | 75 | private static String getFileName() { 76 | Random random = new Random(); 77 | return FILE_PREFIX + Long.toString(System.currentTimeMillis() + random.nextInt(10000)).substring(4) + FILE_FORMAT; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 22 | 23 | 28 | 29 | 30 |