├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── themes.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── icon_camera.png
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ ├── launcher_logo.png
│ │ │ │ ├── ic_launcher_round.webp
│ │ │ │ ├── point_focused_big.png
│ │ │ │ └── point_unfocused_small.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ ├── launcher_header.png
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── drawable
│ │ │ │ ├── selector_banner_unequal.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── layout
│ │ │ │ ├── main_layout_camera_guide.xml
│ │ │ │ ├── main_layout_bottom_tab_guide.xml
│ │ │ │ ├── activity_launcher.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── activity_guide.xml
│ │ │ ├── values-night
│ │ │ │ └── themes.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── dynamicdemo
│ │ │ │ ├── NewSplashActivity.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── GuideActivity.java
│ │ │ │ ├── LauncherActivity.java
│ │ │ │ └── SplashActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── dynamicdemo
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── dynamicdemo
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── lib_guide
├── .gitignore
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── vcom
│ │ └── lib_guide
│ │ ├── DismissCallBack.java
│ │ ├── DecorateInflate.java
│ │ ├── GuideSet.java
│ │ ├── GuideUtils.java
│ │ └── GuideView.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── .idea
├── .gitignore
├── compiler.xml
├── vcs.xml
├── gradle.xml
├── misc.xml
└── jarRepositories.xml
├── README.md
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/lib_guide/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | include ':lib_guide'
3 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DynamicIcon
2 |
3 | APP动态替换Icon(避免杀进程 应用未安装等弊端)/glide预加载/guide引导弹窗
4 |
--------------------------------------------------------------------------------
/lib_guide/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | DynamicDemo
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windfone/DynamicIcon/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windfone/DynamicIcon/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windfone/DynamicIcon/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windfone/DynamicIcon/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/icon_camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windfone/DynamicIcon/HEAD/app/src/main/res/mipmap-xxhdpi/icon_camera.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windfone/DynamicIcon/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/launcher_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windfone/DynamicIcon/HEAD/app/src/main/res/mipmap-xxhdpi/launcher_logo.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windfone/DynamicIcon/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windfone/DynamicIcon/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windfone/DynamicIcon/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/launcher_header.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windfone/DynamicIcon/HEAD/app/src/main/res/mipmap-xxxhdpi/launcher_header.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windfone/DynamicIcon/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windfone/DynamicIcon/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/point_focused_big.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windfone/DynamicIcon/HEAD/app/src/main/res/mipmap-xxhdpi/point_focused_big.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/point_unfocused_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windfone/DynamicIcon/HEAD/app/src/main/res/mipmap-xxhdpi/point_unfocused_small.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/windfone/DynamicIcon/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dynamicdemo/NewSplashActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.dynamicdemo;
2 |
3 |
4 | public class NewSplashActivity extends SplashActivity{
5 |
6 |
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/lib_guide/src/main/java/com/vcom/lib_guide/DismissCallBack.java:
--------------------------------------------------------------------------------
1 | package com.vcom.lib_guide;
2 |
3 | /**
4 | * @Author: zgh
5 | * @Date: 2022/5/19 16:37
6 | * @Description:
7 | */
8 | public interface DismissCallBack {
9 | void onDismiss();
10 | }
11 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu May 26 08:43:17 GMT+08:00 2022
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
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 | .cxx
15 | local.properties
16 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selector_banner_unequal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/lib_guide/src/main/java/com/vcom/lib_guide/DecorateInflate.java:
--------------------------------------------------------------------------------
1 | package com.vcom.lib_guide;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * @Author: zgh
7 | * @Date: 2022/5/19 16:03
8 | * @Description:
9 | */
10 | public interface DecorateInflate {
11 | void onInflate(GuideView guideView, View inflaterView);
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/dynamicdemo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.dynamicdemo;
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/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
11 | #FF03DAC5
12 | #FF03DAC5
13 | #FF03DAC5
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/main_layout_camera_guide.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/lib_guide/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 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/dynamicdemo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.dynamicdemo;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 | assertEquals("com.zzvcom.dynamicdemo", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/lib_guide/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 31
5 |
6 | defaultConfig {
7 | minSdkVersion 21
8 | targetSdkVersion 31
9 | versionCode 1
10 | versionName "1.0"
11 |
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 |
14 | }
15 |
16 | buildTypes {
17 | release {
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 |
22 | buildTypes {
23 | release {
24 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
25 | }
26 | }
27 |
28 | }
29 |
30 | dependencies {
31 | implementation fileTree(dir: 'libs', include: ['*.jar'])
32 | implementation 'androidx.appcompat:appcompat:1.3.0'
33 | implementation 'androidx.annotation:annotation:1.3.0'
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/lib_guide/src/main/java/com/vcom/lib_guide/GuideSet.java:
--------------------------------------------------------------------------------
1 | package com.vcom.lib_guide;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | /**
7 | * @Author: zgh
8 | * @Date: 2022/5/20 9:36
9 | * @Description: 多个引导组成集合
10 | */
11 | public class GuideSet {
12 |
13 | private List guideViews = new ArrayList<>();
14 |
15 | private int position = 0;
16 |
17 | public void addGuide(GuideView guideView) {
18 | guideViews.add(guideView);
19 | guideView.setDismissCallBack(new DismissCallBack() {
20 | @Override
21 | public void onDismiss() {
22 | int nextPosition = position + 1;
23 | if (guideViews.size() > nextPosition) {
24 | //不是最后一个
25 | GuideView next = guideViews.get(nextPosition);
26 | position++;
27 | next.show();
28 | }
29 | }
30 | });
31 | }
32 |
33 | public void show() {
34 | guideViews.get(0).show();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/main_layout_bottom_tab_guide.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
17 |
18 |
19 |
29 |
30 |
--------------------------------------------------------------------------------
/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=-Xmx2048m -Dfile.encoding=UTF-8
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 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Enables namespacing of each library's R class so that its R class includes only the
19 | # resources declared in the library itself and none from the library's dependencies,
20 | # thereby reducing the size of the R class for that library
21 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
20 |
21 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
11 |
18 |
19 |
20 |
26 |
27 |
31 |
35 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | }
4 |
5 | android {
6 | compileSdkVersion 31
7 |
8 | defaultConfig {
9 | applicationId "com.example.dynamicdemo"
10 | minSdkVersion 21
11 | targetSdkVersion 31
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
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 project(path: ':lib_guide')
32 |
33 | implementation 'androidx.appcompat:appcompat:1.3.0'
34 | implementation 'com.google.android.material:material:1.4.0'
35 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
36 | testImplementation 'junit:junit:4.13.2'
37 | androidTestImplementation 'androidx.test.ext:junit:1.1.3'
38 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
39 | implementation 'com.github.bumptech.glide:glide:4.12.0'
40 | implementation 'com.github.bumptech.glide:compiler:4.12.0'
41 |
42 | // 导航界面+轮播图
43 | implementation 'cn.bingoogolapple:bga-banner:3.0.0@aar'
44 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
45 | }
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.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 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dynamicdemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.dynamicdemo;
2 |
3 | import android.content.SharedPreferences;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.widget.EditText;
7 | import android.widget.Toast;
8 |
9 | import androidx.appcompat.app.AppCompatActivity;
10 |
11 | import com.vcom.lib_guide.GuideUtils;
12 |
13 | import java.text.SimpleDateFormat;
14 | import java.util.Date;
15 |
16 | public class MainActivity extends AppCompatActivity {
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_main);
22 |
23 | GuideUtils.getInstance(this).addView(findViewById(R.id.tv1), R.layout.main_layout_bottom_tab_guide, R.id.btn_cancel);
24 | GuideUtils.getInstance(this).addView(findViewById(R.id.btn2), R.layout.main_layout_bottom_tab_guide, R.id.btn_cancel);
25 | GuideUtils.getInstance(this).addNoPassIdView(findViewById(R.id.iv3), R.layout.main_layout_camera_guide).show();
26 |
27 | EditText et4 = findViewById(R.id.et4);
28 | EditText et5 = findViewById(R.id.et5);
29 | et4.setText(getFormatDate());
30 | et5.setText(getFormatDate());
31 |
32 | findViewById(R.id.btn3).setOnClickListener(new View.OnClickListener() {
33 | @Override
34 | public void onClick(View view) {
35 | SharedPreferences sp = getSharedPreferences("save", MODE_PRIVATE);
36 | sp.edit().putString("change", et4.getText().toString().trim()).apply();
37 | sp.edit().putString("reset", et5.getText().toString().trim()).apply();
38 | Toast.makeText(MainActivity.this, "保存成功", Toast.LENGTH_SHORT).show();
39 | }
40 | });
41 |
42 | }
43 |
44 | public static String getFormatDate() {
45 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
46 | return format.format(new Date());
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
46 |
51 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
22 |
23 |
31 |
32 |
40 |
41 |
49 |
50 |
58 |
59 |
67 |
68 |
69 |
76 |
77 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dynamicdemo/GuideActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.dynamicdemo;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.widget.ImageView;
6 |
7 | import androidx.appcompat.app.AppCompatActivity;
8 |
9 | import com.bumptech.glide.Glide;
10 | import com.bumptech.glide.load.engine.DiskCacheStrategy;
11 | import com.bumptech.glide.request.RequestOptions;
12 |
13 | import java.util.List;
14 |
15 | import cn.bingoogolapple.bgabanner.BGABanner;
16 |
17 |
18 | public class GuideActivity extends AppCompatActivity {
19 |
20 | /**
21 | * 用于放置背景图片
22 | */
23 | private BGABanner mBackgroundBanner;
24 | /**
25 | * 用于放置浮动文字
26 | */
27 | private BGABanner mForegroundBanner;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 |
33 | initView();
34 | setListener();
35 | processLogic();
36 | }
37 |
38 | private void initView() {
39 | setContentView(R.layout.activity_guide);
40 | mForegroundBanner = findViewById(R.id.banner_guide_foreground);
41 | mBackgroundBanner = findViewById(R.id.banner_guide_background);
42 |
43 | }
44 |
45 | private void setListener() {
46 | /**
47 | * 设置进入按钮和跳过按钮控件资源 id 及其点击事件
48 | * 如果进入按钮和跳过按钮有一个不存在的话就传 0
49 | * 在 BGABanner 里已经帮开发者处理了防止重复点击事件
50 | * 在 BGABanner 里已经帮开发者处理了「跳过按钮」和「进入按钮」的显示与隐藏
51 | */
52 | mForegroundBanner.setEnterSkipViewIdAndDelegate(R.id.btn_guide_enter, R.id.tv_guide_skip, new BGABanner.GuideDelegate() {
53 | @Override
54 | public void onClickEnterOrSkip() {
55 | startActivity(new Intent(GuideActivity.this,MainActivity.class));
56 | }
57 | });
58 | }
59 |
60 | private void processLogic() {
61 | List caches = getIntent().getStringArrayListExtra("urls");
62 | if (caches != null && caches.size() > 0) {
63 | mForegroundBanner.setAdapter(new BGABanner.Adapter() {
64 | @Override
65 | public void fillBannerItem(BGABanner banner, ImageView itemView, String model, int position) {
66 | Glide.with(GuideActivity.this)
67 | .load(model)
68 | .diskCacheStrategy(DiskCacheStrategy.DATA)
69 | .apply(new RequestOptions().fitCenter())
70 | .into(itemView);
71 | }
72 | });
73 | mForegroundBanner.setData(caches, null);
74 |
75 | }
76 |
77 |
78 | }
79 |
80 | @Override
81 | protected void onResume() {
82 | super.onResume();
83 | // 如果开发者的引导页主题是透明的,需要在界面可见时给背景 Banner 设置一个白色背景,避免滑动过程中两个 Banner 都设置透明度后能看到 Launcher
84 | mBackgroundBanner.setBackgroundResource(android.R.color.white);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_guide.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
25 |
26 |
36 |
37 |
38 |
51 |
52 |
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dynamicdemo/LauncherActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.dynamicdemo;
2 |
3 | import android.content.Intent;
4 | import android.graphics.drawable.Drawable;
5 | import android.os.Bundle;
6 | import android.os.Handler;
7 | import android.text.TextUtils;
8 | import android.util.Log;
9 |
10 | import androidx.annotation.Nullable;
11 | import androidx.appcompat.app.AppCompatActivity;
12 |
13 | import com.bumptech.glide.Glide;
14 | import com.bumptech.glide.load.DataSource;
15 | import com.bumptech.glide.load.engine.DiskCacheStrategy;
16 | import com.bumptech.glide.load.engine.GlideException;
17 | import com.bumptech.glide.request.RequestListener;
18 | import com.bumptech.glide.request.RequestOptions;
19 | import com.bumptech.glide.request.target.Target;
20 |
21 | import java.io.File;
22 | import java.util.ArrayList;
23 | import java.util.Iterator;
24 |
25 |
26 | public class LauncherActivity extends AppCompatActivity {
27 |
28 | private ArrayList urls = new ArrayList<>();
29 |
30 | @Override
31 | protected void onCreate(@Nullable Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 |
34 | setContentView(R.layout.activity_launcher);
35 |
36 | new File(getExternalCacheDir().getAbsolutePath());
37 |
38 | urls.add("https://zw.czbanbantong.com/national_appnass/v1/appshow/1645772611506");
39 | urls.add("https://zw.czbanbantong.com/national_appnass/v1/appshow/1652945167879");
40 | urls.add("https://zw.czbanbantong.com/national_appnass/v1/appshow/1653015210411");
41 | urls.add("https://ncp.czbanbantong.com/appnass/v1/appshow/1630989431331");
42 |
43 | for (int i = 0; i < urls.size(); i++) {
44 | preloadBanner(urls.get(i));
45 | }
46 |
47 | new Handler().postDelayed(new Runnable() {
48 | @Override
49 | public void run() {
50 | startActivity(new Intent(LauncherActivity.this, GuideActivity.class).putStringArrayListExtra("urls", urls));
51 | }
52 | },2000);
53 |
54 | }
55 |
56 | @Override
57 | protected void onStop() {
58 | super.onStop();
59 | // 在当前界面进入后台时,才释放资源,防止跳转白屏问题
60 | finish();
61 | }
62 |
63 | /**
64 | * 预加载图片Url
65 | *
66 | * @param url 动态url
67 | */
68 | private void preloadBanner(String url) {
69 | Glide.with(this).load(url).diskCacheStrategy(DiskCacheStrategy.DATA)
70 | .apply(new RequestOptions().fitCenter())
71 | .listener(new RequestListener() {
72 | @Override
73 | public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
74 | Log.i("","预加载失败:" + url);
75 | Iterator it = urls.iterator();
76 | while (it.hasNext()) {
77 | if (TextUtils.equals(url, it.next())) {
78 | it.remove();
79 | }
80 | }
81 | return true;
82 | }
83 |
84 | @Override
85 | public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) {
86 | Log.i("","预加载完成:" + url);
87 | return true;
88 | }
89 | })
90 | .preload();
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/dynamicdemo/SplashActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.dynamicdemo;
2 |
3 | import android.content.ComponentName;
4 | import android.content.Intent;
5 | import android.content.SharedPreferences;
6 | import android.content.pm.PackageManager;
7 | import android.os.Bundle;
8 | import android.text.TextUtils;
9 |
10 | import androidx.annotation.Nullable;
11 | import androidx.appcompat.app.AppCompatActivity;
12 |
13 | import java.text.SimpleDateFormat;
14 | import java.util.Date;
15 |
16 |
17 | public class SplashActivity extends AppCompatActivity {
18 |
19 | @Override
20 | protected void onCreate(@Nullable Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 |
23 | if (!this.isTaskRoot()) {
24 | Intent mainIntent = getIntent();
25 | String action = mainIntent.getAction();
26 | if (mainIntent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(action)) {
27 | finish();
28 | return;
29 | }
30 | }
31 |
32 | setContentView(R.layout.activity_launcher);
33 |
34 | jumpToLauncher();
35 | }
36 |
37 | private void jumpToLauncher() {
38 | Intent intent = new Intent(this, LauncherActivity.class);
39 |
40 | SharedPreferences sp = getSharedPreferences("save", MODE_PRIVATE);
41 | String targetTime = sp.getString("change", "");
42 | String target2Time = sp.getString("reset", "");
43 |
44 | Date nowDate = new Date(System.currentTimeMillis());
45 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
46 | String now = sdf.format(nowDate);
47 |
48 | if (!TextUtils.isEmpty(targetTime) && !TextUtils.isEmpty(target2Time)) {
49 | PackageManager pm = getPackageManager();
50 | if (now.compareTo(targetTime) >= 0 && now.compareTo(target2Time) <= 0) {
51 | if (PackageManager.COMPONENT_ENABLED_STATE_DISABLED != pm.getComponentEnabledSetting(new ComponentName(getPackageName(), "com.example.dynamicdemo.SplashActivity"))) {
52 | pm.setComponentEnabledSetting(new ComponentName(SplashActivity.this, "com.example.dynamicdemo.SplashActivity"),
53 | PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
54 | pm.setComponentEnabledSetting(new ComponentName(SplashActivity.this, "com.example.dynamicdemo.NewSplashActivity"),
55 | PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
56 |
57 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
58 | }
59 | } else if (now.compareTo(target2Time) >= 0) {
60 | if (PackageManager.COMPONENT_ENABLED_STATE_DISABLED != pm.getComponentEnabledSetting(new ComponentName(getPackageName(), "com.example.dynamicdemo.NewSplashActivity"))) {
61 | pm.setComponentEnabledSetting(new ComponentName(SplashActivity.this, "com.example.dynamicdemo.NewSplashActivity"),
62 | PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
63 | pm.setComponentEnabledSetting(new ComponentName(SplashActivity.this, "com.example.dynamicdemo.SplashActivity"),
64 | PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
65 |
66 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
67 | }
68 | }
69 | }
70 | startActivity(intent);
71 | }
72 |
73 |
74 | @Override
75 | protected void onStop() {
76 | super.onStop();
77 | finish();
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/lib_guide/src/main/java/com/vcom/lib_guide/GuideUtils.java:
--------------------------------------------------------------------------------
1 | package com.vcom.lib_guide;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.view.View;
6 |
7 | import androidx.annotation.IdRes;
8 | import androidx.annotation.LayoutRes;
9 |
10 | /**
11 | * @Author: zgh
12 | * @Date: 2022/5/23 18:01
13 | * @Description: 功能引导遮罩
14 | */
15 | public class GuideUtils {
16 |
17 |
18 | private static GuideUtils instance = null;
19 |
20 | private Context context;
21 |
22 | private GuideSet guideSet;
23 |
24 | private GuideUtils(Context context) {
25 | this.context = context;
26 | guideSet = new GuideSet();
27 | }
28 |
29 | public synchronized static GuideUtils getInstance(Context context) {
30 | if (instance == null) {
31 | synchronized (GuideUtils.class) {
32 | instance = new GuideUtils(context);
33 | }
34 | }
35 | return instance;
36 | }
37 |
38 | private GuideView createGuideView(View view, @LayoutRes int layout, @IdRes int clickId) {
39 | return new GuideView.Builder(context)
40 | .focusView(view)
41 | .setPadding(5, 5, 5, 5)
42 | .setRadius(5)
43 | .setRelyActivity((Activity) context)
44 | .setLayout(layout, null)
45 | .setPassId(clickId)
46 | .build();
47 | }
48 |
49 | private GuideView createNoPassIdGuideView(View view, @LayoutRes int layout) {
50 | return new GuideView.Builder(context)
51 | .focusView(view)
52 | .setPadding(5, 5, 5, 5)
53 | .setRadius(5)
54 | .setRelyActivity((Activity) context)
55 | .setLayout(layout, new DecorateInflate() {
56 | @Override
57 | public void onInflate(final GuideView guideView, View inflaterView) {
58 | inflaterView.setOnClickListener(new View.OnClickListener() {
59 | @Override
60 | public void onClick(View v) {
61 | guideView.dismiss();
62 | }
63 | });
64 | }
65 | })
66 | .build();
67 | }
68 |
69 | public GuideUtils addView(View view, @LayoutRes int layout, @IdRes int clickId) {
70 | guideSet.addGuide(createGuideView(view, layout, clickId));
71 | return this;
72 | }
73 |
74 | public GuideUtils addNoPassIdView(View view, @LayoutRes int layout) {
75 | guideSet.addGuide(createNoPassIdGuideView(view, layout));
76 | return this;
77 | }
78 |
79 | public void show() {
80 | guideSet.show();
81 | }
82 |
83 | /**
84 | * @param view
85 | * @param radius
86 | * @param layout
87 | * @param clickId 点击消失id
88 | */
89 | private void showSingleView(View view, int radius, @LayoutRes int layout, @IdRes int clickId) {
90 | new GuideView.Builder(context)
91 | .focusView(view)
92 | .setRadius(radius)
93 | .setRelyActivity((Activity) context)
94 | .setLayout(layout, null)
95 | .setPassId(clickId)
96 | .build()
97 | .show();
98 | }
99 |
100 | /**
101 | * 不设置clickId,点击空白处消失
102 | *
103 | * @param view
104 | * @param radius
105 | * @param layout
106 | */
107 | private void showNoPassIdSingleView(View view, int radius, @LayoutRes int layout) {
108 | new GuideView.Builder(context)
109 | .focusView(view)
110 | .setRadius(radius)
111 | .setRelyActivity((Activity) context)
112 | .setLayout(layout, new DecorateInflate() {
113 | @Override
114 | public void onInflate(final GuideView guideView, View inflaterView) {
115 | inflaterView.setOnClickListener(new View.OnClickListener() {
116 | @Override
117 | public void onClick(View v) {
118 | guideView.dismiss();
119 | }
120 | });
121 | }
122 | })
123 | .build()
124 | .show();
125 | }
126 |
127 | /**
128 | * 默认配置
129 | *
130 | * @param view
131 | * @param layout
132 | */
133 | private void showDefaultView(View view, @LayoutRes int layout) {
134 | new GuideView.Builder(context)
135 | .focusView(view)
136 | .setPadding(5, 5, 5, 5)
137 | .setRadius(15)
138 | .setRelyActivity((Activity) context)
139 | .setLayout(layout, new DecorateInflate() {
140 | @Override
141 | public void onInflate(final GuideView guideView, View inflaterView) {
142 | inflaterView.setOnClickListener(new View.OnClickListener() {
143 | @Override
144 | public void onClick(View v) {
145 | guideView.dismiss();
146 | }
147 | });
148 | }
149 | })
150 | .build()
151 | .show();
152 | }
153 |
154 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/lib_guide/src/main/java/com/vcom/lib_guide/GuideView.java:
--------------------------------------------------------------------------------
1 | package com.vcom.lib_guide;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.graphics.BlurMaskFilter;
6 | import android.graphics.Canvas;
7 | import android.graphics.Color;
8 | import android.graphics.Paint;
9 | import android.graphics.PorterDuff;
10 | import android.graphics.PorterDuffXfermode;
11 | import android.graphics.Rect;
12 | import android.graphics.RectF;
13 | import android.util.Log;
14 | import android.view.LayoutInflater;
15 | import android.view.View;
16 | import android.view.ViewGroup;
17 | import android.widget.FrameLayout;
18 |
19 | import androidx.annotation.IdRes;
20 | import androidx.annotation.LayoutRes;
21 | import androidx.annotation.Nullable;
22 |
23 | /**
24 | * @Author: zgh
25 | * @Date: 2022/5/19 15:21
26 | * @Description: 功能引导遮罩
27 | */
28 | public class GuideView extends FrameLayout {
29 |
30 | private final String TAG = "GuideView";
31 |
32 | /**
33 | * 高亮View
34 | */
35 | private View focusView;
36 | private Activity relyActivity;
37 | private int layout;
38 | private int clickId;
39 | private float radius;
40 | private int paddingLeft;
41 | private int paddingRight;
42 | private int paddingTop;
43 | private int paddingBottom;
44 | private int bgColor = Color.parseColor("#B3000000");
45 |
46 | /**
47 | * 引导区域
48 | */
49 | private Rect viewRect;
50 | /**
51 | * activity根rect
52 | */
53 | private Rect contentRect;
54 | private Paint paint;
55 | /**
56 | * 要绘制的高亮矩形
57 | */
58 | private RectF rectF;
59 | private PorterDuffXfermode porterDuffXfermode;
60 | /**
61 | * activity根布局
62 | */
63 | private FrameLayout contentParent;
64 |
65 | private View inflaterView;
66 |
67 | private DecorateInflate decorateInflate;
68 |
69 | public void setRelyActivity(Activity relyActivity) {
70 | this.relyActivity = relyActivity;
71 | contentParent = relyActivity.findViewById(android.R.id.content);
72 | }
73 |
74 | private DismissCallBack dismissCallBack;
75 | public void setDismissCallBack(DismissCallBack dismissCallBack) {
76 | this.dismissCallBack = dismissCallBack;
77 | }
78 |
79 | private GuideView(Context context) {
80 | super(context);
81 | setWillNotDraw(false);
82 | viewRect = new Rect();
83 | contentRect = new Rect();
84 | rectF = new RectF();
85 |
86 | initPint();
87 | }
88 |
89 |
90 | private void initPint() {
91 | paint = new Paint();
92 | paint.setColor(Color.TRANSPARENT);
93 | PorterDuff.Mode mode = PorterDuff.Mode.CLEAR;
94 | porterDuffXfermode = new PorterDuffXfermode(mode);
95 | paint.setXfermode(porterDuffXfermode);
96 | //设置画笔遮罩滤镜,可以传入BlurMaskFilter或EmbossMaskFilter,前者为模糊遮罩滤镜而后者为浮雕遮罩滤镜
97 | paint.setMaskFilter(new BlurMaskFilter(10, BlurMaskFilter.Blur.INNER));
98 | //关闭当前view的硬件加速
99 | setLayerType(LAYER_TYPE_SOFTWARE, null);
100 | }
101 |
102 | @Override
103 | protected void onDraw(Canvas canvas) {
104 | super.onDraw(canvas);
105 |
106 | Log.d(TAG, "onDraw");
107 |
108 | canvas.drawColor(bgColor);
109 |
110 | contentParent.getGlobalVisibleRect(contentRect);
111 | int topMargin = contentRect.top;
112 |
113 | Log.d(TAG, "topMargin:" + topMargin);
114 |
115 | //画出高亮区域
116 | focusView.getGlobalVisibleRect(viewRect);
117 |
118 | int left = viewRect.left - paddingLeft;
119 | rectF.left = left;
120 | Log.d(TAG, "left:" + left);
121 | int right = viewRect.right + paddingRight;
122 | rectF.right = right;
123 | Log.d(TAG, "right:" + right);
124 | int top = viewRect.top - paddingTop - topMargin;
125 | rectF.top = top;
126 | Log.d(TAG, "top:" + top);
127 | int bottom = viewRect.bottom + paddingBottom - topMargin;
128 | rectF.bottom = bottom;
129 | Log.d(TAG, "bottom:" + bottom);
130 |
131 | canvas.drawRoundRect(rectF, radius, radius, paint);
132 |
133 | }
134 |
135 | public void show() {
136 | inflaterView = LayoutInflater.from(relyActivity).inflate(layout, this, true);
137 | if (clickId != 0) {
138 | inflaterView.findViewById(clickId).setOnClickListener(new OnClickListener() {
139 | @Override
140 | public void onClick(View v) {
141 | dismiss();
142 | if (dismissCallBack != null) {
143 | dismissCallBack.onDismiss();
144 | }
145 | }
146 | });
147 | }
148 | if (decorateInflate != null) {
149 | decorateInflate.onInflate(this,inflaterView);
150 | }
151 | this.setClickable(true);
152 | contentParent.post(new Runnable() {
153 | @Override
154 | public void run() {
155 | contentParent.addView(GuideView.this,new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
156 | }
157 | });
158 |
159 | }
160 |
161 | public void dismiss() {
162 | contentParent.post(new Runnable() {
163 | @Override
164 | public void run() {
165 | contentParent.removeView(GuideView.this);
166 | }
167 | });
168 | }
169 |
170 | public static class Builder {
171 |
172 | private GuideView guideView;
173 |
174 | public Builder(Context context) {
175 | guideView = new GuideView(context);
176 | }
177 |
178 | public Builder focusView(View view) {
179 | guideView.focusView = view;
180 | return this;
181 | }
182 |
183 | public Builder setRelyActivity(Activity activity) {
184 | guideView.setRelyActivity(activity);
185 | return this;
186 | }
187 |
188 | public Builder setLayout(@LayoutRes int layout, @Nullable DecorateInflate decorateInflate) {
189 | guideView.layout = layout;
190 | guideView.decorateInflate = decorateInflate;
191 | return this;
192 | }
193 |
194 | public Builder setPassId(@IdRes int clickId) {
195 | guideView.clickId = clickId;
196 | return this;
197 | }
198 |
199 | public Builder setRadius(float radius) {
200 | guideView.radius = radius;
201 | return this;
202 | }
203 |
204 | public Builder setPadding(int paddingLeft, int paddingRight, int paddingTop, int paddingBottom) {
205 | guideView.paddingTop = paddingTop;
206 | guideView.paddingBottom = paddingBottom;
207 | guideView.paddingLeft = paddingLeft;
208 | guideView.paddingRight = paddingRight;
209 | return this;
210 | }
211 |
212 | public Builder setBgColor(int bgColor) {
213 | guideView.bgColor = bgColor;
214 | return this;
215 | }
216 |
217 | public GuideView build() {
218 | return guideView;
219 | }
220 | }
221 | }
222 |
--------------------------------------------------------------------------------