├── .gitignore
├── .idea
├── .gitignore
├── appInsightsSettings.xml
├── compiler.xml
├── deploymentTargetDropDown.xml
├── deploymentTargetSelector.xml
├── encodings.xml
├── google-java-format.xml
├── gradle.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── migrations.xml
├── misc.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── gif
│ ├── 1.gif
│ ├── 2.gif
│ ├── 3.gif
│ ├── 4.gif
│ └── 5.gif
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── llw
│ │ └── easyview
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── llw
│ │ │ └── easyview
│ │ │ ├── EasyActivity.java
│ │ │ ├── MainActivity.java
│ │ │ └── used
│ │ │ ├── EasyChartActivity.java
│ │ │ ├── EasyDialogActivity.java
│ │ │ ├── EasyEditTextActivity.java
│ │ │ ├── EasyRulerActivity.java
│ │ │ ├── MacAddressActivity.java
│ │ │ ├── PieProgressBarActivity.java
│ │ │ ├── ProgressBarActivity.java
│ │ │ └── TimingTextActivity.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── ic_launcher_background.xml
│ │ ├── round_check_24.xml
│ │ ├── round_delete_36.xml
│ │ ├── shape_confirm_bg.xml
│ │ └── shape_dialog_bg.xml
│ │ ├── layout
│ │ ├── activity_easy_chart.xml
│ │ ├── activity_easy_dialog.xml
│ │ ├── activity_easy_edittext.xml
│ │ ├── activity_easy_ruler.xml
│ │ ├── activity_mac_address.xml
│ │ ├── activity_main.xml
│ │ ├── activity_pie_progress_bar.xml
│ │ ├── activity_progress_bar.xml
│ │ ├── activity_timing_text.xml
│ │ └── dialog_warm_tip.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-anydpi-v33
│ │ └── ic_launcher.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
│ │ └── ic_logo.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── values-night
│ │ └── themes.xml
│ │ ├── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ │ └── xml
│ │ ├── backup_rules.xml
│ │ └── data_extraction_rules.xml
│ └── test
│ └── java
│ └── com
│ └── llw
│ └── easyview
│ └── ExampleUnitTest.java
├── build.gradle
├── easy
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── easy
│ │ └── view
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── easy
│ │ │ └── view
│ │ │ ├── CircularProgressBar.java
│ │ │ ├── EasyEditText.java
│ │ │ ├── EasyRuler.java
│ │ │ ├── MacAddressEditText.java
│ │ │ ├── PieProgressBar.java
│ │ │ ├── TimingTextView.java
│ │ │ ├── chart
│ │ │ ├── EasyChart.java
│ │ │ └── Point.java
│ │ │ ├── dialog
│ │ │ ├── DialogController.java
│ │ │ ├── DialogViewHelper.java
│ │ │ ├── EasyDialog.java
│ │ │ ├── EasyDialogUtils.java
│ │ │ ├── adapter
│ │ │ │ └── StringAdapter.java
│ │ │ └── listener
│ │ │ │ ├── OnCancelListener.java
│ │ │ │ ├── OnConfirmListener.java
│ │ │ │ ├── OnItemChildClickListener.java
│ │ │ │ ├── OnItemClickListener.java
│ │ │ │ └── OnSelectListener.java
│ │ │ ├── listener
│ │ │ ├── HexKeyboardListener.java
│ │ │ ├── NumberKeyboardListener.java
│ │ │ ├── OnValueChangeListener.java
│ │ │ └── TimingListener.java
│ │ │ └── utils
│ │ │ └── EasyUtils.java
│ └── res
│ │ ├── anim
│ │ ├── dialog_from_bottom_anim_in.xml
│ │ ├── dialog_from_bottom_anim_out.xml
│ │ ├── dialog_from_left_anim_in.xml
│ │ ├── dialog_from_left_anim_out.xml
│ │ ├── dialog_from_right_anim_in.xml
│ │ ├── dialog_from_right_anim_out.xml
│ │ ├── dialog_from_top_anim_in.xml
│ │ ├── dialog_from_top_anim_out.xml
│ │ ├── dialog_scale_anim_in.xml
│ │ └── dialog_scale_anim_out.xml
│ │ ├── drawable
│ │ ├── custom_divider.xml
│ │ ├── round_close_24.xml
│ │ ├── selector_cancel_bg.xml
│ │ ├── selector_confirm_bg.xml
│ │ ├── shape_bottom_left_radius_16_bg.xml
│ │ ├── shape_bottom_right_radius_16_bg.xml
│ │ ├── shape_cancel_16_bg.xml
│ │ ├── shape_cancel_pressed_16_bg.xml
│ │ ├── shape_confirm_16_bg.xml
│ │ ├── shape_confirm_pressed_16_bg.xml
│ │ └── shape_dialog_base_bg.xml
│ │ ├── layout
│ │ ├── dialog_select.xml
│ │ ├── dialog_tip.xml
│ │ ├── item_string.xml
│ │ ├── lay_hex_keyboard.xml
│ │ └── lay_number_keyboard.xml
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── easy
│ └── view
│ └── ExampleUnitTest.java
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.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 | /secring.gpg
17 | /key.properties
18 | secring.gpg
19 | key.properties
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.idea/appInsightsSettings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
22 |
23 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/deploymentTargetDropDown.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/deploymentTargetSelector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/google-java-format.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/migrations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/README.md
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | }
4 |
5 | android {
6 | namespace 'com.llw.easyview'
7 | compileSdk 33
8 |
9 | defaultConfig {
10 | applicationId "com.llw.easyview"
11 | minSdk 16
12 | targetSdk 33
13 | versionCode 106
14 | versionName "1.0.6"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 | compileOptions {
26 | sourceCompatibility JavaVersion.VERSION_1_8
27 | targetCompatibility JavaVersion.VERSION_1_8
28 | }
29 |
30 | buildFeatures {
31 | viewBinding true
32 | }
33 | }
34 |
35 | dependencies {
36 |
37 | implementation 'androidx.appcompat:appcompat:1.5.1'
38 | implementation 'com.google.android.material:material:1.6.1'
39 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
40 | implementation project(path: ':easy')
41 | testImplementation 'junit:junit:4.13.2'
42 | androidTestImplementation 'androidx.test.ext:junit:1.1.3'
43 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
44 | }
--------------------------------------------------------------------------------
/app/gif/1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/app/gif/1.gif
--------------------------------------------------------------------------------
/app/gif/2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/app/gif/2.gif
--------------------------------------------------------------------------------
/app/gif/3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/app/gif/3.gif
--------------------------------------------------------------------------------
/app/gif/4.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/app/gif/4.gif
--------------------------------------------------------------------------------
/app/gif/5.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/app/gif/5.gif
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/llw/easyview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.llw.easyview;
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.llw.easyview", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
14 |
17 |
21 |
25 |
29 |
33 |
37 |
41 |
45 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/llw/easyview/EasyActivity.java:
--------------------------------------------------------------------------------
1 | package com.llw.easyview;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.LayoutInflater;
7 | import android.view.MenuItem;
8 | import android.widget.Toast;
9 |
10 | import androidx.annotation.Nullable;
11 | import androidx.appcompat.app.AppCompatActivity;
12 | import androidx.viewbinding.ViewBinding;
13 | import java.lang.reflect.Method;
14 | import java.lang.reflect.ParameterizedType;
15 | import java.lang.reflect.Type;
16 |
17 | public abstract class EasyActivity extends AppCompatActivity {
18 |
19 | protected T binding;
20 | protected Context context;
21 |
22 | @Override
23 | protected void onCreate(@Nullable Bundle savedInstanceState) {
24 | onRegister();
25 | super.onCreate(savedInstanceState);
26 | this.context = this;
27 | Type type = this.getClass().getGenericSuperclass();
28 | if (type instanceof ParameterizedType) {
29 | try {
30 | Class clazz = (Class) ((ParameterizedType) type).getActualTypeArguments()[0];
31 | //反射
32 | Method method = clazz.getMethod("inflate", LayoutInflater.class);
33 | binding = (T) method.invoke(null, getLayoutInflater());
34 | } catch (Exception e) {
35 | e.printStackTrace();
36 | }
37 | setContentView(binding.getRoot());
38 | }
39 | onCreate();
40 | }
41 |
42 | protected void onRegister() {
43 |
44 | }
45 |
46 | protected abstract void onCreate();
47 |
48 | @Override
49 | public boolean onOptionsItemSelected(MenuItem item) {
50 | switch (item.getItemId()) {
51 | case android.R.id.home:
52 | onBackPressed();
53 | return true;
54 | default:
55 | return super.onOptionsItemSelected(item);
56 | }
57 | }
58 |
59 | protected void showMsg(CharSequence easy) {
60 | Toast.makeText(context, easy, Toast.LENGTH_SHORT).show();
61 | }
62 |
63 | protected void jumpActivity(final Class> clazz) {
64 | startActivity(new Intent(context, clazz));
65 | }
66 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/llw/easyview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.llw.easyview;
2 |
3 | import com.llw.easyview.databinding.ActivityMainBinding;
4 | import com.llw.easyview.used.EasyChartActivity;
5 | import com.llw.easyview.used.EasyDialogActivity;
6 | import com.llw.easyview.used.EasyRulerActivity;
7 | import com.llw.easyview.used.MacAddressActivity;
8 | import com.llw.easyview.used.PieProgressBarActivity;
9 | import com.llw.easyview.used.ProgressBarActivity;
10 | import com.llw.easyview.used.TimingTextActivity;
11 | import com.llw.easyview.used.EasyEditTextActivity;
12 |
13 | /**
14 | * 主页面功能跳转
15 | */
16 | public class MainActivity extends EasyActivity {
17 |
18 | @Override
19 | protected void onCreate() {
20 | binding.btnMadAddress.setOnClickListener(v -> jumpActivity(MacAddressActivity.class));
21 | binding.btnProgressBar.setOnClickListener(v -> jumpActivity(ProgressBarActivity.class));
22 | binding.btnTimingText.setOnClickListener(v -> jumpActivity(TimingTextActivity.class));
23 | binding.btnEasyEdittext.setOnClickListener(v -> jumpActivity(EasyEditTextActivity.class));
24 | binding.btnPieProgressBar.setOnClickListener(v -> jumpActivity(PieProgressBarActivity.class));
25 | binding.btnEasyDialog.setOnClickListener(v -> jumpActivity(EasyDialogActivity.class));
26 | //binding.btnEasyChart.setOnClickListener(v -> jumpActivity(EasyChartActivity.class));
27 | binding.btnEasyRuler.setOnClickListener(v -> jumpActivity(EasyRulerActivity.class));
28 | }
29 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/llw/easyview/used/EasyChartActivity.java:
--------------------------------------------------------------------------------
1 | package com.llw.easyview.used;
2 |
3 | import com.llw.easyview.EasyActivity;
4 | import com.llw.easyview.databinding.ActivityEasyChartBinding;
5 |
6 | import java.util.HashMap;
7 | import java.util.Map;
8 |
9 | /**
10 | * 简易图表使用
11 | */
12 | public class EasyChartActivity extends EasyActivity {
13 |
14 | @Override
15 | protected void onCreate() {
16 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
17 | Map map = new HashMap<>();
18 | map.put("一月", 20);
19 | map.put("二月", 10);
20 | map.put("三月", 30);
21 | map.put("四月", 60);
22 | map.put("五月", 50);
23 | //设置数据
24 | binding.eChart.setData(map);
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/llw/easyview/used/EasyDialogActivity.java:
--------------------------------------------------------------------------------
1 | package com.llw.easyview.used;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.view.Gravity;
5 | import android.view.View;
6 | import android.widget.CompoundButton;
7 | import android.widget.LinearLayout;
8 | import android.widget.RadioGroup;
9 |
10 | import androidx.core.content.ContextCompat;
11 |
12 | import com.easy.view.dialog.EasyDialogUtils;
13 | import com.easy.view.dialog.EasyDialog;
14 | import com.easy.view.dialog.listener.OnSelectListener;
15 | import com.easy.view.utils.EasyUtils;
16 | import com.llw.easyview.EasyActivity;
17 | import com.llw.easyview.R;
18 | import com.llw.easyview.databinding.ActivityEasyDialogBinding;
19 |
20 | import java.util.ArrayList;
21 | import java.util.Arrays;
22 | import java.util.List;
23 |
24 | /**
25 | * 简易弹窗使用
26 | */
27 | public class EasyDialogActivity extends EasyActivity implements View.OnClickListener, CompoundButton.OnCheckedChangeListener, RadioGroup.OnCheckedChangeListener {
28 |
29 | private EasyDialog easyDialog;
30 | private EasyDialog.Builder builder;
31 | private int mGravity;
32 | private boolean mIsAnimation;
33 | private boolean mIsCancelable;
34 | private final String[] stringArr = {"富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信", "友善"};
35 | List stringList;
36 | @Override
37 | protected void onCreate() {
38 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
39 |
40 | builder = new EasyDialog.Builder(EasyDialogActivity.this);
41 | stringList = new ArrayList<>(Arrays.asList(stringArr));
42 | initView();
43 | }
44 |
45 | private void initView() {
46 | binding.btnShow.setOnClickListener(this);
47 | binding.btnShowTip.setOnClickListener(this);
48 | binding.btnShowSelect.setOnClickListener(this);
49 | binding.rgGravity.setOnCheckedChangeListener(this);
50 | binding.cbAnimation.setOnCheckedChangeListener(this);
51 | binding.cbCancelable.setOnCheckedChangeListener(this);
52 | }
53 |
54 | @Override
55 | public void onCheckedChanged(RadioGroup group, int checkedId) {
56 | if (builder != null) {
57 | switch (checkedId) {
58 | case R.id.rb_top:
59 | mGravity = Gravity.TOP;
60 | break;
61 | case R.id.rb_right:
62 | mGravity = Gravity.RIGHT;
63 | break;
64 | case R.id.rb_bottom:
65 | mGravity = Gravity.BOTTOM;
66 | break;
67 | case R.id.rb_left:
68 | mGravity = Gravity.LEFT;
69 | break;
70 | case R.id.rb_center:
71 | mGravity = Gravity.CENTER;
72 | break;
73 | }
74 | }
75 | }
76 |
77 | @Override
78 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
79 | if (builder != null) {
80 | switch (buttonView.getId()) {
81 | case R.id.cb_animation:
82 | mIsAnimation = isChecked;
83 | break;
84 | case R.id.cb_cancelable:
85 | mIsCancelable = isChecked;
86 | break;
87 | }
88 | }
89 | }
90 |
91 | @SuppressLint("NonConstantResourceId")
92 | @Override
93 | public void onClick(View v) {
94 | switch (v.getId()) {
95 | case R.id.btn_show:
96 | showDialog();
97 | break;
98 | case R.id.btn_show_tip:
99 | EasyDialogUtils.showTipDialog(EasyDialogActivity.this, "温馨提示", "端午又要调休!",
100 | () -> showMsg("取消"), () -> showMsg("确定"));
101 | break;
102 | case R.id.btn_show_select:
103 | EasyDialogUtils.showSelectDialog(EasyDialogActivity.this, "社会主义核心价值观",
104 | stringList, this::showMsg);
105 | break;
106 | }
107 | }
108 |
109 | /**
110 | * 显示弹窗
111 | */
112 | private void showDialog() {
113 | builder.setContentView(R.layout.dialog_warm_tip)
114 | //添加自定义动画
115 | .addCustomAnimation(mGravity, mIsAnimation)
116 | //设置对话框可取消
117 | .setCancelable(mIsCancelable)
118 | //设置标题
119 | .setText(R.id.tv_title, "温馨提示")
120 | //设置内容
121 | .setText(R.id.tv_content, "您今天还没有搞钱,请记得搞钱!")
122 | //设置文字颜色
123 | .setTextColor(R.id.tv_confirm, ContextCompat.getColor(EasyDialogActivity.this, R.color.white))
124 | //设置背景资源
125 | .setBackground(R.id.tv_confirm, ContextCompat.getDrawable(EasyDialogActivity.this, R.drawable.shape_confirm_bg))
126 | //设置弹窗宽高
127 | .setWidthAndHeight(EasyUtils.dp2px(EasyDialogActivity.this, 320), LinearLayout.LayoutParams.WRAP_CONTENT)
128 | //添加点击事件 取消
129 | .setOnClickListener(R.id.tv_cancel, v1 -> {
130 | easyDialog.dismiss();
131 | })
132 | //添加点击事件 确定
133 | .setOnClickListener(R.id.tv_confirm, v2 -> {
134 | showMsg("我知道了!");
135 | easyDialog.dismiss();
136 | })
137 | //添加取消监听
138 | .setOnCancelListener(dialog -> {
139 | showMsg("弹窗取消了");
140 | })
141 | //弹窗消失监听
142 | .setOnDismissListener(dialog -> {
143 | showMsg("弹窗消失了");
144 | });
145 | //创建弹窗
146 | easyDialog = builder.create();
147 | //显示弹窗
148 | easyDialog.show();
149 | }
150 |
151 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/llw/easyview/used/EasyEditTextActivity.java:
--------------------------------------------------------------------------------
1 | package com.llw.easyview.used;
2 |
3 | import com.llw.easyview.EasyActivity;
4 | import com.llw.easyview.databinding.ActivityEasyEdittextBinding;
5 |
6 | /**
7 | * 简易输入框使用示例
8 | */
9 | public class EasyEditTextActivity extends EasyActivity {
10 |
11 | @Override
12 | protected void onCreate() {
13 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
14 | binding.cbFlag.setOnCheckedChangeListener((buttonView, isChecked) -> {
15 | binding.etContent.setCiphertext(isChecked);
16 | binding.cbFlag.setText(isChecked ? "密文" : "明文");
17 | });
18 | //输入框
19 | binding.btnGetContent.setOnClickListener(v -> {
20 | String content = binding.etContent.getText();
21 | if (content.isEmpty()) {
22 | showMsg("请输入内容");
23 | return;
24 | }
25 | if (content.length() < binding.etContent.getBoxNum()) {
26 | showMsg("请输入完整内容");
27 | return;
28 | }
29 | showMsg("输入内容为:" + content);
30 | });
31 | }
32 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/llw/easyview/used/EasyRulerActivity.java:
--------------------------------------------------------------------------------
1 | package com.llw.easyview.used;
2 |
3 | import com.llw.easyview.EasyActivity;
4 | import com.llw.easyview.databinding.ActivityEasyRulerBinding;
5 |
6 | public class EasyRulerActivity extends EasyActivity {
7 |
8 | @Override
9 | protected void onCreate() {
10 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
11 | binding.ruler.setValue(170F, 80F, 250F, 1F);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/llw/easyview/used/MacAddressActivity.java:
--------------------------------------------------------------------------------
1 | package com.llw.easyview.used;
2 |
3 | import com.llw.easyview.EasyActivity;
4 | import com.llw.easyview.databinding.ActivityMacAddressBinding;
5 |
6 | /**
7 | * MacAddress 使用示例
8 | */
9 | public class MacAddressActivity extends EasyActivity {
10 |
11 | @Override
12 | protected void onCreate() {
13 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
14 | //蓝牙地址输入框
15 | binding.btnMac.setOnClickListener(v -> {
16 | String macAddress = binding.macEt.getMacAddress();
17 | if (macAddress.isEmpty()) {
18 | showMsg("请输入Mac地址");
19 | return;
20 | }
21 | binding.btnMac.setText(macAddress);
22 | });
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/llw/easyview/used/PieProgressBarActivity.java:
--------------------------------------------------------------------------------
1 | package com.llw.easyview.used;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.widget.Toast;
5 | import com.llw.easyview.EasyActivity;
6 | import com.llw.easyview.R;
7 | import com.llw.easyview.databinding.ActivityPieProgressBarBinding;
8 |
9 | import java.util.Random;
10 |
11 | /**
12 | * 饼状进度条使用示例
13 | */
14 | public class PieProgressBarActivity extends EasyActivity {
15 |
16 | @SuppressLint("NonConstantResourceId")
17 | @Override
18 | protected void onCreate() {
19 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
20 | //是否渐变
21 | binding.cbGradient.setOnCheckedChangeListener((buttonView, isChecked) -> {
22 | binding.cbGradient.setText(isChecked ? "渐变" : "不渐变");
23 | binding.progress.setGradient(isChecked);
24 | });
25 | //开始角度
26 | binding.rg.setOnCheckedChangeListener((group, checkedId) -> {
27 | int angle = 0;
28 | switch (checkedId) {
29 | case R.id.rb_0:
30 | angle = 0;
31 | break;
32 | case R.id.rb_90:
33 | angle = 90;
34 | break;
35 | case R.id.rb_180:
36 | angle = 180;
37 | break;
38 | case R.id.rb_270:
39 | angle = 270;
40 | break;
41 | }
42 | binding.progress.setCustomAngle(angle);
43 | });
44 | binding.cbFlag.setOnCheckedChangeListener((buttonView, isChecked) -> {
45 | binding.progress.setCounterClockwise(isChecked);
46 | binding.cbFlag.setText(isChecked ? "逆时针" : "顺时针");
47 | });
48 | //设置随机进度值
49 | binding.btnSetProgress.setOnClickListener(v -> {
50 | int progress = Math.abs(new Random().nextInt() % 100);
51 | Toast.makeText(this, "" + progress, Toast.LENGTH_SHORT).show();
52 | binding.progress.setProgress(progress);
53 | });
54 | //设置0%进度值
55 | binding.btnSetProgress0.setOnClickListener(v -> binding.progress.setProgress(0));
56 | //设置100%进度值
57 | binding.btnSetProgress100.setOnClickListener(v -> binding.progress.setProgress(100));
58 | }
59 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/llw/easyview/used/ProgressBarActivity.java:
--------------------------------------------------------------------------------
1 | package com.llw.easyview.used;
2 |
3 | import android.graphics.Color;
4 | import android.widget.Toast;
5 | import com.llw.easyview.EasyActivity;
6 | import com.llw.easyview.R;
7 | import com.llw.easyview.databinding.ActivityProgressBarBinding;
8 |
9 | import java.util.Random;
10 |
11 | /**
12 | * 进度条使用示例
13 | */
14 | public class ProgressBarActivity extends EasyActivity {
15 |
16 | @Override
17 | protected void onCreate() {
18 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
19 |
20 | //开始角度
21 | binding.rg.setOnCheckedChangeListener((group, checkedId) -> {
22 | int angle = 0;
23 | switch (checkedId) {
24 | case R.id.rb_0:
25 | angle = 0;
26 | break;
27 | case R.id.rb_90:
28 | angle = 90;
29 | break;
30 | case R.id.rb_180:
31 | angle = 180;
32 | break;
33 | case R.id.rb_270:
34 | angle = 270;
35 | break;
36 | }
37 | binding.cpbTest.setCustomAngle(angle);
38 | });
39 | binding.cbFlag.setOnCheckedChangeListener((buttonView, isChecked) -> {
40 | binding.cpbTest.setCounterClockwise(isChecked);
41 | binding.cbFlag.setText(isChecked ? "逆时针" : "顺时针");
42 | });
43 | //圆形进度条操作
44 | binding.btnSetProgress.setOnClickListener(v -> {
45 | int progress = Math.abs(new Random().nextInt() % 100);
46 | Toast.makeText(this, "" + progress, Toast.LENGTH_SHORT).show();
47 | binding.cpbTest.setText(progress + "%");
48 | binding.cpbTest.setProgress(progress);
49 | binding.cpbTest.setGradient(true);
50 | binding.cpbTest.setColorArray(new int[]{Color.RED,Color.YELLOW});
51 | });
52 |
53 | }
54 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/llw/easyview/used/TimingTextActivity.java:
--------------------------------------------------------------------------------
1 | package com.llw.easyview.used;
2 |
3 | import com.llw.easyview.EasyActivity;
4 | import com.llw.easyview.databinding.ActivityTimingTextBinding;
5 |
6 | /**
7 | * 计时文字使用示例
8 | */
9 | public class TimingTextActivity extends EasyActivity {
10 |
11 | @Override
12 | protected void onCreate() {
13 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
14 | //计时文本操作
15 | binding.tvTiming.setListener(() -> {
16 | binding.tvTiming.setText("计时文字");
17 | binding.btnStart.setText("开始");
18 | });
19 | binding.cbFlag.setOnCheckedChangeListener((buttonView, isChecked) -> binding.cbFlag.setText(isChecked ? "倒计时" : "计时"));
20 | //计时按钮点击
21 | binding.btnStart.setOnClickListener(v -> {
22 | if (binding.tvTiming.isTiming()) {
23 | //停止计时
24 | binding.tvTiming.end();
25 | binding.btnStart.setText("开始");
26 | } else {
27 | binding.tvTiming.setMax(6);
28 | binding.tvTiming.setCountDown(binding.cbFlag.isChecked());
29 | binding.tvTiming.setUnit(3);//单位 秒
30 | //开始计时
31 | binding.tvTiming.start();
32 | binding.btnStart.setText("停止");
33 | }
34 | });
35 | }
36 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/round_check_24.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/round_delete_36.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_confirm_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_dialog_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_easy_chart.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_easy_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
18 |
22 |
27 |
28 |
33 |
34 |
39 |
40 |
45 |
46 |
51 |
52 |
57 |
58 |
63 |
64 |
65 |
66 |
71 |
72 |
77 |
78 |
83 |
84 |
90 |
91 |
96 |
97 |
102 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_easy_edittext.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
25 |
26 |
32 |
33 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_easy_ruler.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_mac_address.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
22 |
23 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
13 |
19 |
25 |
26 |
32 |
33 |
39 |
40 |
46 |
47 |
53 |
54 |
60 |
61 |
68 |
69 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_pie_progress_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
26 |
27 |
33 |
34 |
40 |
41 |
45 |
46 |
51 |
52 |
57 |
58 |
64 |
65 |
70 |
71 |
76 |
77 |
82 |
83 |
84 |
85 |
86 |
92 |
93 |
99 |
100 |
106 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_progress_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
29 |
30 |
35 |
36 |
41 |
42 |
47 |
48 |
54 |
55 |
60 |
61 |
66 |
67 |
72 |
73 |
74 |
75 |
81 |
82 |
88 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_timing_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
22 |
23 |
29 |
30 |
35 |
36 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_warm_tip.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
20 |
21 |
27 |
28 |
39 |
40 |
46 |
47 |
61 |
62 |
72 |
73 |
86 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/app/src/main/res/mipmap-xhdpi/ic_logo.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 | #009C3A
11 | #02752D
12 | #EEE
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | EasyView
3 |
4 |
5 | - #00FFF7
6 | - #FFDD00
7 | - #FF0000
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/src/test/java/com/llw/easyview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.llw.easyview;
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 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | plugins {
3 | id 'com.android.application' version '7.4.0' apply false
4 | id 'com.android.library' version '7.4.0' apply false
5 | }
--------------------------------------------------------------------------------
/easy/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/easy/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'maven-publish'
4 | id 'signing'
5 | }
6 |
7 | Properties properties = new Properties()
8 | properties.load(project.rootProject.file('gradle.properties').newDataInputStream())
9 |
10 | def GROUP_ID = properties.getProperty('GROUP_ID')
11 | def ARTIFACT_ID = properties.getProperty('ARTIFACT_ID')
12 | def VERSION_NAME = properties.getProperty('VERSION_NAME')
13 |
14 | def POM_NAME = properties.getProperty('POM_NAME')
15 | def POM_DESCRIPTION = properties.getProperty('POM_DESCRIPTION')
16 | def POM_INCEPTION_YEAR = properties.getProperty('POM_INCEPTION_YEAR')
17 | def POM_URL = properties.getProperty('POM_URL')
18 |
19 | def POM_LICENCE_COMMENTS = properties.getProperty('POM_LICENCE_COMMENTS')
20 | def POM_LICENCE_NAME = properties.getProperty('POM_LICENCE_NAME')
21 | def POM_LICENCE_URL = properties.getProperty('POM_LICENCE_URL')
22 | def POM_LICENCE_DIST = properties.getProperty('POM_LICENCE_DIST')
23 |
24 | def POM_SCM_URL = properties.getProperty('POM_SCM_URL')
25 | def POM_SCM_CONNECTION = properties.getProperty('POM_SCM_CONNECTION')
26 | def POM_SCM_DEV_CONNECTION = properties.getProperty('POM_SCM_DEV_CONNECTION')
27 |
28 | def POM_DEVELOPER_ID = properties.getProperty('POM_DEVELOPER_ID')
29 | def POM_DEVELOPER_NAME = properties.getProperty('POM_DEVELOPER_NAME')
30 | def POM_DEVELOPER_EMAIL = properties.getProperty('POM_DEVELOPER_EMAIL')
31 | def POM_DEVELOPER_URL = properties.getProperty('POM_DEVELOPER_URL')
32 | def POM_ISSUE_MANAGEMENT_SYSTEM = properties.getProperty('POM_ISSUE_MANAGEMENT_SYSTEM')
33 | def POM_ISSUE_MANAGEMENT_URL = properties.getProperty('POM_ISSUE_MANAGEMENT_URL')
34 |
35 |
36 | configurations {
37 | javadocDeps
38 | }
39 |
40 | android {
41 | namespace 'com.easy.view'
42 | compileSdk 33
43 |
44 | defaultConfig {
45 | minSdk 15
46 | targetSdk 33
47 | }
48 |
49 | buildTypes {
50 | release {
51 | minifyEnabled false
52 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
53 | }
54 | }
55 | compileOptions {
56 | sourceCompatibility JavaVersion.VERSION_1_8
57 | targetCompatibility JavaVersion.VERSION_1_8
58 | }
59 |
60 | task javadoc(type: Javadoc) {
61 | source = android.sourceSets.main.java.srcDirs
62 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + configurations.javadocDeps
63 | }
64 |
65 | buildFeatures {
66 | viewBinding true
67 | }
68 |
69 | javadoc {
70 | options {
71 | encoding "UTF-8"
72 | charSet 'UTF-8'
73 | author true
74 | version true
75 | links "http://docs.oracle.com/javase/8/docs/api"
76 | }
77 | }
78 | }
79 |
80 | dependencies {
81 | // implementation 'androidx.annotation:annotation:1.6.0'
82 | implementation 'com.android.support:support-annotations:28.0.0'
83 | javadocDeps 'com.android.support:support-annotations:28.0.0'
84 | implementation 'androidx.appcompat:appcompat:1.5.1'
85 | implementation 'com.google.android.material:material:1.6.1'
86 | testImplementation 'junit:junit:4.13.2'
87 | androidTestImplementation 'androidx.test.ext:junit:1.1.3'
88 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
89 | }
90 |
91 | def getRepositoryUsername() {
92 | return hasProperty('MAVEN_USERNAME') ? MAVEN_USERNAME : ""
93 | }
94 |
95 | def getRepositoryPassword() {
96 | return hasProperty('MAVEN_PASSWORD') ? MAVEN_PASSWORD : ""
97 | }
98 |
99 | def getReleaseRepositoryUrl() {
100 | return "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
101 | }
102 |
103 | def getSnapshotRepositoryUrl() {
104 | return "https://s01.oss.sonatype.org/content/repositories/snapshots/"
105 | }
106 |
107 | publishing {
108 | publications {
109 | maven(MavenPublication) {
110 | groupId GROUP_ID
111 | artifactId ARTIFACT_ID
112 | version VERSION_NAME
113 | pom {
114 | name = POM_NAME
115 | description = POM_DESCRIPTION
116 | url = POM_URL
117 | inceptionYear = POM_INCEPTION_YEAR
118 |
119 | scm {
120 | url = POM_SCM_URL
121 | connection = POM_SCM_CONNECTION
122 | developerConnection = POM_SCM_DEV_CONNECTION
123 | }
124 |
125 | licenses {
126 | license {
127 | name = POM_LICENCE_NAME
128 | url = POM_LICENCE_URL
129 | distribution = POM_LICENCE_DIST
130 | comments = POM_LICENCE_COMMENTS
131 | }
132 | }
133 |
134 | developers {
135 | developer {
136 | id = POM_DEVELOPER_ID
137 | name = POM_DEVELOPER_NAME
138 | email = POM_DEVELOPER_EMAIL
139 | url = POM_DEVELOPER_URL
140 | }
141 | }
142 |
143 | issueManagement {
144 | system = POM_ISSUE_MANAGEMENT_SYSTEM
145 | url = POM_ISSUE_MANAGEMENT_URL
146 | }
147 | }
148 | artifact './build/outputs/aar/easy-release.aar'
149 | }
150 | }
151 | repositories {
152 | maven {
153 | // 指定要上传的maven仓库
154 | url = VERSION_NAME.contains('SNAPSHOT') ? getSnapshotRepositoryUrl() : getReleaseRepositoryUrl()
155 | //Maven仓库用户名和密码
156 | credentials {
157 | username getRepositoryUsername()
158 | password getRepositoryPassword()
159 | }
160 | }
161 | }
162 | }
163 | signing {
164 | sign publishing.publications.maven //签名配置
165 | }
166 |
167 |
168 |
--------------------------------------------------------------------------------
/easy/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/easy/consumer-rules.pro
--------------------------------------------------------------------------------
/easy/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
--------------------------------------------------------------------------------
/easy/src/androidTest/java/com/easy/view/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.easy.view;
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.easy.view.test", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/easy/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/CircularProgressBar.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view;
17 |
18 | import android.animation.ValueAnimator;
19 | import android.content.Context;
20 | import android.content.res.TypedArray;
21 | import android.graphics.Canvas;
22 | import android.graphics.Color;
23 | import android.graphics.LinearGradient;
24 | import android.graphics.Paint;
25 | import android.graphics.Rect;
26 | import android.graphics.RectF;
27 | import android.graphics.Shader;
28 | import android.util.AttributeSet;
29 | import android.util.TypedValue;
30 | import android.view.View;
31 | import androidx.annotation.Nullable;
32 | import androidx.core.content.ContextCompat;
33 |
34 | /**
35 | * 圆环进度条
36 | *
37 | * @author llw
38 | * @since 2023/4/3
39 | */
40 | public class CircularProgressBar extends View {
41 |
42 | /**
43 | * 半径
44 | */
45 | private int mRadius;
46 | /**
47 | * 进度条宽度
48 | */
49 | private int mStrokeWidth;
50 |
51 | /**
52 | * 进度条背景颜色
53 | */
54 | private int mProgressbarBgColor;
55 |
56 | /**
57 | * 进度条进度颜色
58 | */
59 | private int mProgressColor;
60 |
61 | /**
62 | * 开始角度
63 | */
64 | private int mStartAngle = 0;
65 |
66 | /**
67 | * 当前角度
68 | */
69 | private float mCurrentAngle = 0;
70 |
71 | /**
72 | * 结束角度
73 | */
74 | private int mEndAngle = 360;
75 | /**
76 | * 最大进度
77 | */
78 | private float mMaxProgress;
79 | /**
80 | * 当前进度
81 | */
82 | private float mCurrentProgress;
83 | /**
84 | * 文字
85 | */
86 | private String mText;
87 | /**
88 | * 文字颜色
89 | */
90 | private int mTextColor;
91 | /**
92 | * 文字大小
93 | */
94 | private float mTextSize;
95 | /**
96 | * 是否渐变
97 | */
98 | private boolean isGradient;
99 | /**
100 | * 渐变颜色数组
101 | */
102 | private int[] colorArray;
103 | /**
104 | * 动画的执行时长
105 | */
106 | private long mDuration = 1000;
107 | /**
108 | * 是否执行动画
109 | */
110 | private boolean isAnimation = false;
111 | /**
112 | * 是否逆时针绘制
113 | */
114 | private boolean isCounterClockwise = false;
115 |
116 | public CircularProgressBar(Context context) {
117 | this(context, null);
118 | }
119 |
120 | public CircularProgressBar(Context context, @Nullable AttributeSet attrs) {
121 | this(context, attrs, 0);
122 | }
123 |
124 | public CircularProgressBar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
125 | super(context, attrs, defStyleAttr);
126 | TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.CircularProgressBar);
127 | mRadius = array.getDimensionPixelSize(R.styleable.CircularProgressBar_radius, 80);
128 | mStrokeWidth = array.getDimensionPixelSize(R.styleable.CircularProgressBar_strokeWidth, 8);
129 | mProgressbarBgColor = array.getColor(R.styleable.CircularProgressBar_progressbarBackgroundColor, ContextCompat.getColor(context, R.color.teal_700));
130 | mProgressColor = array.getColor(R.styleable.CircularProgressBar_progressbarColor, ContextCompat.getColor(context, R.color.teal_200));
131 | mMaxProgress = array.getInt(R.styleable.CircularProgressBar_maxProgress, 100);
132 | mCurrentProgress = array.getInt(R.styleable.CircularProgressBar_progress, 0);
133 | String text = array.getString(R.styleable.CircularProgressBar_text);
134 | mText = text == null ? "" : text;
135 | mTextColor = array.getColor(R.styleable.CircularProgressBar_textColor, ContextCompat.getColor(context, R.color.black));
136 | mTextSize = array.getDimensionPixelSize(R.styleable.CircularProgressBar_textSize, (int) TypedValue
137 | .applyDimension(TypedValue.COMPLEX_UNIT_SP, 14, getResources().getDisplayMetrics()));
138 | //是否渐变
139 | isGradient = array.getBoolean(R.styleable.CircularProgressBar_gradient, false);
140 | //渐变颜色数组
141 | CharSequence[] textArray = array.getTextArray(R.styleable.CircularProgressBar_gradientColorArray);
142 | if (textArray != null) {
143 | colorArray = new int[textArray.length];
144 | for (int i = 0; i < textArray.length; i++) {
145 | colorArray[i] = Color.parseColor((String) textArray[i]);
146 | }
147 | }
148 | // 开始角度
149 | mStartAngle = array.getInt(R.styleable.CircularProgressBar_customAngle, 0);
150 | // 是否逆时针绘制
151 | isCounterClockwise = array.getBoolean(R.styleable.CircularProgressBar_counterClockwise, false);
152 | array.recycle();
153 | }
154 |
155 | @Override
156 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
157 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
158 | int width = 0;
159 | switch (MeasureSpec.getMode(widthMeasureSpec)) {
160 | case MeasureSpec.UNSPECIFIED:
161 | case MeasureSpec.AT_MOST: //wrap_content
162 | width = mRadius * 2;
163 | break;
164 | case MeasureSpec.EXACTLY: //match_parent
165 | width = MeasureSpec.getSize(widthMeasureSpec);
166 | break;
167 | }
168 | //Set the measured width and height
169 | setMeasuredDimension(width, width);
170 | }
171 |
172 | @Override
173 | protected void onDraw(Canvas canvas) {
174 | int centerX = getWidth() / 2;
175 | RectF rectF = new RectF();
176 | rectF.left = mStrokeWidth / 2;
177 | rectF.top = mStrokeWidth / 2;
178 | rectF.right = centerX * 2 - mStrokeWidth / 2;
179 | rectF.bottom = centerX * 2 - mStrokeWidth / 2;
180 |
181 | //绘制进度条背景
182 | drawProgressbarBg(canvas, rectF);
183 | //绘制进度
184 | drawProgress(canvas, rectF);
185 | //绘制中心文本
186 | drawCenterText(canvas, centerX);
187 | }
188 |
189 | /**
190 | * 绘制进度条背景
191 | */
192 | private void drawProgressbarBg(Canvas canvas, RectF rectF) {
193 | Paint mPaint = new Paint();
194 | //画笔的填充样式,Paint.Style.STROKE 描边
195 | mPaint.setStyle(Paint.Style.STROKE);
196 | //圆弧的宽度
197 | mPaint.setStrokeWidth(mStrokeWidth);
198 | //抗锯齿
199 | mPaint.setAntiAlias(true);
200 | //画笔的颜色
201 | mPaint.setColor(mProgressbarBgColor);
202 | //画笔的样式 Paint.Cap.Round 圆形
203 | mPaint.setStrokeCap(Paint.Cap.ROUND);
204 | //开始画圆弧
205 | canvas.drawArc(rectF, mStartAngle, mEndAngle, false, mPaint);
206 | }
207 |
208 | /**
209 | * 绘制进度
210 | */
211 | private void drawProgress(Canvas canvas, RectF rectF) {
212 | Paint paint = new Paint();
213 | paint.setStyle(Paint.Style.STROKE);
214 | paint.setStrokeWidth(mStrokeWidth);
215 | paint.setColor(mProgressColor);
216 |
217 | if (isGradient && colorArray != null) {
218 | paint.setShader(new LinearGradient(0, 0, rectF.right, rectF.top, colorArray, null, Shader.TileMode.MIRROR));
219 | }
220 |
221 | paint.setAntiAlias(true);
222 | paint.setStrokeCap(Paint.Cap.ROUND);
223 | if (!isAnimation) {
224 | mCurrentAngle = 360 * (mCurrentProgress / mMaxProgress);
225 | }
226 |
227 | // 根据 isCounterClockwise 调整绘制角度
228 | float startAngle = mStartAngle;
229 | float sweepAngle = mCurrentAngle;
230 | if (isCounterClockwise) {
231 | startAngle = mStartAngle - 360;
232 | sweepAngle = -mCurrentAngle;
233 | }
234 |
235 | canvas.drawArc(rectF, startAngle, sweepAngle, false, paint);
236 | }
237 |
238 | /**
239 | * 绘制中心文字
240 | */
241 | private void drawCenterText(Canvas canvas, int centerX) {
242 | Paint paint = new Paint();
243 | paint.setAntiAlias(true);
244 | paint.setColor(mTextColor);
245 | paint.setTextAlign(Paint.Align.CENTER);
246 | paint.setTextSize(mTextSize);
247 | Rect textBounds = new Rect();
248 | paint.getTextBounds(mText, 0, mText.length(), textBounds);
249 | canvas.drawText(mText, centerX, textBounds.height() / 2 + getHeight() / 2, paint);
250 | }
251 |
252 | /**
253 | * 设置当前进度
254 | */
255 | public void setProgress(float progress) {
256 | if (progress < 0) {
257 | throw new IllegalArgumentException("Progress value can not be less than 0");
258 | }
259 | if (progress > mMaxProgress) {
260 | progress = mMaxProgress;
261 | }
262 | mCurrentProgress = progress;
263 | mCurrentAngle = 360 * (mCurrentProgress / mMaxProgress);
264 | setAnimator(mStartAngle, mCurrentAngle);
265 | }
266 |
267 | /**
268 | * 设置文本
269 | */
270 | public void setText(String text) {
271 | mText = text;
272 | }
273 |
274 | /**
275 | * 设置文本的颜色
276 | */
277 | public void setTextColor(int color) {
278 | if (color <= 0) {
279 | throw new IllegalArgumentException("Color value can not be less than 0");
280 | }
281 | mTextColor = color;
282 | }
283 |
284 | /**
285 | * 设置文本的大小
286 | */
287 | public void setTextSize(float textSize) {
288 | if (textSize <= 0) {
289 | throw new IllegalArgumentException("textSize can not be less than 0");
290 | }
291 | mTextSize = textSize;
292 | }
293 |
294 | /**
295 | * 设置角度
296 | * @param angle 角度
297 | */
298 | public void setCustomAngle(int angle) {
299 | if (angle >= 0 && angle < 90) {
300 | mStartAngle = 0;
301 | } else if (angle >= 90 && angle < 180) {
302 | mStartAngle = 90;
303 | } else if (angle >= 180 && angle < 270) {
304 | mStartAngle = 180;
305 | } else if (angle >= 270 && angle < 360) {
306 | mStartAngle = 270;
307 | } else if (angle >= 360) {
308 | mStartAngle = 0;
309 | }
310 | invalidate();
311 | }
312 |
313 | /**
314 | * 设置是否渐变
315 | */
316 | public void setGradient(boolean gradient) {
317 | isGradient = gradient;
318 | }
319 |
320 | /**
321 | * 设置是否逆时针
322 | * @param counterClockwise
323 | */
324 | public void setCounterClockwise(boolean counterClockwise) {
325 | isCounterClockwise = counterClockwise;
326 | invalidate();
327 | }
328 |
329 | /**
330 | * 设置渐变的颜色
331 | */
332 | public void setColorArray(int[] colorArr) {
333 | if (colorArr == null) return;
334 | colorArray = colorArr;
335 | }
336 |
337 |
338 | /**
339 | * 设置动画
340 | *
341 | * @param start 开始位置
342 | * @param target 结束位置
343 | */
344 | private void setAnimator(float start, float target) {
345 | isAnimation = true;
346 | ValueAnimator animator = ValueAnimator.ofFloat(start, target);
347 | animator.setDuration(mDuration);
348 | animator.setTarget(mCurrentAngle);
349 | //动画更新监听
350 | animator.addUpdateListener(valueAnimator -> {
351 | mCurrentAngle = (float) valueAnimator.getAnimatedValue();
352 | invalidate();
353 | });
354 | animator.start();
355 | }
356 | }
357 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/PieProgressBar.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view;
17 |
18 | import android.animation.ValueAnimator;
19 | import android.annotation.SuppressLint;
20 | import android.content.Context;
21 | import android.content.res.TypedArray;
22 | import android.graphics.Canvas;
23 | import android.graphics.Color;
24 | import android.graphics.Paint;
25 | import android.graphics.RadialGradient;
26 | import android.graphics.RectF;
27 | import android.graphics.Shader;
28 | import android.util.AttributeSet;
29 | import android.view.View;
30 |
31 | import androidx.annotation.Nullable;
32 | import androidx.core.content.ContextCompat;
33 |
34 | /**
35 | * 饼状进度条
36 | *
37 | * @author llw
38 | * @since 2023/5/31
39 | */
40 | public class PieProgressBar extends View {
41 |
42 | /**
43 | * 半径
44 | */
45 | private int mRadius;
46 | /**
47 | * 进度条宽度
48 | */
49 | private int mStrokeWidth;
50 | /**
51 | * 进度条进度颜色
52 | */
53 | private int mProgressColor;
54 | /**
55 | * 开始角度
56 | */
57 | private int mStartAngle;
58 |
59 | /**
60 | * 当前角度
61 | */
62 | private float mCurrentAngle = 0;
63 | /**
64 | * 结束角度
65 | */
66 | private int mEndAngle = 360;
67 | /**
68 | * 最大进度
69 | */
70 | private float mMaxProgress;
71 | /**
72 | * 当前进度
73 | */
74 | private float mCurrentProgress;
75 | /**
76 | * 是否渐变
77 | */
78 | private boolean isGradient;
79 | /**
80 | * 渐变颜色数组
81 | */
82 | private int[] colorArray;
83 | /**
84 | * 动画的执行时长
85 | */
86 | private long mDuration = 1000;
87 | /**
88 | * 是否执行动画
89 | */
90 | private boolean isAnimation = false;
91 | /**
92 | * 是否逆时针绘制
93 | */
94 | private boolean isCounterClockwise = false;
95 |
96 | public PieProgressBar(Context context) {
97 | this(context, null);
98 | }
99 |
100 | public PieProgressBar(Context context, @Nullable AttributeSet attrs) {
101 | this(context, attrs, 0);
102 | }
103 |
104 | public PieProgressBar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
105 | super(context, attrs, defStyleAttr);
106 | TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.PieProgressBar);
107 | mRadius = array.getDimensionPixelSize(R.styleable.PieProgressBar_radius, 80);
108 | mStrokeWidth = array.getDimensionPixelSize(R.styleable.PieProgressBar_strokeWidth, 8);
109 | mProgressColor = array.getColor(R.styleable.PieProgressBar_progressbarColor, ContextCompat.getColor(context, R.color.tx_default_color));
110 | mMaxProgress = array.getInt(R.styleable.PieProgressBar_maxProgress, 100);
111 | mCurrentProgress = array.getInt(R.styleable.PieProgressBar_progress, 0);
112 | //是否渐变
113 | isGradient = array.getBoolean(R.styleable.PieProgressBar_gradient, false);
114 | //渐变颜色数组
115 | CharSequence[] textArray = array.getTextArray(R.styleable.PieProgressBar_gradientColorArray);
116 | if (textArray != null) {
117 | colorArray = new int[textArray.length];
118 | for (int i = 0; i < textArray.length; i++) {
119 | colorArray[i] = Color.parseColor((String) textArray[i]);
120 | }
121 | }
122 | // 开始角度
123 | mStartAngle = array.getInt(R.styleable.PieProgressBar_customAngle, 0);
124 | // 是否逆时针绘制
125 | isCounterClockwise = array.getBoolean(R.styleable.PieProgressBar_counterClockwise, false);
126 | array.recycle();
127 | }
128 |
129 | @Override
130 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
131 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
132 | int width = 0;
133 | switch (MeasureSpec.getMode(widthMeasureSpec)) {
134 | case MeasureSpec.UNSPECIFIED:
135 | case MeasureSpec.AT_MOST: //wrap_content
136 | width = mRadius * 2;
137 | break;
138 | case MeasureSpec.EXACTLY: //match_parent
139 | width = MeasureSpec.getSize(widthMeasureSpec);
140 | break;
141 | }
142 | setMeasuredDimension(width, width);
143 | }
144 |
145 | @Override
146 | protected void onDraw(Canvas canvas) {
147 | int centerX = getWidth() / 2;
148 | @SuppressLint("DrawAllocation")
149 | RectF rectF = new RectF(0,0,centerX * 2,centerX * 2);
150 | //绘制描边
151 | drawStroke(canvas, centerX);
152 | //绘制进度
153 | drawProgress(canvas, rectF);
154 | }
155 |
156 | /**
157 | * 绘制描边
158 | *
159 | * @param canvas 画布
160 | * @param centerX 中心点
161 | */
162 | private void drawStroke(Canvas canvas, int centerX) {
163 | Paint paint = new Paint();
164 | paint.setColor(mProgressColor);
165 | paint.setStyle(Paint.Style.STROKE);
166 | paint.setStrokeWidth(mStrokeWidth);
167 | paint.setAntiAlias(true);
168 | canvas.drawCircle(centerX, centerX, mRadius - (mStrokeWidth / 2), paint);
169 | }
170 |
171 | /**
172 | * 绘制进度条背景
173 | */
174 | private void drawProgress(Canvas canvas, RectF rectF) {
175 | Paint paint = new Paint();
176 | //画笔的填充样式,Paint.Style.STROKE 描边
177 | paint.setStyle(Paint.Style.FILL);
178 | //抗锯齿
179 | paint.setAntiAlias(true);
180 | //画笔的颜色
181 | paint.setColor(mProgressColor);
182 | //是否设置渐变
183 | if (isGradient && colorArray != null) {
184 | paint.setShader(new RadialGradient(rectF.centerX(), rectF.centerY(), mRadius, colorArray, null, Shader.TileMode.MIRROR));
185 | }
186 | if (!isAnimation) {
187 | mCurrentAngle = 360 * (mCurrentProgress / mMaxProgress);
188 | }
189 |
190 | // 根据 isCounterClockwise 调整绘制角度
191 | float startAngle = mStartAngle;
192 | float sweepAngle = mCurrentAngle;
193 | if (isCounterClockwise) {
194 | startAngle = mStartAngle - 360;
195 | sweepAngle = -mCurrentAngle;
196 | }
197 |
198 | //开始画圆弧
199 | canvas.drawArc(rectF, startAngle, sweepAngle, true, paint);
200 | }
201 |
202 | /**
203 | * 设置角度
204 | * @param angle 角度
205 | */
206 | public void setCustomAngle(int angle) {
207 | if (angle >= 0 && angle < 90) {
208 | mStartAngle = 0;
209 | } else if (angle >= 90 && angle < 180) {
210 | mStartAngle = 90;
211 | } else if (angle >= 180 && angle < 270) {
212 | mStartAngle = 180;
213 | } else if (angle >= 270 && angle < 360) {
214 | mStartAngle = 270;
215 | } else if (angle >= 360) {
216 | mStartAngle = 0;
217 | }
218 | invalidate();
219 | }
220 |
221 | /**
222 | * 设置是否渐变
223 | */
224 | public void setGradient(boolean gradient) {
225 | isGradient = gradient;
226 | invalidate();
227 | }
228 |
229 | /**
230 | * 设置是否逆时针
231 | * @param counterClockwise
232 | */
233 | public void setCounterClockwise(boolean counterClockwise) {
234 | isCounterClockwise = counterClockwise;
235 | invalidate();
236 | }
237 |
238 | /**
239 | * 设置渐变的颜色
240 | */
241 | public void setColorArray(int[] colorArr) {
242 | if (colorArr == null) return;
243 | colorArray = colorArr;
244 | }
245 |
246 | /**
247 | * 设置当前进度
248 | */
249 | public void setProgress(float progress) {
250 | if (progress < 0) {
251 | throw new IllegalArgumentException("Progress value can not be less than 0");
252 | }
253 | if (progress > mMaxProgress) {
254 | progress = mMaxProgress;
255 | }
256 | mCurrentProgress = progress;
257 | mCurrentAngle = 360 * (mCurrentProgress / mMaxProgress);
258 | setAnimator(mStartAngle, mCurrentAngle);
259 | }
260 |
261 | /**
262 | * 设置动画
263 | *
264 | * @param start 开始位置
265 | * @param target 结束位置
266 | */
267 | private void setAnimator(float start, float target) {
268 | isAnimation = true;
269 | ValueAnimator animator = ValueAnimator.ofFloat(start, target);
270 | animator.setDuration(mDuration);
271 | animator.setTarget(mCurrentAngle);
272 | //动画更新监听
273 | animator.addUpdateListener(valueAnimator -> {
274 | mCurrentAngle = (float) valueAnimator.getAnimatedValue();
275 | invalidate();
276 | });
277 | animator.start();
278 | }
279 | }
280 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/TimingTextView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view;
17 |
18 | import android.annotation.SuppressLint;
19 | import android.content.Context;
20 | import android.content.res.TypedArray;
21 | import android.os.CountDownTimer;
22 | import android.util.AttributeSet;
23 | import android.util.Log;
24 | import android.util.TypedValue;
25 | import android.view.View;
26 | import android.widget.TextView;
27 |
28 | import androidx.annotation.Nullable;
29 | import androidx.core.content.ContextCompat;
30 |
31 | import com.easy.view.listener.TimingListener;
32 | import com.google.android.material.textview.MaterialTextView;
33 |
34 | import java.util.Timer;
35 | import java.util.concurrent.Executors;
36 | import java.util.concurrent.ScheduledExecutorService;
37 | import java.util.concurrent.TimeUnit;
38 |
39 | /**
40 | * 计时TextView,可以正计时、倒计时
41 | */
42 | public class TimingTextView extends MaterialTextView {
43 |
44 | /**
45 | * 时间单位
46 | */
47 | private int mUnit;
48 | /**
49 | * 计时最大值
50 | */
51 | private int mMax;
52 | /**
53 | * 是否倒计时
54 | */
55 | private boolean mCountDown;
56 | /**
57 | * 总时间
58 | */
59 | private int mTotal;
60 | /**
61 | * 是否计时中
62 | */
63 | private boolean mTiming;
64 | /**
65 | * 计时监听
66 | */
67 | private TimingListener listener;
68 | /**
69 | * 倒计时器
70 | */
71 | private CountDownTimer countDownTimer;
72 |
73 | public TimingTextView(Context context) {
74 | this(context, null);
75 | }
76 |
77 | public TimingTextView(Context context, @Nullable AttributeSet attrs) {
78 | this(context, attrs, 0);
79 | }
80 |
81 | public TimingTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
82 | super(context, attrs, defStyleAttr);
83 | @SuppressLint("CustomViewStyleable")
84 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.TimingTextView);
85 | mCountDown = typedArray.getBoolean(R.styleable.TimingTextView_countdown, false);
86 | mMax = typedArray.getInteger(R.styleable.TimingTextView_max, 60);
87 | mUnit = typedArray.getInt(R.styleable.TimingTextView_unit, 3);
88 | typedArray.recycle();
89 | }
90 |
91 | /**
92 | * 设置时间单位
93 | *
94 | * @param unit 1,2,3
95 | */
96 | public void setUnit(int unit) {
97 | if (unit <= 0 || unit > 3) {
98 | throw new IllegalArgumentException("unit value can only be between 1 and 3");
99 | }
100 | mUnit = unit;
101 | }
102 |
103 | /**
104 | * 设置最大时间值
105 | *
106 | * @param max 最大值
107 | */
108 | public void setMax(int max) {
109 | mMax = max;
110 | }
111 |
112 | /**
113 | * 设置是否为倒计时
114 | *
115 | * @param isCountDown true or false
116 | */
117 | public void setCountDown(boolean isCountDown) {
118 | mCountDown = isCountDown;
119 | }
120 |
121 | public void setListener(TimingListener listener) {
122 | this.listener = listener;
123 | }
124 |
125 | public boolean isTiming() {
126 | return mTiming;
127 | }
128 |
129 | /**
130 | * 开始
131 | */
132 | public void start() {
133 | switch (mUnit) {
134 | case 1:
135 | mTotal = mMax * 60 * 60 * 1000;
136 | break;
137 | case 2:
138 | mTotal = mMax * 60 * 1000;
139 | break;
140 | case 3:
141 | mTotal = mMax * 1000;
142 | break;
143 | }
144 | if (countDownTimer == null) {
145 | countDownTimer = new CountDownTimer(mTotal, 1000) {
146 | @Override
147 | public void onTick(long millisUntilFinished) {
148 | int time = 0;
149 | if (mCountDown) {
150 | time = (int) (millisUntilFinished / 1000);
151 | setText(String.valueOf(time));
152 | } else {
153 | time = (int) (mTotal / 1000 - millisUntilFinished / 1000);
154 | }
155 | setText(String.valueOf(time));
156 | }
157 |
158 | @Override
159 | public void onFinish() {
160 | //倒计时结束
161 | end();
162 | }
163 | };
164 | mTiming = true;
165 | countDownTimer.start();
166 | }
167 |
168 | }
169 |
170 | /**
171 | * 计时结束
172 | */
173 | public void end() {
174 | mTotal = 0;
175 | mTiming = false;
176 | countDownTimer.cancel();
177 | countDownTimer = null;
178 | if (listener != null) {
179 | listener.onEnd();
180 | }
181 | }
182 | }
183 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/chart/EasyChart.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view.chart;
17 |
18 | import android.content.Context;
19 | import android.graphics.Canvas;
20 | import android.graphics.Color;
21 | import android.graphics.Paint;
22 | import android.graphics.Rect;
23 | import android.util.AttributeSet;
24 | import android.util.Log;
25 | import android.view.View;
26 |
27 | import androidx.annotation.Nullable;
28 |
29 | import com.easy.view.utils.EasyUtils;
30 |
31 | import java.util.ArrayList;
32 | import java.util.HashMap;
33 | import java.util.List;
34 | import java.util.Map;
35 |
36 | /**
37 | * 简易图表
38 | */
39 | public class EasyChart extends View {
40 | private final Context mContext;
41 |
42 | private float mWidth;
43 | private float mHeight;
44 | /**
45 | * X、Y轴画笔
46 | */
47 | private Paint mXyPaint;
48 | /**
49 | * X、Y轴文字画笔
50 | */
51 | private Paint mXyTextPaint;
52 | /**
53 | * 图表内填充
54 | */
55 | private int mPadding;
56 | /**
57 | * 文字矩形
58 | */
59 | private final Rect mTextRect = new Rect();
60 |
61 | /**
62 | * X轴绘制刻度坐标列表
63 | */
64 | private List mXScalePoints;
65 | /**
66 | * Y轴绘制刻度坐标列表
67 | */
68 | private List mYScalePoints;
69 | /**
70 | * X轴刻度内容列表
71 | */
72 | private List mXPointList;
73 | /**
74 | * Y轴刻度内容列表
75 | */
76 | private List mYPointList;
77 |
78 | public EasyChart(Context context) {
79 | this(context, null);
80 | }
81 |
82 | public EasyChart(Context context, @Nullable AttributeSet attrs) {
83 | this(context, attrs, 0);
84 | }
85 |
86 | public EasyChart(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
87 | super(context, attrs, defStyleAttr);
88 | mContext = context;
89 | // @SuppressLint("CustomViewStyleable")
90 | initPaint();
91 | }
92 |
93 | /**
94 | * 初始化画笔
95 | */
96 | private void initPaint() {
97 | mXyPaint = new Paint();
98 | mXyPaint.setAntiAlias(true);
99 | mXyPaint.setColor(Color.BLACK);
100 | mXyPaint.setStrokeWidth(EasyUtils.dp2px(mContext, 1));
101 | mXyPaint.setStyle(Paint.Style.FILL);
102 |
103 | mXyTextPaint = new Paint();
104 | mXyTextPaint.setAntiAlias(true);
105 | mXyTextPaint.setStyle(Paint.Style.FILL);
106 | mXyTextPaint.setColor(Color.BLACK);
107 | mXyTextPaint.setTextSize(EasyUtils.sp2px(mContext, 12));
108 | mXyTextPaint.setTextAlign(Paint.Align.CENTER);
109 | }
110 |
111 |
112 | @Override
113 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
114 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
115 | int width = 0;
116 | int height = 0;
117 | switch (MeasureSpec.getMode(widthMeasureSpec)) {
118 | case MeasureSpec.UNSPECIFIED:
119 | case MeasureSpec.AT_MOST: //wrap_content
120 | case MeasureSpec.EXACTLY: //match_parent
121 | width = MeasureSpec.getSize(widthMeasureSpec);
122 | mWidth = MeasureSpec.getSize(widthMeasureSpec);
123 | break;
124 | }
125 | height = (int) (width / 1.5);
126 | mHeight = height;
127 | mPadding = EasyUtils.dp2px(mContext, 16);
128 | setMeasuredDimension(width, height);
129 | }
130 |
131 | @Override
132 | protected void onDraw(Canvas canvas) {
133 | //绘制 X 轴刻度
134 | drawXScale(canvas, getXPointList());
135 | //绘制 Y 轴刻度
136 | drawYScale(canvas, getYPointList());
137 | //绘制折线
138 | drawPolyline(canvas);
139 | }
140 |
141 | /**
142 | * 绘制折线
143 | *
144 | * @param canvas 画布
145 | */
146 | private void drawPolyline(Canvas canvas) {
147 | //根据数据计算出折线图的坐标点,即两点一线
148 |
149 | // map.put("六月", 40);
150 |
151 | }
152 |
153 | private List getYPointList() {
154 | List yPointList = new ArrayList<>();
155 | yPointList.add("0");
156 | yPointList.add("10");
157 | yPointList.add("20");
158 | yPointList.add("30");
159 | yPointList.add("40");
160 | yPointList.add("50");
161 | yPointList.add("60");
162 | return yPointList;
163 | }
164 |
165 | private List getXPointList() {
166 | List xPointList = new ArrayList<>();
167 | xPointList.add("一月");
168 | xPointList.add("二月");
169 | xPointList.add("三月");
170 | xPointList.add("四月");
171 | xPointList.add("五月");
172 | return xPointList;
173 | }
174 |
175 | /**
176 | * 绘制 X 轴刻度,包含X轴和文字刻度
177 | *
178 | * @param canvas 画布
179 | * @param scales X轴刻度列表
180 | */
181 | private void drawXScale(Canvas canvas, List scales) {
182 | if (scales == null) return;
183 | //绘制X轴
184 | canvas.drawLine(mPadding * 2, mHeight - mPadding, mWidth - mPadding, mHeight - mPadding, mXyPaint);
185 |
186 | mXScalePoints = new ArrayList<>();
187 | float xValue = mWidth - mPadding * 3;
188 | float xPointMargin = xValue / scales.size();
189 | for (int i = 0; i < scales.size(); i++) {
190 | String content = scales.get(i);
191 | //获取绘制的文字边界
192 | mXyTextPaint.getTextBounds(content, 0, content.length(), mTextRect);
193 | //绘制的位置
194 | int offset = (mTextRect.top + mTextRect.bottom) / 2;
195 | //绘制文字,需要确定起始点的X、Y的坐标点
196 | float x = (float) (i * xPointMargin + xPointMargin);
197 | float y = (float) (mHeight - (mPadding / 2)) - offset;
198 | mXScalePoints.add(new Point(x, y));
199 | //绘制X轴文字
200 | canvas.drawText(content, x, y, mXyTextPaint);
201 | }
202 | }
203 |
204 | /**
205 | * 绘制 Y 轴刻度,包含Y轴和文字刻度
206 | *
207 | * @param canvas 画布
208 | * @param scales Y轴刻度列表
209 | */
210 | private void drawYScale(Canvas canvas, List scales) {
211 | if (scales == null) return;
212 | //绘制Y轴
213 | canvas.drawLine(mPadding * 2, mHeight - mPadding, mPadding * 2, mPadding, mXyPaint);
214 | mYScalePoints = new ArrayList<>();
215 | //获取Y轴实际长度
216 | float yValue = mHeight - mPadding * 2;
217 | float yPointMargin = yValue / scales.size();
218 | for (int i = 0; i < scales.size(); i++) {
219 | String content = scales.get(i);
220 | //获取绘制的文字边界
221 | mXyTextPaint.getTextBounds(content, 0, content.length(), mTextRect);
222 | //绘制的位置
223 | int offset = (mTextRect.top + mTextRect.bottom) / 2;
224 | //绘制文字,需要确定起始点的X、Y的坐标点
225 | float x = mPadding;
226 | float y = (float) (mHeight - mPadding / 2) - i * yPointMargin + offset;
227 | mYScalePoints.add(new Point(x, y));
228 | //绘制Y轴文字
229 | canvas.drawText(content, x, y, mXyTextPaint);
230 | }
231 | }
232 |
233 | /**
234 | * 根据设置的数据进行X、Y绘制
235 | *
236 | * @param map Key:X轴坐标内容,Value:Y轴坐标内容
237 | */
238 | public void setData(Map map) {
239 | mXPointList = new ArrayList<>();
240 |
241 | int min = 0;
242 | int max = 0;
243 |
244 | for (Map.Entry entry : map.entrySet()) {
245 | mXPointList.add(entry.getKey());
246 | min = Math.min(min, entry.getValue());
247 | max = Math.max(max, entry.getValue());
248 | }
249 | Log.d("TAG", "setData: min:" + min + ",max:" + max);
250 | mYPointList = new ArrayList<>();
251 | //添加Y轴刻度值
252 | mYPointList.add(String.valueOf(min));
253 | //根据最大值和数据量,得出每一个数据之间的刻度大小。
254 | //max / 10
255 | // max / map.size();
256 | // max / map.size() + 1;
257 | }
258 |
259 | /**
260 | * 根据Y轴最大值、数量获取Y轴的标准间隔
261 | * //
262 | */
263 | // private fun getYInterval(maxY: Int): Int {
264 | // val yIntervalCount = yAxisCount - 1
265 | // val rawInterval = maxY / yIntervalCount.toFloat()
266 | // val magicPower = floor(log10(rawInterval.toDouble()))
267 | // var magic = 10.0.pow(magicPower).toFloat()
268 | // if (magic == rawInterval) {
269 | // magic = rawInterval
270 | // } else {
271 | // magic *= 10
272 | // }
273 | // val rawStandardInterval = rawInterval / magic
274 | // val standardInterval = getStandardInterval(rawStandardInterval) * magic
275 | // return standardInterval.roundToInt()
276 | // }
277 |
278 |
279 | //
280 | // /**
281 | // * 根据初始的归一化后的间隔,转化为目标的间隔
282 | // */
283 | // private fun getStandardInterval(x: Float): Float {
284 | // return when {
285 | // x <= 0.1f -> 0.1f
286 | // x <= 0.2f -> 0.2f
287 | // x <= 0.25f -> 0.25f
288 | // x <= 0.5f -> 0.5f
289 | // x <= 1f -> 1f
290 | // else -> getStandardInterval(x / 10) * 10
291 | // }
292 | // }
293 | }
294 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/chart/Point.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view.chart;
17 |
18 | /**
19 | * 绘制点
20 | */
21 | public class Point {
22 | /**
23 | * X轴坐标
24 | */
25 | private float x;
26 | /**
27 | * Y轴坐标
28 | */
29 | private float y;
30 |
31 | public float getX() {
32 | return x;
33 | }
34 |
35 | public void setX(float x) {
36 | this.x = x;
37 | }
38 |
39 | public float getY() {
40 | return y;
41 | }
42 |
43 | public void setY(float y) {
44 | this.y = y;
45 | }
46 |
47 | public Point(float x, float y) {
48 | this.x = x;
49 | this.y = y;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/dialog/DialogController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view.dialog;
17 |
18 | import android.annotation.SuppressLint;
19 | import android.content.Context;
20 | import android.content.DialogInterface;
21 | import android.graphics.Bitmap;
22 | import android.graphics.drawable.Drawable;
23 | import android.graphics.drawable.Icon;
24 | import android.os.Build;
25 | import android.util.SparseArray;
26 | import android.view.Gravity;
27 | import android.view.View;
28 | import android.view.Window;
29 | import android.view.WindowManager;
30 | import androidx.annotation.RequiresApi;
31 |
32 | /**
33 | * 弹窗控制
34 | *
35 | * @author llw
36 | * @since 2023/6/3
37 | */
38 | public class DialogController {
39 | //对话弹窗
40 | private final EasyDialog mEasyDialog;
41 | //窗口
42 | private final Window mWindow;
43 | //帮助类
44 | private DialogViewHelper mViewHelper;
45 |
46 | public DialogController(EasyDialog easyDialog, Window window) {
47 | mEasyDialog = easyDialog;
48 | mWindow = window;
49 | }
50 |
51 | public void setDialogViewHelper(DialogViewHelper dialogViewHelper) {
52 | mViewHelper = dialogViewHelper;
53 | }
54 |
55 | public void setText(int viewId, CharSequence text) {
56 | mViewHelper.setText(viewId, text);
57 | }
58 |
59 | public void setTextColor(int viewId, int color) {
60 | mViewHelper.setTextColor(viewId, color);
61 | }
62 |
63 | @RequiresApi(api = Build.VERSION_CODES.M)
64 | public void setImageIcon(int viewId, Icon icon) {
65 | mViewHelper.setImageIcon(viewId, icon);
66 | }
67 |
68 | public void setImageBitmap(int viewId, Bitmap bitmap) {
69 | mViewHelper.setImageBitmap(viewId, bitmap);
70 | }
71 |
72 | public void setImageDrawable(int viewId, Drawable drawable) {
73 | mViewHelper.setImageDrawable(viewId, drawable);
74 | }
75 |
76 | public void setImageResource(int viewId, int resId) {
77 | mViewHelper.setImageResource(viewId, resId);
78 | }
79 |
80 | public View getView(int viewId) {
81 | return mViewHelper.getSubView(viewId);
82 | }
83 |
84 | public void setBackgroundColor(int viewId, int color) {
85 | mViewHelper.setBackgroundColor(viewId, color);
86 | }
87 |
88 | @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
89 | public void setBackground(int viewId, Drawable drawable) {
90 | mViewHelper.setBackground(viewId, drawable);
91 | }
92 |
93 | public void setOnClickListener(int viewId, View.OnClickListener onClickListener) {
94 | mViewHelper.setOnClickListener(viewId, onClickListener);
95 | }
96 |
97 | public EasyDialog getDialog() {
98 | return mEasyDialog;
99 | }
100 |
101 | public Window getWindow() {
102 | return mWindow;
103 | }
104 |
105 | /**
106 | * 弹窗参数类
107 | */
108 | @SuppressLint("UseSparseArrays")
109 | public static class DialogParams {
110 | //上下文
111 | public Context mContext;
112 | //主题资源Id
113 | public int mThemeResId;
114 | //点击其他区域弹窗是否取消
115 | public boolean mCancelable;
116 | //弹窗取消监听
117 | public DialogInterface.OnCancelListener mOnCancelListener;
118 | //弹窗隐藏监听
119 | public DialogInterface.OnDismissListener mOnDismissListener;
120 | //键值监听
121 | public DialogInterface.OnKeyListener mOnKeyListener;
122 | //文本颜色
123 | public SparseArray mTextColorArray = new SparseArray<>();
124 | //背景颜色
125 | public SparseArray mBgColorArray = new SparseArray<>();
126 | //背景资源
127 | public SparseArray mBgResArray = new SparseArray<>();
128 | //存放文本
129 | public SparseArray mTextArray = new SparseArray<>();
130 | //存放点击事件
131 | public SparseArray mClickArray = new SparseArray<>();
132 | //存放长按点击事件
133 | public SparseArray mLongClickArray = new SparseArray<>();
134 | //存放对话框图标
135 | public SparseArray mIconArray = new SparseArray<>();
136 | //存放对话框图片
137 | public SparseArray mBitmapArray = new SparseArray<>();
138 | //存放对话框图片
139 | public SparseArray mDrawableArray = new SparseArray<>();
140 | //存放对话框图标资源文件
141 | public SparseArray mImageResArray = new SparseArray<>();
142 | //对话框布局资源id
143 | public int mLayoutResId;
144 | //对话框的内容view
145 | public View mView;
146 | //对话框宽度
147 | public int mWidth;
148 | //对话框高度
149 | public int mHeight;
150 | //对话框垂直外边距
151 | public int mHeightMargin;
152 | //对话框横向外边距
153 | public int mWidthMargin;
154 | //对话框出现动画
155 | public int mAnimation;
156 | //对话框显示位置,默认居中显示
157 | public int mGravity = Gravity.CENTER;
158 |
159 | public DialogParams(Context context, int themeResId) {
160 | mContext = context;
161 | mThemeResId = themeResId;
162 | }
163 |
164 | /**
165 | * 应用
166 | */
167 | public void apply(DialogController controller) {
168 | DialogViewHelper helper = null;
169 |
170 | if (mView != null) {
171 | helper = new DialogViewHelper(mView);
172 | } else if (mLayoutResId != 0) {
173 | helper = new DialogViewHelper(mContext, mLayoutResId);
174 | }
175 |
176 | //如果helper为null,则mLayoutResId为0,没有设置弹窗xml
177 | if (helper == null) {
178 | throw new IllegalArgumentException("Please set layout!");
179 | }
180 | //为对话框设置内容视图
181 | controller.getDialog().setContentView(helper.getContentView());
182 | //设置DialogViewHelper辅助类
183 | controller.setDialogViewHelper(helper);
184 | //设置文本
185 | for (int i = 0; i < mTextArray.size(); i++) {
186 | controller.setText(mTextArray.keyAt(i), mTextArray.valueAt(i));
187 | }
188 | //设置文本颜色
189 | for (int i = 0; i < mTextColorArray.size(); i++) {
190 | controller.setTextColor(mTextColorArray.keyAt(i), mTextColorArray.valueAt(i));
191 | }
192 | //设置图标
193 | for (int i = 0; i < mIconArray.size(); i++) {
194 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
195 | controller.setImageIcon(mIconArray.keyAt(i), mIconArray.valueAt(i));
196 | }
197 | }
198 | //设置图片
199 | for (int i = 0; i < mBitmapArray.size(); i++) {
200 | controller.setImageBitmap(mBitmapArray.keyAt(i), mBitmapArray.valueAt(i));
201 | }
202 | //设置图片
203 | for (int i = 0; i < mDrawableArray.size(); i++) {
204 | controller.setImageDrawable(mDrawableArray.keyAt(i), mDrawableArray.valueAt(i));
205 | }
206 | //设置图片
207 | for (int i = 0; i < mImageResArray.size(); i++) {
208 | controller.setImageResource(mImageResArray.keyAt(i), mImageResArray.valueAt(i));
209 | }
210 | //设置背景颜色
211 | for (int i = 0; i < mBgColorArray.size(); i++) {
212 | controller.setBackgroundColor(mBgColorArray.keyAt(i), mBgColorArray.valueAt(i));
213 | }
214 | //设置背景资源
215 | for (int i = 0; i < mBgResArray.size(); i++) {
216 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
217 | controller.setBackground(mBgResArray.keyAt(i), mBgResArray.valueAt(i));
218 | }
219 | }
220 | //设置点击
221 | for (int i = 0; i < mClickArray.size(); i++) {
222 | controller.setOnClickListener(mClickArray.keyAt(i), mClickArray.valueAt(i));
223 | }
224 | //配置自定义效果,底部弹出,宽高,动画,全屏
225 | Window window = controller.getWindow();
226 | //显示位置
227 | window.setGravity(mGravity);
228 | if (mAnimation != 0) {
229 | //设置动画
230 | window.setWindowAnimations(mAnimation);
231 | }
232 | //设置布局参数,主要是宽高和边距
233 | WindowManager.LayoutParams params = window.getAttributes();
234 | params.width = mWidth;
235 | params.height = mHeight;
236 | params.verticalMargin = mHeightMargin;
237 | params.horizontalMargin = mWidthMargin;
238 | window.setAttributes(params);
239 | }
240 | }
241 | }
242 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/dialog/DialogViewHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view.dialog;
17 |
18 | import android.content.Context;
19 | import android.graphics.Bitmap;
20 | import android.graphics.drawable.Drawable;
21 | import android.graphics.drawable.Icon;
22 | import android.os.Build;
23 | import android.util.SparseArray;
24 | import android.view.LayoutInflater;
25 | import android.view.View;
26 | import android.widget.ImageView;
27 | import android.widget.TextView;
28 |
29 | import androidx.annotation.RequiresApi;
30 |
31 | import java.lang.ref.WeakReference;
32 |
33 | /**
34 | * 弹窗视图帮助类
35 | *
36 | * @author llw
37 | * @since 2023/6/3
38 | */
39 | public class DialogViewHelper {
40 |
41 | //内容视图
42 | private final View mView;
43 | //弱应用视图
44 | private final SparseArray> mSubViews;
45 |
46 | /**
47 | * 构造方法
48 | *
49 | * @param view 视图
50 | */
51 | public DialogViewHelper(View view) {
52 | //初始化
53 | mSubViews = new SparseArray<>();
54 | //获取弹窗视图
55 | mView = view;
56 | }
57 |
58 | /**
59 | * 构造方法
60 | *
61 | * @param context 上下文
62 | * @param layoutResId 布局资源id
63 | */
64 | public DialogViewHelper(Context context, int layoutResId) {
65 | //初始化
66 | mSubViews = new SparseArray<>();
67 | //获取弹窗视图
68 | mView = LayoutInflater.from(context).inflate(layoutResId, null);
69 | }
70 |
71 | /**
72 | * 获取弹窗内容视图
73 | *
74 | * @return mView
75 | */
76 | public View getContentView() {
77 | return mView;
78 | }
79 |
80 | /**
81 | * 获取子视图
82 | *
83 | * @param viewId 视图id
84 | * @return view
85 | */
86 | public View getSubView(int viewId) {
87 | //通过视图id得到弱引用视图
88 | WeakReference viewWeakReference = mSubViews.get(viewId);
89 | View view = null;
90 | //如果弱引用视图不为空,说明有对应的xml文件,则对view进行赋值
91 | if (viewWeakReference != null) {
92 | view = viewWeakReference.get();
93 | }
94 | //如果view为空,则说明上面的弱引用列表数据不存在,通过findViewById方式重新赋值,不为空再放到数组里
95 | if (view == null) {
96 | view = mView.findViewById(viewId);
97 | if (view != null) {
98 | mSubViews.put(viewId, new WeakReference<>(view));
99 | }
100 | }
101 | return view;
102 | }
103 |
104 | /**
105 | * 设置文本
106 | *
107 | * @param viewId 视图id
108 | * @param text 字符
109 | */
110 | public void setText(int viewId, CharSequence text) {
111 | TextView tv = (TextView) getSubView(viewId);
112 | if (tv != null) {
113 | tv.setText(text);
114 | }
115 | }
116 |
117 | /**
118 | * 设置文本
119 | *
120 | * @param viewId 视图id
121 | * @param color 颜色
122 | */
123 | public void setTextColor(int viewId, int color) {
124 | TextView tv = (TextView) getSubView(viewId);
125 | if (tv != null) {
126 | tv.setTextColor(color);
127 | }
128 | }
129 |
130 | /**
131 | * 设置图标
132 | *
133 | * @param viewId 视图id
134 | * @param icon 图标
135 | */
136 | @RequiresApi(api = Build.VERSION_CODES.M)
137 | public void setImageIcon(int viewId, Icon icon) {
138 | ImageView iv = (ImageView) getSubView(viewId);
139 | if (iv != null) {
140 | iv.setImageIcon(icon);
141 | }
142 | }
143 |
144 | /**
145 | * 设置图片
146 | *
147 | * @param viewId 视图id
148 | * @param resId 图标资源id
149 | */
150 | public void setImageResource(int viewId, int resId) {
151 | ImageView iv = (ImageView) getSubView(viewId);
152 | if (iv != null) {
153 | iv.setImageResource(resId);
154 | }
155 | }
156 |
157 | /**
158 | * 设置图片
159 | *
160 | * @param viewId 视图id
161 | * @param drawable 图
162 | */
163 | public void setImageDrawable(int viewId, Drawable drawable) {
164 | ImageView iv = (ImageView) getSubView(viewId);
165 | if (iv != null) {
166 | iv.setImageDrawable(drawable);
167 | }
168 | }
169 |
170 | /**
171 | * 设置图片
172 | *
173 | * @param viewId 视图id
174 | * @param bitmap 图片
175 | */
176 | public void setImageBitmap(int viewId, Bitmap bitmap) {
177 | ImageView iv = (ImageView) getSubView(viewId);
178 | if (iv != null) {
179 | iv.setImageBitmap(bitmap);
180 | }
181 | }
182 |
183 | /**
184 | * 设置背景颜色
185 | *
186 | * @param viewId 视图id
187 | * @param color 颜色
188 | */
189 | public void setBackgroundColor(int viewId, int color) {
190 | View view = getSubView(viewId);
191 | if (view != null) {
192 | view.setBackgroundColor(color);
193 | }
194 | }
195 |
196 | /**
197 | * 设置背景
198 | *
199 | * @param viewId 视图id
200 | * @param drawable drawable
201 | */
202 | @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
203 | public void setBackground(int viewId, Drawable drawable) {
204 | View view = getSubView(viewId);
205 | if (view != null) {
206 | view.setBackground(drawable);
207 | }
208 | }
209 |
210 | /**
211 | * 设置点击监听
212 | *
213 | * @param viewId 视图id
214 | * @param onClickListener 点击监听
215 | */
216 | public void setOnClickListener(int viewId, View.OnClickListener onClickListener) {
217 | View view = getSubView(viewId);
218 | if (view != null) {
219 | view.setOnClickListener(onClickListener);
220 | }
221 | }
222 | }
223 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/dialog/EasyDialogUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view.dialog;
17 |
18 | import android.annotation.SuppressLint;
19 | import android.content.Context;
20 | import android.view.LayoutInflater;
21 | import android.widget.LinearLayout;
22 |
23 | import androidx.annotation.NonNull;
24 | import androidx.core.content.ContextCompat;
25 | import androidx.recyclerview.widget.DividerItemDecoration;
26 | import androidx.recyclerview.widget.LinearLayoutManager;
27 |
28 | import com.easy.view.R;
29 | import com.easy.view.databinding.DialogSelectBinding;
30 | import com.easy.view.dialog.adapter.StringAdapter;
31 | import com.easy.view.dialog.listener.OnCancelListener;
32 | import com.easy.view.dialog.listener.OnConfirmListener;
33 | import com.easy.view.dialog.listener.OnItemClickListener;
34 | import com.easy.view.dialog.listener.OnSelectListener;
35 | import com.easy.view.utils.EasyUtils;
36 | import com.google.android.material.bottomsheet.BottomSheetDialog;
37 |
38 | import java.util.List;
39 |
40 | /**
41 | * 简易弹窗工具类 帮助您快速使用
42 | *
43 | * @author llw
44 | * @since 2023/6/7
45 | */
46 | public class EasyDialogUtils {
47 |
48 | @SuppressLint("StaticFieldLeak")
49 | private static EasyDialog tipDialog;
50 |
51 | /**
52 | * 显示提示弹窗
53 | *
54 | * @param context 上下文
55 | * @param title 弹窗标题
56 | * @param content 弹窗内容
57 | * @param onCancelListener 取消按钮监听
58 | * @param onConfirmListener 确定按钮监听
59 | */
60 | public static void showTipDialog(final Context context,
61 | @NonNull String title,
62 | @NonNull String content,
63 | OnCancelListener onCancelListener,
64 | OnConfirmListener onConfirmListener) {
65 | //通过构建者模式设置弹窗的相关参数
66 | EasyDialog.Builder builder = new EasyDialog.Builder(context)
67 | //添加默认出现动画
68 | .addDefaultAnimation()
69 | //设置内容视图
70 | .setContentView(R.layout.dialog_tip)
71 | //设置对话框可取消
72 | .setCancelable(true)
73 | //设置标题
74 | .setText(R.id.tv_title, title)
75 | //设置内容
76 | .setText(R.id.tv_content, content)
77 | //设置文字颜色
78 | .setTextColor(R.id.tv_confirm, ContextCompat.getColor(context, R.color.white))
79 | //设置弹窗宽高
80 | .setWidthAndHeight(EasyUtils.dp2px(context, 280), LinearLayout.LayoutParams.WRAP_CONTENT)
81 | //添加点击事件 取消
82 | .setOnClickListener(R.id.tv_cancel, v1 -> {
83 | if (onCancelListener != null) {
84 | onCancelListener.onCancel();
85 | }
86 | tipDialog.dismiss();
87 | })
88 | //添加点击事件 确定
89 | .setOnClickListener(R.id.tv_confirm, v2 -> {
90 | if (onConfirmListener != null) {
91 | onConfirmListener.onConfirm();
92 | }
93 | tipDialog.dismiss();
94 | });
95 | //创建弹窗
96 | tipDialog = builder.create();
97 | //显示弹窗
98 | tipDialog.show();
99 | }
100 |
101 | /**
102 | * 显示选择弹窗 (String)
103 | *
104 | * @param context 上下文
105 | * @param title 弹窗标题
106 | * @param strings 弹窗内容列表
107 | * @param onSelectListener 选择监听,回调选择的内容
108 | */
109 | public static void showSelectDialog(final Context context,
110 | String title,
111 | List strings,
112 | OnSelectListener onSelectListener) {
113 | BottomSheetDialog dialog = new BottomSheetDialog(context, R.style.BottomSheetDialogStyle);
114 | DialogSelectBinding binding = DialogSelectBinding.inflate(LayoutInflater.from(context));
115 | StringAdapter stringAdapter = new StringAdapter(strings);
116 | //设置标题
117 | binding.toolbar.setTitle(title);
118 | //设置关闭弹窗
119 | binding.toolbar.setNavigationOnClickListener(v -> dialog.dismiss());
120 | //设置Rv
121 | binding.rvString.setLayoutManager(new LinearLayoutManager(context));
122 | //添加Android自带的分割线
123 | //binding.rvString.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
124 | //添加自定义分割线
125 | DividerItemDecoration divider = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL);
126 | divider.setDrawable(ContextCompat.getDrawable(context, R.drawable.custom_divider));
127 | binding.rvString.addItemDecoration(divider);
128 | //列表适配器Item点击
129 | stringAdapter.setOnItemClickListener((view, position) -> {
130 | if (onSelectListener != null) {
131 | //返回点击的内容
132 | onSelectListener.onItemClick(strings.get(position));
133 | }
134 | dialog.dismiss();
135 | });
136 | binding.rvString.setAdapter(stringAdapter);
137 | dialog.setContentView(binding.getRoot());
138 | dialog.show();
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/dialog/adapter/StringAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view.dialog.adapter;
17 |
18 | import android.view.LayoutInflater;
19 | import android.view.ViewGroup;
20 |
21 | import androidx.annotation.NonNull;
22 | import androidx.recyclerview.widget.RecyclerView;
23 |
24 | import com.easy.view.databinding.ItemStringBinding;
25 | import com.easy.view.dialog.listener.OnItemClickListener;
26 |
27 | import java.util.List;
28 |
29 | /**
30 | * 字符串适配器
31 | *
32 | * @author llw
33 | * @since 2023/6/9
34 | */
35 | public class StringAdapter extends RecyclerView.Adapter {
36 |
37 | private final List mList;
38 |
39 | private OnItemClickListener mOnItemClickListener;
40 |
41 |
42 | public void setOnItemClickListener(OnItemClickListener mOnItemClickListener) {
43 | this.mOnItemClickListener = mOnItemClickListener;
44 | }
45 |
46 | public StringAdapter(List mList) {
47 | this.mList = mList;
48 | }
49 |
50 | @NonNull
51 | @Override
52 | public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
53 | ItemStringBinding binding = ItemStringBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
54 | ViewHolder viewHolder = new ViewHolder(binding);
55 | binding.getRoot().setOnClickListener(v -> {
56 | if (mOnItemClickListener != null) {
57 | mOnItemClickListener.onItemClick(v, viewHolder.getAdapterPosition());
58 | }
59 | });
60 | return viewHolder;
61 | }
62 |
63 | @Override
64 | public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
65 | String content = mList.get(position);
66 | holder.binding.tvString.setText(content);
67 | }
68 |
69 | @Override
70 | public int getItemCount() {
71 | return mList.size();
72 | }
73 |
74 | static class ViewHolder extends RecyclerView.ViewHolder {
75 | ItemStringBinding binding;
76 |
77 | public ViewHolder(ItemStringBinding itemView) {
78 | super(itemView.getRoot());
79 | this.binding = itemView;
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/dialog/listener/OnCancelListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view.dialog.listener;
17 |
18 | /**
19 | * 取消监听
20 | *
21 | * @author llw
22 | * @since 2023/6/7
23 | */
24 | public interface OnCancelListener {
25 | void onCancel();
26 | }
27 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/dialog/listener/OnConfirmListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view.dialog.listener;
17 |
18 | /**
19 | * 确定监听
20 | *
21 | * @author llw
22 | * @since 2023/6/7
23 | */
24 | public interface OnConfirmListener {
25 | void onConfirm();
26 | }
27 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/dialog/listener/OnItemChildClickListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view.dialog.listener;
17 |
18 | import android.view.View;
19 |
20 | /**
21 | * Item子控件点击监听
22 | *
23 | * @author llw
24 | * @since 2023/6/9
25 | */
26 | public interface OnItemChildClickListener {
27 | void onItemChildClick(View view, int position);
28 | }
29 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/dialog/listener/OnItemClickListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view.dialog.listener;
17 |
18 | import android.view.View;
19 |
20 | /**
21 | * Item点击监听
22 | *
23 | * @author llw
24 | * @since 2023/6/9
25 | */
26 | public interface OnItemClickListener {
27 | void onItemClick(View view, int position);
28 | }
29 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/dialog/listener/OnSelectListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view.dialog.listener;
17 |
18 | import android.view.View;
19 |
20 | /**
21 | * 选中监听
22 | *
23 | * @author llw
24 | * @since 2023/6/9
25 | */
26 | public interface OnSelectListener {
27 | void onItemClick(String selectContent);
28 | }
29 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/listener/HexKeyboardListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view.listener;
17 |
18 | /**
19 | * Hex 键盘监听
20 | *
21 | * @author llw
22 | * @since 2023/3/24
23 | */
24 | public interface HexKeyboardListener {
25 |
26 | /**
27 | * Hex character
28 | * @param hex 0~9,A~F
29 | */
30 | void onHex(String hex);
31 |
32 | /**
33 | * delete
34 | */
35 | void onDelete();
36 |
37 | /**
38 | * Complete deletion
39 | */
40 | void onDeleteAll();
41 |
42 | /**
43 | * complete
44 | */
45 | void onComplete();
46 | }
47 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/listener/NumberKeyboardListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view.listener;
17 |
18 | /**
19 | * 数字键盘监听
20 | *
21 | * @author llw
22 | * @since 2023/4/30
23 | */
24 | public interface NumberKeyboardListener {
25 |
26 | /**
27 | * 数字字符
28 | * @param num 0~9
29 | */
30 | void onNum(String num);
31 |
32 | /**
33 | * 删除
34 | */
35 | void onDelete();
36 |
37 | /**
38 | * 完成
39 | */
40 | void onComplete();
41 |
42 | /**
43 | * 弹窗关闭
44 | */
45 | void onDialogDismiss();
46 |
47 | /**
48 | * 弹窗显示
49 | */
50 | void onDialogShow();
51 | }
52 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/listener/OnValueChangeListener.java:
--------------------------------------------------------------------------------
1 | package com.easy.view.listener;
2 |
3 | /**
4 | * 值改变监听
5 | */
6 | public interface OnValueChangeListener {
7 |
8 | void onValueChange(float value);
9 | }
10 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/listener/TimingListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view.listener;
17 |
18 | /**
19 | * 计时监听
20 | * @author llw
21 | * @since 2023/4/3
22 | */
23 | public interface TimingListener {
24 | void onEnd();
25 | }
26 |
--------------------------------------------------------------------------------
/easy/src/main/java/com/easy/view/utils/EasyUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) Llw, EasyView Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.easy.view.utils;
17 |
18 | import android.content.Context;
19 | import android.content.DialogInterface;
20 | import android.view.LayoutInflater;
21 | import android.view.View;
22 | import android.view.WindowManager;
23 |
24 | import androidx.annotation.NonNull;
25 |
26 | import com.easy.view.R;
27 | import com.easy.view.listener.HexKeyboardListener;
28 | import com.easy.view.listener.NumberKeyboardListener;
29 | import com.google.android.material.bottomsheet.BottomSheetDialog;
30 |
31 | /**
32 | * Tool class
33 | *
34 | * @author llw
35 | * @since 2023/3/24
36 | */
37 | public class EasyUtils {
38 |
39 | public static final String HOUR_MINUTE_SECOND = "HH:mm:ss";
40 | public static final String HOUR_MINUTE_SECOND_CN = "HH时mm分ss秒";
41 |
42 | /**
43 | * dp to px
44 | *
45 | * @param dpValue dp value
46 | * @return px value
47 | */
48 | public static int dp2px(Context context, final float dpValue) {
49 | final float scale = context.getApplicationContext().getResources().getDisplayMetrics().density;
50 | return (int) (dpValue * scale + 0.5f);
51 | }
52 |
53 | /**
54 | * sp to px
55 | *
56 | * @param spValue sp value
57 | * @return px value
58 | */
59 | public static int sp2px(Context context, final float spValue) {
60 | final float fontScale = context.getApplicationContext().getResources().getDisplayMetrics().scaledDensity;
61 | return (int) (spValue * fontScale + 0.5f);
62 | }
63 |
64 | /**
65 | * 显示Hex键盘弹窗
66 | *
67 | * @param listener Hex keyboard key monitoring
68 | */
69 | public static void showHexKeyboardDialog(@NonNull Context context, @NonNull HexKeyboardListener listener) {
70 | BottomSheetDialog dialog = new BottomSheetDialog(context);
71 | //Get the layout view from the xml
72 | View view = LayoutInflater.from(context).inflate(R.layout.lay_hex_keyboard, null, false);
73 | //Click the button to trigger the interface callback
74 | view.findViewById(R.id.btn_a).setOnClickListener(v -> listener.onHex("A"));
75 | view.findViewById(R.id.btn_b).setOnClickListener(v -> listener.onHex("B"));
76 | view.findViewById(R.id.btn_c).setOnClickListener(v -> listener.onHex("C"));
77 | view.findViewById(R.id.btn_d).setOnClickListener(v -> listener.onHex("D"));
78 | view.findViewById(R.id.btn_e).setOnClickListener(v -> listener.onHex("E"));
79 | view.findViewById(R.id.btn_f).setOnClickListener(v -> listener.onHex("F"));
80 | view.findViewById(R.id.btn_0).setOnClickListener(v -> listener.onHex("0"));
81 | view.findViewById(R.id.btn_1).setOnClickListener(v -> listener.onHex("1"));
82 | view.findViewById(R.id.btn_2).setOnClickListener(v -> listener.onHex("2"));
83 | view.findViewById(R.id.btn_3).setOnClickListener(v -> listener.onHex("3"));
84 | view.findViewById(R.id.btn_4).setOnClickListener(v -> listener.onHex("4"));
85 | view.findViewById(R.id.btn_5).setOnClickListener(v -> listener.onHex("5"));
86 | view.findViewById(R.id.btn_6).setOnClickListener(v -> listener.onHex("6"));
87 | view.findViewById(R.id.btn_7).setOnClickListener(v -> listener.onHex("7"));
88 | view.findViewById(R.id.btn_8).setOnClickListener(v -> listener.onHex("8"));
89 | view.findViewById(R.id.btn_9).setOnClickListener(v -> listener.onHex("9"));
90 | view.findViewById(R.id.btn_del).setOnClickListener(v -> listener.onDelete());
91 | view.findViewById(R.id.btn_delete_all).setOnClickListener(v -> listener.onDeleteAll());
92 | view.findViewById(R.id.btn_complete).setOnClickListener(v -> {
93 | listener.onComplete();
94 | dialog.dismiss();
95 | });
96 | //Click outside does not disappear
97 | dialog.setCancelable(false);
98 | //Set content view
99 | dialog.setContentView(view);
100 | if (dialog.getWindow() != null) {
101 | //Set the popover background transparent
102 | WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
103 | params.dimAmount = 0.0f;
104 | dialog.getWindow().setAttributes(params);
105 | }
106 | dialog.show();
107 | }
108 |
109 | /**
110 | * 显示数字键盘弹窗
111 | *
112 | * @param listener 数字键盘监听
113 | */
114 | public static void showNumKeyboardDialog(@NonNull Context context, @NonNull NumberKeyboardListener listener) {
115 | BottomSheetDialog dialog = new BottomSheetDialog(context);
116 | //从xml中获取布局视图
117 | View view = LayoutInflater.from(context).inflate(R.layout.lay_number_keyboard, null, false);
118 | //单击按钮触发接口回调
119 | view.findViewById(R.id.btn_0).setOnClickListener(v -> listener.onNum("0"));
120 | view.findViewById(R.id.btn_1).setOnClickListener(v -> listener.onNum("1"));
121 | view.findViewById(R.id.btn_2).setOnClickListener(v -> listener.onNum("2"));
122 | view.findViewById(R.id.btn_3).setOnClickListener(v -> listener.onNum("3"));
123 | view.findViewById(R.id.btn_4).setOnClickListener(v -> listener.onNum("4"));
124 | view.findViewById(R.id.btn_5).setOnClickListener(v -> listener.onNum("5"));
125 | view.findViewById(R.id.btn_6).setOnClickListener(v -> listener.onNum("6"));
126 | view.findViewById(R.id.btn_7).setOnClickListener(v -> listener.onNum("7"));
127 | view.findViewById(R.id.btn_8).setOnClickListener(v -> listener.onNum("8"));
128 | view.findViewById(R.id.btn_9).setOnClickListener(v -> listener.onNum("9"));
129 | view.findViewById(R.id.btn_del).setOnClickListener(v -> listener.onDelete());
130 | view.findViewById(R.id.btn_complete).setOnClickListener(v -> {
131 | listener.onComplete();
132 | dialog.dismiss();
133 | });
134 | //点击外面消失
135 | dialog.setCancelable(true);
136 | //设置内容视图
137 | dialog.setContentView(view);
138 | if (dialog.getWindow() != null) {
139 | //设置弹出窗口背景透明
140 | WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
141 | params.dimAmount = 0.0f;
142 | dialog.getWindow().setAttributes(params);
143 | }
144 | dialog.setOnShowListener(dialog1 -> listener.onDialogShow());
145 | dialog.setOnCancelListener(dialog12 -> listener.onDialogDismiss());
146 | dialog.setOnDismissListener(dialog13 -> listener.onDialogDismiss());
147 | dialog.show();
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/easy/src/main/res/anim/dialog_from_bottom_anim_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
--------------------------------------------------------------------------------
/easy/src/main/res/anim/dialog_from_bottom_anim_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
--------------------------------------------------------------------------------
/easy/src/main/res/anim/dialog_from_left_anim_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
--------------------------------------------------------------------------------
/easy/src/main/res/anim/dialog_from_left_anim_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
--------------------------------------------------------------------------------
/easy/src/main/res/anim/dialog_from_right_anim_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
--------------------------------------------------------------------------------
/easy/src/main/res/anim/dialog_from_right_anim_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
--------------------------------------------------------------------------------
/easy/src/main/res/anim/dialog_from_top_anim_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/easy/src/main/res/anim/dialog_from_top_anim_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/easy/src/main/res/anim/dialog_scale_anim_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
22 |
23 |
32 |
33 |
38 |
39 |
--------------------------------------------------------------------------------
/easy/src/main/res/anim/dialog_scale_anim_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
18 |
19 |
--------------------------------------------------------------------------------
/easy/src/main/res/drawable/custom_divider.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/easy/src/main/res/drawable/round_close_24.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/easy/src/main/res/drawable/selector_cancel_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/easy/src/main/res/drawable/selector_confirm_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/easy/src/main/res/drawable/shape_bottom_left_radius_16_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/easy/src/main/res/drawable/shape_bottom_right_radius_16_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/easy/src/main/res/drawable/shape_cancel_16_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/easy/src/main/res/drawable/shape_cancel_pressed_16_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/easy/src/main/res/drawable/shape_confirm_16_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/easy/src/main/res/drawable/shape_confirm_pressed_16_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/easy/src/main/res/drawable/shape_dialog_base_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/easy/src/main/res/layout/dialog_select.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
24 |
--------------------------------------------------------------------------------
/easy/src/main/res/layout/dialog_tip.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
20 |
21 |
27 |
28 |
39 |
40 |
41 |
56 |
57 |
67 |
68 |
82 |
--------------------------------------------------------------------------------
/easy/src/main/res/layout/item_string.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/easy/src/main/res/layout/lay_number_keyboard.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
25 |
26 |
42 |
43 |
61 |
62 |
77 |
78 |
94 |
95 |
113 |
114 |
129 |
130 |
146 |
147 |
163 |
164 |
181 |
182 |
199 |
200 |
217 |
218 |
--------------------------------------------------------------------------------
/easy/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 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
--------------------------------------------------------------------------------
/easy/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 | #fcfcfc
11 | #1b1b1b
12 | #009C3A
13 | #009C3A
14 | #f8f8f8
15 | #0C973F
16 | #050505
17 | #EEE
18 | #f8f8f8
19 | #0C973F
20 | #035C24
21 |
--------------------------------------------------------------------------------
/easy/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | A
4 | B
5 | C
6 | D
7 | E
8 | F
9 | 0
10 | 1
11 | 2
12 | 3
13 | 4
14 | 5
15 | 6
16 | 7
17 | 8
18 | 9
19 | 删除
20 | 全删
21 | 完成
22 |
--------------------------------------------------------------------------------
/easy/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
14 |
15 |
23 |
24 |
25 |
29 |
30 |
34 |
35 |
39 |
40 |
44 |
45 |
49 |
50 |
51 |
59 |
--------------------------------------------------------------------------------
/easy/src/test/java/com/easy/view/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.easy.view;
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 | }
--------------------------------------------------------------------------------
/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
22 | # android.disableAutomaticComponentCreation=true
23 |
24 |
25 |
26 | GROUP_ID=io.github.lilongweidev
27 | ARTIFACT_ID=easyview
28 |
29 | VERSION_NAME=1.0.6
30 |
31 | POM_NAME=EasyView
32 | POM_DESCRIPTION=A simple and handy Android Custom View library.
33 | POM_INCEPTION_YEAR=2023
34 | POM_URL=https://github.com/lilongweidev/EasyView
35 |
36 | POM_LICENCE_COMMENTS=A business-friendly OSS license
37 | POM_LICENSE_NAME=The Apache Software License, Version 2.0
38 | POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt
39 | POM_LICENSE_DIST=repo
40 |
41 | POM_SCM_URL=https://github.com/lilongweidev/EasyView
42 | POM_SCM_CONNECTION=scm:git@https://github.com/lilongweidev/EasyView.git
43 | POM_SCM_DEV_CONNECTION=scm:git@https://github.com/lilongweidev/EasyView.git
44 |
45 |
46 | POM_DEVELOPER_ID=lilongweidev
47 | POM_DEVELOPER_NAME=Longwei Li
48 | POM_DEVELOPER_EMAIL=lonelyholiday@qq.com
49 | POM_DEVELOPER_URL=https://github.com/lilongweidev
50 | POM_ISSUE_MANAGEMENT_SYSTEM=Github
51 | POM_ISSUE_MANAGEMENT_URL=https://github.com/lilongweidev/EasyView
52 |
53 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lilongweidev/EasyView/57a01484b33e16b481e3c9f0707021e57800ab2c/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Mar 02 17:32:00 CST 2023
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | gradlePluginPortal()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | }
15 | rootProject.name = "EasyView"
16 | include ':app'
17 | include ':easy'
18 |
--------------------------------------------------------------------------------