├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── file.template.settings.xml
├── fileTemplates
│ └── includes
│ │ └── File Header.java
├── gradle.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── zhoup
│ │ └── android
│ │ └── aliqrcode
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── zhoup
│ │ │ └── android
│ │ │ └── aliqrcode
│ │ │ ├── activity
│ │ │ ├── BaseActivity.java
│ │ │ └── MainActivity.java
│ │ │ ├── application
│ │ │ └── MyApplication.java
│ │ │ ├── consts
│ │ │ └── AppConst.java
│ │ │ ├── module
│ │ │ ├── model
│ │ │ │ ├── bean
│ │ │ │ │ ├── AlipayAmountEvent.java
│ │ │ │ │ ├── ExpandAccessibilityNodeInfo.java
│ │ │ │ │ └── QRCodeBean.java
│ │ │ │ └── repository
│ │ │ │ │ └── MainRepository.java
│ │ │ ├── presenter
│ │ │ │ ├── BasePresenter.java
│ │ │ │ └── MainPresenter.java
│ │ │ └── view
│ │ │ │ ├── IBaseView.java
│ │ │ │ └── IMainView.java
│ │ │ ├── service
│ │ │ └── AliQRService.java
│ │ │ ├── task
│ │ │ └── AlipayQRTask.java
│ │ │ └── utils
│ │ │ ├── AccessibilityServiceHelper.java
│ │ │ ├── DialogUtils.java
│ │ │ ├── LogUtil.java
│ │ │ ├── NotificationUtils.java
│ │ │ ├── SnackbarUtil.java
│ │ │ └── ToastUtil.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ │ └── xml
│ │ └── service_config.xml
│ └── test
│ └── java
│ └── com
│ └── zhoup
│ └── android
│ └── aliqrcode
│ └── ExampleUnitTest.java
├── build.gradle
├── config.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── screen_recrod
├── 1.gif
├── 2.gif
└── 3.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/file.template.settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/fileTemplates/includes/File Header.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by zhoup on ${DATE}.
3 | */
4 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/.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 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # aliqrcode
2 | 自动批量生成支付宝收款码工具
3 |
4 | # 技术详述
5 | Android里有一个叫`AccessibilityService`的服务,可以模拟点击输入等事件。具体可参考csdn上微信红包外挂实现(http://blog.csdn.net/feifei454498130/article/details/43891781/)
6 |
7 | # 效果预览
8 | 
9 |
10 | 
11 |
12 | 
13 |
14 | # 使用说明
15 | 本软件仅供学习使用,完全模拟人工操作批量生成支付宝收款码。
16 |
17 | # 适用性
18 | 由于支付宝客户端更新会有一些界面的小改动使服务无法捕捉正确的控件id而导致无法正常使用,特此列出适配的安卓支付宝版本号
19 | V1.0适配支付宝版本号为10.0.18
20 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'android-apt'
3 |
4 | android {
5 | compileSdkVersion 26
6 | buildToolsVersion "26.0.0"
7 | defaultConfig {
8 | applicationId "com.zhoup.android.aliqrcode"
9 | minSdkVersion 18
10 | targetSdkVersion 26
11 | versionCode 4
12 | versionName "1.3"
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | debug {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 | }
26 |
27 | dependencies {
28 | compile fileTree(dir: 'libs', include: ['*.jar'])
29 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
30 | exclude group: 'com.android.support', module: 'support-annotations'
31 | })
32 | compile rootProject.ext.dependencies["appcompat-v7"]
33 | compile rootProject.ext.dependencies["design"]
34 | compile rootProject.ext.dependencies["butterknife"]
35 | compile rootProject.ext.dependencies["rxjava"]
36 | compile rootProject.ext.dependencies["rxandroid"]
37 | compile rootProject.ext.dependencies["rxbinding"]
38 | compile rootProject.ext.dependencies["retrofit"]
39 | compile rootProject.ext.dependencies["converter-gson"]
40 | compile rootProject.ext.dependencies["adapter-rxjava"]
41 | compile rootProject.ext.dependencies["rxpermissions"]
42 | compile rootProject.ext.dependencies["eventbus"]
43 | compile rootProject.ext.dependencies["zxing"]
44 | debugCompile rootProject.ext.dependencies["leakcanary-android"]
45 | releaseCompile rootProject.ext.dependencies["leakcanary-android-no-op"]
46 | apt rootProject.ext.dependencies["butterknife-compiler"]
47 | testCompile rootProject.ext.dependencies["junit"]
48 | }
49 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\program\android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/zhoup/android/aliqrcode/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.zhoup.android.aliqrcode", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
20 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
35 |
36 |
37 |
38 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/activity/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.activity;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 |
6 | import com.zhoup.android.aliqrcode.application.MyApplication;
7 |
8 | import org.greenrobot.eventbus.EventBus;
9 |
10 | import butterknife.ButterKnife;
11 |
12 | public abstract class BaseActivity extends AppCompatActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(getContentViewId());
18 | ButterKnife.bind(this);
19 | initViews(savedInstanceState);
20 | }
21 | protected abstract void initViews(Bundle savedInstanceState);
22 |
23 | public abstract int getContentViewId();
24 |
25 | @Override
26 | protected void onDestroy() {
27 | super.onDestroy();
28 | MyApplication.getRefWatcher(this).watch(this);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.activity;
2 |
3 | import android.Manifest;
4 | import android.content.DialogInterface;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.provider.Settings;
8 | import android.support.design.widget.Snackbar;
9 | import android.support.design.widget.TextInputEditText;
10 | import android.view.View;
11 | import android.widget.Button;
12 | import android.widget.TextView;
13 |
14 | import com.zhoup.android.aliqrcode.R;
15 | import com.zhoup.android.aliqrcode.module.model.bean.AlipayAmountEvent;
16 | import com.zhoup.android.aliqrcode.module.presenter.MainPresenter;
17 | import com.zhoup.android.aliqrcode.module.view.IMainView;
18 | import com.zhoup.android.aliqrcode.utils.DialogUtils;
19 | import com.zhoup.android.aliqrcode.utils.SnackbarUtil;
20 |
21 | import org.greenrobot.eventbus.EventBus;
22 |
23 | import java.math.BigDecimal;
24 |
25 | import butterknife.BindView;
26 | import butterknife.OnClick;
27 |
28 | public class MainActivity extends BaseActivity implements IMainView {
29 | @BindView(R.id.tv_info)
30 | TextView mTextView;
31 | @BindView(R.id.btn_service)
32 | Button mServiceButton;
33 | @BindView(R.id.edit_amount)
34 | TextInputEditText mAmountEditText;
35 | @BindView(R.id.btn_submit)
36 | Button mSubmitButton;
37 | private MainPresenter mMainPresenter;
38 |
39 | @Override
40 | protected void initViews(Bundle savedInstanceState) {
41 | mMainPresenter = new MainPresenter();
42 | mMainPresenter.attachView(this);
43 | // check runtime permissions
44 | mMainPresenter.checkPermissions(this,
45 | Manifest.permission.WRITE_EXTERNAL_STORAGE,
46 | Manifest.permission.READ_EXTERNAL_STORAGE);
47 |
48 | }
49 |
50 | @Override
51 | public int getContentViewId() {
52 | return R.layout.activity_main;
53 | }
54 |
55 | @OnClick({R.id.btn_service,R.id.btn_submit})
56 | public void onClick(View view) {
57 | switch (view.getId()) {
58 | case R.id.btn_service:
59 | openAccessibilityServiceSettings();
60 | break;
61 | case R.id.btn_submit:
62 | final BigDecimal amount = new BigDecimal(mAmountEditText.getText().toString().trim());
63 | EventBus.getDefault().postSticky(new AlipayAmountEvent(amount));
64 | break;
65 |
66 | }
67 | }
68 |
69 | @Override
70 | public void showOpenServiceDialog() {
71 | // 显示打开辅助服务的对话框
72 | DialogUtils.showMessage(this, R.string.use_tip, R.string.open_additional_function_service,
73 | true, R.string.open_function, new DialogInterface.OnClickListener() {
74 | @Override
75 | public void onClick(DialogInterface dialog, int which) {
76 | openAccessibilityServiceSettings();
77 | }
78 | });
79 | }
80 |
81 | @Override
82 | public void checkService() {
83 | // check accessibilityservice
84 | mMainPresenter.checkService();
85 | }
86 |
87 | @Override
88 | public void showErrorMessage(String errorMsg) {
89 | SnackbarUtil.showSnackbar(mTextView, errorMsg, Snackbar.LENGTH_SHORT);
90 | }
91 |
92 | // 打开辅助服务的设置
93 | private void openAccessibilityServiceSettings() {
94 | try {
95 | Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
96 | startActivity(intent);
97 | } catch (Exception e) {
98 | e.printStackTrace();
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/application/MyApplication.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.application;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 |
6 | import com.squareup.leakcanary.LeakCanary;
7 | import com.squareup.leakcanary.RefWatcher;
8 |
9 | /**
10 | * Created by zhoup on 2017/6/23.
11 | */
12 |
13 | public class MyApplication extends Application {
14 | private RefWatcher mWatcher;
15 |
16 | public static RefWatcher getRefWatcher(Context context) {
17 | MyApplication application = (MyApplication) context.getApplicationContext();
18 | return application.mWatcher;
19 | }
20 |
21 | public static Context getApplicationContext(Context context){
22 | return context.getApplicationContext();
23 | }
24 |
25 | @Override
26 | public void onCreate() {
27 | super.onCreate();
28 | if (LeakCanary.isInAnalyzerProcess(this)) {
29 | return;
30 | }
31 | mWatcher = LeakCanary.install(this);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/consts/AppConst.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.consts;
2 |
3 | /**
4 | * Created by zhoup on 2017/6/22.
5 | */
6 |
7 | public class AppConst {
8 |
9 | // 支付宝包名
10 | public static final String ALIPAY_PACKAGE_NAME = "com.eg.android.AlipayGphone";
11 |
12 | public static final String LOG_DIR = "/aliqrcode_log/";
13 |
14 | // 加号id = com.alipay.mobile.base.commonbiz:id/launcher_title_search_item_bg
15 | public static final String OPEN_MENU_ID = "com.alipay.mobile.base.commonbiz:id/launcher_title_search_item_bg";
16 | // 收钱id =com.alipay.mobile.ui:id/item_name
17 | public static final String COLLECT_MONEY = "com.alipay.mobile.ui:id/item_name";
18 |
19 | // 设置金额的id = payee_QRCodePayModifyMoney
20 | public static final String SET_MONEY_ID = "com.alipay.mobile.payee:id/payee_QRCodePayModifyMoney";
21 |
22 | // 添加收款理由 id = payee_QRAddBeiZhuLink
23 | public static final String ADD_GATHER_REASON_ID = "com.alipay.mobile.payee:id/payee_QRAddBeiZhuLink";
24 |
25 | // 金额的relativelayout id = payee_QRmoneySetInput
26 | public static final String MONEY_RELATIVELAYOUT_ID = "com.alipay.mobile.payee:id/payee_QRmoneySetInput";
27 |
28 | // 理由 relativelayout id = payee_QRmoneySetBeiZhuInput
29 | public static final String REASON_RELATIVELAYOUT_ID = "com.alipay.mobile.payee:id/payee_QRmoneySetBeiZhuInput";
30 |
31 | // 确定 id = payee_NextBtn
32 | public static final String SUBMIT_ID = "com.alipay.mobile.payee:id/payee_NextBtn";
33 |
34 | //保存图片
35 | public static final String SAVE_PICTURE = "com.alipay.mobile.payee:id/payee_save_qrcode";
36 |
37 | public static final int QRCODE_TOTAL_COUNT = 10;
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/module/model/bean/AlipayAmountEvent.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.module.model.bean;
2 |
3 | import java.math.BigDecimal;
4 |
5 | /**
6 | * Created by zhoup on 2017/6/25.
7 | */
8 |
9 | public class AlipayAmountEvent {
10 | private BigDecimal amount;
11 |
12 | public AlipayAmountEvent(BigDecimal amount) {
13 | this.amount = amount;
14 | }
15 |
16 | public BigDecimal getAmount() {
17 | return amount;
18 | }
19 |
20 | public void setAmount(BigDecimal amount) {
21 | this.amount = amount;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/module/model/bean/ExpandAccessibilityNodeInfo.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.module.model.bean;
2 |
3 | import android.view.accessibility.AccessibilityNodeInfo;
4 |
5 | /**
6 | * Created by zhoup on 2017/6/23.
7 | */
8 |
9 | public class ExpandAccessibilityNodeInfo {
10 | private AccessibilityNodeInfo accessibilityNodeInfo;
11 | private String id;
12 |
13 | public ExpandAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo, String id){
14 | this.accessibilityNodeInfo = accessibilityNodeInfo;
15 | this.id = id;
16 | }
17 |
18 | public AccessibilityNodeInfo getAccessibilityNodeInfo() {
19 | return accessibilityNodeInfo;
20 | }
21 |
22 | public void setAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
23 | this.accessibilityNodeInfo = accessibilityNodeInfo;
24 | }
25 |
26 | public String getId() {
27 | return id;
28 | }
29 |
30 | public void setId(String id) {
31 | this.id = id;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/module/model/bean/QRCodeBean.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.module.model.bean;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * Created by zhoup on 2017/6/23
7 | */
8 |
9 | public class QRCodeBean implements Serializable {
10 |
11 | private String amount;
12 | private String associatedCode;
13 |
14 | public String getAmount() {
15 | return amount;
16 | }
17 |
18 | public void setAmount(String amount) {
19 | this.amount = amount;
20 | }
21 |
22 | public String getAssociatedCode() {
23 | return associatedCode;
24 | }
25 |
26 | public void setAssociatedCode(String associatedCode) {
27 | this.associatedCode = associatedCode;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/module/model/repository/MainRepository.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.module.model.repository;
2 |
3 | import android.content.Context;
4 |
5 | import com.tbruyelle.rxpermissions.RxPermissions;
6 |
7 | import rx.Observable;
8 |
9 | /**
10 | * Created by zhoup on 2017/6/22.
11 | */
12 |
13 | public class MainRepository {
14 | public Observable checkPermissions(Context context, String[] permissions) {
15 | return RxPermissions.getInstance(context).request(permissions);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/module/presenter/BasePresenter.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.module.presenter;
2 |
3 | import com.zhoup.android.aliqrcode.module.view.IBaseView;
4 |
5 | /**
6 | * Created by zhoup on 2017/6/21.
7 | */
8 |
9 | public interface BasePresenter {
10 | void attachView(T view);
11 | void detachView();
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/module/presenter/MainPresenter.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.module.presenter;
2 |
3 | import android.content.Context;
4 |
5 | import com.zhoup.android.aliqrcode.R;
6 | import com.zhoup.android.aliqrcode.module.model.repository.MainRepository;
7 | import com.zhoup.android.aliqrcode.module.view.IMainView;
8 | import com.zhoup.android.aliqrcode.utils.LogUtil;
9 |
10 | import rx.Subscriber;
11 | import rx.subscriptions.CompositeSubscription;
12 |
13 | /**
14 | * Created by zhoup on 2017/6/21.
15 | */
16 | public class MainPresenter implements BasePresenter {
17 | private IMainView mView;
18 | private MainRepository mMainRepository;
19 | private CompositeSubscription mCompositeSubscription;
20 |
21 | @Override
22 | public void attachView(IMainView view) {
23 | this.mView = view;
24 | mMainRepository = new MainRepository();
25 | mCompositeSubscription = new CompositeSubscription();
26 | }
27 |
28 | @Override
29 | public void detachView() {
30 | if (!mCompositeSubscription.isUnsubscribed()) {
31 | mCompositeSubscription.unsubscribe();
32 | }
33 | mMainRepository = null;
34 | mView = null;
35 | }
36 |
37 | public void checkService() {
38 | mView.showOpenServiceDialog();
39 | }
40 |
41 |
42 | public void checkPermissions(final Context context, String... permissions) {
43 | mCompositeSubscription.add(
44 | mMainRepository.checkPermissions(context, permissions)
45 | .subscribe(new Subscriber() {
46 | @Override
47 | public void onCompleted() {
48 | LogUtil.i("check permissions completed");
49 | }
50 |
51 | @Override
52 | public void onError(Throwable e) {
53 | mView.showErrorMessage(e.toString());
54 | }
55 |
56 | @Override
57 | public void onNext(Boolean aBoolean) {
58 | if(aBoolean){
59 | mView.checkService();
60 | }else{
61 | mView.showErrorMessage(context.getResources().getString(R.string.no_permissions));
62 | }
63 | }
64 | })
65 | );
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/module/view/IBaseView.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.module.view;
2 |
3 | /**
4 | * Created by zhoup on 2017/6/21.
5 | */
6 | public interface IBaseView {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/module/view/IMainView.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.module.view;
2 |
3 | /**
4 | * Created by zhoup on 2017/6/21.
5 | */
6 | public interface IMainView extends IBaseView{
7 | void showOpenServiceDialog();
8 |
9 | void showErrorMessage(String e);
10 |
11 | void checkService();
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/service/AliQRService.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.service;
2 |
3 | import android.accessibilityservice.AccessibilityService;
4 | import android.accessibilityservice.AccessibilityServiceInfo;
5 | import android.app.Notification;
6 | import android.app.PendingIntent;
7 | import android.content.Context;
8 | import android.content.Intent;
9 | import android.os.PowerManager;
10 | import android.view.accessibility.AccessibilityEvent;
11 | import android.view.accessibility.AccessibilityManager;
12 | import android.view.accessibility.AccessibilityNodeInfo;
13 | import android.widget.Toast;
14 |
15 | import com.zhoup.android.aliqrcode.R;
16 | import com.zhoup.android.aliqrcode.activity.MainActivity;
17 | import com.zhoup.android.aliqrcode.application.MyApplication;
18 | import com.zhoup.android.aliqrcode.consts.AppConst;
19 | import com.zhoup.android.aliqrcode.module.model.bean.AlipayAmountEvent;
20 | import com.zhoup.android.aliqrcode.module.model.bean.ExpandAccessibilityNodeInfo;
21 | import com.zhoup.android.aliqrcode.module.model.bean.QRCodeBean;
22 | import com.zhoup.android.aliqrcode.task.AlipayQRTask;
23 | import com.zhoup.android.aliqrcode.utils.AccessibilityServiceHelper;
24 | import com.zhoup.android.aliqrcode.utils.LogUtil;
25 | import com.zhoup.android.aliqrcode.utils.NotificationUtils;
26 | import com.zhoup.android.aliqrcode.utils.ToastUtil;
27 |
28 | import org.greenrobot.eventbus.EventBus;
29 | import org.greenrobot.eventbus.Subscribe;
30 | import org.greenrobot.eventbus.ThreadMode;
31 |
32 | import java.math.BigDecimal;
33 | import java.util.Iterator;
34 | import java.util.List;
35 | import java.util.concurrent.atomic.AtomicInteger;
36 |
37 | /**
38 | * Created by zhoup on 2017/6/22.
39 | */
40 |
41 | public class AliQRService extends AccessibilityService {
42 |
43 | private static AliQRService mAliQRService;
44 | // 执行一系列的任务
45 | private AlipayQRTask mTask;
46 | // 是否应该结束
47 | private boolean quit;
48 | private QRCodeBean mCodeBean;
49 | // 是否生成二维码, 防止在生成二维码的同时多次修改数据
50 | private boolean generate;
51 | private boolean skip;
52 | private AtomicInteger notificationId = new AtomicInteger(1);
53 | private PowerManager.WakeLock mWakeLock;
54 | private int count = 0;
55 |
56 | @Override
57 | public void onCreate() {
58 | super.onCreate();
59 | EventBus.getDefault().register(this);
60 | PowerManager pm = (PowerManager) MyApplication.getApplicationContext(this).getSystemService(Context.POWER_SERVICE);
61 | mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Tag");
62 | mTask = new AlipayQRTask();
63 | // foreground service
64 | Notification notification = NotificationUtils.buildNotification(this, R.mipmap.ic_launcher,
65 | getString(R.string.app_name), getString(R.string.alipay_autoservice_running), false,
66 | PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0));
67 | startForeground(notificationId.incrementAndGet(), notification);
68 |
69 | }
70 |
71 | @Override
72 | public void onAccessibilityEvent(AccessibilityEvent event) {
73 | if (!quit) {
74 | AccessibilityNodeInfo nodeInfo = event.getSource();
75 | ExpandAccessibilityNodeInfo target = searchNodeInfo(nodeInfo);
76 | //支付宝首页更多(“+”)菜单
77 | if (target == null) {
78 | if (getRootInActiveWindow() != null) {
79 | mTask.clickMoreMenu(getRootInActiveWindow());
80 | }
81 | return;
82 | }
83 | switch (target.getId()) {
84 | // case AppConst.OPEN_MENU_ID:
85 | // mTask.clickTargetView(target);
86 | // break;
87 | case AppConst.COLLECT_MONEY:
88 | mTask.clickTargetView(target);
89 | break;
90 | case AppConst.SET_MONEY_ID: //设置金额
91 | mTask.clickTargetView(target);
92 | break;
93 | case AppConst.ADD_GATHER_REASON_ID:
94 | mTask.clickTargetView(target);
95 | break;
96 | case AppConst.REASON_RELATIVELAYOUT_ID:
97 | // 模拟输入收款理由
98 | mTask.inputQRCodeInfo(AliQRService.this, mCodeBean, target, getRootInActiveWindow());
99 | break;
100 | case AppConst.SAVE_PICTURE: // 保存图片
101 | if (skip) {
102 | mTask.clickTargetView(target);
103 | count = count + 1;
104 | mTask.goGlobalBack(this);
105 | skip=false;
106 | generate=false;
107 | if (count >= AppConst.QRCODE_TOTAL_COUNT) {
108 | quit = true;
109 | mTask.goGlobalBack(this);
110 | this.stopSelf();
111 | }
112 | }
113 | break;
114 | default:
115 | break;
116 | }
117 | }
118 | }
119 |
120 | /**
121 | * 查找节点
122 | *
123 | * @param nodeInfo
124 | * @return
125 | */
126 | private ExpandAccessibilityNodeInfo searchNodeInfo(AccessibilityNodeInfo nodeInfo) {
127 | ExpandAccessibilityNodeInfo target;
128 |
129 | if (getRootInActiveWindow() != null) {
130 | target = AccessibilityServiceHelper.findNodeInfosById(getRootInActiveWindow(), AppConst.OPEN_MENU_ID);
131 | if (target != null) {
132 | return target;
133 | }
134 | }
135 | if (!skip) {
136 | target = AccessibilityServiceHelper.findNodeInfosById(getRootInActiveWindow(), AppConst.SET_MONEY_ID);
137 | if (target != null) {
138 | skip = true;
139 | return target;
140 | }
141 | }
142 | target = AccessibilityServiceHelper.findNodeInfosById(nodeInfo, AppConst.ADD_GATHER_REASON_ID);
143 | if (target != null) {
144 | return target;
145 | }
146 | if (!generate) {
147 | target = AccessibilityServiceHelper.findNodeInfosById(nodeInfo, AppConst.REASON_RELATIVELAYOUT_ID);
148 | if (target != null) {
149 | generate = true;
150 | return target;
151 | }
152 | }
153 | target = AccessibilityServiceHelper.findNodeInfosById(nodeInfo, AppConst.SAVE_PICTURE);
154 | if (target != null) {
155 | generate=false;
156 | return target;
157 | }
158 | target = AccessibilityServiceHelper.findNodeInfosByText(nodeInfo, AppConst.COLLECT_MONEY, "收钱");
159 | if (target != null) {
160 | return target;
161 | }
162 | return null;
163 | }
164 |
165 | @Override
166 | public void onInterrupt() {
167 | LogUtil.i("中断...");
168 | }
169 |
170 | @Override
171 | public boolean onUnbind(Intent intent) {
172 | if (mWakeLock.isHeld()) {
173 | mWakeLock.release();
174 | }
175 | return super.onUnbind(intent);
176 | }
177 |
178 | @Override
179 | protected void onServiceConnected() {
180 | super.onServiceConnected();
181 | LogUtil.i("无障碍服务连接成功");
182 | mWakeLock.acquire();
183 | quit = false;
184 | mAliQRService = this;
185 | }
186 |
187 | @Override
188 | public void onDestroy() {
189 | super.onDestroy();
190 | LogUtil.i("AlipayService onDestroy");
191 | stopForeground(true);
192 | if (mWakeLock.isHeld()) {
193 | mWakeLock.release();
194 | }
195 | mAliQRService = null;
196 | mTask = null;
197 | MyApplication.getRefWatcher(this).watch(this);
198 | EventBus.getDefault().unregister(this);
199 | }
200 |
201 | private void gotoAlipay(QRCodeBean mQRCodeBean) {
202 | this.mCodeBean = mQRCodeBean;
203 | String packageName = AppConst.ALIPAY_PACKAGE_NAME;
204 | Intent intent = getPackageManager().getLaunchIntentForPackage(packageName);
205 | if (intent != null) {
206 | startActivity(intent);
207 | } else {
208 | ToastUtil.showToast(this.getApplicationContext(), getString(R.string.uninstall_alipay),
209 | Toast.LENGTH_SHORT);
210 | }
211 | }
212 |
213 | /**
214 | * 判断服务是否已经启动
215 | *
216 | * @return
217 | */
218 | public static boolean isRunning() {
219 | if (mAliQRService == null) {
220 | return false;
221 | }
222 | AccessibilityManager accessibilityManager = (AccessibilityManager) mAliQRService.getSystemService(Context.ACCESSIBILITY_SERVICE);
223 | AccessibilityServiceInfo info = mAliQRService.getServiceInfo();
224 | if (info == null) {
225 | return false;
226 | }
227 | List list = accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_GENERIC);
228 | Iterator iterator = list.iterator();
229 |
230 | boolean isConnect = false;
231 | while (iterator.hasNext()) {
232 | AccessibilityServiceInfo i = iterator.next();
233 | if (i.getId().equals(info.getId())) {
234 | isConnect = true;
235 | break;
236 | }
237 | }
238 | if (!isConnect) {
239 | return false;
240 | }
241 | return true;
242 | }
243 |
244 |
245 | // 接收支付宝账号
246 | @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
247 | public void onAlipayAmountEvent(AlipayAmountEvent event) {
248 | if (event != null) {
249 | BigDecimal alipayAmount = event.getAmount();
250 | QRCodeBean qrCodeBean = new QRCodeBean();
251 | qrCodeBean.setAmount(alipayAmount.toString());
252 | qrCodeBean.setAssociatedCode("AAA000");
253 | gotoAlipay(qrCodeBean);
254 | }
255 | }
256 |
257 | }
258 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/task/AlipayQRTask.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.task;
2 |
3 | import android.accessibilityservice.AccessibilityService;
4 | import android.content.Context;
5 | import android.view.accessibility.AccessibilityNodeInfo;
6 |
7 | import com.zhoup.android.aliqrcode.consts.AppConst;
8 | import com.zhoup.android.aliqrcode.module.model.bean.ExpandAccessibilityNodeInfo;
9 | import com.zhoup.android.aliqrcode.module.model.bean.QRCodeBean;
10 | import com.zhoup.android.aliqrcode.utils.AccessibilityServiceHelper;
11 | import com.zhoup.android.aliqrcode.utils.LogUtil;
12 |
13 | /**
14 | * Created by zhoup on 2017/6/22.
15 | */
16 | public class AlipayQRTask {
17 |
18 | private static final long SLEEP_TIME = 500L;
19 |
20 | /**
21 | * 因为支付宝首页更多菜单(“+”)与收钱菜单冲突(resId一样),单独拧出来处理
22 | * 处理方法是先找到惟一redId的子控件按钮“更多操作”,因为按钮不可点击,所以点击事件传递到父控件
23 | * @param info
24 | */
25 | public void clickMoreMenu(AccessibilityNodeInfo info) {
26 | if (info.getChildCount() == 0) {
27 | String desc = info.getContentDescription() == null ? null : info.getContentDescription().toString();
28 | if ("更多操作".equals(desc)) {
29 | AccessibilityServiceHelper.performClick(info.getParent());
30 | }
31 | } else {
32 | for (int i = 0; i < info.getChildCount(); i++) {
33 | if (info.getChild(i) != null) {
34 | clickMoreMenu(info.getChild(i));
35 | }
36 | }
37 | }
38 | }
39 |
40 | /**
41 | * 模拟点击方法
42 | *
43 | * @param target
44 | */
45 | public void clickTargetView(ExpandAccessibilityNodeInfo target) {
46 | AccessibilityNodeInfo accessibilityNodeInfo = target.getAccessibilityNodeInfo();
47 | if (accessibilityNodeInfo != null) {
48 | LogUtil.i("点击了“" + target.getId() + "”按钮...");
49 | // 模拟点击
50 | AccessibilityServiceHelper.performClick(accessibilityNodeInfo);
51 | sleep(SLEEP_TIME);
52 | }
53 | }
54 |
55 | /**
56 | * 模拟输入收款金额和收款理由
57 | *
58 | * @param context
59 | * @param mCodeBean
60 | * @param target
61 | * @param nodeInfo
62 | */
63 |
64 | public void inputQRCodeInfo(Context context, QRCodeBean mCodeBean,
65 | ExpandAccessibilityNodeInfo target, AccessibilityNodeInfo nodeInfo) {
66 | AccessibilityNodeInfo reasonInput = AccessibilityServiceHelper
67 | .findAccessibilityNodeInfosById(nodeInfo, AppConst.REASON_RELATIVELAYOUT_ID);
68 | // get amount edittext
69 | AccessibilityNodeInfo amountInput = AccessibilityServiceHelper
70 | .findAccessibilityNodeInfosById(nodeInfo, AppConst.MONEY_RELATIVELAYOUT_ID);
71 | AccessibilityNodeInfo submitButton = AccessibilityServiceHelper
72 | .findAccessibilityNodeInfosById(nodeInfo, AppConst.SUBMIT_ID);
73 | if (reasonInput == null || submitButton == null || amountInput == null) {
74 | return;
75 | }
76 |
77 | AccessibilityServiceHelper.performInput(context, reasonInput.getChild(1),
78 | "associatedCode", mCodeBean.getAssociatedCode());
79 | // thread sleep
80 | sleep(SLEEP_TIME);
81 | // 模拟输入金额
82 | AccessibilityServiceHelper.performInput(context, amountInput.getChild(1),
83 | "amount", mCodeBean.getAmount());
84 | // thread sleep
85 | sleep(SLEEP_TIME);
86 | // 模拟点击确定按钮
87 | AccessibilityServiceHelper.performClick(submitButton);
88 | }
89 |
90 | /**
91 | * 模拟点击返回键
92 | *
93 | * @param service
94 | */
95 | public void goGlobalBack(AccessibilityService service) {
96 | AccessibilityServiceHelper.performBack(service);
97 | sleep(SLEEP_TIME);
98 | }
99 |
100 | /**
101 | * 每一次点击后停顿一段时间
102 | *
103 | * @param time
104 | */
105 |
106 | private void sleep(long time) {
107 | try {
108 | Thread.sleep(time);
109 | } catch (InterruptedException e) {
110 | e.printStackTrace();
111 | }
112 | }
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/utils/AccessibilityServiceHelper.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.utils;
2 |
3 | import android.accessibilityservice.AccessibilityService;
4 | import android.content.ClipData;
5 | import android.content.ClipboardManager;
6 | import android.content.Context;
7 | import android.os.Build;
8 | import android.os.Bundle;
9 | import android.text.TextUtils;
10 | import android.view.accessibility.AccessibilityNodeInfo;
11 |
12 | import com.zhoup.android.aliqrcode.application.MyApplication;
13 | import com.zhoup.android.aliqrcode.module.model.bean.ExpandAccessibilityNodeInfo;
14 |
15 | import java.lang.reflect.Field;
16 | import java.util.List;
17 |
18 | /**
19 | * Created by zhoup on 2017/6/23.
20 | */
21 |
22 | public class AccessibilityServiceHelper {
23 | /**
24 | * 通过id查找
25 | */
26 | public static ExpandAccessibilityNodeInfo findNodeInfosById(AccessibilityNodeInfo nodeInfo, String resId) {
27 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && nodeInfo != null) {
28 | List list = nodeInfo.findAccessibilityNodeInfosByViewId(resId);
29 | if (list != null && !list.isEmpty()) {
30 | return new ExpandAccessibilityNodeInfo(list.get(0), resId);
31 | }
32 | }
33 | return null;
34 | }
35 |
36 | /**
37 | * 通过id查找
38 | */
39 | public static ExpandAccessibilityNodeInfo findNodeInfosById(AccessibilityNodeInfo nodeInfo, String resId, int index) {
40 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && nodeInfo != null) {
41 | List list = nodeInfo.findAccessibilityNodeInfosByViewId(resId);
42 | if (list != null && !list.isEmpty()) {
43 | return new ExpandAccessibilityNodeInfo(list.get(index), resId);
44 | }
45 | }
46 | return null;
47 | }
48 |
49 | /**
50 | * 通过id查找
51 | */
52 | public static AccessibilityNodeInfo findAccessibilityNodeInfosById(AccessibilityNodeInfo nodeInfo, String resId, int index) {
53 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
54 | List list = nodeInfo.findAccessibilityNodeInfosByViewId(resId);
55 | if (list != null && !list.isEmpty()) {
56 | return list.size() > index ? list.get(index) : null;
57 | }
58 | }
59 | return null;
60 | }
61 |
62 | /**
63 | * 通过id查找
64 | */
65 | public static AccessibilityNodeInfo findAccessibilityNodeInfosById(AccessibilityNodeInfo nodeInfo, String resId) {
66 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
67 | List list = nodeInfo.findAccessibilityNodeInfosByViewId(resId);
68 | if (list != null && !list.isEmpty()) {
69 | return list.get(0);
70 | }
71 | }
72 | return null;
73 | }
74 |
75 | /**
76 | * 通过文本查找
77 | */
78 | public static ExpandAccessibilityNodeInfo findNodeInfosByText(AccessibilityNodeInfo nodeInfo, String resId, String text) {
79 | List list = nodeInfo.findAccessibilityNodeInfosByText(text);
80 | if (list == null || list.isEmpty()) {
81 | return null;
82 | }
83 | return new ExpandAccessibilityNodeInfo(list.get(0), resId);
84 | }
85 |
86 | /**
87 | * 通过关键字查找
88 | */
89 | public static ExpandAccessibilityNodeInfo findNodeInfosByTexts(AccessibilityNodeInfo nodeInfo, String resId, String... texts) {
90 | for (String key : texts) {
91 | ExpandAccessibilityNodeInfo info = findNodeInfosByText(nodeInfo, resId, key);
92 | if (info != null) {
93 | return info;
94 | }
95 | }
96 | return null;
97 | }
98 |
99 | /**
100 | * 通过组件名字查找
101 | */
102 | public static AccessibilityNodeInfo findNodeInfosByClassName(AccessibilityNodeInfo nodeInfo, String className) {
103 | if (TextUtils.isEmpty(className)) {
104 | return null;
105 | }
106 | for (int i = 0; i < nodeInfo.getChildCount(); i++) {
107 | AccessibilityNodeInfo node = nodeInfo.getChild(i);
108 | if (className.equals(node.getClassName())) {
109 | return node;
110 | }
111 | }
112 | return null;
113 | }
114 |
115 | /**
116 | * 找父组件
117 | */
118 | public static AccessibilityNodeInfo findParentNodeInfosByClassName(AccessibilityNodeInfo nodeInfo, String className) {
119 | if (nodeInfo == null) {
120 | return null;
121 | }
122 | if (TextUtils.isEmpty(className)) {
123 | return null;
124 | }
125 | if (className.equals(nodeInfo.getClassName())) {
126 | return nodeInfo;
127 | }
128 | return findParentNodeInfosByClassName(nodeInfo.getParent(), className);
129 | }
130 |
131 | private static final Field sSourceNodeField;
132 |
133 | static {
134 | Field field = null;
135 | try {
136 | field = AccessibilityNodeInfo.class.getDeclaredField("mSourceNodeId");
137 | field.setAccessible(true);
138 | } catch (Exception e) {
139 | e.printStackTrace();
140 | }
141 | sSourceNodeField = field;
142 | }
143 |
144 | public static long getSourceNodeId(AccessibilityNodeInfo nodeInfo) {
145 | if (sSourceNodeField == null) {
146 | return -1;
147 | }
148 | try {
149 | return sSourceNodeField.getLong(nodeInfo);
150 | } catch (Exception e) {
151 | e.printStackTrace();
152 | }
153 | return -1;
154 | }
155 |
156 | public static String getViewIdResourceName(AccessibilityNodeInfo nodeInfo) {
157 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
158 | return nodeInfo.getViewIdResourceName();
159 | }
160 | return null;
161 | }
162 |
163 | /**
164 | * 返回主界面事件
165 | */
166 | public static void performHome(AccessibilityService service) {
167 | if (service == null) {
168 | return;
169 | }
170 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
171 | service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_HOME);
172 | }
173 | }
174 |
175 | /**
176 | * 返回事件
177 | */
178 | public static void performBack(AccessibilityService service) {
179 | if (service == null) {
180 | return;
181 | }
182 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
183 | LogUtil.i("模拟点击了物理返回键 GLOBAL_ACTION_BACK 按钮");
184 | service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
185 | }
186 | }
187 |
188 | /**
189 | * 点击事件
190 | */
191 | public static void performClick(AccessibilityNodeInfo nodeInfo) {
192 | if (nodeInfo == null) {
193 | return;
194 | }
195 | if (nodeInfo.isClickable()) {
196 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
197 | nodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
198 | }
199 | } else {
200 | performClick(nodeInfo.getParent());
201 | }
202 | }
203 |
204 | public static void performInput(AccessibilityNodeInfo nodeInfo, String text) {
205 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
206 | Bundle arguments = new Bundle();
207 | arguments.putCharSequence(
208 | AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, text);
209 | nodeInfo.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments);
210 | }
211 | }
212 |
213 | /**
214 | * 输入事件
215 | */
216 | public static void performInput(Context context, AccessibilityNodeInfo nodeInfo, String label, String text) {
217 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
218 | ClipboardManager clipboard = (ClipboardManager) MyApplication.getApplicationContext(context).getSystemService(Context.CLIPBOARD_SERVICE);
219 | ClipData clip = ClipData.newPlainText(label, text);
220 | clipboard.setPrimaryClip(clip);
221 | try {
222 | Thread.sleep(100L);
223 | } catch (InterruptedException e) {
224 | e.printStackTrace();
225 | }
226 | nodeInfo.performAction(AccessibilityNodeInfo.ACTION_FOCUS);
227 | LogUtil.i("写入了 label = " + label + " , text = " + text);
228 | nodeInfo.performAction(AccessibilityNodeInfo.ACTION_PASTE);
229 | }
230 | }
231 | }
232 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/utils/DialogUtils.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.utils;
2 |
3 | import android.content.Context;
4 | import android.content.DialogInterface;
5 | import android.support.v7.app.AlertDialog;
6 |
7 | /**
8 | *Created by zhoup on 2017/6/22.
9 | */
10 |
11 | public class DialogUtils {
12 |
13 | private DialogUtils() {
14 | //no instance
15 | }
16 |
17 | public static void showMessage(Context context, int titleId, int messageId, boolean cancelable,
18 | int positionId, DialogInterface.OnClickListener onClickListener) {
19 | AlertDialog.Builder builder = new AlertDialog.Builder(context);
20 | builder.setTitle(titleId)
21 | .setMessage(messageId)
22 | .setCancelable(cancelable)
23 | .setPositiveButton(positionId, onClickListener).show();
24 | }
25 |
26 | public static void showMessage(Context context, int titleId, int messageId, boolean cancelable,
27 | int negativeId, DialogInterface.OnClickListener negativeOnClickListener,
28 | int positionId, DialogInterface.OnClickListener positionOnclickListener) {
29 | AlertDialog.Builder builder = new AlertDialog.Builder(context);
30 | builder.setTitle(titleId)
31 | .setMessage(messageId)
32 | .setCancelable(cancelable)
33 | .setNegativeButton(negativeId, negativeOnClickListener)
34 | .setPositiveButton(positionId, positionOnclickListener).show();
35 | }
36 |
37 | public static void showMessage(Context context, int titleId, String message, boolean cancelable,
38 | int negativeId, DialogInterface.OnClickListener negativeOnClickListener,
39 | int positionId, DialogInterface.OnClickListener positionOnclickListener) {
40 | AlertDialog.Builder builder = new AlertDialog.Builder(context);
41 | builder.setTitle(titleId)
42 | .setMessage(message)
43 | .setCancelable(cancelable)
44 | .setNegativeButton(negativeId, negativeOnClickListener)
45 | .setPositiveButton(positionId, positionOnclickListener).show();
46 | }
47 |
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/utils/LogUtil.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.utils;
2 |
3 | import android.os.Environment;
4 | import android.util.Log;
5 |
6 |
7 | import com.zhoup.android.aliqrcode.BuildConfig;
8 | import com.zhoup.android.aliqrcode.consts.AppConst;
9 |
10 | import java.io.File;
11 | import java.io.FileNotFoundException;
12 | import java.io.FileOutputStream;
13 | import java.io.IOException;
14 | import java.io.OutputStream;
15 | import java.io.OutputStreamWriter;
16 | import java.io.UnsupportedEncodingException;
17 | import java.util.Calendar;
18 |
19 | /**
20 | * Created by zhoup on 2017/6/22.
21 | */
22 |
23 | public class LogUtil {
24 |
25 | private static final boolean DEBUG = BuildConfig.DEBUG;
26 | private static final String TAG = "AccessibilityService";
27 | private static final Calendar calendar = Calendar.getInstance();
28 |
29 | public static void i(String tag, String info) {
30 | if (DEBUG) {
31 | Log.i(tag, info);
32 | }
33 | printLog(info);
34 | }
35 |
36 | public static void i(String info) {
37 | if (DEBUG) {
38 | Log.i(TAG, info);
39 | }
40 | printLog(info);
41 | }
42 |
43 | public static void e(String tag, String info) {
44 | if (DEBUG) {
45 | Log.i(tag, info);
46 | }
47 | printLog(info);
48 | }
49 |
50 | public static void e(String info) {
51 | if (DEBUG) {
52 | Log.i(TAG, info);
53 | }
54 | printLog(info);
55 | }
56 |
57 | private static void printLog(final String log) {
58 | String parentPath = Environment.getExternalStorageDirectory().getAbsolutePath()
59 | + AppConst.LOG_DIR;
60 | String fileName = "log_" + "_" + calendar.get(Calendar.YEAR) + "_"
61 | + (calendar.get(Calendar.MONTH) + 1) + "_" + calendar.get(Calendar.DAY_OF_MONTH)
62 | + ".txt";
63 | File file = new File(parentPath, fileName);
64 | if (!file.getParentFile().exists()) {
65 | file.getParentFile().mkdirs();
66 | }
67 | try {
68 | OutputStream output = new FileOutputStream(file.getAbsolutePath(), true);
69 | OutputStreamWriter outputStreamWriter = new OutputStreamWriter(output, "UTF-8");
70 | outputStreamWriter.write(log + "\n");
71 | outputStreamWriter.flush();
72 | outputStreamWriter.close();
73 | output.close();
74 | } catch (FileNotFoundException e) {
75 | e.printStackTrace();
76 | } catch (UnsupportedEncodingException e) {
77 | e.printStackTrace();
78 | } catch (IOException e) {
79 | e.printStackTrace();
80 | }
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/utils/NotificationUtils.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.utils;
2 |
3 | import android.app.Notification;
4 | import android.app.NotificationManager;
5 | import android.app.PendingIntent;
6 | import android.content.Context;
7 | import android.support.v7.app.NotificationCompat;
8 |
9 | import com.zhoup.android.aliqrcode.application.MyApplication;
10 |
11 |
12 | /**
13 | *Created by zhoup on 2017/6/23.
14 | */
15 |
16 | public class NotificationUtils {
17 |
18 | private NotificationUtils() {
19 | //no instance
20 | }
21 |
22 | public static Notification buildNotification(Context context, int smallIcon, String contentTitle,
23 | String contentText, boolean autoCancel, PendingIntent intent) {
24 | return buildNotification(context, smallIcon, contentTitle, contentText, autoCancel, 0, intent);
25 | }
26 |
27 | public static Notification buildNotification(Context context, int smallIcon, String contentTitle,
28 | String contentText, boolean autoCancel, int defaultId, PendingIntent intent) {
29 | NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
30 | return builder.setSmallIcon(smallIcon).setContentTitle(contentTitle)
31 | .setContentText(contentText).setContentIntent(intent)
32 | .setDefaults(defaultId)
33 | .setAutoCancel(autoCancel).build();
34 | }
35 |
36 | public static void sendNotification(Context context, int smallIcon, String contentTitle, String contentText,
37 | boolean autoCancel, int defaultId, PendingIntent intent, int notificationId) {
38 | Notification notification = NotificationUtils.buildNotification(context, smallIcon, contentTitle,
39 | contentText, autoCancel, defaultId, intent);
40 | NotificationManager manager = (NotificationManager) MyApplication.getApplicationContext(context)
41 | .getSystemService(Context.NOTIFICATION_SERVICE);
42 | manager.notify(notificationId, notification);
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/utils/SnackbarUtil.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.utils;
2 |
3 | import android.support.design.widget.Snackbar;
4 | import android.view.View;
5 |
6 | /**
7 | * Created by zhoup on 2017/6/22.
8 | */
9 |
10 | public class SnackbarUtil {
11 |
12 | private static Snackbar mSnackbar;
13 |
14 | private SnackbarUtil() {
15 | //no instance
16 | }
17 |
18 | public static void showSnackbar(View view, CharSequence text, int duration) {
19 | if (mSnackbar != null) {
20 | mSnackbar.setText(text);
21 | } else {
22 | mSnackbar = Snackbar.make(view, text, duration);
23 | }
24 | mSnackbar.show();
25 | }
26 |
27 | public static void destroy() {
28 | if (mSnackbar != null && mSnackbar.isShown()) {
29 | mSnackbar.dismiss();
30 | }
31 | mSnackbar = null;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zhoup/android/aliqrcode/utils/ToastUtil.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode.utils;
2 |
3 | import android.content.Context;
4 | import android.widget.Toast;
5 |
6 | /**
7 | * Created by zhoup on 2017/6/22.
8 | */
9 |
10 | public class ToastUtil {
11 |
12 | private static Toast mToast;
13 |
14 | private ToastUtil() {
15 | //no instance
16 | }
17 |
18 | public static void showToast(Context context, CharSequence text, int duration) {
19 | if (mToast != null) {
20 | mToast.setText(text);
21 | } else {
22 | mToast = Toast.makeText(context, text, duration);
23 | }
24 | mToast.show();
25 | }
26 |
27 | public static void showToast(Context context, int resId, int duration) {
28 | if (mToast != null) {
29 | mToast.setText(resId);
30 | } else {
31 | mToast = Toast.makeText(context, resId, duration);
32 | }
33 | mToast.show();
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
25 |
26 |
31 |
32 |
36 |
37 |
43 |
44 |
45 |
46 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoup0512/aliqrcode/86989b03f27ae49f00a134ac8394189b38486390/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoup0512/aliqrcode/86989b03f27ae49f00a134ac8394189b38486390/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoup0512/aliqrcode/86989b03f27ae49f00a134ac8394189b38486390/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoup0512/aliqrcode/86989b03f27ae49f00a134ac8394189b38486390/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoup0512/aliqrcode/86989b03f27ae49f00a134ac8394189b38486390/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 自动生成支付宝收款码工具V1.0
3 | 开启辅助功能
4 | 用户须知
5 | 本软件需要开启辅助功能才能使用
6 | 打开辅助功能
7 | 打开支付宝
8 | 未安装支付宝
9 | 未授予本软件权限
10 | 此程序为自动生成支付宝二维码工具,开启服务需要辅助功能支持
11 | 打开/关闭 自动生成支付宝二维码
12 | 以下为运行程序时打印出来的部分log,完整log文件在/aliqrcode_log/*目录下
13 | \n---------------------------------------------------------------------
14 | 自动生成支付宝二维码
15 | 二维码无障碍服务
16 | 该支付宝账户的二维码已经生成完毕
17 | 步骤一
18 | 步骤二
19 | 请输入要生成二维码的支付金额
20 | 确定
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/service_config.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/src/test/java/com/zhoup/android/aliqrcode/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.zhoup.android.aliqrcode;
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() throws Exception {
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 | apply from: "config.gradle"
3 |
4 | buildscript {
5 | repositories {
6 | jcenter()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:2.3.1'
10 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | jcenter()
19 | }
20 | }
21 |
22 | task clean(type: Delete) {
23 | delete rootProject.buildDir
24 | }
25 |
--------------------------------------------------------------------------------
/config.gradle:
--------------------------------------------------------------------------------
1 | ext {
2 |
3 | android = [
4 | compileSdkVersion : 26,
5 | buildToolsVersion : "26.0.0",
6 | applicationId : "com.zhoup.android.aliqrcode",
7 | minSdkVersion : 18,
8 | targetSdkVersion : 26,
9 | versionCode : 1,
10 | versionName : "1.0",
11 | testInstrumentationRunner: "android.support.test.runner.AndroidJUnitRunner"
12 | ]
13 |
14 | dependencies = [
15 | "appcompat-v7" : 'com.android.support:appcompat-v7:26.+',
16 | "recyclerview-v7" : 'com.android.support:recyclerview-v7:26.+',
17 | "design" : 'com.android.support:design:26.+',
18 | "glide" : 'com.github.bumptech.glide:glide:3.7.0',
19 | "retrofit" : 'com.squareup.retrofit2:retrofit:2.1.0',
20 | "logging-interceptor" : 'com.squareup.okhttp:logging-interceptor:2.6.0',
21 | "converter-gson" : 'com.squareup.retrofit2:converter-gson:2.1.0',
22 | "adapter-rxjava" : 'com.squareup.retrofit2:adapter-rxjava:2.1.0',
23 | "rxbinding" : 'com.jakewharton.rxbinding:rxbinding:0.4.0',
24 | "rxjava" : 'io.reactivex:rxjava:1.2.0',
25 | "rxandroid" : 'io.reactivex:rxandroid:1.2.1',
26 | "rxpermissions" : 'com.tbruyelle.rxpermissions:rxpermissions:0.8.0@aar',
27 | "eventbus" : 'org.greenrobot:eventbus:3.0.0',
28 | "zxing" : 'com.google.zxing:core:3.3.0',
29 | "butterknife" : 'com.jakewharton:butterknife:8.4.0',
30 | "butterknife-compiler" : 'com.jakewharton:butterknife-compiler:8.4.0',
31 | "leakcanary-android" : 'com.squareup.leakcanary:leakcanary-android:1.5',
32 | "leakcanary-android-no-op": 'com.squareup.leakcanary:leakcanary-android-no-op:1.5',
33 | "junit" : 'junit:junit:4.12'
34 | ]
35 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoup0512/aliqrcode/86989b03f27ae49f00a134ac8394189b38486390/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jun 21 17:00:33 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/screen_recrod/1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoup0512/aliqrcode/86989b03f27ae49f00a134ac8394189b38486390/screen_recrod/1.gif
--------------------------------------------------------------------------------
/screen_recrod/2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoup0512/aliqrcode/86989b03f27ae49f00a134ac8394189b38486390/screen_recrod/2.gif
--------------------------------------------------------------------------------
/screen_recrod/3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zoup0512/aliqrcode/86989b03f27ae49f00a134ac8394189b38486390/screen_recrod/3.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------