commit f298a018c6fc5e7febb8cbece79a25cfafd5d0c9 Author: jianbo <263303411@qq.com> Date: Wed Sep 22 10:02:44 2021 +0800 atom diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b75303 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..0d15693 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..8f32900 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..dbf0c76 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,31 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..2370474 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..892046b --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..ba923f3 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,131 @@ +apply plugin: 'com.android.application' + +// 定义变量,同学们注意:可以定义变量,也可以不定义变量 +def app_android = this.getRootProject().ext.app_android; +def app_dependencies = this.rootProject.ext.app_dependencies; + +android { + // compileOptions.encoding = "GBK" + compileSdkVersion app_android.compileSdkVersion + buildToolsVersion app_android.buildToolsVersion + defaultConfig { + applicationId app_android.applicationId + minSdkVersion app_android.minSdkVersion + targetSdkVersion app_android.targetSdkVersion + versionCode app_android.versionCode + versionName app_android.versionName + testInstrumentationRunner app_android.testInstrumentationRunner + + // 这个方法接收三个非空的参数,第一个:确定值的类型,第二个:指定key的名字,第三个:传值(必须是String) + // 为什么需要定义这个?因为src代码中有可能需要用到跨模块交互,如果是组件化模块显然不行 + // 切记:不能在android根节点,只能在defaultConfig或buildTypes节点下 + buildConfigField("boolean", "isRelease", String.valueOf(isRelease)) + + // 在gradle文件中配置选项参数值(用于APT传参接收) + // 同学们注意:切记:必须写在defaultConfig节点下 + javaCompileOptions { + annotationProcessorOptions { + // project.getName() == app + arguments = [moduleName: project.getName(), packageNameForAPT: packageNameForAPT] + } + } + } + buildTypes { + + debug { + buildConfigField("String", "debug", "\"${url.debug}\"") + + minifyEnabled false + debuggable true + } + release { + buildConfigField("String", "release", "\"${url.release}\"") + + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + aaptOptions.cruncherEnabled = false + aaptOptions.useNewCruncher = false + applicationVariants.all { variant -> + variant.outputs.all { + // 输出apk名称为dc_v1.0_wandoujia.apk + def fileName = "atom-latest.apk" + outputFileName = fileName + } + } + } + } + lintOptions { + checkReleaseBuilds false + abortOnError false + } + //签名 + signingConfigs { + release { + + storeFile file('fuzhu.jks') + storePassword "123456" + keyAlias "fuzhu" + keyPassword "123456" + } + + } + dataBinding { + enabled = true + } + compileOptions { + sourceCompatibility = '1.8' + targetCompatibility = '1.8' + } +} + +this.android.sourceSets { + main { + jniLibs.srcDirs = ['libs'] + res.srcDirs = ['src/main/res', 'src/main/res_zxing'] + } +} +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + + // 循环引入第三方库 + app_dependencies.each {k, v -> + // if (k != "aa" && v != "cc") {} + implementation v + } + + + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.2.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + + implementation files('libs\\eventbus-2.4.0.jar') + implementation files('lib\\XposedBridgeApi-54.jar') + androidTestImplementation 'androidx.test:runner:1.2.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + api 'com.blankj:utilcode:1.23.7' + api 'com.tencent.bugly:crashreport:latest.release' + // 公共基础库 + implementation project(":common") + + // arouter 专用 注解模块 + implementation project(":arouter_annotation") + + // 使用注解处理器 + // arouter 专用 注解处理器 + annotationProcessor project(':arouter_compiler') + + // 如果是集成化模式,做发布版本时。各个模块都不能独立运行了 + if (isRelease) { + // 进if,集成,融为一体(order,personal) + + // 订单模块 + implementation project(":order") + + // 个人中心模块 + implementation project(":personal") + + // 个人中心模块 + implementation project(":wechat") + + } +} diff --git a/app/lib/XposedBridgeApi-54.jar b/app/lib/XposedBridgeApi-54.jar new file mode 100644 index 0000000..fefd4ec Binary files /dev/null and b/app/lib/XposedBridgeApi-54.jar differ diff --git a/app/libs/bdasr_V3_20191017_81d0afc.jar b/app/libs/bdasr_V3_20191017_81d0afc.jar new file mode 100644 index 0000000..6ae7804 Binary files /dev/null and b/app/libs/bdasr_V3_20191017_81d0afc.jar differ diff --git a/app/libs/eventbus-2.4.0.jar b/app/libs/eventbus-2.4.0.jar new file mode 100644 index 0000000..fd5ae26 Binary files /dev/null and b/app/libs/eventbus-2.4.0.jar differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/xiangxue/new_modular_customarouter/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/xiangxue/new_modular_customarouter/ExampleInstrumentedTest.java new file mode 100644 index 0000000..652a4fc --- /dev/null +++ b/app/src/androidTest/java/com/xiangxue/new_modular_customarouter/ExampleInstrumentedTest.java @@ -0,0 +1,27 @@ +package com.xiangxue.new_modular_customarouter; + +import android.content.Context; + +import androidx.test.InstrumentationRegistry; +import androidx.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.xiangxue.new_modular_customarouter", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..759bad7 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/ContactsHelp.java b/app/src/main/java/com/fisherbone/ContactsHelp.java new file mode 100644 index 0000000..af54f1c --- /dev/null +++ b/app/src/main/java/com/fisherbone/ContactsHelp.java @@ -0,0 +1,170 @@ +package com.fisherbone; + +import android.content.ContentProviderOperation; +import android.content.ContentResolver; +import android.content.Context; +import android.content.OperationApplicationException; +import android.net.Uri; +import android.os.Handler; +import android.os.Message; +import android.os.RemoteException; + +import com.blankj.utilcode.util.ToastUtils; +import com.fisherbone.fuzhu.db.zhuanghaoBeanData; +import com.fisherbone.fuzhu.views.ConfirmDialog; +import com.fisherbone.fuzhu.views.LoadingDialog; + +import java.util.ArrayList; +import java.util.List; + +public class ContactsHelp { + Context mcontext; + private LoadingDialog mLoadingDialog; + /** + * 导入通讯录 + */ + public static final int IMPORT_PHONE = 0; + /** + * 导入完成 + */ + public static final int IMPORT_PHONE_OVER = 1; + /** + * 清空号码段 + */ + public static final int CLEAN_PHONE = 2; + /** + * 清空通讯录 + */ + public static final int CLEAN_PHONE_BOOK = 3; + /** + * 通讯录清空完成 + */ + public static final int CLEAN_PHONE_OVER = 4; + + /** + * 自定义对话框 + */ + private ConfirmDialog mConfirmDialog; + private static final String TODO = null; + private Handler myHandler = new Handler() { + @Override + public void handleMessage(Message msg) { + super.handleMessage(msg); + switch (msg.what) { + case IMPORT_PHONE: + //加载进度 + mLoadingDialog = new LoadingDialog(mcontext); + mLoadingDialog.setContent("正在导入通讯录..."); + mLoadingDialog.setCancelable(false); + mLoadingDialog.show(); + break; + + case IMPORT_PHONE_OVER: + mLoadingDialog.dismiss(); + ToastUtils.showShort("导入成功"); + break; + + case CLEAN_PHONE: + ToastUtils.showShort("清空成功"); + break; + + case CLEAN_PHONE_BOOK: + //清空通讯录 + mLoadingDialog = new LoadingDialog(mcontext); + mLoadingDialog.setContent("正在清空通讯录..."); + mLoadingDialog.setCancelable(false); + mLoadingDialog.show(); + break; + + case CLEAN_PHONE_OVER: + mLoadingDialog.dismiss(); + ToastUtils.showShort("清空成功"); + break; + default: + } + } + }; + + private static ContactsHelp instance = null; + public static ContactsHelp getInstance(Context context) { + if (instance == null) { + instance = new ContactsHelp(context); + } + return instance; + } + + public ContactsHelp(Context context) { + this.mcontext=context; + } + + + public void importContacts(List phoneNumber){ + //导入通讯录 + if (phoneNumber.size() == 0) { + ToastUtils.showShort("号码不能为空"); + } else { + new Thread(new Runnable() { + @Override + public void run() { + myHandler.sendEmptyMessage(IMPORT_PHONE); + try { + testAddContactsInTransaction(phoneNumber); + + } catch (Exception e) { + e.printStackTrace(); + } + myHandler.sendEmptyMessage(IMPORT_PHONE_OVER); + } + }).start(); + } + } + + /** + * 批量添加联系人到通讯录中 + * + * @throws Exception + */ + public void testAddContactsInTransaction(List phoneNumber) throws Exception { + ArrayList mOperations = new ArrayList<>(); + ContentResolver resolver = mcontext.getContentResolver(); + int rawContactInsertIndex; + // 循环添加 + for (int i = 0; i < phoneNumber.size(); i++) { + Uri uri = Uri.parse("content://com.android.contacts/raw_contacts"); + rawContactInsertIndex = mOperations.size();// 这句好很重要,有了它才能给真正的实现批量添加。 + // 向raw_contact表添加一条记录 + // 此处.withValue("account_name", null)一定要加,不然会抛NullPointerException + ContentProviderOperation operation1 = ContentProviderOperation.newInsert(uri) + .withValue("account_name", null).build(); + mOperations.add(operation1); + // 向data添加数据 + uri = Uri.parse("content://com.android.contacts/data"); + // 添加姓名 + ContentProviderOperation operation2 = ContentProviderOperation.newInsert(uri) + .withValueBackReference("raw_contact_id", rawContactInsertIndex) + // withValueBackReference的第二个参数表示引用operations[0]的操作的返回id作为此值 + .withValue("mimetype", "vnd.android.cursor.item/name").withValue("data2", phoneNumber.get(i).getName()) + .withYieldAllowed(true).build(); + mOperations.add(operation2); + // 添加手机数据 + ContentProviderOperation operation3 = ContentProviderOperation.newInsert(uri) + .withValueBackReference("raw_contact_id", rawContactInsertIndex) + .withValue("mimetype", "vnd.android.cursor.item/phone_v2").withValue("data2", "2") + .withValue("data1", phoneNumber.get(i).getPhone()).withYieldAllowed(true).build(); + mOperations.add(operation3); + + } + try { + // 这里才调用的批量添加 + resolver.applyBatch("com.android.contacts", mOperations); + + } catch (RemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (OperationApplicationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/BaseActivity.java b/app/src/main/java/com/fisherbone/fuzhu/BaseActivity.java new file mode 100644 index 0000000..6732956 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/BaseActivity.java @@ -0,0 +1,253 @@ +package com.fisherbone.fuzhu; + +import android.Manifest; +import android.app.Activity; +import android.app.ActivityManager; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.content.res.Configuration; +import android.net.Uri; +import android.os.Bundle; +import android.text.TextPaint; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.View; +import android.view.WindowManager; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.ColorRes; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; +import androidx.fragment.app.FragmentActivity; + +import com.blankj.utilcode.util.ToastUtils; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.utils.AblUtil; +import com.fisherbone.fuzhu.utils.StatusBarUtil; + + +/** + * @author: qndroid + * @function: 所有Activity的基类,用来处理一些公共事件,如:数据统计 + * @date: 16/3/10 + */ +public abstract class BaseActivity extends FragmentActivity { + + public static final int REQUEST_CALL_PERMISSION = 10111; //拨号请求码 + protected final String TAG = this.getClass().getSimpleName(); + public String VALUE_ZERO="0"; + public String VALUE_ONE="1"; + public String VALUE_TWO="2"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + reverseStatusColor(); + StatusBarUtil.transparencyBar(this); //设置状态栏全透明 + StatusBarUtil.StatusBarLightMode(this); //设置白底黑字 + StatusBarUtil.setStatusBarColor(this, R.color.colortitlebar); + initFontScale(); + + DisplayMetrics dm = getResources().getDisplayMetrics(); + int screenWidth = dm.widthPixels; + int screenHeight = dm.heightPixels; + Log.e("屏幕分辨率", "宽"+screenWidth+"=="+"高"+screenHeight); + + } + + + + + /** + * 拨打电话(直接拨打) + * + * @param telPhone 电话 + */ + public void call(String telPhone) { + if (checkReadPermission(Manifest.permission.CALL_PHONE, REQUEST_CALL_PERMISSION)) { + Intent intent = new Intent(); + intent.setAction(Intent.ACTION_CALL); + Uri phoneNum = Uri.parse("tel:" + telPhone); + intent.setData(phoneNum); + startActivity(intent); + } + + } + + /** + * 判断是否有某项权限 + * + * @param string_permission 权限 + * @param request_code 请求码 + * @return + */ + public boolean checkReadPermission(String string_permission, int request_code) { + boolean flag = false; + if (ContextCompat.checkSelfPermission(this, string_permission) == PackageManager.PERMISSION_GRANTED) {//已有权限 + flag = true; + } else {//申请权限 + ActivityCompat.requestPermissions(this, new String[]{string_permission}, request_code); + } + return flag; + } + + private void initFontScale() { + Configuration configuration = getResources().getConfiguration(); + configuration.fontScale = (float) 1; + //0.85 小, 1 标准大小, 1.15 大,1.3 超大 ,1.45 特大 + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + metrics.scaledDensity = configuration.fontScale * metrics.density; + getBaseContext().getResources().updateConfiguration(configuration, metrics); + } + + + @Override + protected void onStop() { + super.onStop(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + } + + /** + * 申请指定的权限. + */ + public void requestPermission(int code, String... permissions) { + + ActivityCompat.requestPermissions(this, permissions, code); + } + + + /** + * 判断是否有指定的权限 + */ + public boolean hasPermission(String... permissions) { + + for (String permisson : permissions) { + if (ContextCompat.checkSelfPermission(this, permisson) + != PackageManager.PERMISSION_GRANTED) { + return false; + } + } + return true; + } + + + /** + * 处理整个应用用中的SDCard业务 + */ + public void doSDCardPermission() { + } + + /** + * 隐藏状态栏 + */ + public void hiddenStatusBar() { + getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, + WindowManager.LayoutParams.FLAG_FULLSCREEN); + } + /** + * 开启一个Activity + * + * @param clz + */ + public void startActivity(Class clz) { + startActivity(new Intent(this, clz)); + } + /** + * 改变状态栏颜色 + * + * @param color + */ + public void changeStatusBarColor(@ColorRes int color) { + // StatusBarUtil.setStatusBarColor(this, color); + } + + /** + * 调整状态栏为亮模式,这样状态栏的文字颜色就为深模式了。 + */ + private void reverseStatusColor() { +// StatusBarUtil.statusBarLightMode(this); + } + + public void toast(String msg) { + Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); + } + /** + * 字体加粗 + */ + protected void Thickening(TextView mLayTopTitle) { + TextPaint tp = mLayTopTitle.getPaint(); + tp.setFakeBoldText(true); + } + protected void Thickeningtwo(TextView mLayTopTitle) { + TextPaint tp = mLayTopTitle.getPaint(); + tp.setFakeBoldText(false); + } + + /** + * 初始化一般返回按钮事件 + */ + public void initNormalBack() { + + ImageView iv_back = (ImageView) findViewById(R.id.iv_left_btn); + + + if (iv_back != null) { + iv_back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + } + } + + /** + * 开始执行 + */ + public void StartExecution(Context context,int arg) { + if (AblUtil.isAccessibilityServiceOpen(context)) { + AblStepHandler.getInstance().setStop(false); + AblStepHandler.sendMsg(arg); + } else { + ToastUtils.showShort("点到了"); + ToastUtils.showShort("请先开启辅助服务"); + AblUtil.openAccessibilitySettings(); + } + + } + + /** + * 获取该系统版本号 + * + * @return + */ + public String getVersionn() { + try { + PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0); +// return "Ver." + pi.versionName; + return pi.versionName; + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + return ""; + } + } + + public void displayBriefMemory() { + final ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); + ActivityManager.MemoryInfo info = new ActivityManager.MemoryInfo(); + activityManager.getMemoryInfo(info); + Log.i("内存tag", "系统剩余内存:" + (info.availMem >> 10) + "k"); + Log.i("内存tag", "系统是否处于低内存运行:" + info.lowMemory); + Log.i("内存tag", "当系统剩余内存低于" + info.threshold + "时就看成低内存运行"); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/BootBroadcastReceiver.java b/app/src/main/java/com/fisherbone/fuzhu/BootBroadcastReceiver.java new file mode 100644 index 0000000..6c693d9 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/BootBroadcastReceiver.java @@ -0,0 +1,29 @@ +package com.fisherbone.fuzhu; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.util.Log; + +import com.fisherbone.fuzhu.activity.MainActivity; + +public class BootBroadcastReceiver extends BroadcastReceiver { + + static final String ACTION="android.intent.action.BOOT_COMPLETED"; + + @Override + public void onReceive(Context context, Intent intent) { + // TODO: This method is called when the BroadcastReceiver is receiving + // an Intent broadcast. + if(intent.getAction().equals(ACTION)){ + + Log.d("ciky","接收器接受到开启完成广播!"+intent.getAction()); + System.out.println("自启动程序即将执行!"); + + Intent mainActivityIntent=new Intent(context, MainActivity.class); + mainActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(mainActivityIntent); + + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/ChangLiang.java b/app/src/main/java/com/fisherbone/fuzhu/ChangLiang.java new file mode 100644 index 0000000..ce972a1 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/ChangLiang.java @@ -0,0 +1,238 @@ +package com.fisherbone.fuzhu; + +public class ChangLiang +{ + public static String qidong="F"; + public static String qidongtwo="F"; + + + /** + * 一键取关的常量 + */ + public static boolean cancelclosed; //取消已关 + public static boolean cancelcrosscor; //取消互关 + public static String passnumber="2"; //取关数 + public static String swiinterval; //取关间隔 + public static String minthrthr; //最小开始取关数 + public static String minfans; //互关保留粉丝数 + public static int quguannum; //取关数 + public static String ishuodong="T"; + + + /** + * 推荐加关的常量 + */ + + public static String Runtime; //运行时长 + public static String Videotime; //视频观看时长 + public static String maxVideotime; //视频观看最大时长 + public static String Randomlikes; //随机点赞 + public static String Randomreview; //随机评论 + public static String Randomattention; //随机关注 + public static String Maximumofconcerns; //最大关注数 + + public static String Numberofcon; //加关关注数 + public static String Addfans; //加关粉丝数 + public static String Minimumofworks="0"; //最小作品数 + public static String Maximumprotime; //最大作品时间 + + public static String maxmumlikes="3500"; //最大加关关注数 + public static String maximumcon="20000" ; //最大粉丝数 + public static String maxmumzuopin="10000" ; //最大作品数 + + public static int tasknum=1; + public static int guanzhunum=0;//当前关注数 + public static String condition="0";//是否满足条件:0:满足 1:不满足 + public static String getMaximumprotime; //获得的最大作品时间 + + + /** + * 登录的手机号码 + */ + public static String phonenum="18133922183"; + /** + * 登录的手机验证码 + */ + public static String code="3856"; + + + /** + * 幢号加关注 + */ + public static String zishuodong="T"; + public static String account_duration=""; + public static String touch_num=""; + public static String if_quguan=""; + + + + + + + + /** + * 适配手机型号 + * 0是红米7a(Redmi 7A) 1是华为畅享20 2是红米10手机(M2103K19C) + */ + public static String phonetype="0"; + + + /** + * 浮窗运行状态(推荐加关) + */ + public static boolean isrun=true; + + /** + * 浮窗运行状态(一键取关) + */ + // public static boolean isrun_two=true; + /** + * 浮窗打开状态(推荐加关) + */ + public static boolean isopoen=true; + /** + * 浮窗打开状态(一键取关) + */ + public static boolean isopoen_two=true; + + + + + /** + * 当前执行任务抖音id + */ + public static String short_id=""; + /** + * 当前执行任务id + */ + public static String task_id=""; + /** + * 当前执行任务功能id + */ + public static String id=""; + //_____________________________________________ + /** + * 未处理完成的执行任务抖音id + */ + public static String short_id_f=""; + //_____________________________________________ + /** + * 未处理完成的执行任务id + */ + public static String task_id_f=""; + //_____________________________________________ + /** + * 未处理完成的执行任务功能id + */ + public static String id_f=""; + //_____________________________________________ + /** + * 未处理完成的紧急执行任务抖音id + */ + public static String short_id_jf=""; + //_____________________________________________ + /** + * 未处理完成的紧急执行任务id + */ + public static String task_id_jf=""; + //_____________________________________________ + /** + * 未处理完成的紧急执行任务功能id + */ + public static String id_jf=""; + + + //_____________________________________________ + + /** + * 当前执行任务抖音昵称 + */ + public static String short_name=""; + /** + * 执行任务的抖音昵称 + */ + public static String task_short_name=""; + + /** + * 当前执行任务类型 + */ + public static String task_type="";//1:代表账号登录 2:停任务 3:代表紧急任务,4:代表固定任务 + public static String func_type=""; + + /** + * 无障碍是否开启 + */ + public static String isopenAccessib="F"; + /** + * + *抖音版本号 + **/ + public static String douyinversion="2"; //1.代表13.10 13.20 2代表14.60版本 + + /** + * 1:云端 0:本地 + */ + public static String control_status=""; + + + /** + * 认领任务的常量( + */ + public static boolean istask = false; //当前是否有认领的任务 + public static String isstart = "0"; //0代表没有运行 1代表正在运行 + public static String isstarttwo = "0"; //0代表停任务没有运行 1代表停任务正在运行 + // public static int tasktype = 0; //当前认领的任务类型//success=-1:代表报错;success=0:代表暂无任务;success=1:代表账号登录;success=2:代表停止任务;success=3:代表紧急任务;success=4:代表固定任务) + public static String douyinzhaohao = ""; //当前认领的任务执行任务的抖音号 + + + + /** + * 粉丝互动的常量 + */ + public static String interaContent=""; //互动内容 + public static String interanum; //互动粉丝数 + + + /** + * 大V粉丝截流的常量 + */ + public static String dav_runningtime=""; //运行时长 + public static String dav_maxnumcon=""; //运行时长 + public static String dav_douyinhao="Ting998888"; //抖音号 + public static String dav_guanjianci=""; //关键词 + public static String dav_minimumlikes=""; //最小加关关注数 + public static String dav_minimumcon=""; //最小加关粉丝数 + public static String dav_minimumzuopin=""; //最小作品数 + public static String dav_maxmumzuopin=""; //最大作品数 + public static String dav_maxmumlikes=""; //最大加关关注数 + public static String dav_maximumcon=""; //最大粉丝数 + public static String dav_ishuadong="T";//大V粉丝滑动开关 + public static String dav_condition="0";//是否满足条件:0:满足 1:不满足 + + /** + * 潜在客户加关 + */ + public static String dav_douyinname="地产S姐";//大V都应名称 + public static String dav_douyinname_id="地产S姐";//大V都应名称 + public static String dav_keyword="二手房";//大V都应名称 + public static String dav_qianzai="T"; + + + + + //_______________________________________________________________________________________________ + /** + * 跟单的开关 + */ + public static int gendanopen=0;//0为关 1为开 + public static String genfaneirong="";//跟发内容 + public static String fudaineirong="";//强福带发送的内容 + + //_______________________________________________________________________________________________ + /** + * 粉丝通知 + */ + public static int bnumber=0;//发送私信的循环次数 + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/FZConfig.java b/app/src/main/java/com/fisherbone/fuzhu/FZConfig.java new file mode 100644 index 0000000..1845253 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/FZConfig.java @@ -0,0 +1,20 @@ +package com.fisherbone.fuzhu; + +/** + * FZ配置参数 + * Created by XiaoQiang on 2017/6/24. + */ +public class FZConfig { + + /** + * 设备id + */ + public static String KEY_DEVICE_ID = "device_id"; + + /** + * 设备是否已激活 + * 设备是否已激活 0是激活 1是未激活 + */ + public static String IS_ACTIVATION = "activation"; + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/FuzhuApplication.java b/app/src/main/java/com/fisherbone/fuzhu/FuzhuApplication.java new file mode 100644 index 0000000..a21cdc4 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/FuzhuApplication.java @@ -0,0 +1,165 @@ +package com.fisherbone.fuzhu; + +import android.app.Application; +import android.content.Context; + +import com.fisherbone.fuzhu.db.dao.DataBaseHelper; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.lzy.okgo.OkGo; +import com.lzy.okgo.cache.CacheEntity; +import com.lzy.okgo.cache.CacheMode; +import com.lzy.okgo.cookie.CookieJarImpl; +import com.lzy.okgo.cookie.store.DBCookieStore; +import com.lzy.okgo.https.HttpsUtils; +import com.lzy.okgo.interceptor.HttpLoggingInterceptor; +import com.lzy.okgo.model.HttpHeaders; +import com.lzy.okgo.model.HttpParams; +import com.tencent.bugly.crashreport.CrashReport; +import com.xiangxue.common.network.base.NetworkApi; + +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLSession; +import javax.net.ssl.X509TrustManager; + +import okhttp3.OkHttpClient; + + +/** + * Created by: xudiwei + *

+ * on: 2017/3/13. + *

+ * 描述:Base Application + * 123 + */ + +public class FuzhuApplication extends Application { + + private static Context mContext; + private static FuzhuApplication baseApplication; + public static FuzhuApplication getInstance() { + return baseApplication; + } + + public static Context getContext() { + return mContext; + } + + @Override + public void onCreate() { + super.onCreate(); + baseApplication = this; + mContext = this; + CrashReport.initCrashReport(getApplicationContext(), "e940e41c92", false); + //用户资料存储工具 + ProfileSpUtils.init(this); + DataBaseHelper.initOrmLite(this); + initOkGo(); + MyCrashHandler.getInstance().init(this); + NetworkApi.init(new XiangxueNetwork(this)); + + + + } + + private void initOkGo() { + //---------这里给出的是示例代码,告诉你可以这么传,实际使用的时候,根据需要传,不需要就不传-------------// + HttpHeaders headers = new HttpHeaders(); + headers.put("commonHeaderKey1", "commonHeaderValue1"); //header不支持中文,不允许有特殊字符 + headers.put("commonHeaderKey2", "commonHeaderValue2"); + HttpParams params = new HttpParams(); + params.put("commonParamsKey1", "commonParamsValue1"); //param支持中文,直接传,不要自己编码 + params.put("commonParamsKey2", "这里支持中文参数"); + //----------------------------------------------------------------------------------------// + + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + //log相关 + HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor("OkGo"); + loggingInterceptor.setPrintLevel(HttpLoggingInterceptor.Level.BODY); //log打印级别,决定了log显示的详细程度 + loggingInterceptor.setColorLevel(Level.INFO); //log颜色级别,决定了log在控制台显示的颜色 + builder.addInterceptor(loggingInterceptor); //添加OkGo默认debug日志 + //第三方的开源库,使用通知显示当前请求的log,不过在做文件下载的时候,这个库好像有问题,对文件判断不准确 + //builder.addInterceptor(new ChuckInterceptor(this)); + + //超时时间设置,默认60秒 + builder.readTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS); //全局的读取超时时间 + builder.writeTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS); //全局的写入超时时间 + builder.connectTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS); //全局的连接超时时间 + + //自动管理cookie(或者叫session的保持),以下几种任选其一就行 + //builder.cookieJar(new CookieJarImpl(new SPCookieStore(this))); //使用sp保持cookie,如果cookie不过期,则一直有效 + builder.cookieJar(new CookieJarImpl(new DBCookieStore(this))); //使用数据库保持cookie,如果cookie不过期,则一直有效 + //builder.cookieJar(new CookieJarImpl(new MemoryCookieStore())); //使用内存保持cookie,app退出后,cookie消失 + + //https相关设置,以下几种方案根据需要自己设置 + //方法一:信任所有证书,不安全有风险 + HttpsUtils.SSLParams sslParams1 = HttpsUtils.getSslSocketFactory(); + //方法二:自定义信任规则,校验服务端证书 + HttpsUtils.SSLParams sslParams2 = HttpsUtils.getSslSocketFactory(new SafeTrustManager()); + //方法三:使用预埋证书,校验服务端证书(自签名证书) + //HttpsUtils.SSLParams sslParams3 = HttpsUtils.getSslSocketFactory(getAssets().open("srca.cer")); + //方法四:使用bks证书和密码管理客户端证书(双向认证),使用预埋证书,校验服务端证书(自签名证书) + //HttpsUtils.SSLParams sslParams4 = HttpsUtils.getSslSocketFactory(getAssets().open("xxx.bks"), "123456", getAssets().open("yyy.cer")); + builder.sslSocketFactory(sslParams1.sSLSocketFactory, sslParams1.trustManager); + //配置https的域名匹配规则,详细看demo的初始化介绍,不需要就不要加入,使用不当会导致https握手失败 + builder.hostnameVerifier(new SafeHostnameVerifier()); + + // 其他统一的配置 + // 详细说明看GitHub文档:https://github.com/jeasonlzy/ + OkGo.getInstance().init(this) //必须调用初始化 + .setOkHttpClient(builder.build()) //建议设置OkHttpClient,不设置会使用默认的 + .setCacheMode(CacheMode.NO_CACHE) //全局统一缓存模式,默认不使用缓存,可以不传 + .setCacheTime(CacheEntity.CACHE_NEVER_EXPIRE) //全局统一缓存时间,默认永不过期,可以不传 + .setRetryCount(3); //全局统一超时重连次数,默认为三次,那么最差的情况会请求4次(一次原始请求,三次重连请求),不需要可以设置为0 +// .addCommonHeaders(headers) //全局公共头 +// .addCommonParams(params); //全局公共参数 + } + + /** + * 这里只是我谁便写的认证规则,具体每个业务是否需要验证,以及验证规则是什么,请与服务端或者leader确定 + * 这里只是我谁便写的认证规则,具体每个业务是否需要验证,以及验证规则是什么,请与服务端或者leader确定 + * 这里只是我谁便写的认证规则,具体每个业务是否需要验证,以及验证规则是什么,请与服务端或者leader确定 + * 重要的事情说三遍,以下代码不要直接使用 + */ + private class SafeTrustManager implements X509TrustManager { + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { + try { + for (X509Certificate certificate : chain) { + certificate.checkValidity(); //检查证书是否过期,签名是否通过等 + } + } catch (Exception e) { + throw new CertificateException(e); + } + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + } + + /** + * 这里只是我谁便写的认证规则,具体每个业务是否需要验证,以及验证规则是什么,请与服务端或者leader确定 + * 这里只是我谁便写的认证规则,具体每个业务是否需要验证,以及验证规则是什么,请与服务端或者leader确定 + * 这里只是我谁便写的认证规则,具体每个业务是否需要验证,以及验证规则是什么,请与服务端或者leader确定 + * 重要的事情说三遍,以下代码不要直接使用 + */ + private class SafeHostnameVerifier implements HostnameVerifier { + @Override + public boolean verify(String hostname, SSLSession session) { + //验证主机名是否匹配 + //return hostname.equals("server.jeasonlzy.com"); + return true; + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/InfoMessage.java b/app/src/main/java/com/fisherbone/fuzhu/InfoMessage.java new file mode 100644 index 0000000..6615f1c --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/InfoMessage.java @@ -0,0 +1,25 @@ +package com.fisherbone.fuzhu; + +public interface InfoMessage { + void mesagesuccess(String str); + + void mesagezhuang(String str); + + /** + * 登录 + * @param str + */ + void mesagefinish(String str); + + /** + * 潜在客户加关 + * @param str + */ + void potfinish(String id, String str, String type); + + /** + * 粉丝通知 + * @param str + */ + void potgegin(String str); +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/LiveActivity.java b/app/src/main/java/com/fisherbone/fuzhu/LiveActivity.java new file mode 100644 index 0000000..ca81ab1 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/LiveActivity.java @@ -0,0 +1,67 @@ +package com.fisherbone.fuzhu; + +import android.os.Bundle; +import android.view.View; + +import androidx.databinding.DataBindingUtil; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; + +import com.fisherbone.fuzhu.abllib.utils.AblUtil; +import com.fisherbone.fuzhu.databinding.ActivityLiveBinding; +import com.fisherbone.fuzhu.entity.FourEvent; +import com.fisherbone.fuzhu.entity.LiveBean; +import com.fisherbone.fuzhu.fragment.LiwuFragment; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.fisherbone.fuzhu.widget.TitleBar; + +import de.greenrobot.event.EventBus; + + +public class LiveActivity extends BaseActivity{ + private TitleBar mTitleBar; + private ActivityLiveBinding binding; + private LiveBean liveBean1; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + binding = DataBindingUtil.setContentView(this, R.layout.activity_live); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("指定直播间加热"); + initNormalBack(); + liveBean1 = ProfileSpUtils.getInstance().getLiveBean(); + binding.setLivebean(liveBean1); + //创建fragment管理类 + FragmentManager fm = getSupportFragmentManager(); + //查找当前容器中是否有fragment + Fragment fragment = fm.findFragmentById(R.id.news_content_fragment); + if (fragment == null) { + //如果没有,创建fragment + fragment = new LiwuFragment(liveBean1); + Bundle bundle = new Bundle(); + bundle.putString("visitor_id", ""); + fragment.setArguments(bundle); + //添加fragment到activity中 + fm.beginTransaction().add(R.id.news_content_fragment, fragment).commit(); + } + binding.rlStart.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ProfileSpUtils.getInstance().saveLiveBean(liveBean1); + if("0".equals(ChangLiang.phonetype)) { + EventBus.getDefault().post(new FourEvent("success", "6")); + }else if("3".equals(ChangLiang.phonetype)) { + EventBus.getDefault().post(new FourEvent("success", "6")); + } + else { + if (AblUtil.isAccessibilityServiceOpen(LiveActivity.this)) { + AblUtil.openAccessibilitySettings(); + } else { + AblUtil.openAccessibilitySettings(); + } + } + } + }); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/LiveSuiJiActivity.java b/app/src/main/java/com/fisherbone/fuzhu/LiveSuiJiActivity.java new file mode 100644 index 0000000..bef4347 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/LiveSuiJiActivity.java @@ -0,0 +1,38 @@ +package com.fisherbone.fuzhu; + +import android.os.Bundle; +import android.view.View; + +import androidx.databinding.DataBindingUtil; + +import com.fisherbone.fuzhu.databinding.ActivityLiveSuiJiBinding; +import com.fisherbone.fuzhu.entity.FourEvent; +import com.fisherbone.fuzhu.entity.LiveSuiJiBean; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.fisherbone.fuzhu.widget.TitleBar; + +import de.greenrobot.event.EventBus; + +public class LiveSuiJiActivity extends BaseActivity { + private TitleBar mTitleBar; + private ActivityLiveSuiJiBinding binding; + private LiveSuiJiBean liveSuiJiBean; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + binding = DataBindingUtil.setContentView(this, R.layout.activity_live_sui_ji); + liveSuiJiBean = ProfileSpUtils.getInstance().getLiveSuiJiBean(); + binding.setLivesuijibean(liveSuiJiBean); + binding.setPresenter(new Presenter()); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("随机直播间抢福袋"); + initNormalBack(); + } + public class Presenter { + public void onClick(View view){ + ProfileSpUtils.getInstance().saveLiveSuiJiBean(liveSuiJiBean); + EventBus.getDefault().post(new FourEvent("success","7")); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/Main2Activity.java b/app/src/main/java/com/fisherbone/fuzhu/Main2Activity.java new file mode 100644 index 0000000..26cb8c8 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/Main2Activity.java @@ -0,0 +1,18 @@ +package com.fisherbone.fuzhu; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; + +import com.xiangxue.arouter_annotation.ARouter; +import com.fisherbone.fuzhu.R; + +@ARouter(path = "/app/Main2Activity") +public class Main2Activity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main2); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/MainActivityy.java b/app/src/main/java/com/fisherbone/fuzhu/MainActivityy.java new file mode 100644 index 0000000..0b1b794 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/MainActivityy.java @@ -0,0 +1,102 @@ +package com.fisherbone.fuzhu; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.ImageView; + +import com.xiangxue.arouter_annotation.ARouter; +import com.xiangxue.arouter_annotation.Parameter; +import com.xiangxue.arouter_api.ParameterManager; +import com.xiangxue.arouter_api.RouterManager; +import com.xiangxue.common.bean.Student; +import com.xiangxue.common.order.OrderDrawable; +import com.xiangxue.common.order.user.IUser; +import com.xiangxue.common.utils.Cons; + +@ARouter(path = "/app/MainActivityy") +public class MainActivityy extends AppCompatActivity { + + @Parameter(name = "/order/getDrawable") + OrderDrawable orderDrawable; // 公共基础库common + + @Parameter(name = "/order/getUserInfo") + IUser iUser; // 公共基础库common + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main1); + + if (BuildConfig.isRelease) { + Log.e(Cons.TAG, "当前为:集成化模式,除app可运行,其他子模块都是Android Library"); + } else { + Log.e(Cons.TAG, "当前为:组件化模式,app/order/personal子模块都可独立运行"); + } + + // 懒加载方式,跳到哪加载哪个类 + ParameterManager.getInstance().loadParameter(this); + + // app模块本来就可以直接加载其他模块的资源 personal + // 拿到 order模块的图片 在app模块展示 + int drawableId = orderDrawable.getDrawable(); + ImageView img = findViewById(R.id.img); + img.setImageResource(drawableId); + + // 我输出 order模块的Bean休息 + Log.d(Cons.TAG, "order的Bean onCreate: " + iUser.getUserInfo().toString()); + } + + public void jumpOrder(View view) { + /*Intent intent = new Intent(this, Order_MainActivity.class); + intent.putExtra("name", "derry"); + startActivity(intent);*/ + + // 使用我们自己写的路由 跳转交互 + RouterManager.getInstance() + .build("/order/Order_MainActivity") + .withString("name", "杜子腾") + .navigation(this); // 组件和组件通信 + } + + public void jumpPersonal(View view) { + // 以前是这样跳转 + /*Intent intent = new Intent(this, Personal_MainActivity.class); + intent.putExtra("name", "derry"); + startActivity(intent);*/ + + // 现在是这样跳转 目前还要写这么多代码,是不是非常累 + + // TODO 最终的成效:用户 一行代码搞定,同时还可以传递参数,同时还可以懒加载 + /*ARouter$$Group$$personal group$$personal = new ARouter$$Group$$personal(); + Map> groupMap = group$$personal.getGroupMap(); + Class myClass = groupMap.get("personal"); + + try { + ARouter$$Path$$personal path = (ARouter$$Path$$personal) myClass.newInstance(); + Map pathMap = path.getPathMap(); + RouterBean bean = pathMap.get("/personal/Personal_MainActivity"); + + if (bean != null) { + Intent intent = new Intent(this, bean.getMyClass()); + startActivity(intent); + } + + } catch (Exception e) { + e.printStackTrace(); + }*/ + + Student student = new Student("Derry大大", "男", 99); + + // 使用我们自己写的路由 跳转交互 + RouterManager.getInstance() + .build("/personal/Personal_MainActivity") + .withString("name", "史甄湘") + .withString("sex", "男") + .withInt("age", 99) + .withSerializable("student", student) + .navigation(this); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/MyCrashHandler.java b/app/src/main/java/com/fisherbone/fuzhu/MyCrashHandler.java new file mode 100644 index 0000000..7b7e517 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/MyCrashHandler.java @@ -0,0 +1,63 @@ +package com.fisherbone.fuzhu; + +import android.content.Context; +import android.util.Log; + +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; + +class MyCrashHandler implements Thread.UncaughtExceptionHandler { + @Override + public void uncaughtException(Thread t, Throwable e) { + againStart(); + Log.e("TIAOSHI###", "闪退了"); +// Intent intent = new Intent(mContext, MainActivity.class); +// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); +// mContext.startActivity(intent); + System.exit(0);// 关闭已奔溃的app进程 + + } + + public static MyCrashHandler getInstance() { + return INSTANCE; + } + // CrashHandler实例 + private static MyCrashHandler INSTANCE = new MyCrashHandler(); + // 程序的Context对象 + private Context mContext; + + /** + * 初始化 + * + * @param context + */ + public void init(Context context) { + mContext = context; + // 获取系统默认的UncaughtException处理 + // mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler(); + // 设置该CrashHandler为程序的默认处理 + Thread.setDefaultUncaughtExceptionHandler(this); + } + + private void againStart() { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("task_status", "0"); + paramsPost.put("task_id", ChangLiang.task_id); + paramsPost.put("task_type", ChangLiang.task_type); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appscanlogin_againStart).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + Log.e("需通知后台重新启动", body); + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + + } + }); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/MyFileProvider.java b/app/src/main/java/com/fisherbone/fuzhu/MyFileProvider.java new file mode 100644 index 0000000..a0343ef --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/MyFileProvider.java @@ -0,0 +1,6 @@ +package com.fisherbone.fuzhu; + +import androidx.core.content.FileProvider; + +public class MyFileProvider extends FileProvider { +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/MyProvider.java b/app/src/main/java/com/fisherbone/fuzhu/MyProvider.java new file mode 100644 index 0000000..81e6722 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/MyProvider.java @@ -0,0 +1,11 @@ +package com.fisherbone.fuzhu; + +import androidx.core.content.FileProvider; + +/** + * Time: 2020/6/1 + * Author: jianbo + * Description: + */ +public class MyProvider extends FileProvider { +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/Neirong.java b/app/src/main/java/com/fisherbone/fuzhu/Neirong.java new file mode 100644 index 0000000..426fbc3 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/Neirong.java @@ -0,0 +1,6 @@ +package com.fisherbone.fuzhu; + +public class Neirong { + public static String neirong=""; + public static boolean hasNeirong=false; +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/PhoneActivity.java b/app/src/main/java/com/fisherbone/fuzhu/PhoneActivity.java new file mode 100644 index 0000000..8d2f6be --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/PhoneActivity.java @@ -0,0 +1,625 @@ +package com.fisherbone.fuzhu; + +import android.content.ContentProviderOperation; +import android.content.ContentResolver; +import android.content.ContentUris; +import android.content.ContentValues; +import android.content.Intent; +import android.content.OperationApplicationException; +import android.database.Cursor; +import android.net.Uri; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.os.RemoteException; +import android.provider.ContactsContract; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.RadioButton; +import android.widget.RadioGroup; +import android.widget.RelativeLayout; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.recyclerview.widget.RecyclerView; + +import com.fisherbone.fuzhu.config.Callback; +import com.fisherbone.fuzhu.utils.MyToast; +import com.fisherbone.fuzhu.utils.PrefUtils; +import com.fisherbone.fuzhu.views.ConfirmDialog; +import com.fisherbone.fuzhu.views.LoadingDialog; + +import java.util.ArrayList; +import java.util.List; + +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; + +/** + * Created by Eren on 2017/6/23. + *

+ * 通讯录 + */ +public class PhoneActivity extends BaseActivity implements RadioGroup.OnCheckedChangeListener { + @BindView(R.id.iv_back) + ImageView mIvBack; + @BindView(R.id.tv_content_city) + TextView mTvContentCity; + @BindView(R.id.rl_city) + RelativeLayout mRlCity; + @BindView(R.id.rv_phone) + RecyclerView mRvPhone; + @BindView(R.id.but_begin) + Button mButBegin; + @BindView(R.id.clean_phone) + RelativeLayout mCleanPhone; + @BindView(R.id.open_phone) + RelativeLayout mOpenPhone; + @BindView(R.id.import_phone) + RelativeLayout mImportPhone; + @BindView(R.id.smash_phone) + RelativeLayout mSmashPhone; + @BindView(R.id.mobile) + RadioButton mMobile; + @BindView(R.id.telecom) + RadioButton mTelecom; + @BindView(R.id.unicom) + RadioButton mUnicom; + @BindView(R.id.rg_opera) + RadioGroup mRgOpera; + // private MyApplication mApp; + /** + * 自定义对话框 + */ + private ConfirmDialog mConfirmDialog; + /** + * 跳转返回时的flag + */ + private static final int REQUEST_CODE_PICK_CITY = 0; + /** + * 选中的城市 + */ + private String city; + /** + * 获取所有符合号段集合 + */ + // private List mCityPhoneList; + + private List phoneNumber = new ArrayList<>(); + // private PhoneRvAdapter mRvAdapter; + + private LoadingDialog mLoadingDialog; + + /** + * 导入通讯录 + */ + public static final int IMPORT_PHONE = 0; + /** + * 导入完成 + */ + public static final int IMPORT_PHONE_OVER = 1; + /** + * 清空号码段 + */ + public static final int CLEAN_PHONE = 2; + /** + * 清空通讯录 + */ + public static final int CLEAN_PHONE_BOOK = 3; + /** + * 通讯录清空完成 + */ + public static final int CLEAN_PHONE_OVER = 4; + + + private Handler myHandler = new Handler() { + @Override + public void handleMessage(Message msg) { + super.handleMessage(msg); + switch (msg.what) { + case IMPORT_PHONE: + //加载进度 + mLoadingDialog = new LoadingDialog(PhoneActivity.this); + mLoadingDialog.setContent("正在导入通讯录..."); + mLoadingDialog.setCancelable(false); + mLoadingDialog.show(); + break; + + case IMPORT_PHONE_OVER: + mLoadingDialog.dismiss(); + + MyToast.show(PhoneActivity.this, "导入成功"); + break; + + case CLEAN_PHONE: + MyToast.show(PhoneActivity.this, "清空成功"); + + break; + + case CLEAN_PHONE_BOOK: + //清空通讯录 + mLoadingDialog = new LoadingDialog(PhoneActivity.this); + mLoadingDialog.setContent("正在清空通讯录..."); + mLoadingDialog.setCancelable(false); + mLoadingDialog.show(); + break; + + case CLEAN_PHONE_OVER: + mLoadingDialog.dismiss(); + MyToast.show(PhoneActivity.this, "清空成功"); + break; + default: + } + } + }; + // private CityNumberBean.AutoCityBean mCityNumberBean = new CityNumberBean.AutoCityBean(); + + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_phone); + ButterKnife.bind(this); +// mApp = (MyApplication) getApplication(); +// initRg(); +// initRv(); + + + findViewById(R.id.clean_phone).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + phoneNumber.add("18133922189"); + phoneNumber.add("18133922190"); + phoneNumber.add("18133922191"); + phoneNumber.add("18133922192"); + phoneNumber.add("18133922193"); + phoneNumber.add("18133922194"); + + if (phoneNumber.size() == 0) { + MyToast.show(PhoneActivity.this, "号码不能为空"); + } else { + mConfirmDialog = new ConfirmDialog(PhoneActivity.this, new Callback() { + @Override + public void Positive() { + new Thread( new Runnable() { + @Override + public void run() { + myHandler.sendEmptyMessage(IMPORT_PHONE); + try { + testAddContactsInTransaction(); + // writeContact(); + // addContacts("ddd","18133988585"); + } catch (Exception e) { + e.printStackTrace(); + } + myHandler.sendEmptyMessage(IMPORT_PHONE_OVER); + } + }).start(); + } + @Override + public void Negative() { + mConfirmDialog.dismiss(); + } + }); + mConfirmDialog.setContent("提示:" + "\n是否导入通讯录"); + mConfirmDialog.setCancelable(true); + mConfirmDialog.show(); + } + } + }); + } + + /** + * 初始化运营商 + */ +// private void initRg() { +// if (mApp.mCityNumberList.size() > 0 && mApp.mCityNumberList != null) { //如果网络获取成功 +// mCityNumberBean = mApp.mCityNumberList.get(0); +// //从网络里获取城市 +// city = mCityNumberBean.getCity(); +// mTvContentCity.setText(city); +// +// PrefUtils.putString(PhoneActivity.this, "phone_area", city); +// +// //从网络里获取运营商 +// String operator = mCityNumberBean.getOperator(); +// Log.i("123", operator); +// PrefUtils.putString(PhoneActivity.this, "phone_opera", operator); //如果网络获取成功,设置成网络运营商 +// } else { +// PrefUtils.putString(PhoneActivity.this, "phone_opera", "移动"); //如果网络获取失败,第一次默认是移动,不设置会出现空白状态 +// PrefUtils.putString(PhoneActivity.this, "phone_area", "无锡"); +// city = "无锡"; +// mTvContentCity.setText("无锡"); +// Log.i("123", "AAAA"); +// } +// //从网络获取的运营商选中状态 +// switch (PrefUtils.getString(PhoneActivity.this, "phone_opera", "移动")) { +// case "移动": +// mMobile.setChecked(true); +// break; +// +// case "电信": +// mTelecom.setChecked(true); +// break; +// +// case "联通": +// mUnicom.setChecked(true); +// break; +// } +// mRgOpera.setOnCheckedChangeListener(this); +// } + + /** + * 初始化RecyclerView + */ +// private void initRv() { +// mRvPhone.setLayoutManager(new GridLayoutManager(this, 2)); +// mRvAdapter = new PhoneRvAdapter(PhoneActivity.this, phoneNumber); +// mRvPhone.setAdapter(mRvAdapter); +// mRvPhone.addItemDecoration(new SpaceItemDecoration(10)); +// +// } + + @OnClick({R.id.iv_back, R.id.rl_city, R.id.but_begin, R.id.clean_phone, R.id.open_phone, R.id.import_phone, R.id.smash_phone}) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.iv_back: //返回按钮 + // outAnimation(); + break; + case R.id.rl_city: //选择城市 +// startActivityForResult(new Intent(PhoneActivity.this, CityPickerActivity.class), REQUEST_CODE_PICK_CITY); +// overridePendingTransition(R.anim.anim_in, R.anim.anim_out); + break; + case R.id.but_begin: //生成号码段 +// phoneNumber.clear(); +// if (city == null) { // 判断有没有选择城市 +// MyToast.show(PhoneActivity.this, "未选择城市"); +// } else { +// mRvPhone.setVisibility(View.VISIBLE); +// CityPhoneDao cityPhoneDao = new CityPhoneDao(PhoneActivity.this); +// mCityPhoneList = cityPhoneDao.findAll(); +// // 循环加入集合,后四位随机生成 +// for (int i = 0; i < mCityPhoneList.size(); i++) { +// for (int j = 0; j < 5; j++) { +// String phoneNum = mCityPhoneList.get(i).getName() + (int) (Math.random() * 9000 + 1000); +// phoneNumber.add(phoneNum); +// } +// } +// //刷新适配器 +// mRvAdapter = new PhoneRvAdapter(PhoneActivity.this, phoneNumber); +// mRvPhone.setAdapter(mRvAdapter); +// } + break; + + case R.id.clean_phone: //导入通讯录 + phoneNumber.add("18133922190"); + phoneNumber.add("18133922188"); + + if (phoneNumber.size() == 0) { + MyToast.show(PhoneActivity.this, "号码不能为空"); + } else { + mConfirmDialog = new ConfirmDialog(PhoneActivity.this, new Callback() { + @Override + public void Positive() { + new Thread( new Runnable() { + @Override + public void run() { + myHandler.sendEmptyMessage(IMPORT_PHONE); + try { + testAddContactsInTransaction(); + } catch (Exception e) { + e.printStackTrace(); + } + myHandler.sendEmptyMessage(IMPORT_PHONE_OVER); + } + }).start(); + } + @Override + public void Negative() { + mConfirmDialog.dismiss(); + } + }); + mConfirmDialog.setContent("提示:" + "\n是否导入通讯录"); + mConfirmDialog.setCancelable(true); + mConfirmDialog.show(); + } + break; + + case R.id.open_phone: // 打开联系人界面 + + Intent intent = new Intent(); + intent.setClassName("com.android.contacts", "com.android.contacts.activities.PeopleActivity"); + startActivity(intent); + break; + case R.id.import_phone: //清空号码段 + if (phoneNumber.size() == 0) { + MyToast.show(PhoneActivity.this, "号码为空"); + } else { + mConfirmDialog = new ConfirmDialog(PhoneActivity.this, new Callback() { + @Override + public void Positive() { + phoneNumber.clear(); + mRvPhone.setVisibility(View.GONE); + myHandler.sendEmptyMessage(CLEAN_PHONE); + } + @Override + public void Negative() { + mConfirmDialog.dismiss(); + } + }); + mConfirmDialog.setContent("提示:" + "\n是否清空电话号码"); + mConfirmDialog.setCancelable(true); + mConfirmDialog.show(); + } + break; + case R.id.smash_phone: //清空通讯录 + mConfirmDialog = new ConfirmDialog(PhoneActivity.this, new Callback() { + @Override + public void Positive() { + new Thread(new Runnable() { + @Override + public void run() { + myHandler.sendEmptyMessage(CLEAN_PHONE_BOOK); + clearContent(); +// cleanphone(); + myHandler.sendEmptyMessage(CLEAN_PHONE_OVER); + } + }).start(); + } + + @Override + public void Negative() { + mConfirmDialog.dismiss(); + } + }); + mConfirmDialog.setContent("提示:" + "\n是否清空通讯录"); + mConfirmDialog.setCancelable(true); + mConfirmDialog.show(); + break; + default: + } + + } + +// @Override +// protected void onActivityResult(int requestCode, int resultCode, Intent data) { +// if (requestCode == REQUEST_CODE_PICK_CITY && resultCode == RESULT_OK) { +// if (data != null) { +// city = data.getStringExtra(CityPickerActivity.KEY_PICKED_CITY); +// mTvContentCity.setText(city); +// PrefUtils.putString(PhoneActivity.this, "phone_area", city); +// } +// } +// } +// + @Override + public void onCheckedChanged(RadioGroup group, int checkedId) { + switch (checkedId) { + case R.id.mobile: + PrefUtils.putString(PhoneActivity.this, "phone_opera", "移动"); + break; + + case R.id.telecom: + PrefUtils.putString(PhoneActivity.this, "phone_opera", "电信"); + break; + + case R.id.unicom: + PrefUtils.putString(PhoneActivity.this, "phone_opera", "联通"); + break; + default: + } + } + + + /** + * 清空系统通信录数据 + */ + public void clearContent() { + ContentResolver cr = PhoneActivity.this.getContentResolver();// 获取 + // ContentResolver对象查询在ContentProvider里定义的共享对象 + // 根据URI对象ContactsContract.Contacts.CONTENT_URI查询所有联系人 + Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); + try { + // 如果记录不为空 + if (cursor != null) { + // 游标初始指向查询结果的第一条记录的上方,执行moveToNext函数会判断 + // 下一条记录是否存在,如果存在,指向下一条记录。否则,返回false。 + // 循环 + while (cursor.moveToNext()) { + String name = cursor + .getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); + // 根据姓名求id + Uri uri = Uri.parse("content://com.android.contacts/raw_contacts"); + + Cursor cursor1 = cr.query(uri, new String[]{ContactsContract.Data._ID}, "display_name=?", new String[]{name}, + null); + // 除去姓名对应的号码 + if (cursor1.moveToFirst()) { + int id = cursor1.getInt(0); + cr.delete(uri, "display_name=?", new String[]{name}); + // 根据id删除data中的相应数据 + uri = Uri.parse("content://com.android.contacts/data"); + cr.delete(uri, "raw_contact_id=?", new String[]{id + ""}); + } + cursor1.close();// Cursor循环内再申请Cursor,记得将内部申请的每个Cursor都加上close + } + cursor.close(); + + } else { + Toast.makeText(PhoneActivity.this, "通讯录为空", Toast.LENGTH_SHORT).show(); + } + } catch (Exception e) { + // TODO: handle exception + } + } + +// private void cleanphone(){ +// ContentResolver cr = PhoneActivity.this.getContentResolver();// 获取 +// Cursor contactsCur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); +// while(contactsCur.moveToNext()){ +// //获取ID +// String rawId = contactsCur.getString(contactsCur.getColumnIndex(ContactsContract.Contacts._ID)); +// //删除 +// String where = ContactsContract.Data._ID + " =?"; +// String[] whereparams = new String[]{rawId}; +// getContentResolver().delete(ContactsContract.RawContacts.CONTENT_URI, where, whereparams); +// } +// } + + + /** + * 批量添加联系人到通讯录中 + * + * @throws Exception + */ + public void testAddContactsInTransaction() throws Exception { + ArrayList mOperations = new ArrayList<>(); + ContentResolver resolver = PhoneActivity.this.getContentResolver(); + int rawContactInsertIndex; + // 循环添加 + for (int i = 0; i < phoneNumber.size(); i++) { + Uri uri = Uri.parse("content://com.android.contacts/raw_contacts"); + rawContactInsertIndex = mOperations.size();// 这句好很重要,有了它才能给真正的实现批量添加。 + // 向raw_contact表添加一条记录 + // 此处.withValue("account_name", null)一定要加,不然会抛NullPointerException + ContentProviderOperation operation1 = ContentProviderOperation.newInsert(uri) + .withValue("account_name", null).build(); + mOperations.add(operation1); + // 向data添加数据 + uri = Uri.parse("content://com.android.contacts/data"); + // 添加姓名 + ContentProviderOperation operation2 = ContentProviderOperation.newInsert(uri) + .withValueBackReference("raw_contact_id", rawContactInsertIndex) + // withValueBackReference的第二个参数表示引用operations[0]的操作的返回id作为此值 + .withValue("mimetype", "vnd.android.cursor.item/name").withValue("data2", phoneNumber.get(i)) + .withYieldAllowed(true).build(); + mOperations.add(operation2); + // 添加手机数据 + ContentProviderOperation operation3 = ContentProviderOperation.newInsert(uri) + .withValueBackReference("raw_contact_id", rawContactInsertIndex) + .withValue("mimetype", "vnd.android.cursor.item/phone_v2").withValue("data2", "2") + .withValue("data1", phoneNumber.get(i)).withYieldAllowed(true).build(); + mOperations.add(operation3); + + } + try { + // 这里才调用的批量添加 + resolver.applyBatch("com.android.contacts", mOperations); + + } catch (RemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (OperationApplicationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + protected void onDestroy() { + super.onDestroy(); + myHandler.removeCallbacksAndMessages(null); + } + + + + /** + * 导入到通讯录 + */ + public void addContacts(String name , String tel){ + name = name+"@客户管理"; + //插入raw_contacts表,并获取_id属性 + Uri uri = Uri.parse("content://com.android.contacts/raw_contacts"); + ContentResolver resolver = getContentResolver(); + ContentValues values = new ContentValues(); + long contact_id = ContentUris.parseId(resolver.insert(uri, values)); + //插入data表 + uri = Uri.parse("content://com.android.contacts/data"); + //add Name + values.put("raw_contact_id", contact_id); + values.put(ContactsContract.Data.MIMETYPE,"vnd.android.cursor.item/name"); + values.put("data2", name); + values.put("data1", name); + resolver.insert(uri, values); + values.clear(); + //add Phone + values.put("raw_contact_id", contact_id); + values.put(ContactsContract.Data.MIMETYPE,"vnd.android.cursor.item/phone_v2"); + values.put("data2", "2"); //手机 + values.put("data1", tel); + resolver.insert(uri, values); + values.clear(); + /*//add email + values.put("raw_contact_id", contact_id); + values.put(ContactsContract.Data.MIMETYPE,"vnd.android.cursor.item/email_v2"); + values.put("data2", "2"); //单位 + values.put("data1", "xzdong@xzdong.com"); + resolver.insert(uri, values);*/ + } + + + /** + * 写入手机联系人 + */ + private void writeContact() { + String name = "test"; + String number = "13666668888"; + + //先查询要添加的号码是否已存在通讯录中, 不存在则添加. 存在则提示用户 + Uri uri = Uri.parse("content://com.android.contacts/data/phones/filter/" + number); + ContentResolver resolver = getContentResolver(); + //从raw_contact表中返回display_name + Cursor cursor = resolver.query(uri, new String[]{ContactsContract.Data.DISPLAY_NAME}, null, null, null); + if (cursor == null) + return; + + if (cursor.moveToFirst()) { + Log.i("nn", "name=" + cursor.getString(0)); + Toast.makeText(this, "存在相同号码", Toast.LENGTH_SHORT).show(); + } else { + uri = Uri.parse("content://com.android.contacts/raw_contacts"); + ContentValues values = new ContentValues(); + long contact_id = ContentUris.parseId(resolver.insert(uri, values)); + //插入data表 + uri = Uri.parse("content://com.android.contacts/data"); + //add Name + values.put("raw_contact_id", contact_id); + values.put(ContactsContract.Data.MIMETYPE, "vnd.android.cursor.item/name"); + values.put("data2", "qq"); + values.put("data1", name); + resolver.insert(uri, values); + values.clear(); + + //add Phone + values.put("raw_contact_id", contact_id); + values.put(ContactsContract.Data.MIMETYPE, "vnd.android.cursor.item/phone_v2"); + values.put("data2", "2"); //手机 + values.put("data1", number); + resolver.insert(uri, values); + values.clear(); + + //add email + values.put("raw_contact_id", contact_id); + values.put(ContactsContract.Data.MIMETYPE, "vnd.android.cursor.item/email_v2"); + values.put("data2", "1"); //邮箱 + values.put("data1", "xxxx@qq.com"); + resolver.insert(uri, values); + values.clear(); + + //add organization + values.put("raw_contact_id", contact_id); + values.put(ContactsContract.Data.MIMETYPE, "vnd.android.cursor.item/organization"); + values.put("data4", "产品经理"); //职务 + values.put("data1", "腾讯科技"); //公司 + resolver.insert(uri, values); + values.clear(); + + Toast.makeText(this, "插入号码成功", Toast.LENGTH_SHORT).show(); + } + cursor.close(); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/RandumInt.java b/app/src/main/java/com/fisherbone/fuzhu/RandumInt.java new file mode 100644 index 0000000..d22de08 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/RandumInt.java @@ -0,0 +1,20 @@ +package com.fisherbone.fuzhu; + +import java.util.Random; + +/*产生一个1~4之间的随机数*/ +public class RandumInt { + public static int getRandumInt4(){ + return new Random().nextInt(4)+1; + } + public static int getRandumInt3(){ + return new Random().nextInt(3)+1; + } + public static int getRandumInt2(){ + return new Random().nextInt(2)+1; + } + public static int getRandumInt10to20(){ + return new Random().nextInt(15)+1; + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/TaskChangLiang.java b/app/src/main/java/com/fisherbone/fuzhu/TaskChangLiang.java new file mode 100644 index 0000000..e1ee5f7 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/TaskChangLiang.java @@ -0,0 +1,8 @@ +package com.fisherbone.fuzhu; + +public class TaskChangLiang { + + + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/TestTwoService.java b/app/src/main/java/com/fisherbone/fuzhu/TestTwoService.java new file mode 100644 index 0000000..3acd3cf --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/TestTwoService.java @@ -0,0 +1,58 @@ +package com.fisherbone.fuzhu; + +import android.app.Service; +import android.content.Intent; +import android.os.Binder; +import android.os.IBinder; +import android.util.Log; +import android.widget.Toast; + +import androidx.annotation.Nullable; + +/** + * Created by Kathy on 17-2-6. + */ + +public class TestTwoService extends Service { + protected final String TAG = this.getClass().getSimpleName(); + //client 可以通过Binder获取Service实例 + public class MyBinder extends Binder { + public TestTwoService getService() { + return TestTwoService.this; + } + } + //通过binder实现调用者client与Service之间的通信 + private MyBinder binder = new MyBinder(); + + @Override + public void onCreate() { + Log.i("Kathy","TestTwoService - onCreate - Thread = " + Thread.currentThread().getName()); + super.onCreate(); + } + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + Log.i("Kathy", "TestTwoService - onStartCommand - startId = " + startId + ", Thread = " + Thread.currentThread().getName()); + return START_NOT_STICKY; + } + + @Nullable + @Override + public IBinder onBind(Intent intent) { + Log.i("Kathy", "TestTwoService - onBind - Thread = " + Thread.currentThread().getName()); + Toast.makeText(this, "服务已经启动", Toast.LENGTH_LONG).show(); + return binder; + } + + @Override + public boolean onUnbind(Intent intent) { + Log.i("Kathy", "TestTwoService - onUnbind - from = " + intent.getStringExtra("from")); + return false; + } + + @Override + public void onDestroy() { + Log.i("Kathy", "TestTwoService - onDestroy - Thread = " + Thread.currentThread().getName()); + super.onDestroy(); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/XiangxueNetwork.java b/app/src/main/java/com/fisherbone/fuzhu/XiangxueNetwork.java new file mode 100644 index 0000000..8baa6af --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/XiangxueNetwork.java @@ -0,0 +1,31 @@ +package com.fisherbone.fuzhu;//package com.fisherbone.fuzhu; + +import android.app.Application; + +import com.xiangxue.common.network.base.INetworkRequiredInfo; + +public class XiangxueNetwork implements INetworkRequiredInfo { + private Application mApplication; + public XiangxueNetwork(Application application){ + this.mApplication = application; + } + @Override + public String getAppVersionName() { + return BuildConfig.VERSION_NAME; + } + + @Override + public String getAppVersionCode() { + return String.valueOf(BuildConfig.VERSION_CODE); + } + + @Override + public boolean isDebug() { + return BuildConfig.DEBUG; + } + + @Override + public Application getApplicationContext() { + return mApplication; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/abllib/AblConfig.java b/app/src/main/java/com/fisherbone/fuzhu/abllib/AblConfig.java new file mode 100644 index 0000000..291774b --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/abllib/AblConfig.java @@ -0,0 +1,87 @@ +package com.fisherbone.fuzhu.abllib; + +import com.blankj.utilcode.util.LogUtils; + +/** + * 2019/4/21 + * 17:49 + * Levine + * wechat 1483232332 + */ +public class AblConfig { + + private String mLogTag; + private boolean mIsLog; + private long mStepMsgDelayMillis;//消息延迟发送时间 + private long findViewMillisInFuture;//查找view倒计时总时长 + private long findViewCountDownInterval;//查找view检查间隔时间 + /** + * 所监测的APP包名,如果不设置将会监听整个系统的界面变化,如果设置后只会监听指定包名的APP + * 【暂时不用】 + */ + public static String[] sMonitoringPackageNames; + + private AblConfig(Builder builder) { + mLogTag = builder.mLogTag; + mIsLog = builder.mIsLog; + sMonitoringPackageNames = builder.mMonitoringPackageNames; + mStepMsgDelayMillis = builder.mStepMsgDelayMillis; + findViewCountDownInterval = builder.findViewCountDownInterval; + findViewMillisInFuture = builder.findViewMillisInFuture; + } + + public void init() { + LogUtils.getConfig().setGlobalTag(mLogTag); + LogUtils.getConfig().setLogSwitch(mIsLog); + AblStepHandler.getInstance().setStepMsgDelayMillis(mStepMsgDelayMillis); + FindViewCountDown.countDownInterval = findViewCountDownInterval; + FindViewCountDown.millisInFuture = findViewMillisInFuture; + } + + public static Builder Builder() { + return new Builder(); + } + + public static class Builder { + private String mLogTag = "abllib"; + private boolean mIsLog = true; + private String[] mMonitoringPackageNames; + private long mStepMsgDelayMillis = 2000;//步骤延迟发送时间 + private long findViewMillisInFuture = 10000;//查找view倒计时总时长 + private long findViewCountDownInterval = 500;//查找view检查间隔时间 + + public Builder setLogTag(String logTag) { + mLogTag = logTag; + return this; + } + + public Builder setLog(boolean log) { + mIsLog = log; + return this; + } + + public Builder setMonitoringPackageNames(String... monitoringPackageNames) { + mMonitoringPackageNames = monitoringPackageNames; + return this; + } + + public Builder setStepMsgDelayMillis(long stepMsgDelayMillis) { + mStepMsgDelayMillis = stepMsgDelayMillis; + return this; + } + + public Builder setFindViewMillisInFuture(long findViewMillisInFuture) { + this.findViewMillisInFuture = findViewMillisInFuture; + return this; + } + + public Builder setFindViewCountDownInterval(long findViewCountDownInterval) { + this.findViewCountDownInterval = findViewCountDownInterval; + return this; + } + + public AblConfig build() { + return new AblConfig(this); + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/abllib/AblService.java b/app/src/main/java/com/fisherbone/fuzhu/abllib/AblService.java new file mode 100644 index 0000000..01dbd2a --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/abllib/AblService.java @@ -0,0 +1,653 @@ +package com.fisherbone.fuzhu.abllib; + +import android.accessibilityservice.AccessibilityService; +import android.accessibilityservice.GestureDescription; +import android.annotation.TargetApi; +import android.content.Intent; +import android.graphics.Path; +import android.graphics.Rect; +import android.os.Build; +import android.text.TextUtils; +import android.util.Log; +import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityNodeInfo; + +import androidx.annotation.RequiresApi; + +import com.blankj.utilcode.util.LogUtils; +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.FuzhuApplication; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.db.CommentBeanData; +import com.fisherbone.fuzhu.db.dao.CommentDao; +import com.fisherbone.fuzhu.entity.SixEvent; +import com.jeremyliao.liveeventbus.LiveEventBus; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import de.greenrobot.event.EventBus; +import io.reactivex.disposables.Disposable; + +/** + * 2019/4/21 + * 11:29 + * Levine + * wechat 1483232332 + */ +public class AblService extends AccessibilityService { + + private static AblService mAblService; + private Disposable mdDisposable; + private String TAG = "commongendan"; + public String SHEBEITIPE_VILUETHREE = "3"; + + public static AblService getInstance() { + if (mAblService == null) { + throw new NullPointerException("AblService辅助服务未开启"); + } + return mAblService; + } + + @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) + public void inputClickId(String clickId) { + AccessibilityNodeInfo nodeInfo = getRootInActiveWindow(); + if (nodeInfo != null) { + List list = nodeInfo.findAccessibilityNodeInfosByText(clickId); + for (AccessibilityNodeInfo item : list) { + clickcommontwo(item, clickId); + } + } + } + + + @Override + public void onCreate() { + super.onCreate(); + mAblService = this; + init(); + } + + private void init() { + + } + + /** + * 系统成功绑定该服务时被触发,也就是当你在设置中开启相应的服务, + * 系统成功的绑定了该服务时会触发,通常我们可以在这里做一些初始化操作 + */ + @Override + protected void onServiceConnected() { + super.onServiceConnected(); + LogUtils.v("onServiceConnected"); + Log.e("TIAOSHI", "无障碍服务开启"); + LiveEventBus.get("ablservice").post("无障碍服务开启"); + } + + private ArrayList objects = new ArrayList<>(); + + @Override + public void onAccessibilityEvent(AccessibilityEvent event) { +// if("2".equals(ChangLiang.phonetype)) { +// if ("T".equals(ChangLiang.qidong)) { +// ChangLiang.qidong = "F"; +// AblViewUtil.startApplication(); +// AblViewUtil.mySleep(10); +// DianSou(); +// AblViewUtil.mySleep(3); +// AccessibilityNodeInfo findcomentt = findEditText(); +// String content = "178421572"; +// Log.e("TIAOSHI###", "获得的关键词内容" + content); +// AblViewUtil.mySleep(1); +// if ("0".equals(ChangLiang.phonetype)) { +// AblViewUtil.sayInput(content, findcomentt); +// } else { +// //华为畅享20 +// AblViewUtil.sayInput(content, findcomentt); +// } +// AblViewUtil.mySleep(3); +// DianSou(); +// AblViewUtil.mySleep(5); +// //进入直播间 +// if ("0".equals(ChangLiang.phonetype) || "1".equals(ChangLiang.phonetype)) { +// AblService.getInstance().clickPoint(705, 198, 300); +// } else { +// AblService.getInstance().clickPoint(1058, 300, 300); +// } +// AblViewUtil.mySleep(3); +// if ("0".equals(ChangLiang.phonetype)) { +// AblService.getInstance().clickPoint(100, 300, 300); +// } else { +// //华为畅享20 +// AblService.getInstance().clickPoint(200, 400, 300); +// } +// AblViewUtil.mySleep(1); +// ansy(); +// } +// } + + + LogUtils.v(event.getPackageName() + ""); + if (ChangLiang.gendanopen == 1) { + scroll2PositionClick(this, "6"); + } + + + int eventType = event.getEventType(); + + switch (eventType) { + //当通知栏发生改变的时候 + case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED: + Log.w("TIAOSHI", "有弹出======11111" + "==classname=="); + break; + //当窗口状态发生改变的时候 + case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: + String classname = event.getClassName().toString(); + Log.e("TIAOSHI", "有弹出==22222" + "==classname==" + classname); + List text = event.getText(); + if (text.size() > 0) { + CharSequence charSequence = text.get(0); + String str = charSequence.toString(); + // Log.w("TIAOSHI", "有弹出==" + str + "==classname==" + classname); + String s = charSequence.toString(); + Log.w("TIAOSHI", "有弹出==" + s + "==classname==" + classname); + if (!TextUtils.isEmpty(s)) { + EventBus.getDefault().post(new SixEvent("success", s)); + } + if (classname.equals("android.app.AlertDialog")) { + + } else if (classname.equals("com.android.packageinstaller.permission.ui.GrantPermissionsActivity")) { +// //点击安装 +// AblViewUtil.mySleep(2); +// inputClickId("始终允许"); + } else if (classname.equals("com.android.packageinstaller.PackageInstallerActivity")) { + //点击安装 + inputClickId("安装"); + } else if (classname.equals("com.android.packageinstaller.InstallAppProgress")) { + //点击打开 + AblViewUtil.mySleep(5); + inputClickId("打开"); + } else if (classname.equals("android.app.Dialog")) {//测试可以用 + if (str.contains("朋友推荐")) { + AblViewUtil.mySleep(2); + performGlobalAction(GLOBAL_ACTION_BACK); // 返回安装页面 + Log.e("TIAOSHI###", "关闭了好友推荐的弹框"); + } + } else if (classname.equals("androidx.appcompat.app.AlertDialog")) { + if (str.contains("为呵护未成")) { + AblViewUtil.mySleep(2); + performGlobalAction(GLOBAL_ACTION_BACK); // 返回安装页面 + Log.e("TIAOSHI###", "关闭了为呵护未成年人健康成长的弹框"); + } + } else if (str.contains("检测到更新")) {//测试可以用 + LiveEventBus.get("runningstate").post("0"); + AblViewUtil.mySleep(2); + inputClickId("以后再说"); + Log.e("TIAOSHI###", "关闭了检测到更新的弹框"); + } else if (str.contains("发现通讯录朋友")) {//测试可以用 + LiveEventBus.get("runningstate").post("0"); + AblViewUtil.mySleep(2); + inputClickId("暂时不要"); + Log.e("TIAOSHI###", "AblService关闭了发现通讯录好友的弹框"); + } else if (str.contains("由于该用户隐私设置")) { + + } else if (str.contains("个人信息保护指引")) { + LiveEventBus.get("runningstate").post("0"); + } else if (str.contains("欢迎体验抖音浅色模式")) { + LiveEventBus.get("runningstate").post("0"); + } else if (str.contains("朋友推荐")) { + LiveEventBus.get("runningstate").post("0"); + } else if (str.contains("设置抖音号")) { + LiveEventBus.get("runningstate").post("0"); + } + + break; + } + default: + } + } + + + public void scroll2PositionClick(AccessibilityService service, String text) { + try { + Thread.sleep(5000); //隔200 ms 滚动一次 + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { //必须android4.3以上的版本 + getdouyindsf(); + } + } + + private void getdouyindsf() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###跟", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); + if ("android.widget.TextView".equals(child3.getClassName())) { + String content = child3.getText().toString(); + if (!TextUtils.isEmpty(content)) { + //检索内容里面是否有数字 + String[] buff = content.split(":"); + String sdfsd = buff[buff.length - 1]; + Log.e("获得结果----", sdfsd + ""); + fasongpinglun(sdfsd); + if (sdfsd.length() == 1) { + Log.e("获得结果----", sdfsd + ""); + if (Compliance(sdfsd)) { + ChangLiang.genfaneirong = sdfsd; + ChangLiang.gendanopen = 0; + Log.d(TAG, "获得结果----有数字=====" + content); + //跟发数字 + fasongpinglun(ChangLiang.genfaneirong); + break; + } else { + Log.d(TAG, "获得结果----中没有数字"); + } + } + } + } + } + } + break; + } + } + } + } + + public boolean Compliance(String substring) { + if (substring.contains("0") || substring.contains("1") || substring.contains("2") || substring.contains("3") || substring.contains("4") || substring.contains("5") || substring.contains("6") || substring.contains("7") || substring.contains("8") || substring.contains("9")) { + return true; + } else { + return false; + } + } + + + private void fasongpinglun(String conment) { + //直播间话术 + AblViewUtil.mySleep(2); + clickmoreli("1"); + AblViewUtil.mySleep(2); + //复制文本粘贴在留言板 + AccessibilityNodeInfo getedittext = getedittext(); + Log.e("TIAOSHI###", "获得的关键词内容" + conment); + AblViewUtil.mySleep(2); + AblViewUtil.sayInput(conment, getedittext); + AblViewUtil.mySleep(1); + AccessibilityNodeInfo geouyintdd = geouyintdd(); + AblService.getInstance().clickcommontwo(geouyintdd, "点击发送"); + AblViewUtil.mySleep(2); + } + + /** + * 输入框 + * + * @return + */ + public AccessibilityNodeInfo getedittext() { + AccessibilityNodeInfo nodeinfo = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.EditText".equals(child.getClassName())) { + nodeinfo = child; + } + } + return nodeinfo; + } + + /** + * 发送节点 + * + * @return + */ + public AccessibilityNodeInfo geouyintdd() { + AccessibilityNodeInfo nodeinfo = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.Button".equals(child.getClassName())) { + if (child.getContentDescription() != null) { + if (child.getContentDescription().toString().equals("发送")) { + nodeinfo = child; + } + } + } + } + return nodeinfo; + } + + /** + * 点击直播间下方的更多按钮(备注:通过搜索点击直播进去的可用) + * 1.说点什么 + * 2.更多 + * 3.礼物 + */ + public void clickmoreli(String type) { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + // Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); + for (int r = 0; r < child3.getChildCount(); r++) { + AccessibilityNodeInfo child4 = child3.getChild(r); + // Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText() + ":" + child4.getContentDescription()); + switch (type) { + case "1"://说点什么 + if ("android.widget.TextView".equals(child4.getClassName())) { + if (child4.getText() != null) { + if (child4.getText().toString().equals("说点什么...")) { + AblService.getInstance().clickcommontwo(child4, ""); + } + } + } + break; + case "2"://更多 + if ("android.widget.Button".equals(child4.getClassName())) { + if (child4.getContentDescription().equals("更多")) { + AblService.getInstance().clickcommontwo(child4, "点击了更多"); + } + } + break; + case "3"://礼物 + if ("android.widget.Button".equals(child4.getClassName())) { + if (child4.getContentDescription().equals("礼物")) { + AblService.getInstance().clickcommontwo(child4, ""); + } + } + break; + default: + } + } + } + } + } + } + } + + + @Override + public void onDestroy() { + super.onDestroy(); + Log.e("TIAOSHI###", "无障碍服务被销毁"); + LiveEventBus.get("ablservice").post("无障碍服务被销毁"); + // sendAction(false); + } + +// private void sendAction(boolean state) { +// intent.putExtra("state", state); +// sendBroadcast(intent); +// } + + + /** + * 当服务要被中断时调用.会被调用多次 + */ + @Override + public void onInterrupt() { + Log.e("TIAOSHI###", "无障碍服务被中断"); + LiveEventBus.get("ablservice").post("无障碍服务被中断"); + } + + @Override + public boolean onUnbind(Intent intent) { + Log.e("TIAOSHI###", "无障碍服务关闭"); + LiveEventBus.get("ablservice").post("无障碍服务关闭"); + return super.onUnbind(intent); + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickPoint(float x1, float y1, long duration) { + + Path path = new Path(); + path.moveTo(x1, y1); + GestureDescription.Builder builder = new GestureDescription.Builder(); + GestureDescription gestureDescription = builder + .addStroke(new GestureDescription.StrokeDescription(path, 0, duration)) + .build(); + boolean b = dispatchGesture(gestureDescription, new GestureResultCallback() { + @Override + public void onCompleted(GestureDescription gestureDescription) { + super.onCompleted(gestureDescription); + // Log.e("TIAOSHI###", "点击结束..." + gestureDescription.getStrokeCount()); + } + + @Override + public void onCancelled(GestureDescription gestureDescription) { + super.onCancelled(gestureDescription); + Log.e("TIAOSHI###", "点击取消"); + } + }, null); + } + + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickcommon(List idsd, String s) { + if (idsd.size() > 0) { + AccessibilityNodeInfo accessibilityNodeInfo = idsd.get(0); + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + this.clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮,直接退出了。。。。"); + return; + } + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickcommontwo(AccessibilityNodeInfo accessibilityNodeInfo, String s) { + if (accessibilityNodeInfo != null) { + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + this.clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮,直接退出了。。。。"); + return; + } + } + + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickcommonthree(AccessibilityNodeInfo accessibilityNodeInfo, String s) { + if (accessibilityNodeInfo != null) { + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + this.clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + // ToastUtils.showShort("点击"+s+"按钮"+ "("+ (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮,直接退出了。。。。"); + AblViewUtil.back(); + return; + } + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void randomSwipe() { + int a = 270 + RandumInt.getRandumInt4() * 8; + int b = 270 - RandumInt.getRandumInt4() * 10; +// int c=1700-RandumInt.getRandumInt4()*8; // 1920分辨率起步的滑动方式,原为1800 + int c = 1200 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 +// int c=1250-RandumInt.getRandumInt4()*8; // 1440分辨率的滑动方式:红米6A的方式,感觉屏幕没有1440高 + + int d = 300 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 320); //延迟330毫秒 +// mySleep(200); +// swipe(c,b,a,d,50); + } + + @RequiresApi(api = Build.VERSION_CODES.N) + public void randomSwipetwo() { + if (SHEBEITIPE_VILUETHREE.equals(ChangLiang.phonetype)) { + int a = 700 + RandumInt.getRandumInt4() * 8; + int b = 700 - RandumInt.getRandumInt4() * 10; + int c = 1700 - RandumInt.getRandumInt4() * 8; // 1920分辨率起步的滑动方式,原为1800 + int d = 500 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 500); //延迟330毫秒 + } else { + int a = 270 + RandumInt.getRandumInt4() * 8; + int b = 270 - RandumInt.getRandumInt4() * 10; +// int c=1700-RandumInt.getRandumInt4()*8; // 1920分辨率起步的滑动方式,原为1800 + int c = 1200 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 +// int c=1250-RandumInt.getRandumInt4()*8; // 1440分辨率的滑动方式:红米6A的方式,感觉屏幕没有1440高 + int d = 200 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 500); //延迟330毫秒 + } + } + + @RequiresApi(api = Build.VERSION_CODES.N) + public void randomSwipethree() { + if (SHEBEITIPE_VILUETHREE.equals(ChangLiang.phonetype)) { + int a = 700 + RandumInt.getRandumInt4() * 8; + int b = 700 - RandumInt.getRandumInt4() * 10; + int c = 1700 - RandumInt.getRandumInt4() * 8; // 1920分辨率起步的滑动方式,原为1800 + int d = 500 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(b, d, a, c, 500); //延迟330毫秒 + } else { + int a = 270 + RandumInt.getRandumInt4() * 8; + int b = 270 - RandumInt.getRandumInt4() * 10; +// int c=1700-RandumInt.getRandumInt4()*8; // 1920分辨率起步的滑动方式,原为1800 + int c = 1200 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 +// int c=1250-RandumInt.getRandumInt4()*8; // 1440分辨率的滑动方式:红米6A的方式,感觉屏幕没有1440高 + int d = 200 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(b, d, a, c, 500); //延迟330毫秒 + + } + } + + @RequiresApi(api = Build.VERSION_CODES.N) + public void swipe(float x1, float y1, float x2, float y2, long duration) { + Path path = new Path(); + path.moveTo(x1, y1); + path.lineTo(x2, y2); + + Log.e("TIAOSHI###", "MyAccessibilityService中滑动swipe()方法滑动点,reset:(" + x1 + "," + y1 + "),(" + x2 + "," + y2 + ")" + "滑动的时长是:" + duration); + GestureDescription.Builder builder = new GestureDescription.Builder(); + GestureDescription gestureDescription = builder + .addStroke(new GestureDescription.StrokeDescription(path, 0, duration)) + .build(); + boolean b = dispatchGesture(gestureDescription, new GestureResultCallback() { + @Override + public void onCompleted(GestureDescription gestureDescription) { + super.onCompleted(gestureDescription); + Log.e("TIAOSHI###", "滑动结束..." + gestureDescription.getStrokeCount()); + } + + @Override + public void onCancelled(GestureDescription gestureDescription) { + super.onCancelled(gestureDescription); + Log.e("TIAOSHI###", "滑动取消"); + } + }, null); + } + + //点击右上角搜索 + public void DianSou() { + + switch (ChangLiang.phonetype) { + case "0": + //红米7a + AblService.getInstance().clickPoint(656, 99, 300); + break; + case "1": + //华为畅享20 + AblService.getInstance().clickPoint(659, 99, 300); + break; + case "2": + //华为畅享20 + AblService.getInstance().clickPoint(990, 163, 300); + break; + default: + } + Log.e("TIAOSHI###", "点击搜索按钮"); + } + + + /** + * 寻找搜索输入框 + */ + public AccessibilityNodeInfo findEditText() { + AccessibilityNodeInfo infooos = null; + AccessibilityNodeInfo rootttt = AblService.getInstance().getRootInActiveWindow(); + for (int j = 0; j < rootttt.getChildCount(); j++) { + AccessibilityNodeInfo child = rootttt.getChild(j); + // Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + if ("android.widget.EditText".equals(child.getClassName())) { + infooos = child; + } + } + return infooos; + } + + + /** + * 直播间点赞(红米10) + * + * @param mun + */ + private void hongDianzan(int mun) { + for (int i = 0; i < mun; i++) { + int a = 500 + RandumInt.getRandumInt4() * 20; + int b = 1000 - RandumInt.getRandumInt4() * 20; + int c = 600 - RandumInt.getRandumInt4() * 50; + AblService.getInstance().clickPoint(a, b, 200); + try { + //隔200 ms 滚动一次 + Thread.sleep(c); + } catch (InterruptedException e) { + e.printStackTrace(); + } + // Log.e("TIAOSHI###", "点击了"); + } + } + + /** + * 随机获取评论话术 + */ + private String getConment() { + CommentDao commentDao = new CommentDao(FuzhuApplication.getContext()); + List CommentBeanDatas = commentDao.queryInByCustom("type", "3"); + if (CommentBeanDatas.size() == 0) { + return "哈哈"; + } else if (CommentBeanDatas.size() == 1) { + CommentBeanData commentBeanData = CommentBeanDatas.get(0); + String comment = commentBeanData.getComment(); + return comment; + } else { + int i = new Random().nextInt(CommentBeanDatas.size() - 1); + CommentBeanData commentBeanData = CommentBeanDatas.get(i); + String comment = commentBeanData.getComment(); + return comment; + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/abllib/AblStepHandler.java b/app/src/main/java/com/fisherbone/fuzhu/abllib/AblStepHandler.java new file mode 100644 index 0000000..4e332c6 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/abllib/AblStepHandler.java @@ -0,0 +1,212 @@ +package com.fisherbone.fuzhu.abllib; + + +import android.os.Handler; +import android.os.Looper; +import android.os.Message; + +import androidx.annotation.NonNull; + +import com.blankj.utilcode.util.LogUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * 2019/4/21 + * 14:36 + * Levine + * wechat 1483232332 + */ +public class AblStepHandler extends Handler { + + private static AblStepHandler instance; + private List mStepListeners = new ArrayList<>(); + private boolean isStop = true;//是否停止 + private String[] mDatas;//数据 + private long mStepMsgDelayMillis = 2000;//消息延迟发送时间 + private List mInitializedSteps = new ArrayList<>();//已经初始化过的步骤 + + private AblStepHandler() { + super(Looper.getMainLooper()); + } + + public static AblStepHandler getInstance() { + if (instance == null) { + synchronized (AblStepHandler.class) { + if (instance == null) { + instance = new AblStepHandler(); + } + } + } + return instance; + } + + /** + * 发送handler执行消息 + * + * @param step 步骤 + * @param delayMillis 延迟时间 + * @param datas 数据 + */ + public static void sendMsg(int step, long delayMillis, String... datas) { + AblStepHandler ablStepHandler = AblStepHandler.getInstance(); + if (datas != null && datas.length > 0) { + ablStepHandler.setDatas(datas); + } + ablStepHandler.sendEmptyMessageDelayed(step, delayMillis); + } + + /** + * 发送handler执行消息 + * + * @param step 步骤 + * @param delayMillis 延迟时间 + */ + public static void sendMsg(int step, long delayMillis) { + sendMsg(step, delayMillis, new String[]{}); + } + + /** + * 发送handler执行消息 + * + * @param step 步骤 + * @param datas 数据 + */ + public static void sendMsg(int step, String... datas) { + sendMsg(step, AblStepHandler.getInstance().getStepMsgDelayMillis(), datas); + } + + /** + * 发送handler执行消息 + * + * @param step 步骤 + */ + public static void sendMsg(int step) { + sendMsg(step, AblStepHandler.getInstance().getStepMsgDelayMillis(), new String[]{}); + } + + /** + * 根据viewid或文字发送执行消息 + * + * @param millisInFuture view查找超时时间 + * @param countDownInterval 查找间隔时间 + * @param step 步骤 + */ + public static void sendMsgByView( + long millisInFuture, + long countDownInterval, + int step, + String... nextMsgViewIdOrText + ) { + FindViewCountDown.start(millisInFuture, countDownInterval, step, nextMsgViewIdOrText); + } + + /** + * 根据viewid或文字发送执行消息 + * + * @param millisInFuture view查找超时时间 + * @param countDownInterval 查找间隔时间 + * @param callBack 回调,注:如果回调不为空将不发送消息,要发送消息就自己在成功的回调里发送 + * @param viewIdOrText viewid或者文字内容 + */ + public static void sendMsgByView( + long millisInFuture, + long countDownInterval, + @NonNull FindViewCountDown.CallBack callBack, + String... viewIdOrText + ) { + FindViewCountDown.start(millisInFuture, countDownInterval, callBack, viewIdOrText); + } + + /** + * 根据viewid或文字发送执行消息 + * + * @param step 步骤 + * @param viewIdOrText viewid或者文字内容 + */ + public static void sendMsgByView( + int step, + String... viewIdOrText + ) { + FindViewCountDown.start(step, viewIdOrText); + } + + /** + * 根据viewid或文字发送执行消息 + * + * @param callBack 回调,注:如果回调不为空将不发送消息,要发送消息就自己在成功的回调里发送 + * @param viewIdOrText viewid或者文字内容 + */ + public static void sendMsgByView( + @NonNull FindViewCountDown.CallBack callBack, + String... viewIdOrText + ) { + FindViewCountDown.start(callBack, viewIdOrText); + } + + + public String[] getDatas() { + return mDatas; + } + + public void setDatas(String... datas) { + mDatas = datas; + } + + public long getStepMsgDelayMillis() { + return mStepMsgDelayMillis; + } + + public void setStepMsgDelayMillis(long msgDelayMillis) { + mStepMsgDelayMillis = msgDelayMillis; + } + + public boolean isStop() { + + return isStop; + } + + public void setStop(boolean stop) { + isStop = stop; + } + + @Override + public void handleMessage(Message msg) { + super.handleMessage(msg); + if (isStop) return; + LogUtils.v("step", msg.what); + for (StepListener stepListener : mStepListeners) { + stepListener.onStep(msg.what, msg); + } + } + + private void addStepListener(StepListener handleMessageListener) { + mStepListeners.add(handleMessageListener); + } + + public void removeStepListener(StepListener handleMessageListener) { + mStepListeners.remove(handleMessageListener); + } + + /** + * 初始化步骤实现类 + * + * @param ablStepBases 继承了StepBase的实现类 + */ + public void initStepClass(BaseAblStep... ablStepBases) { + for (BaseAblStep ablStepBase : ablStepBases) { + if (mInitializedSteps.contains(ablStepBase.getClass().getName())) { + LogUtils.e(ablStepBase.getClass().getName() + "已经初始化,请勿重复初始化"); + continue; + } + addStepListener(ablStepBase); + mInitializedSteps.add(ablStepBase.getClass().getName()); + } + } + + public interface StepListener { + void onStep(int step, Message msg); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/abllib/AblSteps.java b/app/src/main/java/com/fisherbone/fuzhu/abllib/AblSteps.java new file mode 100644 index 0000000..98fbaad --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/abllib/AblSteps.java @@ -0,0 +1,306 @@ +package com.fisherbone.fuzhu.abllib; + +/** + * 2019/4/21 + * 18:33 + * Levine + * wechat 1483232332 + */ +public class AblSteps { + + /** + * 全局静态常量步骤标识1~200,不够自己再加,从200开始加,基本应该都是够的了 + */ + public final static int STEP_1 = 1; + public final static int STEP_2 = 2; + public final static int STEP_3 = 3; + public final static int STEP_4 = 4; + public final static int STEP_5 = 5; + public final static int STEP_6 = 6; + public final static int STEP_7 = 7; + public final static int STEP_8 = 8; + public final static int STEP_9 = 9; + /*****************************************/ + public final static int STEP_10 = 10; + public final static int STEP_11 = 11; + public final static int STEP_12 = 12; + public final static int STEP_13 = 13; + public final static int STEP_14 = 14; + public final static int STEP_15 = 15; + public final static int STEP_16 = 16; + public final static int STEP_17 = 17; + public final static int STEP_18 = 18; + public final static int STEP_19 = 19; + /*****************************************/ + public final static int STEP_20 = 20; + public final static int STEP_21 = 21; + public final static int STEP_22 = 22; + public final static int STEP_23 = 23; + public final static int STEP_24 = 24; + public final static int STEP_25 = 25; + public final static int STEP_26 = 26; + public final static int STEP_27 = 27; + public final static int STEP_28 = 28; + public final static int STEP_29 = 29; + /*****************************************/ + public final static int STEP_30 = 30; + public final static int STEP_31 = 31; + public final static int STEP_32 = 32; + public final static int STEP_33 = 33; + public final static int STEP_34 = 34; + public final static int STEP_35 = 35; + public final static int STEP_36 = 36; + public final static int STEP_37 = 37; + public final static int STEP_38 = 38; + public final static int STEP_39 = 39; + /*****************************************/ + public final static int STEP_40 = 40; + public final static int STEP_41 = 41; + public final static int STEP_42 = 42; + public final static int STEP_43 = 43; + public final static int STEP_44 = 44; + public final static int STEP_45 = 45; + public final static int STEP_46 = 46; + public final static int STEP_47 = 47; + public final static int STEP_48 = 48; + public final static int STEP_49 = 49; + /*****************************************/ + public final static int STEP_50 = 50; + public final static int STEP_51 = 51; + public final static int STEP_52 = 52; + public final static int STEP_53 = 53; + public final static int STEP_54 = 54; + public final static int STEP_55 = 55; + public final static int STEP_56 = 56; + public final static int STEP_57 = 57; + public final static int STEP_58 = 58; + public final static int STEP_59 = 59; + /*****************************************/ + public final static int STEP_60 = 60; + public final static int STEP_61 = 61; + public final static int STEP_62 = 62; + public final static int STEP_63 = 63; + public final static int STEP_64 = 64; + public final static int STEP_65 = 65; + public final static int STEP_66 = 66; + public final static int STEP_67 = 67; + public final static int STEP_68 = 68; + public final static int STEP_69 = 69; + /*****************************************/ + public final static int STEP_70 = 70; + public final static int STEP_71 = 71; + public final static int STEP_72 = 72; + public final static int STEP_73 = 73; + public final static int STEP_74 = 74; + public final static int STEP_75 = 75; + public final static int STEP_76 = 76; + public final static int STEP_77 = 77; + public final static int STEP_78 = 78; + public final static int STEP_79 = 79; + /*****************************************/ + public final static int STEP_80 = 80; + public final static int STEP_81 = 81; + public final static int STEP_82 = 82; + public final static int STEP_83 = 83; + public final static int STEP_84 = 84; + public final static int STEP_85 = 85; + public final static int STEP_86 = 86; + public final static int STEP_87 = 87; + public final static int STEP_88 = 88; + public final static int STEP_89 = 89; + /*****************************************/ + public final static int STEP_90 = 90; + public final static int STEP_91 = 91; + public final static int STEP_92 = 92; + public final static int STEP_93 = 93; + public final static int STEP_94 = 94; + public final static int STEP_95 = 95; + public final static int STEP_96 = 96; + public final static int STEP_97 = 97; + public final static int STEP_98 = 98; + public final static int STEP_99 = 99; + /*****************************************/ + public final static int STEP_100 = 100; + public final static int STEP_101 = 101; + public final static int STEP_102 = 102; + public final static int STEP_103 = 103; + public final static int STEP_104 = 104; + public final static int STEP_105 = 105; + public final static int STEP_106 = 106; + public final static int STEP_107 = 107; + public final static int STEP_108 = 108; + public final static int STEP_109 = 109; + /*****************************************/ + public final static int STEP_110 = 110; + public final static int STEP_111 = 111; + public final static int STEP_112 = 112; + public final static int STEP_113 = 113; + public final static int STEP_114 = 114; + public final static int STEP_115 = 115; + public final static int STEP_116 = 116; + public final static int STEP_117 = 117; + public final static int STEP_118 = 118; + public final static int STEP_119 = 119; + /*****************************************/ + public final static int STEP_120 = 120; + public final static int STEP_121 = 121; + public final static int STEP_122 = 122; + public final static int STEP_123 = 123; + public final static int STEP_124 = 124; + public final static int STEP_125 = 125; + public final static int STEP_126 = 126; + public final static int STEP_127 = 127; + public final static int STEP_128 = 128; + public final static int STEP_129 = 129; + /*****************************************/ + public final static int STEP_130 = 130; + public final static int STEP_131 = 131; + public final static int STEP_132 = 132; + public final static int STEP_133 = 133; + public final static int STEP_134 = 134; + public final static int STEP_135 = 135; + public final static int STEP_136 = 136; + public final static int STEP_137 = 137; + public final static int STEP_138 = 138; + public final static int STEP_139 = 139; + /*****************************************/ + public final static int STEP_140 = 140; + public final static int STEP_141 = 141; + public final static int STEP_142 = 142; + public final static int STEP_143 = 143; + public final static int STEP_144 = 144; + public final static int STEP_145 = 145; + public final static int STEP_146 = 146; + public final static int STEP_147 = 147; + public final static int STEP_148 = 148; + public final static int STEP_149 = 149; + /*****************************************/ + public final static int STEP_150 = 150; + public final static int STEP_151 = 151; + public final static int STEP_152 = 152; + public final static int STEP_153 = 153; + public final static int STEP_154 = 154; + public final static int STEP_155 = 155; + public final static int STEP_156 = 156; + public final static int STEP_157 = 157; + public final static int STEP_158 = 158; + public final static int STEP_159 = 159; + /*****************************************/ + public final static int STEP_160 = 160; + public final static int STEP_161 = 161; + public final static int STEP_162 = 162; + public final static int STEP_163 = 163; + public final static int STEP_164 = 164; + public final static int STEP_165 = 165; + public final static int STEP_166 = 166; + public final static int STEP_167 = 167; + public final static int STEP_168 = 168; + public final static int STEP_169 = 169; + /*****************************************/ + public final static int STEP_170 = 170; + public final static int STEP_171 = 171; + public final static int STEP_172 = 172; + public final static int STEP_173 = 173; + public final static int STEP_174 = 174; + public final static int STEP_175 = 175; + public final static int STEP_176 = 176; + public final static int STEP_177 = 177; + public final static int STEP_178 = 178; + public final static int STEP_179 = 179; + /*****************************************/ + public final static int STEP_180 = 180; + public final static int STEP_181 = 181; + public final static int STEP_182 = 182; + public final static int STEP_183 = 183; + public final static int STEP_184 = 184; + public final static int STEP_185 = 185; + public final static int STEP_186 = 186; + public final static int STEP_187 = 187; + public final static int STEP_188 = 188; + public final static int STEP_189 = 189; + /*****************************************/ + public final static int STEP_190 = 190; + public final static int STEP_191 = 191; + public final static int STEP_192 = 192; + public final static int STEP_193 = 193; + public final static int STEP_194 = 194; + public final static int STEP_195 = 195; + public final static int STEP_196 = 196; + public final static int STEP_197 = 197; + public final static int STEP_198 = 198; + public final static int STEP_199 = 199; + public final static int STEP_200 = 200; + + /*****************************************/ + public final static int STEP_201 = 201; + public final static int STEP_202 = 202; + public final static int STEP_203 = 203; + public final static int STEP_204 = 24; + public final static int STEP_205 = 205; + public final static int STEP_206 = 206; + public final static int STEP_207 = 207; + public final static int STEP_208 = 208; + public final static int STEP_209 = 209; + public final static int STEP_210 = 210; + + /*****************************************/ + public final static int STEP_211 = 211; + public final static int STEP_212 = 212; + public final static int STEP_213 = 213; + public final static int STEP_214 = 214; + public final static int STEP_215 = 215; + public final static int STEP_216 = 216; + public final static int STEP_217 = 217; + public final static int STEP_218 = 218; + public final static int STEP_219 = 219; + public final static int STEP_220 = 220; + /*****************************************/ + + public final static int STEP_221 = 221; + public final static int STEP_222 = 222; + public final static int STEP_223 = 223; + public final static int STEP_224 = 224; + public final static int STEP_225 = 225; + public final static int STEP_226 = 226; + public final static int STEP_227 = 227; + public final static int STEP_228 = 228; + public final static int STEP_229 = 229; + public final static int STEP_230 = 230; + + /*****************************************/ + + public final static int STEP_231 = 231; + public final static int STEP_232 = 232; + public final static int STEP_233 = 233; + public final static int STEP_234 = 234; + public final static int STEP_235 = 235; + public final static int STEP_236 = 236; + public final static int STEP_237 = 237; + public final static int STEP_238 = 238; + public final static int STEP_239 = 239; + public final static int STEP_240 = 240; + /*****************************************/ + + public final static int STEP_241 = 241; + public final static int STEP_242 = 242; + public final static int STEP_243 = 243; + public final static int STEP_244 = 244; + public final static int STEP_245 = 245; + public final static int STEP_246 = 246; + public final static int STEP_247 = 247; + public final static int STEP_248 = 248; + public final static int STEP_249 = 249; + + /*****************************************/ + public final static int STEP_250 = 250; + public final static int STEP_251 = 251; + public final static int STEP_252 = 252; + public final static int STEP_253 = 253; + public final static int STEP_254 = 254; + public final static int STEP_255 = 255; + public final static int STEP_256 = 256; + public final static int STEP_257 = 257; + public final static int STEP_258 = 258; + public final static int STEP_259 = 259; + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/abllib/BaseAblStep.java b/app/src/main/java/com/fisherbone/fuzhu/abllib/BaseAblStep.java new file mode 100644 index 0000000..38e20ee --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/abllib/BaseAblStep.java @@ -0,0 +1,508 @@ +package com.fisherbone.fuzhu.abllib; + +import android.graphics.Rect; +import android.os.Build; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import androidx.annotation.RequiresApi; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; + +import java.util.List; + +/** + * 2019/4/21 + * 16:44 + * Levine + * wechat 1483232332 + */ +public abstract class BaseAblStep implements AblStepHandler.StepListener { + + + /** + * 点击我的 + */ + @RequiresApi(api = Build.VERSION_CODES.N) + public void myClick(){ + AblService instance = AblService.getInstance(); + if(ChangLiang.phonetype.equals("0")){ + instance.clickPoint(648,1286, 300);//红米7a + }else { + instance.clickPoint(648,1536, 300);//华为畅享20 [632,1521][664,1552] + } + Log.e("TIAOSHI###", "点击了我按钮"); + } + + + /** + * 查看节点的坐标点 + */ + public void nodeZuobiao(AccessibilityNodeInfo nodeinfo){ + Rect rect = new Rect(); + nodeinfo.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----显示节点的坐标:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + + } + + /** + * 查看节点的坐标点 + */ + public void nodeZuobiaoii(AccessibilityNodeInfo nodeinfo){ + Rect rect = new Rect(); + nodeinfo.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----显示控件点击的坐标:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + + } + + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickcommontwo(AccessibilityNodeInfo accessibilityNodeInfo, String s) { + if (accessibilityNodeInfo != null) { + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮"); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮,直接退出了。。。。"); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_14); + } + } + + + /** + * 关闭青少年保护弹框 + * @param instance + */ + public void closedQDialog(AblService instance) { + //处理我知道了的弹框 + AccessibilityNodeInfo zhidao = AblViewUtil.findByText("我知道了", 0); + if(zhidao==null){ + Log.e("TIAOSHI###", "没有找到我知道了的弹窗" ); + }else { + Log.e("TIAOSHI###", "弹出了我知道了的弹窗" ); + AblService.getInstance().clickcommontwo(zhidao, "我知道了"); + AblViewUtil.mySleep(2); + } + } + + /** + * 关闭设置抖音号弹框 + * @param instance + */ + public void setdoyinQDialog(AblService instance) { + //处理我知道了的弹框 + AccessibilityNodeInfo zhidao = AblViewUtil.findByText("设置抖音号", 0); + if(zhidao==null){ + Log.e("TIAOSHI###", "没有找到设置抖音号的弹窗" ); + }else { + Log.e("TIAOSHI###", "弹出了设置抖音号的弹窗" ); + AblService.getInstance().clickPoint(1025, 1630, 300); + AblViewUtil.mySleep(3); + fangqiQDialog(instance); + } + } + + public void fangqiQDialog(AblService instance) { + //处理我知道了的弹框 + AccessibilityNodeInfo zhidao = AblViewUtil.findByText("放弃", 0); + if(zhidao==null){ + Log.e("TIAOSHI###", "没有找到放弃的弹窗" ); + }else { + Log.e("TIAOSHI###", "弹出了放弃的弹窗" ); + //[623,1146][799,1295] + AblService.getInstance().clickPoint(711, 1220, 300); + AblViewUtil.mySleep(2); + } + } + + /** + * 关闭检测到更新弹框 + * @param instance + */ + public void closedJDialog(AblService instance) { + //处理我知道了的弹框 + AccessibilityNodeInfo zhidao = AblViewUtil.findByText("检测到更新", 0); + if(zhidao==null){ + Log.e("TIAOSHI###", "没有找到检测到更新的弹窗" ); + }else { + Log.e("TIAOSHI###", "弹出了检测到更新的弹窗" ); + AccessibilityNodeInfo zaishuo = AblViewUtil.findByText("以后再说", 0); + AblService.getInstance().clickcommontwo(zaishuo, "以后再说"); + AblViewUtil.mySleep(1); + } + } + + /** + * 关闭检测到更新弹框 + * @param instance + */ + public void closedzsDialog(AblService instance) { + //处理我知道了的弹框 + AccessibilityNodeInfo zhidao = AblViewUtil.findByText("暂时不要", 0); + if(zhidao==null){ + Log.e("TIAOSHI###", "没有找到暂时不要的弹窗" ); + }else { + Log.e("TIAOSHI###", "弹出了暂时不要的弹窗" ); + AccessibilityNodeInfo zaishuo = AblViewUtil.findByText("暂时不要", 0); + AblService.getInstance().clickcommontwo(zaishuo, "暂时不要"); + AblViewUtil.mySleep(1); + } + } + + /** + * 关闭朋友推荐弹框 + * @param instance + */ + public void closedtjDialog(AblService instance) { + //处理我知道了的弹框 + AccessibilityNodeInfo zhidao = AblViewUtil.findByText("朋友推荐", 0); + if(zhidao==null){ + Log.e("TIAOSHI###", "没有找到朋友推荐的弹窗" ); + }else { + Log.e("TIAOSHI###", "弹出了朋友推荐的弹窗" ); + //[890,489][956,555] + AblService.getInstance().clickPoint(923, 522, 300); + AblViewUtil.mySleep(1); + } + } + + /** + * 个人信息保护指引 + * @param instance + */ + public void yinsiDialog(AblService instance) { + //处理我知道了的弹框 + AccessibilityNodeInfo zhidao = AblViewUtil.findByText("个人信息保护指引", 0); + if(zhidao==null){ + Log.e("TIAOSHI###", "没有找到个人信息保护指引的弹窗" ); + }else { + Log.e("TIAOSHI###", "弹出了个人信息保护指引的弹窗" ); + List list = AblViewUtil.findByText("同意"); + for (AccessibilityNodeInfo item : list) { + clickcommontwo(item, "同意"); + } + AblViewUtil.mySleep(1); + } + } + + /** + * 我们才能继续为你提供服务 + * @param instance + */ + public void fuwuDialog(AblService instance) { + //处理我知道了的弹框 + AccessibilityNodeInfo zhidao = AblViewUtil.findByText("我们才能继续为你提供服务", 0); + if(zhidao==null){ + Log.e("TIAOSHI###", "没有找到我们才能继续为你提供服务的弹窗" ); + }else { + Log.e("TIAOSHI###", "弹出了我们才能继续为你提供服务的弹窗" ); + List list = AblViewUtil.findByText("同意并继续"); + for (AccessibilityNodeInfo item : list) { + clickcommontwo(item, "同意并继续"); + } + AblViewUtil.mySleep(1); + } + } + /** + * 访问以下权限吗 + * @param instance + */ + public void quanxianDialog(AblService instance) { + //处理我知道了的弹框 + AccessibilityNodeInfo zhidao = AblViewUtil.findByText("访问以下权限吗", 0); + if(zhidao==null){ + Log.e("TIAOSHI###", "没有找到访问以下权限吗的弹窗" ); + }else { + Log.e("TIAOSHI###", "弹出了访问以下权限吗的弹窗" ); + List list = AblViewUtil.findByText("始终允许"); + for (AccessibilityNodeInfo item : list) { + clickcommontwo(item, "始终允许"); + } + AblViewUtil.mySleep(1); + } + } + + + /** + * 关闭地理位置信息弹框 + * @param instance + */ + public void closedDDialog(AblService instance) { + //处理我知道了的弹框 + AccessibilityNodeInfo zhidao = AblViewUtil.findByText("地理位置信息", 0); + if(zhidao==null){ + Log.e("TIAOSHI###", "没有找到地理位置信息的弹窗" ); + }else { + Log.e("TIAOSHI###", "弹出了检测到地理位置信息的弹窗" ); + AccessibilityNodeInfo zaishuo = AblViewUtil.findByText("取消", 0); + AblService.getInstance().clickcommontwo(zaishuo, "取消"); + AblViewUtil.mySleep(1); + } + } + + /** + * 关闭地理位置=授权弹框 + * @param instance + */ + public void closedSDialog(AblService instance) { + //处理我知道了的弹框 + AccessibilityNodeInfo zhidao = AblViewUtil.findByText("地理位置授权", 0); + if(zhidao==null){ + Log.e("TIAOSHI###", "没有找到地理位置授权的弹窗" ); + }else { + Log.e("TIAOSHI###", "弹出了检测到地理位置授权的弹窗" ); + AccessibilityNodeInfo zaishuo = AblViewUtil.findByText("不允许", 0); + AblService.getInstance().clickcommontwo(zaishuo, "不允许"); + AblViewUtil.mySleep(1); + } + } + + /** + * 关闭个人信息保护指引 + * @param instance + */ + public void closedBDialog(AblService instance) { + //处理我知道了的弹框 + AccessibilityNodeInfo zhidao = AblViewUtil.findByText("个人信息保护指引", 0); + if(zhidao==null){ + Log.e("TIAOSHI###", "没有找到个人信息保护指引" ); + }else { + Log.e("TIAOSHI###", "弹出了个人信息保护指引的弹窗" ); + AccessibilityNodeInfo zaishuo = AblViewUtil.findByText("同意", 0); + AblService.getInstance().clickcommontwo(zaishuo, "同意"); + AblViewUtil.mySleep(1); + } + } + + /** + * 寻找控件 + */ + public void getNodeInfo() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + + Rect rect = new Rect(); + child1.getBoundsInScreen(rect); + if (rect.left >0&& rect.left<1080) { + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + nodeZuobiao(child1); + } + +// for (int j = 0; j < child1.getChildCount(); j++) { +// AccessibilityNodeInfo child2 = child1.getChild(j); +// Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); +// nodeZuobiao(child2); +// for (int x = 0; x < child2.getChildCount(); x++) { +// AccessibilityNodeInfo child3 = child2.getChild(x); +// Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child3.getContentDescription()); +// nodeZuobiao(child3); +// for (int r = 0; r < child3.getChildCount(); r++) { +// AccessibilityNodeInfo child4 = child3.getChild(r); +// Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText()+ ":" + child4.getContentDescription()); +// nodeZuobiao(child4); +// for (int m = 0; m < child4.getChildCount(); m++) { +// AccessibilityNodeInfo child5 = child4.getChild(m); +// Log.e("TIAOSHI###", "----6Node:" + child5.getClassName() + ":" + child5.getText()+ ":" + child5.getContentDescription()); +// nodeZuobiao(child5); +// for (int p = 0; p < child5.getChildCount();p++) { +// AccessibilityNodeInfo child6 = child5.getChild(p); +// Log.e("TIAOSHI###", "----7Node:" + child6.getClassName() + ":" + child6.getText()+ ":" + child6.getContentDescription()); +// for (int t = 0; t < child6.getChildCount();t++) { +// AccessibilityNodeInfo child7 = child6.getChild(t); +// Log.e("TIAOSHI###", "----8Node:" + child7.getClassName() + ":" + child7.getText()+ ":" + child7.getContentDescription()); +// for (int q = 0; q < child7.getChildCount();t++) { +// AccessibilityNodeInfo child8 = child7.getChild(q); +// Log.e("TIAOSHI###", "----9Node:" + child8.getClassName() + ":" + child8.getText()+ ":" + child8.getContentDescription()); +// +// } +// } +// } +// } +// } +// } +// } + } + } + } + + + /** + * 寻找控件 + */ + public void getNodeInfoh() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + nodeZuobiao(child1); +// for (int j = 0; j < child1.getChildCount(); j++) { +// AccessibilityNodeInfo child2 = child1.getChild(j); +// Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); +// nodeZuobiao(child2); +// for (int x = 0; x < child2.getChildCount(); x++) { +// AccessibilityNodeInfo child3 = child2.getChild(x); +// Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child3.getContentDescription()); +// nodeZuobiao(child3); +// for (int r = 0; r < child3.getChildCount(); r++) { +// AccessibilityNodeInfo child4 = child3.getChild(r); +// Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText()+ ":" + child4.getContentDescription()); +// nodeZuobiao(child4); +// for (int m = 0; m < child4.getChildCount(); m++) { +// AccessibilityNodeInfo child5 = child4.getChild(m); +// Log.e("TIAOSHI###", "----6Node:" + child5.getClassName() + ":" + child5.getText()+ ":" + child5.getContentDescription()); +// nodeZuobiao(child5); +// for (int p = 0; p < child5.getChildCount();p++) { +// AccessibilityNodeInfo child6 = child5.getChild(p); +// Log.e("TIAOSHI###", "----7Node:" + child6.getClassName() + ":" + child6.getText()+ ":" + child6.getContentDescription()); +// for (int t = 0; t < child6.getChildCount();t++) { +// AccessibilityNodeInfo child7 = child6.getChild(t); +// Log.e("TIAOSHI###", "----8Node:" + child7.getClassName() + ":" + child7.getText()+ ":" + child7.getContentDescription()); +// for (int q = 0; q < child7.getChildCount();t++) { +// AccessibilityNodeInfo child8 = child7.getChild(q); +// Log.e("TIAOSHI###", "----9Node:" + child8.getClassName() + ":" + child8.getText()+ ":" + child8.getContentDescription()); +// +// } +// } +// } +// } +// } +// } +// } + } + } + } + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo, String s) { + if (accessibilityNodeInfo != null) { + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮"); + } + } + + + + + protected void againStart(String str) { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("task_status", str); + paramsPost.put("task_id", ChangLiang.task_id); + paramsPost.put("task_type", ChangLiang.task_type); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appscanlogin_againStart).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + Log.e("需通知后台重新启动", body); + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + + } + }); + } + + + /** + * 当前页面如果有com.bytedance.ies.dmt.ui.widget.DmtTextView,说明是在二级页面运行正常 + */ + public boolean Norma() { + boolean flag = false; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // nodeZuobiao(child); + Rect rect = new Rect(); + child.getBoundsInScreen(rect); + if (rect.left >= 0 && rect.left < 1080) { + // Log.e("TIAOSHI###", "----twoNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // nodeZuobiao(child); + if ("com.bytedance.ies.dmt.ui.widget.DmtTextView".equals(child.getClassName())) { + flag = true; + } + } + } + + return flag; + } + /** + * 当前页面如果有切换账号和管理,说明账号切换任务运行正常 + */ + public boolean ZhongHaoNorma() { + boolean flag = false; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // nodeZuobiao(child); + if ("android.widget.TextView".equals(child.getClassName())) { + if("管理".equals(child.getText().toString())){ + flag = true; + } + + } + + } + + return flag; + } + /** + * 当前页面是否在我的页面 + */ + public boolean wodeNorma() { + boolean flag = false; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(0); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // nodeZuobiao(child); + if ("主页背景图".equals(child.getContentDescription())) { + flag = true; + } + } + return flag; + } + + + public boolean allowed() { + boolean ifOpen = false; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.TextView".equals(child.getClassName())) { + if(child.getText()!=null) { + if (child.getText().toString().contains("正在尝试开启") || child.getText().toString().contains("是否允许")) { + int childCount = root.getChildCount(); + AccessibilityNodeInfo child1 = root.getChild(childCount - 1); + clickNodeInfo(child1, "点击了允许"); + } + } + ifOpen = true; + } + } + return ifOpen; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/abllib/FindViewCountDown.java b/app/src/main/java/com/fisherbone/fuzhu/abllib/FindViewCountDown.java new file mode 100644 index 0000000..ffaff1d --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/abllib/FindViewCountDown.java @@ -0,0 +1,159 @@ +package com.fisherbone.fuzhu.abllib; + +import android.os.CountDownTimer; +import android.view.accessibility.AccessibilityNodeInfo; + +import androidx.annotation.NonNull; + +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; + +/** + * 寻找界面倒计时 + * 2019/4/21 + * 15:21 + * Levine + * wechat 1483232332 + */ +public class FindViewCountDown { + + private static DownTimer mDownTimer; + public static long millisInFuture = 10000;//默认倒计时总时长 + public static long countDownInterval = 500;//间隔时间 + + private static class DownTimer extends CountDownTimer { + + private String[] mMsgViewIdOrText; + private int mStep; + private CallBack mCallback; + + public DownTimer( + long millisInFuture, + long countDownInterval, + int step, CallBack callback, + String... viewIdOrText + ) { + super(millisInFuture, countDownInterval); + mMsgViewIdOrText = viewIdOrText.clone(); + mStep = step; + mCallback = callback; + } + + @Override + public void onTick(long l) { + if (AblStepHandler.getInstance().isStop()) { + cancel(); + return; + } + for (String string : mMsgViewIdOrText) { + AccessibilityNodeInfo fromId = AblViewUtil.findById(string, 0); + AccessibilityNodeInfo fromText = AblViewUtil.findByText(string, 0); + if (fromId != null || fromText != null) { + cancel(); + if (mCallback != null) { + mCallback.succ(); + } else { + AblStepHandler.sendMsg(mStep); + } + return; + } + } + } + + @Override + public void onFinish() { + if (mCallback != null) mCallback.fail(); + } + } + + public interface CallBack { + void succ(); + + default void fail() { + } + } + + /** + * 根据viewid或文字发送执行消息 + * + * @param millisInFuture view查找超时时间 + * @param countDownInterval 查找间隔时间 + * @param step 步骤 + * @param viewIdOrText viewid或者文字内容 + */ + public static void start( + long millisInFuture, + long countDownInterval, + int step, + String... viewIdOrText + ) { + start(millisInFuture, countDownInterval, step, null, viewIdOrText); + } + + /** + * 根据viewid或文字发送执行消息 + * + * @param millisInFuture view查找超时时间 + * @param countDownInterval 查找间隔时间 + * @param callBack 回调,注:如果回调不为空将不发送消息,要发送消息就自己在成功的回调里发送 + * @param viewIdOrText viewid或者文字内容 + */ + public static void start( + long millisInFuture, + long countDownInterval, + @NonNull CallBack callBack, + String... viewIdOrText + ) { + start(millisInFuture, countDownInterval, 0, callBack, viewIdOrText); + } + + /** + * 根据viewid或文字发送执行消息 + * + * @param callBack 回调,注:如果回调不为空将不发送消息,要发送消息就自己在成功的回调里发送 + * @param viewIdOrText viewid或者文字内容 + */ + public static void start( + @NonNull CallBack callBack, + String... viewIdOrText + ) { + start(millisInFuture, countDownInterval, 0, callBack, viewIdOrText); + } + + /** + * 根据viewid或文字发送执行消息 + * + * @param step 步骤 + * @param viewIdOrText viewid或者文字内容 + */ + public static void start( + int step, + String... viewIdOrText + ) { + start(millisInFuture, countDownInterval, step, null, viewIdOrText); + } + + /** + * 根据viewid或文字发送执行消息 + * + * @param millisInFuture view查找超时时间 + * @param countDownInterval 查找间隔时间 + * @param step 步骤 + * @param callBack 回调,注:如果回调不为空将不发送消息,要发送消息就自己在成功的回调里发送 + * @param viewIdOrText viewid或者文字内容 + */ + private static void start( + long millisInFuture, + long countDownInterval, + int step, + CallBack callBack, + String... viewIdOrText + ) { + if (mDownTimer != null) mDownTimer.cancel(); + mDownTimer = new DownTimer(millisInFuture, countDownInterval, step, callBack, viewIdOrText); + mDownTimer.start(); + } + + public static DownTimer getDownTimer() { + return mDownTimer; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/abllib/Func1.java b/app/src/main/java/com/fisherbone/fuzhu/abllib/Func1.java new file mode 100644 index 0000000..2b8b201 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/abllib/Func1.java @@ -0,0 +1,6 @@ +package com.fisherbone.fuzhu.abllib; + +public interface Func1 { + //把一个结果转为我们需要的一个结果 + R call(T t); +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/abllib/RandumInt.java b/app/src/main/java/com/fisherbone/fuzhu/abllib/RandumInt.java new file mode 100644 index 0000000..524faba --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/abllib/RandumInt.java @@ -0,0 +1,22 @@ +package com.fisherbone.fuzhu.abllib; + +import java.util.Random; + +/*产生一个1~4之间的随机数*/ +public class RandumInt { + public static int getRandumInt4(){ + return new Random().nextInt(4)+1; + } + public static int getRandumInt3(){ + return new Random().nextInt(3)+1; + } + public static int getRandumInt2(){ + return new Random().nextInt(2)+1; + } + public static int getRandumInt10to20(){ + return new Random().nextInt(15)+1; + } + public static int getRandumInt40(){ + return new Random().nextInt(95)+40; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/abllib/callback/AniCallBack.java b/app/src/main/java/com/fisherbone/fuzhu/abllib/callback/AniCallBack.java new file mode 100644 index 0000000..568d86e --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/abllib/callback/AniCallBack.java @@ -0,0 +1,16 @@ +package com.fisherbone.fuzhu.abllib.callback; + +import android.view.accessibility.AccessibilityNodeInfo; + +/** + * 2019/4/21 + * 13:05 + * Levine + * wechat 1483232332 + */ +public interface AniCallBack { + void succ(AccessibilityNodeInfo info); + + default void fail() { + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/abllib/callback/AnisCallBack.java b/app/src/main/java/com/fisherbone/fuzhu/abllib/callback/AnisCallBack.java new file mode 100644 index 0000000..600c079 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/abllib/callback/AnisCallBack.java @@ -0,0 +1,18 @@ +package com.fisherbone.fuzhu.abllib.callback; + +import android.view.accessibility.AccessibilityNodeInfo; + +import java.util.List; + +/** + * 2019/4/21 + * 13:04 + * Levine + * wechat 1483232332 + */ +public interface AnisCallBack { + void succ(List infos); + + default void fail() { + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/abllib/callback/GestureCallBack.java b/app/src/main/java/com/fisherbone/fuzhu/abllib/callback/GestureCallBack.java new file mode 100644 index 0000000..3384140 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/abllib/callback/GestureCallBack.java @@ -0,0 +1,15 @@ +package com.fisherbone.fuzhu.abllib.callback; + +import android.accessibilityservice.GestureDescription; + +/** + * 2019/4/21 + * 13:20 + * Levine + * wechat 1483232332 + */ +public interface GestureCallBack { + void succ(GestureDescription gestureDescription); + + void fail(GestureDescription gestureDescription); +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/abllib/utils/AblUtil.java b/app/src/main/java/com/fisherbone/fuzhu/abllib/utils/AblUtil.java new file mode 100644 index 0000000..96c3987 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/abllib/utils/AblUtil.java @@ -0,0 +1,267 @@ +package com.fisherbone.fuzhu.abllib.utils; + +import android.Manifest; +import android.app.Activity; +import android.app.ActivityManager; +import android.content.Context; +import android.content.Intent; +import android.graphics.PixelFormat; +import android.net.Uri; +import android.os.Build; +import android.provider.Settings; +import android.util.Log; +import android.view.Gravity; +import android.view.View; +import android.view.ViewGroup; +import android.view.WindowManager; +import android.widget.Toast; + +import com.blankj.utilcode.util.LogUtils; +import com.blankj.utilcode.util.ToastUtils; +import com.fisherbone.fuzhu.FZConfig; +import com.fisherbone.fuzhu.abllib.AblConfig; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.entity.addWinEntity; +import com.fisherbone.fuzhu.utils.DeviceUtils; +import com.fisherbone.fuzhu.utils.SPUtils; +import com.lzy.okgo.OkGo; +import com.lzy.okgo.model.HttpParams; +import com.tbruyelle.rxpermissions2.RxPermissions; + +import java.security.NoSuchAlgorithmException; +import java.util.List; + +import io.reactivex.disposables.Disposable; + +import static com.blankj.utilcode.util.ActivityUtils.startActivity; + +/** + * 2019/4/21 + * 18:21 + * Levine + * wechat 1483232332 + */ +public class AblUtil { + + /** + * 添加悬浮界面 + * + * @param context + * @param view + */ + public static void addSuspensionWindowView(Context context, View view) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (Settings.canDrawOverlays(context)) { + if(!addWinEntity.isopen){ + Log.e("TIAOSHI###", "temp7"); + addSuspensionView(context, view); + Log.e("TIAOSHI###", "temp8"); + addWinEntity.isopen=true; + } + + } else { + ToastUtils.showShort("请先开启允许显示在其他应用上权限"); + AblUtil.openDrawOverlaysAnth(context); + } + } else { + addSuspensionView(context, view); + } + } + + /** + * 添加悬浮界面(取关) + * + * @param context + * @param view + */ + public static void addSuspensionWindowViewtwo(Context context, View view) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (Settings.canDrawOverlays(context)) { + addSuspensionView(context, view); + addWinEntity.cancleisopen=true; + } else { + ToastUtils.showShort("请先开启允许显示在其他应用上权限"); + AblUtil.openDrawOverlaysAnth(context); + } + } else { + addSuspensionView(context, view); + } + } + + /** + * 添加悬浮界面 + * + * @param context + * @param view + */ + private static void addSuspensionView(Context context, View view) { + WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); + WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; + } else { + layoutParams.type = WindowManager.LayoutParams.TYPE_PHONE; + } + layoutParams.format = PixelFormat.TRANSLUCENT;// 支持透明 + layoutParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;// 焦点 + layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;//窗口的宽和高 + layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; + layoutParams.x = 0;//窗口位置的偏移量 + layoutParams.y = -500; + layoutParams.gravity = Gravity.LEFT; + windowManager.addView(view, layoutParams);//添加窗口 + } + + + /** + * 添加底部悬浮界面 + * + * @param context + * @param view + */ + public static void addSuWindowView(Context context, View view) { + showFloatingWindow(context, view); + } + + /** + * 添加底部悬浮界面 + * + * @param context + * @param view + */ + private static void showFloatingWindow(Context context, View view) { + if (Settings.canDrawOverlays(context)) { + // 获取WindowManager服务 + WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); + // 根据android版本设置悬浮窗类型 + WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; + layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; + } else { + layoutParams.type = WindowManager.LayoutParams.TYPE_PHONE; + } + + // layoutParams.format = PixelFormat.RGBA_8888; + layoutParams.format = PixelFormat.TRANSLUCENT;// 支持透明 + layoutParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;// 焦点 + //设置大小 + layoutParams.width = 300; + layoutParams.height = 100; + + //设置位置 + layoutParams.x = 0; + layoutParams.y = 688; + + // 将悬浮窗控件添加到WindowManager + windowManager.addView(view, layoutParams); + } + } + + + + /** + * 打开悬浮窗授权界面 + * + * @param context + */ + public static void openDrawOverlaysAnth(Context context) { + Intent intent = new Intent( + Settings.ACTION_MANAGE_OVERLAY_PERMISSION, + Uri.parse("package:" + context.getPackageName()) + ); + context.startActivity(intent); + } + + /** + * 检查是否是需要监听的APP包名 + * + * @param thisPackageName APP包名 + * @return + */ + public static boolean checkPackageName(String thisPackageName) { + if (AblConfig.sMonitoringPackageNames != null && AblConfig.sMonitoringPackageNames.length > 0) { + for (String packageName : AblConfig.sMonitoringPackageNames) { + if (packageName.contentEquals(thisPackageName)) { + return true; + } + } + return false; + } + return true; + } + + /** + * 打开无障碍服务设置 + */ + public static void openAccessibilitySettings() { + Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS); + startActivity(intent); + } + + /** + * 辅助服务是否开启 + * + * @return + */ + public static boolean isAccessibilityServiceOpen(Context context) { + ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); + List services = am.getRunningServices(Short.MAX_VALUE); + for (ActivityManager.RunningServiceInfo info : services) { + LogUtils.v(info.service.getClassName()); + if (info.service.getClassName().equals(AblService.class.getName())) { + return true; + } + } + return false; + } + + public static void getPermissions(Context context) { + + + RxPermissions rxPermissions = new RxPermissions((Activity) context); + rxPermissions.request(Manifest.permission.READ_PHONE_STATE,Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.READ_EXTERNAL_STORAGE) + .subscribe(new io.reactivex.Observer() { + @Override + public void onSubscribe(Disposable d) { + + } + + @Override + public void onNext(Boolean aBoolean) { + if (aBoolean) { + String device_id = (String) SPUtils.getSp(context, FZConfig.KEY_DEVICE_ID, ""); + Log.e("设备imei为sp:", device_id);//小米8==548ec01ca14763927b10defb19371f81 + if(device_id.equals("")) { + String imei = DeviceUtils.getIMEI(context); + try { + String s = DeviceUtils.toMD5(imei); + Log.e("设备imei为:", s);//小米8==548ec01ca14763927b10defb19371f81 + //红米7a==7228bdb66fed66c60d961e30a9dc06d3 + SPUtils.setSP(context, FZConfig.KEY_DEVICE_ID, s); + OkGo.getInstance().addCommonParams(new HttpParams("device_id", s)); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + } + //红米7a==865367043276309 + } else { + Toast.makeText(context, "获取权限失败,请重新授权",Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onError(Throwable e) { + + } + + @Override + public void onComplete() { + + } + }); + } + + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/abllib/utils/AblViewUtil.java b/app/src/main/java/com/fisherbone/fuzhu/abllib/utils/AblViewUtil.java new file mode 100644 index 0000000..379425f --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/abllib/utils/AblViewUtil.java @@ -0,0 +1,540 @@ +package com.fisherbone.fuzhu.abllib.utils; + +import android.accessibilityservice.AccessibilityService; +import android.accessibilityservice.GestureDescription; +import android.annotation.TargetApi; +import android.content.ClipData; +import android.content.ClipboardManager; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.graphics.Path; +import android.graphics.Rect; +import android.os.Build; +import android.os.Bundle; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import androidx.annotation.Nullable; +import androidx.annotation.RequiresApi; + +import com.blankj.utilcode.util.ScreenUtils; +import com.fisherbone.fuzhu.FuzhuApplication; +import com.fisherbone.fuzhu.InfoMessage; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.callback.AniCallBack; +import com.fisherbone.fuzhu.abllib.callback.AnisCallBack; +import com.fisherbone.fuzhu.abllib.callback.GestureCallBack; + +import java.util.ArrayList; +import java.util.List; + +import static android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_BACK; +import static android.content.Context.CLIPBOARD_SERVICE; + +/** + * 界面操作工具类 + * wechat 1483232332 + */ +public class AblViewUtil { + private static InfoMessage infoMessag; + /** + * 根据id获取view + * + * @param parent + * @param id 界面id + * @param position + * @return + */ + public static AccessibilityNodeInfo findById( + AccessibilityNodeInfo parent, + String id, + int position, + @Nullable AniCallBack callBack + ) { + if (parent != null) { + List accessibilityNodeInfos = + parent.findAccessibilityNodeInfosByViewId(id); + if (accessibilityNodeInfos != null && + !accessibilityNodeInfos.isEmpty() && + position < accessibilityNodeInfos.size()) { + if (callBack != null) { + callBack.succ(accessibilityNodeInfos.get(position)); + } + return accessibilityNodeInfos.get(position); + } + } + if (callBack != null) { + callBack.fail(); + } + return null; + } + + public static AccessibilityNodeInfo findById( + AccessibilityNodeInfo parent, + String id, + int position + ) { + return findById(parent, id, position, null); + } + + public static AccessibilityNodeInfo findById(String id, int position) { + return findById(AblService.getInstance().getRootInActiveWindow(), id, position, null); + } + + public static AccessibilityNodeInfo findById(String id, int position, AniCallBack callBack) { + return findById(AblService.getInstance().getRootInActiveWindow(), id, position, callBack); + } + + public static List findById( + AccessibilityNodeInfo parent, + String id, + @Nullable AnisCallBack anisCallBack + ) { + if (parent != null) { + List accessibilityNodeInfos = + parent.findAccessibilityNodeInfosByViewId(id); + if (accessibilityNodeInfos != null && + !accessibilityNodeInfos.isEmpty()) { + if (anisCallBack != null) anisCallBack.succ(accessibilityNodeInfos); + return accessibilityNodeInfos; + } + } + if (anisCallBack != null) anisCallBack.fail(); + return new ArrayList<>(); + } + + public static List findById( + AccessibilityNodeInfo parent, + String id + ) { + return findById(parent, id, null); + } + + public static List findById(String id) { + return findById(AblService.getInstance().getRootInActiveWindow(), id, null); + } + + public static List findById(String id, AnisCallBack anisCallBack) { + return findById(AblService.getInstance().getRootInActiveWindow(), id, anisCallBack); + } + + /** + * 根据文本获取view + * + * @param parent + * @param text + * @param position + * @return + */ + public static AccessibilityNodeInfo findByText(AccessibilityNodeInfo parent, String text, int position) { + if (parent != null) { + List accessibilityNodeInfos = + parent.findAccessibilityNodeInfosByText(text); + if (accessibilityNodeInfos != null && + !accessibilityNodeInfos.isEmpty() && + position < accessibilityNodeInfos.size()) { + return accessibilityNodeInfos.get(position); + } + } + return null; + } + + public static AccessibilityNodeInfo findByText(String text, int position) { + return findByText(AblService.getInstance().getRootInActiveWindow(), text, position); + } + + public static List findByText(AccessibilityNodeInfo parent, String text) { + if (parent != null) { + List accessibilityNodeInfos = + parent.findAccessibilityNodeInfosByText(text); + if (accessibilityNodeInfos != null && + !accessibilityNodeInfos.isEmpty()) { + return accessibilityNodeInfos; + } + } + return new ArrayList<>(); + } + + public static List findByText(String text) { + return findByText(AblService.getInstance().getRootInActiveWindow(), text); + } + + /** + * 手势模拟 + * + * @param start_position 开始位置,长度为2的数组,下标0为x轴,下标1为y轴 + * @param end_position + * @param startTime 开始间隔时间 + * @param duration 持续时间 + * @param callback 回调 + */ + @TargetApi(Build.VERSION_CODES.N) + public static void dispatch_gesture( + float[] start_position, + float[] end_position, + long startTime, + long duration, + @Nullable GestureCallBack callback + ) { + Path path = new Path(); + path.moveTo(start_position[0], start_position[1]); + path.lineTo(end_position[0], end_position[1]); + GestureDescription.Builder builder = new GestureDescription.Builder(); + GestureDescription.StrokeDescription strokeDescription = + new GestureDescription.StrokeDescription(path, startTime, duration); + GestureDescription gestureDescription = builder.addStroke(strokeDescription).build(); + AblService.getInstance().dispatchGesture(gestureDescription, new AccessibilityService.GestureResultCallback() { + @Override + public void onCompleted(GestureDescription gestureDescription) { + if (callback != null) callback.succ(gestureDescription); + } + + @Override + public void onCancelled(GestureDescription gestureDescription) { + if (callback != null) callback.fail(gestureDescription); + } + }, null); + } + + /** + * x轴居中竖直滑动屏幕 + * + * @param yRatio y轴份数 + * @param startSlideRatio y轴开始的份数 + * @param stopSlideRatio y轴结束的份数 + */ + public static void scrollVertical( + int yRatio, + int startSlideRatio, + int stopSlideRatio, + long startTime, + long duration, + @Nullable GestureCallBack callback + ) { + int screenHeight = ScreenUtils.getScreenHeight(); + int screenWidth = ScreenUtils.getScreenWidth(); + int start = (screenHeight / yRatio) * startSlideRatio; + int stop = (screenHeight / yRatio) * stopSlideRatio; + dispatch_gesture( + new float[]{screenWidth >> 1, start}, + new float[]{screenWidth >> 1, stop}, + startTime, + duration, + callback + ); + + } + + /** + * 竖直滑动,y轴分为20份 + * + * @param startSlideRatio 开始份数 + * @param stopSlideRatio 结束份数 + */ + public static void scrollVertical( + int startSlideRatio, + int stopSlideRatio + ) { + int screenHeight = ScreenUtils.getScreenHeight(); + int screenWidth = ScreenUtils.getScreenWidth(); + int start = (screenHeight / 20) * startSlideRatio; + int stop = (screenHeight / 20) * stopSlideRatio; + dispatch_gesture( + new float[]{screenWidth >> 1, start}, + new float[]{screenWidth >> 1, stop}, + 50, + 500, + null + ); + + } + + /** + * x轴居中竖直滑动屏幕 + * + * @param startY y轴开始位置 + * @param stopY y轴结束位置 + */ + public static void scrollVertical( + float startY, + float stopY, + long startTime, + long duration, + @Nullable GestureCallBack callback + ) { + int screenWidth = ScreenUtils.getScreenWidth(); + dispatch_gesture( + new float[]{screenWidth >> 1, startY}, + new float[]{screenWidth >> 1, stopY}, + startTime, + duration, + callback + ); + + } + + + /** + * y轴居中横向滑动 + * + * @param xRatio x轴份数 + * @param startSlideRatio x轴开始滑动份数 + * @param stopSlideRatio x轴结束滑动份数 + * @param startTime 开始延迟时间 + * @param duration 滑动持续时间 + * @param callback 回调 + */ + public void scrollHorizontal( + int xRatio, + int startSlideRatio, + int stopSlideRatio, + long startTime, + long duration, + @Nullable GestureCallBack callback + ) { + int screenHeight = ScreenUtils.getScreenHeight(); + int screenWidth = ScreenUtils.getScreenWidth(); + int start = (screenWidth / xRatio) * startSlideRatio; + int stop = (screenWidth / xRatio) * stopSlideRatio; + dispatch_gesture( + new float[]{start, screenHeight >> 1}, + new float[]{stop, screenHeight >> 1}, + startTime, + duration, + callback + ); + } + + /** + * y轴居中横向滑动 + * + * @param startX x轴开始位置 + * @param stopX x轴结束位置 + * @param startTime 开始延迟时间 + * @param duration 滑动持续时间 + * @param callback 回调 + */ + public static void scrollHorizontal( + int startX, + int stopX, + long startTime, + long duration, + @Nullable GestureCallBack callback + ) { + int screenHeight = ScreenUtils.getScreenHeight(); + dispatch_gesture( + new float[]{startX, screenHeight >> 1}, + new float[]{stopX, screenHeight >> 1}, + startTime, + duration, + callback + ); + } + + /** + * 点击屏幕 + * + * @param ratio 屏幕长宽份数 + * @param xRatio 屏幕宽ratio份的比例 + * @param yRatio + */ + public static void clickScreen( + int ratio, + int xRatio, + int yRatio, + @Nullable GestureCallBack callback + ) { + int screenHeight = ScreenUtils.getScreenHeight(); + int screenWidth = ScreenUtils.getScreenWidth(); + int y = (screenHeight / ratio) * yRatio; + int x = (screenWidth / ratio) * xRatio; + dispatch_gesture( + new float[]{x, y}, + new float[]{x, y}, + 100, + 50, + callback + ); + } + + /** + * 点击屏幕 + */ + public static void clickScreen( + int xRatio, + int yRatio + ) { + int screenHeight = ScreenUtils.getScreenHeight(); + int screenWidth = ScreenUtils.getScreenWidth(); + int y = (screenHeight / 20) * yRatio; + int x = (screenWidth / 20) * xRatio; + dispatch_gesture( + new float[]{x, y}, + new float[]{x, y}, + 100, + 50, + null + ); + } + + /** + * 点击屏幕 + * + * @param x x轴像素 + * @param y + * @param startTime 开始间隔时间 + * @param duration 持续时间 + */ + public static void clickScreen( + float x, + float y, + long startTime, + long duration, + @Nullable GestureCallBack callback + ) { + dispatch_gesture( + new float[]{x, y}, + new float[]{x, y}, + startTime, + duration, + callback + ); + } + + /** + * 返回 + */ + public static void back() { + AblService.getInstance().performGlobalAction(GLOBAL_ACTION_BACK); + } + + + /** + * 黏贴文本至view + * + * @param info + * @param text + */ + public static void paste(AccessibilityNodeInfo info, String text) { + ClipData clip = ClipData.newPlainText(System.currentTimeMillis() + "", text); + ClipboardManager clipboardManager = (ClipboardManager) AblService.getInstance().getSystemService(CLIPBOARD_SERVICE); + assert clipboardManager != null; + clipboardManager.setPrimaryClip(clip); + ClipData abc = clipboardManager.getPrimaryClip(); + assert abc != null; + ClipData.Item item = abc.getItemAt(0); + if (info != null) info.performAction(AccessibilityNodeInfo.ACTION_PASTE); + } + + + /** + * 具体的说话方法 + * + * @param text + * @param node + */ + public static void sayInput(String text, AccessibilityNodeInfo node) { + if(node!=null) { + if ("android.widget.EditText".equals(node.getClassName())) { + Log.e("TIAOSHI###", "要说的话:.." + text); + Bundle arguments = new Bundle(); + arguments.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, text); + node.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments); + } + } + + } + + + /** + * @param + * @return + * @description 开启app + */ + @RequiresApi(api = Build.VERSION_CODES.N) + public static void startApplication() { + startApplicationtwo(FuzhuApplication.getContext(), "com.ss.android.ugc.aweme"); + } + + public static void startApplicationtwo(Context ctx, String pkName) { + PackageManager packageManager = ctx.getPackageManager(); + Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null); + resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER); + resolveIntent.setPackage(pkName); + List apps = packageManager.queryIntentActivities(resolveIntent, 0); + ResolveInfo ri = apps.iterator().next(); + if (ri != null) { + String packageName = ri.activityInfo.packageName; + String className = ri.activityInfo.name; + Intent intent = new Intent(Intent.ACTION_MAIN); + intent.addCategory(Intent.CATEGORY_LAUNCHER); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + ComponentName cn = new ComponentName(packageName, className); + intent.setComponent(cn); + ctx.startActivity(intent); + } + } + + + public static void mySleep(int i) { + try { + Thread.sleep(i * 1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + + /** + * + + * @param nikename 方法内字符串变量 + * @param child1 + * @param numt 上坐标点 + * @param numb 下坐标点 + * @param numl 左坐标点 + * @param numr 右坐标点 + * @param classStr 节点的包名 + * @return + */ + public static String getString(String nikename, AccessibilityNodeInfo child1, int numt, int numb, int numl, int numr, String classStr) { + Rect rect = new Rect(); + child1.getBoundsInScreen(rect); + if (rect.top >= numt && rect.bottom <= numb&&rect.left>=numl&&rect.right<=numr) { + Log.e("TIAOSHI###", "----RectNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if (classStr.equals(child1.getClassName())) { + if (child1.getText() != null) { + nikename = child1.getText().toString(); + } + } + } + return nikename; + } + + + public void rigist(InfoMessage infoMessag){ + this.infoMessag=infoMessag; + } + public static void onMessage(String str){ + infoMessag.mesagesuccess(str); + } + + public static void mesagefinish(String str){ + infoMessag.mesagefinish(str); + } + + + public static void zhuanghaoMessage(String str){ + infoMessag.mesagezhuang(str); + } + + public static void potfinish(String id,String str,String type){ + infoMessag.potfinish(id,str,type); + } + public static void potgegin(String str){ + infoMessag.potgegin(str); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/AppointActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/AppointActivity.java new file mode 100644 index 0000000..058e6c9 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/AppointActivity.java @@ -0,0 +1,79 @@ +package com.fisherbone.fuzhu.activity; + +import android.os.Bundle; +import android.view.View; + +import androidx.databinding.DataBindingUtil; + +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.databinding.ActivityAppointBinding; +import com.fisherbone.fuzhu.entity.AppoBean; +import com.fisherbone.fuzhu.entity.AppointBean; +import com.fisherbone.fuzhu.entity.FourEvent; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.fisherbone.fuzhu.utils.JsonUtils; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.fisherbone.fuzhu.utils.ToastUtils; +import com.fisherbone.fuzhu.widget.TitleBar; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; + +import java.util.List; + +import de.greenrobot.event.EventBus; + +public class AppointActivity extends BaseActivity { + + private TitleBar mTitleBar; + private ActivityAppointBinding binding; + private AppointBean appointBean; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + binding = DataBindingUtil.setContentView(this, R.layout.activity_appoint); + appointBean = ProfileSpUtils.getInstance().getAppointBean(); + binding.setAppointBean(appointBean); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("关注指定直播间"); + initNormalBack(); + binding.appRlStart.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ProfileSpUtils.getInstance().saveAppointBean(appointBean); + if(binding.appSwitch1.isChecked()) { + EventBus.getDefault().post(new FourEvent("success", "8")); + }else { + //随机直播间加关注 + EventBus.getDefault().post(new FourEvent("success", "9")); + } + } + }); + //获得数据 + getData(); + } + + private void getData() { + final HttpParams paramsPost = new HttpParams(); + //抖音号 + // paramsPost.put("short_id", ChangLiang.short_id); + paramsPost.put("short_id", "178421572"); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_LiveRoom).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + AppoBean appoBean = JsonUtils.fromJson(body, AppoBean.class); + ProfileSpUtils.getInstance().saveAppoBean(appoBean); + List data = appoBean.getData(); + ToastUtils.showToast(AppointActivity.this,appoBean.getMsg()); + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/BaseMoActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/BaseMoActivity.java new file mode 100644 index 0000000..a59ffd2 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/BaseMoActivity.java @@ -0,0 +1,148 @@ +package com.fisherbone.fuzhu.activity; + +import android.annotation.SuppressLint; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.recyclerview.widget.RecyclerView; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.entity.Savaselect; + +import java.util.List; + +public abstract class BaseMoActivity extends BaseActivity { + + public static final String ARG_PAGE = "ARG_PAGE"; + private boolean IS_LOADED = false; + private static int mSerial = 0; + private boolean isFirst = true; + @SuppressLint("HandlerLeak") + private Handler handler = new Handler() { + public void handleMessage(Message msg) { + Log.e("tag", "IS_LOADED=" + IS_LOADED); + if (!IS_LOADED) { + IS_LOADED = true; + //请求我的客户已流失数据 + requesdata(); + } + return; + } + + }; + public Savaselect savaselectbean; + private RelativeLayout rl_top; + private RelativeLayout layTop_left_tv; + public BaseQuickAdapter markingtwoAdapter; + public void sendMessage() { + Message message = handler.obtainMessage(); + message.sendToTarget(); + } + + private String uid; + public RecyclerView mMarkingFragmentRecyclerView; + public SwipeRefreshLayout mSwl; + public int mNextRequestPage = 1; + private static final int PAGE_SIZE = 10; + View view; + public View notDataView; + public View errorView; + public TextView mLayTopTitle; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_mo); + initView(view); + //设置页和当前页一致时加载,防止预加载 + if (isFirst) { + isFirst = false; + sendMessage(); + } + } + + private void initView(View mContentView) { + mMarkingFragmentRecyclerView = (RecyclerView) findViewById(R.id.marking_fragment_recyclerView); + mSwl = findViewById(R.id.srl); + notDataView = this.getLayoutInflater().inflate(R.layout.empty_view, (ViewGroup) mMarkingFragmentRecyclerView.getParent(), false); + notDataView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // refresh(); + } + }); + errorView = this.getLayoutInflater().inflate(R.layout.error_view, (ViewGroup) mMarkingFragmentRecyclerView.getParent(), false); + errorView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // onRefresh(); + } + }); + + } + + public void requesdata() { + initAdapter(); + initRefreshLayout(); + mSwl.setRefreshing(true); + refresh(); + } + + public abstract void initAdapter(); + + + private void initRefreshLayout() { + mSwl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + refresh(); + } + }); + } + + private void refresh() { + mNextRequestPage = 1; + // markingtwoAdapter.setEnableLoadMore(false);//这里的作用是防止下拉刷新的时候还可以上拉加载 + requestData(); + } + + public void loadMore() { + requestData(); + } + + public void setData(boolean isRefresh, List data) { + mNextRequestPage++; + final int size = data == null ? 0 : data.size(); + if (isRefresh) { + markingtwoAdapter.setNewData(data); + } else { + if (size > 0) { + markingtwoAdapter.addData(data); + } + } + if (size < PAGE_SIZE) { + //第一页如果不够一页就不显示没有更多数据布局 + markingtwoAdapter.loadMoreEnd(isRefresh); + } else { + markingtwoAdapter.loadMoreComplete(); + } + } + public abstract void requestData(); + + public void getAdpter(BaseQuickAdapter markingtwoAdapter){ + this.markingtwoAdapter=markingtwoAdapter; + } + @Override + public void onDestroy() { + super.onDestroy(); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/CancleFollowActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/CancleFollowActivity.java new file mode 100644 index 0000000..23ccae2 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/CancleFollowActivity.java @@ -0,0 +1,114 @@ +package com.fisherbone.fuzhu.activity; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.CompoundButton; + +import androidx.databinding.DataBindingUtil; + +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.databinding.ActivityCancleFollowBinding; +import com.fisherbone.fuzhu.entity.CancleFollowBean; +import com.fisherbone.fuzhu.entity.FourEvent; +import com.fisherbone.fuzhu.entity.addWinEntity; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.fisherbone.fuzhu.utils.StringUtils; +import com.fisherbone.fuzhu.widget.TitleBar; + +import de.greenrobot.event.EventBus; + +/** + * 一键取关 + */ +public class CancleFollowActivity extends BaseActivity { + private ActivityCancleFollowBinding binding; + private TitleBar mTitleBar; + private CancleFollowBean cancleFollowBean; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + binding = DataBindingUtil.setContentView(this, R.layout.activity_cancle_follow); + cancleFollowBean = ProfileSpUtils.getInstance().getCan(); + binding.setCanclefollowbean(cancleFollowBean); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("一键取关"); + initNormalBack(); + binding.radioButton01.setChecked(true); + cancleFollowBean.setCancelclosed(true); + binding.radioButton02.setChecked(false); + cancleFollowBean.setCancelcrosscor(false); + + binding.radioButton01.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + cancleFollowBean.setCancelclosed(b); + } + }); + binding.radioButton02.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + cancleFollowBean.setCancelcrosscor(b); + } + }); + + binding.rlStart.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Log.e("TIAOSHI###==发送的一键取关参数", cancleFollowBean.toString()); + //将参数数据缓存起来 + ChangLiang.cancelclosed = cancleFollowBean.getCancelclosed(); + ChangLiang.cancelcrosscor = cancleFollowBean.getCancelcrosscor(); + ChangLiang.passnumber = cancleFollowBean.getPassnumber(); + ChangLiang.swiinterval = cancleFollowBean.getSwiinterval(); + ChangLiang.minthrthr = cancleFollowBean.getMinthrthr(); + ChangLiang.minfans = cancleFollowBean.getMinfans(); + //存储参数信息 + ProfileSpUtils.getInstance().saveCan(cancleFollowBean); + if (StringUtils.isEmpty(cancleFollowBean.getPassnumber())) { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(CancleFollowActivity.this, "请输入取关数"); + return; + } + if (StringUtils.isEmpty(cancleFollowBean.getSwiinterval())) { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(CancleFollowActivity.this, "请输入取关间隔"); + return; + } + if (cancleFollowBean.getCancelclosed()) { + if (StringUtils.isEmpty(cancleFollowBean.getMinthrthr())) { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(CancleFollowActivity.this, "请输入最小开始取关数"); + return; + } + } + if (cancleFollowBean.getCancelcrosscor()) { + if (StringUtils.isEmpty(cancleFollowBean.getMinfans())) { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(CancleFollowActivity.this, "请输入互关保留粉丝数"); + return; + } + } + + if(!addWinEntity.cancleisopen){ + //下面两个步骤不能同时执行 + //取消已关 + if (ChangLiang.cancelclosed&&!ChangLiang.cancelcrosscor) { + Log.e("TIAOSHI###==发送的一键取关参数", "执行取消已关"); + EventBus.getDefault().post(new FourEvent("success","2")); + + } + //取消互关 + if (ChangLiang.cancelcrosscor&&!ChangLiang.cancelclosed) { + Log.e("TIAOSHI###==发送的一键取关参数", "执行取消互关"); + EventBus.getDefault().post(new FourEvent("success","2")); + } + + if(ChangLiang.cancelclosed&&ChangLiang.cancelcrosscor){ + Log.e("TIAOSHI###==发送的一键取关参数", "执行取消互关"); + EventBus.getDefault().post(new FourEvent("success","2")); + } + } + } + }); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/ControlWindow.java b/app/src/main/java/com/fisherbone/fuzhu/activity/ControlWindow.java new file mode 100644 index 0000000..8142b37 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/ControlWindow.java @@ -0,0 +1,351 @@ +package com.fisherbone.fuzhu.activity; + +import android.content.Context; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.WindowManager; + +import androidx.databinding.DataBindingUtil; + +import com.blankj.utilcode.util.ToastUtils; +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.utils.AblUtil; +import com.fisherbone.fuzhu.databinding.ViewTestBinding; +import com.fisherbone.fuzhu.entity.ControlBean; +import com.fisherbone.fuzhu.entity.addWinEntity; +import com.fisherbone.fuzhu.step.TestAblStep30; +import com.fisherbone.fuzhu.step.TestAblStep34; +import com.fisherbone.fuzhu.step.TestAblStepXin5; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.jeremyliao.liveeventbus.LiveEventBus; + +/** + * Time: 2021/6/28 + * Author: jianbo + * Description: + */ +public class ControlWindow { + + Context mContext; + private ViewTestBinding binding; + private ControlBean controlBean; + public ControlWindow (Context mContext){ + this.mContext=mContext; + } + private String func_type; + /** + * 显示运行信息 + */ + public void showRunInfo(String str){ + controlBean.setContent(str); + } + /** + * 显示控制系统运行的浮窗 + * + * @return + */ + public View initWindowView( String func_typee) { + this.func_type = func_typee; + LayoutInflater inflater = (LayoutInflater)mContext.getSystemService + (Context.LAYOUT_INFLATER_SERVICE); + binding = DataBindingUtil.inflate(inflater, R.layout.view_test, null, false); + controlBean = new ControlBean(); + controlBean.setContent(""); + controlBean.setPhonetype(Integer.valueOf(ChangLiang.phonetype)); + binding.setControlBean(controlBean); + stutas(true); + binding.image01.setBackgroundResource(R.mipmap.icon_bianzu); + AblStepHandler.getInstance().setStop(false); + //func_type 1:推荐加关,2:一键取关,3:撞号设置 4.登录 5.抢红包 51.粉丝互动 6.大V粉丝截流 7.潜在客户加关 9.粉丝通知 10.直播间加热 12.抢福袋 + switch (func_type) { + case "1": + AblStepHandler.getInstance().initStepClass(new TestAblStepXin5(mContext)); + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_9); + break; + case "2": + if (AblUtil.isAccessibilityServiceOpen(mContext)) { + stutas(ChangLiang.isrun); + if (ChangLiang.cancelclosed && !ChangLiang.cancelcrosscor) { + Log.e("TIAOSHI###", "执行取消关注"); + AblStepHandler.sendMsg(AblSteps.STEP_11); + } + //取消互关 + if (ChangLiang.cancelcrosscor && !ChangLiang.cancelclosed) { + Log.e("TIAOSHI###", "执行取消相互关注"); + AblStepHandler.sendMsg(AblSteps.STEP_15); + } + //取消互关+取消已关 + if (ChangLiang.cancelcrosscor && ChangLiang.cancelclosed) { + Log.e("TIAOSHI###", "执行取消相互关注+取消已关"); + AblStepHandler.sendMsg(AblSteps.STEP_60); + } + } else { + ToastUtils.showShort("点到了"); + ToastUtils.showShort("请先开启辅助服务"); + AblUtil.openAccessibilitySettings(); + } + break; + case "3"://执行幢号任务 + if (ChangLiang.if_quguan.equals("0")) { + stutas(ChangLiang.isrun); + ChangLiang.zishuodong = "T"; + AblStepHandler.sendMsg(AblSteps.STEP_70); + } else { + stutas(ChangLiang.isrun); + ChangLiang.zishuodong = "T"; + AblStepHandler.sendMsg(AblSteps.STEP_70); + } + break; + case "4"://帐号登录任务 + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_90); + break; + //抢红包 + case "5": + AblStepHandler.getInstance().initStepClass(new TestAblStep34(mContext)); + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_249); + break; + //粉丝互动 + case "51": + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_180); + break; + case "6": + AblStepHandler.getInstance().initStepClass(new TestAblStep30()); + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_210); + break; + //大V粉丝截流 + case "61": + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_130); + break; + case "7"://潜在客户加关(大咖) + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_170); + break; + case "8"://潜在客户加关(关键词) + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_160); + break; + case "9"://粉丝通知 + stutas(ChangLiang.isrun); + String lettertype = ProfileSpUtils.getInstance().getFensiNotice().getLettertype(); + Log.e("类型", lettertype); + if (lettertype.equals("1")) { + AblStepHandler.sendMsg(AblSteps.STEP_201); + } else if (lettertype.equals("2")) { + AblStepHandler.sendMsg(AblSteps.STEP_80); + } else { + AblStepHandler.sendMsg(AblSteps.STEP_120); + } + break; + //直播间加热 + case "10": + + break; + //抢福袋 + case "12": + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_221); + break; + //关注指定直播间 + case "13": + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_231); + break; + //随机直播间 + case "14": + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_241); + break; + //直播间抢红包 + case "15": + + break; + default: + Log.e("TIAOSHI###", "执行的功能类型不匹配"); + break; + } + + binding.tv1.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // Log.e("TIAOSHI###", "func_type=="+func_type); + AblStepHandler.getInstance().setStop(false); + switch (func_type) { + case "1": + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_9); + break; + case "2": + if (AblUtil.isAccessibilityServiceOpen(mContext)) { + stutas(ChangLiang.isrun); + if (ChangLiang.cancelclosed && !ChangLiang.cancelcrosscor) { + Log.e("TIAOSHI###", "执行取消关注"); + AblStepHandler.sendMsg(AblSteps.STEP_11); + } + //取消互关 + if (ChangLiang.cancelcrosscor && !ChangLiang.cancelclosed) { + Log.e("TIAOSHI###", "执行取消相互关注"); + AblStepHandler.sendMsg(AblSteps.STEP_15); + } + //取消互关+取消已关 + if (ChangLiang.cancelcrosscor && ChangLiang.cancelclosed) { + Log.e("TIAOSHI###", "执行取消相互关注+取消已关"); + AblStepHandler.sendMsg(AblSteps.STEP_60); + } + } else { + ToastUtils.showShort("点到了"); + ToastUtils.showShort("请先开启辅助服务"); + AblUtil.openAccessibilitySettings(); + } + break; + case "3"://执行幢号任务 + if (ChangLiang.if_quguan.equals("0")) { + stutas(ChangLiang.isrun); + ChangLiang.zishuodong = "T"; + AblStepHandler.sendMsg(AblSteps.STEP_70); + } else { + stutas(ChangLiang.isrun); + ChangLiang.zishuodong = "T"; + AblStepHandler.sendMsg(AblSteps.STEP_70); + } + break; + case "4"://帐号登录任务 + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_90); + break; + case "5"://粉丝互动 + AblStepHandler.getInstance().initStepClass(new TestAblStep34(mContext)); + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_249); + break; + //粉丝互动 + case "51": + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_180); + break; + case "6": + AblStepHandler.getInstance().initStepClass(new TestAblStep30()); + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_210); + break; + //大V粉丝截流 + case "61": + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_130); + break; + case "7"://潜在客户加关(大咖) + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_170); + break; + case "8"://潜在客户加关(关键词) + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_160); + break; + case "9"://粉丝通知 + stutas(ChangLiang.isrun); + String lettertype = ProfileSpUtils.getInstance().getFensiNotice().getLettertype(); + Log.e("类型", lettertype); + if (lettertype.equals("1")) { + AblStepHandler.sendMsg(AblSteps.STEP_201); + } else if (lettertype.equals("2")) { + AblStepHandler.sendMsg(AblSteps.STEP_80); + } else { + AblStepHandler.sendMsg(AblSteps.STEP_120); + } + break; + case "10"://直播间加热 + AblStepHandler.getInstance().initStepClass(new TestAblStep30()); + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_210); + break; + case "12"://抢福袋 + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_221); + break; + case "13"://关注指定直播间 + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_231); + break; + case "14"://随机直播间 + stutas(ChangLiang.isrun); + AblStepHandler.sendMsg(AblSteps.STEP_241); + break; + case "15"://直播间抢红包 + + break; + default: + Log.e("TIAOSHI###", "执行的功能类型不匹配"); + break; + } + + } + }); + binding.tv2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + stutas(ChangLiang.isrun); + Log.e("TIAOSHI###", "停止服务"); + AblStepHandler.getInstance().setStop(true); + ChangLiang.short_id="";// 当前执行任务抖音id + ChangLiang.task_id="";//当前执行任务id + ChangLiang.id="";//当前执行任务功能id + ChangLiang.task_type="";//当前执行任务类型 + LiveEventBus.get("closedtime").post(""); + } + }); + binding.tv4.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); + windowManager.removeView(binding.getRoot()); + addWinEntity.isopen = false; + } + }); + binding.rl04.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //缩小浮窗 + if (ChangLiang.isopoen) { + binding.rlAt.setVisibility(View.GONE); + binding.image01.setBackgroundResource(R.mipmap.icon_open); + ChangLiang.isopoen = false; + } else { + binding.rlAt.setVisibility(View.VISIBLE); + binding.image01.setBackgroundResource(R.mipmap.icon_bianzu); + ChangLiang.isopoen = true; + } + } + }); + return binding.getRoot(); + } + + public void stutas(boolean isrun) { + if (isrun) { + binding.tv1.setVisibility(View.VISIBLE); + binding.tv2.setVisibility(View.GONE);; + ChangLiang.isrun = false; + } else { + binding.tv1.setVisibility(View.GONE); + binding.tv2.setVisibility(View.VISIBLE); + ChangLiang.isrun = true; + } + } + + /** + * 退出悬浮窗 + */ + public void closedWin(){ + WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); + windowManager.removeView(binding.getRoot()); + addWinEntity.isopen = false; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/DakaActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/DakaActivity.java new file mode 100644 index 0000000..bddd777 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/DakaActivity.java @@ -0,0 +1,188 @@ +package com.fisherbone.fuzhu.activity; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.adapter.DakaAdapter; +import com.fisherbone.fuzhu.entity.AddDakaBeanData; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.fisherbone.fuzhu.utils.ToastUtils; +import com.fisherbone.fuzhu.widget.TitleBar; +import com.google.gson.Gson; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + + +/** + * 新建大咖页面 + */ +public class DakaActivity extends BaseActivity { + + private RecyclerView mRecyclerView; + private DakaAdapter headerAndFooterAdapter; + private List statuses; + private TitleBar mTitleBar; + private String type="1";//1:大咖,2:视频关键词 + private EditText et_coneten; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_prilet); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("新建大咖"); + initNormalBack(); + mTitleBar.visibleTvRightTextBtn(true); + mTitleBar.setTvRightText("确定"); + type = getIntent().getStringExtra("type"); + mTitleBar.setTvRightTextColor(R.color.color_30B9B6); + mTitleBar.setOnTitleBarAllClickListener(new TitleBar.OnTitleBarAllClickListener() { + @Override + public void onRightTextButtonClick(View view) { + Gson gson = new Gson(); + // ToastUtils.showToast(ScriptSettingActivity.this, s1); + ArrayList strings = new ArrayList<>(); + for(int i=0;i(); + AddDakaBeanData status = new AddDakaBeanData(); + statuses.add(status); + initAdapter(); + View footerView = getFooterView(0, new View.OnClickListener() { + @Override + public void onClick(View v) { + // headerAndFooterAdapter.addFooterView(getFooterView(1, getRemoveFooterListener()), 0); + + AddDakaBeanData status = new AddDakaBeanData(); + statuses.add(status); + headerAndFooterAdapter.notifyDataSetChanged(); + int size = statuses.size(); + mRecyclerView.scrollToPosition(size); // 将ListView定位到最后一行 + } + }); + View headView = getHeadView(type, new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }); + headerAndFooterAdapter.addHeaderView(headView,0); + headerAndFooterAdapter.addFooterView(footerView, 0); + mRecyclerView.setAdapter(headerAndFooterAdapter); + } + + private View getFooterView(int type, View.OnClickListener listener) { + View view = getLayoutInflater().inflate(R.layout.footer_prilet_view, (ViewGroup) mRecyclerView.getParent(), false); + if (type == 1) { + ImageView imageView = (ImageView) view.findViewById(R.id.iv); + imageView.setImageResource(R.mipmap.rm_icon); + } + view.setOnClickListener(listener); + return view; + } + private View getHeadView(String type, View.OnClickListener listener) { + View view = getLayoutInflater().inflate(R.layout.head_prilet_view, (ViewGroup) mRecyclerView.getParent(), false); + if (type.equals("1")) { + TextView tv_head = (TextView) view.findViewById(R.id.tv_head); + tv_head.setText("大咖抖音昵称"); + }else { + TextView tv_head = (TextView) view.findViewById(R.id.tv_head); + tv_head.setText("视频关键词"); + } + et_coneten = (EditText)view.findViewById(R.id.et_coneten); + view.setOnClickListener(listener); + return view; + } + + + private View.OnClickListener getRemoveFooterListener() { + return new View.OnClickListener() { + @Override + public void onClick(View v) { + headerAndFooterAdapter.removeFooterView(v); + } + }; + } + + private void initAdapter() { + + headerAndFooterAdapter = new DakaAdapter(statuses); + headerAndFooterAdapter.openLoadAnimation(); + mRecyclerView.setAdapter(headerAndFooterAdapter); + headerAndFooterAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() { + @Override + public void onItemClick(BaseQuickAdapter adapter, View view, int position) { + Toast.makeText(DakaActivity.this, "" + Integer.toString(position), Toast.LENGTH_LONG).show(); + } + }); + } + + + private void addDakaVideo(String s1){ + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("name", et_coneten.getText().toString()); + paramsPost.put("key_name", s1); + paramsPost.put("type", type); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_addDakaVideo).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if(success.equals("0")){ + finish(); + ToastUtils.showToast(DakaActivity.this, msg); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/DavActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/DavActivity.java new file mode 100644 index 0000000..ce7031a --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/DavActivity.java @@ -0,0 +1,130 @@ +package com.fisherbone.fuzhu.activity; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; + +import androidx.databinding.DataBindingUtil; + +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.databinding.ActivityDavBinding; +import com.fisherbone.fuzhu.db.CommentBeanData; +import com.fisherbone.fuzhu.db.dao.CommentDao; +import com.fisherbone.fuzhu.entity.DavBean; +import com.fisherbone.fuzhu.entity.FourEvent; +import com.fisherbone.fuzhu.entity.HusshuBean; +import com.fisherbone.fuzhu.entity.addWinEntity; +import com.fisherbone.fuzhu.utils.GetJsonDataUtil; +import com.fisherbone.fuzhu.utils.JsonUtils; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.fisherbone.fuzhu.utils.StringUtils; +import com.fisherbone.fuzhu.widget.TitleBar; + +import java.util.ArrayList; +import java.util.List; + +import de.greenrobot.event.EventBus; + +/** + * 大V粉丝截流 + */ +public class DavActivity extends BaseActivity { + private ActivityDavBinding binding; + private TitleBar mTitleBar; + private DavBean davCan; + private CommentDao commentDao; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + binding = DataBindingUtil.setContentView(this, R.layout.activity_dav); + davCan = ProfileSpUtils.getInstance().getDavCan(); + binding.setDavbean(davCan); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("大V粉丝截流"); + initNormalBack(); + commentDao = new CommentDao(DavActivity.this); + //给数据库插入十条默认数据 + ArrayList commentBeanData = commentDao.queryAll(); + if(commentBeanData.size()==0) { + Log.e("ceshi","添加了数据"); + madeData(); + } + + binding.rlStart.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + // ToastUtils.showShort("点到了"); + Log.e("TIAOSHI###==发送的dav粉丝截流参数", davCan.toString()); + //将参数数据缓存起来 + ChangLiang.dav_runningtime = davCan.getRunningtime(); + ChangLiang.dav_maxnumcon =davCan.getMaxnumcon(); + ChangLiang.dav_douyinhao =davCan.getDavdouyin(); + ChangLiang.dav_guanjianci =davCan.getGuanjianci(); + ChangLiang.dav_minimumlikes =davCan.getMinimumlikes(); + ChangLiang.dav_minimumcon =davCan.getMinimumcon(); + ChangLiang.dav_minimumzuopin =davCan.getMinimumzuopin(); + ChangLiang.dav_maxmumzuopin =davCan.getMaxmumzuopin(); + ChangLiang.dav_maxmumlikes =davCan.getMaxmumlikes(); + ChangLiang.dav_maximumcon =davCan.getMaximumcon(); + //存储参数信息 + ProfileSpUtils.getInstance().saveDavCan(davCan); + if (StringUtils.isEmpty(davCan.getRunningtime())) { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(DavActivity.this, "运行时长"); + return; + } + if (StringUtils.isEmpty(davCan.getMaxnumcon())) { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(DavActivity.this, "最大关注数"); + return; + } + if (StringUtils.isEmpty(davCan.getMinimumlikes())) { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(DavActivity.this, "最小加关关注数"); + return; + } + if (StringUtils.isEmpty(davCan.getMinimumcon())) { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(DavActivity.this, "最小加关粉丝数"); + return; + } + if (StringUtils.isEmpty(davCan.getMinimumzuopin())) { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(DavActivity.this, "最小作品数"); + return; + } + if (StringUtils.isEmpty(davCan.getMaxmumzuopin())) { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(DavActivity.this, "最大作品数"); + return; + } + if (StringUtils.isEmpty(davCan.getMaxmumlikes())) { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(DavActivity.this, "最大加关关注数"); + return; + } + if (StringUtils.isEmpty(davCan.getMaximumcon())) { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(DavActivity.this, "最大粉丝数"); + return; + } + + if(!addWinEntity.cancleisopen){ + //下面两个步骤不能同时执行 + Log.e("TIAOSHI###==发送的粉丝互动参数", "执行粉丝互动"); + EventBus.getDefault().post(new FourEvent("success","4")); + } + } + }); + } + + + private void madeData() { + String JsonData = new GetJsonDataUtil().getJson(DavActivity.this, "huashu.json");//获取assets目录下的json文件数据 + HusshuBean resultt = JsonUtils.fromJson(JsonData, HusshuBean.class); + List data = resultt.getData(); + for (int i = 0; i < data.size(); i++) { + CommentBeanData commentBeanData = data.get(i); + if (null != commentDao.queryByCustom("Id", commentBeanData.getId()) && commentDao.queryByCustom("Id", commentBeanData.getId()).size() > 0) { + commentDao.updateData(commentBeanData); + } else { + commentDao.addInsert(commentBeanData); + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/HongBaoActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/HongBaoActivity.java new file mode 100644 index 0000000..df7fcd4 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/HongBaoActivity.java @@ -0,0 +1,45 @@ +package com.fisherbone.fuzhu.activity; + +import android.os.Bundle; + +import androidx.databinding.DataBindingUtil; + +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.databinding.ActivityHongBaoBinding; +import com.fisherbone.fuzhu.entity.FourEvent; +import com.fisherbone.fuzhu.entity.RedEnvBean; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.fisherbone.fuzhu.widget.TitleBar; +import com.jakewharton.rxbinding2.view.RxView; + +import java.util.concurrent.TimeUnit; + +import de.greenrobot.event.EventBus; +import io.reactivex.functions.Consumer; + +public class HongBaoActivity extends BaseActivity { + private TitleBar mTitleBar; + private ActivityHongBaoBinding binding; + private RedEnvBean redEnvBean; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + binding = DataBindingUtil.setContentView(this, R.layout.activity_hong_bao); + redEnvBean = ProfileSpUtils.getInstance().getRedEnvBean(); + binding.setRedEnvBean(redEnvBean); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("关注直播间抢抖币"); + initNormalBack(); + RxView.clicks(binding.appRlStart) + .throttleFirst(3, TimeUnit.SECONDS) + .subscribe(new Consumer() { + @Override + public void accept(Object o) throws Exception { + ProfileSpUtils.getInstance().saveRedEnvBean(redEnvBean); + EventBus.getDefault().post(new FourEvent("success", "10")); + } + }); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/InteraActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/InteraActivity.java new file mode 100644 index 0000000..fd500e8 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/InteraActivity.java @@ -0,0 +1,66 @@ +package com.fisherbone.fuzhu.activity; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; + +import androidx.databinding.DataBindingUtil; + +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.databinding.ActivityInteraBinding; +import com.fisherbone.fuzhu.entity.FourEvent; +import com.fisherbone.fuzhu.entity.InteraBean; +import com.fisherbone.fuzhu.entity.addWinEntity; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.fisherbone.fuzhu.utils.StringUtils; +import com.fisherbone.fuzhu.widget.TitleBar; + +import de.greenrobot.event.EventBus; + +/** + * 粉丝互动 + */ +public class InteraActivity extends BaseActivity { + private ActivityInteraBinding binding; + private TitleBar mTitleBar; + private InteraBean fensiCan; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + binding = DataBindingUtil.setContentView(this, R.layout.activity_intera); + fensiCan = ProfileSpUtils.getInstance().getFensiCan(); + binding.setCanclefollowbean(fensiCan); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("粉丝互动"); + initNormalBack(); + + binding.rlStart.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + // ToastUtils.showShort("点到了"); + Log.e("TIAOSHI###==发送的粉丝互动参数", fensiCan.toString()); + //将参数数据缓存起来 + ChangLiang.interaContent = fensiCan.getInteraContent(); + ChangLiang.interanum = fensiCan.getInteranum(); + //存储参数信息 + ProfileSpUtils.getInstance().saveFensiCan(fensiCan); + if (StringUtils.isEmpty(fensiCan.getInteraContent())) { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(InteraActivity.this, "请输入文字内容"); + return; + } + if (StringUtils.isEmpty(fensiCan.getInteranum())) { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(InteraActivity.this, "请输入群发粉丝数"); + return; + } + if(!addWinEntity.cancleisopen){ + //下面两个步骤不能同时执行 + Log.e("TIAOSHI###==发送的粉丝互动参数", "执行粉丝互动"); + EventBus.getDefault().post(new FourEvent("success","3")); + } + } + }); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/KeyWordActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/KeyWordActivity.java new file mode 100644 index 0000000..08de00d --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/KeyWordActivity.java @@ -0,0 +1,294 @@ +package com.fisherbone.fuzhu.activity; + +import android.graphics.Paint; +import android.os.Bundle; +import android.util.Log; +import android.view.View; + +import androidx.databinding.DataBindingUtil; + +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.databinding.ActivityKeywordBinding; +import com.fisherbone.fuzhu.db.KeyWordBean; +import com.fisherbone.fuzhu.db.LetterBean; +import com.fisherbone.fuzhu.entity.PotCusBean; +import com.fisherbone.fuzhu.entity.addWinEntity; +import com.fisherbone.fuzhu.entity.dakaVideoListBean; +import com.fisherbone.fuzhu.entity.letterListBean; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.fisherbone.fuzhu.utils.JsonUtils; +import com.fisherbone.fuzhu.utils.JumpUtils; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.fisherbone.fuzhu.utils.ToastUtils; +import com.fisherbone.fuzhu.widget.TitleBar; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +import de.greenrobot.event.EventBus; + +/** + * 关键词加关 + */ +public class KeyWordActivity extends BaseActivity { + private ActivityKeywordBinding binding; + private TitleBar mTitleBar; + private PotCusBean potCusBean; + private String select="1"; //1是大咖 2是关键词 + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + binding = DataBindingUtil.setContentView(this, R.layout.activity_keyword); + potCusBean = new PotCusBean(); + binding.setCanclefollowbean(potCusBean); + List bigshotData = new ArrayList<>(); + dakaVideoListBean.DataBean bigshotData1 = new dakaVideoListBean.DataBean(); + bigshotData1.setName("地产S姐"); + bigshotData.add(bigshotData1); + potCusBean.setBigshotdatas(bigshotData); + ArrayList keyWordBeans = new ArrayList<>(); + KeyWordBean keyWordBean = new KeyWordBean(); + keyWordBean.setComment("位置"); + keyWordBeans.add(keyWordBean); + KeyWordBean keyWordBean1 = new KeyWordBean(); + keyWordBean1.setComment("楼盘"); + keyWordBeans.add(keyWordBean1); + potCusBean.setKeyworddatas(keyWordBeans); + ArrayList letterBeans = new ArrayList<>(); + LetterBean letterBean = new LetterBean(); + letterBean.setComment("哈哈"); + letterBeans.add(letterBean); + potCusBean.setLetterdatas(letterBeans); + + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("潜在客户加关"); + initNormalBack(); + getdakaVideoNumber(); + menu(); + binding.tvSec01.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + select="1"; + menu(); + potCusBean.setSelect("1"); + } + }); + binding.tvSec03.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + select="2"; + menu(); + potCusBean.setSelect("2"); + } + }); + binding.tvKeyAdd.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线 + binding.tvKeyAdd.getPaint().setAntiAlias(true);//抗锯齿 + binding.tvKeyAdd.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + potCusBean.setSelect("2"); + JumpUtils.gotoActivity(KeyWordActivity.this, KeyWordShoActivity.class, false, "page_type", "2"); + } + }); + + binding.tvKeyAdd0.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线 + binding.tvKeyAdd0.getPaint().setAntiAlias(true);//抗锯齿 + binding.tvKeyAdd0.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + potCusBean.setSelect("1"); + JumpUtils.gotoActivity(KeyWordActivity.this, KeyWordShoActivity.class, false, "page_type", "1"); + } + }); + binding.rlStart.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + //获取参数 + getdakaVideoList(select); + getletterList(); + if(!addWinEntity.cancleisopen){ + //下面两个步骤不能同时执行 + Log.e("TIAOSHI###==发送的潜在客户参数", "执行潜在客户加关"); + if(potCusBean.getBigshotdatas().size()>0) { + EventBus.getDefault().post(potCusBean); + }else { + ToastUtils.showToast(KeyWordActivity.this,"没有需要加关的大v或者关键词"); + } + } + updFollow(potCusBean.getMaxnum()); + } + }); + } + private void menu() { + if(select.equals("1")){ + binding.tvSec01.setBackgroundResource(R.mipmap.icon_cheched_true); + binding.tvSec03.setBackgroundResource(R.mipmap.icon_cheched_false); + binding.lyKey01.setVisibility(View.VISIBLE); + binding.lyKey02.setVisibility(View.GONE); + }else { + binding.tvSec01.setBackgroundResource(R.mipmap.icon_cheched_false); + binding.tvSec03.setBackgroundResource(R.mipmap.icon_cheched_true); + binding.lyKey01.setVisibility(View.GONE); + binding.lyKey02.setVisibility(View.VISIBLE); + } + } + + private void getdakaVideoNumber(){ + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("type", select);//1:大咖,2:视频关键词 + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_dakaVideoNumber).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + String max = jsonObject.getString("max"); + potCusBean.setMaxnum(max); + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + + /** + * 修改最大关注数 + * @param max_num + */ + private void updFollow(String max_num){ + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("max_num", max_num); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_updFollow).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if(success.equals("0")){ + // ToastUtils.showToast(KeyWordActivity.this, msg); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + + private void getdakaVideoList(String page_type){ + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("type", page_type);//1:大咖,2:视频关键词 + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_dakaVideoList).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + + @Override + public void onNext(Response response) { + String body = (String) response.body(); + dakaVideoListBean dakaVideoListBean = JsonUtils.fromJson(body, com.fisherbone.fuzhu.entity.dakaVideoListBean.class); + if(dakaVideoListBean.getSuccess()==0){ + List datavideo = dakaVideoListBean.getData(); + if(datavideo.size()>0) { + com.fisherbone.fuzhu.entity.dakaVideoListBean.DataBean dataBean = datavideo.get(0); + String name = dataBean.getName();//搜索内容 + ChangLiang.dav_douyinname=name; + ChangLiang.dav_douyinname_id=dataBean.getId(); + Log.e("TIAOSHI###", "得到的大咖或者视频==" + ChangLiang.dav_douyinname ); + List key = dataBean.getKey(); + ChangLiang.dav_keyword=key.get(0).getKey_name(); + Log.e("TIAOSHI###", "得到的关键词==" + ChangLiang.dav_keyword); + + final HttpParams paramsPost = new HttpParams(); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_letterList).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + + @Override + public void onNext(Response response) { + String body = (String) response.body(); + letterListBean letterListBean = JsonUtils.fromJson(body, com.fisherbone.fuzhu.entity.letterListBean.class); + if(letterListBean.getSuccess()==0){ + List data = letterListBean.getData(); + PotCusBean potCusBean = new PotCusBean(); +// List bigshotData = new ArrayList<>(); +// BigshotData bigshotData1 = new BigshotData(); +// bigshotData1.setComment(name); +// bigshotData.add(bigshotData1); + potCusBean.setBigshotdatas(datavideo); + ArrayList keyWordBeans = new ArrayList<>(); + for(int i=0;i letterBeans = new ArrayList<>(); + for(int i=0;i() { + + @Override + public void onNext(Response response) { + String body = (String) response.body(); + letterListBean letterListBean = JsonUtils.fromJson(body, com.fisherbone.fuzhu.entity.letterListBean.class); + if(letterListBean.getSuccess()==0){ + List data = letterListBean.getData(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/KeyWordEditActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/KeyWordEditActivity.java new file mode 100644 index 0000000..75e184e --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/KeyWordEditActivity.java @@ -0,0 +1,48 @@ +package com.fisherbone.fuzhu.activity; + +import android.os.Bundle; + +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; + +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.fragment.EditTitleFragment; +import com.fisherbone.fuzhu.widget.TitleBar; + +/** + * 关键词编辑页面 + */ +public class KeyWordEditActivity extends BaseActivity { + private TitleBar mTitleBar; + private String type;//1代表 大咖 2代表 视频关键词 + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_keywordedit); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("编辑"); + initNormalBack(); + type = getIntent().getStringExtra("type"); + + + //创建fragment管理类 + FragmentManager fmm = getSupportFragmentManager(); + //查找当前容器中是否有fragment + Fragment fragmentt = fmm.findFragmentById(R.id.news_title_fragment); + if (fragmentt == null) { + //如果没有,创建fragment + fragmentt = new EditTitleFragment(); + Bundle bundle = new Bundle(); + bundle.putString("page_type", this.type);//1代表 大咖 2代表 视频关键词 + fragmentt.setArguments(bundle); + //添加fragment到activity中 + fmm.beginTransaction() + .add(R.id.news_title_fragment, fragmentt) + .commit(); + } + + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/KeyWordShoActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/KeyWordShoActivity.java new file mode 100644 index 0000000..a5aeba9 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/KeyWordShoActivity.java @@ -0,0 +1,45 @@ +package com.fisherbone.fuzhu.activity; + +import android.os.Bundle; + +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; + +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.fragment.NewsTitleFragment; +import com.fisherbone.fuzhu.widget.TitleBar; + +/** + * 关键词选择 + */ +public class KeyWordShoActivity extends BaseActivity { + private TitleBar mTitleBar; + private String page_type; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_keywordsho); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("分类"); + initNormalBack(); + page_type = getIntent().getStringExtra("page_type"); + + //创建fragment管理类 + FragmentManager fmm = getSupportFragmentManager(); + //查找当前容器中是否有fragment + Fragment fragmentt = fmm.findFragmentById(R.id.news_title_fragment); + if (fragmentt == null) { + //如果没有,创建fragment + fragmentt = new NewsTitleFragment(); + Bundle bundle = new Bundle(); + bundle.putString("page_type", page_type);//1代表 大咖 2代表 视频关键词 + fragmentt.setArguments(bundle); + //添加fragment到activity中 + fmm.beginTransaction() + .add(R.id.news_title_fragment, fragmentt) + .commit(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/MainActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/MainActivity.java new file mode 100644 index 0000000..38e9872 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/MainActivity.java @@ -0,0 +1,1348 @@ +package com.fisherbone.fuzhu.activity; + +import android.Manifest; +import android.annotation.SuppressLint; +import android.app.Activity; +import android.app.ActivityManager; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.ServiceConnection; +import android.content.pm.PackageManager; +import android.os.Build; +import android.os.Bundle; +import android.os.Handler; +import android.os.IBinder; +import android.provider.Settings; +import android.util.Log; +import android.view.Gravity; +import android.view.View; +import android.view.ViewGroup; +import android.widget.PopupWindow; +import android.widget.TextView; + +import com.blankj.utilcode.util.ToastUtils; +import com.derry.wechat.WeChatPlate; +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.BuildConfig; +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.FZConfig; +import com.fisherbone.fuzhu.FuzhuApplication; +import com.fisherbone.fuzhu.InfoMessage; +import com.fisherbone.fuzhu.LiveActivity; +import com.fisherbone.fuzhu.LiveSuiJiActivity; +import com.fisherbone.fuzhu.MainActivityy; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.TestTwoService; +import com.fisherbone.fuzhu.abllib.AblConfig; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.utils.AblUtil; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; + +import com.fisherbone.fuzhu.api.GetVesionResponseBean; +import com.fisherbone.fuzhu.api.NewsApiInterface; +import com.fisherbone.fuzhu.db.CommentBeanData; +import com.fisherbone.fuzhu.db.KeyWordBean; +import com.fisherbone.fuzhu.db.LetterBean; +import com.fisherbone.fuzhu.db.dao.CommentDao; +import com.fisherbone.fuzhu.db.dao.RedenvDao; +import com.fisherbone.fuzhu.db.dao.ZhanghaoDao; +import com.fisherbone.fuzhu.db.dao.daoutil; +import com.fisherbone.fuzhu.db.zhuanghaoBeanData; +import com.fisherbone.fuzhu.entity.FourEvent; +import com.fisherbone.fuzhu.entity.HusshuBean; +import com.fisherbone.fuzhu.entity.PotCusBean; +import com.fisherbone.fuzhu.entity.SixEvent; +import com.fisherbone.fuzhu.entity.UrgentTaskBean; +import com.fisherbone.fuzhu.entity.dakaVideoListBean; +import com.fisherbone.fuzhu.entity.letterListBean; +import com.fisherbone.fuzhu.entity.touchTaskBean; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.fisherbone.fuzhu.reflect.InjectUtils; +import com.fisherbone.fuzhu.reflect.OnClickk; +import com.fisherbone.fuzhu.step.TestAblStep0; +import com.fisherbone.fuzhu.step.TestAblStep1; +import com.fisherbone.fuzhu.step.TestAblStep10; +import com.fisherbone.fuzhu.step.TestAblStep12; +import com.fisherbone.fuzhu.step.TestAblStep13; +import com.fisherbone.fuzhu.step.TestAblStep18; +import com.fisherbone.fuzhu.step.TestAblStep19; +import com.fisherbone.fuzhu.step.TestAblStep2; +import com.fisherbone.fuzhu.step.TestAblStep21; +import com.fisherbone.fuzhu.step.TestAblStep23; +import com.fisherbone.fuzhu.step.TestAblStep24; +import com.fisherbone.fuzhu.step.TestAblStep25; +import com.fisherbone.fuzhu.step.TestAblStep26; +import com.fisherbone.fuzhu.step.TestAblStep27; +import com.fisherbone.fuzhu.step.TestAblStep28; +import com.fisherbone.fuzhu.step.TestAblStep29; +import com.fisherbone.fuzhu.step.TestAblStep31; +import com.fisherbone.fuzhu.step.TestAblStep32; +import com.fisherbone.fuzhu.step.TestAblStep33; +import com.fisherbone.fuzhu.step.TestAblStep6; +import com.fisherbone.fuzhu.step.TestAblStep7; +import com.fisherbone.fuzhu.step.TestAblStep8; +import com.fisherbone.fuzhu.step.TestAblStep9; +import com.fisherbone.fuzhu.utils.JsonUtils; +import com.fisherbone.fuzhu.utils.JumpUtils; +import com.fisherbone.fuzhu.utils.Observerlife; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.fisherbone.fuzhu.utils.SPUtils; +import com.fisherbone.fuzhu.utils.SystemUtil; +import com.fisherbone.fuzhu.utils.UpdateManager; +import com.fisherbone.fuzhu.utils.VersionUtils; +import com.google.gson.Gson; +import com.gyf.immersionbar.ImmersionBar; +import com.jeremyliao.liveeventbus.LiveEventBus; +import com.lzy.okgo.OkGo; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; +import com.xiangxue.arouter_annotation.ARouter; +import com.xiangxue.arouter_api.RouterManager; +import com.xiangxue.common.network.TecentNetworkApi; +import com.xiangxue.common.network.observer.BaseObserver; + + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import de.greenrobot.event.EventBus; +import io.reactivex.Flowable; +import io.reactivex.Observable; +import io.reactivex.Observer; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.Disposable; +import io.reactivex.functions.Action; +import io.reactivex.functions.Consumer; + +@ARouter(path = "/app/MainActivity") +public class MainActivity extends BaseActivity implements InfoMessage { + private TestTwoService service = null; + private boolean isBind = false; + private UpdateManager mUpdateManager;//版本更新 + private CommentDao commentDao; + private ControlWindow controlWindow; + private RedenvDao redenvDao; + private StartTask startTask; + private PopupWindow mPopCut; + + private ServiceConnection conn = new ServiceConnection() { + @Override + public void onServiceConnected(ComponentName name, IBinder binder) { + isBind = true; + TestTwoService.MyBinder myBinder = (TestTwoService.MyBinder) binder; + service = myBinder.getService(); + Log.i("TIAOSHI###--Kathy", "ActivityA - onServiceConnected"); + String isactivation = (String) SPUtils.getSp(MainActivity.this, FZConfig.IS_ACTIVATION, ""); + if (VALUE_ZERO.equals(isactivation)) { + fivelunxun(); + if (VALUE_ZERO.equals(isactivation)) { + Log.e("TIAOSHI###--Kathy", "设备已激活"); + tvStutas.setText("设备在线"); + } + Log.e("TIAOSHI###--Kathy", "轮询请求"); + + } else { + if ("1".equals(isactivation)) { + Log.e("TIAOSHI###--Kathy", "设备未激活"); + } + Log.e("TIAOSHI###--Kathy", "未轮询请求" + "设备是否已激活==" + isactivation + "云端本地==" + ChangLiang.control_status);//01为激活并且云端开启 + } + } + + @Override + public void onServiceDisconnected(ComponentName name) { + isBind = false; + Log.i("TIAOSHI###--", "ActivityA - onServiceDisconnected"); + } + }; + private Disposable mdDisposable; + final private int REQUEST_CODE_ASK_PERMISSIONS = 123; + private TextView tvShowInfo, tvStutas,yunduanStu,tv_ifcunzai; + private ZhanghaoDao zhanghaoDao; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + if (BuildConfig.isRelease) { + Log.d(TAG, "onCreate: 当前是:集成化 线上环境,以app壳为主导运行的方式"); + // Toast.makeText(this, "当前是:集成化 线上环境,以app壳为主导运行的方式", Toast.LENGTH_SHORT).show(); + } else { + Log.d(TAG, "onCreate: 当前是:组件化 测试环境,所有的子模块都可以独立运行"); + // Toast.makeText(this, "当前是:组件化 测试环境,所有的子模块都可以独立运行", Toast.LENGTH_SHORT).show(); + } + ImmersionBar.with(this).statusBarDarkFont(true).init();//设置状态栏颜色 + IntentFilter intentFilter = new IntentFilter(); + intentFilter.addAction(Intent.ACTION_TIME_TICK); + String systemModel = SystemUtil.getSystemModel(); + Log.e("手机型号", systemModel); + if ("M2103K19C".equals(systemModel)) { + ChangLiang.phonetype = "2"; + } else if ("Redmi 7A".equals(systemModel)) { + ChangLiang.phonetype = "0"; + } else if ("M2007J22C".equals(systemModel)) { + ChangLiang.phonetype = "3"; + } else { + ChangLiang.phonetype = "1"; + } + + Settings.Secure.putString(getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, "com.fisherbone.fuzhu/com.fisherbone.fuzhu.abllib.AblService"); + Settings.Secure.putString(getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED, "1");//1表示开启 + ChangLiang.task_id = "";//当前执行任务id + ChangLiang.id = "";//当前执行任务功能id + ChangLiang.task_type = "";//当前执行任务类型 + ChangLiang.isstart = "0"; + ChangLiang.isstarttwo = "0"; + controlWindow = new ControlWindow(MainActivity.this); + LiveEventBus.get("some_key", String.class).observe(this, new Observerlife() { + @Override + public void onChanged(Object o) { + controlWindow.showRunInfo((String) o); + } + }); + LiveEventBus.get("success", String.class).observe(this, new Observerlife() { + @Override + public void onChanged(Object o) { + Log.e("TIAOSHI###", "getcontrolStatus==执行了"); + getcontrolStatus(); + } + }); + LiveEventBus.get("ablservice", String.class).observe(this, new Observerlife() { + @Override + public void onChanged(Object o) { + tvShowInfo.setText((String)o); + if("无障碍服务被销毁".equals((String)o)){ + againStart("0"); + } + } + }); + LiveEventBus.get("jiaguantime", String.class).observe(this, new Observerlife() { + @Override + public void onChanged(Object o) { + Log.w("TIAOSHI###运行时长", (String) o); + //开启运行倒计时 + daojishitwo(Integer.parseInt((String) o)); + } + }); + LiveEventBus.get("closedtime", String.class).observe(this, new Observerlife() { + @Override + public void onChanged(Object o) { + if(mdDisposable!=null) { + mdDisposable.dispose(); + } + } + }); + LiveEventBus.get("runningstate", String.class).observe(this, new Observerlife() { + @Override + public void onChanged(Object o) { + againStart((String) o); + } + }); + LiveEventBus.get("yunkong", String.class).observe(this, new Observerlife() { + @Override + public void onChanged(Object o) { + if("open".equals((String) o)){ + }else { + closeService(); + } + } + }); + InjectUtils.injectEvent(this); + requestVersion(); + + zhanghaoDao = new ZhanghaoDao(MainActivity.this); + commentDao = new CommentDao(MainActivity.this); + redenvDao = new RedenvDao(MainActivity.this); + startTask = new StartTask(MainActivity.this, controlWindow, zhanghaoDao); + ArrayList commentBeanData = commentDao.queryAll(); + if (commentBeanData.size() == 0) { + madeData(); + } + EventBus.getDefault().register(this); + displayBriefMemory(); + //红米7设备imei为:: 865367043276309 + AblUtil.getPermissions(MainActivity.this); + //设置公共参数 + String device_id = (String) SPUtils.getSp(MainActivity.this, FZConfig.KEY_DEVICE_ID, ""); + if (!"".equals(device_id)) { + OkGo.getInstance().addCommonParams(new HttpParams("device_id", device_id)); + } + checkDevice(); + Log.e("TIAOSHI###", "getcontrolStatus==执行了2"); + getcontrolStatus(); + renewType("1"); + new AblViewUtil().rigist(MainActivity.this); + AblConfig.Builder() + .setLogTag("123456")//logtag,不设置默认是abllib + .setStepMsgDelayMillis(2000)//步骤延迟时间 + .setFindViewMillisInFuture(10000)//寻找界面超时时间 + .setFindViewCountDownInterval(200)//寻找界面间隔时间 + .build().init(); + AblStepHandler.getInstance().initStepClass(new TestAblStep0(), new TestAblStep1(), new TestAblStep2(), new TestAblStep6(), new TestAblStep7(), new TestAblStep8(), new TestAblStep9(), new TestAblStep10(), new TestAblStep12(), new TestAblStep13(), new TestAblStep18(), new TestAblStep19(), new TestAblStep21(), new TestAblStep23(), new TestAblStep24(), new TestAblStep25(), new TestAblStep26(), new TestAblStep27(), new TestAblStep28(), new TestAblStep29(), new TestAblStep31(), new TestAblStep32(), new TestAblStep33()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + int hasWriteContactsPermission = checkSelfPermission(Manifest.permission.READ_CONTACTS); + if (hasWriteContactsPermission != PackageManager.PERMISSION_GRANTED) { + requestPermissions(new String[]{Manifest.permission.WRITE_CONTACTS}, REQUEST_CODE_ASK_PERMISSIONS); + } + } + tvShowInfo = findViewById(R.id.tv_showinfo); + tvStutas = findViewById(R.id.tv_stutas); + yunduanStu = findViewById(R.id.tv_yunduanstutas); + tv_ifcunzai = findViewById(R.id.tv_ifcunzai); + + findViewById( R.id.rl_bottom_02).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + JumpUtils.gotoActivity(MainActivity.this, ScrSetActivity.class, false, "", ""); + } + }); + findViewById( R.id.rl_bottom_04).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + JumpUtils.gotoActivity(MainActivity.this, SettingActivity.class, false, "", ""); + } + }); + findViewById( R.id.rl_bottom_03).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + @SuppressLint("InflateParams") View v = getLayoutInflater().inflate(com.derry.wechat.R.layout.layout_pop,null); + TextView viewById = v.findViewById(R.id.wechat_cut); + viewById.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(MainActivity.this, WeChatPlate.class); + intent.putExtra("name", "Derry"); + startActivity(intent); + } + }); + mPopCut = new PopupWindow(v, ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT); + mPopCut.setTouchable(true); + mPopCut.setFocusable(true); + mPopCut.showAtLocation(getWindow().getDecorView(), Gravity.BOTTOM,0,0); + } + }); + + } + + @OnClickk({R.id.rl_05, R.id.rl_12, R.id.rl_011, R.id.rl_10, R.id.rl_09, R.id.rl_08, R.id.rl_07, R.id.rl_06, R.id.rl_04, R.id.rl_03, R.id.rl_01, R.id.rl_02}) + public void click(View view) { + if(ProfileSpUtils.getInstance().getSetBean().isRedswitchone()){ + ToastUtils.showShort( "请关闭云端控制"); + return; + } + switch (view.getId()) { + case R.id.rl_05: + JumpUtils.gotoActivity(MainActivity.this, DavActivity.class, false, "", ""); + break; + case R.id.rl_12: + JumpUtils.gotoActivity(MainActivity.this, HongBaoActivity.class, false, "", ""); + break; + case R.id.rl_011: + JumpUtils.gotoActivity(MainActivity.this, AppointActivity.class, false, "", ""); + break; + case R.id.rl_10: + JumpUtils.gotoActivity(MainActivity.this, LiveSuiJiActivity.class, false, "", ""); + break; + case R.id.rl_09: + JumpUtils.gotoActivity(MainActivity.this, LiveActivity.class, false, "", ""); + break; + case R.id.rl_08: + JumpUtils.gotoActivity(MainActivity.this, noticeActivity.class, false, "", ""); + break; + case R.id.rl_07: + JumpUtils.gotoActivity(MainActivity.this, KeyWordActivity.class, false, "", ""); + break; + case R.id.rl_06: + JumpUtils.gotoActivity(MainActivity.this, InteraActivity.class, false, "", ""); + break; + case R.id.rl_04: + JumpUtils.gotoActivity(MainActivity.this, CancleFollowActivity.class, false, "", ""); + break; + case R.id.rl_03: + JumpUtils.gotoActivity(MainActivity.this, KeyWordActivity.class, false, "", ""); + break; + case R.id.rl_01: + JumpUtils.gotoActivity(MainActivity.this, RecFollowActivity.class, false, "", ""); + // JumpUtils.gotoActivity(MainActivity.this, MainActivityy.class, false, "", ""); + break; + case R.id.rl_02: +// Settings.Secure.putString(getContentResolver(), +// Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, "com.fisherbone.fuzhu.abllib/AblService"); +// Settings.Secure.putString(getContentResolver(), +// Settings.Secure.ACCESSIBILITY_ENABLED, "0");//1表示开启 + // service.stopSelf(); + + // CrashReport.testJavaCrash(); + + // 使用我们自己写的路由 跳转交互 +// RouterManager.getInstance() +// .build("/order/Order_MainActivity") +// .withString("name", "杜子腾") +// .navigation(this); // 组件和组件通信 + + RouterManager.getInstance() + .build("/wechat/W_MainActivity") + .withString("name", "杜子腾") + .navigation(this); // 组件和组件通信 + break; + default: + } + } + + private void closeService() { + //单击了“unbindService”按钮 + if (isBind) { + Log.i("TIAOSHI###--Kathy", + "----------------------------------------------------------------------"); + Log.i("TIAOSHI###--Kathy", "ActivityA 执行 unbindService"); + tvStutas.setText(""); + unbindService(conn); + } + } + + /** + * 模拟结束任务 + * + * @param a + */ + private void daojishitwo(final int a) { + //启动计时器 + //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 + mdDisposable= Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) + .observeOn(AndroidSchedulers.mainThread()) + .doOnNext(new Consumer() { + @Override + public void accept(Long aLong) throws Exception { + long b = a - aLong; + Log.w("TIAOSHI###运行剩余时长", b + ""); + } + }) + .doOnComplete(new Action() { + @Override + public void run() throws Exception { + Log.e("TIAOSHI###", "运行时间已到,停止自动加关"); + ToastUtils.showLong("运行时间已到,停止自动加关"); + AblStepHandler.getInstance().setStop(true); + AblViewUtil.onMessage("停止"); + + } + }) + .subscribe(); + } + + + /** + * @param + * @return + * @description 接收tost通知栏消息 + */ + public void onEvent(SixEvent event) { + if (null != event) { + String msg = event.getMsg(); + if ("success".equals(msg)) { + String toastMsg = event.getToastMsg(); + if (toastMsg.contains("关注太快了,先休息一下")) { + AblStepHandler.getInstance().setStop(true); + AblViewUtil.onMessage("停止"); + }else if (toastMsg.contains("下线提醒")) { + UpdateTuoguan("1"); + } else if (toastMsg.contains("账号下线")) { + UpdateTuoguan("1"); + } else if (toastMsg.contains("粉丝列表不可见")) { + AblStepHandler.getInstance().setStop(true); + AblViewUtil.onMessage("停止"); + }else if(toastMsg.contains("已切换到")){ + UpdateTuoguan("0"); + } + } + } + } + + public void onEventMainThread(PotCusBean potCusBean) { + if ("1".equals(potCusBean.getSelect())) { + if (potCusBean.getBigshotdatas().size() > 0) { + execute("7"); + } + } + if (VALUE_TWO.equals(potCusBean.getSelect())) { + if (potCusBean.getKeyworddatas().size() > 0) { + execute("8"); + } + } + } + + public void onEventMainThread(FourEvent event) { + if (null != event) { + String msg = event.getMsg(); + if ("success".equals(msg)) { + String type = event.getType(); + switch (type) { + case "1": + List CommentBeanDatas = CommentDao.queryInByCustom("type", "1"); + if (CommentBeanDatas.size() > 0) { + execute("1"); + } else { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(MainActivity.this, "请先添加评论话术"); + } + break; + case "2": + execute("2"); + break; + case "3": + execute("51"); + break; + case "4": + execute("61"); + break; + case "5": + execute("9"); + break; + case "6": + execute("6"); + break; + case "7": + execute("12"); + break; + case "8": + execute("13"); + break; + case "9": + execute("14"); + break; + case "10": + execute("5"); + break; + default: + } + } + } + } + + private void execute(String s) { + if (AblUtil.isAccessibilityServiceOpen(MainActivity.this)) { + AblUtil.addSuspensionWindowView(MainActivity.this, controlWindow.initWindowView(s)); + } else { + ToastUtils.showShort("点到了"); + ToastUtils.showShort("请先开启辅助服务"); + AblUtil.openAccessibilitySettings(); + } + } + + private void openService() { + //单击了“bindService”按钮 + Intent intent = new Intent(MainActivity.this, TestTwoService.class); + // intent.putExtra("from", "ActivityA"); + Log.i("TIAOSHI###--Kathy", "----------------------------------------------------------------------"); + Log.i("TIAOSHI###--Kathy", "ActivityA 执行 bindService"); + bindService(intent, conn, BIND_AUTO_CREATE); + } + + private void fivelunxun() { + Observable.interval(2, 10, TimeUnit.SECONDS) + .doOnNext(new Consumer() { + @Override + public void accept(Long integer) throws Exception { + Log.w("TIAOSHI###", "第 " + integer + " 次轮询"); + Log.w("TIAOSHI###", "第查看参数1 " + ChangLiang.control_status + "======"+ProfileSpUtils.getInstance().getSetBean().isRedswitchone()); + if (VALUE_ONE.equals(ChangLiang.control_status)&&ProfileSpUtils.getInstance().getSetBean().isRedswitchone()) { + getUrgentTask(); + } + if (AblUtil.isAccessibilityServiceOpen(MainActivity.this)) { + // Log.e("TIAOSHI###", "无障碍服务正常"); + } else { + Log.e("TIAOSHI###", "无障碍服务异常"); + Settings.Secure.putString(getContentResolver(), + Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, "com.fisherbone.fuzhu.abllib/AblService"); + Settings.Secure.putString(getContentResolver(), + Settings.Secure.ACCESSIBILITY_ENABLED, "0");//1表示开启 + AblService.getInstance().disableSelf(); + againStart("0"); + } + boolean destroy = isDestroy(MainActivity.this); + if(destroy) { + Log.e("TIAOSHI###", "MainActivity已经被销毁"); + closeService(); + Settings.Secure.putString(getContentResolver(), + Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, "com.fisherbone.fuzhu.abllib/AblService"); + Settings.Secure.putString(getContentResolver(), + Settings.Secure.ACCESSIBILITY_ENABLED, "0");//1表示开启 + } + } + }).subscribe(new Observer() { + @Override + public void onSubscribe(Disposable d) { + + } + + @Override + public void onNext(Long value) { + + } + + @Override + public void onError(Throwable e) { + Log.d(TAG, "对Error事件作出响应"); + } + + @Override + public void onComplete() { + Log.d(TAG, "对Complete事件作出响应"); + } + }); + } + /** + * 判断Activity是否Destroy + * @param mActivity + * @return true:已销毁 + */ + public static boolean isDestroy(Activity mActivity) { + if (mActivity == null || + mActivity.isFinishing() || + (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && mActivity.isDestroyed())) { + return true; + } else { + return false; + } + } + + /** + * 1代表正常 + * 0代表异常 + * @param str + */ + private void againStart(String str) { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("task_status", str); + paramsPost.put("task_id", ChangLiang.task_id); + paramsPost.put("task_type", ChangLiang.task_type); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appscanlogin_againStart).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + Log.e("需通知后台重新启动", body); + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + + } + }); + } + + private void getUrgentTask() { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("short_id", ChangLiang.short_id); + paramsPost.put("task_id", ChangLiang.task_id); + paramsPost.put("id", ChangLiang.id); + paramsPost.put("task_type", ChangLiang.task_type); + //是否有当前有执行任务,有则传下面4个参数,无则不需用传。 + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_urgentTask).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + if (AblUtil.isAccessibilityServiceOpen(MainActivity.this)) { + startTask.startTask(body); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + //倒计时2秒开启服务 + private void daojishifirst(final int a) { + //启动计时器 + //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 + mdDisposable = Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) + .observeOn(AndroidSchedulers.mainThread()) + .doOnNext(new Consumer() { + @Override + public void accept(Long aLong) throws Exception { + long b = a - aLong; + Log.w("TIAOSHI###", b + ""); + } + }) + .doOnComplete(new Action() { + @Override + public void run() throws Exception { + openService(); + Log.e("TIAOSHI###", "轮询开启服务"); + } + }) + .subscribe(); + } + + + @Override + public void mesagesuccess(String str) { + + if ("停止".equals(str)) { + // mdDisposable.dispose(); + AblStepHandler.getInstance().setStop(true); + controlWindow.stutas(true); + controlWindow.closedWin(); + FinishTask(); + } + } + + /** + * 帐号登录回调 + * + * @param str + */ + @Override + public void mesagefinish(String str) { + if ("停止".equals(str)) { + mdDisposable.dispose(); + AblStepHandler.getInstance().setStop(true); + FinishTask(); + } + } + + /** + * 撞号任务完成的通知 + * + * @param str + */ + @Override + public void mesagezhuang(String str) { + if ("停止".equals(str)) { + mdDisposable.dispose(); + AblStepHandler.getInstance().setStop(true); + touchResult(); + controlWindow.stutas(true); + } + } + + /** + * 粉丝通知停止 + * + * @param str + */ + @Override + public void potgegin(String str) { + if ("停止".equals(str)) { + mdDisposable.dispose(); + AblStepHandler.getInstance().setStop(true); + controlWindow.stutas(true); + controlWindow.closedWin(); + FinishTask(); + } + } + + @Override + public void onDestroy() { + super.onDestroy(); + if(mdDisposable!=null) { + mdDisposable.dispose(); + } + EventBus.getDefault().unregister(this); + closeService(); + Settings.Secure.putString(getContentResolver(), + Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, "com.fisherbone.fuzhu.abllib/AblService"); + Settings.Secure.putString(getContentResolver(), + Settings.Secure.ACCESSIBILITY_ENABLED, "0");//1表示开启 + + Log.e("TIAOSHI###", "执行了onDestroy"); + killAppProcess(); + } + + /** + * 获取设备控制状态 -- 云端还是本地 + */ + private void getcontrolStatus() { + final HttpParams paramsPost = new HttpParams(); + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appoperate_controlStatus).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + String control_status = jsonObject.getString("control_status"); + //{"success":0,"msg":"调取蜂狐成功"} + if (VALUE_ZERO.equals(success)) { + ChangLiang.control_status = control_status; + if (VALUE_ONE.equals(control_status)) { + Log.e("TIAOSHI###", "倒计时开启服务"); + if(ProfileSpUtils.getInstance().getSetBean().isRedswitchone()) { + Log.i("Kathy","云控状态 " + ProfileSpUtils.getInstance().getSetBean().isRedswitchone()); + Log.i("Kathy","倒计时开始执行了"); + daojishifirst(2); + } + } + } + + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + /** + * app每执行完一个任务成功后调取接口 + */ + private void FinishTask() { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("short_id", ChangLiang.short_id);// 拿到的抖音id + paramsPost.put("task_id", ChangLiang.task_id);//拿到的任务id + paramsPost.put("id", ChangLiang.id);//功能id + paramsPost.put("task_type", ChangLiang.task_type);//拿到的任务类型 1:代表账号登录 2:停任务 3:代表紧急任务,4:代表固定任务 + + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_FinishTask).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if (VALUE_ZERO.equals(success)) { + Log.e("TIAOSHI###", "每执行完一个任务成功后调取接口==" + msg); + Log.e("TIAOSHI###", "任务执行完毕,领取新的任务。"); + ChangLiang.isstarttwo = "0"; + ChangLiang.isstart = "0"; + fixedTask(); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + /** + * 撞号返回结果[{'id':'1','phone':'15029224225','record_id':'1'},{'id':'2','phone':'14712354698','record_id':'1'}] + */ + private void touchResult() { + String zhuanghao = ""; + ZhanghaoDao instance1 = daoutil.getInstance(FuzhuApplication.getContext()); + List zhuanghaoBeanData = instance1.queryByCustom("isjiaguan", "1"); + if (zhuanghaoBeanData.size() > 0) { + Gson gson = new Gson(); + zhuanghao = gson.toJson(zhuanghaoBeanData); + Log.e("TIAOSHI###", "撞号返回结果==" + zhuanghao); + } else { + zhuanghao = ""; + Log.e("TIAOSHI###", "撞号返回结果==" + zhuanghao); + } + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("short_id", ChangLiang.short_id);// 拿到的抖音id + paramsPost.put("zhuanghao", zhuanghao); + + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_touchResult).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + //success=0,表示撞号继续,同时返回需要请求的数量,去获取撞号账号去请求数据 + //success=-2,表示撞号结束,可以去请求其他任务 + String success = jsonObject.getString("success"); + + if (VALUE_ZERO.equals(success)) { + String data = jsonObject.getString("data"); + com.fisherbone.fuzhu.utils.ToastUtils.showToast(MainActivity.this, msg); + Log.e("TIAOSHI###", "撞号结果==" + msg); + touchTask(data, new Zhuanhaoretren() { + @Override + public void call(touchTaskBean urgentTaskBean, String success) { + if (VALUE_ZERO.equals(success)) { + daojishifour(20, "3"); + } else if ("-2".equals(success)) { + Log.e("TIAOSHI###", "获取撞号账号==" + urgentTaskBean.getMsg()); + //表示撞号结束,可以去请求其他任务 + FinishTask(); + } + } + }); + + } else if ("-1".equals(success)) { + String data = jsonObject.getString("data"); + Log.e("TIAOSHI###", "撞号结果==" + msg); + touchTask(data, new Zhuanhaoretren() { + @Override + public void call(touchTaskBean urgentTaskBean, String success) { + if (VALUE_ZERO.equals(success)) { + daojishifour(20, "3"); + } else if ("-2".equals(success)) { + Log.e("TIAOSHI###", "获取撞号账号==" + urgentTaskBean.getMsg()); + //表示撞号结束,可以去请求其他任务 + FinishTask(); + } + } + }); + daojishifour(20, "3"); + } else { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(MainActivity.this, msg); + Log.e("TIAOSHI###", "撞号结果==" + msg); + //表示撞号结束,可以去请求其他任务 + FinishTask(); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + /** + * 固定任务(当前任务执行完请求下一个任务接口) + * 此处有一个核心逻辑,最后三个参数,传值分两种情况,一、如果来的紧急任务是一个停任务,那么就传空。二、如果来的紧急任务是一个其它任务。那么就传值 + */ + private void fixedTask() { + if (VALUE_TWO.equals(ChangLiang.task_type)) { + Log.e("TIAOSHI###", "执行了传值分两种情况第一种情况"); + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("short_id", ChangLiang.short_id);// 拿到的抖音id + paramsPost.put("task_id", ChangLiang.task_id);//拿到的任务id + paramsPost.put("id", ChangLiang.id);//功能id + paramsPost.put("task_type", ChangLiang.task_type);//拿到的任务类型 1:代表账号登录 2:停任务 3:代表紧急任务,4:代表固定任务 + paramsPost.put("urgent_short_id", "");//未处理完成紧急任务抖音id + paramsPost.put("urgent_task_id", "");//未处理完成紧急任务id + paramsPost.put("urgent_id", "");// 未处理完成紧急功能id + paramsPost.put("fixed_short_id", "");//未处理完成固定任务抖音id + paramsPost.put("fixed_task_id", "");//未处理完成固定任务id + paramsPost.put("fixed_id", "");//未处理完成固定功能id + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_fixedTask).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + UrgentTaskBean urgentTaskBean = JsonUtils.fromJson(body, UrgentTaskBean.class); + int success = urgentTaskBean.getSuccess(); + if (success == 0) { + //初始化5秒的接口参数 + ChangLiang.task_id = "";//当前执行任务id + ChangLiang.id = "";//当前执行任务功能id + ChangLiang.task_type = "";//当前执行任务类型 + } + startTask.startTask(body); + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } else { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("short_id", ChangLiang.short_id);// 拿到的抖音id + paramsPost.put("task_id", ChangLiang.task_id);//拿到的任务id + paramsPost.put("id", ChangLiang.id);//功能id + paramsPost.put("task_type", ChangLiang.task_type);//拿到的任务类型 1:代表账号登录 2:停任务 3:代表紧急任务,4:代表固定任务 + paramsPost.put("urgent_short_id", ChangLiang.short_id_jf);//未处理完成紧急任务抖音id + paramsPost.put("urgent_task_id", ChangLiang.task_id_jf);//未处理完成紧急任务id + paramsPost.put("urgent_id", ChangLiang.id_jf);// 未处理完成紧急功能id + paramsPost.put("fixed_short_id", ChangLiang.short_id_f);//未处理完成固定任务抖音id + paramsPost.put("fixed_task_id", ChangLiang.task_id_f);//未处理完成固定任务id + paramsPost.put("fixed_id", ChangLiang.id_f);//未处理完成固定功能id + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_fixedTask).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + startTask.startTask(body); + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + } + + /** + * 倒计时开始执行任务 + * + * @param a + */ + private void daojishifour(final int a, String func_type) { + //启动计时器 + //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 + mdDisposable = Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) + .observeOn(AndroidSchedulers.mainThread()) + .doOnNext(new Consumer() { + @Override + public void accept(Long aLong) throws Exception { + long b = a - aLong; + Log.w("TIAOSHI###", b + ""); + } + }) + .doOnComplete(new Action() { + @Override + public void run() throws Exception { + //先判断无障碍是否开启 + Log.e("TIAOSHI###", "temp3"); + // ControlWindow controlWindow = new ControlWindow(MainActivity.this); + AblUtil.addSuspensionWindowView(MainActivity.this, controlWindow.initWindowView(func_type)); + } + }) + .subscribe(); + } + + /** + * 获取撞号账号 + * 如果{"success":-2,"msg":"暂无需要撞号的账号"}停止撞号任务 + */ + private void touchTask(String touch_num, Zhuanhaoretren zhuanhaoretren) { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("short_id", ChangLiang.short_id);// 拿到的抖音id + paramsPost.put("touch_num", touch_num);//功能id + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_touchTask).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + touchTaskBean urgentTaskBean = JsonUtils.fromJson(body, touchTaskBean.class); + int success = urgentTaskBean.getSuccess(); + zhuanhaoretren.call(urgentTaskBean, urgentTaskBean.getSuccess() + ""); + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + interface Zhuanhaoretren { + /** + * 幢号结果的回调 + */ + void call(touchTaskBean urgentTaskBean, String success); + } + + @Override + protected void onResume() { + super.onResume(); + againStart("0"); + if(ProfileSpUtils.getInstance().getSetBean().isRedswitchone()){ + yunduanStu.setText("云端开启"); + }else { + yunduanStu.setText(""); + } + } + + /** + * 检查设备是否存在 + */ + private void checkDevice() { + final HttpParams paramsPost = new HttpParams(); + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appoperate_checkDevice).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if (VALUE_ZERO.equals(success)) { + tv_ifcunzai.setText("设备已注册"); + SPUtils.setSP(MainActivity.this, FZConfig.IS_ACTIVATION, "0"); + } else { + tv_ifcunzai.setText("设备未注册"); + SPUtils.setSP(MainActivity.this, FZConfig.IS_ACTIVATION, "1"); + } + + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + /** + * 请求最新版本号 + */ + private void requestVersion() { + TecentNetworkApi.getService(NewsApiInterface.class) + .getNowVersion() + .subscribe(new BaseObserver() { + @Override + public void onSuccess(GetVesionResponseBean newsChannelsBean) { + Log.e("MainActivity", new Gson().toJson(newsChannelsBean)); + String newVersion = newsChannelsBean.getVersion(); + if (newVersion != null) { + String versionn = getVersionn(); + int versionUpdate = VersionUtils.compareVersion(versionn, newVersion); + if (VALUE_ZERO.equals(newsChannelsBean.getSuccess() + "")) { + if (versionUpdate == -1) {//两个版本相同 + mUpdateManager = new UpdateManager(MainActivity.this, "http://139.186.151.48/apk/atom-latest.apk"); + mUpdateManager.checkUpdateDownload(); + } + } + } + } + + @Override + public void onFailure(Throwable e) { + Log.e("Error", "Message:" + e.getMessage()); + } + }); + + } + + private void UpdateTuoguan(String str) { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("short_id", ChangLiang.short_id); + paramsPost.put("tuoguan_type", str);//1是离线,2是正常 + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appscanlogin_UpdateTuoguan).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if (VALUE_ZERO.equals(success)) { + Log.e("TIAOSHI###", "提交帐号异常" + msg); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + /** + * 潜在客户加关停止 + * + * @param str + */ + @Override + public void potfinish(String id, String str, String type) { + updatType(id, type); + } + + private void updatType(String id, String type) { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("id", id); + paramsPost.put("type", type); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_updatType).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if (VALUE_ZERO.equals(success)) { + getdakaVideoList(type); + com.fisherbone.fuzhu.utils.ToastUtils.showToast(MainActivity.this, msg); + } + + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + private void renewType(String type) { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("type", type); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_renewType).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + + @Override + public void onNext(Response response) { + String body = (String) response.body(); + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + private void getdakaVideoList(String page_type) { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("type", page_type);//1:大咖,2:视频关键词 + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_dakaVideoList).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + + @Override + public void onNext(Response response) { + String body = (String) response.body(); + dakaVideoListBean dakaVideoListBean = JsonUtils.fromJson(body, dakaVideoListBean.class); + if (dakaVideoListBean.getSuccess() == 0) { + List datavideo = dakaVideoListBean.getData(); + if (datavideo.size() > 0) { + boolean ifzhixing = ifzhixing(datavideo); + if (!ifzhixing) { + for (int i = 0; i < datavideo.size(); i++) { + com.fisherbone.fuzhu.entity.dakaVideoListBean.DataBean dataBean = datavideo.get(i); + //type:0么有执行,1:已执行 + if (VALUE_ZERO.equals(dataBean.getType())) { + String name = dataBean.getName();//搜索内容 + ChangLiang.dav_douyinname = name; + Log.e("TIAOSHI###", "赋值==" + name); + ChangLiang.dav_douyinname_id = dataBean.getId(); + Log.e("TIAOSHI###", "得到的大咖或者视频==" + ChangLiang.dav_douyinname); + List key = dataBean.getKey(); + final HttpParams paramsPost = new HttpParams(); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_letterList).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + letterListBean letterListBean = JsonUtils.fromJson(body, letterListBean.class); + if (letterListBean.getSuccess() == 0) { + List data = letterListBean.getData(); + PotCusBean potCusBean = new PotCusBean(); + potCusBean.setBigshotdatas(datavideo); + ArrayList keyWordBeans = new ArrayList<>(); + for (int i = 0; i < key.size(); i++) { + KeyWordBean keyWordBean = new KeyWordBean(); + keyWordBean.setComment(key.get(i).getKey_name()); + keyWordBeans.add(keyWordBean); + } + potCusBean.setKeyworddatas(keyWordBeans); + ArrayList letterBeans = new ArrayList<>(); + for (int i = 0; i < data.size(); i++) { + LetterBean letterBean = new LetterBean(); + letterBean.setComment(data.get(i).getContent()); + letterBeans.add(letterBean); + } + potCusBean.setLetterdatas(letterBeans); + ProfileSpUtils.getInstance().savePot(potCusBean); + //判断还有没有未加关的号 + Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + @Override + public void run() { + controlWindow.stutas(ChangLiang.isrun); + AblStepHandler.getInstance().setStop(false); + if (VALUE_ONE.equals(page_type)) { + StartExecution(MainActivity.this, AblSteps.STEP_170); + } else { + StartExecution(MainActivity.this, AblSteps.STEP_160); + } + } + }, 5000);//3秒后执行Runnable中的run方法 + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + break; + } + } + } else { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(MainActivity.this, "所有大v或者关键词已经执行完毕"); + } + } + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + /** + * 是否全部执行 + */ + private boolean ifzhixing(List datavideo) { + boolean isallrun = true;//是否已经全部执行完毕 + for (int i = 0; i < datavideo.size(); i++) { + if (VALUE_ZERO.equals(datavideo.get(i).getType())) { + isallrun = false; + } + } + return isallrun; + } + + private void madeData() { + final HttpParams paramsPost = new HttpParams(); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_liveScript).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + HusshuBean result = JsonUtils.fromJson(body, HusshuBean.class); + List data = result.getData(); + for (int i = 0; i < data.size(); i++) { + CommentBeanData commentBeanData = data.get(i); + commentBeanData.setId(0 + "" + i); + if (null != commentDao.queryByCustom("Id", commentBeanData.getId()) && commentDao.queryByCustom("Id", commentBeanData.getId()).size() > 0) { + commentDao.updateData(commentBeanData); + } else { + commentDao.addInsert(commentBeanData); + } + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + + public void killAppProcess() + { + //注意:不能先杀掉主进程,否则逻辑代码无法继续执行,需先杀掉相关进程最后杀掉主进程 + ActivityManager mActivityManager = (ActivityManager) MainActivity.this.getSystemService(Context.ACTIVITY_SERVICE); + // List mList = mActivityManager.getRunningAppProcesses(); + for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : mList) + { + if (runningAppProcessInfo.pid != android.os.Process.myPid()) + { + android.os.Process.killProcess(runningAppProcessInfo.pid); + } + } + android.os.Process.killProcess(android.os.Process.myPid()); + System.exit(0); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/PriLetActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/PriLetActivity.java new file mode 100644 index 0000000..76a210b --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/PriLetActivity.java @@ -0,0 +1,169 @@ +package com.fisherbone.fuzhu.activity; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.adapter.PriLetAdapter; +import com.fisherbone.fuzhu.db.CommentBeanData; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.fisherbone.fuzhu.utils.ToastUtils; +import com.fisherbone.fuzhu.widget.TitleBar; +import com.google.gson.Gson; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + + +/** + * 私信话术页面 + */ +public class PriLetActivity extends BaseActivity { + + private RecyclerView mRecyclerView; + private PriLetAdapter headerAndFooterAdapter; + private List statuses; + private TitleBar mTitleBar; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_prilet); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("新建私信话术"); + initNormalBack(); + mTitleBar.visibleTvRightTextBtn(true); + mTitleBar.setTvRightText("确定"); + mTitleBar.setTvRightTextColor(R.color.color_30B9B6); + mTitleBar.setOnTitleBarAllClickListener(new TitleBar.OnTitleBarAllClickListener() { + @Override + public void onRightTextButtonClick(View view) { + Gson gson = new Gson(); + ArrayList strings = new ArrayList<>(); + for(int i=0;i(); + CommentBeanData status = new CommentBeanData(); + status.setComment(""); + status.setId(new Random().nextInt(10000)+""); + statuses.add(status); + initAdapter(); + + + View footerView = getFooterView(0, new View.OnClickListener() { + @Override + public void onClick(View v) { + CommentBeanData status = new CommentBeanData(); + status.setComment(""); + status.setId(0 + ""+new Random().nextInt(10000)); + statuses.add(status); + headerAndFooterAdapter.notifyDataSetChanged(); + int size = statuses.size(); + mRecyclerView.scrollToPosition(size); // 将ListView定位到最后一行 + } + }); + headerAndFooterAdapter.addFooterView(footerView, 0); + + mRecyclerView.setAdapter(headerAndFooterAdapter); + + } + + + + private View getFooterView(int type, View.OnClickListener listener) { + View view = getLayoutInflater().inflate(R.layout.footer_prilet_view, (ViewGroup) mRecyclerView.getParent(), false); + if (type == 1) { + ImageView imageView = (ImageView) view.findViewById(R.id.iv); + imageView.setImageResource(R.mipmap.rm_icon); + } + view.setOnClickListener(listener); + return view; + } + + + private View.OnClickListener getRemoveFooterListener() { + return new View.OnClickListener() { + @Override + public void onClick(View v) { + headerAndFooterAdapter.removeFooterView(v); + } + }; + } + + private void initAdapter() { + headerAndFooterAdapter = new PriLetAdapter(statuses); + headerAndFooterAdapter.openLoadAnimation(); + mRecyclerView.setAdapter(headerAndFooterAdapter); + headerAndFooterAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() { + @Override + public void onItemClick(BaseQuickAdapter adapter, View view, int position) { + // Toast.makeText(PriLetActivity.this, "" + Integer.toString(position), Toast.LENGTH_LONG).show(); + } + }); + } + + private void getaddLetter(String content){ + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("content", content); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_addLetter).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + + if(success.equals("0")){ + finish(); + ToastUtils.showToast(PriLetActivity.this, msg); + } + + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/PriLetEditActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/PriLetEditActivity.java new file mode 100644 index 0000000..3e99ac6 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/PriLetEditActivity.java @@ -0,0 +1,199 @@ +package com.fisherbone.fuzhu.activity; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.adapter.PriLetEditAdapter; +import com.fisherbone.fuzhu.dialog.BaseTipsDialog; +import com.fisherbone.fuzhu.entity.letterListBean; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.fisherbone.fuzhu.utils.JsonUtils; +import com.fisherbone.fuzhu.utils.JumpUtils; +import com.fisherbone.fuzhu.utils.ToastUtils; +import com.fisherbone.fuzhu.widget.TitleBar; +import com.google.gson.Gson; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + + +/** + * 私信话术页面 + */ +public class PriLetEditActivity extends BaseActivity { + + private RecyclerView mRecyclerView; + private PriLetEditAdapter headerAndFooterAdapter; + private TitleBar mTitleBar; + private List data; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_prilet_edit); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("编辑话术"); + initNormalBack(); + mTitleBar.visibleTvRightTextBtn(true); + mTitleBar.setTvRightText(""); + mTitleBar.setTvRightTextColor(R.color.color_30B9B6); + mTitleBar.setOnTitleBarAllClickListener(new TitleBar.OnTitleBarAllClickListener() { + @Override + public void onRightTextButtonClick(View view) { + Gson gson = new Gson(); + ArrayList strings = new ArrayList<>(); + for(int i=0;i data) { + View footerView = getFooterView(0, new View.OnClickListener() { + @Override + public void onClick(View v) { + JumpUtils.gotoActivity(PriLetEditActivity.this, PriLetActivity.class, false, "",""); + } + }); + headerAndFooterAdapter = new PriLetEditAdapter(data); + headerAndFooterAdapter.addFooterView(footerView, 0); + headerAndFooterAdapter.openLoadAnimation(); + mRecyclerView.setAdapter(headerAndFooterAdapter); +// headerAndFooterAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() { +// @Override +// public void onItemClick(BaseQuickAdapter adapter, View view, int position) { +// Toast.makeText(PriLetEditActivity.this, "" + Integer.toString(position), Toast.LENGTH_LONG).show(); +// } +// }); + headerAndFooterAdapter.OnItemDelete(new PriLetEditAdapter.Itemdelete() { + @Override + public void itemdelete(letterListBean.DataBean item,int position) { + new BaseTipsDialog().showDownloadDialog(PriLetEditActivity.this, "确认删除吗?", "确定", new BaseTipsDialog.ClickListener() { + @Override + public void confirm() { + data.remove(position); + deleteLetter(item.getId()); + } + @Override + public void cancle() { + + } + }); + } + }); + } + + private void getletterList(){ + final HttpParams paramsPost = new HttpParams(); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_letterList).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + + @Override + public void onNext(Response response) { + String body = (String) response.body(); + letterListBean letterListBean = JsonUtils.fromJson(body, letterListBean.class); + if(letterListBean.getSuccess()==0){ + data = letterListBean.getData(); + initAdapter(data); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + private void refresh(){ + headerAndFooterAdapter.notifyDataSetChanged(); + } + + private void deleteLetter(String id){ + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("id", id); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_deleteLetter).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if(success.equals("0")){ + ToastUtils.showToast(PriLetEditActivity.this, msg); + refresh(); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + @Override + protected void onResume() { + super.onResume(); + getletterList(); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/PublishActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/PublishActivity.java new file mode 100644 index 0000000..83c3216 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/PublishActivity.java @@ -0,0 +1,179 @@ +package com.fisherbone.fuzhu.activity; + + +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.chad.library.adapter.base.BaseViewHolder; +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.entity.DakaVideoBean; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.fisherbone.fuzhu.okgonet.Observer; +import com.fisherbone.fuzhu.utils.JsonUtils; +import com.fisherbone.fuzhu.utils.WidgetTools; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.List; + + +public class PublishActivity extends BaseActivity { + + private RecyclerView reply_rcey; + private TextView tv_fuzhi; + private List data; + private String selectType="1"; + private String key_name; + private String id; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_puplish); + reply_rcey = (RecyclerView)findViewById(R.id.news_title_recycler_view); + key_name = getIntent().getStringExtra("key_name"); + Bundle databean= getIntent().getExtras(); + id = databean.getString("id"); + tv_fuzhi = (TextView)findViewById(R.id.tv_fuzhi); + tv_fuzhi.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + // ToastUtils.showShort("点击了复制。。。"); + Log.e("提交的字符串", id); + Log.e("提交的字符串", key_name); + sureCopy(id, key_name,"1"); + } + }); + LinearLayoutManager manager = new LinearLayoutManager(PublishActivity.this); + reply_rcey.setLayoutManager(manager); + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("type","1"); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_dakaVideo).subscribe(new Observer() { + + @Override + public void onNext(Response response) { + String body = (String) response.body(); + DakaVideoBean dakaVideoBean = JsonUtils.fromJson(body, DakaVideoBean.class); + if(dakaVideoBean.getSuccess()==0){ + data = dakaVideoBean.getData(); + reply_rcey.setAdapter(new BaseQuickAdapter(R.layout.item_reply_dialog, data) { + @Override + protected void convert(final BaseViewHolder helper, final DakaVideoBean.DataBean item) { + WidgetTools.setTextfive((TextView) helper.getView(R.id.img_modify), "", helper.getAdapterPosition()+1+"."+item.getName()); + ImageView ima_word = helper.getView(R.id.ima_word); + if (item.getIf_sel_del().equals("0")) { + ima_word.setImageResource(R.mipmap.icon_cheched_false); + } else { + ima_word.setImageResource(R.mipmap.icon_cheched_true); + } + helper.getView(R.id.ima_word).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + //本次选择 + if (IsSelecet(helper.getAdapterPosition())) { + cancalchoose(helper.getAdapterPosition()); + } else { + //selectType 0为单选 1为多选 + if (selectType.equals("0")) { + //先清除上次选中状态 + for (int i = 0; i < data.size(); i++) { + DakaVideoBean.DataBean dataBean = data.get(i); + if (dataBean.getIf_sel_del().equals("1")) { + cancalchoose(i); + } + } + } + selecttrue(helper.getAdapterPosition()); + + } + notifyDataSetChanged(); + } + }); + + } + }); + } + } + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + /** + * 选中(单选) + * + * @return + */ + private void selecttrue(int position) { + data.get(position).setIf_sel_del("1"); + } + /** + * 取消 + * + * @return + */ + private void cancalchoose(int childposition) { + data.get(childposition).setIf_sel_del("0"); + } + + /** + * 当前条目是否选中 + * + * @return + */ + public boolean IsSelecet(int childposition) { + + if (data.get(childposition).getIf_sel_del().equals("1")) { + return true; + } else { + return false; + } + } + private void sureCopy(String id,String key_name,String type){ + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("id", id); + paramsPost.put("key_name", key_name); + paramsPost.put("type", type); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_sureCopy).subscribe(new Observer() { + + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + + if(success.equals("0")){ + finish(); + com.fisherbone.fuzhu.utils.ToastUtils.showToast(PublishActivity.this, msg); + } + + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/RecFollowActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/RecFollowActivity.java new file mode 100644 index 0000000..3679bd8 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/RecFollowActivity.java @@ -0,0 +1,82 @@ +package com.fisherbone.fuzhu.activity; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; + +import androidx.databinding.DataBindingUtil; + +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.databinding.ActivityRecFollowBinding; +import com.fisherbone.fuzhu.entity.FourEvent; +import com.fisherbone.fuzhu.entity.RecFollowBean; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.fisherbone.fuzhu.utils.StringUtils; +import com.fisherbone.fuzhu.utils.ToastUtils; +import com.fisherbone.fuzhu.widget.TitleBar; + +import de.greenrobot.event.EventBus; + +/** + * 推荐加关 + */ +public class RecFollowActivity extends BaseActivity { + private TitleBar mTitleBar; + private ActivityRecFollowBinding binding; + private RecFollowBean recFollowBean; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + binding = DataBindingUtil.setContentView(this, R.layout.activity_rec_follow); + recFollowBean = ProfileSpUtils.getInstance().getUserProfie(); + binding.setRecfollowbean(recFollowBean); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("推荐加关"); + initNormalBack(); + /** + * @description 推荐加关开始运行 + * @param [savedInstanceState] + * @return void + */ + binding.rlStart.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Log.e("数据", recFollowBean.toString()); + //存储参数信息 + ProfileSpUtils.getInstance().saveProfile(recFollowBean); + + if (StringUtils.isEmpty(recFollowBean.getRunningtime())) { + ToastUtils.showToast(RecFollowActivity.this, "请输入运行时长"); + return; + } + + if (StringUtils.isEmpty(recFollowBean.getMaxnumcon())) { + ToastUtils.showToast(RecFollowActivity.this, "请输入最大关注数"); + return; + } + + if (StringUtils.isEmpty(recFollowBean.getMinimumlikes())) { + ToastUtils.showToast(RecFollowActivity.this, "请输入加关关注数"); + return; + } + + if (StringUtils.isEmpty(recFollowBean.getMinimumcon())) { + ToastUtils.showToast(RecFollowActivity.this, "请输入加关粉丝数"); + return; + } + + if (StringUtils.isEmpty(recFollowBean.getMinimumzuopin())) { + ToastUtils.showToast(RecFollowActivity.this, "请输入最小作品数"); + return; + } + if (StringUtils.isEmpty(recFollowBean.getMaximumprotime())) { + ToastUtils.showToast(RecFollowActivity.this, "请输入最大作品时间"); + return; + } + EventBus.getDefault().post(new FourEvent("success","1")); + } + }); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/ScrSetActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/ScrSetActivity.java new file mode 100644 index 0000000..1fcd6a4 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/ScrSetActivity.java @@ -0,0 +1,75 @@ +package com.fisherbone.fuzhu.activity; + +import android.os.Bundle; + +import androidx.recyclerview.widget.LinearLayoutManager; + +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.adapter.ScrSetAdapter; +import com.fisherbone.fuzhu.entity.StyleBean; +import com.fisherbone.fuzhu.utils.JumpUtils; +import com.fisherbone.fuzhu.widget.TitleBar; + +import java.util.ArrayList; +import java.util.List; + +/** + *话术设置1级页面 + */ +public class ScrSetActivity extends BaseMoActivity { + + private TitleBar mTitleBar; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("话术设置"); + initNormalBack(); + } + + @Override + public void initAdapter() { + mMarkingFragmentRecyclerView.setLayoutManager(new LinearLayoutManager(ScrSetActivity.this)); + ScrSetAdapter markingtwoAdapter = new ScrSetAdapter(ScrSetActivity.this, null); + getAdpter(markingtwoAdapter); + mMarkingFragmentRecyclerView.setAdapter(markingtwoAdapter); + markingtwoAdapter.operationListenner(new ScrSetAdapter.OnViewClickListener() { + @Override + public void enterCusDetail(StyleBean.ResultBean.DataBean item) { + JumpUtils.gotoActivity(ScrSetActivity.this, ScriptSettingActivity.class, false, "style_id",item); + } + }); + } + + @Override + public void requestData() { + mSwl.setRefreshing(false); + List data = new ArrayList(); + StyleBean.ResultBean.DataBean dataBean1 = new StyleBean.ResultBean.DataBean(); + dataBean1.setStyle("评论话术"); + dataBean1.setStyle_id("1"); + data.add(dataBean1); + StyleBean.ResultBean.DataBean dataBean2 = new StyleBean.ResultBean.DataBean(); + dataBean2.setStyle("私信话术"); + dataBean2.setStyle_id("2"); + data.add(dataBean2); + StyleBean.ResultBean.DataBean dataBean3 = new StyleBean.ResultBean.DataBean(); + dataBean3.setStyle("直播话术"); + dataBean3.setStyle_id("3"); + data.add(dataBean3); + StyleBean.ResultBean.DataBean dataBean4 = new StyleBean.ResultBean.DataBean(); + dataBean4.setStyle("回访话术"); + dataBean4.setStyle_id("4"); + data.add(dataBean4); + StyleBean.ResultBean.DataBean dataBean5 = new StyleBean.ResultBean.DataBean(); + dataBean5.setStyle("首关话术"); + dataBean5.setStyle_id("5"); + data.add(dataBean5); + setData(true, data); + } + @Override + public void onDestroy() { + super.onDestroy(); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/ScriptSettingActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/ScriptSettingActivity.java new file mode 100644 index 0000000..d83034c --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/ScriptSettingActivity.java @@ -0,0 +1,146 @@ +package com.fisherbone.fuzhu.activity; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.Toast; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.adapter.HeaderAndFooterAdapter; +import com.fisherbone.fuzhu.db.CommentBeanData; +import com.fisherbone.fuzhu.db.dao.CommentDao; +import com.fisherbone.fuzhu.entity.StyleBean; +import com.fisherbone.fuzhu.utils.ToastUtils; +import com.fisherbone.fuzhu.widget.TitleBar; +import com.google.gson.Gson; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + + +public class ScriptSettingActivity extends BaseActivity { + + private RecyclerView mRecyclerView; + private HeaderAndFooterAdapter headerAndFooterAdapter; + private List statuses; + private TitleBar mTitleBar; + private StyleBean.ResultBean.DataBean style_bean; + private String style_id; + private String style; + private CommentDao commentDao; + private List commentBeanDatas; + private List commentBeanDatas1; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_script_setting); + style_bean = (StyleBean.ResultBean.DataBean)getIntent().getSerializableExtra("style_id"); + style = style_bean.getStyle(); + style_id = style_bean.getStyle_id(); + commentDao = new CommentDao(ScriptSettingActivity.this); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle(style); + initNormalBack(); + mTitleBar.visibleTvRightTextBtn(true); + mTitleBar.setTvRightText("保存"); + mTitleBar.setTvRightTextColor(R.color.color_30B9B6); + mTitleBar.setOnTitleBarAllClickListener(new TitleBar.OnTitleBarAllClickListener() { + @Override + public void onRightTextButtonClick(View view) { + // ToastUtils.showToast(ScriptSettingActivity.this,"保存"); + String s = statuses.toString(); + Gson gson = new Gson(); + String s1 = gson.toJson(statuses); + Log.e("提交的字符串", s1); + // ToastUtils.showToast(ScriptSettingActivity.this, s1); + for (int i = 0; i < statuses.size(); i++) { + CommentBeanData commentBeanData = statuses.get(i); + if (null != commentDao.queryByCustom("Id", commentBeanData.getId()) && commentDao.queryByCustom("Id", commentBeanData.getId()).size() > 0) { + commentDao.updateData(commentBeanData); + } else { + commentDao.addInsert(commentBeanData); + } + } + ToastUtils.showToast(ScriptSettingActivity.this, "保存成功"); + } + + @Override + public void onLeftButtonClick(View view) { + + } + + @Override + public void onRightButtonClick(View view) { + + } + }); + mRecyclerView = (RecyclerView) findViewById(R.id.rv_list); + mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); + // CommentDao commentDao = new CommentDao(this); + commentBeanDatas1 = commentDao.queryInByCustom("type", this.style_id); + if (commentBeanDatas1.size() == 0) { + statuses = new ArrayList<>(); + CommentBeanData status = new CommentBeanData(); + status.setComment(""); + status.setId(new Random().nextInt(10000)+""); + status.setType(this.style_id); + statuses.add(status); + } else { + statuses = new ArrayList<>(); + statuses.addAll(commentBeanDatas1); + } + initAdapter(); + + + View footerView = getFooterView(0, new View.OnClickListener() { + @Override + public void onClick(View v) { + // headerAndFooterAdapter.addFooterView(getFooterView(1, getRemoveFooterListener()), 0); + + CommentBeanData status = new CommentBeanData(); + status.setComment(""); + status.setId(0 + ""+new Random().nextInt(10000)); + status.setType(ScriptSettingActivity.this.style_id); + statuses.add(status); + headerAndFooterAdapter.notifyDataSetChanged(); + int size = statuses.size(); + mRecyclerView.scrollToPosition(size); // 将ListView定位到最后一行 + } + }); + headerAndFooterAdapter.addFooterView(footerView, 0); + + mRecyclerView.setAdapter(headerAndFooterAdapter); + + } + private View getFooterView(int type, View.OnClickListener listener) { + View view = getLayoutInflater().inflate(R.layout.footer_view, (ViewGroup) mRecyclerView.getParent(), false); + if (type == 1) { + ImageView imageView = (ImageView) view.findViewById(R.id.iv); + imageView.setImageResource(R.mipmap.rm_icon); + } + view.setOnClickListener(listener); + return view; + } + + private void initAdapter() { + + headerAndFooterAdapter = new HeaderAndFooterAdapter(statuses); + headerAndFooterAdapter.openLoadAnimation(); + mRecyclerView.setAdapter(headerAndFooterAdapter); + headerAndFooterAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() { + @Override + public void onItemClick(BaseQuickAdapter adapter, View view, int position) { + Toast.makeText(ScriptSettingActivity.this, "" + Integer.toString(position), Toast.LENGTH_LONG).show(); + } + }); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/SettingActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/SettingActivity.java new file mode 100644 index 0000000..3b794ba --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/SettingActivity.java @@ -0,0 +1,537 @@ +package com.fisherbone.fuzhu.activity; + +import android.Manifest; +import android.app.Activity; +import android.app.Dialog; +import android.content.Context; +import android.content.Intent; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.os.Build; +import android.os.Bundle; +import android.text.Html; +import android.util.Log; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; +import android.widget.Button; +import android.widget.CompoundButton; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.StyleRes; +import androidx.databinding.DataBindingUtil; + +import com.blankj.utilcode.util.ToastUtils; +import com.fisherbone.ContactsHelp; +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.FZConfig; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.utils.AblUtil; +import com.fisherbone.fuzhu.api.GetVesionResponseBean; +import com.fisherbone.fuzhu.databinding.ActivitySettingBinding; +import com.fisherbone.fuzhu.db.DouyinBean; +import com.fisherbone.fuzhu.db.dao.DouyinDao; +import com.fisherbone.fuzhu.db.zhuanghaoBeanData; +import com.fisherbone.fuzhu.dialog.BaseTipsDialog; +import com.fisherbone.fuzhu.entity.SettingBean; +import com.fisherbone.fuzhu.entity.touchTaskBean; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.fisherbone.fuzhu.okgonet.Observer; +import com.fisherbone.fuzhu.reflect.InjectUtils; +import com.fisherbone.fuzhu.reflect.OnClickk; +import com.fisherbone.fuzhu.utils.EmojiFilter; +import com.fisherbone.fuzhu.utils.JsonUtils; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.fisherbone.fuzhu.utils.QrCode; +import com.fisherbone.fuzhu.utils.SPUtils; +import com.fisherbone.fuzhu.utils.SystemUtil; +import com.fisherbone.fuzhu.utils.UpdateManager; +import com.fisherbone.fuzhu.utils.VersionUtils; +import com.fisherbone.fuzhu.widget.TitleBar; +import com.google.gson.Gson; +import com.jeremyliao.liveeventbus.LiveEventBus; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; +import com.tbruyelle.rxpermissions2.RxPermissions; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +import io.reactivex.disposables.Disposable; + +/** + * 系统设置 + */ +public class SettingActivity extends BaseActivity { + private ActivitySettingBinding binding; + private TitleBar mTitleBar; + private static final int REQUEST_QRCODE = 0x01; + private UpdateManager mUpdateManager;//版本更新 + private DouyinDao douyinDao; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + binding = DataBindingUtil.setContentView(this, R.layout.activity_setting); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("系统设置"); + initNormalBack(); + douyinDao = new DouyinDao(SettingActivity.this); + InjectUtils.injectEvent(this); + if(ChangLiang.control_status.equals("1")&&ProfileSpUtils.getInstance().getSetBean().isRedswitchone()){ + binding.setSwitch1.setChecked(true); + }else { + binding.setSwitch1.setChecked(false); + } + binding.tvVewsion.setText("v."+getVersionn()); + // 添加监听 + binding.setSwitch1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (isChecked){ + ToastUtils.showShort(isChecked + ""); + SettingBean settingBean = new SettingBean(true); + ProfileSpUtils.getInstance().saveSetBean(settingBean); + updateControlStatus("1"); + LiveEventBus.get("yunkong").post("open"); + ToastUtils.showShort("群控状态1"+ProfileSpUtils.getInstance().getSetBean().isRedswitchone()+""); + }else { + ToastUtils.showShort(isChecked + ""); + SettingBean settingBean = new SettingBean(false); + updateControlStatus("0"); + ProfileSpUtils.getInstance().saveSetBean(settingBean); + LiveEventBus.get("yunkong").post("closed"); + ToastUtils.showShort("群控状态2"+ProfileSpUtils.getInstance().getSetBean().isRedswitchone()+""); + } + } + }); + + binding.rlVersion.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + // requestVersion(); + } + }); + binding.rlAut.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ArrayList douyinBeans = douyinDao.queryAll(); + if(douyinBeans.size()!=3){ + ToastUtils.showShort("未获得3个抖音帐号"); + return; + } + String isactivation = (String) SPUtils.getSp(SettingActivity.this, FZConfig.IS_ACTIVATION, ""); + if (isactivation.equals("0")) { + ToastUtils.showShort( "设备已激活"); + } else { + getPermissions(); + } + } + }); + binding.rlCan.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + new BaseTipsDialog().showDownloadDialog(SettingActivity.this, "确认注销该设备吗?", "确定", new BaseTipsDialog.ClickListener() { + @Override + public void confirm() { + zhuxiao(); + } + + @Override + public void cancle() { + + } + }); + } + }); + + binding.rlOpenwuzhangai.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + AblUtil.openAccessibilitySettings(); + } + }); + + binding.rlOpenfuchuang.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + AblUtil.openDrawOverlaysAnth(SettingActivity.this); + } + }); + binding.rlGetdouyin.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (AblUtil.isAccessibilityServiceOpen(SettingActivity.this)) { + AblStepHandler.getInstance().setStop(false); + AblStepHandler.sendMsg(AblSteps.STEP_1); + + } else { + AblUtil.openAccessibilitySettings(); + } + } + }); + binding.rlJihuo.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + SPUtils.setSP(SettingActivity.this, FZConfig.IS_ACTIVATION, "0"); + } + }); + binding.rlDaoru.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + String s = binding.etLianxiren.getText().toString(); + if("".equals(s)){ + ToastUtils.showShort("请输入导入通讯录的个数"); + return; + } + getPhoneNum(s); + + } + }); + } + + private void infoTv() { + String isactivation = (String) SPUtils.getSp(SettingActivity.this, FZConfig.IS_ACTIVATION, ""); + ArrayList douyinBeans = douyinDao.queryAll(); + if (douyinBeans.size() == 3&&isactivation.equals("0")) { + binding.tvAut.setText("激活授权(可授权)"); + } + } + + /** + * 获取撞号账号 + */ + public static void touchTasktwo(Context ctx,String body) { + //拿到json字符串,假数据 +// String JsonData = new GetJsonDataUtil().getJson(ctx, "touchTask.json");//获取assets目录下的json文件数据 +// touchTaskBean urgentTaskBean = JsonUtils.fromJson(JsonData, touchTaskBean.class); + touchTaskBean urgentTaskBean = JsonUtils.fromJson(body, touchTaskBean.class); + int success = urgentTaskBean.getSuccess(); + if (success == 0) { + List phoneNumber = urgentTaskBean.getData(); + //phoneNumber = urgentTaskBean.getData(); + //导入通讯录 + ContactsHelp.getInstance(ctx).importContacts(phoneNumber); + } + } + + @Override + protected void onResume() { + super.onResume(); + infoTv(); + } + + private void getPermissions() { + RxPermissions rxPermissions = new RxPermissions(this); + rxPermissions.request(Manifest.permission.CAMERA) + .subscribe(new io.reactivex.Observer() { + @Override + public void onSubscribe(Disposable d) { + + } + + @Override + public void onNext(Boolean aBoolean) { + if (aBoolean) { + QrCode qrCode = new QrCode(SettingActivity.this); + qrCode.startQrCode(); + } else { + ToastUtils.showShort("获取权限失败,请重新授权"); + } + } + + @Override + public void onError(Throwable e) { + + } + + @Override + public void onComplete() { + + } + }); + } + + + @OnClickk({R.id.rl_env}) + public void click(View view) { + switch (view.getId()) { + case R.id.rl_env: + ArrayList douyinBeans = douyinDao.queryAll(); + douyinDao.delete(douyinBeans); + if (AblUtil.isAccessibilityServiceOpen(SettingActivity.this)) { + AblStepHandler.getInstance().setStop(false); + AblStepHandler.sendMsg(AblSteps.STEP_50); + } else { + ToastUtils.showShort("请先开启辅助服务)))))))"); + } + break; + + default: + } + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + switch (requestCode) { + + case REQUEST_QRCODE: + if (resultCode == Activity.RESULT_OK) { + String code = data.getStringExtra("SCAN_RESULT"); + Log.e("扫码后的内容", code + ""); + jihuo(code); + } + break; + default: + } + } + + private void jihuo(String code) { + String device_id = (String) SPUtils.getSp(SettingActivity.this, FZConfig.KEY_DEVICE_ID, ""); + Gson gson = new Gson(); + ArrayList douyinBeans1 = douyinDao.queryAll(); + String s1 = gson.toJson(douyinBeans1); + Log.e("提交的字符串", s1);//[{"login_status":"1","short_id":"xiao629972576","short_name":""}] + String s = EmojiFilter.filterEmoji(s1);//去除字符串中包含的表情符号 + Log.e("提交的字符串(不包含表情符号)", s); + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("device_id", device_id);//扫码(设备)id + paramsPost.put("douyin", s);// 抖音号 + // paramsPost.put("douyin", "[{\"short_id\":\"tangjie0501\",\"short_name\":\"软件工程师蝴蝶剑\",\"login_status\":\"1\"}]");// 抖音号[{"short_id":"tangjie0501","short_name":"软件工程师蝴蝶剑","login_status":"1"}] + paramsPost.put("online_status", "");//阿童木在线状态 + paramsPost.put("control_status", "");//控制状态 + paramsPost.put("network_type", "");//网络类型 + paramsPost.put("app_version", "1.0");//app版本 + paramsPost.put("douyin_version", "");//抖音版本 + paramsPost.put("system_version", Build.MODEL);//系统版本 + paramsPost.put("device_qrcode", code);//授权码 + paramsPost.put("phone_type", SystemUtil.getSystemModel());//手机型号 + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_scanInfo).subscribe(new Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + Log.e("返回的数据", body); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + ToastUtils.showShort(msg); + String success = jsonObject.getString("success"); + if(success.equals("0")){ + SPUtils.setSP(SettingActivity.this, FZConfig.IS_ACTIVATION, "0"); + LiveEventBus.get("success").post("str"); + finish(); + }else { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(SettingActivity.this, msg); + SPUtils.setSP(SettingActivity.this, FZConfig.IS_ACTIVATION, "0"); + } + + } catch (JSONException e) { + e.printStackTrace(); + } + + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + /** + * 修改设备控制状态 -- 云端还是本地 + */ + private void updateControlStatus(String control_status){ + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("control_status", control_status);//网络类型1:云端 0:本地 + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appoperate_updateControlStatus).subscribe(new Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if(success.equals("0")){ + LiveEventBus.get("success").post("str"); + } + + } catch (JSONException e) { + e.printStackTrace(); + } + + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + /** + * 获取电话号码 + */ + private void getPhoneNum(String s) { + String device_id = (String) SPUtils.getSp(SettingActivity.this, FZConfig.KEY_DEVICE_ID, ""); + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("device_id", device_id); + paramsPost.put("number", s); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_getPhone).subscribe(new Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + touchTasktwo(SettingActivity.this,body); + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + + } + + + + /** + * 请求最新版本号 + */ + private void requestVersion() { + + final HttpParams paramsPost = new HttpParams(); + new NetApi().getPostDatatwo(paramsPost, HttpConstants.URi_Device_Appoperate_NowVersion).subscribe(new Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + + GetVesionResponseBean groupStatisticalBean = JsonUtils.fromJson(body, GetVesionResponseBean.class); + String newVersion = groupStatisticalBean.getVersion(); + if(newVersion!=null){ + String versionn = getVersionn(); + //versionn = "1.0.2"; + int versionUpdate = VersionUtils.compareVersion(versionn, newVersion); + if(groupStatisticalBean.getSuccess().equals("0")){ + if (versionUpdate == -1) {//两个版本相同 + ADialog mShareWechatDialog = new ADialog(SettingActivity.this, 0, groupStatisticalBean); + mShareWechatDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);//代码中取消标题栏 + mShareWechatDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + Window win = mShareWechatDialog.getWindow(); + win.getDecorView().setPadding(0, 0, 0, 0); + WindowManager.LayoutParams lp = win.getAttributes(); + lp.width = WindowManager.LayoutParams.FILL_PARENT; + lp.height = WindowManager.LayoutParams.WRAP_CONTENT; + win.setAttributes(lp); + mShareWechatDialog.setCancelable(false); + mShareWechatDialog.show(); + } else {//没有最新版本 + ToastUtils.showShort("当前已是最新版本"); + } + } + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + + } + class ADialog extends Dialog implements View.OnClickListener { + + private Context context; + GetVesionResponseBean mGetVesionResponseBean; + + public ADialog(@NonNull Context context, @StyleRes int themeResId, GetVesionResponseBean mGetVesionResponseBean) { + super(context, themeResId); + this.context = context; + this.mGetVesionResponseBean = mGetVesionResponseBean; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + this.setContentView(R.layout.version_dailog); + + if(isHuaWei()){ + launchAppDetail(SettingActivity.this, "com.fanghoo.mendian", "com.huawei.appmarket"); + }else { + launchAppDetail(SettingActivity.this, "com.fanghoo.mendian", "com.tencent.android.qqdownloader"); + } + } + public void launchAppDetail(final Context context, final String appPkg, final String marketPkg) { + + String content = mGetVesionResponseBean.getContent(); + content = content.replace("
", "
"); + TextView mContentTv = (TextView) findViewById(R.id.tv_content); + mContentTv.setText(Html.fromHtml(content)); + TextView mVersionTv = (TextView) findViewById(R.id.tv_version); + mVersionTv.setText("V" + mGetVesionResponseBean.getVersion()); + Button mUpdateBtn = (Button) findViewById(R.id.btn_update); + Button btn_update_one = (Button) findViewById(R.id.btn_update_one); + mUpdateBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dismiss(); + // 这里来检测版本是否需要更新 + mUpdateManager = new UpdateManager(SettingActivity.this, "http://139.186.151.48/apk/atom-latest.apk"); + mUpdateManager.checkUpdateDownload(); + // Log.d("apkUrl", apkUrl); + } + }); + btn_update_one.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dismiss(); + } + }); + } + + @Override + public void onClick(View v) { + } + } + public static boolean isHuaWei() { + String manufacturer = Build.MANUFACTURER; + //这个字符串可以自己定义,例如判断华为就填写huawei,魅族就填写meizu + if ("huawei".equalsIgnoreCase(manufacturer)) { + return true; + } + return false; + } + private void zhuxiao() { + String device_id = (String) SPUtils.getSp(SettingActivity.this, FZConfig.KEY_DEVICE_ID, ""); + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("device_id", device_id);//扫码(设备)id + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appscanlogin_cancellationDevice).subscribe(new Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + Log.e("返回的数据", body); + SPUtils.setSP(SettingActivity.this, FZConfig.IS_ACTIVATION, "1"); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + ToastUtils.showShort(msg); + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/ShouQuanActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/ShouQuanActivity.java new file mode 100644 index 0000000..c896e68 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/ShouQuanActivity.java @@ -0,0 +1,120 @@ +package com.fisherbone.fuzhu.activity; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; + +import androidx.databinding.DataBindingUtil; + +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.FZConfig; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.databinding.ActivityShouQuanBinding; +import com.fisherbone.fuzhu.db.DouyinBean; +import com.fisherbone.fuzhu.db.dao.DouyinDao; +import com.fisherbone.fuzhu.entity.CodeBean; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.fisherbone.fuzhu.okgonet.Observer; +import com.fisherbone.fuzhu.utils.SPUtils; +import com.fisherbone.fuzhu.utils.SystemUtil; +import com.fisherbone.fuzhu.utils.ToastUtils; +import com.fisherbone.fuzhu.widget.TitleBar; +import com.google.gson.Gson; +import com.jeremyliao.liveeventbus.LiveEventBus; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; + +public class ShouQuanActivity extends BaseActivity { + private TitleBar mTitleBar; + CodeBean codebean = new CodeBean("2Nz8-U2jC-YKJg-c9wo"); + private ActivityShouQuanBinding binding; + private DouyinDao douyinDao; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + binding = DataBindingUtil.setContentView(this, R.layout.activity_shou_quan); + binding.setCodebean(codebean); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("输入激活码"); + initNormalBack(); + douyinDao = new DouyinDao(ShouQuanActivity.this); + mTitleBar.visibleTvRightTextBtn(true); + mTitleBar.setTvRightText("激活"); + mTitleBar.setTvRightTextColor(R.color.color_30B9B6); + String isactivation = (String) SPUtils.getSp(ShouQuanActivity.this, FZConfig.IS_ACTIVATION, ""); + if (isactivation.equals("0")) { + mTitleBar.visibleTvRightTextBtn(false); + } else { + mTitleBar.visibleTvRightTextBtn(true); + } + mTitleBar.setOnTitleBarAllClickListener(new TitleBar.OnTitleBarAllClickListener() { + @Override + public void onRightTextButtonClick(View view) { + String code = codebean.getCode(); + Gson gson = new Gson(); + ArrayList douyinBeans1 = douyinDao.queryAll(); + String s1 = gson.toJson(douyinBeans1); + Log.e("提交的字符串", s1); + String device_id = (String) SPUtils.getSp(ShouQuanActivity.this, FZConfig.KEY_DEVICE_ID, ""); + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("device_id", device_id);//扫码(设备)id + paramsPost.put("douyin", s1);// 抖音号 + // paramsPost.put("douyin", "[{\"short_id\":\"tangjie0501\",\"short_name\":\"软件工程师蝴蝶剑\",\"login_status\":\"1\"}]");// 抖音号[{"short_id":"tangjie0501","short_name":"软件工程师蝴蝶剑","login_status":"1"}] + paramsPost.put("online_status", "");//阿童木在线状态 + paramsPost.put("control_status", "");//控制状态 + paramsPost.put("network_type", "");//网络类型 + paramsPost.put("app_version", "");//app版本 + paramsPost.put("douyin_version", "");//抖音版本 + paramsPost.put("system_version", "");//系统版本 + paramsPost.put("device_qrcode", code);//授权码 + paramsPost.put("phone_type", SystemUtil.getSystemModel());//手机型号 + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_scanInfo).subscribe(new Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if(success.equals("0")){ + SPUtils.setSP(ShouQuanActivity.this, FZConfig.IS_ACTIVATION, "0"); + // EventBus.getDefault().post(new FirstEvent("success")); + LiveEventBus.get("success").post("str"); + finish(); + }else { + ToastUtils.showToast(ShouQuanActivity.this, msg); + SPUtils.setSP(ShouQuanActivity.this, FZConfig.IS_ACTIVATION, "0"); + } + + } catch (JSONException e) { + e.printStackTrace(); + } + + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + @Override + public void onLeftButtonClick(View view) { + + } + + @Override + public void onRightButtonClick(View view) { + + } + }); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/ShowAty.java b/app/src/main/java/com/fisherbone/fuzhu/activity/ShowAty.java new file mode 100644 index 0000000..0667b13 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/ShowAty.java @@ -0,0 +1,19 @@ +package com.fisherbone.fuzhu.activity; + +import android.content.Context; +import android.content.Intent; + +public class ShowAty { + + public static void LoginPasswordActivity(Context ctx) { +// Intent i = new Intent(ctx, LoginPasswordActivity.class); +// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); +// ctx.startActivity(i); + } + + public static void ScriptSettingActivity(Context ctx) { + Intent i = new Intent(ctx, ScriptSettingActivity.class); + ctx.startActivity(i); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/StartTask.java b/app/src/main/java/com/fisherbone/fuzhu/activity/StartTask.java new file mode 100644 index 0000000..9948d4a --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/StartTask.java @@ -0,0 +1,900 @@ +package com.fisherbone.fuzhu.activity; + +import android.content.Context; +import android.util.Log; + +import com.blankj.utilcode.util.ToastUtils; +import com.fisherbone.ContactsHelp; +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.utils.AblUtil; +import com.fisherbone.fuzhu.db.dao.ZhanghaoDao; +import com.fisherbone.fuzhu.db.zhuanghaoBeanData; +import com.fisherbone.fuzhu.entity.LiveBean; +import com.fisherbone.fuzhu.entity.RecFollowBean; +import com.fisherbone.fuzhu.entity.RedEnvBean; +import com.fisherbone.fuzhu.entity.UrgentTaskBean; +import com.fisherbone.fuzhu.entity.touchTaskBean; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.fisherbone.fuzhu.utils.DateUtils; +import com.fisherbone.fuzhu.utils.JsonUtils; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import io.reactivex.Flowable; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.Disposable; +import io.reactivex.functions.Action; +import io.reactivex.functions.Consumer; + +/** + * Time: 2021/6/28 + * Description: + * @author : jianbo + */ +public class StartTask { + public String valueZero="0"; + public String valueOne="1"; + public String valueTwo="2"; + public String valueTwoF="-2"; + private Disposable mdDisposable; + Context mContext; + private boolean isRandGoodb; + private boolean isRandCommentb; + private boolean isRandFollowb; + + public StartTask(Context mContext, ControlWindow controlWindow, ZhanghaoDao zhanghaoDao){ + this.mContext=mContext; + this.controlWindow=controlWindow; + this.zhanghaoDao=zhanghaoDao; + } + private List phoneNumber = new ArrayList<>(); + ControlWindow controlWindow; + private ZhanghaoDao zhanghaoDao; + + public void startTask(String body) { + UrgentTaskBean urgentTaskBean = JsonUtils.fromJson(body, UrgentTaskBean.class); + int success = urgentTaskBean.getSuccess(); + //success=-1:代表报错;success=0:代表暂无任务;success=1:代表账号登录;success=2:代表停止任务;success=3:代表紧急任务;success=4:代表固定任务 + switch (success) { + case -1: + Log.w("TIAOSHI###", "5s----代表报错"); + break; + case 0: + Log.w("TIAOSHI###", "5s----暂无紧急任务"); + break; + case 1: + Log.w("TIAOSHI###", "5s----账号登录"); + ChangLiang.istask = true; + //领取到任务开始执行,调接口通知后台 + //有任务且任务没有执行 + if (ChangLiang.istask && valueZero.equals(ChangLiang.isstart)) { + ChangLiang.isstart = "1"; + //拿到这个功能类型,然后去解析数据。 + tastJiexidenglu(body); + //daojishithree(20); + } else { + Log.e("TIAOSHI###", "当前没有认领到可执行的任务"); + } + break; + //代表停止任务 + case 2: + Log.w("TIAOSHI###", "5s----停止任务"); + ChangLiang.task_type = "2"; + ChangLiang.istask = false; + //领取到任务开始执行,调接口通知后台 + Log.e("TIAOSHI###", "开始给后台上报拿到了停任务"); + updateTaskStatus(); + AblStepHandler.getInstance().setStop(true); + ChangLiang.isstart = "0"; + if (valueZero.equals(ChangLiang.isstarttwo)) { + ChangLiang.isstarttwo = "1"; + Log.e("TIAOSHI###", "停止了任务,并开始倒计时10秒关闭抖音"); + taskdaojishi(30); + } + break; + //代表紧急任务 + case 3: + Log.w("TIAOSHI###", "5s----紧急任务"); + ChangLiang.task_type = "3"; + ChangLiang.istask = true; + if (!ChangLiang.istask) { + Log.e("TIAOSHI###", "紧急任务——当前没有认领到可执行的任务"); + } + //任务没有执行 + if (valueZero.equals(ChangLiang.isstart)) { + ChangLiang.isstart = "1"; + //func_type 1:推荐加关,2:一键取关,3:撞号设置 + String funcType = urgentTaskBean.getData().getFunc_type(); + Log.e("TIAOSHI###", "执行的功能类型==" + funcType); + //领取到任务开始执行,调接口通知后台 + //updateTaskStatus(); + switch (funcType) { + case "1": + tastJiexi(body); + // daojishitwo(20); + break; + case "2": + tastJiexitwo(body); + // daojishitwo(20); + break; + //幢号任务 + case "3": + //解析数据,开始执行幢号任务 + Log.e("TIAOSHI###", "temp1"); + tastJiexithree(body); + break; + default: + Log.e("TIAOSHI###", "执行的功能类型不匹配"); + break; + } + + } else { + Log.e("TIAOSHI###", "固定任务——任务正在执行"); + } + break; + //代表固定任务 + case 4: + Log.w("TIAOSHI###", "5s----固定任务"); + ChangLiang.istask = true; + ChangLiang.task_type = "4"; + if (!ChangLiang.istask) { + Log.e("TIAOSHI###", "固定任务——没有任务"); + } + //任务没有执行 + Log.e("TIAOSHI###", "任务是否执行==" + ChangLiang.isstart); + if (valueZero.equals(ChangLiang.isstart)) { + ChangLiang.isstart = "1"; + //func_type 1:推荐加关,2:一键取关,3:撞号设置 5.抢红包 + String funcType = urgentTaskBean.getData().getFunc_type(); + Log.e("TIAOSHI###", "执行的功能类型==" + funcType); + //领取到任务开始执行,调接口通知后台 + // updateTaskStatus(); + switch (funcType) { + case "1": + tastJiexi(body); + // daojishitwo(20); + break; + case "2": + tastJiexitwo(body); + // daojishitwo(20); + break; + case "3": + //解析数据,开始执行幢号任务 + tastJiexithree(body); + break; + case "5": + tastJiexifive(body); + break; + case "6": + tastJiexisix(body); + break; + default: + Log.e("TIAOSHI###", "执行的功能类型不匹配"); + break; + } + + } else { + Log.e("TIAOSHI###", "固定任务——任务正在执行"); + } + break; + default: + } + } + + + /** + * app拿到任务调用接口 + */ + private void updateTaskStatus() { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("short_id", ChangLiang.short_id); + paramsPost.put("task_id", ChangLiang.task_id); + paramsPost.put("task_type", ChangLiang.task_type); + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_updateTaskStatus).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if (valueZero.equals(success)) { + com.fisherbone.fuzhu.utils.ToastUtils.showToast(mContext, "开始执行新任务"); + Log.e("TIAOSHI###", "给后台上报任务==" + msg); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + + private void tastJiexi(String body) { + //拿到这个功能类型,然后去解析数据。 + try { + /** + * -- ---------------------------- + * DROP TABLE IF EXISTS `t_sys_task_function_tjjg`; + * CREATE TABLE `t_sys_task_function_tjjg` ( + * `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键id', + * `task_id` varchar(32) NOT NULL COMMENT '任务id', + * `account_duration` int(11) DEFAULT '0' COMMENT '单账号时长(h)', + * `watch_duration_max` int(11) DEFAULT '0' COMMENT '视频最大观看时长(s)', + * `watch_duration_min` int(11) DEFAULT '0' COMMENT '视频最小观看时长(s)', + * `is_rand_good` tinyint(2) DEFAULT '1' COMMENT '是否随机点赞(1:是随机点赞,0:否)', + * `is_rand_follow` tinyint(2) DEFAULT '1' COMMENT '是否随机关注(1:是随机关注,0:否)', + * `is_rand_comment` tinyint(2) DEFAULT '1' COMMENT '是否随机评论(1:是随机评论,0:否)', + * `max_follow` int(11) DEFAULT '0' COMMENT '最大关注数', + * `and_follow_max` int(11) DEFAULT '0' COMMENT '最大加关关注数', + * `and_follow_min` int(11) DEFAULT '0' COMMENT '最小加关关注数', + * `and_fans_max` int(11) DEFAULT '0' COMMENT '最大加关粉丝数', + * `and_fans_min` int(11) DEFAULT '0' COMMENT '最小加关粉丝数', + * `min_work` int(11) DEFAULT '0' COMMENT '最小作品数', + * `max_work_time` int(11) DEFAULT '0' COMMENT '最大作品时间(天)', + * `create_time` datetime DEFAULT NULL COMMENT '系统时间', + * `is_rand_forward` tinyint(2) DEFAULT '0' COMMENT '是否随机转发(1:是随机转发,0:否)', + * PRIMARY KEY (`id`) + * ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='任务功能推荐加关表'; + */ + //拿到json字符串,假数据 + // String JsonData = new GetJsonDataUtil().getJson(MainActivity.this, "jiaguan.json");//获取assets目录下的json文件数据 + JSONObject jsonObject = new JSONObject(body); + JSONObject data = jsonObject.getJSONObject("data"); + String funcType = data.getString("func_type"); + JSONObject functionExecute = data.getJSONObject("function_execute"); + String taskId = data.getString("task_id");//任务id + String shortId = data.getString("short_id");//抖音id + String shortName = data.getString("short_name");//抖音昵称 + String end_time = data.getString("end_time");//抖音昵称 + String accountDuration = functionExecute.getString("account_duration");//单账号时长(h) + String watchDurationMax = functionExecute.getString("watch_duration_max");//视频最大观看时长(s) + String watchDurationMin = functionExecute.getString("watch_duration_min");//视频最小观看时长(s) + String isRandGood = functionExecute.getString("is_rand_good");//是否随机点赞(1:是随机点赞,0:否) + if(isRandGood.equals("1")){ + isRandGoodb = true; + }else { + isRandGoodb =false; + } + String isRandComment = functionExecute.getString("is_rand_comment");//是否随机评论(1:是随机评论,0:否) + if(isRandComment.equals("1")){ + isRandCommentb = true; + }else { + isRandCommentb =false; + } + String isRandFollow = functionExecute.getString("is_rand_follow");//是否随机关注(1:是随机关注,0:否) + if(isRandFollow.equals("1")){ + isRandFollowb = true; + }else { + isRandFollowb =false; + } + String maxFollow = functionExecute.getString("max_follow");//最大关注数 + // String maxFollow = "30";//最大关注数 + String andFollow = functionExecute.getString("and_follow");//加关关注数 + String andFans = functionExecute.getString("and_fans");//加关粉丝数 + String minWork = functionExecute.getString("min_work");//最小作品数 + String maxWork = functionExecute.getString("max_work");//最大作品数(新) + String andFollowMax = functionExecute.getString("and_follow_max");//最大加关关注数(新) + String andFansMax = functionExecute.getString("and_fans_max");//最大加关粉丝数(新) + String maxWorkTime = functionExecute.getString("max_work_time");//最大作品时间(天) + String createTime = functionExecute.getString("create_time");//系统时间 + String isRandForward = functionExecute.getString("is_rand_forward");//是否随机转发 + String id = functionExecute.getString("id");//功能id + ChangLiang.short_id = shortId;//抖音id + ChangLiang.task_short_name = shortName;//任务抖音昵称 + ChangLiang.task_id = taskId;//任务id + ChangLiang.id = id;//功能id + String gaizaotime = gaizaotime(end_time); + RecFollowBean recFollowBean = new RecFollowBean(accountDuration,watchDurationMin,watchDurationMax,isRandGoodb,isRandCommentb,isRandFollowb,maxFollow,andFollow,andFans,minWork,maxWorkTime,maxWork,andFollowMax,andFansMax,gaizaotime); + ProfileSpUtils.getInstance().saveProfile(recFollowBean); + Log.e("TIAOSHI###", "一键加关的数据解析成功"); + //领取到任务开始执行,调接口通知后台 + updateTaskStatus(); + //执行帐号切换帐号 + Log.e("TIAOSHI###", "开始执行帐号切换帐号"); + AblStepHandler.getInstance().setStop(false); + startExecution(mContext, AblSteps.STEP_3); + daojishifour(35, funcType); + } catch (JSONException e) { + e.printStackTrace(); + } + } + private String gaizaotime(String end_time) { + String nowString = DateUtils.getNowString(); + String[] all = nowString.split(" "); +// Log.e("TIAOSHI###", nowString); +// Log.e("TIAOSHI###", "获得的抖音号==" + all[0]); +// Log.e("TIAOSHI###", "获得的抖音号==" + all[1]); + String xend_time = all[0]+" "+end_time; + //Log.e("TIAOSHI###", xend_time); + return xend_time; + } + + private void tastJiexitwo(String body) { + Log.e("TIAOSHI###", "一键取关的数据开始解析"); + //拿到这个功能类型,然后去解析数据。 + try { + /** + * -- ---------------------------- + *DROP TABLE IF EXISTS `t_sys_task_function_yjqg`; + * CREATE TABLE `t_sys_task_function_yjqg` ( + * `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键id', + * `task_id` varchar(32) NOT NULL COMMENT '任务id', + * `account_duration` int(11) DEFAULT '0' COMMENT '单账号时长(h)', + * `cancel_type` tinyint(2) DEFAULT '1' COMMENT '取消状态(1:取消已关 2:取消互关)', + * `cancel_num` int(11) DEFAULT '0' COMMENT '取关数', + * `cancel_gap_max` int(11) DEFAULT '0' COMMENT '最大取关间隔(s)', + * `cancel_gap_min` int(11) DEFAULT '0' COMMENT '最小取关间隔(s)', + * `min_cancel_num` int(11) DEFAULT '0' COMMENT '最小开始取关数', + * `save_fans` int(11) DEFAULT '0' COMMENT '互关保留粉丝数', + * `create_time` datetime DEFAULT NULL COMMENT '系统时间', + * PRIMARY KEY (`id`) + * ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='任务功能一键取关表'; + */ + //拿到json字符串,假数据 + // String JsonData = new GetJsonDataUtil().getJson(MainActivity.this, "quguan.json");//获取assets目录下的json文件数据 + JSONObject jsonObject = new JSONObject(body); + JSONObject data = jsonObject.getJSONObject("data"); + String funcType = data.getString("func_type"); + JSONObject functionExecute = data.getJSONObject("function_execute"); + String taskId = data.getString("task_id");//任务id + String shortId = data.getString("short_id");//抖音id + String shortName = data.getString("short_name");//抖音昵称 + functionExecute.getString("account_duration");//单账号时长(h) + String cancelType = functionExecute.getString("cancel_type");//取消状态(1:取消已关 2:取消互关) + String cancelNum = functionExecute.getString("cancel_num");//取关数 + functionExecute.getString("cancel_gap_max");//最大取关间隔(s) + functionExecute.getString("cancel_gap_min");//最小取关间隔(s) + String minCancelNum = functionExecute.getString("min_cancel_num");//最小开始取关数 + String saveFans = functionExecute.getString("save_fans");//互关保留粉丝数 + functionExecute.getString("create_time");//系统时间 + String id = functionExecute.getString("id");//功能id + ChangLiang.task_id = taskId;//任务id + ChangLiang.short_id = shortId;//抖音id + ChangLiang.task_short_name = shortName;//任务抖音昵称 + ChangLiang.id = id;//功能id + if (valueOne.equals(cancelType)) { + ChangLiang.cancelclosed = true; + } else { + ChangLiang.cancelcrosscor = true; + } + ChangLiang.passnumber = cancelNum; + ChangLiang.swiinterval = "1"; + ChangLiang.minthrthr = minCancelNum; + ChangLiang.minfans = saveFans; + Log.e("TIAOSHI###", "一键取关的数据解析成功"); + //领取到任务开始执行,调接口通知后台 + updateTaskStatus(); + //执行帐号切换帐号 + Log.e("TIAOSHI###", "执行帐号切换帐号"); + startExecution(mContext, AblSteps.STEP_3); + daojishifour(30, funcType); + + } catch (JSONException e) { + e.printStackTrace(); + } + } + + + private void tastJiexithree(String body) { + Log.e("TIAOSHI###", "幢号的数据开始解析"); + //拿到这个功能类型,然后去解析数据。 + try { + //拿到json字符串,假数据 + // String JsonData = new GetJsonDataUtil().getJson(MainActivity.this, "quguan.json");//获取assets目录下的json文件数据 + JSONObject jsonObject = new JSONObject(body); + JSONObject data = jsonObject.getJSONObject("data"); + String funcType = data.getString("func_type"); + JSONObject functionExecute = data.getJSONObject("function_execute"); + String taskId = data.getString("task_id");//任务id + String shortId = data.getString("short_id");//抖音id + String shortName = data.getString("short_name");//抖音昵称 + + String accountDuration = functionExecute.getString("account_duration");//单账号时长 + String touchNum = functionExecute.getString("touch_num");//幢号数量 + String ifQuguan = functionExecute.getString("if_quguan");//是否取关 + ChangLiang.if_quguan = ifQuguan;//是否要先取关,0是要取关 1是不要取关 + + functionExecute.getString("create_time");//系统时间 + String id = functionExecute.getString("id");//功能id + ChangLiang.task_id = taskId;//任务id + ChangLiang.short_id = shortId;//抖音id + ChangLiang.task_short_name = shortName;//任务抖音昵称 + ChangLiang.id = id;//功能id + ChangLiang.account_duration = ChangLiang.account_duration;//功能id + ChangLiang.touch_num = touchNum;//功能id + + Log.e("TIAOSHI###", "幢号的数据解析成功"); + updateTaskStatus(); + //如果当前登录的抖音号和后台指派任务的抖音号不一致 + touchTask(touchNum, new MainActivity.Zhuanhaoretren() { + @Override + public void call(touchTaskBean urgentTaskBean, String success) { + if (valueZero.equals(success)) { + phoneNumber = urgentTaskBean.getData(); + Log.e("TIAOSHI###", "幢号的数据解析成功个数==" + phoneNumber.size()); + //存入本地数据库 + for (int i = 0; i < phoneNumber.size(); i++) { + zhuanghaoBeanData zhuanghaoBeanData = phoneNumber.get(i); + if (null != zhanghaoDao.queryByCustom("Id", zhuanghaoBeanData.getId()) && zhanghaoDao.queryByCustom("Id", zhuanghaoBeanData.getId()).size() > 0) { + zhanghaoDao.updateData(zhuanghaoBeanData); + } else { + zhanghaoDao.addInsert(zhuanghaoBeanData); + } + } + //导入通讯录 + ContactsHelp.getInstance(mContext).importContacts(phoneNumber); + //执行帐号切换帐号 + startExecution(mContext, AblSteps.STEP_3); + daojishifour(30, funcType); + } else if (valueTwoF.equals(success)) { + Log.e("TIAOSHI###", "获取撞号账号==" + urgentTaskBean.getMsg()); + //表示撞号结束,可以去请求其他任务 + finishTask(); + } + } + }); + } catch (JSONException e) { + e.printStackTrace(); + } + } + /** + * app每执行完一个任务成功后调取接口 + */ + private void finishTask() { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("short_id", ChangLiang.short_id);// 拿到的抖音id + paramsPost.put("task_id", ChangLiang.task_id);//拿到的任务id + paramsPost.put("id", ChangLiang.id);//功能id + paramsPost.put("task_type", ChangLiang.task_type);//拿到的任务类型 1:代表账号登录 2:停任务 3:代表紧急任务,4:代表固定任务 + + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_FinishTask).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if (valueZero.equals(success)) { + Log.e("TIAOSHI###", "每执行完一个任务成功后调取接口==" + msg); + Log.e("TIAOSHI###", "任务执行完毕,领取新的任务。"); + ChangLiang.isstarttwo = "0"; + ChangLiang.isstart = "0"; + fixedTask(); + } + } catch (JSONException e) { + e.printStackTrace(); + } + + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + /** + * 固定任务(当前任务执行完请求下一个任务接口) + * 此处有一个核心逻辑,最后三个参数,传值分两种情况,一、如果来的紧急任务是一个停任务,那么就传空。二、如果来的紧急任务是一个其它任务。那么就传值 + */ + private void fixedTask() { + if (valueTwo.equals(ChangLiang.task_type)) { + Log.e("TIAOSHI###", "执行了传值分两种情况第一种情况"); + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("short_id", ChangLiang.short_id);// 拿到的抖音id + paramsPost.put("task_id", ChangLiang.task_id);//拿到的任务id + paramsPost.put("id", ChangLiang.id);//功能id + paramsPost.put("task_type", ChangLiang.task_type);//拿到的任务类型 1:代表账号登录 2:停任务 3:代表紧急任务,4:代表固定任务 + paramsPost.put("urgent_short_id", "");//未处理完成紧急任务抖音id + paramsPost.put("urgent_task_id", "");//未处理完成紧急任务id + paramsPost.put("urgent_id", "");// 未处理完成紧急功能id + paramsPost.put("fixed_short_id", "");//未处理完成固定任务抖音id + paramsPost.put("fixed_task_id", "");//未处理完成固定任务id + paramsPost.put("fixed_id", "");//未处理完成固定功能id + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_fixedTask).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + UrgentTaskBean urgentTaskBean = JsonUtils.fromJson(body, UrgentTaskBean.class); + int success = urgentTaskBean.getSuccess(); + if (success == 0) { + //初始化5秒的接口参数 + ChangLiang.task_id = "";//当前执行任务id + ChangLiang.id = "";//当前执行任务功能id + ChangLiang.task_type = "";//当前执行任务类型 + } + startTask(body); + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } else { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("short_id", ChangLiang.short_id);// 拿到的抖音id + paramsPost.put("task_id", ChangLiang.task_id);//拿到的任务id + paramsPost.put("id", ChangLiang.id);//功能id + paramsPost.put("task_type", ChangLiang.task_type);//拿到的任务类型 1:代表账号登录 2:停任务 3:代表紧急任务,4:代表固定任务 + paramsPost.put("urgent_short_id", ChangLiang.short_id_jf);//未处理完成紧急任务抖音id + paramsPost.put("urgent_task_id", ChangLiang.task_id_jf);//未处理完成紧急任务id + paramsPost.put("urgent_id", ChangLiang.id_jf);// 未处理完成紧急功能id + paramsPost.put("fixed_short_id", ChangLiang.short_id_f);//未处理完成固定任务抖音id + paramsPost.put("fixed_task_id", ChangLiang.task_id_f);//未处理完成固定任务id + paramsPost.put("fixed_id", ChangLiang.id_f);//未处理完成固定功能id + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_fixedTask).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + startTask(body); + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + } + private void tastJiexifive(String body) { + Log.e("TIAOSHI###", "抢红包的数据开始解析"); + /** + * -- 直播间抢抖币 + * { + * "success": 4, + * "msg": "执行固定任务", + * "data": { + * "task_type": "4", -- 固定任务 + * "short_id": "tangjie0501", -- 抖音号 + * "short_name": "软件工程师蝴蝶剑", -- 抖音名称 + * "task_id": "3000def9108812dbd2df76980516532e", -- 任务id + * "start_time": "09:00:00", -- 开始时间 + * "end_time": "16:00:00", -- 结束时间 + * "create_time": "2021-01-12 18:31:22", -- 创建时间 + * "function_execute": { + * "id": 1, -- 任务功能id + * "task_id": "3000def9108812dbd2df76980516532e", -- 任务id + * "account_duration": 2, -- 单账号时长(h) + * "live_num": 10, -- 直播间个数 + * "change_time": 3, -- 切换时间设置(s) + * "live_speech": 1, -- 直播间话术是否开启 1:开启 0:关闭' + * "live_click": 1, -- 是否点赞 1:是 0:否 + * "grab_lucky_bag": 1, -- 是否抢福袋 1:是 0:否 + * "bag_min_coin": 1, -- 抢福袋时,抖币的最小数字,小于则不参与 + * "grab_red_envelopes": 1, -- 是否抢红包 1:是 0:否 + * "red_min_coin": 1, -- 抢红包时,抖币的最小数字,大于参与 + * "create_time": "2021-07-01 10:48:37", -- 创建时间 + * "task_type": 1, -- 任务类型(1:固定 0:临时) + * "if_quguan": 1, -- 0:要取关,1:不要取关 + * "touch_num": "0" -- 撞号数量 + * }, + * "func_type": "5" -- 任务功能是直播间抢抖币* } + * } + */ + //拿到这个功能类型,然后去解析数据。 + try { + //拿到json字符串,假数据 + // String JsonData = new GetJsonDataUtil().getJson(MainActivity.this, "quguan.json");//获取assets目录下的json文件数据 + JSONObject jsonObject = new JSONObject(body); + JSONObject data = jsonObject.getJSONObject("data"); + String createTime =data.getString("create_time"); + String endTime =data.getString("end_time"); + String startTime =data.getString("start_time"); + String funcType = data.getString("func_type"); + String taskId = data.getString("task_id");//任务id + String shortId = data.getString("short_id");//抖音id + String shortName = data.getString("short_name");//抖音昵称 + String taskType = data.getString("task_type");//固定任务 + + JSONObject functionExecute = data.getJSONObject("function_execute"); + String id = functionExecute.getString("id");//单账号时长(h) + String accountDuration = functionExecute.getString("account_duration");//单账号时长(h) + String liveNum = functionExecute.getString("live_num");//直播间个数 + String changeTime = functionExecute.getString("change_time");//直播间切换时间 + String redMinCoin = functionExecute.getString("red_min_coin");//抢红包时,抖币的最小数字,大于参与 + String liveSpeech = functionExecute.getString("live_speech");//直播间话术是否开启 1:开启 0:关闭' + String liveClick = functionExecute.getString("live_click");//是否点赞 1:是 0:否 + String grabRedEnvelopes = functionExecute.getString("grab_red_envelopes");//是否抢红包 1:是 0:否 + + + ChangLiang.task_id = taskId;//任务id + ChangLiang.short_id = shortId;//抖音id + ChangLiang.task_short_name = shortName;//任务抖音昵称 + ChangLiang.task_type = taskType;//固定任务 + ChangLiang.id = id;//功能id + ChangLiang.func_type = funcType;//功能id + String gaizaotime = gaizaotime(endTime); + RedEnvBean redEnvBean = new RedEnvBean(); + redEnvBean.setEndtime(gaizaotime); + String accountduration = Integer.parseInt(accountDuration)*60+""; + // String accountduration = Integer.parseInt(accountDuration)+""; + redEnvBean.setRuntime(accountduration); + redEnvBean.setLivenum(liveNum); + String changetime = Integer.parseInt(changeTime)+""; + redEnvBean.setQiehuantime(changetime); + redEnvBean.setDoubinum(redMinCoin); + if(valueOne.equals(liveSpeech)){ + redEnvBean.setRedswitchone(true); + }else { + redEnvBean.setRedswitchone(false); + } + if(valueOne.equals(liveClick)){ + redEnvBean.setRedswitchtwo(true); + }else { + redEnvBean.setRedswitchtwo(false); + } + if(valueOne.equals(grabRedEnvelopes)){ + redEnvBean.setRedswitchthree(true); + }else { + redEnvBean.setRedswitchthree(false); + } + ProfileSpUtils.getInstance().saveRedEnvBean(redEnvBean); + Log.e("TIAOSHI###", "抢红包的数据解析成功"); + //领取到任务开始执行,调接口通知后台 + updateTaskStatus(); + Log.e("TIAOSHI###", "执行帐号切换帐号"); + startExecution(mContext, AblSteps.STEP_3); + daojishifour(30, funcType); + } catch (JSONException e) { + e.printStackTrace(); + } + } + + private void tastJiexisix(String body) { + Log.e("TIAOSHI###", "抢红包的数据开始解析"); + /** + -- 直播间加热 + { + "success": 4, + "msg": "执行固定任务", + "data": { + "task_type": "4", -- 固定任务 + "short_id": "tangjie0501", -- 抖音id + "short_name": "软件工程师蝴蝶剑", -- 抖音名 + "task_id": "3000def9108812dbd2df76980516532e", -- 任务id + "start_time": "09:00:00",-- 开始时间 + "end_time": "16:00:00", -- 结束时间 + "create_time": "2021-01-12 18:31:22", -- 创建时间 + "function_execute": { + "id": 1, -- 任务功能id + "task_id": "3000def9108812dbd2df76980516532e", -- 任务id + "account_duration": 1, -- 单账号时长(h) + "live_nickname": "12", -- 加热直播间抖音昵称 + "live_come": 1, -- 进直播间方式 1:直播广场 2:关注列表 + "live_speech": 1, -- 直播间话术是否开启 1:开启 0:关闭 + "live_click": 0, -- 是否点赞 1:是 0:否 + "live_documentary": 1, -- 直播间跟单 1:是 0:否 + "fans_gift": 1, -- 优先粉丝团礼物 1:是 0:否 + "fans_gift_type": 1, -- 礼物类型 1:固定礼物 2:全部礼物 + "gift_heart": 1, -- 心心相吸的个数 + "gift_time_min": 3, -- 随机间隔时间的最小时间(分) + "gift_time_max": 10, -- 随机间隔时间的最大时间(分) + "grab_lucky_bag": 1, -- 是否抢福袋 1:是 0:否 + "bag_min_coin": 1, -- 抢福袋时,抖币的最小数字,小于则不参与 + "grab_red_envelopes": 1, -- 是否抢红包 1:是 0:否 + "red_min_coin": 2, -- 抢红包时,抖币的最小数字,大于参与 + "create_time": "2021-07-01 10:50:51", -- 创建事假 + "task_type": 1, -- 任务类型(1:固定 0:临时) + "if_quguan": 1, -- 0:要取关,1:不要取关 + "touch_num": "0" -- -- 撞号数量 + }, + "func_type": "6" -- 任务功能是直播间加热 + } + } + */ + //拿到这个功能类型,然后去解析数据。 + try { + //拿到json字符串,假数据 + // String JsonData = new GetJsonDataUtil().getJson(MainActivity.this, "quguan.json");//获取assets目录下的json文件数据 + JSONObject jsonObject = new JSONObject(body); + JSONObject data = jsonObject.getJSONObject("data"); + String createTime =data.getString("create_time"); + String endTime =data.getString("end_time"); + String startTime =data.getString("start_time"); + String funcType = data.getString("func_type"); + String taskId = data.getString("task_id");//任务id + String shortId = data.getString("short_id");//抖音id + String shortName = data.getString("short_name");//抖音昵称 + String taskType = data.getString("task_type");//固定任务 + + JSONObject functionExecute = data.getJSONObject("function_execute"); + String id = functionExecute.getString("id");//-- 任务功能id + String taskId1 = functionExecute.getString("task_id");//-- 任务id + String accountDuration = functionExecute.getString("account_duration");//单账号时长(h) + String liveNickname = functionExecute.getString("live_nickname");//-- 加热直播间抖音昵称 + String liveCome = functionExecute.getString("live_come");//-- -- 进直播间方式 1:直播广场 2:关注列表 + String liveSpeech = functionExecute.getString("live_speech");// -- 直播间话术是否开启 1:开启 0:关闭 + String liveClick = functionExecute.getString("live_click");// -- 是否点赞 1:是 0:否 + String liveDocumentary = functionExecute.getString("live_documentary");// -- 直播间跟单 1:是 0:否 + String fansGift = functionExecute.getString("fans_gift");// -- 优先粉丝团礼物 1:是 0:否 + String fansGiftType = functionExecute.getString("fans_gift_type");// -- 礼物类型 1:固定礼物 2:全部礼物 + String giftHeart = functionExecute.getString("gift_heart");// -- 心心相吸的个数 + String giftTimeMin = functionExecute.getString("gift_time_min");// -- 随机间隔时间的最小时间(分) + String giftTimeMax = functionExecute.getString("gift_time_max");// -- 随机间隔时间的最大时间(分) + String grabLuckyBag = functionExecute.getString("grab_lucky_bag");// -- 是否抢福袋 1:是 0:否 + String bagMinCoin = functionExecute.getString("bag_min_coin");// -- 抢福袋时,抖币的最小数字,小于则不参与 + String grabRedEnvelopes = functionExecute.getString("grab_red_envelopes");// -- 是否抢红包 1:是 0:否 + String redMinCoin = functionExecute.getString("red_min_coin");//-- 抢红包时,抖币的最小数字,大于参与 + String ifQuguan = functionExecute.getString("if_quguan");//-- 0:要取关,1:不要取关 + String touchNum = functionExecute.getString("touch_num");//-- 撞号数量 + + ChangLiang.task_id = taskId;//任务id + ChangLiang.short_id = shortId;//抖音id + ChangLiang.task_short_name = shortName;//任务抖音昵称 + ChangLiang.task_type = taskType;//固定任务 + ChangLiang.id = id;//功能id + String gaizaotime = gaizaotime(endTime); + + LiveBean liveBean = new LiveBean(); + liveBean.setEndtime(gaizaotime); + liveBean.setDouyinhao(liveNickname); + String accountduration = Integer.parseInt(accountDuration)*60+""; + liveBean.setZhibomin(accountduration); + if(valueOne.equals(liveSpeech)){ + liveBean.setSwitchone(true); + }else { + liveBean.setSwitchone(false); + } + if(valueOne.equals(liveClick)){ + liveBean.setSwitchtwo(true); + }else { + liveBean.setSwitchtwo(false); + } + if(valueOne.equals(liveDocumentary)){ + liveBean.setSwitchthree(true); + }else { + liveBean.setSwitchthree(false); + } + if(valueOne.equals(fansGift)){ + liveBean.setSwitchfive(true); + }else { + liveBean.setSwitchfive(false); + } + + ProfileSpUtils.getInstance().saveLiveBean(liveBean); + Log.e("TIAOSHI###", "直播间加热的数据解析成功"); + //领取到任务开始执行,调接口通知后台 + updateTaskStatus(); + //执行帐号切换帐号 + Log.e("TIAOSHI###", "执行帐号切换帐号"); + startExecution(mContext, AblSteps.STEP_3); + daojishifour(30, funcType); + } catch (JSONException e) { + e.printStackTrace(); + } + } + + private void tastJiexidenglu(String body) { + //拿到这个功能类型,然后去解析数据。 + try { + //拿到json字符串,假数据 + // String JsonData = new GetJsonDataUtil().getJson(MainActivity.this, "denglu.json");//获取assets目录下的json文件数据 + JSONObject jsonObject = new JSONObject(body); + JSONObject data = jsonObject.getJSONObject("data"); + String phone = data.getString("phone"); + ChangLiang.phonenum = phone; + // ChangLiang.tasktype = 1; + ChangLiang.task_type = "1"; + updateTaskStatus(); + AblUtil.addSuspensionWindowView(mContext, controlWindow.initWindowView("4")); + } catch (JSONException e) { + e.printStackTrace(); + } + } + + /** + * 停任务的倒计时 + * + * @param a + */ + private void taskdaojishi(final int a) { + //启动计时器 + //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 + mdDisposable = Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) + .observeOn(AndroidSchedulers.mainThread()) + .doOnNext(new Consumer() { + @Override + public void accept(Long aLong) throws Exception { + long b = a - aLong; + Log.e("TIAOSHI###", b + ""); + } + }) + .doOnComplete(new Action() { + @Override + public void run() throws Exception { + AblStepHandler.getInstance().setStop(false); + // StartExecution(MainActivity.this, AblSteps.STEP_109); + Log.e("TIAOSHI###", "开始执行关闭抖音程序"); + startExecution(mContext, AblSteps.STEP_192); + } + }) + .subscribe(); + } + + + /** + * 开始执行 + */ + public void startExecution(Context context,int arg) { + if (AblUtil.isAccessibilityServiceOpen(context)) { + AblStepHandler.getInstance().setStop(false); + AblStepHandler.sendMsg(arg); + } else { + ToastUtils.showShort("点到了"); + ToastUtils.showShort("请先开启辅助服务"); + AblUtil.openAccessibilitySettings(); + } + + } + + /** + * 获取撞号账号 + * 如果{"success":-2,"msg":"暂无需要撞号的账号"}停止撞号任务 + */ + private void touchTask(String touchNum, MainActivity.Zhuanhaoretren zhuanhaoretren) { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("short_id", ChangLiang.short_id);// 拿到的抖音id + paramsPost.put("touch_num", touchNum);//功能id + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_touchTask).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + touchTaskBean urgentTaskBean = JsonUtils.fromJson(body, touchTaskBean.class); + int success = urgentTaskBean.getSuccess(); + zhuanhaoretren.call(urgentTaskBean, urgentTaskBean.getSuccess() + ""); + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + /** + * 倒计时开始执行任务 + * + * @param a + */ + private void daojishifour(final int a, String funcType) { + //启动计时器 + //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 + mdDisposable = Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) + .observeOn(AndroidSchedulers.mainThread()) + .doOnNext(new Consumer() { + @Override + public void accept(Long aLong) throws Exception { + long b = a - aLong; + Log.e("TIAOSHI###", b + ""); + } + }) + .doOnComplete(new Action() { + @Override + public void run() throws Exception { + //先判断无障碍是否开启 + Log.e("TIAOSHI###", "temp3"); + AblUtil.addSuspensionWindowView(mContext, controlWindow.initWindowView(funcType)); + } + }) + .subscribe(); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/noticeActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/noticeActivity.java new file mode 100644 index 0000000..db59ae5 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/noticeActivity.java @@ -0,0 +1,214 @@ +package com.fisherbone.fuzhu.activity; + +import android.os.Bundle; +import android.view.View; +import android.view.ViewGroup; +import android.widget.EditText; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.adapter.noticeAdapter; +import com.fisherbone.fuzhu.db.CommentBeanData; +import com.fisherbone.fuzhu.entity.FourEvent; +import com.fisherbone.fuzhu.entity.NoticeBean; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.fisherbone.fuzhu.widget.TitleBar; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import de.greenrobot.event.EventBus; + +/** + * 粉丝通知 + */ +public class noticeActivity extends BaseActivity { + private TitleBar mTitleBar; + private RecyclerView mRecyclerView; + private noticeAdapter headerAndFooterAdapter; + private List statuses; + private String ed01; + private String ed02; + private String select="1"; //1直播间 2视频 3话术 + private TextView tv_sec_01,tv_sec_03,tv_sec_05; + private EditText ed_douyin; + private EditText ed_01; + private EditText ed_02; + private RelativeLayout rl_douyin; + private RelativeLayout rl_tianshu; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_notice); + mTitleBar = (TitleBar) findViewById(R.id.title_bar); + mTitleBar.setTitle("粉丝通知"); + initNormalBack(); + + + mRecyclerView = (RecyclerView) findViewById(R.id.rv_list); + mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); + NoticeBean fensiNotice = ProfileSpUtils.getInstance().getFensiNotice(); + List commentBeanDataList = fensiNotice.getCommentBeanDataList(); + statuses = new ArrayList<>(); + if(commentBeanDataList!=null&&commentBeanDataList.size()>0){ + statuses.addAll(commentBeanDataList); + }else { + CommentBeanData status = new CommentBeanData(); + status.setComment(""); + status.setId(new Random().nextInt(10000)+""); + statuses.add(status); + } + initAdapter(); + + findViewById(R.id.rl_start).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + NoticeBean noticeBean = new NoticeBean(); + noticeBean.setDouyin(ed_douyin.getText().toString()); + noticeBean.setFensinum(ed_01.getText().toString()); + String s = ed_01.getText().toString(); + int y = Integer.parseInt(s); + ChangLiang.bnumber=y/8;//设置循环次数 + noticeBean.setLettertype(select); + noticeBean.setZuopinday(ed_02.getText().toString()); + noticeBean.setCommentBeanDataList(statuses); + ProfileSpUtils.getInstance().saveFensiNotice(noticeBean); + EventBus.getDefault().post(new FourEvent("success","5")); + } + }); + + + View footerView = getFooterView(0, new View.OnClickListener() { + @Override + public void onClick(View v) { + CommentBeanData status = new CommentBeanData(); + status.setComment(""); + status.setId(0 + ""+new Random().nextInt(10000)); + statuses.add(status); + headerAndFooterAdapter.notifyDataSetChanged(); + int size = statuses.size(); + mRecyclerView.scrollToPosition(size+1); // 将ListView定位到最后一行 + } + }); + View headView = getHeadView("0", new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }); + headerAndFooterAdapter.addHeaderView(headView,0); + headerAndFooterAdapter.addFooterView(footerView, 0); + + mRecyclerView.setAdapter(headerAndFooterAdapter); + + tv_sec_01.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + select="1"; + menu("1"); + + } + }); + tv_sec_03.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + select="2"; + menu("2"); + + } + }); + tv_sec_05.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + select="3"; + menu("3"); + + } + }); + + } + private void menu(String select) { + if(select.equals("1")){ + tv_sec_01.setBackgroundResource(R.mipmap.icon_cheched_true); + tv_sec_03.setBackgroundResource(R.mipmap.icon_cheched_false); + tv_sec_05.setBackgroundResource(R.mipmap.icon_cheched_false); + rl_douyin.setVisibility(View.VISIBLE); + rl_tianshu.setVisibility(View.GONE); + + }else if(select.equals("2")){ + tv_sec_01.setBackgroundResource(R.mipmap.icon_cheched_false); + tv_sec_03.setBackgroundResource(R.mipmap.icon_cheched_true); + tv_sec_05.setBackgroundResource(R.mipmap.icon_cheched_false); + rl_douyin.setVisibility(View.VISIBLE); + rl_tianshu.setVisibility(View.VISIBLE); + }else{ + tv_sec_01.setBackgroundResource(R.mipmap.icon_cheched_false); + tv_sec_03.setBackgroundResource(R.mipmap.icon_cheched_false); + tv_sec_05.setBackgroundResource(R.mipmap.icon_cheched_true); + rl_douyin.setVisibility(View.GONE); + rl_tianshu.setVisibility(View.VISIBLE); + + } + } + private void initAdapter() { + + headerAndFooterAdapter = new noticeAdapter(statuses); + headerAndFooterAdapter.openLoadAnimation(); + // mRecyclerView.setAdapter(headerAndFooterAdapter); + headerAndFooterAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() { + @Override + public void onItemClick(BaseQuickAdapter adapter, View view, int position) { + // Toast.makeText(PriLetActivity.this, "" + Integer.toString(position), Toast.LENGTH_LONG).show(); + } + }); + } + private View getHeadView(String type, View.OnClickListener listener) { + View view = getLayoutInflater().inflate(R.layout.head_notice_view, (ViewGroup) mRecyclerView.getParent(), false); + ed_douyin = view.findViewById(R.id.ed_douyin); + ed_01 = view.findViewById(R.id.ed_01); + ed_02 = view.findViewById(R.id.ed_02); + tv_sec_01 = view.findViewById(R.id.tv_sec_01); + tv_sec_03 = view.findViewById(R.id.tv_sec_03); + tv_sec_05 = view.findViewById(R.id.tv_sec_05); + rl_douyin = view.findViewById(R.id.rl_douyin); + rl_tianshu = view.findViewById(R.id.rl_tianshu); +// ed01 = ed_01.getText().toString(); +// ed02 = ed_02.getText().toString(); + NoticeBean fensiNotice = ProfileSpUtils.getInstance().getFensiNotice(); + String douyin = fensiNotice.getDouyin(); + ed_douyin.setText(douyin); + String fensinum = fensiNotice.getFensinum(); + ed_01.setText(fensinum); + String zuopinday = fensiNotice.getZuopinday(); + ed_02.setText(zuopinday); + String lettertype = fensiNotice.getLettertype(); + if(lettertype.equals("1")){ + menu("1"); + select="1"; + } else if(lettertype.equals("2")){ + menu("2"); + select="2"; + }else{ + menu("3"); + select="3"; + } + view.setOnClickListener(listener); + return view; + } + private View getFooterView(int type, View.OnClickListener listener) { + View view = getLayoutInflater().inflate(R.layout.footer_prilet_view, (ViewGroup) mRecyclerView.getParent(), false); + view.setOnClickListener(listener); + return view; + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/adapter/CourseAdapter.java b/app/src/main/java/com/fisherbone/fuzhu/adapter/CourseAdapter.java new file mode 100644 index 0000000..45efa18 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/adapter/CourseAdapter.java @@ -0,0 +1,111 @@ +package com.fisherbone.fuzhu.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; + +import androidx.appcompat.app.AlertDialog; + +import com.fisherbone.fuzhu.entity.DealInfoBean; + +import java.util.List; + +/** + * @author: qndroid + * @function: + * @date: 16/6/15 + */ +public class CourseAdapter extends BaseAdapter { + + private static final int CARD_COUNT = 2; + private static final int VIDOE_TYPE = 0; + private static final int CARD_TYPE_ONE = 1; + private AlertDialog alert = null; + private AlertDialog.Builder builder = null; + + + private LayoutInflater mInflate; + private Context mContext; + private List mData; + private ViewHolder mViewHolder; + + + public CourseAdapter(Context context) { + mContext = context; + mInflate = LayoutInflater.from(mContext); + } + + @Override + public int getCount() { + return 0; + } + + @Override + public Object getItem(int position) { + return mData.get(position); + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public int getViewTypeCount() { + return CARD_COUNT; + } + + @Override + public int getItemViewType(int position) { + //根据moudle的个数做奇偶判断。 + if (position % 2 != 0) { + return 1; + } else { + return 0; + } + + } + + @Override + public View getView(final int position, View convertView, ViewGroup parent) { + int type = getItemViewType(position); + // final gengzonglishi.DataBean value = (gengzonglishi.DataBean) getItem(position); + //无tag时 + if (convertView == null) { + switch (type) { + case VIDOE_TYPE: + + + break; + case CARD_TYPE_ONE: + + break; + default: + + } + convertView.setTag(mViewHolder); + }//有tag时 + else { + mViewHolder = (ViewHolder) convertView.getTag(); + } + //填充item的数据 + switch (type) { + case VIDOE_TYPE: + + break; + case CARD_TYPE_ONE: + + break; + default: + } + return convertView; + } + + private static class ViewHolder { + + + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/adapter/DakaAdapter.java b/app/src/main/java/com/fisherbone/fuzhu/adapter/DakaAdapter.java new file mode 100644 index 0000000..23c6969 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/adapter/DakaAdapter.java @@ -0,0 +1,62 @@ +package com.fisherbone.fuzhu.adapter; + +import android.text.Editable; +import android.text.TextUtils; +import android.text.TextWatcher; +import android.widget.EditText; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.chad.library.adapter.base.BaseViewHolder; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.entity.AddDakaBeanData; + +import java.util.List; + + +public class DakaAdapter extends BaseQuickAdapter { + + public DakaAdapter(List statuses) { + super(R.layout.item_daka,statuses); + } + + @Override + protected void convert(BaseViewHolder helper, final AddDakaBeanData item) { + + EditText et_coneten = (EditText) helper.getView(R.id.et_coneten); + + //1、为了避免TextWatcher在第2步被调用,提前将他移除。 + if (et_coneten.getTag() instanceof TextWatcher) { + et_coneten.removeTextChangedListener((TextWatcher) (et_coneten.getTag())); + } + + + // 第2步:移除TextWatcher之后,设置EditText的Text。 + et_coneten.setText(item.getComment()); + + + TextWatcher watcher = new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + } + + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + } + + + @Override + public void afterTextChanged(Editable editable) { + if (TextUtils.isEmpty(editable.toString())) { + item.setComment(""); + } else { + item.setComment(editable.toString()); + } + } + }; + et_coneten.addTextChangedListener(watcher); + et_coneten.setTag(watcher); + } + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/adapter/HeaderAndFooterAdapter.java b/app/src/main/java/com/fisherbone/fuzhu/adapter/HeaderAndFooterAdapter.java new file mode 100644 index 0000000..862e68c --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/adapter/HeaderAndFooterAdapter.java @@ -0,0 +1,65 @@ +package com.fisherbone.fuzhu.adapter; + +import android.text.Editable; +import android.text.TextUtils; +import android.text.TextWatcher; +import android.widget.EditText; +import android.widget.TextView; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.chad.library.adapter.base.BaseViewHolder; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.db.CommentBeanData; + +import java.util.List; + + +public class HeaderAndFooterAdapter extends BaseQuickAdapter { + + public HeaderAndFooterAdapter(List statuses) { + super(R.layout.item_header_and_footer,statuses); + } + + @Override + protected void convert(BaseViewHolder helper, final CommentBeanData item) { + TextView tv_01 = (TextView) helper.getView(R.id.tv_01); + final int layoutPosition = helper.getLayoutPosition()+1; + tv_01.setText("评论"+layoutPosition); + EditText et_coneten = (EditText) helper.getView(R.id.et_coneten); + + //1、为了避免TextWatcher在第2步被调用,提前将他移除。 + if (et_coneten.getTag() instanceof TextWatcher) { + et_coneten.removeTextChangedListener((TextWatcher) (et_coneten.getTag())); + } + + + // 第2步:移除TextWatcher之后,设置EditText的Text。 + et_coneten.setText(item.getComment()); + + + TextWatcher watcher = new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + } + + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + } + + + @Override + public void afterTextChanged(Editable editable) { + if (TextUtils.isEmpty(editable.toString())) { + item.setComment(""); + } else { + item.setComment(editable.toString()); + } + } + }; + et_coneten.addTextChangedListener(watcher); + et_coneten.setTag(watcher); + } + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/adapter/PriLetAdapter.java b/app/src/main/java/com/fisherbone/fuzhu/adapter/PriLetAdapter.java new file mode 100644 index 0000000..ee4acd4 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/adapter/PriLetAdapter.java @@ -0,0 +1,64 @@ +package com.fisherbone.fuzhu.adapter; + +import android.text.Editable; +import android.text.TextUtils; +import android.text.TextWatcher; +import android.widget.EditText; +import android.widget.TextView; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.chad.library.adapter.base.BaseViewHolder; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.db.CommentBeanData; + +import java.util.List; + + +public class PriLetAdapter extends BaseQuickAdapter { + + public PriLetAdapter(List statuses) { + super(R.layout.item_prilet,statuses); + } + + @Override + protected void convert(BaseViewHolder helper, final CommentBeanData item) { + TextView tv_01 = (TextView) helper.getView(R.id.tv_01); + tv_01.setText("私信话术"); + EditText et_coneten = (EditText) helper.getView(R.id.et_coneten); + + //1、为了避免TextWatcher在第2步被调用,提前将他移除。 + if (et_coneten.getTag() instanceof TextWatcher) { + et_coneten.removeTextChangedListener((TextWatcher) (et_coneten.getTag())); + } + + + // 第2步:移除TextWatcher之后,设置EditText的Text。 + et_coneten.setText(item.getComment()); + + + TextWatcher watcher = new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + } + + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + } + + + @Override + public void afterTextChanged(Editable editable) { + if (TextUtils.isEmpty(editable.toString())) { + item.setComment(""); + } else { + item.setComment(editable.toString()); + } + } + }; + et_coneten.addTextChangedListener(watcher); + et_coneten.setTag(watcher); + } + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/adapter/PriLetEditAdapter.java b/app/src/main/java/com/fisherbone/fuzhu/adapter/PriLetEditAdapter.java new file mode 100644 index 0000000..faec705 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/adapter/PriLetEditAdapter.java @@ -0,0 +1,39 @@ +package com.fisherbone.fuzhu.adapter; + +import android.view.View; +import android.widget.TextView; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.chad.library.adapter.base.BaseViewHolder; +import com.fisherbone.fuzhu.R; + +import java.util.List; + + +public class PriLetEditAdapter extends BaseQuickAdapter { + Itemdelete itemdelete; + public PriLetEditAdapter(List statuses) { + super(R.layout.item_priletedit,statuses); + } + + @Override + protected void convert(BaseViewHolder helper, final com.fisherbone.fuzhu.entity.letterListBean.DataBean item) { + TextView tv_01 = helper.getView(R.id.tv_01); + tv_01.setText("删除"); + TextView et_coneten = helper.getView(R.id.et_coneten); + et_coneten.setText(item.getContent()); + tv_01.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + // ToastUtils.showShort("点击了删除"); + itemdelete.itemdelete(item,helper.getAdapterPosition()); + } + }); + } + public interface Itemdelete{ + void itemdelete(com.fisherbone.fuzhu.entity.letterListBean.DataBean item, int position); + } + public void OnItemDelete(Itemdelete itemdelete){ + this.itemdelete=itemdelete; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/adapter/ScrSetAdapter.java b/app/src/main/java/com/fisherbone/fuzhu/adapter/ScrSetAdapter.java new file mode 100644 index 0000000..a563da5 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/adapter/ScrSetAdapter.java @@ -0,0 +1,49 @@ +package com.fisherbone.fuzhu.adapter; + +import android.content.Context; +import android.view.View; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.chad.library.adapter.base.BaseViewHolder; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.entity.StyleBean; +import com.fisherbone.fuzhu.utils.WidgetTools; + +import java.util.List; + + +public class ScrSetAdapter extends BaseQuickAdapter { + Context mcontext; + OnViewClickListener onViewClickListener; + + public ScrSetAdapter(Context context, List list) { + super(R.layout.scrset_item, list); + this.mcontext = context; + } + + @Override + protected void convert(final BaseViewHolder helper, final StyleBean.ResultBean.DataBean item) { + WidgetTools.setTextfive((TextView) helper.getView(R.id.tv_style), "", item.getStyle()); + RelativeLayout rl_style = (RelativeLayout)helper.getView(R.id.rl_style); + rl_style.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + onViewClickListener.enterCusDetail(item); + } + }); + + } + + public void operationListenner(OnViewClickListener onViewClickListener){ + this.onViewClickListener = onViewClickListener; + } + + public interface OnViewClickListener{ + + void enterCusDetail(StyleBean.ResultBean.DataBean item); + + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/adapter/noticeAdapter.java b/app/src/main/java/com/fisherbone/fuzhu/adapter/noticeAdapter.java new file mode 100644 index 0000000..6203796 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/adapter/noticeAdapter.java @@ -0,0 +1,60 @@ +package com.fisherbone.fuzhu.adapter; + +import android.text.Editable; +import android.text.TextUtils; +import android.text.TextWatcher; +import android.widget.EditText; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.chad.library.adapter.base.BaseViewHolder; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.db.CommentBeanData; + +import java.util.List; + + +public class noticeAdapter extends BaseQuickAdapter { + + public noticeAdapter(List statuses) { + super(R.layout.item_notice,statuses); + } + + @Override + protected void convert(BaseViewHolder helper, final CommentBeanData item) { + + EditText et_coneten = (EditText) helper.getView(R.id.et_coneten); + + //1、为了避免TextWatcher在第2步被调用,提前将他移除。 + if (et_coneten.getTag() instanceof TextWatcher) { + et_coneten.removeTextChangedListener((TextWatcher) (et_coneten.getTag())); + } + + + // 第2步:移除TextWatcher之后,设置EditText的Text。 + et_coneten.setText(item.getComment()); + + + TextWatcher watcher = new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + } + + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + } + + + @Override + public void afterTextChanged(Editable editable) { + if (TextUtils.isEmpty(editable.toString())) { + item.setComment(""); + } else { + item.setComment(editable.toString()); + } + } + }; + et_coneten.addTextChangedListener(watcher); + et_coneten.setTag(watcher); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/api/GetVesionResponseBean.java b/app/src/main/java/com/fisherbone/fuzhu/api/GetVesionResponseBean.java new file mode 100644 index 0000000..f2bcd2a --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/api/GetVesionResponseBean.java @@ -0,0 +1,59 @@ +package com.fisherbone.fuzhu.api; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import com.xiangxue.common.network.beans.TecentBaseResponse; + +public class GetVesionResponseBean extends TecentBaseResponse { + + + @SerializedName("version") + @Expose + private String version; + @SerializedName("content") + @Expose + private String content; + @SerializedName("link") + @Expose + private String link; + + public Integer getSuccess() { + return success; + } + + public void setSuccess(Integer success) { + this.success = success; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getLink() { + return link; + } + + public void setLink(String link) { + this.link = link; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/api/NewsApiInterface.java b/app/src/main/java/com/fisherbone/fuzhu/api/NewsApiInterface.java new file mode 100644 index 0000000..1681a04 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/api/NewsApiInterface.java @@ -0,0 +1,13 @@ +package com.fisherbone.fuzhu.api; + +import io.reactivex.Observable; +import retrofit2.http.GET; + +/** + * Created by Allen on 2017/7/20. + * 保留所有版权,未经允许请不要分享到互联网和其他人 + */ +public interface NewsApiInterface { + @GET("app/Appoperate/NowVersion") + Observable getNowVersion(); +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/api/NewsChannelsBean.java b/app/src/main/java/com/fisherbone/fuzhu/api/NewsChannelsBean.java new file mode 100644 index 0000000..21007d4 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/api/NewsChannelsBean.java @@ -0,0 +1,38 @@ +package com.fisherbone.fuzhu.api; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import com.xiangxue.common.network.beans.TecentBaseResponse; + +import java.util.List; + +/** + * Created by Allen on 2017/7/20. + * 保留所有版权,未经允许请不要分享到互联网和其他人 + */ +public class NewsChannelsBean extends TecentBaseResponse { + @SerializedName("showapi_res_body") + @Expose + public ShowapiResBody showapiResBody; + + public class ChannelList { + @SerializedName("channelId") + @Expose + public String channelId; + @SerializedName("name") + @Expose + public String name; + } + + public class ShowapiResBody { + @SerializedName("totalNum") + @Expose + public Integer totalNum; + @SerializedName("ret_code") + @Expose + public Integer retCode; + @SerializedName("channelList") + @Expose + public List channelList = null; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/config/Callback.java b/app/src/main/java/com/fisherbone/fuzhu/config/Callback.java new file mode 100644 index 0000000..b72a3a6 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/config/Callback.java @@ -0,0 +1,12 @@ +package com.fisherbone.fuzhu.config; + +/** + * Created by sanmu on 2016/10/13 0013. + *

+ * 自定义对话框接口 + */ +public interface Callback { + void Positive(); + + void Negative(); +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/data/DataServer.java b/app/src/main/java/com/fisherbone/fuzhu/data/DataServer.java new file mode 100644 index 0000000..59000de --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/data/DataServer.java @@ -0,0 +1,27 @@ +package com.fisherbone.fuzhu.data; + + +import com.fisherbone.fuzhu.entity.Status; + +import java.util.List; + +/** + * https://github.com/CymChad/BaseRecyclerViewAdapterHelper + */ +public class DataServer { + + private DataServer() { + } + + public static List addData(List list, int dataSize) { + for (int i = 0; i < dataSize; i++) { + Status status = new Status(); + status.setContent(""); + list.add(status); + } + + return list; + } + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/BigshotData.java b/app/src/main/java/com/fisherbone/fuzhu/db/BigshotData.java new file mode 100644 index 0000000..631bc39 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/BigshotData.java @@ -0,0 +1,42 @@ +package com.fisherbone.fuzhu.db; + +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +import java.io.Serializable; + +@DatabaseTable(tableName = "tab_comment") +public class BigshotData extends DbBean implements Serializable { + @DatabaseField(id = true,columnName = "Id") + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + @DatabaseField(columnName = "comment") + private String comment; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @DatabaseField(columnName = "type") + private String type;//1.评论话术 2.私信话术 3.直播话术 4.回访话术 5.首关话术 +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/CommentBeanData.java b/app/src/main/java/com/fisherbone/fuzhu/db/CommentBeanData.java new file mode 100644 index 0000000..7c64343 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/CommentBeanData.java @@ -0,0 +1,42 @@ +package com.fisherbone.fuzhu.db; + +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +import java.io.Serializable; + +@DatabaseTable(tableName = "tab_comment") +public class CommentBeanData extends DbBean implements Serializable { + @DatabaseField(id = true,columnName = "Id") + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + @DatabaseField(columnName = "comment") + private String comment; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @DatabaseField(columnName = "type") + private String type;//1.评论话术 2.私信话术 3.直播话术 4.回访话术 5.首关话术 +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/CommenttwData.java b/app/src/main/java/com/fisherbone/fuzhu/db/CommenttwData.java new file mode 100644 index 0000000..cf80a53 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/CommenttwData.java @@ -0,0 +1,42 @@ +package com.fisherbone.fuzhu.db; + +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +import java.io.Serializable; + +@DatabaseTable(tableName = "tab_commentt") +public class CommenttwData extends DbBean implements Serializable { + @DatabaseField(id = true,columnName = "Id") + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + @DatabaseField(columnName = "comment") + private String comment; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @DatabaseField(columnName = "type") + private String type;//1.评论话术 2.私信话术 3.直播话术 4.回访话术 5.首关话术 +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/ContentBeanData.java b/app/src/main/java/com/fisherbone/fuzhu/db/ContentBeanData.java new file mode 100644 index 0000000..aa6dbda --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/ContentBeanData.java @@ -0,0 +1,34 @@ +package com.fisherbone.fuzhu.db; + +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +import java.io.Serializable; + +@DatabaseTable(tableName = "tab_content") +public class ContentBeanData extends DbBean implements Serializable { + @DatabaseField(id = true,columnName = "Id") + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + @DatabaseField(columnName = "content") + private String content; + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/DbBean.java b/app/src/main/java/com/fisherbone/fuzhu/db/DbBean.java new file mode 100644 index 0000000..5b06df6 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/DbBean.java @@ -0,0 +1,4 @@ +package com.fisherbone.fuzhu.db; + +public class DbBean { +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/DouyinBean.java b/app/src/main/java/com/fisherbone/fuzhu/db/DouyinBean.java new file mode 100644 index 0000000..03d086a --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/DouyinBean.java @@ -0,0 +1,41 @@ +package com.fisherbone.fuzhu.db; + +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +import java.io.Serializable; + +@DatabaseTable(tableName = "tab_douyin") +public class DouyinBean extends DbBean implements Serializable { + public String getShort_id() { + return short_id; + } + + public void setShort_id(String short_id) { + this.short_id = short_id; + } + + @DatabaseField(columnName = "short_id") + private String short_id=""; + @DatabaseField(columnName = "short_name") + private String short_name=""; + + public String getShort_name() { + return short_name; + } + + public void setShort_name(String short_name) { + this.short_name = short_name; + } + + public String getLogin_status() { + return login_status; + } + + public void setLogin_status(String login_status) { + this.login_status = login_status; + } + + @DatabaseField(columnName = "login_status") + private String login_status=""; +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/KeyWordBean.java b/app/src/main/java/com/fisherbone/fuzhu/db/KeyWordBean.java new file mode 100644 index 0000000..d44fa03 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/KeyWordBean.java @@ -0,0 +1,42 @@ +package com.fisherbone.fuzhu.db; + +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +import java.io.Serializable; + +@DatabaseTable(tableName = "tab_comment") +public class KeyWordBean extends DbBean implements Serializable { + @DatabaseField(id = true,columnName = "Id") + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + @DatabaseField(columnName = "comment") + private String comment; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @DatabaseField(columnName = "type") + private String type;//1.评论话术 2.私信话术 3.直播话术 4.回访话术 5.首关话术 +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/LetterBean.java b/app/src/main/java/com/fisherbone/fuzhu/db/LetterBean.java new file mode 100644 index 0000000..650c550 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/LetterBean.java @@ -0,0 +1,42 @@ +package com.fisherbone.fuzhu.db; + +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +import java.io.Serializable; + +@DatabaseTable(tableName = "tab_comment") +public class LetterBean extends DbBean implements Serializable { + @DatabaseField(id = true,columnName = "Id") + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + @DatabaseField(columnName = "comment") + private String comment; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @DatabaseField(columnName = "type") + private String type;//1.评论话术 2.私信话术 3.直播话术 4.回访话术 5.首关话术 +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/PersonInfo.java b/app/src/main/java/com/fisherbone/fuzhu/db/PersonInfo.java new file mode 100644 index 0000000..e55007e --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/PersonInfo.java @@ -0,0 +1,95 @@ +package com.fisherbone.fuzhu.db; + +/** + * Time: 2021/7/3 + * Author: jianbo + * Description: + */ + +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +import java.io.Serializable; + +@DatabaseTable(tableName = "t_person") +public class PersonInfo implements Serializable { + + @DatabaseField(columnName = "id", generatedId = true) + public int id; + + @DatabaseField(columnName = "personName") + private String personName; + + @DatabaseField(columnName = "personSex") + private String personSex; + + @DatabaseField(columnName = "personAge") + private String personAge; + + @DatabaseField(columnName = "personHeight") + private String personHeight; + + @DatabaseField(columnName = "personNative") + private String personNative; + + @DatabaseField(columnName = "personNumber") + private String personNumber; + + @DatabaseField(columnName = "personImage") + private String personImage; + + /** + * 创建空的构造函数,否则报错 + */ + public PersonInfo() { + } + + public PersonInfo(String personName, String personSex, String personAge, String personHeight, String personNative, String personNumber) { + this.personName = personName; + this.personSex = personSex; + this.personAge = personAge; + this.personHeight = personHeight; + this.personNumber = personNumber; + this.personNative = personNative; + } + + public PersonInfo(String personName, String personSex, String personAge, String personHeight, String personNative, String personNumber, String personImage) { + this.personName = personName; + this.personSex = personSex; + this.personAge = personAge; + this.personHeight = personHeight; + this.personNumber = personNumber; + this.personNative = personNative; + this.personImage = personImage; + } + + public String getPersonName() { + return personName; + } + + public String getPersonSex() { + return personSex; + } + + public String getPersonAge() { + return personAge; + } + + public String getPersonHeight() { + return personHeight; + } + + public String getPersonNative() { + return personNative; + } + + public String getPersonNumber() { + return personNumber; + } + + public String getPersonImage() { + return personImage; + } + +} + diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/RedenvBeanData.java b/app/src/main/java/com/fisherbone/fuzhu/db/RedenvBeanData.java new file mode 100644 index 0000000..1c5bac1 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/RedenvBeanData.java @@ -0,0 +1,58 @@ +package com.fisherbone.fuzhu.db; + +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +import java.io.Serializable; + +@DatabaseTable(tableName = "tab_redenv") +public class RedenvBeanData extends DbBean implements Serializable { + @DatabaseField(id = true,columnName = "Id") + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getLivename() { + return livename; + } + + public void setLivename(String livename) { + this.livename = livename; + } + + //直播间名字 + @DatabaseField(columnName = "livename") + private String livename=""; + + + public String getRedenvtime() { + return redenvtime; + } + + public void setRedenvtime(String redenvtime) { + this.redenvtime = redenvtime; + } + + public String getFudaitime() { + return fudaitime; + } + + public void setFudaitime(String fudaitime) { + this.fudaitime = fudaitime; + } + + //红包倒计时 + @DatabaseField(columnName = "redenvtime") + private String redenvtime="0"; + //福袋倒计时 + @DatabaseField(columnName = "fudaitime") + private String fudaitime="0"; + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/UserData.java b/app/src/main/java/com/fisherbone/fuzhu/db/UserData.java new file mode 100644 index 0000000..c091bcf --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/UserData.java @@ -0,0 +1,307 @@ +package com.fisherbone.fuzhu.db; + +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +import java.io.Serializable; + +///*组织、部门、人员、角色、权限SYS_USER_ROLE_LINKS*/ +@DatabaseTable(tableName = "tab_user") +public class UserData extends DbBean implements Serializable { + @DatabaseField (columnName = "permissionid") + private String permissionid; + @DatabaseField (columnName = "refParentResourceId") + private String refParentResourceId; + @DatabaseField (columnName = "type") + private int type; + + @DatabaseField (columnName = "userisDelete")/*是否删除:逻辑删除,默认值为0*/ + private int userisDelete; + @DatabaseField (columnName = "username")/*人员姓名*/ + private String username; + @DatabaseField (columnName = "objType") + private String objType; + @DatabaseField (columnName = "rolename")/*角色名称*/ + private String rolename; + @DatabaseField (columnName = "deptid")/*部门ID*/ + private String deptid; + @DatabaseField (columnName = "orgid") + private String orgid; + @DatabaseField (columnName = "deptcode")/*部门编码*/ + private String deptcode; + @DatabaseField (columnName = "name") + private String name; + @DatabaseField (columnName = "refResourceCode") + private String refResourceCode; + @DatabaseField (columnName = "deptname")/*部门名称*/ + private String deptname; + @DatabaseField (columnName = "usernike")/*人员昵称*/ + private String usernike; + @DatabaseField (columnName = "depttype")/*部门类型*/ + private int depttype; + @DatabaseField (columnName = "isOper") + private int isOper; + @DatabaseField (columnName = "refResourceId") + private String refResourceId; + @DatabaseField (columnName = "roleid")/*角色ID*/ + private String roleid; + @DatabaseField (columnName = "refResourceType") + private String refResourceType; + @DatabaseField (columnName = "rolecode")/*角色编号*/ + private String rolecode; + @DatabaseField (columnName = "code") + private String code; + + @DatabaseField (columnName = "deptisDelete")/*是否可用:逻辑删除,默认值为0*/ + private int deptisDelete; + @DatabaseField (columnName = "workNo")/*人员工号*/ + private String workNo; + @DatabaseField (columnName = "userstatus")/*人员状态*/ + private int userstatus; + @DatabaseField (columnName = "isVisibility") + private int isVisibility; + + @DatabaseField (columnName = "Id" ) + private String Id; + @DatabaseField (columnName = "deptparentId")/*部门关系ID*/ + private String deptparentId; + @DatabaseField (columnName = "shortName")/*部门简称*/ + private String shortName; + @DatabaseField (columnName = "refParentResourceCode") + private String refParentResourceCode; + + public String getPermissionid() { + return permissionid; + } + + public void setPermissionid(String permissionid) { + this.permissionid = permissionid; + } + + public String getRefParentResourceId() { + return refParentResourceId; + } + + public void setRefParentResourceId(String refParentResourceId) { + this.refParentResourceId = refParentResourceId; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + + public int getUserisDelete() { + return userisDelete; + } + + public void setUserisDelete(int userisDelete) { + this.userisDelete = userisDelete; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getObjType() { + return objType; + } + + public void setObjType(String objType) { + this.objType = objType; + } + + public String getRolename() { + return rolename; + } + + public void setRolename(String rolename) { + this.rolename = rolename; + } + + public String getDeptid() { + return deptid; + } + + public void setDeptid(String deptid) { + this.deptid = deptid; + } + + public String getOrgid() { + return orgid; + } + + public void setOrgid(String orgid) { + this.orgid = orgid; + } + + public String getDeptcode() { + return deptcode; + } + + public void setDeptcode(String deptcode) { + this.deptcode = deptcode; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRefResourceCode() { + return refResourceCode; + } + + public void setRefResourceCode(String refResourceCode) { + this.refResourceCode = refResourceCode; + } + + public String getDeptname() { + return deptname; + } + + public void setDeptname(String deptname) { + this.deptname = deptname; + } + + public String getUsernike() { + return usernike; + } + + public void setUsernike(String usernike) { + this.usernike = usernike; + } + + public int getDepttype() { + return depttype; + } + + public void setDepttype(int depttype) { + this.depttype = depttype; + } + + public int getIsOper() { + return isOper; + } + + public void setIsOper(int isOper) { + this.isOper = isOper; + } + + public String getRefResourceId() { + return refResourceId; + } + + public void setRefResourceId(String refResourceId) { + this.refResourceId = refResourceId; + } + + public String getRoleid() { + return roleid; + } + + public void setRoleid(String roleid) { + this.roleid = roleid; + } + + public String getRefResourceType() { + return refResourceType; + } + + public void setRefResourceType(String refResourceType) { + this.refResourceType = refResourceType; + } + + public String getRolecode() { + return rolecode; + } + + public void setRolecode(String rolecode) { + this.rolecode = rolecode; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + + + public int getDeptisDelete() { + return deptisDelete; + } + + public void setDeptisDelete(int deptisDelete) { + this.deptisDelete = deptisDelete; + } + + public String getWorkNo() { + return workNo; + } + + public void setWorkNo(String workNo) { + this.workNo = workNo; + } + + public int getUserstatus() { + return userstatus; + } + + public void setUserstatus(int userstatus) { + this.userstatus = userstatus; + } + + public int getIsVisibility() { + return isVisibility; + } + + public void setIsVisibility(int isVisibility) { + this.isVisibility = isVisibility; + } + + public String getId() { + return Id; + } + + public void setId(String Id) { + this.Id = Id; + } + + public String getDeptparentId() { + return deptparentId; + } + + public void setDeptparentId(String deptparentId) { + this.deptparentId = deptparentId; + } + + public String getShortName() { + return shortName; + } + + public void setShortName(String shortName) { + this.shortName = shortName; + } + + public String getRefParentResourceCode() { + return refParentResourceCode; + } + + public void setRefParentResourceCode(String refParentResourceCode) { + this.refParentResourceCode = refParentResourceCode; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/dao/BigshotDao.java b/app/src/main/java/com/fisherbone/fuzhu/db/dao/BigshotDao.java new file mode 100644 index 0000000..394dac8 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/dao/BigshotDao.java @@ -0,0 +1,119 @@ +package com.fisherbone.fuzhu.db.dao; + +import android.content.Context; +import android.database.SQLException; + +import com.fisherbone.fuzhu.db.BigshotData; +import com.j256.ormlite.dao.Dao; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class BigshotDao { + private static Dao userAccountDao; + + public BigshotDao(Context mContext) { + DataBaseHelper dataBaseHelper = DataBaseHelper.getInstance(mContext); + try { + try { + userAccountDao = dataBaseHelper.getDao(BigshotData.class); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + + public long addInsert(BigshotData userData) { + int id = 0; + try { + try { + id = userAccountDao.create(userData); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return id; + } + + + public List queryByCustom(String columnName, String columnValue) { + List ormTables = new ArrayList<>(); + try { + ormTables = userAccountDao.queryBuilder().where().eq(columnName, columnValue).query(); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + + return ormTables; + } + + public List queryByCustomtwo(String columnName, String columnValue) { + List ormTables = new ArrayList<>(); + try { + // ormTables = userAccountDao.queryBuilder().where().eq(columnName, columnValue).query(); + ormTables= userAccountDao.queryBuilder().where().like("phone", "%"+columnValue+"%").or().like("name","%"+columnValue+"%").query(); + + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + + return ormTables; + } + + public boolean updateData(BigshotData userData) { + + try { + int result = userAccountDao.update(userData); + if (result != -1) { + return true; + + } + } catch (java.sql.SQLException e) { + e.printStackTrace(); + return false; + } + return false; + } + + public static List queryInByCustom(String columnName, String columnValues){ + List ormTables = new ArrayList<>(); + try { + List strings = Arrays.asList(columnValues.split(",")); + + ormTables = userAccountDao.queryBuilder().where().in(columnName,strings ).query(); + }catch (java.sql.SQLException e){ + e.printStackTrace(); + } + return ormTables; + } + + public ArrayList queryAll() { + ArrayList userAccountList = new ArrayList<>(); + try { + userAccountList = (ArrayList) userAccountDao.queryForAll(); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + return userAccountList; + } + + public long delete(List DATA){ + int id = 0; + try { + try { + id = userAccountDao.delete(DATA); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return id; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/dao/CommentDao.java b/app/src/main/java/com/fisherbone/fuzhu/db/dao/CommentDao.java new file mode 100644 index 0000000..75f3934 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/dao/CommentDao.java @@ -0,0 +1,119 @@ +package com.fisherbone.fuzhu.db.dao; + +import android.content.Context; +import android.database.SQLException; + +import com.fisherbone.fuzhu.db.CommentBeanData; +import com.j256.ormlite.dao.Dao; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class CommentDao { + private static Dao userAccountDao; + + public CommentDao(Context mContext) { + DataBaseHelper dataBaseHelper = DataBaseHelper.getInstance(mContext); + try { + try { + userAccountDao = dataBaseHelper.getDao(CommentBeanData.class); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + + public long addInsert(CommentBeanData userData) { + int id = 0; + try { + try { + id = userAccountDao.create(userData); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return id; + } + + + public List queryByCustom(String columnName, String columnValue) { + List ormTables = new ArrayList<>(); + try { + ormTables = userAccountDao.queryBuilder().where().eq(columnName, columnValue).query(); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + + return ormTables; + } + + public List queryByCustomtwo(String columnName, String columnValue) { + List ormTables = new ArrayList<>(); + try { + // ormTables = userAccountDao.queryBuilder().where().eq(columnName, columnValue).query(); + ormTables= userAccountDao.queryBuilder().where().like("phone", "%"+columnValue+"%").or().like("name","%"+columnValue+"%").query(); + + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + + return ormTables; + } + + public boolean updateData(CommentBeanData userData) { + + try { + int result = userAccountDao.update(userData); + if (result != -1) { + return true; + + } + } catch (java.sql.SQLException e) { + e.printStackTrace(); + return false; + } + return false; + } + + public static List queryInByCustom(String columnName, String columnValues){ + List ormTables = new ArrayList<>(); + try { + List strings = Arrays.asList(columnValues.split(",")); + + ormTables = userAccountDao.queryBuilder().where().in(columnName,strings ).query(); + }catch (java.sql.SQLException e){ + e.printStackTrace(); + } + return ormTables; + } + + public ArrayList queryAll() { + ArrayList userAccountList = new ArrayList<>(); + try { + userAccountList = (ArrayList) userAccountDao.queryForAll(); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + return userAccountList; + } + + public long delete(List DATA){ + int id = 0; + try { + try { + id = userAccountDao.delete(DATA); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return id; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/dao/ContentDao.java b/app/src/main/java/com/fisherbone/fuzhu/db/dao/ContentDao.java new file mode 100644 index 0000000..3c6c6e2 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/dao/ContentDao.java @@ -0,0 +1,119 @@ +package com.fisherbone.fuzhu.db.dao; + +import android.content.Context; +import android.database.SQLException; + +import com.fisherbone.fuzhu.db.ContentBeanData; +import com.j256.ormlite.dao.Dao; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class ContentDao { + private static Dao userAccountDao; + + public ContentDao(Context mContext) { + DataBaseHelper dataBaseHelper = DataBaseHelper.getInstance(mContext); + try { + try { + userAccountDao = dataBaseHelper.getDao(ContentBeanData.class); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + + public long addInsert(ContentBeanData userData) { + int id = 0; + try { + try { + id = userAccountDao.create(userData); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return id; + } + + + public List queryByCustom(String columnName, String columnValue) { + List ormTables = new ArrayList<>(); + try { + ormTables = userAccountDao.queryBuilder().where().eq(columnName, columnValue).query(); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + + return ormTables; + } + + public List queryByCustomtwo(String columnName, String columnValue) { + List ormTables = new ArrayList<>(); + try { + // ormTables = userAccountDao.queryBuilder().where().eq(columnName, columnValue).query(); + ormTables= userAccountDao.queryBuilder().where().like("phone", "%"+columnValue+"%").or().like("name","%"+columnValue+"%").query(); + + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + + return ormTables; + } + + public boolean updateData(ContentBeanData userData) { + + try { + int result = userAccountDao.update(userData); + if (result != -1) { + return true; + + } + } catch (java.sql.SQLException e) { + e.printStackTrace(); + return false; + } + return false; + } + + public static List queryInByCustom(String columnName, String columnValues){ + List ormTables = new ArrayList<>(); + try { + List strings = Arrays.asList(columnValues.split(",")); + + ormTables = userAccountDao.queryBuilder().where().in(columnName,strings ).query(); + }catch (java.sql.SQLException e){ + e.printStackTrace(); + } + return ormTables; + } + + public ArrayList queryAll() { + ArrayList userAccountList = new ArrayList<>(); + try { + userAccountList = (ArrayList) userAccountDao.queryForAll(); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + return userAccountList; + } + + public long delete(List DATA){ + int id = 0; + try { + try { + id = userAccountDao.delete(DATA); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return id; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/dao/DataBaseHelper.java b/app/src/main/java/com/fisherbone/fuzhu/db/dao/DataBaseHelper.java new file mode 100644 index 0000000..6a0fb62 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/dao/DataBaseHelper.java @@ -0,0 +1,135 @@ +package com.fisherbone.fuzhu.db.dao; + +import android.content.Context; +import android.database.SQLException; +import android.database.sqlite.SQLiteDatabase; + +import com.fisherbone.fuzhu.db.CommentBeanData; +import com.fisherbone.fuzhu.db.DouyinBean; +import com.fisherbone.fuzhu.db.RedenvBeanData; +import com.fisherbone.fuzhu.db.zhuanghaoBeanData; +import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper; +import com.j256.ormlite.dao.Dao; +import com.j256.ormlite.support.ConnectionSource; +import com.j256.ormlite.table.TableUtils; + +public class DataBaseHelper extends OrmLiteSqliteOpenHelper { + + /** + * 数据库名称 + */ + private static final String TABLE_NAME = "sqlite-test.db"; + /** + * 版本号 + */ + private static final int DBVERSION = 5; + + private static Context mContext; + /** + * 单例 + */ + private static DataBaseHelper mInstance; + private static DataBaseHelper dataBaseHelper; + + + private DataBaseHelper(Context context) { + super(context, TABLE_NAME, null, DBVERSION); + } + + public synchronized static DataBaseHelper getInstance(Context mContext) { + if (dataBaseHelper == null) { + dataBaseHelper = new DataBaseHelper(mContext); + } + return dataBaseHelper; + } + + /** + * 初始化 + * + * @param context + */ + public static void initOrmLite(Context context) { + mContext = context; + getIntence(); + } + + /** + * 创建数据库表 + * + * @param database + * @param connectionSource + */ + @Override + public void onCreate(SQLiteDatabase database, + ConnectionSource connectionSource) { + try { + + TableUtils.createTable(connectionSource, CommentBeanData.class); + TableUtils.createTable(connectionSource, zhuanghaoBeanData.class); + // TableUtils.createTable(connectionSource, UserData.class); +// TableUtils.createTable(connectionSource, BigshotData.class); +// TableUtils.createTable(connectionSource, KeyWordBean.class); +// TableUtils.createTable(connectionSource, ContentBeanData.class); + TableUtils.createTable(connectionSource, RedenvBeanData.class); + TableUtils.createTable(connectionSource, DouyinBean.class); + + } catch (SQLException e) { + e.printStackTrace(); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } + + /** + * 升级数据库 + * + * @param database + * @param connectionSource + * @param oldVersion + * @param newVersion + */ + @Override + public void onUpgrade(SQLiteDatabase database, + ConnectionSource connectionSource, int oldVersion, int newVersion) { + try { + + + onCreate(database, connectionSource); + } catch (SQLException e) { + e.printStackTrace(); + + } + } + + + /** + * 单例获取该Helper + * + * @param + * @return + */ + public static synchronized DataBaseHelper getIntence() { + + if (null == mInstance) { + synchronized (DataBaseHelper.class) { + if (null == mInstance) { + mInstance = new DataBaseHelper(mContext); + } + } + } + return mInstance; + } + + /** + * 获取数据对象 + * + * @param classz 对应的表实体的字节码对象 + * @return Dao :T:表实体对象类型.ID:对应的表实体中被指定为id字段的属性类型 + * @throws SQLException + */ + @Override + public Dao getDao(Class classz) throws SQLException, java.sql.SQLException { + return super.getDao(classz); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/dao/DouyinDao.java b/app/src/main/java/com/fisherbone/fuzhu/db/dao/DouyinDao.java new file mode 100644 index 0000000..349917d --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/dao/DouyinDao.java @@ -0,0 +1,135 @@ +package com.fisherbone.fuzhu.db.dao; + +import android.content.Context; +import android.database.SQLException; + +import com.fisherbone.fuzhu.db.DouyinBean; +import com.j256.ormlite.dao.Dao; +import com.j256.ormlite.stmt.DeleteBuilder; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class DouyinDao { + private static Dao userAccountDao; + + public DouyinDao(Context mContext) { + DataBaseHelper dataBaseHelper = DataBaseHelper.getInstance(mContext); + try { + try { + userAccountDao = dataBaseHelper.getDao(DouyinBean.class); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + + public long addInsert(DouyinBean userData) { + int id = 0; + try { + try { + id = userAccountDao.create(userData); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return id; + } + + + public List queryByCustom(String columnName, String columnValue) { + List ormTables = new ArrayList<>(); + try { + ormTables = userAccountDao.queryBuilder().where().eq(columnName, columnValue).query(); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + + return ormTables; + } + + public List queryByCustomtwo(String columnName, String columnValue) { + List ormTables = new ArrayList<>(); + try { + // ormTables = userAccountDao.queryBuilder().where().eq(columnName, columnValue).query(); + ormTables= userAccountDao.queryBuilder().where().like("phone", "%"+columnValue+"%").or().like("name","%"+columnValue+"%").query(); + + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + + return ormTables; + } + + public boolean updateData(DouyinBean userData) { + + try { + int result = userAccountDao.update(userData); + if (result != -1) { + return true; + + } + } catch (java.sql.SQLException e) { + e.printStackTrace(); + return false; + } + return false; + } + + public static List queryInByCustom(String columnName, String columnValues){ + List ormTables = new ArrayList<>(); + try { + List strings = Arrays.asList(columnValues.split(",")); + + ormTables = userAccountDao.queryBuilder().where().in(columnName,strings ).query(); + }catch (java.sql.SQLException e){ + e.printStackTrace(); + } + return ormTables; + } + + public ArrayList queryAll() { + ArrayList userAccountList = new ArrayList<>(); + try { + userAccountList = (ArrayList) userAccountDao.queryForAll(); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + return userAccountList; + } + +// public long delete(List DATA){ +// int id = 0; +// try { +// try { +// id = userAccountDao.delete(DATA); +// } catch (java.sql.SQLException e) { +// e.printStackTrace(); +// } +// } catch (SQLException e) { +// e.printStackTrace(); +// } +// return id; +// } + + public long delete(List cardImg) { + int id = 0; + try { + try { + DeleteBuilder deleteBuilder = userAccountDao.deleteBuilder(); + deleteBuilder.delete(); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return id; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/dao/KeyWordDao.java b/app/src/main/java/com/fisherbone/fuzhu/db/dao/KeyWordDao.java new file mode 100644 index 0000000..680588a --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/dao/KeyWordDao.java @@ -0,0 +1,119 @@ +package com.fisherbone.fuzhu.db.dao; + +import android.content.Context; +import android.database.SQLException; + +import com.fisherbone.fuzhu.db.KeyWordBean; +import com.j256.ormlite.dao.Dao; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class KeyWordDao { + private static Dao userAccountDao; + + public KeyWordDao(Context mContext) { + DataBaseHelper dataBaseHelper = DataBaseHelper.getInstance(mContext); + try { + try { + userAccountDao = dataBaseHelper.getDao(KeyWordBean.class); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + + public long addInsert(KeyWordBean userData) { + int id = 0; + try { + try { + id = userAccountDao.create(userData); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return id; + } + + + public List queryByCustom(String columnName, String columnValue) { + List ormTables = new ArrayList<>(); + try { + ormTables = userAccountDao.queryBuilder().where().eq(columnName, columnValue).query(); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + + return ormTables; + } + + public List queryByCustomtwo(String columnName, String columnValue) { + List ormTables = new ArrayList<>(); + try { + // ormTables = userAccountDao.queryBuilder().where().eq(columnName, columnValue).query(); + ormTables= userAccountDao.queryBuilder().where().like("phone", "%"+columnValue+"%").or().like("name","%"+columnValue+"%").query(); + + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + + return ormTables; + } + + public boolean updateData(KeyWordBean userData) { + + try { + int result = userAccountDao.update(userData); + if (result != -1) { + return true; + + } + } catch (java.sql.SQLException e) { + e.printStackTrace(); + return false; + } + return false; + } + + public static List queryInByCustom(String columnName, String columnValues){ + List ormTables = new ArrayList<>(); + try { + List strings = Arrays.asList(columnValues.split(",")); + + ormTables = userAccountDao.queryBuilder().where().in(columnName,strings ).query(); + }catch (java.sql.SQLException e){ + e.printStackTrace(); + } + return ormTables; + } + + public ArrayList queryAll() { + ArrayList userAccountList = new ArrayList<>(); + try { + userAccountList = (ArrayList) userAccountDao.queryForAll(); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + return userAccountList; + } + + public long delete(List DATA){ + int id = 0; + try { + try { + id = userAccountDao.delete(DATA); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return id; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/dao/RedenvDao.java b/app/src/main/java/com/fisherbone/fuzhu/db/dao/RedenvDao.java new file mode 100644 index 0000000..788b476 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/dao/RedenvDao.java @@ -0,0 +1,139 @@ +package com.fisherbone.fuzhu.db.dao; + +import android.content.Context; +import android.database.SQLException; + +import com.fisherbone.fuzhu.db.RedenvBeanData; +import com.j256.ormlite.dao.Dao; +import com.j256.ormlite.stmt.DeleteBuilder; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class RedenvDao { + private static Dao userAccountDao; + + public RedenvDao(Context mContext) { + DataBaseHelper dataBaseHelper = DataBaseHelper.getInstance(mContext); + try { + try { + userAccountDao = dataBaseHelper.getDao(RedenvBeanData.class); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + + public long addInsert(RedenvBeanData userData) { + int id = 0; + try { + try { + id = userAccountDao.create(userData); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return id; + } + + + public List queryByCustom(String columnName, String columnValue) { + List ormTables = new ArrayList<>(); + try { + ormTables = userAccountDao.queryBuilder().where().eq(columnName, columnValue).query(); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + + return ormTables; + } + + public List queryByCustomtwo(String columnName, String columnValue) { + List ormTables = new ArrayList<>(); + try { + // ormTables = userAccountDao.queryBuilder().where().eq(columnName, columnValue).query(); + ormTables= userAccountDao.queryBuilder().where().like("phone", "%"+columnValue+"%").or().like("name","%"+columnValue+"%").query(); + + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + + return ormTables; + } + + public boolean updateData(RedenvBeanData userData) { + + try { + int result = userAccountDao.update(userData); + if (result != -1) { + return true; + + } + } catch (java.sql.SQLException e) { + e.printStackTrace(); + return false; + } + return false; + } + + public static List queryInByCustom(String columnName, String columnValues){ + List ormTables = new ArrayList<>(); + try { + List strings = Arrays.asList(columnValues.split(",")); + + ormTables = userAccountDao.queryBuilder().where().in(columnName,strings ).query(); + }catch (java.sql.SQLException e){ + e.printStackTrace(); + } + return ormTables; + } + + public ArrayList queryAll() { + ArrayList userAccountList = new ArrayList<>(); + try { + userAccountList = (ArrayList) userAccountDao.queryForAll(); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + return userAccountList; + } + + public long delete(List DATA){ + int id = 0; + try { + try { + id = userAccountDao.delete(DATA); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return id; + } + + + public long deletetwo(List cardImg) { + int id = 0; + try { + try { + DeleteBuilder deleteBuilder = userAccountDao.deleteBuilder(); + deleteBuilder.delete(); + + // id = userAccountDao.delete(cardImg); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return id; + } + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/dao/ZhanghaoDao.java b/app/src/main/java/com/fisherbone/fuzhu/db/dao/ZhanghaoDao.java new file mode 100644 index 0000000..edad839 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/dao/ZhanghaoDao.java @@ -0,0 +1,119 @@ +package com.fisherbone.fuzhu.db.dao; + +import android.content.Context; +import android.database.SQLException; + +import com.fisherbone.fuzhu.db.zhuanghaoBeanData; +import com.j256.ormlite.dao.Dao; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class ZhanghaoDao { + private static Dao userAccountDao; + + public ZhanghaoDao(Context mContext) { + DataBaseHelper dataBaseHelper = DataBaseHelper.getInstance(mContext); + try { + try { + userAccountDao = dataBaseHelper.getDao(zhuanghaoBeanData.class); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + + public long addInsert(zhuanghaoBeanData userData) { + int id = 0; + try { + try { + id = userAccountDao.create(userData); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return id; + } + + + public List queryByCustom(String columnName, String columnValue) { + List ormTables = new ArrayList<>(); + try { + ormTables = userAccountDao.queryBuilder().where().eq(columnName, columnValue).query(); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + + return ormTables; + } + + public List queryByCustomtwo(String columnName, String columnValue) { + List ormTables = new ArrayList<>(); + try { + // ormTables = userAccountDao.queryBuilder().where().eq(columnName, columnValue).query(); + ormTables= userAccountDao.queryBuilder().where().like("phone", "%"+columnValue+"%").or().like("name","%"+columnValue+"%").query(); + + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + + return ormTables; + } + + public boolean updateData(zhuanghaoBeanData userData) { + + try { + int result = userAccountDao.update(userData); + if (result != -1) { + return true; + + } + } catch (java.sql.SQLException e) { + e.printStackTrace(); + return false; + } + return false; + } + + public static List queryInByCustom(String columnName, String columnValues){ + List ormTables = new ArrayList<>(); + try { + List strings = Arrays.asList(columnValues.split(",")); + + ormTables = userAccountDao.queryBuilder().where().in(columnName,strings ).query(); + }catch (java.sql.SQLException e){ + e.printStackTrace(); + } + return ormTables; + } + + public ArrayList queryAll() { + ArrayList userAccountList = new ArrayList<>(); + try { + userAccountList = (ArrayList) userAccountDao.queryForAll(); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + return userAccountList; + } + + public long delete(List DATA){ + int id = 0; + try { + try { + id = userAccountDao.delete(DATA); + } catch (java.sql.SQLException e) { + e.printStackTrace(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + return id; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/dao/daoutil.java b/app/src/main/java/com/fisherbone/fuzhu/db/dao/daoutil.java new file mode 100644 index 0000000..412ea2e --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/dao/daoutil.java @@ -0,0 +1,26 @@ +package com.fisherbone.fuzhu.db.dao; + +import android.content.Context; + +public class daoutil { + + //2.本类内部创建对象实例 + private static ZhanghaoDao instance = null; + + /** + * 1.构造方法私有化,外部不能new + */ + private daoutil() { + + } + +//3.提供一个公有的静态方法,返回实例对象 + + public static ZhanghaoDao getInstance(Context context) { + if (instance == null) { + instance = new ZhanghaoDao(context); + } + return instance; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/db/zhuanghaoBeanData.java b/app/src/main/java/com/fisherbone/fuzhu/db/zhuanghaoBeanData.java new file mode 100644 index 0000000..5901ea0 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/db/zhuanghaoBeanData.java @@ -0,0 +1,67 @@ +package com.fisherbone.fuzhu.db; + +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +import java.io.Serializable; + +@DatabaseTable(tableName = "tab_zhuanghao") +public class zhuanghaoBeanData extends DbBean implements Serializable { + @DatabaseField(id = true,columnName = "Id") + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getRecord_id() { + return record_id; + } + + public void setRecord_id(String record_id) { + this.record_id = record_id; + } + + @DatabaseField(columnName = "phone") + private String phone; + + + @DatabaseField(columnName = "record_id") + private String record_id; + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @DatabaseField(columnName = "name") + private String name; + + public String getIsjiaguan() { + return isjiaguan; + } + + public void setIsjiaguan(String isjiaguan) { + this.isjiaguan = isjiaguan; + } + + @DatabaseField(columnName = "isjiaguan") + private String isjiaguan; +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/dialog/BaseDialog.java b/app/src/main/java/com/fisherbone/fuzhu/dialog/BaseDialog.java new file mode 100644 index 0000000..14cdc9d --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/dialog/BaseDialog.java @@ -0,0 +1,65 @@ +package com.fisherbone.fuzhu.dialog; + +import android.app.Activity; +import android.app.Dialog; +import android.content.Context; +import android.view.Display; +import android.view.View; +import android.view.WindowManager; + +/** + * 日期:2017.01.11 + *

+ * 作者:xudiwei + *

+ * 描述:base对话框 + */ +public class BaseDialog extends Dialog implements View.OnClickListener { + + protected Context mContext; + private View view; + private boolean isDismiss = true; + + public BaseDialog(Context context) { + super(context); + } + + public BaseDialog(Context context, int themeResId) { + super(context, themeResId); + } + + public BaseDialog(Context context, View view, int themeResId) { + super(context, themeResId); + this.mContext = context; + this.view = view; + this.view.setOnClickListener(this); + setContentView(view); + } + + @Override + public void show() { + super.show(); + + WindowManager windowManager = ((Activity) mContext).getWindowManager(); + Display display = windowManager.getDefaultDisplay(); + WindowManager.LayoutParams lp = getWindow().getAttributes(); + lp.width = display.getWidth(); //设置宽度 + getWindow().setAttributes(lp); + } + + @Override + public void onClick(View v) { + if (isDismiss) { + dismiss(); + } + } + + /** + * 当点击对话框外面时是否关闭对话框,默认是要关闭对话框 + * + * @param b + */ + public void clickOutsideDismiss(boolean b) { + this.isDismiss = b; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/dialog/BaseTipsDialog.java b/app/src/main/java/com/fisherbone/fuzhu/dialog/BaseTipsDialog.java new file mode 100644 index 0000000..a9e9169 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/dialog/BaseTipsDialog.java @@ -0,0 +1,87 @@ +package com.fisherbone.fuzhu.dialog; + +import android.app.Dialog; +import android.content.Context; +import android.text.Html; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; +import android.widget.TextView; + +import com.fisherbone.fuzhu.R; + + +/** + * Time: 2020/7/14 + * Author: jianbo + * Description: + */ +public class BaseTipsDialog { + Context mcontext; + ClickListener clickListener; + + public void showDownloadDialog(Context mcontext,final String s1, final String s2, final ClickListener clickListener) { + this.clickListener=clickListener; + this.mcontext=mcontext; + final Dialog dialog = new Dialog(mcontext, R.style.DialogStyle); + dialog.setCancelable(false); + dialog.setCanceledOnTouchOutside(false); + View view = LayoutInflater.from(mcontext).inflate(R.layout.item_base_dialog, null); + dialog.setContentView(view); + TextView tv_title = (TextView) view.findViewById(R.id.tv_title); + TextView tvSexCancel = (TextView) view.findViewById(R.id.tvSexCancel); + TextView tvPhone = (TextView) view.findViewById(R.id.tvPhone); + TextView tvSexSend = (TextView) view.findViewById(R.id.tvSexSend); + tv_title.setText("温馨提示"); + tvPhone.setText(Html.fromHtml(s1)); + tvSexSend.setText(s2); + tvPhone.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }); + tvSexSend.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { +// if (pagetype.equals("3")) { +// updClerkStore(updClerkStoreBean.getTrans_storeid(), updClerkStoreBean.getTrans_usertype(), updClerkStoreBean.getHand_uid()); +// } else { +// updLeaveTime(updClerkStoreBean.getHand_uid()); +// } + clickListener.confirm(); + dialog.dismiss(); + + + } + }); + tvSexCancel.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + + clickListener.cancle(); + dialog.dismiss(); + + } + }); + Window mWindow = dialog.getWindow(); + WindowManager.LayoutParams lp = mWindow.getAttributes(); + lp.width = MyDialog.getScreenWidth(mcontext); + mWindow.setGravity(Gravity.CENTER); + // mWindow.setWindowAnimations(R.style.dialogAnim); + mWindow.setAttributes(lp); + dialog.show(); + } + + public interface ClickListener{ + + void confirm(); + void cancle(); + + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/dialog/LoadingDialog.java b/app/src/main/java/com/fisherbone/fuzhu/dialog/LoadingDialog.java new file mode 100644 index 0000000..0c76c79 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/dialog/LoadingDialog.java @@ -0,0 +1,47 @@ +package com.fisherbone.fuzhu.dialog; + +import android.app.Activity; +import android.content.Context; +import android.view.View; + +import com.fisherbone.fuzhu.R; + + +/** + * Created by: xudiwei + *

+ * on: 2017/5/16. + *

+ * 描述:加载中禁止用户手机关闭的对话框 + */ + +public class LoadingDialog extends BaseDialog { + private boolean mClose = true; + + public LoadingDialog(Context context) { + super(context, View.inflate(context, R.layout.dialog_loading, null), R.style.avatar_dialog_style); + setCanceledOnTouchOutside(false); + } + + + @Override + public void onClick(View v) { +// super.onClick(v); + } + + @Override + public void onBackPressed() { + super.onBackPressed(); + if (mClose) { + ((Activity) mContext).finish(); + } + } + + /** + * 当用户按下返回键时是否关闭Activity + * @param close + */ + public void setPressBackCloseActivity(boolean close) { + this.mClose = close; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/dialog/MyDialog.java b/app/src/main/java/com/fisherbone/fuzhu/dialog/MyDialog.java new file mode 100644 index 0000000..d2d4335 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/dialog/MyDialog.java @@ -0,0 +1,16 @@ +package com.fisherbone.fuzhu.dialog; + +import android.app.Activity; +import android.content.Context; +import android.util.DisplayMetrics; + + +public class MyDialog { + + + public static int getScreenWidth(Context context){ + DisplayMetrics dm = new DisplayMetrics(); + ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(dm); + return dm.widthPixels; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/AddDakaBeanData.java b/app/src/main/java/com/fisherbone/fuzhu/entity/AddDakaBeanData.java new file mode 100644 index 0000000..bf2ee8a --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/AddDakaBeanData.java @@ -0,0 +1,43 @@ +package com.fisherbone.fuzhu.entity; + +import com.j256.ormlite.field.DatabaseField; + +import java.io.Serializable; + +public class AddDakaBeanData implements Serializable { + + @DatabaseField(id = true,columnName = "Id") + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + @DatabaseField(columnName = "comment") + private String comment; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @DatabaseField(columnName = "type") + private String type;//1.评论话术 2.私信话术 3.直播话术 4.回访话术 5.首关话术 + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/AppoBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/AppoBean.java new file mode 100644 index 0000000..328da96 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/AppoBean.java @@ -0,0 +1,63 @@ +package com.fisherbone.fuzhu.entity; + +import java.util.List; + +/** + * Time: 2021/6/21 + * Author: jianbo + * Description: + */ +public class AppoBean extends BaseModel { + public AppoBean(List data) { + this.data = data; + } + + private List data; + private String msg; + private Integer success; + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public Integer getSuccess() { + return success; + } + + public void setSuccess(Integer success) { + this.success = success; + } + + public static class DataBean { + private String room_name; + private String room_shortid; + + public String getRoom_name() { + return room_name; + } + + public void setRoom_name(String room_name) { + this.room_name = room_name; + } + + public String getRoom_shortid() { + return room_shortid; + } + + public void setRoom_shortid(String room_shortid) { + this.room_shortid = room_shortid; + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/AppointBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/AppointBean.java new file mode 100644 index 0000000..f8c5e7d --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/AppointBean.java @@ -0,0 +1,36 @@ +package com.fisherbone.fuzhu.entity; + +import androidx.databinding.BaseObservable; +import androidx.databinding.Bindable; + +import com.fisherbone.fuzhu.BR; + +/** + * Time: 2020/10/30 + * Author: jianbo + * Description: + */ +public class AppointBean extends BaseObservable { + + boolean seclect = false; //请求后台目标直播间 + + public AppointBean() { + + } + public AppointBean(boolean seclectn) { + + this.seclect = seclectn; + + } + + @Bindable + public boolean isSeclect() { + return seclect; + } + + public void setSeclect(boolean seclect) { + this.seclect = seclect; + notifyPropertyChanged(BR.seclect); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/BaseModel.java b/app/src/main/java/com/fisherbone/fuzhu/entity/BaseModel.java new file mode 100644 index 0000000..a096d6d --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/BaseModel.java @@ -0,0 +1,13 @@ +package com.fisherbone.fuzhu.entity; + +import java.io.Serializable; + +/** + * @description 实体基类 + * @author fangyan + * @date 2015年8月1日 + */ +public class BaseModel implements Serializable { + + private static final long serialVersionUID = 1L; +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/CancleFollowBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/CancleFollowBean.java new file mode 100644 index 0000000..6667ce8 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/CancleFollowBean.java @@ -0,0 +1,113 @@ +package com.fisherbone.fuzhu.entity; + +import androidx.databinding.BaseObservable; +import androidx.databinding.Bindable; + +import com.fisherbone.fuzhu.BR; + +/** + * Time: 2020/10/30 + * Author: jianbo + * Description:一键取关bean + */ +public class CancleFollowBean extends BaseObservable { + boolean cancelclosed; //取消已关 + boolean cancelcrosscor; //取消互关 + + public boolean isCancelall() { + return cancelall; + } + + public void setCancelall(boolean cancelall) { + this.cancelall = cancelall; + } + + boolean cancelall; //取消已关和取消互关 + + @Override + public String toString() { + return "CancleFollowBean{" + + "cancelclosed='" + cancelclosed + '\'' + + ", cancelcrosscor='" + cancelcrosscor + '\'' + + ", passnumber='" + passnumber + '\'' + + ", swiinterval='" + swiinterval + '\'' + + ", minthrthr='" + minthrthr + '\'' + + ", minfans='" + minfans + '\'' + + '}'; + } + + String passnumber; //取关数 + + public boolean getCancelclosed() { + return cancelclosed; + } + + public void setCancelclosed(boolean cancelclosed) { + this.cancelclosed = cancelclosed; + } + + public boolean getCancelcrosscor() { + return cancelcrosscor; + } + + public void setCancelcrosscor(boolean cancelcrosscor) { + this.cancelcrosscor = cancelcrosscor; + } + + @Bindable + public String getPassnumber() { + return passnumber; + } + + public void setPassnumber(String passnumber) { + this.passnumber = passnumber; + notifyPropertyChanged(BR.runningtime); + } + @Bindable + public String getSwiinterval() { + return swiinterval; + } + + public void setSwiinterval(String swiinterval) { + this.swiinterval = swiinterval; + notifyPropertyChanged(BR.runningtime); + } + @Bindable + public String getMinthrthr() { + return minthrthr; + } + + public void setMinthrthr(String minthrthr) { + this.minthrthr = minthrthr; + notifyPropertyChanged(BR.runningtime); + } + + String swiinterval; //取关间隔 + + public CancleFollowBean(boolean cancelclosed, boolean cancelcrosscor, String passnumber, String swiinterval, String minthrthr,String minfans) { + this.cancelclosed = cancelclosed; + this.cancelcrosscor = cancelcrosscor; + this.passnumber = passnumber; + this.swiinterval = swiinterval; + this.minthrthr = minthrthr; + this.minfans = minfans; + } + + String minthrthr; //最小开始取关数 + + + @Bindable + public String getMinfans() { + return minfans; + } + + public void setMinfans(String minfans) { + this.minfans = minfans; + notifyPropertyChanged(BR.minfans); + } + + String minfans; //互关保留粉丝数 + + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/CodeBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/CodeBean.java new file mode 100644 index 0000000..1900f92 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/CodeBean.java @@ -0,0 +1,39 @@ +package com.fisherbone.fuzhu.entity; + +import androidx.databinding.BaseObservable; +import androidx.databinding.Bindable; + +import com.fisherbone.fuzhu.BR; + +/** + * Time: 2020/10/30 + * Author: jianbo + * Description: + */ +public class CodeBean extends BaseObservable { + + @Bindable + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + notifyPropertyChanged(BR.runningtime); + } + + String code=""; //运行时长 + + @Override + public String toString() { + return "RecFollowBean{" + + "runningtime='" + code + '\'' + + '}'; + } + + public CodeBean(String code) { + this.code = code; + + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/ControlBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/ControlBean.java new file mode 100644 index 0000000..d244a82 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/ControlBean.java @@ -0,0 +1,45 @@ +package com.fisherbone.fuzhu.entity; + +import androidx.databinding.BaseObservable; +import androidx.databinding.Bindable; + +import com.fisherbone.fuzhu.BR; + +/** + * Time: 2020/10/30 + * Author: jianbo + * Description: + */ +public class ControlBean extends BaseObservable { + @Bindable + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + notifyPropertyChanged(BR.content); + } + + String content = ""; + + public ControlBean() { + + } + public ControlBean(String content) { + + this.content = content; + + } + + public int getPhonetype() { + return phonetype; + } + + public void setPhonetype(int phonetype) { + this.phonetype = phonetype; + } + + public int phonetype = 0; + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/DakaVideoBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/DakaVideoBean.java new file mode 100644 index 0000000..ee09d5b --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/DakaVideoBean.java @@ -0,0 +1,71 @@ +package com.fisherbone.fuzhu.entity; + +import java.io.Serializable; +import java.util.List; + +/** + * Time: 2021/4/29 + * Author: jianbo + * Description: + */ +public class DakaVideoBean implements Serializable { + + private List data; + private String msg; + private int success; + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public int getSuccess() { + return success; + } + + public void setSuccess(int success) { + this.success = success; + } + + public static class DataBean { + private String id; + private String name; + public String getIf_sel_del() { + return if_sel_del; + } + + public void setIf_sel_del(String if_sel_del) { + this.if_sel_del = if_sel_del; + } + + private String if_sel_del="0";//是否选中 //0未选中 1为选中 + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/DavBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/DavBean.java new file mode 100644 index 0000000..6ad072b --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/DavBean.java @@ -0,0 +1,166 @@ +package com.fisherbone.fuzhu.entity; + +import androidx.databinding.BaseObservable; +import androidx.databinding.Bindable; + +import com.fisherbone.fuzhu.BR; + +/** + * Time: 2020/10/30 + * Author: jianbo + * Description: + */ +public class DavBean extends BaseObservable { + String runningtime=""; //运行时长 + + @Override + public String toString() { + return "DavBean{" + + "runningtime='" + runningtime + '\'' + + ", videotime='" + videotime + '\'' + + ", maxnumcon='" + maxnumcon + '\'' + + ", minimumlikes='" + minimumlikes + '\'' + + ", minimumcon='" + minimumcon + '\'' + + ", minimumzuopin='" + minimumzuopin + '\'' + + '}'; + } + + String videotime; //视频观看时长 + + + + + + String maxnumcon=""; //最大关注数 + + @Bindable + public String getRunningtime() { + return runningtime; + } + + public void setRunningtime(String runningtime) { + this.runningtime = runningtime; + notifyPropertyChanged(BR.runningtime); + } + @Bindable + public String getVideotime() { + return videotime; + } + + public void setVideotime(String videotime) { + this.videotime = videotime; + notifyPropertyChanged(BR.videotime); + } + + + + @Bindable + public String getMaxnumcon() { + return maxnumcon; + } + + public void setMaxnumcon(String maxnumcon) { + this.maxnumcon = maxnumcon; + notifyPropertyChanged(BR.maxnumcon); + } + + @Bindable + public String getMinimumlikes() { + return minimumlikes; + } + + public void setMinimumlikes(String minimumlikes) { + this.minimumlikes = minimumlikes; + notifyPropertyChanged(BR.minimumlikes); + } + @Bindable + public String getMinimumcon() { + return minimumcon; + } + + public void setMinimumcon(String minimumcon) { + this.minimumcon = minimumcon; + notifyPropertyChanged(BR.minimumcon); + } + @Bindable + public String getMinimumzuopin() { + return minimumzuopin; + } + + public void setMinimumzuopin(String minimumzuopin) { + this.minimumzuopin = minimumzuopin; + notifyPropertyChanged(BR.minimumzuopin); + } + + String minimumlikes=""; //加关关注数 + String minimumcon=""; //加关粉丝数 + + public DavBean(String runningtime, String maxnumcon,String davdouyin,String guanjianci, String minimumlikes, String minimumcon, String minimumzuopin, String maxmumzuopin, String maxmumlikes, String maximumcon) { + this.runningtime = runningtime;//运行时长 + this.maxnumcon = maxnumcon;//最大关注数 + this.davdouyin = davdouyin;//抖音号 + this.guanjianci = guanjianci;//关键词 + this.minimumlikes = minimumlikes;//最小加关关注数 + this.minimumcon = minimumcon;//最小加关粉丝数 + this.minimumzuopin = minimumzuopin;//最小作品数 + this.maxmumzuopin = maxmumzuopin;//最大作品数 + this.maxmumlikes = maxmumlikes;//最大加关关注数 + this.maximumcon = maximumcon;//最大粉丝数 + } + + String minimumzuopin=""; //最小作品数 + String maxmumzuopin=""; //最大作品数 + @Bindable + public String getMaxmumzuopin() { + return maxmumzuopin; + } + + public void setMaxmumzuopin(String maxmumzuopin) { + this.maxmumzuopin = maxmumzuopin; + notifyPropertyChanged(BR.maximumprotime); + } + @Bindable + public String getMaxmumlikes() { + return maxmumlikes; + } + + public void setMaxmumlikes(String maxmumlikes) { + this.maxmumlikes = maxmumlikes; + notifyPropertyChanged(BR.maximumprotime); + } + @Bindable + public String getMaximumcon() { + return maximumcon; + } + + public void setMaximumcon(String maximumcon) { + this.maximumcon = maximumcon; + notifyPropertyChanged(BR.maximumprotime); + } + + String maxmumlikes=""; //最大加关关注数 + String maximumcon=""; //最大粉丝数 + @Bindable + public String getDavdouyin() { + return davdouyin; + } + + public void setDavdouyin(String davdouyin) { + this.davdouyin = davdouyin; + notifyPropertyChanged(BR.davdouyin); + } + + String davdouyin=""; //大V抖音号 + @Bindable + public String getGuanjianci() { + return guanjianci; + } + + public void setGuanjianci(String guanjianci) { + this.guanjianci = guanjianci; + notifyPropertyChanged(BR.maximumprotime); + } + + String guanjianci=""; //关键词 + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/DealInfoBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/DealInfoBean.java new file mode 100644 index 0000000..ceeeaa0 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/DealInfoBean.java @@ -0,0 +1,274 @@ +package com.fisherbone.fuzhu.entity; + +/** + * 项目名:MenDian + * 包名:com.fanghoo.mendian.module.marking + * 创建者:任剑波 + * 创建时间:2018/5/12 13:19 + * 描述:TODO + */ +public class DealInfoBean extends NewInfoBean { + /** + * phone_type : 0 + * wechat_type : 0 + * relation_type : 1 + * record_id : e2d70ccfdb2c906e9d7dd7e6377c452e + * store_name : 红一美式大店 + * record_time : 2019-01-16 15:43:52 + * uid : 149924121c1791c4fbee7fbdf78f0df9 + * user_name : 汤妍妍 + * only_unique : + * tag_type : 0 + * baobei : 0 + */ + + private String phone_type=""; + private String wechat_type=""; + private String relation_type=""; + private String record_id=""; + private String store_name=""; + private String record_time=""; + private String uid=""; + private String user_name=""; + private String only_unique=""; + private String tag_type=""; + private String baobei=""; + + public String getInfo_type() { + return info_type; + } + + public void setInfo_type(String info_type) { + this.info_type = info_type; + } + + private String info_type="";//1是进店,2:开单,3:抢单 + + + private String rob_time="";//抢单时间 + + public String getRob_time() { + return rob_time; + } + + public void setRob_time(String rob_time) { + this.rob_time = rob_time; + } + + public String getCz_type() { + return cz_type; + } + + public void setCz_type(String cz_type) { + this.cz_type = cz_type; + } + + public String getCustomer_id() { + return customer_id; + } + + public void setCustomer_id(String customer_id) { + this.customer_id = customer_id; + } + + private String cz_type="";//1:抢单,5和6是回收 + private String customer_id="";//抢单客户id + + + + public String getType_name() { + return type_name; + } + + public void setType_name(String type_name) { + this.type_name = type_name; + } + + private String type_name=""; + + public String getStoreid() { + return storeid; + } + + public void setStoreid(String storeid) { + this.storeid = storeid; + } + + private String storeid=""; + /** + * satrt_time : 2019-01-14 11:01:25 + * recudesum : 826.00 + * store_id : b8754b65a0bcfb8526ffc6cbf851a135 + * user_name : 陈莉莉 + */ + + private String satrt_time=""; + private String recudesum=""; + private String store_id=""; + + public String getMark_baobei() { + return mark_baobei; + } + + public void setMark_baobei(String mark_baobei) { + this.mark_baobei = mark_baobei; + } + + public String getVisitor_id() { + return visitor_id; + } + + public void setVisitor_id(String visitor_id) { + this.visitor_id = visitor_id; + } + + public String getOrdernum() { + return ordernum; + } + + public void setOrdernum(String ordernum) { + this.ordernum = ordernum; + } + + private String mark_baobei=""; + private String visitor_id=""; + private String ordernum=""; + + public String getDb_set() { + return db_set; + } + + public void setDb_set(String db_set) { + this.db_set = db_set; + } + + private String db_set=""; + + + + + + public String getSelf_record_id() { + return self_record_id; + } + + public void setSelf_record_id(String self_record_id) { + this.self_record_id = self_record_id; + } + + private String self_record_id=""; + + public String getPhone_type() { + return phone_type; + } + + public void setPhone_type(String phone_type) { + this.phone_type = phone_type; + } + + public String getWechat_type() { + return wechat_type; + } + + public void setWechat_type(String wechat_type) { + this.wechat_type = wechat_type; + } + + public String getRelation_type() { + return relation_type; + } + + public void setRelation_type(String relation_type) { + this.relation_type = relation_type; + } + + public String getRecord_id() { + return record_id; + } + + public void setRecord_id(String record_id) { + this.record_id = record_id; + } + + public String getStore_name() { + return store_name; + } + + public void setStore_name(String store_name) { + this.store_name = store_name; + } + + public String getRecord_time() { + return record_time; + } + + public void setRecord_time(String record_time) { + this.record_time = record_time; + } + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public String getUser_name() { + return user_name; + } + + public void setUser_name(String user_name) { + this.user_name = user_name; + } + + public String getOnly_unique() { + return only_unique; + } + + public void setOnly_unique(String only_unique) { + this.only_unique = only_unique; + } + + public String getTag_type() { + return tag_type; + } + + public void setTag_type(String tag_type) { + this.tag_type = tag_type; + } + + public String getBaobei() { + return baobei; + } + + public void setBaobei(String baobei) { + this.baobei = baobei; + } + + + + public String getSatrt_time() { + return satrt_time; + } + + public void setSatrt_time(String satrt_time) { + this.satrt_time = satrt_time; + } + + public String getRecudesum() { + return recudesum; + } + + public void setRecudesum(String recudesum) { + this.recudesum = recudesum; + } + + public String getStore_id() { + return store_id; + } + + public void setStore_id(String store_id) { + this.store_id = store_id; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/FensiBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/FensiBean.java new file mode 100644 index 0000000..0946129 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/FensiBean.java @@ -0,0 +1,36 @@ + +package com.fisherbone.fuzhu.entity; + +import androidx.databinding.BaseObservable; + +public class FensiBean extends BaseObservable { + + public FensiBean(){ + + } + public FensiBean(String zimu,String nikename){ + this.zimu = zimu;//运行时长 + this.nikename = nikename;//最大关注数 + } + + private String zimu; //字母 + + public String getZimu() { + return zimu; + } + + public void setZimu(String zimu) { + this.zimu = zimu; + } + + public String getNikename() { + return nikename; + } + + public void setNikename(String nikename) { + this.nikename = nikename; + } + + private String nikename; //用户昵称 + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/FourEvent.java b/app/src/main/java/com/fisherbone/fuzhu/entity/FourEvent.java new file mode 100644 index 0000000..c35fe32 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/FourEvent.java @@ -0,0 +1,32 @@ +package com.fisherbone.fuzhu.entity; + +/** + * Time: 2020/8/28 + * Author: jianbo + * Description: + */ +public class FourEvent { + private String mMsg; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + private String type;//3.4.大v粉丝截流 + + + public FourEvent(String msg,String typee) { + // TODO Auto-generated constructor stub + mMsg = msg; + type = typee; + + } + public String getMsg(){ + return mMsg; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/Fruit.java b/app/src/main/java/com/fisherbone/fuzhu/entity/Fruit.java new file mode 100644 index 0000000..3c936a0 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/Fruit.java @@ -0,0 +1,22 @@ +package com.fisherbone.fuzhu.entity; + +public class Fruit { + + private String name; + + private int imageId; + + public Fruit(String name, int imageId) { + this.name = name; + this.imageId = imageId; + } + + public String getName() { + return name; + } + + public int getImageId() { + return imageId; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/GetVesionResponseBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/GetVesionResponseBean.java new file mode 100644 index 0000000..4522741 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/GetVesionResponseBean.java @@ -0,0 +1,43 @@ +//package com.fisherbone.fuzhu.entity; +// +//import com.xiangxue.common.network.beans.TecentBaseResponse; +// +//public class GetVesionResponseBean extends TecentBaseResponse { +// private String success; +// +// public String getSuccess() { +// return success; +// } +// +// public void setSuccess(String success) { +// this.success = success; +// } +// +// public String getVersion() { +// return version; +// } +// +// public void setVersion(String version) { +// this.version = version; +// } +// +// public String getContent() { +// return content; +// } +// +// public void setContent(String content) { +// this.content = content; +// } +// +// public String getMsg() { +// return msg; +// } +// +// public void setMsg(String msg) { +// this.msg = msg; +// } +// +// private String version; +// private String content; +// private String msg; +//} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/HusshuBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/HusshuBean.java new file mode 100644 index 0000000..1c72257 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/HusshuBean.java @@ -0,0 +1,74 @@ +package com.fisherbone.fuzhu.entity; + + +import com.fisherbone.fuzhu.db.CommentBeanData; + +import java.util.List; + +/** + * Time: 2020/8/28 + * Author: jianbo + * Description: + */ +public class HusshuBean extends BaseModel { + + + private String msg; + private int success; + private List data; + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public int getSuccess() { + return success; + } + + public void setSuccess(int success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataDTO { + private String id; + private String comment; + private String type; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/InteraBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/InteraBean.java new file mode 100644 index 0000000..6c76b44 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/InteraBean.java @@ -0,0 +1,49 @@ +package com.fisherbone.fuzhu.entity; + +import androidx.databinding.BaseObservable; +import androidx.databinding.Bindable; + +import com.fisherbone.fuzhu.BR; + +/** + * Time: 2020/10/30 + * Author: jianbo + * Description:粉丝互动bean + */ +public class InteraBean extends BaseObservable { + public String interaContent=""; //互动内容 + public String interanum=""; //互动内容 + + @Bindable + public String getInteraContent() { + return interaContent; + } + public InteraBean(String interaContent, String interanum) { + this.interaContent = interaContent; + this.interanum = interanum; + + } + + @Override + public String toString() { + return "InteraBean{" + + "interaContent='" + interaContent + '\'' + + ", interanum='" + interanum + '\'' + + '}'; + } + public void setInteraContent(String interaContent) { + this.interaContent = interaContent; + notifyPropertyChanged(BR.interaContent); + } + + @Bindable + public String getInteranum() { + return interanum; + } + + public void setInteranum(String interanum) { + this.interanum = interanum; + notifyPropertyChanged(BR.interanum); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/LiveBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/LiveBean.java new file mode 100644 index 0000000..32d17b9 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/LiveBean.java @@ -0,0 +1,223 @@ +package com.fisherbone.fuzhu.entity; + +import androidx.databinding.BaseObservable; +import androidx.databinding.Bindable; + +import com.fisherbone.fuzhu.BR; + +/** + * Time: 2020/10/30 + * Author: jianbo + * Description:直播间加热 + */ +public class LiveBean extends BaseObservable { + private String douyinhao;//抖音帐号 + private String zhibohour;//直播时间小时 + private String zhibomin;//直播时间分钟 + private String liwucishu;//礼物次数 + private String doubishu;//总计抖币数 + private String liwutime;//刷礼物间隔时间 + private String hongbaonum;//发红包个数 + @Bindable + public String getLiwucishu() { + return liwucishu; + } + + public void setLiwucishu(String liwucishu) { + this.liwucishu = liwucishu; + notifyPropertyChanged(BR.liwucishu); + } + @Bindable + public String getDoubishu() { + return doubishu; + } + + public void setDoubishu(String doubishu) { + this.doubishu = doubishu; + notifyPropertyChanged(BR.doubishu); + } + @Bindable + public String getLiwutime() { + return liwutime; + } + + public void setLiwutime(String liwutime) { + this.liwutime = liwutime; + notifyPropertyChanged(BR.liwutime); + } + @Bindable + public String getHongbaonum() { + return hongbaonum; + } + + public void setHongbaonum(String hongbaonum) { + this.hongbaonum = hongbaonum; + notifyPropertyChanged(BR.hongbaonum); + } + @Bindable + public String getHongbaotime() { + return hongbaotime; + } + + public void setHongbaotime(String hongbaotime) { + this.hongbaotime = hongbaotime; + notifyPropertyChanged(BR.hongbaotime); + } + @Bindable + public Boolean getSwitchone() { + return switchone; + } + + public void setSwitchone(Boolean switchone) { + this.switchone = switchone; + notifyPropertyChanged(BR.switchone); + } + @Bindable + public Boolean getSwitchtwo() { + return switchtwo; + } + + public void setSwitchtwo(Boolean switchtwo) { + this.switchtwo = switchtwo; + notifyPropertyChanged(BR.switchtwo); + } + @Bindable + public Boolean getSwitchthree() { + return switchthree; + } + + public void setSwitchthree(Boolean switchthree) { + this.switchthree = switchthree; + notifyPropertyChanged(BR.switchthree); + } + @Bindable + public String getSwitchfour() { + return switchfour; + } + + public void setSwitchfour(String switchfour) { + this.switchfour = switchfour; + notifyPropertyChanged(BR.switchfour); + } + @Bindable + public Boolean getSwitchfive() { + return switchfive; + } + + public void setSwitchfive(Boolean switchfive) { + this.switchfive = switchfive; + notifyPropertyChanged(BR.switchfive); + } + @Bindable + public Boolean getSwitchsix() { + return switchsix; + } + + public void setSwitchsix(Boolean switchsix) { + this.switchsix = switchsix; + notifyPropertyChanged(BR.switchsix); + } + @Bindable + public Boolean getSwitchsevern() { + return switchsevern; + } + + public void setSwitchsevern(Boolean switchsevern) { + this.switchsevern = switchsevern; + notifyPropertyChanged(BR.switchsevern); + } + @Bindable + public Boolean getSwitcheight() { + return switcheight; + } + + public void setSwitcheight(Boolean switcheight) { + this.switcheight = switcheight; + notifyPropertyChanged(BR.switcheight); + } + + private String hongbaotime;//发红包间隔时间 + private Boolean switchone;//switch1 + private Boolean switchtwo;//switch2 + private Boolean switchthree;//switch3 + private String switchfour;//switch4 + private Boolean switchfive;//switch5 + private Boolean switchsix;//switch6 + private Boolean switchsevern;//switch7 + private Boolean switcheight;//switch8 + + public String getEndtime() { + return endtime; + } + + public void setEndtime(String endtime) { + this.endtime = endtime; + } + + private String endtime; + public LiveBean(){ + + } + public LiveBean(String str1,String str2,String str3,String str4,String str5,String str6,String str7,String str8,Boolean str9,Boolean str10,Boolean str11,String str12,Boolean str13,Boolean str14,Boolean str15,Boolean str16) { + this.douyinhao=str1; + this.zhibohour=str2; + this.zhibomin=str3; + this.liwucishu=str4; + this.doubishu=str5; + this.liwutime=str6; + this.hongbaonum=str7; + this.hongbaotime=str8; + this.switchone=str9; + this.switchtwo=str10; + this.switchthree=str11; + this.switchfour=str12; + this.switchfive=str13; + this.switchsix=str14; + this.switchsevern=str15; + this.switcheight=str16; + } + + + @Bindable + public String getMaxnum() { + return maxnum; + } + + public void setMaxnum(String maxnum) { + this.maxnum = maxnum; + notifyPropertyChanged(BR.maxnum); + } + + private String maxnum;//最大关注数 + @Bindable + public String getDouyinhao() { + return douyinhao; + } + + public void setDouyinhao(String douyinhao) { + this.douyinhao = douyinhao; + notifyPropertyChanged(BR.douyinhao); + } + + @Bindable + public String getZhibohour() { + return zhibohour; + } + + public void setZhibohour(String zhibohour) { + this.zhibohour = zhibohour; + notifyPropertyChanged(BR.zhibohour); + } + + + @Bindable + public String getZhibomin() { + return zhibomin; + } + + public void setZhibomin(String zhibomin) { + this.zhibomin = zhibomin; + notifyPropertyChanged(BR.zhibomin); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/LiveSuiJiBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/LiveSuiJiBean.java new file mode 100644 index 0000000..033df75 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/LiveSuiJiBean.java @@ -0,0 +1,168 @@ +package com.fisherbone.fuzhu.entity; + +import androidx.databinding.BaseObservable; +import androidx.databinding.Bindable; + +import com.fisherbone.fuzhu.BR; +import com.fisherbone.fuzhu.db.KeyWordBean; +import com.fisherbone.fuzhu.db.LetterBean; + +import java.util.List; + +/** + * Time: 2020/10/30 + * Author: jianbo + * Description:随机直播间抢福袋 + */ +public class LiveSuiJiBean extends BaseObservable { + + public LiveSuiJiBean(){ + + } + public LiveSuiJiBean(String str1,String str2,String str3,String str4,Boolean str5,Boolean str6,Boolean str7,Boolean str8,String str9) { + + this.minnum = str1; + this.maxnum = str2; + this.minute = str3; + this.winningrate = str4; + this.switchone=str5; + this.switchtwo=str6; + this.switchthree=str7; + this.switchfour=str8; + this.minutetwo=str9; + } + + public List getBigshotdatas() { + return bigshotdatas; + } + + public void setBigshotdatas(List bigshotdatas) { + this.bigshotdatas = bigshotdatas; + } + + public List getKeyworddatas() { + return keyworddatas; + } + + public void setKeyworddatas(List keyworddatas) { + this.keyworddatas = keyworddatas; + } + + public List getLetterdatas() { + return letterdatas; + } + + public void setLetterdatas(List letterdatas) { + this.letterdatas = letterdatas; + } + + private List bigshotdatas;//大咖 + private List keyworddatas; //关键词 + private List letterdatas; //私信话术 + + public String getSelect() { + return select; + } + + public void setSelect(String select) { + this.select = select; + } + + private String select="1"; //1是大咖 2是关键词 + @Bindable + public String getMaxnum() { + return maxnum; + } + + public void setMaxnum(String maxnum) { + this.maxnum = maxnum; + notifyPropertyChanged(BR.maxnum); + } + @Bindable + public String getMinnum() { + return minnum; + } + + public void setMinnum(String minnum) { + this.minnum = minnum; + notifyPropertyChanged(BR.minnum); + } + + private String minnum;//最少人数 + private String maxnum;//最多人数 + @Bindable + public String getMinute() { + return minute; + } + + public void setMinute(String minute) { + this.minute = minute; + notifyPropertyChanged(BR.minute); + } + + private String minute;//几分钟之内参与 + @Bindable + public String getMinutetwo() { + return minutetwo; + } + + public void setMinutetwo(String minutetwo) { + this.minutetwo = minutetwo; + notifyPropertyChanged(BR.minutetwo); + } + + private String minutetwo;//小于多少分钟之内不参与 + @Bindable + public String getWinningrate() { + return winningrate; + } + + public void setWinningrate(String winningrate) { + this.winningrate = winningrate; + notifyPropertyChanged(BR.winningrate); + } + + private String winningrate;//福袋中奖率 + private Boolean switchone; + @Bindable + public Boolean getSwitchone() { + return switchone; + } + + public void setSwitchone(Boolean switchone) { + this.switchone = switchone; + notifyPropertyChanged(BR.switchone); + } + @Bindable + public Boolean getSwitchtwo() { + return switchtwo; + } + + public void setSwitchtwo(Boolean switchtwo) { + this.switchtwo = switchtwo; + notifyPropertyChanged(BR.switchtwo); + } + @Bindable + public Boolean getSwitchthree() { + return switchthree; + } + + public void setSwitchthree(Boolean switchthree) { + this.switchthree = switchthree; + notifyPropertyChanged(BR.switchthree); + } + @Bindable + public Boolean getSwitchfour() { + return switchfour; + } + + public void setSwitchfour(Boolean switchfour) { + this.switchfour = switchfour; + notifyPropertyChanged(BR.switchfour); + } + + private Boolean switchtwo; + private Boolean switchthree; + private Boolean switchfour; + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/NewInfoBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/NewInfoBean.java new file mode 100644 index 0000000..7614aea --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/NewInfoBean.java @@ -0,0 +1,155 @@ +package com.fisherbone.fuzhu.entity; + +import java.io.Serializable; + +public class NewInfoBean implements Serializable { +// /** +// * phone_type : 0 +// * wechat_type : 0 +// * relation_type : 1 +// * record_id : e2d70ccfdb2c906e9d7dd7e6377c452e +// * store_name : 红一美式大店 +// * record_time : 2019-01-16 15:43:52 +// * uid : 149924121c1791c4fbee7fbdf78f0df9 +// * user_name : 汤妍妍 +// * only_unique : +// * tag_type : 0 +// * baobei : 0 +// */ +// +// private String phone_type; +// private String wechat_type; +// private String relation_type; +// private String record_id; +// private String store_name; +// private String record_time; +// private String uid; +// private String user_name; +// private String only_unique; +// private String tag_type; +// private String baobei; +// +// public String getPhone_type() { +// return phone_type; +// } +// +// public void setPhone_type(String phone_type) { +// this.phone_type = phone_type; +// } +// +// public String getWechat_type() { +// return wechat_type; +// } +// +// public void setWechat_type(String wechat_type) { +// this.wechat_type = wechat_type; +// } +// +// public String getRelation_type() { +// return relation_type; +// } +// +// public void setRelation_type(String relation_type) { +// this.relation_type = relation_type; +// } +// +// public String getRecord_id() { +// return record_id; +// } +// +// public void setRecord_id(String record_id) { +// this.record_id = record_id; +// } +// +// public String getStore_name() { +// return store_name; +// } +// +// public void setStore_name(String store_name) { +// this.store_name = store_name; +// } +// +// public String getRecord_time() { +// return record_time; +// } +// +// public void setRecord_time(String record_time) { +// this.record_time = record_time; +// } +// +// public String getUid() { +// return uid; +// } +// +// public void setUid(String uid) { +// this.uid = uid; +// } +// +// public String getUser_name() { +// return user_name; +// } +// +// public void setUser_name(String user_name) { +// this.user_name = user_name; +// } +// +// public String getOnly_unique() { +// return only_unique; +// } +// +// public void setOnly_unique(String only_unique) { +// this.only_unique = only_unique; +// } +// +// public String getTag_type() { +// return tag_type; +// } +// +// public void setTag_type(String tag_type) { +// this.tag_type = tag_type; +// } +// +// public String getBaobei() { +// return baobei; +// } +// +// public void setBaobei(String baobei) { +// this.baobei = baobei; +// } +// +// /** +// * satrt_time : 2019-01-14 11:01:25 +// * recudesum : 826.00 +// * store_id : b8754b65a0bcfb8526ffc6cbf851a135 +// * user_name : 陈莉莉 +// */ +// +// private String satrt_time; +// private String recudesum; +// private String store_id; +// +// public String getSatrt_time() { +// return satrt_time; +// } +// +// public void setSatrt_time(String satrt_time) { +// this.satrt_time = satrt_time; +// } +// +// public String getRecudesum() { +// return recudesum; +// } +// +// public void setRecudesum(String recudesum) { +// this.recudesum = recudesum; +// } +// +// public String getStore_id() { +// return store_id; +// } +// +// public void setStore_id(String store_id) { +// this.store_id = store_id; +// } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/NewTwos.java b/app/src/main/java/com/fisherbone/fuzhu/entity/NewTwos.java new file mode 100644 index 0000000..7d62e76 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/NewTwos.java @@ -0,0 +1,36 @@ +package com.fisherbone.fuzhu.entity; + +public class NewTwos { + public static final int ITEM_TYPE_HEADER = 0; + public static final int ITEM_TYPE_CONTENT = 1; + public static final int ITEM_TYPE_BOTTOM = 2;//单选 + private String title; + + private String content; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public boolean isSelect() { + return isSelect; + } + + public void setSelect(boolean select) { + isSelect = select; + } + + private boolean isSelect; +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/NoticeBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/NoticeBean.java new file mode 100644 index 0000000..3d3f345 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/NoticeBean.java @@ -0,0 +1,70 @@ + +package com.fisherbone.fuzhu.entity; + +import androidx.databinding.BaseObservable; + +import com.fisherbone.fuzhu.db.CommentBeanData; + +import java.util.List; + +public class NoticeBean extends BaseObservable { + + public NoticeBean(){ + + } + public NoticeBean(String lettertype,String douyin, String fensinum,String zuopinday){ + this.lettertype = lettertype; + this.douyin = douyin; + this.fensinum = fensinum; + this.zuopinday = zuopinday; + } + + public String getLettertype() { + return lettertype; + } + + public void setLettertype(String lettertype) { + this.lettertype = lettertype; + } + + public String getFensinum() { + return fensinum; + } + + public void setFensinum(String fensinum) { + this.fensinum = fensinum; + } + + public String getZuopinday() { + return zuopinday; + } + + public void setZuopinday(String zuopinday) { + this.zuopinday = zuopinday; + } + + public List getCommentBeanDataList() { + return commentBeanDataList; + } + + public void setCommentBeanDataList(List commentBeanDataList) { + this.commentBeanDataList = commentBeanDataList; + } + + private String lettertype; //私信类型 + private String fensinum; //群发粉丝数 + private String zuopinday; //作品天数 + + public String getDouyin() { + return douyin; + } + + public void setDouyin(String douyin) { + this.douyin = douyin; + } + + private String douyin; //抖音号 + + + List commentBeanDataList; +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/PotCusBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/PotCusBean.java new file mode 100644 index 0000000..afa99e5 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/PotCusBean.java @@ -0,0 +1,80 @@ +package com.fisherbone.fuzhu.entity; + +import androidx.databinding.BaseObservable; +import androidx.databinding.Bindable; + +import com.fisherbone.fuzhu.BR; +import com.fisherbone.fuzhu.db.KeyWordBean; +import com.fisherbone.fuzhu.db.LetterBean; + +import java.util.List; + +/** + * Time: 2020/10/30 + * Author: jianbo + * Description:潜在客户加关bean + */ +public class PotCusBean extends BaseObservable { + + public PotCusBean(){ + + } + public PotCusBean(List bigshotdatas, List keyworddatas, List letterdatas, String select, String maxnum) { + this.bigshotdatas = bigshotdatas; + this.keyworddatas = keyworddatas; + this.letterdatas = letterdatas; + this.select = select; + this.maxnum = maxnum; + } + + public List getBigshotdatas() { + return bigshotdatas; + } + + public void setBigshotdatas(List bigshotdatas) { + this.bigshotdatas = bigshotdatas; + } + + public List getKeyworddatas() { + return keyworddatas; + } + + public void setKeyworddatas(List keyworddatas) { + this.keyworddatas = keyworddatas; + } + + public List getLetterdatas() { + return letterdatas; + } + + public void setLetterdatas(List letterdatas) { + this.letterdatas = letterdatas; + } + + private List bigshotdatas;//大咖 + private List keyworddatas; //关键词 + private List letterdatas; //私信话术 + + public String getSelect() { + return select; + } + + public void setSelect(String select) { + this.select = select; + } + + private String select="1"; //1是大咖 2是关键词 + @Bindable + public String getMaxnum() { + return maxnum; + } + + public void setMaxnum(String maxnum) { + this.maxnum = maxnum; + notifyPropertyChanged(BR.maxnum); + } + + private String maxnum;//最大关注数 + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/RecFollowBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/RecFollowBean.java new file mode 100644 index 0000000..f70eb69 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/RecFollowBean.java @@ -0,0 +1,231 @@ +package com.fisherbone.fuzhu.entity; + +import androidx.databinding.BaseObservable; +import androidx.databinding.Bindable; + +import com.fisherbone.fuzhu.BR; + +/** + * Time: 2020/10/30 + * Author: jianbo + * Description: + */ +public class RecFollowBean extends BaseObservable { + String runningtime=""; //运行时长 + + @Override + public String toString() { + return "RecFollowBean{" + + "runningtime='" + runningtime + '\'' + + ", videotime='" + videotime + '\'' + + ", randomlikes='" + randomlikes + '\'' + + ", randomreview='" + randomreview + '\'' + + ", randomattention='" + randomattention + '\'' + + ", maxnumcon='" + maxnumcon + '\'' + + ", minimumlikes='" + minimumlikes + '\'' + + ", minimumcon='" + minimumcon + '\'' + + ", minimumzuopin='" + minimumzuopin + '\'' + + '}'; + } + + String videotime; //视频观看时长 + @Bindable + public String getMaxvideotime() { + return maxvideotime; + } + + public void setMaxvideotime(String maxvideotime) { + this.maxvideotime = maxvideotime; + notifyPropertyChanged(BR.runningtime); + } + + String maxvideotime; //视频观看最大时长 + boolean randomlikes; //随机点赞 + boolean randomreview; //随机评论 + boolean randomattention; //随机关注 + String maxnumcon=""; //最大关注数 + + @Bindable + public String getRunningtime() { + return runningtime; + } + + public void setRunningtime(String runningtime) { + this.runningtime = runningtime; + notifyPropertyChanged(BR.runningtime); + } + @Bindable + public String getVideotime() { + return videotime; + } + + public void setVideotime(String videotime) { + this.videotime = videotime; + notifyPropertyChanged(BR.videotime); + } + @Bindable + public boolean getRandomlikes() { + return randomlikes; + } + + public void setRandomlikes(boolean randomlikes) { + this.randomlikes = randomlikes; + notifyPropertyChanged(BR.randomlikes); + } + @Bindable + public boolean getRandomreview() { + return randomreview; + } + + public void setRandomreview(boolean randomreview) { + this.randomreview = randomreview; + notifyPropertyChanged(BR.randomreview); + } + @Bindable + public boolean getRandomattention() { + return randomattention; + } + + public void setRandomattention(boolean randomattention) { + this.randomattention = randomattention; + notifyPropertyChanged(BR.randomattention); + } + @Bindable + public String getMaxnumcon() { + return maxnumcon; + } + + public void setMaxnumcon(String maxnumcon) { + this.maxnumcon = maxnumcon; + notifyPropertyChanged(BR.maxnumcon); + } + + @Bindable + public String getMinimumlikes() { + return minimumlikes; + } + + public void setMinimumlikes(String minimumlikes) { + this.minimumlikes = minimumlikes; + notifyPropertyChanged(BR.minimumlikes); + } + @Bindable + public String getMinimumcon() { + return minimumcon; + } + + public void setMinimumcon(String minimumcon) { + this.minimumcon = minimumcon; + notifyPropertyChanged(BR.minimumcon); + } + @Bindable + public String getMinimumzuopin() { + return minimumzuopin; + } + + public void setMinimumzuopin(String minimumzuopin) { + this.minimumzuopin = minimumzuopin; + notifyPropertyChanged(BR.minimumzuopin); + } + + + + String minimumlikes=""; //加关关注数 + String minimumcon=""; //加关粉丝数 + + public String getEnd_time() { + return end_time; + } + + public void setEnd_time(String end_time) { + this.end_time = end_time; + } + + String end_time=""; //结束时间 + + public RecFollowBean(String runningtime, String videotime,String maxvideotime, boolean randomlikes, boolean randomreview, boolean randomattention, String maxnumcon, String minimumlikes, String minimumcon, String minimumzuopin,String maximumprotime,String maxmumzuopin,String maxmumlikes,String maximumcon,String end_time) { + this.runningtime = runningtime; + this.videotime = videotime; + this.maxvideotime = maxvideotime; + this.randomlikes = randomlikes; + this.randomreview = randomreview; + this.randomattention = randomattention; + this.maxnumcon = maxnumcon; + + this.minimumlikes = minimumlikes; + this.minimumcon = minimumcon; + this.minimumzuopin = minimumzuopin; + this.maximumprotime = maximumprotime; + this.maxmumzuopin = maxmumzuopin; + this.maxmumlikes = maxmumlikes; + this.maximumcon = maximumcon; + this.end_time = end_time; + } + + String minimumzuopin=""; //最小作品数 + String maxmumzuopin=""; //最大作品数 + @Bindable + public String getMaxmumzuopin() { + return maxmumzuopin; + } + + public void setMaxmumzuopin(String maxmumzuopin) { + this.maxmumzuopin = maxmumzuopin; + notifyPropertyChanged(BR.maximumprotime); + } + @Bindable + public String getMaxmumlikes() { + return maxmumlikes; + } + + public void setMaxmumlikes(String maxmumlikes) { + this.maxmumlikes = maxmumlikes; + notifyPropertyChanged(BR.maximumprotime); + } + @Bindable + public String getMaximumcon() { + return maximumcon; + } + + public void setMaximumcon(String maximumcon) { + this.maximumcon = maximumcon; + notifyPropertyChanged(BR.maximumprotime); + } + + String maxmumlikes=""; //最大加关关注数 + String maximumcon=""; //最大粉丝数 + @Bindable + public String getMaximumprotime() { + return maximumprotime; + } + + public void setMaximumprotime(String maximumprotime) { + this.maximumprotime = maximumprotime; + notifyPropertyChanged(BR.maximumprotime); + } + + String maximumprotime=""; //最大作品时间 + //直播运行时间(第一次记录) + String livetimefir = ""; + //直播运行时间(每次循环记录) + String livetime = ""; + + @Bindable + public String getLivetimefir() { + return livetimefir; + } + + public void setLivetimefir(String livetimefir) { + this.livetimefir = livetimefir; + notifyPropertyChanged(BR.livetimefir); + } + @Bindable + public String getLivetime() { + return livetime; + } + + public void setLivetime(String livetime) { + this.livetime = livetime; + notifyPropertyChanged(BR.livetime); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/RedEnvBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/RedEnvBean.java new file mode 100644 index 0000000..bd70fc2 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/RedEnvBean.java @@ -0,0 +1,191 @@ +package com.fisherbone.fuzhu.entity; + +import androidx.databinding.BaseObservable; +import androidx.databinding.Bindable; + +import com.fisherbone.fuzhu.BR; + +/** + * Time: 2021/7/2 + * Author: jianbo + * Description: + */ +public class RedEnvBean extends BaseObservable { + @Bindable + public String getRuntime() { + return runtime; + } + + public void setRuntime(String runtime) { + this.runtime = runtime; + notifyPropertyChanged(BR.runtime); + + } + + //任务运行时长 + String runtime = ""; + //直播间个数 + String livenum = ""; + //切换时间 + String qiehuantime = ""; + //直播间话术 + boolean redswitchone=false; + @Bindable + public String getLivedoubinumfir() { + return livedoubinumfir; + } + + public void setLivedoubinumfir(String livedoubinumfir) { + this.livedoubinumfir = livedoubinumfir; + notifyPropertyChanged(BR.livedoubinumfir); + } + @Bindable + public String getLivedoubinum() { + return livedoubinum; + } + + public void setLivedoubinum(String livedoubinum) { + this.livedoubinum = livedoubinum; + notifyPropertyChanged(BR.livedoubinum); + } + + //直播抖币数(第一次记录) + String livedoubinumfir = ""; + //直播抖币数(每次循环记录) + String livedoubinum = ""; + @Bindable + public String getLivetimefir() { + return livetimefir; + } + + public void setLivetimefir(String livetimefir) { + this.livetimefir = livetimefir; + notifyPropertyChanged(BR.livetimefir); + } + @Bindable + public String getLivetime() { + return livetime; + } + + public void setLivetime(String livetime) { + this.livetime = livetime; + notifyPropertyChanged(BR.livetime); + } + + //直播运行时间(第一次记录) + String livetimefir = ""; + //直播运行时间(每次循环记录) + String livetime = ""; + @Bindable + public boolean isRedswitchone() { + return redswitchone; + } + + public void setRedswitchone(boolean redswitchone) { + this.redswitchone = redswitchone; + notifyPropertyChanged(BR.redswitchone); + } + @Bindable + public boolean isRedswitchtwo() { + return redswitchtwo; + } + + public void setRedswitchtwo(boolean redswitchtwo) { + this.redswitchtwo = redswitchtwo; + notifyPropertyChanged(BR.redswitchtwo); + } + @Bindable + public boolean isRedswitchthree() { + return redswitchthree; + } + + public void setRedswitchthree(boolean redswitchthree) { + this.redswitchthree = redswitchthree; + notifyPropertyChanged(BR.redswitchthree); + } + @Bindable + public boolean isRedswitchfour() { + return redswitchfour; + } + + public void setRedswitchfour(boolean redswitchfour) { + this.redswitchfour = redswitchfour; + notifyPropertyChanged(BR.redswitchfour); + } + + //直播间点赞 + boolean redswitchtwo=false; + @Bindable + public String getLivenum() { + return livenum; + } + + public void setLivenum(String livenum) { + this.livenum = livenum; + notifyPropertyChanged(BR.livenum); + } + @Bindable + public String getQiehuantime() { + return qiehuantime; + } + + public void setQiehuantime(String qiehuantime) { + this.qiehuantime = qiehuantime; + notifyPropertyChanged(BR.qiehuantime); + } + + @Bindable + public String getDoubinum() { + return doubinum; + } + + public void setDoubinum(String doubinum) { + this.doubinum = doubinum; + notifyPropertyChanged(BR.doubinum); + } + @Bindable + public String getHongbaonum() { + return hongbaonum; + } + + public void setHongbaonum(String hongbaonum) { + this.hongbaonum = hongbaonum; + notifyPropertyChanged(BR.hongbaonum); + } + + //抢福袋 + boolean redswitchthree=false; + //抢红包 + boolean redswitchfour=false; + //抖币数 + String doubinum=""; + //红包数 + String hongbaonum=""; + + public String getEndtime() { + return endtime; + } + + public void setEndtime(String endtime) { + this.endtime = endtime; + } + + String endtime=""; + + public RedEnvBean() { + + } + public RedEnvBean(String runtime,String livenum,String qiehuantime,String doubinum,boolean redswitchfour,boolean redswitchtwo,boolean redswitchone) { + + this.runtime = runtime; + this.livenum = livenum; + this.qiehuantime = qiehuantime; + this.doubinum = doubinum; + this.redswitchfour = redswitchfour; + this.redswitchtwo = redswitchtwo; + this.redswitchone = redswitchone; + + } + +} + diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/Savaselect.java b/app/src/main/java/com/fisherbone/fuzhu/entity/Savaselect.java new file mode 100644 index 0000000..7f4e262 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/Savaselect.java @@ -0,0 +1,23 @@ +package com.fisherbone.fuzhu.entity; + +public class Savaselect { + private String serchuid=""; + + public String getSerchuid() { + return serchuid; + } + + public void setSerchuid(String serchuid) { + this.serchuid = serchuid; + } + + public String getUser_name() { + return user_name; + } + + public void setUser_name(String user_name) { + this.user_name = user_name; + } + + private String user_name=""; +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/SettingBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/SettingBean.java new file mode 100644 index 0000000..2011597 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/SettingBean.java @@ -0,0 +1,39 @@ +package com.fisherbone.fuzhu.entity; + +import androidx.databinding.BaseObservable; +import androidx.databinding.Bindable; + +import com.fisherbone.fuzhu.BR; + +/** + * Time: 2021/7/2 + * Author: jianbo + * Description: + */ +public class SettingBean extends BaseObservable { + + //直播间话术 + boolean redswitchone=false; + + //直播运行时间(第一次记录) + String livetimefir = ""; + //直播运行时间(每次循环记录) + String livetime = ""; + @Bindable + public boolean isRedswitchone() { + return redswitchone; + } + + public void setRedswitchone(boolean redswitchone) { + this.redswitchone = redswitchone; + notifyPropertyChanged(BR.redswitchone); + } + + public SettingBean(boolean redswitchone) { + + this.redswitchone = redswitchone; + + } + +} + diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/SixEvent.java b/app/src/main/java/com/fisherbone/fuzhu/entity/SixEvent.java new file mode 100644 index 0000000..ce45431 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/SixEvent.java @@ -0,0 +1,32 @@ +package com.fisherbone.fuzhu.entity; + +/** + * Time: 2020/8/28 + * Author: jianbo + * Description:此是弹出的toast的检测通知bean + */ +public class SixEvent { + private String mMsg; + + public String getToastMsg() { + return toastMsg; + } + + public void setToastMsg(String toastMsg) { + this.toastMsg = toastMsg; + } + + private String toastMsg; + + + public SixEvent(String msg,String toastmsg) { + // TODO Auto-generated constructor stub + mMsg = msg; + toastMsg = toastmsg; + + } + public String getMsg(){ + return mMsg; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/Status.java b/app/src/main/java/com/fisherbone/fuzhu/entity/Status.java new file mode 100644 index 0000000..dc383dd --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/Status.java @@ -0,0 +1,18 @@ +package com.fisherbone.fuzhu.entity; + +/** + * https://github.com/CymChad/BaseRecyclerViewAdapterHelper + */ +public class Status { + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + private String content; + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/StyleBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/StyleBean.java new file mode 100644 index 0000000..9783deb --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/StyleBean.java @@ -0,0 +1,99 @@ +package com.fisherbone.fuzhu.entity; + + +import java.io.Serializable; +import java.util.List; + +/** + * Time: 2020/8/28 + * Author: jianbo + * Description: + */ +public class StyleBean extends BaseModel { + + /** + * result : {"msg":"成功","data":[{"style":"北欧","style_id":"1"}],"success":0} + * status : 0 + */ + + private ResultBean result; + private int status; + + public ResultBean getResult() { + return result; + } + + public void setResult(ResultBean result) { + this.result = result; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public static class ResultBean { + /** + * msg : 成功 + * data : [{"style":"北欧","style_id":"1"}] + * success : 0 + */ + + private String msg; + private int success; + private List data; + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public int getSuccess() { + return success; + } + + public void setSuccess(int success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean implements Serializable { + /** + * style : 北欧 + * style_id : 1 + */ + + private String style; + private String style_id; + + public String getStyle() { + return style; + } + + public void setStyle(String style) { + this.style = style; + } + + public String getStyle_id() { + return style_id; + } + + public void setStyle_id(String style_id) { + this.style_id = style_id; + } + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/ThirdEvent.java b/app/src/main/java/com/fisherbone/fuzhu/entity/ThirdEvent.java new file mode 100644 index 0000000..fa5ba55 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/ThirdEvent.java @@ -0,0 +1,21 @@ +package com.fisherbone.fuzhu.entity; + +/** + * Time: 2020/8/28 + * Author: jianbo + * Description: + */ +public class ThirdEvent { + private String mMsg; + + + public ThirdEvent(String msg) { + // TODO Auto-generated constructor stub + mMsg = msg; + + } + public String getMsg(){ + return mMsg; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/UrgentTaskBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/UrgentTaskBean.java new file mode 100644 index 0000000..d5b03d9 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/UrgentTaskBean.java @@ -0,0 +1,276 @@ +package com.fisherbone.fuzhu.entity; + +public class UrgentTaskBean extends BaseModel { + + + private String msg; + private DataDTO data; + private int success; + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public DataDTO getData() { + return data; + } + + public void setData(DataDTO data) { + this.data = data; + } + + public int getSuccess() { + return success; + } + + public void setSuccess(int success) { + this.success = success; + } + + public static class DataDTO { + private String start_time; + private String create_time; + private String end_time; + private String task_id; + private String short_id; + private String task_type; + + public String getFunc_type() { + return func_type; + } + + public void setFunc_type(String func_type) { + this.func_type = func_type; + } + + private String func_type; + private FunctionExecuteDTO function_execute; + + public String getStart_time() { + return start_time; + } + + public void setStart_time(String start_time) { + this.start_time = start_time; + } + + public String getCreate_time() { + return create_time; + } + + public void setCreate_time(String create_time) { + this.create_time = create_time; + } + + public String getEnd_time() { + return end_time; + } + + public void setEnd_time(String end_time) { + this.end_time = end_time; + } + + public String getTask_id() { + return task_id; + } + + public void setTask_id(String task_id) { + this.task_id = task_id; + } + + public String getShort_id() { + return short_id; + } + + public void setShort_id(String short_id) { + this.short_id = short_id; + } + + public String getTask_type() { + return task_type; + } + + public void setTask_type(String task_type) { + this.task_type = task_type; + } + + public FunctionExecuteDTO getFunction_execute() { + return function_execute; + } + + public void setFunction_execute(FunctionExecuteDTO function_execute) { + this.function_execute = function_execute; + } + + public static class FunctionExecuteDTO { + private int is_rand_good; + private int is_rand_forward; + private int max_follow; + private int is_rand_follow; + private String create_time; + private int and_follow_min; + private int watch_duration_max; + private String task_id; + private int min_work; + private int max_work_time; + private int and_fans_min; + private String touch_num; + private int and_follow_max; + private int watch_duration_min; + private int is_rand_comment; + private int and_fans_max; + private int id; + private int account_duration; + + public int getIs_rand_good() { + return is_rand_good; + } + + public void setIs_rand_good(int is_rand_good) { + this.is_rand_good = is_rand_good; + } + + public int getIs_rand_forward() { + return is_rand_forward; + } + + public void setIs_rand_forward(int is_rand_forward) { + this.is_rand_forward = is_rand_forward; + } + + public int getMax_follow() { + return max_follow; + } + + public void setMax_follow(int max_follow) { + this.max_follow = max_follow; + } + + public int getIs_rand_follow() { + return is_rand_follow; + } + + public void setIs_rand_follow(int is_rand_follow) { + this.is_rand_follow = is_rand_follow; + } + + public String getCreate_time() { + return create_time; + } + + public void setCreate_time(String create_time) { + this.create_time = create_time; + } + + public int getAnd_follow_min() { + return and_follow_min; + } + + public void setAnd_follow_min(int and_follow_min) { + this.and_follow_min = and_follow_min; + } + + public int getWatch_duration_max() { + return watch_duration_max; + } + + public void setWatch_duration_max(int watch_duration_max) { + this.watch_duration_max = watch_duration_max; + } + + + + public String getTask_id() { + return task_id; + } + + public void setTask_id(String task_id) { + this.task_id = task_id; + } + + public int getMin_work() { + return min_work; + } + + public void setMin_work(int min_work) { + this.min_work = min_work; + } + + public int getMax_work_time() { + return max_work_time; + } + + public void setMax_work_time(int max_work_time) { + this.max_work_time = max_work_time; + } + + public int getAnd_fans_min() { + return and_fans_min; + } + + public void setAnd_fans_min(int and_fans_min) { + this.and_fans_min = and_fans_min; + } + + public String getTouch_num() { + return touch_num; + } + + public void setTouch_num(String touch_num) { + this.touch_num = touch_num; + } + + public int getAnd_follow_max() { + return and_follow_max; + } + + public void setAnd_follow_max(int and_follow_max) { + this.and_follow_max = and_follow_max; + } + + public int getWatch_duration_min() { + return watch_duration_min; + } + + public void setWatch_duration_min(int watch_duration_min) { + this.watch_duration_min = watch_duration_min; + } + + public int getIs_rand_comment() { + return is_rand_comment; + } + + public void setIs_rand_comment(int is_rand_comment) { + this.is_rand_comment = is_rand_comment; + } + + public int getAnd_fans_max() { + return and_fans_max; + } + + public void setAnd_fans_max(int and_fans_max) { + this.and_fans_max = and_fans_max; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getAccount_duration() { + return account_duration; + } + + public void setAccount_duration(int account_duration) { + this.account_duration = account_duration; + } + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/addCustomerBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/addCustomerBean.java new file mode 100644 index 0000000..b5f8134 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/addCustomerBean.java @@ -0,0 +1,155 @@ +package com.fisherbone.fuzhu.entity; + +import com.j256.ormlite.field.DatabaseField; +import com.j256.ormlite.table.DatabaseTable; + +/** + * Time: 2020/8/28 + * Author: jianbo + * Description: + */ +@DatabaseTable(tableName = "tab_customerbean") +public class addCustomerBean { +// private String uid string 登录员工的uid 是 否 +// private String headimg string 头像 否 否 base64 空 +// private String name string 姓名 是 否 +// private String phone string 电话 是 否 +// private String wechat string 微信 否 否 空 +// private String address string 住址 否 否 空 +// private String decoration string 家装阶段 否 否 1:毛坯,2:精装,3:旧房改造 1 +// private String style_id string 风格id 否 否 空 +// private String budget string 预算 否 否 空 +// private String source string 客户来源 否 否 1:添加客户 1 +// private String customer_id string 客户id 否 否 有值代表完善信息,空代表添加 + + @DatabaseField(id = true,columnName = "Id") + private String id; + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + @DatabaseField(columnName = "uid") + private String uid=""; + @DatabaseField(columnName = "headimg") + private String headimg=""; + @DatabaseField(columnName = "name") + private String name=""; + + public String getStyle_name() { + return style_name; + } + + public void setStyle_name(String style_name) { + this.style_name = style_name; + } + @DatabaseField(columnName = "style_name") + private String style_name; + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public String getHeadimg() { + return headimg; + } + + public void setHeadimg(String headimg) { + this.headimg = headimg; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getWechat() { + return wechat; + } + + public void setWechat(String wechat) { + this.wechat = wechat; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getDecoration() { + return decoration; + } + + public void setDecoration(String decoration) { + this.decoration = decoration; + } + + public String getStyle_id() { + return style_id; + } + + public void setStyle_id(String style_id) { + this.style_id = style_id; + } + + public String getBudget() { + return budget; + } + + public void setBudget(String budget) { + this.budget = budget; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getCustomer_id() { + return customer_id; + } + + public void setCustomer_id(String customer_id) { + this.customer_id = customer_id; + } + @DatabaseField(columnName = "phone") + private String phone=""; + @DatabaseField(columnName = "wechat") + private String wechat=""; + @DatabaseField(columnName = "address") + private String address=""; + @DatabaseField(columnName = "decoration") + private String decoration="1"; + @DatabaseField(columnName = "style_id") + private String style_id=""; + @DatabaseField(columnName = "budget") + private String budget=""; + @DatabaseField(columnName = "source") + private String source="1"; + @DatabaseField(columnName = "customer_id") + private String customer_id=""; + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/addWinEntity.java b/app/src/main/java/com/fisherbone/fuzhu/entity/addWinEntity.java new file mode 100644 index 0000000..7d42dd4 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/addWinEntity.java @@ -0,0 +1,8 @@ +package com.fisherbone.fuzhu.entity; + +public class addWinEntity { + + public static boolean isopen=false;//加关悬浮界面是否开启 + public static boolean cancleisopen=false;//取关关悬浮界面是否开启 + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/dakaVideoListBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/dakaVideoListBean.java new file mode 100644 index 0000000..620781f --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/dakaVideoListBean.java @@ -0,0 +1,146 @@ +package com.fisherbone.fuzhu.entity; + +import java.io.Serializable; +import java.util.List; + +/** + * Time: 2021/4/28 + * Author: jianbo + * Description: + */ +public class dakaVideoListBean implements Serializable { + + private int success; + private List data; + private String msg; + + + + public int getSuccess() { + return success; + } + + public void setSuccess(int success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public static class DataBean { + public static final int ITEM_TYPE_HEADER = 0; + public static final int ITEM_TYPE_CONTENT = 1; + public static final int ITEM_TYPE_BOTTOM = 2;//单选 + private String id; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + private String type; + private String name; + private List key; + + public boolean isSelect() { + return isSelect; + } + + public void setSelect(boolean select) { + isSelect = select; + } + + private boolean isSelect; + + public boolean isIsseclect() { + return isseclect; + } + + public void setIsseclect(boolean isseclect) { + this.isseclect = isseclect; + } + + private boolean isseclect=false; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getIf_sel_del() { + return if_sel_del; + } + + public void setIf_sel_del(String if_sel_del) { + this.if_sel_del = if_sel_del; + } + + private String if_sel_del="0";//是否选中 //0未选中 1为选中 + + + public List getKey() { + return key; + } + + public void setKey(List key) { + this.key = key; + } + + public static class KeyBean { + private String key_id; + private String id; + private String key_name; + + public String getKey_id() { + return key_id; + } + + public void setKey_id(String key_id) { + this.key_id = key_id; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getKey_name() { + return key_name; + } + + public void setKey_name(String key_name) { + this.key_name = key_name; + } + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/letterListBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/letterListBean.java new file mode 100644 index 0000000..927ec7c --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/letterListBean.java @@ -0,0 +1,61 @@ +package com.fisherbone.fuzhu.entity; + +import java.io.Serializable; +import java.util.List; + +/** + * Time: 2021/4/28 + * Author: jianbo + * Description: + */ +public class letterListBean implements Serializable { + + private int success; + private List data; + private String msg; + + public int getSuccess() { + return success; + } + + public void setSuccess(int success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public static class DataBean { + private String id; + private String content; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/loginInfoBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/loginInfoBean.java new file mode 100644 index 0000000..8b1661d --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/loginInfoBean.java @@ -0,0 +1,151 @@ +package com.fisherbone.fuzhu.entity; + +import java.io.Serializable; + +/** + * loginInfoBean + * (๑• . •๑) + * 类描述:用户资料实体类 + * Created by LeiXiaoXing on 2017/4/11 10:56 + */ + +public class loginInfoBean implements Serializable { + /** + * msg : 登陆成功 + * data : {"store_id":"1","industry_name":"家具","user_head":"","user_type":"2","user_name":"admin","phone_number":"14729066305","uuid":"3","status":"0"} + * success : 0 + */ + + private String msg; + private DataBean data; + private int success; + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public int getSuccess() { + return success; + } + + public void setSuccess(int success) { + this.success = success; + } + + public static class DataBean { + /** + * store_id : 1 + * industry_name : 家具 + * user_head : + * user_type : 2 + * user_name : admin + * phone_number : 14729066305 + * uuid : 3 + * status : 0 + */ + + private String store_id; + private String industry_name; + private String user_head; + private String user_type; + private String user_name; + private String phone_number; + private String uuid; + private String status; + + public String getUnion_id() { + return union_id; + } + + public void setUnion_id(String union_id) { + this.union_id = union_id; + } + + public String getAddress_addr() { + return address_addr; + } + + public void setAddress_addr(String address_addr) { + this.address_addr = address_addr; + } + + private String union_id; + private String address_addr; + + public String getStore_id() { + return store_id; + } + + public void setStore_id(String store_id) { + this.store_id = store_id; + } + + public String getIndustry_name() { + return industry_name; + } + + public void setIndustry_name(String industry_name) { + this.industry_name = industry_name; + } + + public String getUser_head() { + return user_head; + } + + public void setUser_head(String user_head) { + this.user_head = user_head; + } + + public String getUser_type() { + return user_type; + } + + public void setUser_type(String user_type) { + this.user_type = user_type; + } + + public String getUser_name() { + return user_name; + } + + public void setUser_name(String user_name) { + this.user_name = user_name; + } + + public String getPhone_number() { + return phone_number; + } + + public void setPhone_number(String phone_number) { + this.phone_number = phone_number; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/touchTaskBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/touchTaskBean.java new file mode 100644 index 0000000..e80b172 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/touchTaskBean.java @@ -0,0 +1,76 @@ +package com.fisherbone.fuzhu.entity; + +import com.fisherbone.fuzhu.db.zhuanghaoBeanData; + +import java.util.List; + +public class touchTaskBean extends BaseModel { + + + private String msg; + private int success; + private List data; + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public int getSuccess() { + return success; + } + + public void setSuccess(int success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + +// public static class zhuanghaoBeanData { +// private String record_id; +// private String phone; +// private String name; +// private String id; +// +// public String getRecord_id() { +// return record_id; +// } +// +// public void setRecord_id(String record_id) { +// this.record_id = record_id; +// } +// +// public String getPhone() { +// return phone; +// } +// +// public void setPhone(String phone) { +// this.phone = phone; +// } +// +// public String getName() { +// return name; +// } +// +// public void setName(String name) { +// this.name = name; +// } +// +// public String getId() { +// return id; +// } +// +// public void setId(String id) { +// this.id = id; +// } +// } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/fragment/EditContentFragment.java b/app/src/main/java/com/fisherbone/fuzhu/fragment/EditContentFragment.java new file mode 100644 index 0000000..dc64eba --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/fragment/EditContentFragment.java @@ -0,0 +1,350 @@ +package com.fisherbone.fuzhu.fragment; + +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.blankj.utilcode.util.ToastUtils; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.activity.PublishActivity; +import com.fisherbone.fuzhu.dialog.BaseTipsDialog; +import com.fisherbone.fuzhu.entity.NewTwos; +import com.fisherbone.fuzhu.entity.dakaVideoListBean; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.google.gson.Gson; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +import io.reactivex.disposables.Disposable; + +public class EditContentFragment extends Fragment { + + private View view; + private RecyclerView newsTitleRecyclerView; + private NewsAdapter adapter; + private List mNewsList; + private Disposable mdDisposable; + private String page_type; + private String title="评论关键词"; + private boolean isTwoPane=true; + private List mNewTwos; + List key; + private String selectType="1"; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + view = inflater.inflate(R.layout.news_content_frag, container, false); + newsTitleRecyclerView = (RecyclerView) view.findViewById(R.id.news_title_recycler_view); + LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); + newsTitleRecyclerView.setLayoutManager(layoutManager); + return view; + } + + private void initData() { + //左边listView集合添加数据,适配器适配 + mNewsList = getNews(); + + adapter = new NewsAdapter(mNewsList,mNewTwos); + newsTitleRecyclerView.setAdapter(adapter); + //默认选中ListView第一条item + //ListView第一条item的Select为true + // mList.get(0).setSelect(true); + //listView点击事件 + } + + public void refresh(String page_type, String newsContent,List key) { + View visibilityLayout = view.findViewById(R.id.visibility_layout); + visibilityLayout.setVisibility(View.VISIBLE); + this.page_type=page_type; + this.key=key; + initData(); + } + + + private List getNews() { + List newsList = new ArrayList<>(); + for(int i=0;i { + + private List mNewsList; + + class ViewHolderCotent extends RecyclerView.ViewHolder { + + TextView newsTitleText; + TextView tv_word; + ImageView ima_word; + + public ViewHolderCotent(View view) { + super(view); + newsTitleText = (TextView) view.findViewById(R.id.news_title); + tv_word = (TextView) view.findViewById(R.id.tv_word); + ima_word = (ImageView) view.findViewById(R.id.ima_word); + + } + + } + + class ViewHolderBoot extends RecyclerView.ViewHolder { + RelativeLayout rl_bianji; + RecyclerView recycler_view; + public ViewHolderBoot(View view) { + super(view); + rl_bianji = (RelativeLayout) view.findViewById(R.id.rl_bianji); + recycler_view = (RecyclerView) view.findViewById(R.id.recycler_view); + } + } + + class ViewHolderHead extends RecyclerView.ViewHolder { + TextView tv_head_title; + public ViewHolderHead(View view) { + super(view); + tv_head_title = (TextView) view.findViewById(R.id.tv_head_title); + } + } + + public NewsAdapter(List newsList,List newTwos) { + mNewsList = newsList; + mNewTwos = newTwos; + } + + @Override + public int getItemViewType(int position) { + if (position == 0) { // 头部 + return dakaVideoListBean.DataBean.ITEM_TYPE_HEADER; + }if (position == mNewsList.size()+1) { + return dakaVideoListBean.DataBean.ITEM_TYPE_BOTTOM; + } + else { + return dakaVideoListBean.DataBean.ITEM_TYPE_CONTENT; + } + } + + @Override + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + switch (viewType) { + case dakaVideoListBean.DataBean.ITEM_TYPE_HEADER: + final ViewHolderHead holderone = new ViewHolderHead(LayoutInflater.from(parent.getContext()).inflate(R.layout.news_item_head, parent, false)); + return holderone; + case dakaVideoListBean.DataBean.ITEM_TYPE_BOTTOM: + final ViewHolderBoot holdertwo = new ViewHolderBoot(LayoutInflater.from(parent.getContext()).inflate(R.layout.edit_content_boot, parent, false)); + return holdertwo; + case dakaVideoListBean.DataBean.ITEM_TYPE_CONTENT: + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.words_content_item, parent, false); + final ViewHolderCotent holder = new ViewHolderCotent(view); + return holder; + default: + } + return null; + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + if (holder instanceof ViewHolderHead) { + ViewHolderHead headHolder = (ViewHolderHead) holder; + headHolder.tv_head_title.setText(title); + } else if (holder instanceof ViewHolderBoot) { + ViewHolderBoot bootHolder = (ViewHolderBoot) holder; + bootHolder.rl_bianji.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + + Gson gson = new Gson(); + ArrayList strings = new ArrayList<>(); + for(int i=0;i stringtwo = new ArrayList<>(); + for(int i=0;i0){ + Intent i = new Intent(getActivity(), PublishActivity.class); + Bundle bundle = new Bundle(); + bundle.putSerializable("id", id); + bundle.putSerializable("key_name", keyname); + i.putExtras(bundle); + getActivity().startActivity(i); + }else { + ToastUtils.showShort("请选择评论关键词"); + } + // ToastUtils.showShort("点击了选择大咖。。。"); + } + }); + + } else { + dakaVideoListBean.DataBean news = mNewsList.get(position - 1); + ViewHolderCotent contentHolder = (ViewHolderCotent) holder; + contentHolder.newsTitleText.setText(news.getName()); + contentHolder.tv_word.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + // ToastUtils.showShort("点击了删除。。。"); + new BaseTipsDialog().showDownloadDialog(getActivity(), "确认删除吗?", "确定", new BaseTipsDialog.ClickListener() { + @Override + public void confirm() { + //1:大咖,2:视频关键词,3:大咖评论关键词,4:视频的评论关键词 + if(page_type.equals("1")){ + delete(news.getId(),"3"); + }else { + delete(news.getId(),"4"); + } + + } + @Override + public void cancle() { + + } + }); + + + } + }); + + if (news.getIf_sel_del().equals("0")) { + contentHolder.ima_word.setImageResource(R.mipmap.icon_cheched_false); + } else { + contentHolder.ima_word.setImageResource(R.mipmap.icon_cheched_true); + } + //做单选条件限制 + contentHolder.ima_word.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + //本次选择 + if (IsSelecet(position-1)) { + cancalchoose(position-1); + } else { + //selectType 0为单选 1为多选 + if (selectType.equals("0")) { + //先清除上次选中状态 + for (int i = 0; i < mNewsList.size(); i++) { + dakaVideoListBean.DataBean news1 = mNewsList.get(i); + if (news1.getIf_sel_del().equals("1")) { + cancalchoose(i); + } + } + } + selecttrue(position-1); + + } + notifyDataSetChanged(); + } + }); + } + } + + @Override + public int getItemCount() { + return mNewsList.size() + 2; + } + + } + /** + * 选中(单选) + * + * @return + */ + private void selecttrue(int position) { + mNewsList.get(position).setIf_sel_del("1"); + } + /** + * 取消 + * + * @return + */ + private void cancalchoose(int childposition) { + mNewsList.get(childposition).setIf_sel_del("0"); + } + + /** + * 当前条目是否选中 + * + * @return + */ + public boolean IsSelecet(int childposition) { + + if (mNewsList.get(childposition).getIf_sel_del().equals("1")) { + return true; + } else { + return false; + } + } + + private void delete(String del_id,String type){ + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("del_id", del_id); + paramsPost.put("type", type); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_delete).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if(success.equals("0")){ + com.fisherbone.fuzhu.utils.ToastUtils.showToast(getActivity(), msg); + for(int i=0;i list; + private StreamList streamList; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.edit_title_frag, container, false); + streamList = (StreamList) view.findViewById(R.id.sl); + streamList.setaddDakaCallBack(this); + Bundle bundle = getArguments(); + //这里就拿到了之前传递的参数 + page_type = bundle.getString("page_type"); + + initData(); + return view; + } + + private void initData() { +// list = new ArrayList<>(); +// list.add( new dataBean("地产S姐",true)); +// list.add(new dataBean("西安房产彭于晏",false)); +// list.add(new dataBean("西安房产豪哥",false)); +// list.add(new dataBean("西安地产裂痕",false)); +// list.add(new dataBean("李先生房必得地产",false)); +// +// streamList.setType(Contant.TEXT_DELETE); +// streamList.setViewResouce(R.layout.item_text_delete); +// streamList.setData(list); +// +// //默认选中ListView第一条item +// //ListView第一条item的Select为true +// // mList.get(0).setSelect(true); +// //listView点击事件 +// taskdaojishi(1); + + + getdakaVideoList(); + + } + private void getdakaVideoList(){ + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("type", "1");//1:大咖,2:视频关键词 + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_dakaVideoList).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + + @Override + public void onNext(Response response) { + String body = (String) response.body(); + dakaVideoListBean dakaVideoListBean = JsonUtils.fromJson(body, dakaVideoListBean.class); + if(dakaVideoListBean.getSuccess()==0){ + list = dakaVideoListBean.getData(); + // list = new ArrayList<>(); +// list.add( new dataBean("地产S姐",true)); +// list.add(new dataBean("西安房产彭于晏",false)); +// list.add(new dataBean("西安房产豪哥",false)); +// list.add(new dataBean("西安地产裂痕",false)); +// list.add(new dataBean("李先生房必得地产",false)); +// + if(list.size()>0){ + com.fisherbone.fuzhu.entity.dakaVideoListBean.DataBean dataBean = list.get(0); + dataBean.setIsseclect(true); + } + + streamList.setType(Contant.TEXT_DELETE); + streamList.setViewResouce(R.layout.item_text_delete); + streamList.setData(list); + taskdaojishi(1); + + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + /** + * 停任务的倒计时 + * + * @param a + */ + private void taskdaojishi(final int a) { + //启动计时器 + //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 + mdDisposable = Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) + .observeOn(AndroidSchedulers.mainThread()) + .doOnNext(new Consumer() { + @Override + public void accept(Long aLong) throws Exception { + long b = a - aLong; + Log.e("TIAOSHI###", b + ""); + } + }) + .doOnComplete(new Action() { + @Override + public void run() throws Exception { + if(list.size()>0) { + dakaVideoListBean.DataBean dataBean = list.get(0); + EditContentFragment newsContentFragment = (EditContentFragment) + getFragmentManager().findFragmentById(R.id.news_content_fragment); + newsContentFragment.refresh(page_type, dataBean.getName(), dataBean.getKey()); + } + + } + }) + .subscribe(); + } + + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + if (getActivity().findViewById(R.id.news_content_layout) != null) { + isTwoPane = true; // 可以找到news_content_layout布局时,为双页模式 + } else { + isTwoPane = false; // 找不到news_content_layout布局时,为单页模式 + } + } + + private List getNews() { + List newsList = new ArrayList<>(); + dakaVideoListBean.DataBean news = new dakaVideoListBean.DataBean(); + news.setName("位置" + 0); + news.setName(getRandomLengthContent("地产S姐 " + 0 + ". ")); + newsList.add(news); + + return newsList; + } + + private String getRandomLengthContent(String content) { + Random random = new Random(); + int length = random.nextInt(20) + 1; + StringBuilder builder = new StringBuilder(); + for (int i = 0; i < length; i++) { + builder.append(content); + } + return builder.toString(); + } + + @Override + public void addDaka() { + JumpUtils.gotoActivity(getActivity(), DakaActivity.class, false, "type","1"); + } + + @Override + public void deleteDaka(String del_id) { + delete(del_id,page_type); + } + + @Override + public void pinglunword(List key) { + EditContentFragment newsContentFragment = (EditContentFragment) + getFragmentManager().findFragmentById(R.id.news_content_fragment); + newsContentFragment.refresh(page_type,"", key); + } + + + private void delete(String del_id,String type){ + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("del_id", del_id); + paramsPost.put("type", type); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_delete).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if(success.equals("0")){ + com.fisherbone.fuzhu.utils.ToastUtils.showToast(getActivity(), msg); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/fragment/LiwuFragment.java b/app/src/main/java/com/fisherbone/fuzhu/fragment/LiwuFragment.java new file mode 100644 index 0000000..124608d --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/fragment/LiwuFragment.java @@ -0,0 +1,80 @@ +package com.fisherbone.fuzhu.fragment; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.CompoundButton; +import android.widget.RelativeLayout; +import android.widget.Switch; + +import androidx.databinding.DataBindingUtil; +import androidx.fragment.app.Fragment; + +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.databinding.ItemLiwusetBinding; +import com.fisherbone.fuzhu.entity.LiveBean; +import com.fisherbone.fuzhu.views.FoldLayout; + +import java.util.ArrayList; +import java.util.List; + +public class LiwuFragment extends Fragment { + + private View view; + private Switch switch1; + private RelativeLayout rl_liwu; + private LiveBean liveBean1; + + public LiwuFragment(LiveBean liveBean1){ + this.liveBean1=liveBean1; + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + view = inflater.inflate(R.layout.liwu_content_frag, container, false); + Bundle bundle = getArguments(); + //这里就拿到了之前传递的参数 + //visitor_id = bundle.getString("visitor_id"); + + FoldLayout foldlayout = (FoldLayout) view.findViewById(R.id.foldlayout); + // foldlayout.setOnItemClickListener(); + List views1 = new ArrayList<>(); + // views1.add(getLayoutInflater().inflate(R.layout.item_liwuset, null)); + ItemLiwusetBinding binding= DataBindingUtil.inflate(inflater, R.layout.item_liwuset, container, false); + binding.setLivebean(liveBean1); + views1.add(binding.getRoot()); + // foldlayout.addItemView(views1); + foldlayout.addItemView(views1); + + // rl_liwu = (RelativeLayout) view.findViewById(R.id.rl_liwu); + switch1 = (Switch) view.findViewById(R.id.switch1); +// if (randomlikes.equals("0")) { +// binding.switch1.setChecked(false); +// } else { +// binding.switch1.setChecked(true); +// } + switch1.setSwitchTextAppearance(getActivity(), 0); + switch1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + //控制开关字体颜色 + if (b) { + // Toast.makeText(getActivity(), "开", Toast.LENGTH_SHORT).show(); + // recFollowBean.setRandomlikes("1"); + foldlayout.isopen(); + } else { + // Toast.makeText(getActivity(), "关", Toast.LENGTH_SHORT).show(); + // recFollowBean.setRandomlikes("0"); + foldlayout.isclosed(); + } + + } + }); + + return view; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/fragment/NewsContentFragment.java b/app/src/main/java/com/fisherbone/fuzhu/fragment/NewsContentFragment.java new file mode 100644 index 0000000..ca41197 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/fragment/NewsContentFragment.java @@ -0,0 +1,307 @@ +package com.fisherbone.fuzhu.fragment; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.chad.library.adapter.base.BaseQuickAdapter; +import com.chad.library.adapter.base.BaseViewHolder; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.activity.PriLetEditActivity; +import com.fisherbone.fuzhu.entity.NewTwos; +import com.fisherbone.fuzhu.entity.dakaVideoListBean; +import com.fisherbone.fuzhu.entity.letterListBean; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.fisherbone.fuzhu.utils.JsonUtils; +import com.fisherbone.fuzhu.utils.JumpUtils; +import com.fisherbone.fuzhu.utils.WidgetTools; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import io.reactivex.disposables.Disposable; + +public class NewsContentFragment extends Fragment { + + private View view; + private RecyclerView newsTitleRecyclerView; + private NewsAdapter adapter; + private List mNewsList; + private Disposable mdDisposable; + private String page_type; + private String title="评论关键词"; + private boolean isTwoPane=true; + private List mNewTwos; + List key; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + view = inflater.inflate(R.layout.news_content_frag, container, false); + newsTitleRecyclerView = (RecyclerView) view.findViewById(R.id.news_title_recycler_view); + LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); + newsTitleRecyclerView.setLayoutManager(layoutManager); + + + return view; + } + + private void initData() { + //左边listView集合添加数据,适配器适配 + mNewsList = getNews(); + getNewTwos(); + + //默认选中ListView第一条item + //ListView第一条item的Select为true + // mList.get(0).setSelect(true); + //listView点击事件 + } + + public void refresh(List key) { + View visibilityLayout = view.findViewById(R.id.visibility_layout); + visibilityLayout.setVisibility(View.VISIBLE); +// TextView newsTitleText = (TextView) view.findViewById (R.id.news_title); +// TextView newsContentText = (TextView) view.findViewById(R.id.news_content); +// newsTitleText.setText(newsTitle); // 刷新新闻的标题 +// newsContentText.setText(newsContent); // 刷新新闻的内容 + this.key=key; + initData(); + } + + + private List getNews() { + List newsList = new ArrayList<>(); +// News news = new News(); +// news.setTitle("地产S姐 " + 0); +// news.setContent(getRandomLengthContent("地产S姐 " + 0 + ". ")); +// newsList.add(news); +// News news1 = new News(); +// news1.setTitle("西安房产彭于晏 " + 1); +// news1.setContent(getRandomLengthContent("西安房产彭于晏 " + 1 + ". ")); +// newsList.add(news1); +// News news2 = new News(); +// news2.setTitle("西安房产豪哥 " + 2); +// news2.setContent(getRandomLengthContent("西安房产豪哥 " + 2 + ". ")); +// newsList.add(news2); +// News news3 = new News(); +// news3.setTitle("西安地产裂痕 " + 3); +// news3.setContent(getRandomLengthContent("西安地产裂痕 " + 3 + ". ")); +// newsList.add(news3); +// News news4 = new News(); +// news4.setTitle("李先生房必得地产 " + 4); +// news4.setContent(getRandomLengthContent("李先生房必得地产 " + 4 + ". ")); +// newsList.add(news4); +// News news5 = new News(); +// news5.setTitle("小周聊房产 " + 5); +// news5.setContent(getRandomLengthContent("小周聊房产 " + 5 + ". ")); +// newsList.add(news5); + + for(int i=0;i newsList = new ArrayList<>(); +// NewTwos news = new NewTwos(); +// news.setTitle("好几次看到你了~缘分互关一下吧!互赞三个! " + 0); +// news.setContent(getRandomLengthContent("地产S姐 " + 0 + ". ")); +// newsList.add(news); +// NewTwos news1 = new NewTwos(); +// news1.setTitle("拍的不错,好几次看到你了~缘分互关一下吧!互赞三个! " + 1); +// news1.setContent(getRandomLengthContent("西安房产彭于晏 " + 1 + ". ")); +// newsList.add(news1); +// NewTwos news2 = new NewTwos(); +// news2.setTitle("你的视频真好~互关一下,互赞三个! " + 2); +// news2.setContent(getRandomLengthContent("西安房产豪哥 " + 2 + ". ")); +// newsList.add(news2); +// NewTwos news3 = new NewTwos(); +// news3.setTitle("哎~好几次看到你了~缘分互关一下吧!互赞三个! " + 3); +// news3.setContent(getRandomLengthContent("西安地产裂痕 " + 3 + ". ")); +// newsList.add(news3); +// NewTwos news4 = new NewTwos(); +// news4.setTitle("好几次看到你了~互赞三个互关吧! " + 4); +// news4.setContent(getRandomLengthContent("李先生房必得地产 " + 4 + ". ")); +// newsList.add(news4); +// NewTwos news5 = new NewTwos(); +// news5.setTitle("在吗?互关一下互赞三个吧,我看到你好几次了 " + 5); +// news5.setContent(getRandomLengthContent("小周聊房产 " + 5 + ". ")); +// newsList.add(news5); +// return newsList; + + getletterList(); + + + } + + private void getletterList(){ + final HttpParams paramsPost = new HttpParams(); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_letterList).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + + @Override + public void onNext(Response response) { + String body = (String) response.body(); + letterListBean letterListBean = JsonUtils.fromJson(body, letterListBean.class); + if(letterListBean.getSuccess()==0){ + List data = letterListBean.getData(); + mNewTwos = new ArrayList<>(); + for(int i=0;i { + + private List mNewsList; + + class ViewHolderCotent extends RecyclerView.ViewHolder { + + TextView newsTitleText; + TextView mYueDouXianShi; + RelativeLayout mYueDouLin; + + public ViewHolderCotent(View view) { + super(view); + newsTitleText = (TextView) view.findViewById(R.id.news_title); + mYueDouXianShi = (TextView) view.findViewById(R.id.mYueDouXianShi); + mYueDouLin = view.findViewById(R.id.mYueDouLin); + } + + } + + class ViewHolderBoot extends RecyclerView.ViewHolder { + RelativeLayout rl_bianji; + RecyclerView recycler_view; + public ViewHolderBoot(View view) { + super(view); + rl_bianji = (RelativeLayout) view.findViewById(R.id.rl_bianji); + recycler_view = (RecyclerView) view.findViewById(R.id.recycler_view); + } + } + + class ViewHolderHead extends RecyclerView.ViewHolder { + TextView tv_head_title; + public ViewHolderHead(View view) { + super(view); + tv_head_title = (TextView) view.findViewById(R.id.tv_head_title); + } + } + + public NewsAdapter(List newsList,List newTwos) { + mNewsList = newsList; + mNewTwos = newTwos; + } + + @Override + public int getItemViewType(int position) { + if (position == 0) { // 头部 + return dakaVideoListBean.DataBean.ITEM_TYPE_HEADER; + }if (position == mNewsList.size()+1) { + return dakaVideoListBean.DataBean.ITEM_TYPE_BOTTOM; + } + else { + return dakaVideoListBean.DataBean.ITEM_TYPE_CONTENT; + } + } + + @Override + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + switch (viewType) { + case dakaVideoListBean.DataBean.ITEM_TYPE_HEADER: + final ViewHolderHead holderone = new ViewHolderHead(LayoutInflater.from(parent.getContext()).inflate(R.layout.news_item_head, parent, false)); + return holderone; + case dakaVideoListBean.DataBean.ITEM_TYPE_BOTTOM: + final ViewHolderBoot holdertwo = new ViewHolderBoot(LayoutInflater.from(parent.getContext()).inflate(R.layout.news_content_boot, parent, false)); + return holdertwo; + case dakaVideoListBean.DataBean.ITEM_TYPE_CONTENT: + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.news_content_item, parent, false); + final ViewHolderCotent holder = new ViewHolderCotent(view); + return holder; + default: + } + return null; + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + if (holder instanceof ViewHolderHead) { + ViewHolderHead headHolder = (ViewHolderHead) holder; + headHolder.tv_head_title.setText(title); + } else if (holder instanceof ViewHolderBoot) { + ViewHolderBoot bootHolder = (ViewHolderBoot) holder; + bootHolder.rl_bianji.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + // ToastUtils.showShort("私信话术页面。。。"); + // JumpUtils.gotoActivity(getActivity(), PriLetActivity.class, false, "",""); + JumpUtils.gotoActivity(getActivity(), PriLetEditActivity.class, false, "",""); + getActivity().finish(); + } + }); + + LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); + bootHolder.recycler_view.setLayoutManager(layoutManager); + bootHolder.recycler_view.setAdapter(new BaseQuickAdapter(R.layout.news_content_item, mNewTwos) { + @Override + protected void convert(final BaseViewHolder helper, final NewTwos item) { + WidgetTools.setTextfive((TextView) helper.getView(R.id.news_title), "", item.getTitle()); + } + }); + + } else { + dakaVideoListBean.DataBean news = mNewsList.get(position - 1); + ViewHolderCotent contentHolder = (ViewHolderCotent) holder; + contentHolder.newsTitleText.setText(news.getName()); + } + } + + @Override + public int getItemCount() { + return mNewsList.size() + 2; + } + + } + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/fragment/NewsTitleFragment.java b/app/src/main/java/com/fisherbone/fuzhu/fragment/NewsTitleFragment.java new file mode 100644 index 0000000..f822e17 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/fragment/NewsTitleFragment.java @@ -0,0 +1,299 @@ +package com.fisherbone.fuzhu.fragment; + +import android.graphics.Color; +import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.activity.KeyWordEditActivity; +import com.fisherbone.fuzhu.entity.dakaVideoListBean; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.fisherbone.fuzhu.utils.JsonUtils; +import com.fisherbone.fuzhu.utils.JumpUtils; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import io.reactivex.Flowable; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.Disposable; +import io.reactivex.functions.Action; +import io.reactivex.functions.Consumer; + +public class NewsTitleFragment extends Fragment { + + private boolean isTwoPane; + private RecyclerView newsTitleRecyclerView; + private NewsAdapter adapter; + private List mNewsList; + private Disposable mdDisposable; + private String page_type; + private String title; + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.news_title_frag, container, false); + newsTitleRecyclerView = (RecyclerView) view.findViewById(R.id.news_title_recycler_view); + LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); + newsTitleRecyclerView.setLayoutManager(layoutManager); + Bundle bundle = getArguments(); + //这里就拿到了之前传递的参数 + page_type = bundle.getString("page_type"); + if(page_type.equals("1")){ + title="大咖"; + }else { + title="视频关键词"; + } + + initData(); + return view; + } + + private void initData() { + getdakaVideoList(page_type); + //左边listView集合添加数据,适配器适配 +// mNewsList = getNews(); +// adapter = new NewsAdapter(mNewsList); +// newsTitleRecyclerView.setAdapter(adapter); +// //默认选中ListView第一条item +// //ListView第一条item的Select为true +// // mList.get(0).setSelect(true); +// //listView点击事件 +// taskdaojishi(1); + + + } + private void getdakaVideoList(String page_type){ + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("type", page_type);//1:大咖,2:视频关键词 + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appoperate_dakaVideoList).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + + @Override + public void onNext(Response response) { + String body = (String) response.body(); + dakaVideoListBean dakaVideoListBean = JsonUtils.fromJson(body, com.fisherbone.fuzhu.entity.dakaVideoListBean.class); + if(dakaVideoListBean.getSuccess()==0){ + mNewsList = dakaVideoListBean.getData(); +// mNewsList = new ArrayList<>(); +// if(data!=null&&data.size()>0) { +// for (int i = 0; i < data.size(); i++) { +// News news = new News(); +// news.setTitle(data.get(i).getName()); +// news.setKey(data.get(i).getKey()); +// mNewsList.add(news); +// } +// } + adapter = new NewsAdapter(mNewsList); + newsTitleRecyclerView.setAdapter(adapter); + //默认选中ListView第一条item + //ListView第一条item的Select为true + // mList.get(0).setSelect(true); + //listView点击事件 + taskdaojishi(1); + + + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + /** + * 停任务的倒计时 + * + * @param a + */ + private void taskdaojishi(final int a) { + //启动计时器 + //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 + mdDisposable = Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) + .observeOn(AndroidSchedulers.mainThread()) + .doOnNext(new Consumer() { + @Override + public void accept(Long aLong) throws Exception { + long b = a - aLong; + Log.e("TIAOSHI###", b + ""); + } + }) + .doOnComplete(new Action() { + @Override + public void run() throws Exception { + if(mNewsList.size()>0) { + dakaVideoListBean.DataBean news = mNewsList.get(0); + NewsContentFragment newsContentFragment = (NewsContentFragment) + getFragmentManager().findFragmentById(R.id.news_content_fragment); + newsContentFragment.refresh( news.getKey()); + + for (int i = 0; i < mNewsList.size(); i++) { + mNewsList.get(i).setSelect(false); + } + mNewsList.get(0).setSelect(true); + //在刷新一下适配器就ok + adapter.notifyDataSetChanged(); + } + } + }) + .subscribe(); + } + + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + if (getActivity().findViewById(R.id.news_content_layout) != null) { + isTwoPane = true; // 可以找到news_content_layout布局时,为双页模式 + } else { + isTwoPane = false; // 找不到news_content_layout布局时,为单页模式 + } + } + + + class NewsAdapter extends RecyclerView.Adapter { + + private List mNewsList; + + class ViewHolderCotent extends RecyclerView.ViewHolder { + + TextView newsTitleText; + TextView mYueDouXianShi; + RelativeLayout mYueDouLin; + + public ViewHolderCotent(View view) { + super(view); + newsTitleText = (TextView) view.findViewById(R.id.news_title); + mYueDouXianShi = (TextView) view.findViewById(R.id.mYueDouXianShi); + mYueDouLin = view.findViewById(R.id.mYueDouLin); + } + + } + + class ViewHolderBoot extends RecyclerView.ViewHolder { + RelativeLayout rl_bianji; + public ViewHolderBoot(View view) { + super(view); + rl_bianji = (RelativeLayout) view.findViewById(R.id.rl_bianji); + } + } + + class ViewHolderHead extends RecyclerView.ViewHolder { + TextView tv_head_title; + public ViewHolderHead(View view) { + super(view); + tv_head_title = (TextView) view.findViewById(R.id.tv_head_title); + } + } + + public NewsAdapter(List newsList) { + mNewsList = newsList; + } + + @Override + public int getItemViewType(int position) { + if (position == 0) { // 头部 + return dakaVideoListBean.DataBean.ITEM_TYPE_HEADER; + }if (position == mNewsList.size()+1) { + return dakaVideoListBean.DataBean.ITEM_TYPE_BOTTOM; + } + else { + return dakaVideoListBean.DataBean.ITEM_TYPE_CONTENT; + } + } + + @Override + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + switch (viewType) { + case dakaVideoListBean.DataBean.ITEM_TYPE_HEADER: + final ViewHolderHead holderone = new ViewHolderHead(LayoutInflater.from(parent.getContext()).inflate(R.layout.news_item_head, parent, false)); + return holderone; + case dakaVideoListBean.DataBean.ITEM_TYPE_BOTTOM: + final ViewHolderBoot holdertwo = new ViewHolderBoot(LayoutInflater.from(parent.getContext()).inflate(R.layout.news_boot, parent, false)); + return holdertwo; + case dakaVideoListBean.DataBean.ITEM_TYPE_CONTENT: + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.news_item, parent, false); + final ViewHolderCotent holder = new ViewHolderCotent(view); + return holder; + default: + } + return null; + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + if (holder instanceof ViewHolderHead) { + ViewHolderHead headHolder = (ViewHolderHead) holder; + headHolder.tv_head_title.setText(title); + } else if (holder instanceof ViewHolderBoot) { + ViewHolderBoot bootHolder = (ViewHolderBoot) holder; + bootHolder.rl_bianji.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + // ToastUtils.showShort("进入编辑页面。。。"); + JumpUtils.gotoActivity(getActivity(), KeyWordEditActivity.class, false, "type",page_type); + getActivity().finish(); + } + + }); + } else { + dakaVideoListBean.DataBean news = mNewsList.get(position - 1); + ViewHolderCotent contentHolder = (ViewHolderCotent) holder; + contentHolder.newsTitleText.setText(news.getName()); + + //true和false用来解决复用问题的,如果当前标记为选中状态那么item字体颜色变红,红色竖条显示,item背景色变白 + if (news.isSelect()) { + // holder.mListViewText.setTextColor(Color.RED); + contentHolder.mYueDouXianShi.setVisibility(View.VISIBLE); + contentHolder.mYueDouLin.setBackgroundColor(Color.parseColor("#F8F8F8")); + } + //如果不是选中状态,item字体颜色变黑,红色竖条隐藏,item背景还变灰 + else { + // holder.mListViewText.setTextColor(Color.BLACK); + contentHolder.mYueDouXianShi.setVisibility(View.GONE); + contentHolder.mYueDouLin.setBackgroundColor(Color.parseColor("#FFFFFF")); + } + contentHolder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dakaVideoListBean.DataBean news = mNewsList.get(contentHolder.getAdapterPosition() - 1); + if (isTwoPane) { + NewsContentFragment newsContentFragment = (NewsContentFragment) + getFragmentManager().findFragmentById(R.id.news_content_fragment); + newsContentFragment.refresh(news.getKey()); + } else { + } + + for (int i = 0; i < mNewsList.size(); i++) { + mNewsList.get(i).setSelect(false); + } + mNewsList.get(contentHolder.getAdapterPosition() - 1).setSelect(true); + //在刷新一下适配器就ok + adapter.notifyDataSetChanged(); + } + }); + } + } + + @Override + public int getItemCount() { + return mNewsList.size() + 2; + } + + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/hongbao/CursorRed.java b/app/src/main/java/com/fisherbone/fuzhu/hongbao/CursorRed.java new file mode 100644 index 0000000..5baa811 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/hongbao/CursorRed.java @@ -0,0 +1,28 @@ +package com.fisherbone.fuzhu.hongbao; + +/** + * Time: 2021/7/3 + * Author: jianbo + * Description: + */ + public class CursorRed { + public int curlocation=0; + + + /** + * 获得当前位置 + * @return + */ + private int curLocation(){ + + return curlocation; + } + + /** + * 记录当前位置 + * @return + */ + public void saveCurLoc(int curloc){ + this.curlocation=curloc; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/hongbao/RedEnv.java b/app/src/main/java/com/fisherbone/fuzhu/hongbao/RedEnv.java new file mode 100644 index 0000000..2f10548 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/hongbao/RedEnv.java @@ -0,0 +1,206 @@ +package com.fisherbone.fuzhu.hongbao; + +import com.fisherbone.fuzhu.db.RedenvBeanData; + +import java.util.ArrayList; + +/** + * Time: 2021/6/29 + * Author: jianbo + * Description:抢红包的接口 + */ +public interface RedEnv { + + interface RedEnvFunc { + /** + * 打开抖音 + * @return boolean + */ + boolean openTiktok(); + + /** + * 推荐页刷新进入一个直播间 + * @return boolean + */ + boolean enterLive(); + + /** + * 检测直播的时间是否到达 + * @return boolean + */ + boolean liveTime(); + + /** + * 检测抢的抖币是否到达参数值 + * @return boolean + */ + boolean liveDoubiNum(String doubimun); + + /** + * 直播间的人数判断,不满足条件直接滑走 + * @return boolean + */ + boolean perNumCon(); + + /** + * 监听当前页面有没有红包福袋优惠券控件 + * @return boolean + */ + boolean ifControlView(); + + /** + * 给当前页面中的控件做标签记录,标记当前的名称和位置 + * @return boolean + */ + boolean tagControlView(String str, int position); + + /** + * 判断控件中是否有红包 + * @return boolean + */ + boolean ifRedEnv(); + + /** + * 判断控件中是否有福袋 + * @return boolean + */ + boolean ifFuDai(); + + /** + * 开始抢红包 + * @return boolean + */ + boolean grabRedEnv(); + + /** + * 开始抢福袋 + * @return boolean + */ + boolean grabFuDai(); + + /** + * 当前直播间是否退播 + * @return boolean + */ + boolean ifLiveTuiBo(); + + /** + * 当前抖币数 + * @return boolean + */ + int dangqianDoubi(); + + } + + /** + * 时间位置算法 + */ + interface TimeFunc { + /** + * 记录红包时间 + * @return boolean + * @param data 参数实体类 + * @param RedEnvTime 红包的倒计时 + */ + boolean recRedEnv(RedenvBeanData data, String RedEnvTime); + /** + * 记录福袋时间 + * @return boolean + * @param data 参数实体类 + * @param FuDaiTime 福袋的倒计时 + */ + boolean recFuDai(RedenvBeanData data, String FuDaiTime); + + /** + * 记录直播间的名字 + * @param data 参数实体类 + * @param liveName 直播间的名字 + * @return boolean + */ + boolean recLiveName(RedenvBeanData data, String liveName); + + /** + * 记录当前的直播间的参数(包含直播间的名字,红包的倒计时,福袋的倒计时) + * @param data 参数实体类 + * @return boolean + */ + boolean recZhiBoPar(RedenvBeanData data); + + /** + * 直播间的参数是否记录完成指定个数 + * @param objects 直播间的参数集合 + * @param num 设置的一组直播间的个数参数 + * @return boolean + */ + boolean SatNum(ArrayList objects, int num); + /** + * 初始化直播间的参数 + * 清空参数数据,重新开始记录 + * @return boolean + */ + boolean chuShiZhiBoParmer(); + + /** + * 取关当前主播 + * @return boolean + */ + boolean quGuanZhuBo(); + + /** + * 是否满足取关参数(当前直播间无红包无福袋直播间人数<100) + * @return boolean + */ + boolean ifConQuGuan(); + + /** + * 当前直播间的红包或者福袋的倒计时是否<30s + * @return boolean + */ + boolean ifLessThanTime(); + + + /** + * 当直播列表满足参数的时候,检索直播列表中直播间的红包或者福袋的倒计时<30s的直播间 + * @return boolean + */ + boolean ifContain(); + + + /** + * 检索直播列表中直播间的红包或者福袋的倒计时<30s的直播间,返回它的位置 + * @return boolean + */ + int ContainPostion(); + } + + /** + * 移动算法 + */ + interface MoveFunc { + + //通过时间计算获得那个记录的红包倒计时快到了 + + /** + * 移动到指定直播间 + * @return int + */ + int redEnvPostion(); + + /** + * 移动到指定直播间 + * @param postion 当前直播间的位置 + * @param postiontwo 目标直播间的位置 + * @return boolean + */ + boolean moveZhiBoJian(int postion, int postiontwo); + + /** + * 判断移动到指定直播间是否正确 + * @param objects 直播间的参数集合 + * @param liveName 移动到的直播间的名字 + * @return boolean + */ + boolean ifMoveZhiBo(ArrayList objects, String liveName); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/hook/AppInfoProvider.java b/app/src/main/java/com/fisherbone/fuzhu/hook/AppInfoProvider.java new file mode 100644 index 0000000..a4a16f0 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/hook/AppInfoProvider.java @@ -0,0 +1,95 @@ +package com.fisherbone.fuzhu.hook; + +import android.content.ContentProvider; +import android.content.ContentValues; +import android.content.UriMatcher; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +import android.net.Uri; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + + +/** + * Created by on 2016/5/4 0004. + */ +public class AppInfoProvider extends ContentProvider { + public static final String AUTHRITY = "com.fisherbone.fuzhu.hook.AppInfoProvider"; + public static final Uri APP_CONTENT_URI = Uri.parse("content://" + AUTHRITY + "/app"); + public static final int APP_URI_CODE = 0; + private static final UriMatcher SURI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH); + + static { + SURI_MATCHER.addURI(AUTHRITY, "app", APP_URI_CODE); + } + + private SQLiteDatabase mSQLiteDatabase; + + @Override + public boolean onCreate() { + mSQLiteDatabase = new PxDBHelper(getContext()).getWritableDatabase(); + return true; + } + + @Nullable + @Override + public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { + String table = getTableName(uri); + if (table == null) + throw new IllegalArgumentException("Unsupported URI:" + uri); + return mSQLiteDatabase.query(table, projection, selection, selectionArgs, null, null, sortOrder, null); + } + + @Nullable + @Override + public String getType(@NonNull Uri uri) { + return null; + } + + @Nullable + @Override + public Uri insert(@NonNull Uri uri, ContentValues values) { + String table = getTableName(uri); + if (table == null) + throw new IllegalArgumentException("Unsupported URI:" + uri); + mSQLiteDatabase.insert(table, null, values); + getContext().getContentResolver().notifyChange(uri, null); + return uri; + } + + @Override + public int delete(@NonNull Uri uri, String selection, String[] selectionArgs) { + String table = getTableName(uri); + if (table == null) + throw new IllegalArgumentException("Unsupported URI:" + uri); + int count = mSQLiteDatabase.delete(table, selection, selectionArgs); + if (count > 0) { + getContext().getContentResolver().notifyChange(uri, null); + } + return count; + } + + @Override + public int update(@NonNull Uri uri, ContentValues values, String selection, String[] selectionArgs) { + String table = getTableName(uri); + if (table == null) + throw new IllegalArgumentException("Unsupported URI:" + uri); + int row = mSQLiteDatabase.update(table, values, selection, selectionArgs); + if (row > 0) { + getContext().getContentResolver().notifyChange(uri, null); + } + return row; + } + + private String getTableName(Uri uri) { + String tableName = null; + switch (SURI_MATCHER.match(uri)) { + case APP_URI_CODE: + tableName = PxDBHelper.APP_TABLE_NAME; + break; + default: + } + return tableName; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/hook/HookUtils.java b/app/src/main/java/com/fisherbone/fuzhu/hook/HookUtils.java new file mode 100644 index 0000000..7e8ad14 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/hook/HookUtils.java @@ -0,0 +1,476 @@ +package com.fisherbone.fuzhu.hook; + +import android.location.Criteria; +import android.location.GpsStatus; +import android.location.Location; +import android.location.LocationListener; +import android.location.LocationManager; +import android.os.Build; +import android.os.SystemClock; +import android.telephony.CellIdentityCdma; +import android.telephony.CellIdentityGsm; +import android.telephony.CellIdentityLte; +import android.telephony.CellIdentityWcdma; +import android.telephony.CellInfoCdma; +import android.telephony.CellInfoGsm; +import android.telephony.CellInfoLte; +import android.telephony.CellInfoWcdma; +import android.telephony.CellLocation; +import android.telephony.gsm.GsmCellLocation; + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.List; + +import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.XposedBridge; +import de.robv.android.xposed.XposedHelpers; + + +class HookUtils { + + static void HookAndChange(ClassLoader classLoader, final double latitude, final double longtitude, final int mnc, final int lac, final int cid) { + +// XposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", classLoader, +// "getNetworkOperatorName", new XC_MethodHook() { +// @Override +// protected void afterHookedMethod(MethodHookParam param) throws Throwable { +// param.setResult(""); +// } +// }); +// +// XposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", classLoader, +// "getNetworkOperator", new XC_MethodHook() { +// @Override +// protected void afterHookedMethod(MethodHookParam param) throws Throwable { +// param.setResult(""); +// } +// }); +// +// XposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", classLoader, +// "getSimOperatorName", new XC_MethodHook() { +// @Override +// protected void afterHookedMethod(MethodHookParam param) throws Throwable { +// param.setResult(""); +// } +// }); +// +// XposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", classLoader, +// "getSimOperator", new XC_MethodHook() { +// @Override +// protected void afterHookedMethod(MethodHookParam param) throws Throwable { +// param.setResult(null); +// } +// }); +// +// XposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", classLoader, +// "getSimCountryIso", new XC_MethodHook() { +// @Override +// protected void afterHookedMethod(MethodHookParam param) throws Throwable { +// param.setResult(""); +// } +// }); +// +// XposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", classLoader, +// "getNetworkCountryIso", new XC_MethodHook() { +// @Override +// protected void afterHookedMethod(MethodHookParam param) throws Throwable { +// param.setResult(""); +// } +// }); +// XposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", classLoader, +// "getNetworkType", new XC_MethodHook() { +// @Override +// protected void afterHookedMethod(MethodHookParam param) throws Throwable { +// param.setResult(TelephonyManager.NETWORK_TYPE_UNKNOWN); +// } +// }); +// +// XposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", classLoader, +// "getPhoneType", new XC_MethodHook() { +// @Override +// protected void afterHookedMethod(MethodHookParam param) throws Throwable { +// param.setResult(TelephonyManager.PHONE_TYPE_NONE); +// } +// }); +// +// XposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", classLoader, +// "getCurrentPhoneType", new XC_MethodHook() { +// @Override +// protected void afterHookedMethod(MethodHookParam param) throws Throwable { +// param.setResult(0); +// } +// }); +// +// XposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", classLoader, +// "getDataState", new XC_MethodHook() { +// @Override +// protected void afterHookedMethod(MethodHookParam param) throws Throwable { +// param.setResult(TelephonyManager.DATA_DISCONNECTED); +// } +// }); +// +// XposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", classLoader, +// "getSimState", new XC_MethodHook() { +// @Override +// protected void afterHookedMethod(MethodHookParam param) throws Throwable { +// param.setResult(TelephonyManager.SIM_STATE_UNKNOWN); +// } +// }); + //ceshi + XposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", classLoader, + "getCellLocation", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + GsmCellLocation gsmCellLocation = new GsmCellLocation(); + gsmCellLocation.setLacAndCid(lac, cid); + param.setResult(gsmCellLocation); + } + }); + + XposedHelpers.findAndHookMethod("android.telephony.PhoneStateListener", classLoader, + "onCellLocationChanged", CellLocation.class, new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + GsmCellLocation gsmCellLocation = new GsmCellLocation(); + gsmCellLocation.setLacAndCid(lac, cid); + param.setResult(gsmCellLocation); + } + }); + + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { + XposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", classLoader, + "getPhoneCount", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + param.setResult(1); + } + }); + } + + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { + XposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", classLoader, + "getNeighboringCellInfo", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + param.setResult(new ArrayList<>()); + } + }); + } + + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) { + XposedHelpers.findAndHookMethod("android.telephony.TelephonyManager", classLoader, + "getAllCellInfo", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + param.setResult(getCell(460, mnc, lac, cid, 0, 0)); + } + }); + XposedHelpers.findAndHookMethod("android.telephony.PhoneStateListener", classLoader, + "onCellInfoChanged", List.class, new XC_MethodHook() { + @Override + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + param.setResult(getCell(460, mnc, lac, cid, 0, 0)); + } + }); + } + + XposedHelpers.findAndHookMethod("android.net.wifi.WifiManager", classLoader, "getScanResults", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + param.setResult(new ArrayList<>()); + } + }); + + XposedHelpers.findAndHookMethod("android.net.wifi.WifiManager", classLoader, "getWifiState", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + param.setResult(1); + } + }); + + XposedHelpers.findAndHookMethod("android.net.wifi.WifiManager", classLoader, "isWifiEnabled", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + param.setResult(true); + } + }); + + XposedHelpers.findAndHookMethod("android.net.wifi.WifiInfo", classLoader, "getMacAddress", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + param.setResult("00-00-00-00-00-00-00-00"); + } + }); + + XposedHelpers.findAndHookMethod("android.net.wifi.WifiInfo", classLoader, "getSSID", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + param.setResult("null"); + } + }); + + XposedHelpers.findAndHookMethod("android.net.wifi.WifiInfo", classLoader, "getBSSID", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + param.setResult("00-00-00-00-00-00-00-00"); + } + }); + + + XposedHelpers.findAndHookMethod("android.net.NetworkInfo", classLoader, + "getTypeName", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + param.setResult("WIFI"); + } + }); + XposedHelpers.findAndHookMethod("android.net.NetworkInfo", classLoader, + "isConnectedOrConnecting", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + param.setResult(true); + } + }); + + XposedHelpers.findAndHookMethod("android.net.NetworkInfo", classLoader, + "isConnected", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + param.setResult(true); + } + }); + + XposedHelpers.findAndHookMethod("android.net.NetworkInfo", classLoader, + "isAvailable", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + param.setResult(true); + } + }); + + XposedHelpers.findAndHookMethod("android.telephony.CellInfo", classLoader, + "isRegistered", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + param.setResult(true); + } + }); + + XposedHelpers.findAndHookMethod(LocationManager.class, "getLastLocation", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + Location l = new Location(LocationManager.GPS_PROVIDER); + l.setLatitude(latitude); + l.setLongitude(longtitude); + l.setAccuracy(100f); + l.setTime(System.currentTimeMillis()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + l.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); + } + param.setResult(l); + } + }); + + XposedHelpers.findAndHookMethod(LocationManager.class, "getLastKnownLocation", String.class, new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + Location l = new Location(LocationManager.GPS_PROVIDER); + l.setLatitude(latitude); + l.setLongitude(longtitude); + l.setAccuracy(100f); + l.setTime(System.currentTimeMillis()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + l.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); + } + param.setResult(l); + } + }); + + + XposedBridge.hookAllMethods(LocationManager.class, "getProviders", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + ArrayList arrayList = new ArrayList<>(); + arrayList.add("gps"); + param.setResult(arrayList); + } + }); + + XposedHelpers.findAndHookMethod(LocationManager.class, "getBestProvider", Criteria.class, Boolean.TYPE, new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + param.setResult("gps"); + } + }); + + XposedHelpers.findAndHookMethod(LocationManager.class, "addGpsStatusListener", GpsStatus.Listener.class, new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + if (param.args[0] != null) { + XposedHelpers.callMethod(param.args[0], "onGpsStatusChanged", 1); + XposedHelpers.callMethod(param.args[0], "onGpsStatusChanged", 3); + } + } + }); + + XposedHelpers.findAndHookMethod(LocationManager.class, "addNmeaListener", GpsStatus.NmeaListener.class, new XC_MethodHook() { + @Override + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + param.setResult(false); + } + }); + + XposedHelpers.findAndHookMethod("android.location.LocationManager", classLoader, + "getGpsStatus", GpsStatus.class, new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + GpsStatus gss = (GpsStatus) param.getResult(); + if (gss == null) + return; + + Class clazz = GpsStatus.class; + Method m = null; + for (Method method : clazz.getDeclaredMethods()) { + if (method.getName().equals("setStatus")) { + if (method.getParameterTypes().length > 1) { + m = method; + break; + } + } + } + if (m == null) + return; + + //access the private setStatus function of GpsStatus + m.setAccessible(true); + + //make the apps belive GPS works fine now + int svCount = 5; + int[] prns = {1, 2, 3, 4, 5}; + float[] snrs = {0, 0, 0, 0, 0}; + float[] elevations = {0, 0, 0, 0, 0}; + float[] azimuths = {0, 0, 0, 0, 0}; + int ephemerisMask = 0x1f; + int almanacMask = 0x1f; + + //5 satellites are fixed + int usedInFixMask = 0x1f; + + XposedHelpers.callMethod(gss, "setStatus", svCount, prns, snrs, elevations, azimuths, ephemerisMask, almanacMask, usedInFixMask); + param.args[0] = gss; + param.setResult(gss); + try { + m.invoke(gss, svCount, prns, snrs, elevations, azimuths, ephemerisMask, almanacMask, usedInFixMask); + param.setResult(gss); + } catch (Exception e) { + XposedBridge.log(e); + } + } + }); + + for (Method method : LocationManager.class.getDeclaredMethods()) { + if (method.getName().equals("requestLocationUpdates") + && !Modifier.isAbstract(method.getModifiers()) + && Modifier.isPublic(method.getModifiers())) { + XposedBridge.hookMethod(method, new XC_MethodHook() { + @Override + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + if (param.args.length >= 4 && (param.args[3] instanceof LocationListener)) { + + LocationListener ll = (LocationListener) param.args[3]; + + Class clazz = LocationListener.class; + Method m = null; + for (Method method : clazz.getDeclaredMethods()) { + if (method.getName().equals("onLocationChanged") && !Modifier.isAbstract(method.getModifiers())) { + m = method; + break; + } + } + Location l = new Location(LocationManager.GPS_PROVIDER); + l.setLatitude(latitude); + l.setLongitude(longtitude); + l.setAccuracy(10.00f); + l.setTime(System.currentTimeMillis()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + l.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); + } + XposedHelpers.callMethod(ll, "onLocationChanged", l); + try { + if (m != null) { + m.invoke(ll, l); + } + } catch (Exception e) { + XposedBridge.log(e); + } + } + } + }); + } + + if (method.getName().equals("requestSingleUpdate ") + && !Modifier.isAbstract(method.getModifiers()) + && Modifier.isPublic(method.getModifiers())) { + XposedBridge.hookMethod(method, new XC_MethodHook() { + @Override + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + if (param.args.length >= 3 && (param.args[1] instanceof LocationListener)) { + + LocationListener ll = (LocationListener) param.args[3]; + + Class clazz = LocationListener.class; + Method m = null; + for (Method method : clazz.getDeclaredMethods()) { + if (method.getName().equals("onLocationChanged") && !Modifier.isAbstract(method.getModifiers())) { + m = method; + break; + } + } + + try { + if (m != null) { + Location l = new Location(LocationManager.GPS_PROVIDER); + l.setLatitude(latitude); + l.setLongitude(longtitude); + l.setAccuracy(100f); + l.setTime(System.currentTimeMillis()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + l.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); + } + m.invoke(ll, l); + } + } catch (Exception e) { + XposedBridge.log(e); + } + } + } + }); + } + } + } + + private static ArrayList getCell(int mcc, int mnc, int lac, int cid, int sid, int networkType) { + ArrayList arrayList = new ArrayList(); + CellInfoGsm cellInfoGsm = (CellInfoGsm) XposedHelpers.newInstance(CellInfoGsm.class); + XposedHelpers.callMethod(cellInfoGsm, "setCellIdentity", XposedHelpers.newInstance(CellIdentityGsm.class, new Object[]{Integer.valueOf(mcc), Integer.valueOf(mnc), Integer.valueOf( + lac), Integer.valueOf(cid)})); + CellInfoCdma cellInfoCdma = (CellInfoCdma) XposedHelpers.newInstance(CellInfoCdma.class); + XposedHelpers.callMethod(cellInfoCdma, "setCellIdentity", XposedHelpers.newInstance(CellIdentityCdma.class, new Object[]{Integer.valueOf(lac), Integer.valueOf(sid), Integer.valueOf(cid), Integer.valueOf(0), Integer.valueOf(0)})); + CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) XposedHelpers.newInstance(CellInfoWcdma.class); + XposedHelpers.callMethod(cellInfoWcdma, "setCellIdentity", XposedHelpers.newInstance(CellIdentityWcdma.class, new Object[]{Integer.valueOf(mcc), Integer.valueOf(mnc), Integer.valueOf(lac), Integer.valueOf(cid), Integer.valueOf(300)})); + CellInfoLte cellInfoLte = (CellInfoLte) XposedHelpers.newInstance(CellInfoLte.class); + XposedHelpers.callMethod(cellInfoLte, "setCellIdentity", XposedHelpers.newInstance(CellIdentityLte.class, new Object[]{Integer.valueOf(mcc), Integer.valueOf(mnc), Integer.valueOf(cid), Integer.valueOf(300), Integer.valueOf(lac)})); + if (networkType == 1 || networkType == 2) { + arrayList.add(cellInfoGsm); + } else if (networkType == 13) { + arrayList.add(cellInfoLte); + } else if (networkType == 4 || networkType == 5 || networkType == 6 || networkType == 7 || networkType == 12 || networkType == 14) { + arrayList.add(cellInfoCdma); + } else if (networkType == 3 || networkType == 8 || networkType == 9 || networkType == 10 || networkType == 15) { + arrayList.add(cellInfoWcdma); + } + return arrayList; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/hook/MainHook.java b/app/src/main/java/com/fisherbone/fuzhu/hook/MainHook.java new file mode 100644 index 0000000..f80e133 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/hook/MainHook.java @@ -0,0 +1,35 @@ +package com.fisherbone.fuzhu.hook; + +import android.content.Context; +import android.database.Cursor; +import android.net.Uri; + +import java.util.Random; + +import de.robv.android.xposed.IXposedHookLoadPackage; +import de.robv.android.xposed.XposedBridge; +import de.robv.android.xposed.XposedHelpers; +import de.robv.android.xposed.callbacks.XC_LoadPackage; + + +public class MainHook implements IXposedHookLoadPackage { + + @Override + public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { + final Object activityThread = XposedHelpers.callStaticMethod(XposedHelpers.findClass("android.app.ActivityThread", null), "currentActivityThread"); + final Context systemContext = (Context) XposedHelpers.callMethod(activityThread, "getSystemContext");//系统类 + Uri uri = Uri.parse("content://com.fisherbone.fuzhu.hook.AppInfoProvider/app");//指向本地数据库下 + Cursor cursor = systemContext.getContentResolver().query(uri, new String[]{"latitude", "longitude", "mnc", "lac", "cid"}, "package_name=?", new String[]{loadPackageParam.packageName}, null); + if (cursor != null && cursor.moveToNext()) { + //41019, 18511 + double latitude = cursor.getDouble(cursor.getColumnIndex("latitude")) + (double) new Random().nextInt(100) / 1000000 + ((double) new Random().nextInt(99999999)) / 100000000000000d; + double longitude = cursor.getDouble(cursor.getColumnIndex("longitude")) + (double) new Random().nextInt(100) / 1000000 + ((double) new Random().nextInt(99999999)) / 100000000000000d; + int lac = cursor.getInt(cursor.getColumnIndex("lac")); + int cid = cursor.getInt(cursor.getColumnIndex("cid")); + int mnc = cursor.getInt(cursor.getColumnIndex("mnc")); + XposedBridge.log("模拟位置:" + loadPackageParam.packageName + "," + latitude + "," + longitude + "," + lac + "," + cid + "," + mnc); + HookUtils.HookAndChange(loadPackageParam.classLoader, latitude, longitude, mnc, lac, cid); + cursor.close(); + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/hook/PxDBHelper.java b/app/src/main/java/com/fisherbone/fuzhu/hook/PxDBHelper.java new file mode 100644 index 0000000..bb8bbc1 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/hook/PxDBHelper.java @@ -0,0 +1,33 @@ +package com.fisherbone.fuzhu.hook; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; + +/** + * 模拟定位数据库 + */ +public class PxDBHelper extends SQLiteOpenHelper { + + private final static String DB_NAME = "applist.db"; + public final static String APP_TABLE_NAME = "app"; + private final static int DB_VERSION = 2; + + public PxDBHelper(Context context) { + super(context, DB_NAME, null, DB_VERSION); + } + + @Override + public void onCreate(SQLiteDatabase db) { + String CREATE_APP_TABLE = "CREATE TABLE IF NOT EXISTS " + APP_TABLE_NAME + "(package_name TEXT PRIMARY KEY," + "latitude DOUBLE,longitude DOUBLE,mnc Integer,lac Integer,cid Integer)"; + db.execSQL(CREATE_APP_TABLE); + } + + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + String DROP_TEMP_SUBSCRIBE = "drop table if exists app"; + db.execSQL(DROP_TEMP_SUBSCRIBE); + String CREATE_APP_TABLE = "CREATE TABLE IF NOT EXISTS " + APP_TABLE_NAME + "(package_name TEXT PRIMARY KEY," + "latitude DOUBLE,longitude DOUBLE,mnc Integer,lac Integer,cid Integer)"; + db.execSQL(CREATE_APP_TABLE); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/lunxun/GetRequest_Interface.java b/app/src/main/java/com/fisherbone/fuzhu/lunxun/GetRequest_Interface.java new file mode 100644 index 0000000..b3de618 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/lunxun/GetRequest_Interface.java @@ -0,0 +1,20 @@ +package com.fisherbone.fuzhu.lunxun; + +import io.reactivex.Observable; +import retrofit2.http.GET; + + +/** + * Created by Carson_Ho on 17/9/8. + */ + +public interface GetRequest_Interface { + + @GET("ajax.php?a=fy&f=auto&t=auto&w=hi%20world") + Observable getCall(); + // 注解里传入 网络请求 的部分URL地址 + // Retrofit把网络请求的URL分成了两部分:一部分放在Retrofit对象里,另一部分放在网络请求接口里 + // 如果接口里的url是一个完整的网址,那么放在Retrofit对象里的URL可以忽略 + // 采用Observable<...>接口 + // getCall()是接受网络请求数据的方法 +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/lunxun/Translation.java b/app/src/main/java/com/fisherbone/fuzhu/lunxun/Translation.java new file mode 100644 index 0000000..193024d --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/lunxun/Translation.java @@ -0,0 +1,27 @@ +package com.fisherbone.fuzhu.lunxun; + +import android.util.Log; + +/** + * Created by Carson_Ho on 17/9/8. + */ + +public class Translation { + + + private int status; + + private content content; + private static class content { + private String from; + private String to; + private String vendor; + private String out; + private int errNo; + } + + //定义 输出返回数据 的方法 + public void show() { + Log.d("RxJava", content.out ); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/okgonet/Func1.java b/app/src/main/java/com/fisherbone/fuzhu/okgonet/Func1.java new file mode 100644 index 0000000..3329b37 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/okgonet/Func1.java @@ -0,0 +1,15 @@ +package com.fisherbone.fuzhu.okgonet; + +/** + * ================================================ + * 作 者:jeasonlzy(廖子尧)Github地址:https://github.com/jeasonlzy + * 版 本:1.0 + * 创建日期:2017/2/6 + * 描 述: + * 修订历史: + * ================================================ + */ +public interface Func1 { + //把一个结果转为我们需要的一个结果 + R call(T t); +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/okgonet/HttpConstants.java b/app/src/main/java/com/fisherbone/fuzhu/okgonet/HttpConstants.java new file mode 100644 index 0000000..713c231 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/okgonet/HttpConstants.java @@ -0,0 +1,208 @@ +package com.fisherbone.fuzhu.okgonet; + +import com.fisherbone.fuzhu.BuildConfig; + +/** + * 项目名:JiaJieSong + * 包名:com.fanghoo.jiajiesong.http + * 文件名:HttpConstants + * 创建者:任剑波 + * 创建时间:2017/10/22 0022 23:05 + * 描述:所有请求相关地址 + */ +public class HttpConstants { + + // public static String URiBase = "http://192.168.1.3";// ATOM本地地址 + //public static String URiBase = "http://139.186.151.48";// ATOM线上地址 + + // public static String URiBase = BuildConfig.release;// ATOM线上地址 + public static String URiBase = BuildConfig.debug;// ATOM线上地址 + + + + /** + * 扫码提交信息 + */ + public static String URi_device_Appscanlogin_scanInfo = URiBase + "/app/Appscanlogin/scanInfo"; + + /** + * 添加客户和完善信息 + */ + public static String URi_device_AppCustomer_addCustomer = URiBase + "/device/AppCustomer/addCustomer"; + + + /** + * 每5s定时请求的紧急任务 + */ + public static String URi_device_Appscanlogin_urgentTask = URiBase + "/app/Appscanlogin/urgentTask"; + + /** + * 设备控制状态 -- 云端还是本地 + */ + public static String URi_device_Appoperate_controlStatus = URiBase + "/app/Appoperate/controlStatus"; + + + /** + * 修改控制状态 -- 云端还是本地 + */ + public static String URi_device_Appoperate_updateControlStatus = URiBase + "/app/Appoperate/updateControlStatus"; + + /** + * app每执行完一个任务成功后调取接口 + */ + public static String URi_device_Appscanlogin_FinishTask = URiBase + "/app/Appscanlogin/FinishTask"; + + /** + * app拿到任务调用接口 + */ + public static String URi_device_Appscanlogin_updateTaskStatus = URiBase + "/app/Appscanlogin/updateTaskStatus"; + + /** + * 固定任务(当前任务执行完请求下一个任务接口) + */ + public static String URi_device_Appscanlogin_fixedTask = URiBase + "/app/Appscanlogin/fixedTask"; + + /** + * 获取撞号账号 + */ + public static String URi_device_Appscanlogin_touchTask = URiBase + "/app/Appscanlogin/touchTask"; + + /** + * 2、获取到账号登录紧急任务,需要用户发送验证码或短信 -- 阿童木调取蜂狐接口 + */ + public static String URi_device_Appscanlogin_sendCode = URiBase + "/app/Appscanlogin/sendCode"; + + /** + * app获取验证短信或验证码 + */ + public static String URi_device_Appscanlogin_getCode = URiBase + "/app/Appscanlogin/getCode"; + + /** + * 4、账号登录结果 -- 阿童木调蜂狐接口 + */ + public static String URi_device_Appscanlogin_loginResult = URiBase + "/app/Appscanlogin/loginResult"; + + /** + * 撞号返回结果 接口描述:success=0,表示撞号继续,同时返回需要请求的数量,去获取撞号账号去请求数据 + * success=-2,表示撞号结束,可以去请求其他任务 + */ + public static String URi_device_Appscanlogin_touchResult = URiBase + "/app/Appscanlogin/touchResult"; + + /** + * 6、再次发送验证码结果 -- 阿童木调取蜂狐接口 + */ + public static String URi_device_Appscanlogin_againLoginResult = URiBase + "/app/Appscanlogin/againLoginResult"; + + /** + * 7、设备是否注册 + */ + public static String URi_device_Appoperate_checkDevice = URiBase + "/app/Appoperate/checkDevice"; + + /** + * 8.抖音加粉托管账号每日数据统计 + */ + public static String URi_device_Appscanlogin_fasStatistics = URiBase + "/app/Appscanlogin/fasStatistics"; + /** + * 9.阿童木获取刷到的客户基本信息 + */ + public static String URi_device_Appoperate_getAtomBrushCus = URiBase + "/app/Appoperate/getAtomBrushCus"; + + /** + * 10.获取当前版本号 + */ + public static String URi_Device_Appoperate_NowVersion = URiBase + "/app/Appoperate/NowVersion"; + + /** + * 11.托管账号异常 + */ + public static String URi_Device_Appscanlogin_UpdateTuoguan = URiBase + "/app/Appscanlogin/UpdateTuoguan"; + + /** + * 12.大咖/视频关键词与最大关注数 + */ + public static String URi_Device_Appoperate_dakaVideoNumber = URiBase + "/app/Appoperate/dakaVideoNumber"; + + /** + * 13.新建大咖/视频关键词 + */ + public static String URi_Device_Appoperate_addDakaVideo = URiBase + "/app/Appoperate/addDakaVideo"; + + /** + * 14.大咖/视频关键词列表 + */ + public static String URi_Device_Appoperate_dakaVideoList = URiBase + "/app/Appoperate/dakaVideoList"; + + /** + * 15.话术列表 + */ + public static String URi_Device_Appoperate_letterList = URiBase + "/app/Appoperate/letterList"; + + /** + * 15.新建话术 + */ + public static String URi_Device_Appoperate_addLetter = URiBase + "/app/Appoperate/addLetter"; + + /** + * 15.删除话术 + */ + public static String URi_Device_Appoperate_deleteLetter = URiBase + "/app/Appoperate/deleteLetter"; + /** + * 16. 修改最大关注数 + */ + public static String URi_Device_Appoperate_updFollow = URiBase + "/app/Appoperate/updFollow"; + /** + * 17. 删除大咖、关键词、评论关键词 + */ + public static String URi_Device_Appoperate_delete = URiBase + "/app/Appoperate/delete"; + + /** + * 18. 复制关键词选择大咖或视频关键词 + */ + public static String URi_Device_Appoperate_dakaVideo = URiBase + "/app/Appoperate/dakaVideo"; + + /** + * 19. 确认复制关键词 + */ + public static String URi_Device_Appoperate_sureCopy = URiBase + "/app/Appoperate/sureCopy"; + + /** + * 20. 执行完大咖/视频关键词修改状态 + */ + public static String URi_Device_Appoperate_updatType = URiBase + "/app/Appoperate/updatType"; + + /** + * 21. 大咖或视频关键词恢复执行之前状态 + */ + public static String URi_Device_Appoperate_renewType = URiBase + "/app/Appoperate/renewType"; + /** + * 22. 获取直播间数据 + */ + public static String URi_Device_Appoperate_LiveRoom = URiBase + "/app/Appoperate/LiveRoom"; + + /** + * 23. 直播间话术 + */ + public static String URi_Device_Appoperate_liveScript = URiBase + "/app/Appscanlogin/liveScript"; + + /** + * 24. 获取电话号码 + */ + public static String URi_Device_Appoperate_getPhone = URiBase + "/app/Appoperate/getPhone"; + + /** + * 25. 设备执行中断,需通知后台重新启动 + */ + public static String URi_Device_Appscanlogin_againStart = URiBase + "/app/Appscanlogin/againStart"; + + /** + * 26. 直播间抢抖币任务、或 直播间加热任务执行完毕后,调取的接口,统计抖币 + */ + public static String URi_Device_Appscanlogin_taskDbTj = URiBase + "/app/Appscanlogin/taskDbTj"; + + /** + * 27. 注销帐号 + */ + public static String URi_Device_Appscanlogin_cancellationDevice = URiBase + "/app/Appscanlogin/cancellationDevice"; +} + + diff --git a/app/src/main/java/com/fisherbone/fuzhu/okgonet/NetApi.java b/app/src/main/java/com/fisherbone/fuzhu/okgonet/NetApi.java new file mode 100644 index 0000000..7efd9d8 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/okgonet/NetApi.java @@ -0,0 +1,98 @@ +package com.fisherbone.fuzhu.okgonet; + + +import com.lzy.okgo.OkGo; +import com.lzy.okgo.cache.CacheMode; +import com.lzy.okgo.convert.StringConvert; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; +import com.lzy.okrx2.adapter.ObservableResponse; + +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.annotations.NonNull; +import io.reactivex.disposables.Disposable; +import io.reactivex.schedulers.Schedulers; + +public class NetApi { + + /** + * @description 简单的封装OkGo + */ + public Observable getPostData(final HttpParams paramsPost, final String uri) { + return new Observable() { + @Override + public void subscribe(final Observer observer) { + OkGo.post(uri) + .params(paramsPost) + .converter(new StringConvert())// + .cacheMode(CacheMode.NO_CACHE) //无缓存模式 CacheMode.NO_CACHE + .adapt(new ObservableResponse())// + .subscribeOn(Schedulers.io())// + .observeOn(AndroidSchedulers.mainThread())// + .subscribe(new io.reactivex.Observer>() { + + @Override + public void onSubscribe(@NonNull Disposable d) { + // addDisposable(d); + } + + @Override + public void onNext(@NonNull Response response) { + observer.onNext(response); + } + + @Override + public void onError(@NonNull Throwable e) { + e.printStackTrace(); + + } + + @Override + public void onComplete() { + + } + }); + } + }; + + } + + public Observable getPostDatatwo(final HttpParams paramsPost, final String uri) { + return new Observable() { + @Override + public void subscribe(final Observer observer) { + OkGo.get(uri) + .params(paramsPost) + .converter(new StringConvert())// + .cacheMode(CacheMode.NO_CACHE) //无缓存模式 CacheMode.NO_CACHE + .adapt(new ObservableResponse())// + .subscribeOn(Schedulers.io())// + .observeOn(AndroidSchedulers.mainThread())// + .subscribe(new io.reactivex.Observer>() { + + @Override + public void onSubscribe(@NonNull Disposable d) { + // addDisposable(d); + } + + @Override + public void onNext(@NonNull Response response) { + observer.onNext(response); + } + + @Override + public void onError(@NonNull Throwable e) { + e.printStackTrace(); + + } + + @Override + public void onComplete() { + + } + }); + } + }; + + } + } \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/okgonet/Observable.java b/app/src/main/java/com/fisherbone/fuzhu/okgonet/Observable.java new file mode 100644 index 0000000..56e5699 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/okgonet/Observable.java @@ -0,0 +1,59 @@ +package com.fisherbone.fuzhu.okgonet; + + +//定义一个动作 +public abstract class Observable { + public abstract void subscribe(Observer observer); + + public Observable map(final Func1 func1){ + final Observable source=this; + return new Observable() { + @Override + public void subscribe(final Observer observer) { + source.subscribe(new Observer() { + @Override + public void onNext(T t) { + R r=func1.call(t); + observer.onNext(r); + } + + @Override + public void onError(Exception e) { + observer.onError(e); + } + }); + } + }; + } + + public Observable flatMap(final Func1> func1) { + final Observable source=this; + return new Observable() { + @Override + public void subscribe(final Observer observer) { + source.subscribe(new Observer() { + @Override + public void onNext(T t) { + final Observable call = func1.call(t); + call.subscribe(new Observer() { + @Override + public void onNext(R r) { + observer.onNext(r); + } + + @Override + public void onError(Exception e) { + observer.onError(e); + } + }); + } + + @Override + public void onError(Exception e) { + + } + }); + } + }; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/okgonet/Observer.java b/app/src/main/java/com/fisherbone/fuzhu/okgonet/Observer.java new file mode 100644 index 0000000..ca02a22 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/okgonet/Observer.java @@ -0,0 +1,6 @@ +package com.fisherbone.fuzhu.okgonet; + +public interface Observer { + void onNext(T t); + void onError(Exception e); +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/reflect/EventType.java b/app/src/main/java/com/fisherbone/fuzhu/reflect/EventType.java new file mode 100644 index 0000000..1783499 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/reflect/EventType.java @@ -0,0 +1,15 @@ +package com.fisherbone.fuzhu.reflect; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.ANNOTATION_TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface EventType { + Class listenerType(); + + String listenerSetter(); + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/reflect/InjectUtils.java b/app/src/main/java/com/fisherbone/fuzhu/reflect/InjectUtils.java new file mode 100644 index 0000000..1093aae --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/reflect/InjectUtils.java @@ -0,0 +1,82 @@ +package com.fisherbone.fuzhu.reflect; + +import android.app.Activity; +import android.view.View; + +import java.lang.annotation.Annotation; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; + +public class InjectUtils { + + + public static void injectEvent(Activity activity) { + Class activityClass = activity.getClass(); + Method[] declaredMethods = activityClass.getDeclaredMethods(); + + + for (Method method : declaredMethods) { + //获得方法上所有注解 + Annotation[] annotations = method.getAnnotations(); + + for (Annotation annotation : annotations) { + //注解类型 + Class annotationType = annotation.annotationType(); + if (annotationType.isAnnotationPresent(EventType.class)) { + EventType eventType = annotationType.getAnnotation(EventType.class); + // OnClickListener.class + Class listenerType = eventType.listenerType(); + //setOnClickListener + String listenerSetter = eventType.listenerSetter(); + + try { + // 不需要关心到底是OnClick 还是 OnLongClick + Method valueMethod = annotationType.getDeclaredMethod("value"); + int[] viewIds = (int[]) valueMethod.invoke(annotation); + + method.setAccessible(true); + ListenerInvocationHandler handler = new ListenerInvocationHandler(activity, method); + Object listenerProxy = Proxy.newProxyInstance(listenerType.getClassLoader(), + new Class[]{listenerType}, handler); + // 遍历注解的值 + for (int viewId : viewIds) { + // 获得当前activity的view(赋值) + View view = activity.findViewById(viewId); + // 获取指定的方法(不需要判断是Click还是LongClick) + // 如获得:setOnClickLisnter方法,参数为OnClickListener + // 获得 setOnLongClickLisnter,则参数为OnLongClickLisnter + Method setter = view.getClass().getMethod(listenerSetter, listenerType); + // 执行方法 + setter.invoke(view, listenerProxy); //执行setOnclickListener里面的回调 onclick方法 + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + } + } + + /** + * 还可能在自定义view注入,所以是泛型: T = Activity/View + * + * @param + */ + static class ListenerInvocationHandler implements InvocationHandler { + + private Method method; + private T target; + + public ListenerInvocationHandler(T target, Method method) { + this.target = target; + this.method = method; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + return this.method.invoke(target, args); + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/reflect/OnClickk.java b/app/src/main/java/com/fisherbone/fuzhu/reflect/OnClickk.java new file mode 100644 index 0000000..e7410f6 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/reflect/OnClickk.java @@ -0,0 +1,15 @@ +package com.fisherbone.fuzhu.reflect; + +import android.view.View; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@EventType(listenerType = View.OnClickListener.class, listenerSetter = "setOnClickListener") +public @interface OnClickk { + int[] value(); +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/reflect/OnLongClick.java b/app/src/main/java/com/fisherbone/fuzhu/reflect/OnLongClick.java new file mode 100644 index 0000000..a420918 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/reflect/OnLongClick.java @@ -0,0 +1,15 @@ +package com.fisherbone.fuzhu.reflect; + +import android.view.View; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@EventType(listenerType = View.OnLongClickListener.class, listenerSetter = "setOnLongClickListener") +public @interface OnLongClick { + int[] value(); +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/reflect/OnTouch.java b/app/src/main/java/com/fisherbone/fuzhu/reflect/OnTouch.java new file mode 100644 index 0000000..427cbdd --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/reflect/OnTouch.java @@ -0,0 +1,15 @@ +package com.fisherbone.fuzhu.reflect; + +import android.view.View; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@EventType(listenerType = View.OnTouchListener.class, listenerSetter = "setOnTouchListener") +public @interface OnTouch { + int[] value(); +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/HongbaoBase.java b/app/src/main/java/com/fisherbone/fuzhu/step/HongbaoBase.java new file mode 100644 index 0000000..0e26e61 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/HongbaoBase.java @@ -0,0 +1,870 @@ +package com.fisherbone.fuzhu.step; + +import android.graphics.Rect; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.RandumInt; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.db.CommentBeanData; +import com.fisherbone.fuzhu.db.RedenvBeanData; +import com.fisherbone.fuzhu.db.dao.CommentDao; +import com.fisherbone.fuzhu.hongbao.RedEnv; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +import io.reactivex.Flowable; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.Disposable; +import io.reactivex.functions.Action; +import io.reactivex.functions.Consumer; + +/** + * Time: 2021/5/21 + * Author: jianbo + * Description: + */ +class HongbaoBase extends BaseAblStep implements RedEnv.RedEnvFunc, RedEnv.TimeFunc, RedEnv.MoveFunc { + // private List jiluBeans; + public String SHEBEITIPE_VILUEONE = "0"; + public String SHEBEITIPE_VILUETHREE = "3"; + public ArrayList accessibilityNodeInfos; + + + @Override + public void onStep(int step, Message msg) { + + } + + /** + * 1.同城 + * 2.关注 + * 3.推荐 + */ + public void getNodeInfo(String type) { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // nodeZuobiao(child); + //显示节点的坐标:(261,99),(447,220) + switch (type) { + //同城 + case "1": + TextViewClick(child, "同城"); + break; + //关注 + case "2": + TextViewClick(child, "关注"); + break; + //推荐 + case "3": + TextViewClick(child, "推荐"); + break; + default: + + } + + } + } + + /** + * 关闭确认支付弹框 + * @param instance + */ + public void closedzfDialog(AblService instance) { + //处理我知道了的弹框 + AccessibilityNodeInfo zhidao = AblViewUtil.findByText("确认支付", 0); + if(zhidao==null){ + Log.e("TIAOSHI###", "没有找到确认支付的弹窗" ); + }else { + Log.e("TIAOSHI###", "弹出了确认支付的弹窗" ); + AccessibilityNodeInfo zaishuo = AblViewUtil.findByText("确认并不再提醒", 0); + AblService.getInstance().clickcommontwo(zaishuo, "确认并不再提醒"); + AblViewUtil.mySleep(1); + } + } + + /** + * TextView的点击 + * + * @param child2 + * @param str + */ + private void TextViewClick(AccessibilityNodeInfo child2, String str) { + if ("android.widget.TextView".equals(child2.getClassName())) { + if (child2.getText() != null) { + if (child2.getText().toString().equals(str)) { + Rect rect = new Rect(); + child2.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----显示节点的坐标:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + if (rect.top >= 99 && rect.bottom <= 220 && rect.left >= 261 && rect.right <= 819) { + AblService.getInstance().clickcommontwo(child2, ""); + return; + } + } + } + } + } + + /** + * 进入第一个直播间 + */ + public void enterOneNodeInfo() { + AblService.getInstance().clickPoint(121, 379, 300); + } + + + /** + * 说点什么节点 + * + * @return + */ + public AccessibilityNodeInfo getNodeInfoS() { + AccessibilityNodeInfo nodeinfo = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "one----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "one----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); +// Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); +// nodeZuobiao(child2); + if(child2!=null) { + if ("android.widget.TextView".equals(child2.getClassName())) { + if (child2.getText() != null) { + if ("说点什么...".equals(child2.getText().toString())) { + nodeinfo = child2; + } + } + } + } + } + } + } + return nodeinfo; + } + + /** + * 点击直播间下方的更多按钮(备注:通过搜索点击直播进去的可用) + * 1.说点什么 + * 2.更多 + * 3.礼物 + */ + public void clickmoreli() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + nodeZuobiao(child1); + if ("android.widget.RelativeLayout".equals(child1.getClassName())) { + if (child1.getContentDescription() != null) { + if (child1.getContentDescription().equals("礼物")) { + AblService.getInstance().clickcommontwo(child1, ""); + } + } + } + + } + } + } + + /** + * 获得抖币数 + */ + public String getdoubinum() { + String doubinum = ""; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + if (root != null) { + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + //nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + //nodeZuobiao(child1); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Rect rect = new Rect(); + if (child2 != null) { + child2.getBoundsInScreen(rect); + if (rect.top >= 2092 && rect.bottom <= 2151 && rect.left >= 800) { + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + if ("android.widget.TextView".equals(child2.getClassName())) { + if (child2.getText() != null) { + String s = child2.getText().toString(); + doubinum = s; + } + } + } + } + } + } + } + return doubinum; + } + return "0"; + } + + /** + * 控件的监听 + * + * @return + */ + public int jiedianhuoqutwo() { + accessibilityNodeInfos = new ArrayList<>(); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + if (root != null) { + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + Rect rect = new Rect(); + child1.getBoundsInScreen(rect); + if(child1!=null) { + if (rect.top >= 319 && rect.bottom <= 418 && rect.right < 706) { + if ("android.widget.FrameLayout".equals(child1.getClassName())) { + accessibilityNodeInfos.add(child1); + } + } + } + } + } + } + return accessibilityNodeInfos.size(); + } + + + + /** + * 判断页面类型 + * + * @return + */ + + /** + * 判断页面类型 + * + * @return + */ + public int pagetype() { + int childCount = 0; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + if (root != null) { + childCount = root.getChildCount(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { + childCount = 4; + } + if("android.widget.Button".equals(child.getClassName())){ + childCount =21; + } + } + } + return childCount; + } + + /** + * 获得控件的父控件 + */ + public AccessibilityNodeInfo getParNode() { + AccessibilityNodeInfo kongjian = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + if (child1 != null) { + if ("android.widget.HorizontalScrollView".equals(child1.getClassName())) { + kongjian = child1; + } + } + } + } + return kongjian; + } + + public void fasongpingluntwo(String conment) { + //直播间话术 + AblViewUtil.mySleep(2); + AccessibilityNodeInfo geouyintd = geouyintdsse(); + AblService.getInstance().clickcommontwo(geouyintd, ""); + AblViewUtil.mySleep(2); + //复制文本粘贴在留言板 + AccessibilityNodeInfo getedittext = getedittext(); + Log.e("TIAOSHI###", "获得的关键词内容" + conment); + AblViewUtil.mySleep(1); + if (SHEBEITIPE_VILUEONE.equals(ChangLiang.phonetype)) { + AblViewUtil.sayInput(conment, getedittext); + } else { + /** + * 华为畅享20 + */ + AblViewUtil.sayInput(conment, getedittext); + } + AblViewUtil.mySleep(1); + AccessibilityNodeInfo geouyintdd = geouyintdd(); + AblService.getInstance().clickcommontwo(geouyintdd, "点击发送评论"); + AblViewUtil.mySleep(2); + } + + /** + * 停任务的倒计时 + * + * @param a + */ + public void taskdaojishi(final int a) { + + //启动计时器 + //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 + Disposable mdDisposable = Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) + .observeOn(AndroidSchedulers.mainThread()) + .doOnNext(new Consumer() { + @Override + public void accept(Long aLong) throws Exception { + long b = a - aLong; + Log.e("TIAOSHI###", b + ""); + } + }) + .doOnComplete(new Action() { + @Override + public void run() throws Exception { + AblStepHandler.getInstance().setStop(false); + Log.e("TIAOSHI###", "开始点击抢红包"); + zhibodianzanb(64); + AblViewUtil.mySleep(3); + int pagetype = pagetype(); + if (pagetype==21) { + Log.e("TIAOSHI###", "有红包弹框,点击关闭"); + // AblViewUtil.back(); + AblService.getInstance().clickPoint(540, 1663, 300); + // (100,563),(980,1746) + } else { + Log.e("TIAOSHI###", "没有有红包弹框,不点击返回"); + } + AblViewUtil.mySleep(1); + int pagenum = pagetype(); + if(pagenum!=21) { + AblStepHandler.sendMsg(AblSteps.STEP_254); + }else { + Log.e("TIAOSHI###", "有红包弹框,再次点击关闭"); + AblService.getInstance().clickPoint(540, 1663, 300); + AblStepHandler.sendMsg(AblSteps.STEP_254); + } + AblViewUtil.mySleep(1); + } + }) + .subscribe(); + } + + + + /** + * 直播间点赞 + * + * @param mun + */ + public void zhibodianzanb(int mun) { + for (int i = 0; i < mun; i++) { + int a = 520 + RandumInt.getRandumInt4() * 2; + int b = 1162 - RandumInt.getRandumInt4() * 2; + // int c = 500 - RandumInt.getRandumInt4() * 50; + AblService.getInstance().clickPoint(a, b, 20); + Log.e("TIAOSHI###", "----点击次数1:" + i); + try { + Thread.sleep(30); //隔200 ms 滚动一次 + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + + /** + * 寻找控件 + */ + public boolean liveOver() { + boolean liveover = false; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // nodeZuobiao(child1); + if ("android.widget.TextView".equals(child1.getClassName())) { + CharSequence text = child1.getText(); + if (child1.getText() != null) { + if ("直播已结束".equals(child1.getText().toString())) { + Log.e("TIAOSHI###", y + ""); + //0用来区分直播结束页面和正常直播页面 + if ("0".equals(y + "")) { + liveover = true; + } + break; + } + } + } + } + } + return liveover; + } + + + /** + * 点击取消关注 + */ + public void clickyiguanzhu() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); +// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); +// nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // nodeZuobiao(child1); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + nodeZuobiao(child2); + if ("android.widget.TextView".equals(child2.getClassName())) { + if (child2.getText() != null) { + if ("取消关注".equals(child2.getText().toString())) { + clickNodeInfo(child2, ""); + } + } + } + } + } + } + } + + /** + * 直播间点赞 + * 100-300 + * + * @param mun + */ + public void zhibodianzan(int mun) { + for (int i = 0; i < mun; i++) { + int a = 540 + RandumInt.getRandumInt4() * 8; + int b = 500 - RandumInt.getRandumInt4() * 10; + int c = 200 - RandumInt.getRandumInt4() * 20; + AblService.getInstance().clickPoint(a, b, 100); + try { + //隔200 ms + Thread.sleep(c); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + + /** + * 说点什么节点 + * + * @return + */ + public AccessibilityNodeInfo geouyintdsse() { + AccessibilityNodeInfo nodeinfo = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("android.widget.TextView".equals(child1.getClassName())) { + if (child1.getText() != null) { + if ("说点什么...".equals(child1.getText().toString())) { + nodeinfo = child1; + } + } + } + } + } + return nodeinfo; + } + + /** + * 输入框 + * + * @return + */ + public AccessibilityNodeInfo getedittext() { + AccessibilityNodeInfo nodeinfo = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.EditText".equals(child.getClassName())) { + nodeinfo = child; + } + } + return nodeinfo; + } + + /** + * 发送节点 + * + * @return + */ + public AccessibilityNodeInfo geouyintdd() { + AccessibilityNodeInfo nodeinfo = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.ImageView".equals(child.getClassName())) { + if (child.getContentDescription() != null) { + if (child.getContentDescription().toString().equals("发送")) { + nodeinfo = child; + } + } + } + } + return nodeinfo; + } + + + @Override + public boolean openTiktok() { + return false; + } + + @Override + public boolean enterLive() { + return false; + } + + @Override + public boolean liveTime() { + return false; + } + + @Override + public boolean liveDoubiNum(String doubimun) { + return false; + } + + @Override + public boolean perNumCon() { + return false; + } + + @Override + public boolean ifControlView() { + boolean ifcontain = false; + //监听一次有没有控件 + int jiedianhuoqutwo = jiedianhuoqutwo(); + Log.e("TIAOSHI###", "获得的控件个数==" + jiedianhuoqutwo); + if (jiedianhuoqutwo > 0) { + ifcontain = true; + } + return ifcontain; + } + + /** + * 随机获取评论话术 + */ + public String getConment() { + List CommentBeanDatas = CommentDao.queryInByCustom("type", "3"); + if (CommentBeanDatas.size() == 0) { + return "哈哈"; + } else if (CommentBeanDatas.size() == 1) { + CommentBeanData commentBeanData = CommentBeanDatas.get(0); + String comment = commentBeanData.getComment(); + return comment; + } else { + int i = new Random().nextInt(CommentBeanDatas.size() - 1); + CommentBeanData commentBeanData = CommentBeanDatas.get(i); + String comment = commentBeanData.getComment(); + return comment; + } + } + + + /** + * 获得直播间人数 + */ + public int getPersonNum() { + int personnum = 0; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + nodeZuobiao(child2); + Rect rect = new Rect(); + child2.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----threeNode:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + //红米7A(560,77),(632,137) 畅想20(560,70),(632,130) 红米9(860,129),(959,212) + if (SHEBEITIPE_VILUEONE.equals(ChangLiang.phonetype)) { + if (rect.left > 360 && rect.top >= 77 && rect.bottom <= 137) { + if ("android.widget.Button".equals(child2.getClassName())) { + String person = child2.getText().toString(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + person); + if (person.contains("万")) { + String substring = person.substring(0, person.indexOf("万")); + double personmun = Double.parseDouble(substring) * 10000; + personnum = new Double(personmun).intValue(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + personnum); + } else { + personnum = Integer.valueOf(person); + } + break; + } + } + } else if (SHEBEITIPE_VILUETHREE.equals(ChangLiang.phonetype)) { + if (rect.left > 540 && rect.top >= 129 && rect.bottom <= 212) { + if ("android.widget.Button".equals(child2.getClassName())) { + String person = child2.getText().toString(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + person); + if (person.contains("万")) { + String substring = person.substring(0, person.indexOf("万")); + double personmun = Double.parseDouble(substring) * 10000; + personnum = new Double(personmun).intValue(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + personnum); + } else { + personnum = Integer.valueOf(person); + } + break; + } + } + } else { + // 16.5版本(561,69),(633,129) 14.6版本(560,70),(632,130) + if (rect.left > 360 && rect.top >= 68 && rect.bottom <= 130) { + if ("android.widget.Button".equals(child2.getClassName())) { + String person = child2.getText().toString(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + person); + if (person.contains("万")) { + String substring = person.substring(0, person.indexOf("万")); + double personmun = Double.parseDouble(substring) * 10000; + personnum = new Double(personmun).intValue(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + personnum); + } else { + personnum = Integer.valueOf(person); + } + break; + } + } + } + } + } + } + return personnum; + } + + @Override + public boolean tagControlView(String str, int position) { + return false; + } + + @Override + public boolean ifRedEnv() { + return false; + } + + @Override + public boolean ifFuDai() { + return false; + } + + @Override + public boolean grabRedEnv() { + return false; + } + + @Override + public boolean grabFuDai() { + return false; + } + + @Override + public boolean ifLiveTuiBo() { + return false; + } + + @Override + public int dangqianDoubi() { + return 0; + } + + @Override + public boolean recRedEnv(RedenvBeanData data, String RedEnvTime) { + return false; + } + + @Override + public boolean recFuDai(RedenvBeanData data, String FuDaiTime) { + return false; + } + + @Override + public boolean recLiveName(RedenvBeanData data, String liveName) { + return false; + } + + @Override + public boolean recZhiBoPar(RedenvBeanData data) { + return false; + } + + @Override + public boolean SatNum(ArrayList objects, int num) { + return false; + } + + @Override + public boolean chuShiZhiBoParmer() { + return false; + } + + @Override + public boolean quGuanZhuBo() { + return false; + } + + @Override + public boolean ifConQuGuan() { + return false; + } + + @Override + public boolean ifLessThanTime() { + return false; + } + + @Override + public boolean ifContain() { + return false; + } + + @Override + public int ContainPostion() { + return 0; + } + + @Override + public int redEnvPostion() { + return 0; + } + + @Override + public boolean moveZhiBoJian(int postion, int postiontwo) { + return false; + } + + @Override + public boolean ifMoveZhiBo(ArrayList objects, String liveName) { + return false; + } + + /** + * 寻找控件 + */ + public AccessibilityNodeInfo getdaohang() { + AccessibilityNodeInfo childw = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + if (root != null) { + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if(child!=null) { + if ("android.widget.FrameLayout".equals(child.getClassName())) { + AblViewUtil.mySleep(2); + Log.e("TIAOSHI###", "出现了取消关注的弹框,点击坐标540,500关闭"); + AblService.getInstance().clickPoint(540, 500, 300); + AblViewUtil.mySleep(2); + getdaohang(); + } + } + if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { + // nodeZuobiao(child); + childw = child; + } + } + } + return childw; + } + + /** + * 是否有首页 + */ + public boolean ifShouye() { + boolean flag = false; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // nodeZuobiao(child1); + if ("android.widget.TextView".equals(child1.getClassName())) { + if (child1.getText() != null) { + if (child1.getText().toString().equals("首页")) { + flag = true; + } + } + } + } + } + return flag; + } + + /** + * 首页 + */ + public AccessibilityNodeInfo getShouye() { + AccessibilityNodeInfo nodeInfo = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // nodeZuobiao(child1); + if ("android.widget.TextView".equals(child1.getClassName())) { + if (child1.getText() != null) { + if (child1.getText().toString().equals("首页")) { + nodeInfo = child1; + } + } + } + } + } + return nodeInfo; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/Lance.java b/app/src/main/java/com/fisherbone/fuzhu/step/Lance.java new file mode 100644 index 0000000..f37bac0 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/Lance.java @@ -0,0 +1,19 @@ +package com.fisherbone.fuzhu.step; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Time: 2021/8/17 + * Author: jianbo + * Description: + */ + +@Retention(RetentionPolicy.RUNTIME)//保留时 +@Target({ElementType.TYPE,ElementType.METHOD}) +@interface Lance { + int a(); + String b(); +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/NoticeBase.java b/app/src/main/java/com/fisherbone/fuzhu/step/NoticeBase.java new file mode 100644 index 0000000..1022245 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/NoticeBase.java @@ -0,0 +1,752 @@ +package com.fisherbone.fuzhu.step; + +import android.accessibilityservice.AccessibilityService; +import android.graphics.Rect; +import android.os.Build; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import androidx.annotation.RequiresApi; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.db.CommentBeanData; +import com.fisherbone.fuzhu.entity.FensiBean; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +/** + * Time: 2021/5/21 + * Author: jianbo + * Description: + */ +class NoticeBase extends BaseAblStep { + public String SHEBEITIPE_VILUEONE="0"; + public String SHEBEITIPE_VILUETHREE="3"; + public String SHEBEITIPE_VILUETWO="2"; + public String IFCONTIAN="x"; + private static final String TAG = "Conmon"; + private String conment; + @Override + public void onStep(int step, Message msg) { + + } + + /** + * 获取一条随机字符串 + * @param length + * @return + */ + public String getRandomString(int length) { //length表示生成字符串的长度 + String base = "abcdefghijklmnopqrstuvwxyz0123456789"; + Random random = new Random(); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < length; i++) { + int number = random.nextInt(base.length()); + sb.append(base.charAt(number)); + } + Log.e("提交的字符串s", "getRandomString: " + sb.toString()); + return sb.toString(); + } + + public boolean allowed() { + boolean ifOpen = false; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.TextView".equals(child.getClassName())) { + if(child.getText()!=null) { + if (child.getText().toString().contains("正在尝试开启") || child.getText().toString().contains("是否允许")) { + int childCount = root.getChildCount(); + AccessibilityNodeInfo child1 = root.getChild(childCount - 1); + clickNodeInfo(child1, "点击了允许"); + } + } + ifOpen = true; + } + } + return ifOpen; + } + + + + public void scroll2PositionClick(AccessibilityService service, String text, AccessibilityNodeInfo chilrecy) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { //必须android4.3以上的版本 + AccessibilityNodeInfo rootInActiveWindow = service.getRootInActiveWindow(); //获取当前展示的窗口 + if (rootInActiveWindow != null) { + List item = rootInActiveWindow.findAccessibilityNodeInfosByText(text); //根据关键字查找某控件元素 + if (item == null || item.size() == 0) { // 关键字元素不存在,则滚动容器元素 + Log.d(TAG, "不存在 " + text); + try { + Thread.sleep(300); //隔200 ms 滚动一次 + } catch (InterruptedException e) { + e.printStackTrace(); + } + chilrecy.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); //触发容器元素的滚动事件 + Log.d(TAG, "---- [ " + text + " ] 滚动查找中 ----"); + FensiBean fensi = ProfileSpUtils.getInstance().getFensi(); + String nikename = fensi.getNikename(); + scroll2PositionClick(AblService.getInstance(), nikename, chilrecy); + } else { + Log.d(TAG, "存在 " + text); + try { + Thread.sleep(3000); //隔200 ms 滚动一次 + } catch (InterruptedException e) { + e.printStackTrace(); + } + // chilrecy.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); //触发容器元素的滚动事件 + AblViewUtil.mySleep(1); + getdouyin(); + } + } + } + } + public void getdouyin() { + AccessibilityNodeInfo chilrecy = getguanjian(); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + // Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); + if ("android.widget.ImageView".equals(child3.getClassName())) { + //设置recy每次操作的区间0,411 0,1020 + //点击屏幕内的节点元素 + Rect imgBtnOutBound = new Rect(); + child3.getBoundsInScreen(imgBtnOutBound); + if (imgBtnOutBound.top >= 390 && imgBtnOutBound.bottom <= 1020 && imgBtnOutBound.right <= 72) { + // Log.e("TIAOSHI###", "----点击了" + child3.getClassName()); + clickcommonthree(child3, "选择框"); + AblViewUtil.mySleep(1); + } else { + Log.e("TIAOSHI###", "不在区间内"); + continue; + } + break; + } + } + } + } + } + chilrecy.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); //触发容器元素的滚动事件 + AblViewUtil.mySleep(2); + AccessibilityNodeInfo roott = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < roott.getChildCount(); i++) { + AccessibilityNodeInfo child = roott.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + // Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); + if ("android.widget.ImageView".equals(child3.getClassName())) { + //设置recy每次操作的区间0,411 0,1020 + //点击屏幕内的节点元素 + Rect imgBtnOutBound = new Rect(); + child3.getBoundsInScreen(imgBtnOutBound); + if (imgBtnOutBound.top >= 390 && imgBtnOutBound.bottom <= 1020 && imgBtnOutBound.right <= 72) { + // Log.e("TIAOSHI###", "----点击了" + child3.getClassName()); + clickcommonthree(child3, "选择框"); + FensiBean fensiBean = new FensiBean(); + AccessibilityNodeInfo child4 = child3.getParent().getChild(2); + if(child4!=null) { + fensiBean.setNikename(child4.getText().toString()); + ProfileSpUtils.getInstance().saveFensi(fensiBean); + } + AblViewUtil.mySleep(2); + } else { + Log.e("TIAOSHI###", "不在区间内"); + continue; + } + break; + } + } + } + } + } + } + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickcommonthree(AccessibilityNodeInfo accessibilityNodeInfo, String s) { + if (accessibilityNodeInfo != null) { + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮"); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮"); + } + } + + public AccessibilityNodeInfo getguanjian() { + AccessibilityNodeInfo chilrecy = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child.getClassName())) { + chilrecy = root.getChild(i); + // Log.e("TIAOSHI###", "----thrxxxxNode:" + chilrecy.getClassName() + ":" + chilrecy.getText() + ":" + chilrecy.getContentDescription()); + + } + } + return chilrecy; + } + + + public void fasongsixin(AblService instance) { + AblViewUtil.mySleep(2); + //寻找编辑控件 + AccessibilityNodeInfo findcomentt = getEdit(); + List commentBeanDataList = ProfileSpUtils.getInstance().getFensiNotice().getCommentBeanDataList(); + if(commentBeanDataList.size()>0){ + CommentBeanData commentBeanData = commentBeanDataList.get(new Random().nextInt(commentBeanDataList.size())); + conment = commentBeanData.getComment()+""+getRandomString(2); + } + // String conment = getRandomString(2)+"=="+"汉中绿茶,炒青仙豪有需要的联系。品质保障,价格实惠!"+"=="+getRandomString(2); + Log.e("TIAOSHI###", "获得的信息内容" + conment); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "获得的信息内容" + conment); + if (ChangLiang.phonetype.equals("0")) { + Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype); + //郝总的手机用第一个评论不上去 + // AblViewUtil.paste(findcomentt, conment);//红米7a + AblViewUtil.sayInput(conment, findcomentt); + } else { + Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype); + AblViewUtil.sayInput(conment, findcomentt);//华为畅享20 + } + //发送 + AblViewUtil.mySleep(2+new Random().nextInt(5)+1); + +// 点击分别发送 + List list = AblViewUtil.findByText("分别发送"); + for (AccessibilityNodeInfo item : list) { + clickcommonthree(item, "发私信"); + } + AblViewUtil.mySleep(6+new Random().nextInt(5)+1); + AblStepHandler.sendMsg(AblSteps.STEP_122); + } + public void fasongsixintwo(AblService instance) { + AblViewUtil.mySleep(2); + //寻找编辑控件 + AccessibilityNodeInfo findcomentt = getEdit(); + List commentBeanDataList = ProfileSpUtils.getInstance().getFensiNotice().getCommentBeanDataList(); + if(commentBeanDataList.size()>0){ + CommentBeanData commentBeanData = commentBeanDataList.get(new Random().nextInt(commentBeanDataList.size())); + conment = commentBeanData.getComment()+""+getRandomString(2); + } + // String conment = getRandomString(2)+"=="+"汉中绿茶,炒青仙豪有需要的联系。品质保障,价格实惠!"+"=="+getRandomString(2); + Log.e("TIAOSHI###", "获得的信息内容" + conment); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "获得的信息内容" + conment); + if (ChangLiang.phonetype.equals("0")) { + Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype); + //郝总的手机用第一个评论不上去 + // AblViewUtil.paste(findcomentt, conment);//红米7a + AblViewUtil.sayInput(conment, findcomentt); + } else { + Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype); + AblViewUtil.sayInput(conment, findcomentt);//华为畅享20 + } + //发送 + AblViewUtil.mySleep(2+new Random().nextInt(5)+1); + +// 点击分别发送 + List list = AblViewUtil.findByText("分别发送"); + for (AccessibilityNodeInfo item : list) { + clickcommonthree(item, "发私信"); + } + AblViewUtil.mySleep(6+new Random().nextInt(5)+1); + AblStepHandler.sendMsg(AblSteps.STEP_83); + } + + public void fasongsixinthree(AblService instance) { + AblViewUtil.mySleep(2); + //寻找编辑控件 + AccessibilityNodeInfo findcomentt = getEdit(); + List commentBeanDataList = ProfileSpUtils.getInstance().getFensiNotice().getCommentBeanDataList(); + if(commentBeanDataList.size()>0){ + CommentBeanData commentBeanData = commentBeanDataList.get(new Random().nextInt(commentBeanDataList.size())); + conment = commentBeanData.getComment()+""+getRandomString(2); + } + // String conment = getRandomString(2)+"=="+"汉中绿茶,炒青仙豪有需要的联系。品质保障,价格实惠!"+"=="+getRandomString(2); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "获得的信息内容" + conment); + if (ChangLiang.phonetype.equals("0")) { + Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype); + //郝总的手机用第一个评论不上去 + // AblViewUtil.paste(findcomentt, conment);//红米7a + AblViewUtil.sayInput(conment, findcomentt); + } else { + Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype); + AblViewUtil.sayInput(conment, findcomentt);//华为畅享20 + } + //发送 + AblViewUtil.mySleep(2+new Random().nextInt(5)+1); + +// 点击分别发送 + List list = AblViewUtil.findByText("分别发送"); + for (AccessibilityNodeInfo item : list) { + clickcommonthree(item, "发私信"); + } + AblViewUtil.mySleep(6+new Random().nextInt(5)+1); + AblStepHandler.sendMsg(AblSteps.STEP_203); + } + + private AccessibilityNodeInfo getEdit() { + AccessibilityNodeInfo nodeinfo = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if("android.widget.EditText".equals(child1.getClassName())){ + if(child1.getText().equals("有什么想和好友说的...")){ + nodeinfo=child1; + } + } + } + } + return nodeinfo; + } + + + + /** + * 点击直播间下方的更多按钮(备注:在首页点击直播进去的可用) + * 1.说点什么 + * 2.更多 + * 3.礼物 + */ + public void clickmore(String type) { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + switch (type) { + case "1"://说点什么 + if ("android.widget.TextView".equals(child1.getClassName())) { + if (child1.getText() != null) { + if (child1.getText().toString().equals("说点什么...")) { + AblService.getInstance().clickcommontwo(child1, ""); + } + } + } + break; + case "2"://更多 + if ("android.widget.Button".equals(child1.getClassName())) { + if (child1.getContentDescription().equals("更多")) { + AblService.getInstance().clickcommontwo(child1, "点击了更多"); + } + } + break; + case "3"://礼物 + if ("android.widget.Button".equals(child1.getClassName())) { + if (child1.getContentDescription().equals("礼物")) { + AblService.getInstance().clickcommontwo(child1, ""); + } + } + break; + default: + } + } + } + } + /** + * 点击直播间下方的更多按钮(备注:通过搜索点击直播进去的可用) + * 1.说点什么 + * 2.更多 + * 3.礼物 + */ + public void clickmoreli(String type) { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + // Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); + for (int r = 0; r < child3.getChildCount(); r++) { + AccessibilityNodeInfo child4 = child3.getChild(r); + // Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText() + ":" + child4.getContentDescription()); + switch (type) { + case "1"://说点什么 + if ("android.widget.TextView".equals(child4.getClassName())) { + if (child4.getText() != null) { + if (child4.getText().toString().equals("说点什么...")) { + AblService.getInstance().clickcommontwo(child4, ""); + } + } + } + break; + case "2"://更多 + if ("android.widget.Button".equals(child4.getClassName())) { + if (child4.getContentDescription().equals("更多")) { + AblService.getInstance().clickcommontwo(child4, "点击了更多"); + } + } + break; + case "3"://礼物 + if ("android.widget.Button".equals(child4.getClassName())) { + if (child4.getContentDescription().equals("礼物")) { + AblService.getInstance().clickcommontwo(child4, ""); + } + } + break; + default: + } + } + } + } + } + } + } + + + /** + * 分享 + * 1为分享 2为私信朋友 + */ + public void share(String type) { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + // Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); + switch (type) { + case "1": + if ("android.widget.TextView".equals(child3.getClassName())) { + if (child3.getText() != null) { + if (child3.getText().toString().equals("分享")) { + AblService.getInstance().clickcommontwo(child3, ""); + } + } + } + break; + case "2": + if ("android.widget.TextView".equals(child3.getClassName())) { + if (child3.getText() != null) { + if (child3.getText().toString().equals("私信朋友")) { + AblService.getInstance().clickcommontwo(child3, ""); + } + } + } + break; + default: + } + } + } + } + } + } + //点击右上角搜索 + public void DianSou() { + //华为畅享20 + AblService.getInstance().clickPoint(990, 163, 300); + switch (ChangLiang.phonetype){ + case "0": + //红米7a + AblService.getInstance().clickPoint(656, 99, 300); + break; + case "1": + //华为畅享20 + AblService.getInstance().clickPoint(659, 99, 300); + break; + case "2": + //华为畅享20 + AblService.getInstance().clickPoint(990, 163, 300); + break; + case "3": + //note9 + AblService.getInstance().clickPoint(990, 163, 300); + break; + default: + } + Log.e("TIAOSHI###", "点击搜索按钮"); + } + + /** + * 寻找搜索输入框 + */ + public AccessibilityNodeInfo findEditText() { + AccessibilityNodeInfo infooos = null; + AccessibilityNodeInfo rootttt = AblService.getInstance().getRootInActiveWindow(); + for (int j = 0; j < rootttt.getChildCount(); j++) { + AccessibilityNodeInfo child = rootttt.getChild(j); + // Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); +// Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); +// nodeZuobiao(child1); + if ("android.widget.EditText".equals(child1.getClassName())) { + infooos = child1; + } + } + } + return infooos; + } + + + /** + * 选择搜索的分类 + * 1为用户 2为直播 + */ + public void selecttype(String type) { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + + switch (type) { + case "1": + if ("android.widget.TextView".equals(child2.getClassName())) { + if (child2.getText() != null) { + if (child2.getText().toString().equals("用户")) { + AblService.getInstance().clickcommontwo(child2, ""); + } + } + } + break; + case "2": + if ("android.widget.TextView".equals(child2.getClassName())) { + if (child2.getText() != null) { + if (child2.getText().toString().equals("直播")) { + AblService.getInstance().clickcommontwo(child2, ""); + } + } + } + break; + default: + } + } + } + } + } + + + /** + * 说点什么节点 + * @return + */ + public AccessibilityNodeInfo geouyintd() { + AccessibilityNodeInfo nodeinfo = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.TextView".equals(child.getClassName())) { + if (child.getText().toString().equals("说点什么...:")) { + nodeinfo=child; + } + } + } + return nodeinfo; + } + /** + * 输入框 + * @return + */ + public AccessibilityNodeInfo getedittext() { + AccessibilityNodeInfo nodeinfo = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.EditText".equals(child.getClassName())) { + nodeinfo=child; + } + } + return nodeinfo; + } + + /** + * 发送节点 + * @return + */ + public AccessibilityNodeInfo geouyintdd() { + AccessibilityNodeInfo nodeinfo = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.Button".equals(child.getClassName())) { + if(child.getContentDescription()!=null) { + if (child.getContentDescription().toString().equals("发送")) { + nodeinfo = child; + } + } + } + } + return nodeinfo; + } + + + /** + * 点击礼物下面的菜单 + * 1.礼物 + * 2.表情 + * 3.粉丝团 + * 4.等级 + * 5.背包 + */ + public void clickmenu(String type) { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); + switch (type) { + case "1"://礼物 + if ("android.widget.TextView".equals(child3.getClassName())) { + if (child3.getText() != null) { + if (child3.getText().toString().equals("礼物")) { + AblService.getInstance().clickcommontwo(child3, ""); + } + } + } + break; + case "2"://表情 + if ("android.widget.TextView".equals(child3.getClassName())) { + if (child3.getText().toString().equals("表情")) { + AblService.getInstance().clickcommontwo(child3, ""); + } + } + break; + case "3"://粉丝团 + if ("android.widget.TextView".equals(child3.getClassName())) { + if (child3.getText().toString().equals("粉丝团")) { + AblService.getInstance().clickcommontwo(child3, ""); + } + } + break; + case "4"://等级 + if ("android.widget.TextView".equals(child3.getClassName())) { + if (child3.getText().toString().equals("等级")) { + AblService.getInstance().clickcommontwo(child3, ""); + } + } + case "5"://背包 + if ("android.widget.TextView".equals(child3.getClassName())) { + if (child3.getText().toString().equals("背包")) { + AblService.getInstance().clickcommontwo(child3, ""); + } + } + break; + default: + } + } + } + } + } + } + + /** + * 获得背包中第一个位置的了礼物 + */ + public List geliwu() { + List liwus = new ArrayList<>(); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + if ("android.view.ViewGroup".equals(child2.getClassName())) { + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + liwus.add(child2); +// for (int x = 0; x < child2.getChildCount(); x++) { +// AccessibilityNodeInfo child3 = child2.getChild(x); +// Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); +// } + } + } + } + } + return liwus; + } + + /** + * 点击加关注 + */ + public void clickGuanzhu() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + if ("android.widget.TextView".equals(child2.getClassName())) { + if (child2.getText() != null) { + if (child2.getText().toString().equals("关注")) { + AblService.getInstance().clickcommontwo(child2, ""); + } + } + } + } + } + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/OnClick.java b/app/src/main/java/com/fisherbone/fuzhu/step/OnClick.java new file mode 100644 index 0000000..cfbffd4 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/OnClick.java @@ -0,0 +1,17 @@ +package com.fisherbone.fuzhu.step; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Time: 2021/8/18 + * Author: jianbo + * Description: + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@interface OnClick { + int[] value(); +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep0.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep0.java new file mode 100644 index 0000000..df727eb --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep0.java @@ -0,0 +1,162 @@ +package com.fisherbone.fuzhu.step; + +import android.graphics.Rect; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; + +import java.util.ArrayList; +import java.util.List; + +/** + * 获得作品时间 + */ +public class TestAblStep0 extends BaseAblStep { + private List jiluBeans; + private String guanzhunum; + private String fensinum; + private String zuopinnum; + private String huozannum; + public String SHEBEITIPE_VILUEONE = "0"; + public String SHEBEITIPE_VILUETHREE = "3"; + private ArrayList accessibilityNodeInfos; + private String direction ="0";//0代表向上滑动,1代表向下 + public String IFCONTIAN="x"; + private int liwusubstring; + private boolean noqinmidu=true; + private int num3; + @Override + public void onStep(int step, Message msg) { + switch (step) { + case AblSteps.STEP_1: + AblViewUtil.startApplication(); + jiluBeans = new ArrayList<>(); + AblStepHandler.sendMsg(AblSteps.STEP_2); + + break; + case AblSteps.STEP_2: + AblViewUtil.mySleep(2); + //getNodeInfoh(); + // (138,148),(278,193) +// String nodeName = getNodeName(); +// Log.e("TIAOSHI###", nodeName); + + // moveLive("九九美食"); +// boolean enterfensituan = enterfensituan(); +// Log.e("TIAOSHI###", "最终=="+enterfensituan); + + if (ifControlView()) { + openFudai(); + } + break; + default: + } + } + public boolean ifControlView() { + boolean ifcontain = false; + //监听一次有没有控件 + int jiedianhuoqutwo = jiedianhuoqutwo(); + Log.e("TIAOSHI###", "获得的控件个数==" + jiedianhuoqutwo); + if (jiedianhuoqutwo > 0) { + ifcontain = true; + } + return ifcontain; + } + + private void openFudai(){ + for (int j = 0; j < accessibilityNodeInfos.size(); j++) { + AccessibilityNodeInfo child2 = accessibilityNodeInfos.get(j); + if (child2 != null) { + clickNodeInfo(child2, ""); + Log.e("TIAOSHI###", "点击控件" + j); + Rect rect = new Rect(); + child2.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----显示控件点击的控件坐标:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + } + AblViewUtil.mySleep(2); + int pagetype = pagetype(); + if (pagetype == 1) { + Log.e("TIAOSHI###","福袋测试1"); + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(540, 1663, 300); + AblViewUtil.mySleep(1); + int pagetype1 = pagetype(); + if (pagetype1 == 1) { + Log.e("TIAOSHI###", "第一次点击没有关掉"); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "再次点击关闭按钮"); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + } else { + Log.e("TIAOSHI###", "优惠卷弹框关闭了"); + } + } else if (pagetype == 2) { + + break; + } else if (pagetype == 21) { + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + } else if (pagetype == 4) { + AblViewUtil.mySleep(2); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + } else { + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + } + } + } + public int pagetype() { + int childCount = 0; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + if (root != null) { + childCount = root.getChildCount(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { + childCount = 4; + } + if("android.widget.Button".equals(child.getClassName())){ + childCount =21; + } + } + } + return childCount; + } + public int jiedianhuoqutwo() { + accessibilityNodeInfos = new ArrayList<>(); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + if (root != null) { + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + Rect rect = new Rect(); + child1.getBoundsInScreen(rect); + if(child1!=null) { + if (rect.top >= 319 && rect.bottom <= 418 && rect.right < 706) { + if ("android.widget.FrameLayout".equals(child1.getClassName())) { + accessibilityNodeInfos.add(child1); + } + } + } + } + } + } + return accessibilityNodeInfos.size(); + } + +} + + diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep1.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep1.java new file mode 100644 index 0000000..64867cf --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep1.java @@ -0,0 +1,176 @@ +package com.fisherbone.fuzhu.step; + +import android.graphics.Rect; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.FuzhuApplication; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.db.DouyinBean; +import com.fisherbone.fuzhu.db.dao.DouyinDao; +import com.fisherbone.fuzhu.utils.EmojiFilter; + +import java.util.ArrayList; +import java.util.List; + +public class TestAblStep1 extends BaseAblStep { + private List accessibilityNodeInfos; + private DouyinDao douyinDao; + private AblService instance; + + @Override + public void onStep(int step, Message msg) { + switch (step) { + case AblSteps.STEP_50: + instance = AblService.getInstance(); + AblViewUtil.startApplication(); + douyinDao = new DouyinDao(FuzhuApplication.getContext()); + AblStepHandler.sendMsg(AblSteps.STEP_51); + break; + case AblSteps.STEP_51: + clickmy(); + AblStepHandler.sendMsg(AblSteps.STEP_52); + break; + case AblSteps.STEP_52: + getdouyinid(); + AblStepHandler.sendMsg(AblSteps.STEP_53); + break; + case AblSteps.STEP_53: + instance.clickPoint(972, 2112, 300); + Log.e("TIAOSHI###", "点击了我按钮"); + AblStepHandler.sendMsg(AblSteps.STEP_54); + break; + case AblSteps.STEP_54: + qiehuanz(instance); + //第二个帐号的点击 + instance.clickPoint(540, 616, 300); + AblStepHandler.sendMsg(AblSteps.STEP_55); + break; + case AblSteps.STEP_55: + clickmy(); + AblStepHandler.sendMsg(AblSteps.STEP_56); + break; + case AblSteps.STEP_56: + getdouyinid(); + AblStepHandler.sendMsg(AblSteps.STEP_57); + break; + case AblSteps.STEP_57: + instance.clickPoint(972, 2112, 300); + Log.e("TIAOSHI###", "点击了我按钮"); + AblStepHandler.sendMsg(AblSteps.STEP_58); + break; + case AblSteps.STEP_58: + qiehuanz(instance); + //第三个帐号的点击 + instance.clickPoint(360, 858, 300); + AblStepHandler.sendMsg(AblSteps.STEP_59); + + break; + case AblSteps.STEP_59: + clickmy(); + getdouyinid(); + AblViewUtil.back(); + //让服务暂停 + AblStepHandler.getInstance().setStop(true); + break; + default: + } + } + + private void clickmy() { + AblViewUtil.mySleep(6); + AblService.getInstance().clickPoint(972, 2103, 300); + Log.e("TIAOSHI###", "点击了我按钮"); + } + + private void qiehuanz(AblService instance) { + + AblViewUtil.mySleep(2); + //(945,126),(1033,214) + + instance.clickPoint(989, 170, 300); + Log.e("TIAOSHI###", "点击了更多按钮"); + + AblViewUtil.mySleep(2); + //(546,1764),(622,1816) + instance.clickPoint(584, 1790, 300); + Log.e("TIAOSHI###", "点击了设置按钮"); + + //等待2秒向上滑动 + AblViewUtil.mySleep(2); + instance.randomSwipe(); + //等待2秒点击切换账户 + AblViewUtil.mySleep(2); + AccessibilityNodeInfo zhaohao = AblViewUtil.findByText("切换帐号", 0); + if (zhaohao == null) { + Log.e("TIAOSHI###", "没有找到切换帐号"); + } else { + Log.e("TIAOSHI###", "弹出了个人信息保护指引的弹窗"); + clickNodeInfo(zhaohao, "切换帐号"); + } + AblViewUtil.mySleep(2); + } + + private void getdouyinid() { + + AblViewUtil.mySleep(2); + //获取抖音号 + getdouyin(); + AccessibilityNodeInfo accessibilityNodeInfoo = accessibilityNodeInfos.get(1); + String str = accessibilityNodeInfoo.getText().toString(); + String[] all = str.split(":"); + Log.e("TIAOSHI###", "获得的抖音号==" + all[0]); + Log.e("TIAOSHI###", "获得的抖音号==" + all[1]); + AccessibilityNodeInfo accessibilityNodeInfo = accessibilityNodeInfos.get(0); + String s = accessibilityNodeInfo.getText().toString(); + ChangLiang.short_id = all[1]; + String s1 = EmojiFilter.filterEmoji(s);//去除字符串中包含的表情符号 + Log.e("TIAOSHI###", "获得的抖音号昵称==" + s1); + ChangLiang.short_name = s1; +// SPUtils.setSP(FuzhuApplication.getContext(), FZConfig.SHORT_NAME, s1); +// SPUtils.setSP(FuzhuApplication.getContext(), FZConfig.SHORT_ID, ChangLiang.short_id ); + DouyinBean douyinBean = new DouyinBean(); + douyinBean.setLogin_status("1"); + douyinBean.setShort_id(ChangLiang.short_id); + douyinBean.setShort_name(ChangLiang.short_name); + if (null != douyinDao.queryByCustom("short_id", douyinBean.getShort_id()) && douyinDao.queryByCustom("short_id", douyinBean.getShort_id()).size() > 0) { + douyinDao.updateData(douyinBean); + } else { + douyinDao.addInsert(douyinBean); + } + + AblViewUtil.mySleep(2); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + } + + private void getdouyin() { + int num = 0; + accessibilityNodeInfos = new ArrayList<>(); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + nodeZuobiao(child); + Rect rect = new Rect(); + child.getBoundsInScreen(rect); + //(547,1437),(613,1510) + if (rect.top >= 564 && rect.bottom <= 743) { + if ("android.widget.TextView".equals(child.getClassName())) { + if (num < 3) { + accessibilityNodeInfos.add(child); + num = num + 1; + } + } + } + } + } +} + + diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep10.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep10.java new file mode 100644 index 0000000..ee83cbf --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep10.java @@ -0,0 +1,229 @@ +package com.fisherbone.fuzhu.step; + +import android.accessibilityservice.AccessibilityService; +import android.accessibilityservice.GestureDescription; +import android.graphics.Path; +import android.graphics.Rect; +import android.os.Build; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import androidx.annotation.RequiresApi; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.RandumInt; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; + +import java.util.List; + +/** + * @param + * @description 幢号 + * @return + */ +public class TestAblStep10 extends BaseAblStep { + @Override + public void onStep(int step, Message msg) { + switch (step) { + case AblSteps.STEP_22: + AblViewUtil.startApplication(); + AblService instance = AblService.getInstance(); + AblViewUtil.mySleep(10); + //通过坐标点的方式获得node节点id + if(ChangLiang.phonetype.equals("0")){ + instance.clickPoint(648,1286, 300);//红米7a + }else { + instance.clickPoint(648,1536, 300);//华为畅享20 [632,1521][664,1552] + } + Log.e("TIAOSHI###", "点击了我按钮"); + + //等待2秒点击➕朋友[540,274][688,346] + AblViewUtil.mySleep(2); + if(ChangLiang.phonetype.equals("0")){ + instance.clickPoint(614,310, 300);//红米7a + }else { + instance.clickPoint(614,298, 300);//华为畅享20 [540,262][688,334] + } + AblViewUtil.mySleep(2); + + //处理发现通讯好好友的弹框 +// AccessibilityNodeInfo friend = AblViewUtil.findByText("发现好友", 0); +// if(friend==null){ +// Log.e("TIAOSHI###", "没有找到发现好友的按钮" ); +// AblStepHandler.sendMsg(AblSteps.STEP_26); +// }else { +// AblService.getInstance().clickcommontwo(friend, "发现好友"); +// AblViewUtil.mySleep(2); +// AblStepHandler.sendMsg(AblSteps.STEP_26); +// } + AblStepHandler.sendMsg(AblSteps.STEP_26); + + + break; + case AblSteps.STEP_26: + Log.e("TIAOSHI###", "26执行了" ); + //点击查看通讯录好友[540,274][688,346] + AblViewUtil.mySleep(2); + if(ChangLiang.phonetype.equals("0")){ + AblService.getInstance().clickPoint(388,306, 300);//红米7a + }else { + AblService.getInstance().clickPoint(316,304, 300);//华为畅享20 [152,262][480,347] + } + AblViewUtil.mySleep(2); + //查看手机通讯录中的好友列表是否为空,如果为空的话停止无障碍服务,结束任务。否则执行点关注的操作。 + //处理发现通讯好好友的弹框 + AccessibilityNodeInfo liebiaokong = AblViewUtil.findByText("列表为空", 0); + if(liebiaokong==null){ + Log.e("TIAOSHI###", "手机通讯录有数据" ); + AblStepHandler.sendMsg(AblSteps.STEP_23); + }else { + Log.e("TIAOSHI###", "手机通讯录无数据" ); + AblViewUtil.back(); + AblViewUtil.onMessage("停止"); + + } + break; + case AblSteps.STEP_23: + + AblViewUtil.mySleep(3); + Guanzhu(AblService.getInstance()); + break; + case AblSteps.STEP_24: + //获取一屏幕数据:快照 + AccessibilityNodeInfo roott = AblService.getInstance().getRootInActiveWindow(); + List idsj = roott.findAccessibilityNodeInfosByText("暂时没有更多了"); + if (idsj.size() > 0) { + AccessibilityNodeInfo accessibilityNodeInfo = idsj.get(0); + CharSequence text1 = accessibilityNodeInfo.getText(); + if (text1.equals("暂时没有更多了")) { + ChangLiang.zishuodong = "F"; + AblViewUtil.back(); + } + } + if (ChangLiang.zishuodong.equals("T")) { + AblViewUtil.mySleep(1); + randomSwipe(); + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_23); + } + break; + default: + + } + } + + + private void Guanzhu(AblService instance) { + // 在关注列表中,遍历寻找【已关注】的用户,点击【已关注】进行取关; + AblViewUtil.mySleep(2); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); + if("android.widget.LinearLayout".equals(child2.getClassName())) { + int childCount = child2.getChildCount(); + AccessibilityNodeInfo child4 = child2.getChild(childCount - 1); + AblViewUtil.mySleep(1); + String s = child4.getText().toString(); + if(s.equals("关注")||s.equals("回关")) { + clickcommonthree(child4, "关注"); + AblViewUtil.mySleep(2); + //关闭修改备注 + AccessibilityNodeInfo cancanl = AblViewUtil.findByText("取消", 0); + clickcommonfour(cancanl, "取消"); + AblViewUtil.mySleep(3); + } + } + } + } + } + } + + //向上滑动 + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_24); + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickcommonthree(AccessibilityNodeInfo accessibilityNodeInfo, String s) { + if (accessibilityNodeInfo != null) { + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮"); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮,直接退出了。。。。"); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_14); + } + } + + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickcommonfour(AccessibilityNodeInfo accessibilityNodeInfo, String s) { + if (accessibilityNodeInfo != null) { + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮"); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮,直接退出了。。。。"); + AblViewUtil.mySleep(2); + } + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void randomSwipe() { + int a = 170 + RandumInt.getRandumInt4() * 8; + int b = 170 - RandumInt.getRandumInt4() * 10; + int c = 1200 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 + int d = 400 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 320); //延迟330毫秒 + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void swipe(float x1, float y1, float x2, float y2, long duration) { + Path path = new Path(); + path.moveTo(x1, y1); + path.lineTo(x2, y2); + + Log.e("TIAOSHI###", "MyAccessibilityService中滑动swipe()方法滑动点,reset:(" + x1 + "," + y1 + "),(" + x2 + "," + y2 + ")" + "滑动的时长是:" + duration); + GestureDescription.Builder builder = new GestureDescription.Builder(); + GestureDescription gestureDescription = builder + .addStroke(new GestureDescription.StrokeDescription(path, 0, duration)) + .build(); + boolean b = AblService.getInstance().dispatchGesture(gestureDescription, new AccessibilityService.GestureResultCallback() { + @Override + public void onCompleted(GestureDescription gestureDescription) { + super.onCompleted(gestureDescription); + Log.e("TIAOSHI###", "滑动结束..." + gestureDescription.getStrokeCount()); + + } + + @Override + public void onCancelled(GestureDescription gestureDescription) { + super.onCancelled(gestureDescription); + Log.e("TIAOSHI###", "滑动取消"); + } + }, null); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep12.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep12.java new file mode 100644 index 0000000..dec87a6 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep12.java @@ -0,0 +1,863 @@ +package com.fisherbone.fuzhu.step; + +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.fisherbone.fuzhu.utils.EmojiFilter; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import io.reactivex.Observable; +import io.reactivex.Observer; +import io.reactivex.disposables.Disposable; +import io.reactivex.functions.Consumer; +import io.reactivex.functions.Predicate; + +/** + * @param + * @description 切换抖音帐号的逻辑 + * @return + */ +public class TestAblStep12 extends BaseAblStep { + + private List accessibilityNodeInfos; + private List accessibilityNodeInfoss; + private List NodeInfos; + private int success = 1000; + private JSONObject jsonObject; + private String huozannum; + private String guanzhunum; + private String fensinum; + private String zuopinnum; + private AccessibilityNodeInfo child3; + + @Override + public void onStep(int step, Message msg) { + switch (step) { + case AblSteps.STEP_90: + AblViewUtil.startApplication(); + AblStepHandler.sendMsg(AblSteps.STEP_91); + break; + case AblSteps.STEP_91://获取验证码 + + AblService instance = AblService.getInstance(); + AblViewUtil.mySleep(10); + //通过坐标点的方式获得node节点id + instance.clickPoint(648, 1286, 300); + Log.e("TIAOSHI###", "点击了我按钮"); + + AblViewUtil.mySleep(4); + // closedDialog(instance); + + + //等待2秒点击更多按钮([624,75][688,139]) + AblViewUtil.mySleep(2); + //通过id的方式获得node节点id + instance.clickPoint(656, 107, 300); + Log.e("TIAOSHI###", "点击了更多按钮"); + + //等待2秒点击设置按钮([220,1023][720,1143]) + AblViewUtil.mySleep(2); + //通过id的方式获得node节点id + instance.clickPoint(470, 1083, 300); + Log.e("TIAOSHI###", "点击了设置按钮"); + + //等待2秒向上滑动 + AblViewUtil.mySleep(2); + instance.randomSwipe(); + + //等待2秒点击切换账户 + AblViewUtil.mySleep(2); + // instance.clickPoint(360, 964, 300); + //点击切换帐号 + AccessibilityNodeInfo zhidao = AblViewUtil.findByText("切换帐号", 0); + instance.clickcommontwo(zhidao, "切换帐号"); + AblViewUtil.mySleep(2); + Log.e("TIAOSHI###", "----ewrwerwe:"); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); + if ("android.widget.TextView".equals(child2.getClassName())) { + if (child2.getText().equals("添加帐号")) { + AccessibilityNodeInfo child3 = child1.getChild(j); + instance.clickcommontwo(child3, "添加账号"); + } + } + } + } + } + AblViewUtil.mySleep(2); + //复制文本粘贴在留言板 + AccessibilityNodeInfo findcomentt = phoneEditview(); + AblViewUtil.paste(findcomentt, ChangLiang.phonenum); + AblViewUtil.mySleep(2); + AccessibilityNodeInfo yanzhengma = yanzhengma(); + instance.clickcommontwo(yanzhengma, "获取短信验证码"); + AblViewUtil.mySleep(2); + //页面判断,是在输入验证码页面还是在发送短信页面 + AccessibilityNodeInfo yanzhenginfo = AblViewUtil.findByText("请输入验证码", 0); + if (yanzhenginfo == null) {//在发送短信的页面 + getduanxinyanzheng(); + AccessibilityNodeInfo accessibilityNodeInfo = NodeInfos.get(6); + String code_phone = accessibilityNodeInfo.getText().toString(); + Log.e("TIAOSHI###", code_phone); + AccessibilityNodeInfo accessibilityNodeInfo1 = NodeInfos.get(4); + String code = accessibilityNodeInfo1.getText().toString(); + Log.e("TIAOSHI###", code); + + + sendCode(ChangLiang.phonenum,"2",code,code_phone); + }else {//在发送验证码的页面 + sendCode(ChangLiang.phonenum,"1","",""); + } + break; + case AblSteps.STEP_98://粘贴验证码 + + + //复制文本粘贴在验证码框 + AccessibilityNodeInfo findcomenttt = phoneEditviewtwo(); + AblViewUtil.paste(findcomenttt, ChangLiang.code); + //到此动作抖音已经开始跳转页面了 + AblViewUtil.mySleep(5); + //确认抖音是否还在输入验证码的页面 + AblStepHandler.sendMsg(AblSteps.STEP_100); + + break; + case AblSteps.STEP_99://切换回之前的账号 + AblViewUtil.startApplication(); + AblViewUtil.mySleep(5); + instance = AblService.getInstance(); + //等待2秒点击更多按钮([624,75][688,139]) + AblViewUtil.mySleep(2); + //通过id的方式获得node节点id + instance.clickPoint(656, 107, 300); + Log.e("TIAOSHI###", "点击了更多按钮"); + + //等待2秒点击设置按钮([220,1023][720,1143]) + AblViewUtil.mySleep(2); + //通过id的方式获得node节点id + instance.clickPoint(470, 1083, 300); + Log.e("TIAOSHI###", "点击了设置按钮"); + + //等待2秒向上滑动 + AblViewUtil.mySleep(2); + instance.randomSwipe(); + + //等待2秒点击切换账户 + AblViewUtil.mySleep(2); + instance.clickPoint(360, 964, 300); + AblViewUtil.mySleep(2); + //等待2秒点击切换账户 + AblViewUtil.mySleep(2); + AblService.getInstance().clickPoint(360, 399, 300); + AblViewUtil.mySleep(5); + Log.e("TIAOSHI###", "测试停止1"); + AblViewUtil.mesagefinish("停止"); + break; + case AblSteps.STEP_100://效验验证码是否正确 + AccessibilityNodeInfo yazhenginfo = AblViewUtil.findByText("请输入验证码", 0); + if (yazhenginfo == null) { + Log.e("TIAOSHI###", "页面不在输入验证码页面,成功"); + //这里需要判断一个发现通讯录的页面,有则关调,没有则继续往下执行 + AccessibilityNodeInfo tongxunlu = AblViewUtil.findByText("查看通讯录", 0); + if (tongxunlu != null) { + Log.e("TIAOSHI###", "进入了查看通讯录页面"); + AccessibilityNodeInfo tiaoguo = AblViewUtil.findByText("跳过", 0); + AblViewUtil.mySleep(1); + AblService.getInstance().clickcommontwo(tiaoguo, "跳过"); + AblViewUtil.mySleep(1); + } + AblStepHandler.sendMsg(AblSteps.STEP_101); + } else { + find(); + Log.e("TIAOSHI###", "页面在输入验证码页面,失败"); + AccessibilityNodeInfo accessibilityNodeInfo = accessibilityNodeInfoss.get(4); + String ss = accessibilityNodeInfo.getText().toString(); + Log.e("TIAOSHI###", "获得的失败原因==" + ss); + loginResult(ChangLiang.phonenum, "", "", "2", ss); + + //让服务暂停 + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "测试停止4"); + AblViewUtil.mesagefinish("停止"); + } + + break; + case AblSteps.STEP_101://登录成功后把抖音号和昵称传给后台 + AblViewUtil.mySleep(5); + //通过坐标点的方式获得node节点id + AblService.getInstance().clickPoint(648, 1286, 300); + Log.e("TIAOSHI###", "点击了我按钮"); + //检查是否有弹框,并关闭所有弹窗 + //AblService全局处理发现通讯好好友的弹框 + AblViewUtil.mySleep(5); + //获取抖音号 + getdouyin(); + getargone(); + getargfour(); + AblViewUtil.mySleep(2); + AccessibilityNodeInfo accessibilityNodeInfoo = accessibilityNodeInfos.get(2); + String str = accessibilityNodeInfoo.getText().toString(); + String[] all = str.split(":"); + Log.e("TIAOSHI###", "获得的抖音号==" + all[1]); + AccessibilityNodeInfo accessibilityNodeInfo = accessibilityNodeInfos.get(1); + String s = accessibilityNodeInfo.getText().toString(); + String s1 = EmojiFilter.filterEmoji(s);//去除字符串中包含的表情符号 + Log.e("TIAOSHI###", "获得的抖音号昵称==" + s1); + loginResult(ChangLiang.phonenum, all[1], s1, "1", ""); + AblStepHandler.sendMsg(AblSteps.STEP_99); + //让服务暂停 + // AblStepHandler.getInstance().setStop(true); + break; + + case AblSteps.STEP_102://再次发送验证码 + //点击重新发送验证码 + AccessibilityNodeInfo chongxin = AblViewUtil.findByText("重新发送", 0); + AblService.getInstance().clickcommontwo(chongxin, "重新发送"); + AblViewUtil.mySleep(2); + //等待55秒获取验证码 + // daojishifirst(55, ChangLiang.phonenum); + lunxungetcode(ChangLiang.phonenum); + break; + case AblSteps.STEP_103: + AblService.getInstance().inputClickId("已发送短信");//红米7a + AblStepHandler.sendMsg(AblSteps.STEP_104); + break; + case AblSteps.STEP_104://效验验证码是否正确 + AblViewUtil.mySleep(5); + AccessibilityNodeInfo duanxininfo = AblViewUtil.findByText("短信验证登录", 0); + if (duanxininfo == null) { + Log.e("TIAOSHI###", "页面不在输入验证码页面,成功"); + AblViewUtil.mySleep(6); + //这里需要判断一个发现通讯录的页面,有则关调,没有则继续往下执行 + AccessibilityNodeInfo tongxunlu = AblViewUtil.findByText("查看通讯录", 0); + if (tongxunlu != null) { + Log.e("TIAOSHI###", "进入了查看通讯录页面"); + AccessibilityNodeInfo tiaoguo = AblViewUtil.findByText("跳过", 0); + AblViewUtil.mySleep(1); + AblService.getInstance().clickcommontwo(tiaoguo, "跳过"); + AblViewUtil.mySleep(1); + } + AblStepHandler.sendMsg(AblSteps.STEP_101); + } else { + loginResult(ChangLiang.phonenum, "", "", "2", "未成功"); + + //让服务暂停 + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "测试停止4"); + AblViewUtil.mesagefinish("停止"); + } + + break; + default: + + } + } + + + + private void getdouyin() { + int num = 0; + accessibilityNodeInfos = new ArrayList<>(); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("dmt.viewpager.DmtViewPager$MyAccessibilityDelegate".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("android.widget.TabHost".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + // Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); + if ("android.widget.TextView".equals(child3.getClassName())) { + if (num < 3) { + accessibilityNodeInfos.add(child3); + num = num + 1; + } + } + } + } + } + } + } + } + } + + private void find() { + int num = 0; + accessibilityNodeInfoss = new ArrayList<>(); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("android.widget.TextView".equals(child1.getClassName())) { + if (num < 5) { + accessibilityNodeInfoss.add(child1); + num = num + 1; + } + } + + } + } + } + + /** + * 寻找+获取短信验证码 + */ + private AccessibilityNodeInfo yanzhengma() { + AccessibilityNodeInfo infooos = null; + AccessibilityNodeInfo rootttt = AblService.getInstance().getRootInActiveWindow(); + for (int j = 0; j < rootttt.getChildCount(); j++) { + AccessibilityNodeInfo child = rootttt.getChild(j); + Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----2Node:" + child1.getClassName() + ":" + child1.getText()); + if ("android.widget.LinearLayout".equals(child1.getClassName())) { + infooos = child.getChild(y); + } + } + } + + return infooos; + } + + + /** + * 寻找+电话输入框 + */ + private AccessibilityNodeInfo phoneEditview() { + AccessibilityNodeInfo infooos = null; + AccessibilityNodeInfo rootttt = AblService.getInstance().getRootInActiveWindow(); + for (int j = 0; j < rootttt.getChildCount(); j++) { + AccessibilityNodeInfo child = rootttt.getChild(j); + // Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----2Node:" + child1.getClassName() + ":" + child1.getText()); + if ("android.widget.EditText".equals(child1.getClassName())) { + infooos = child.getChild(y); + } + } + } + + return infooos; + } + + /** + * 验证码输入框 + */ + private AccessibilityNodeInfo phoneEditviewtwo() { + AccessibilityNodeInfo infooos = null; + AccessibilityNodeInfo rootttt = AblService.getInstance().getRootInActiveWindow(); + for (int j = 0; j < rootttt.getChildCount(); j++) { + AccessibilityNodeInfo child = rootttt.getChild(j); + // Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----2Node:" + child1.getClassName() + ":" + child1.getText()); + if ("android.widget.EditText".equals(child1.getClassName())) { + infooos = child.getChild(y); + } + } + } + + return infooos; + } + + + /** + * 2、获取到账号登录紧急任务,需要用户发送验证码或短信 -- 阿童木调取蜂狐接口 + */ + private void sendCode(String phone,String type,String code,String code_phone) { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("phone", phone);//手机号 + paramsPost.put("type", type);//确认类型 1:提交验证码 2:确认短信发送成功 + paramsPost.put("code", code);//发送的内容 + paramsPost.put("code_phone", code_phone);//发送至的手机 + // new NetApi().getPostData(paramsPost, "http://192.168.1.3/app/Appscanlogin/sendCode").subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_sendCode).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if (success.equals("0")) { + Log.e("TIAOSHI###", "获取到账号登录紧急任务,需要用户发送验证码或短信 -- 阿童木调取蜂狐接口==" + msg); + // daojishifirst(55, phone); + lunxungetcode(phone); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + /** + * app获取验证短信或验证码 + */ + private void getCode(String phone) { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("phone", phone);// 拿到的抖音id + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_getCode).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + success = jsonObject.getInt("success"); + JSONObject data = jsonObject.getJSONObject("data"); + String code = data.getString("code"); + String type = data.getString("type"); + Log.e("TIAOSHI###", "收到验证码" + code); + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + /** + * 账号登录结果 -- 阿童木调蜂狐接口 + */ + private void loginResult(String phone, String short_id, String short_name, String result_type, String result) { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("phone", phone);//手机号 + paramsPost.put("short_id", short_id);//抖音号 + paramsPost.put("short_name", short_name);//抖音名称 + paramsPost.put("result_type", result_type);//结果类型 + paramsPost.put("result", result);//失败原因 + + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_loginResult).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String successs = jsonObject.getString("success"); + fasStatistics(short_id,huozannum,guanzhunum,fensinum,zuopinnum); + + ChangLiang.task_type = ""; + ChangLiang.istask = false; + ChangLiang.isstart="0"; + success = 1000; + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + + + + /** + * 抖音加粉托管账号每日数据统计 + */ + private void fasStatistics(String short_id, String hz_num,String gz_num, String fs_num,String zp_num) { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("short_id", short_id);//抖音号 + paramsPost.put("hz_num", hz_num);//获赞量 + paramsPost.put("gz_num", gz_num);//关注量 + paramsPost.put("fs_num", fs_num);//粉丝量 + paramsPost.put("zp_num", zp_num);//作品量 + + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_fasStatistics).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if (success.equals("0")) { + Log.e("TIAOSHI###", "获取到账号登录紧急任务,需要用户发送验证码或短信 -- 阿童木调取蜂狐接口==" + msg); + + + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + + /** + * 6、再次发送验证码结果 -- 阿童木调取蜂狐接口 + */ + private void againLoginResult(String phone, String result) { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("phone", phone);//手机号 + paramsPost.put("result", result);//失败原因 + + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appscanlogin_againLoginResult).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if (success.equals("0")) { + Log.e("TIAOSHI###", "获取到账号登录紧急任务,需要用户发送验证码或短信 -- 阿童木调取蜂狐接口==" + msg); + // daojishifirst(55, phone); + lunxungetcode(phone); + + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + private void lunxungetcode(String phone) { + + /* + * 步骤1:采用interval()延迟发送 + * 注:此处主要展示无限次轮询,若要实现有限次轮询,仅需将interval()改成intervalRange()即可 + **/ + // Observable.interval(2, 10, TimeUnit.SECONDS) + Observable.intervalRange(2, 17, 0, 5, TimeUnit.SECONDS) + // 参数说明: + // 参数1 = 第1次延迟时间; + // 参数2 = 间隔时间数字; + // 参数3 = 时间单位; + // 该例子发送的事件特点:延迟2s后发送事件,每隔1秒产生1个数字(从0开始递增1,无限个) + + /* + * 步骤2:每次发送数字前发送1次网络请求(doOnNext()在执行Next事件前调用) + * 即每隔1秒产生1个数字前,就发送1次网络请求,从而实现轮询需求 + **/ + .doOnNext(new Consumer() { + @Override + public void accept(Long integer) throws Exception { + Log.e("TIAOSHI###", "活动验证码轮询第 " + integer + " 次轮询"); + getCode(phone); + } + + + }) + .takeWhile(new Predicate() {//observable.takUtil(condition),当condition == false的时候终止,不包含临界条件的item 不停地获取数据,直到[满足/不满足]某个条件时终止 + @Override + public boolean test(Long aLong) throws Exception { + if (success==0) { + Log.e("TIAOSHI###", "返回false"); + return false; + } else { + Log.e("TIAOSHI###", "true"); + return true; + } + } + }) + .subscribe(new Observer() { + @Override + public void onSubscribe(Disposable d) { + + } + + @Override + public void onNext(Long value) { + + } + + @Override + public void onError(Throwable e) { + Log.d("TAG", "对Error事件作出响应"); + } + + @Override + public void onComplete() { + Log.d("TAG", "对Complete事件作出响应"); + switch (success) { + case 0: + try { + JSONObject data = jsonObject.getJSONObject("data"); + String code = data.getString("code"); + String type = data.getString("type"); + + Log.e("TIAOSHI###", "收到验证码2" + code); + ChangLiang.code = code; + //切换到我 + //获取抖音号 + if(type.equals("1")){ + AblStepHandler.sendMsg(AblSteps.STEP_98); + } + if(type.equals("2")){ + AblStepHandler.sendMsg(AblSteps.STEP_103); + } + } catch (JSONException e) { + e.printStackTrace(); + } + + break; + case 1: + Log.e("TIAOSHI###", "请指定手机号"); + loginResult(ChangLiang.phonenum, "", "", "2", "请指定手机号"); + //让服务暂停 + AblStepHandler.getInstance().setStop(true); + break; + case 2: + Log.e("TIAOSHI###", "请重新发送验证码"); + AblStepHandler.sendMsg(AblSteps.STEP_102); + break; + case 3: + Log.e("TIAOSHI###", "没收到验证码,请稍等"); + loginResult(ChangLiang.phonenum, "", "", "2", "没收到验证码,请稍等"); +// ChangLiang.task_type = ""; +// ChangLiang.istask = false; +// ChangLiang.isstart="0"; + //让服务暂停 + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "测试停止3"); + AblViewUtil.mesagefinish("停止"); + break; + default: + } + } + }); + } + + + /** + * 获得最近作品时间 + */ + private void getargfour() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + //if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + if ("dmt.viewpager.DmtViewPager$MyAccessibilityDelegate".equals(child.getClassName())) { + // Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int j = 0; j < child.getChildCount(); j++) { + AccessibilityNodeInfo child1 = child.getChild(j); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText()); + for (int x = 0; x < child1.getChildCount(); x++) { + AccessibilityNodeInfo child2 = child1.getChild(x); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); + if ("androidx.appcompat.app.ActionBar$Tab".equals(child2.getClassName())) { + for (int y = 0; y < child2.getChildCount(); y++) { + AccessibilityNodeInfo child3 = child2.getChild(y); + String text = child3.getText().toString(); + if (text != null) { + boolean status = text.contains("作品"); + if (status) { + if (text.length() > 2) { + zuopinnum = child3.getText().toString().substring(3); + Log.e("TIAOSHI###", "获得的作品数==" + zuopinnum); + if (!zuopinnum.equals("-") && zuopinnum != null) { + if (Integer.parseInt(zuopinnum) < Integer.parseInt(ChangLiang.Minimumofworks)||Integer.parseInt(zuopinnum)>Integer.parseInt(ChangLiang.maxmumzuopin)) { + Log.e("TIAOSHI###", "获取的该用户作品数"+Integer.parseInt(zuopinnum)+"小于设置的加关作品数(不在区间"+Integer.parseInt(ChangLiang.Minimumofworks)+"-"+Integer.parseInt(ChangLiang.maxmumzuopin)+"),作品数不满足条件"); + AblViewUtil.onMessage("作品数不满足条件"); + ChangLiang.condition = "1"; + return; + }else { + Log.e("TIAOSHI###", "获取的该用户作品数不小于设置的加关作品数,满足加关点赞评论条件"); + } + } + } + } + } + } + } + } + } + // AblViewUtil.mySleep(2); + } + } + } + + + /** + * 获得关注数 + */ + private void getargone() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) {//13.1版本写法 + if ("dmt.viewpager.DmtViewPager$MyAccessibilityDelegate".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // if ("android.widget.LinearLayout".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); + + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child4 = child2.getChild(x); + Log.e("TIAOSHI###", "----fourNode:" + child4.getClassName() + ":" + child4.getText()); + for (int z = 0; z < child4.getChildCount(); z++) { + AccessibilityNodeInfo child5 = child4.getChild(z); + Log.e("TIAOSHI###", "----fiveNode:" + child5.getClassName() + ":" + child5.getText()); + if (child5.getText() != null) { + if (child5.getText().equals("关注")) { + AccessibilityNodeInfo parent = child5.getParent(); + child3 = parent.getChild(0); + Log.e("TIAOSHI###", "获得的关注数==" + child3.getText().toString()); + guanzhunum = child3.getText().toString(); + if (child3.getText().toString().equals("-")) { + Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); + } + //return; + + } + if (child5.getText().equals("获赞")) { + AccessibilityNodeInfo parent = child5.getParent(); + child3 = parent.getChild(0); + Log.e("TIAOSHI###", "获得的获赞数==" + child3.getText().toString()); + huozannum = child3.getText().toString(); + if (child3.getText().toString().equals("-")) { + Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); + } + //return; + + } + if (child5.getText().equals("粉丝")) { + AccessibilityNodeInfo parent = child5.getParent(); + AccessibilityNodeInfo child3 = parent.getChild(0); + Log.e("TIAOSHI###", "获得的粉丝数==" + child3.getText().toString()); + fensinum = child3.getText().toString(); + if (child3.getText().toString().equals("-")) { + Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); + } + return; + } + } + } + } + } + } + } + } + } + + + + + private void getduanxinyanzheng() { + int num = 0; + NodeInfos = new ArrayList<>(); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.TextView".equals(child.getClassName())) { + if (num < 8) { + NodeInfos.add(child); + num = num + 1; + } + } + } + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep13.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep13.java new file mode 100644 index 0000000..c79f70c --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep13.java @@ -0,0 +1,282 @@ +package com.fisherbone.fuzhu.step; + +import android.accessibilityservice.AccessibilityService; +import android.accessibilityservice.GestureDescription; +import android.graphics.Path; +import android.graphics.Rect; +import android.os.Build; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import androidx.annotation.RequiresApi; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.FuzhuApplication; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.RandumInt; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.db.dao.ZhanghaoDao; +import com.fisherbone.fuzhu.db.dao.daoutil; +import com.fisherbone.fuzhu.db.zhuanghaoBeanData; + +import java.util.List; + +/** + * @param + * @description 幢号 + * @return + */ +public class TestAblStep13 extends BaseAblStep { + @Override + public void onStep(int step, Message msg) { + switch (step) { + case AblSteps.STEP_70://点击我的 ,然后点击+朋友 + AblViewUtil.startApplication(); + + + AblService instance = AblService.getInstance(); + AblViewUtil.mySleep(10); + AccessibilityNodeInfo zhidao = AblViewUtil.findByText("我知道了", 0); + if(zhidao==null){ + Log.e("TIAOSHI###", "没有找到我知道了的弹窗" ); + }else { + Log.e("TIAOSHI###", "找到我知道了的弹窗" ); + AblService.getInstance().clickcommontwo(zhidao, "我知道了"); + AblViewUtil.mySleep(2); + } + + //通过坐标点的方式获得node节点id + if(ChangLiang.phonetype.equals("0")){ + instance.clickPoint(648,1286, 300);//红米7a + }else { + instance.clickPoint(648,1536, 300);//华为畅享20 [632,1521][664,1552] + } + Log.e("TIAOSHI###", "点击了我按钮"); + + //等待2秒点击➕朋友[540,274][688,346] + AblViewUtil.mySleep(2); + if(ChangLiang.phonetype.equals("0")){ + instance.clickPoint(614,310, 300);//红米7a + }else { + instance.clickPoint(614,298, 300);//华为畅享20 [540,262][688,334] + } + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_71); + + break; + case AblSteps.STEP_71: //处理发现通讯好好友的弹框 + AccessibilityNodeInfo friend = AblViewUtil.findByText("发现好友", 0); + if(friend==null){ + Log.e("TIAOSHI###", "没有找到发现好友的按钮" ); + AblStepHandler.sendMsg(AblSteps.STEP_72); + }else { + Log.e("TIAOSHI###", "找到发现好友的按钮" ); + AblService.getInstance().clickcommontwo(friend, "发现好友"); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_72); + } + + break; + case AblSteps.STEP_72: //点击查看通讯录好友 + //点击查看通讯录好友[540,274][688,346] + AblViewUtil.mySleep(2); + if(ChangLiang.phonetype.equals("0")){ + AblService.getInstance().clickPoint(388,306, 300);//红米7a + }else { + AblService.getInstance().clickPoint(316,304, 300);//华为畅享20 [152,262][480,347] + } + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_73); + AblViewUtil.mySleep(2); + break; + case AblSteps.STEP_73: //处理列表为空情况 + //查看手机通讯录中的好友列表是否为空,如果为空的话停止无障碍服务,结束任务。否则执行点关注的操作。 + //处理发现通讯好好友的弹框 + AccessibilityNodeInfo liebiaokong = AblViewUtil.findByText("列表为空", 0); + if(liebiaokong==null){ + Log.e("TIAOSHI###", "手机通讯录有数据" ); + AblStepHandler.sendMsg(AblSteps.STEP_74); + }else { + Log.e("TIAOSHI###", "手机通讯录无数据" ); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + //通过坐标点的方式获得node节点id + if(ChangLiang.phonetype.equals("0")){ + AblService.getInstance().clickPoint(72,1286, 300);//红米7a + }else { + // AblService.getInstance().clickPoint(648,1536, 300);//华为畅享20 [632,1521][664,1552] + } + Log.e("TIAOSHI###", "点击了首页按钮"); + + AblViewUtil.zhuanghaoMessage("停止"); + } + + break; + case AblSteps.STEP_74: //处理列表为空情况 + AblViewUtil.mySleep(3); + Guanzhu(AblService.getInstance()); + break; + case AblSteps.STEP_75: + //获取一屏幕数据:快照 + AccessibilityNodeInfo roott = AblService.getInstance().getRootInActiveWindow(); + List idsj = roott.findAccessibilityNodeInfosByText("暂时没有更多了"); + if (idsj.size() > 0) { + AccessibilityNodeInfo accessibilityNodeInfo = idsj.get(0); + CharSequence text1 = accessibilityNodeInfo.getText(); + if (text1.equals("暂时没有更多了")) { + ChangLiang.zishuodong = "F"; + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + //通过坐标点的方式获得node节点id + if(ChangLiang.phonetype.equals("0")){ + AblService.getInstance().clickPoint(72,1286, 300);//红米7a + }else { + // AblService.getInstance().clickPoint(648,1536, 300);//华为畅享20 [632,1521][664,1552] + } + Log.e("TIAOSHI###", "点击了首页按钮"); + + AblViewUtil.zhuanghaoMessage("停止"); + } + } + if (ChangLiang.zishuodong.equals("T")) { + AblViewUtil.mySleep(1); + randomSwipe(); + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_74); + } + break; + default: + } + } + private void Guanzhu(AblService instance) { + // 在关注列表中,遍历寻找【已关注】的用户,点击【已关注】进行取关; + AblViewUtil.mySleep(2); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); + if("android.widget.LinearLayout".equals(child2.getClassName())) { + int childCount = child2.getChildCount(); + AccessibilityNodeInfo child7 = child2.getChild(1); + String s1 = child7.getText().toString(); + Log.e("TIAOSHI###", "----servenNode:" + s1); + AccessibilityNodeInfo child4 = child2.getChild(childCount - 1); + AblViewUtil.mySleep(1); + String s = child4.getText().toString(); + Log.e("TIAOSHI###", "----servenNode:" + s); + if(s.equals("关注")||s.equals("回关")) { + clickcommonthree(child4, "关注"); + // 修改数据库状态 + ZhanghaoDao instance1 = daoutil.getInstance(FuzhuApplication.getContext()); + List zhuanghaoBeanData = instance1.queryByCustom("name", s1); + if(zhuanghaoBeanData.size()>0) { + com.fisherbone.fuzhu.db.zhuanghaoBeanData zhuanghaoBeanData1 = zhuanghaoBeanData.get(0); + zhuanghaoBeanData1.setIsjiaguan("1"); + instance1.updateData(zhuanghaoBeanData1); + } + AblViewUtil.mySleep(2); + //关闭修改备注 + AccessibilityNodeInfo cancanl = AblViewUtil.findByText("确认", 0); + clickcommonfour(cancanl, "确认"); + AblViewUtil.mySleep(3); + } + } + } + } + } + } + + //向上滑动 + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_75); + } + + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickcommonthree(AccessibilityNodeInfo accessibilityNodeInfo, String s) { + if (accessibilityNodeInfo != null) { + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮"); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮,直接退出了。。。。"); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_75); + } + } + + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickcommonfour(AccessibilityNodeInfo accessibilityNodeInfo, String s) { + if (accessibilityNodeInfo != null) { + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮"); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮,直接退出了。。。。"); + AblViewUtil.mySleep(2); + } + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void randomSwipe() { + int a = 170 + RandumInt.getRandumInt4() * 8; + int b = 170 - RandumInt.getRandumInt4() * 10; + int c = 1200 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 + int d = 400 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 320); //延迟330毫秒 + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void swipe(float x1, float y1, float x2, float y2, long duration) { + Path path = new Path(); + path.moveTo(x1, y1); + path.lineTo(x2, y2); + + Log.e("TIAOSHI###", "MyAccessibilityService中滑动swipe()方法滑动点,reset:(" + x1 + "," + y1 + "),(" + x2 + "," + y2 + ")" + "滑动的时长是:" + duration); + GestureDescription.Builder builder = new GestureDescription.Builder(); + GestureDescription gestureDescription = builder + .addStroke(new GestureDescription.StrokeDescription(path, 0, duration)) + .build(); + boolean b = AblService.getInstance().dispatchGesture(gestureDescription, new AccessibilityService.GestureResultCallback() { + @Override + public void onCompleted(GestureDescription gestureDescription) { + super.onCompleted(gestureDescription); + Log.e("TIAOSHI###", "滑动结束..." + gestureDescription.getStrokeCount()); + + } + + @Override + public void onCancelled(GestureDescription gestureDescription) { + super.onCancelled(gestureDescription); + Log.e("TIAOSHI###", "滑动取消"); + } + }, null); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep15.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep15.java new file mode 100644 index 0000000..e040281 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep15.java @@ -0,0 +1,514 @@ +package com.fisherbone.fuzhu.step; + +import android.accessibilityservice.AccessibilityService; +import android.accessibilityservice.GestureDescription; +import android.graphics.Path; +import android.graphics.Rect; +import android.os.Build; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import androidx.annotation.RequiresApi; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.FuzhuApplication; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.RandumInt; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.db.dao.ZhanghaoDao; +import com.fisherbone.fuzhu.db.dao.daoutil; +import com.fisherbone.fuzhu.db.zhuanghaoBeanData; + +import java.util.List; + +/** + * @param + * @description 幢号(之前有个取消所有关注和互关的操作) + * @return + */ +public class TestAblStep15 extends BaseAblStep { + + private AccessibilityNodeInfo child3; + private AblService instance; + + + @Override + public void onStep(int step, Message msg) { + switch (step) { + case AblSteps.STEP_140: + AblViewUtil.startApplication(); + instance = AblService.getInstance(); + AblViewUtil.mySleep(10); + closedQDialog(instance);//关闭我知道了弹窗 + AblStepHandler.sendMsg(AblSteps.STEP_141); + break; + case AblSteps.STEP_141: + ChangLiang.ishuodong = "T"; + AblViewUtil.mySleep(5); + //1.关闭广告 + //2.关闭青少年弹窗 + //3.点击我的 + myClick(); + AblViewUtil.mySleep(2); + getargone(); + //点击进入用户关注页 + AblViewUtil.mySleep(2); + AblService.getInstance().clickcommontwo(child3, "进入用户关注页"); + AblStepHandler.sendMsg(AblSteps.STEP_142); + break; + case AblSteps.STEP_142: + cancelGuanzhu(AblService.getInstance()); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_143); + break; + case AblSteps.STEP_143: + //获取一屏幕数据:快照 + AccessibilityNodeInfo roott = AblService.getInstance().getRootInActiveWindow(); + List idsj = roott.findAccessibilityNodeInfosByText("查找好友并关注"); + if (idsj.size() > 0) { + AccessibilityNodeInfo accessibilityNodeInfo = idsj.get(0); + CharSequence text1 = accessibilityNodeInfo.getText(); + if (text1.equals("查找好友并关注")) { + ChangLiang.ishuodong = "F"; + AblViewUtil.back(); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_144); + } + } + if (ChangLiang.ishuodong.equals("T")) { + AblViewUtil.mySleep(1); + randomSwipe(); + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_142); + } + break; + case AblSteps.STEP_144: + ChangLiang.ishuodong = "T"; + AblViewUtil.mySleep(2); + getargone(); + //点击进入用户关注页 + AblViewUtil.mySleep(2); + AblService.getInstance().clickcommontwo(child3, "进入用户关注页"); + AblStepHandler.sendMsg(AblSteps.STEP_145); + break; + case AblSteps.STEP_145: + cancelXianghu(AblService.getInstance()); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_146); + break; + + case AblSteps.STEP_146: + //获取一屏幕数据:快照 + AccessibilityNodeInfo roottt = AblService.getInstance().getRootInActiveWindow(); + List idsjj = roottt.findAccessibilityNodeInfosByText("查找好友并关注"); + if (idsjj.size() > 0) { + AccessibilityNodeInfo accessibilityNodeInfo = idsjj.get(0); + CharSequence text1 = accessibilityNodeInfo.getText(); + if (text1.equals("查找好友并关注")) { + ChangLiang.ishuodong = "F"; + AblViewUtil.back(); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_150); + } + } + if (ChangLiang.ishuodong.equals("T")) { + AblViewUtil.mySleep(1); + randomSwipe(); + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_145); + } + break; + case AblSteps.STEP_147: + + break; + + case AblSteps.STEP_148: + + break; + case AblSteps.STEP_149: + + break; + + case AblSteps.STEP_150: + + //等待2秒点击➕朋友[540,274][688,346] + AblViewUtil.mySleep(2); + if(ChangLiang.phonetype.equals("0")){ + instance.clickPoint(614,310, 300);//红米7a + }else { + instance.clickPoint(614,298, 300);//华为畅享20 [540,262][688,334] + } + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_151); + + break; + case AblSteps.STEP_151: //处理发现通讯好好友的弹框 + AccessibilityNodeInfo friend = AblViewUtil.findByText("发现好友", 0); + if(friend==null){ + Log.e("TIAOSHI###", "没有找到发现好友的按钮" ); + AblStepHandler.sendMsg(AblSteps.STEP_152); + }else { + Log.e("TIAOSHI###", "找到发现好友的按钮" ); + AblService.getInstance().clickcommontwo(friend, "发现好友"); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_152); + } + + break; + case AblSteps.STEP_152: //点击查看通讯录好友 + //点击查看通讯录好友[540,274][688,346] + AblViewUtil.mySleep(2); + if(ChangLiang.phonetype.equals("0")){ + AblService.getInstance().clickPoint(388,306, 300);//红米7a + }else { + AblService.getInstance().clickPoint(316,304, 300);//华为畅享20 [152,262][480,347] + } + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_153); + AblViewUtil.mySleep(2); + break; + case AblSteps.STEP_153: //处理列表为空情况 + //查看手机通讯录中的好友列表是否为空,如果为空的话停止无障碍服务,结束任务。否则执行点关注的操作。 + //处理发现通讯好好友的弹框 + AccessibilityNodeInfo liebiaokong = AblViewUtil.findByText("列表为空", 0); + if(liebiaokong==null){ + Log.e("TIAOSHI###", "手机通讯录有数据" ); + AblStepHandler.sendMsg(AblSteps.STEP_154); + }else { + Log.e("TIAOSHI###", "手机通讯录无数据" ); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + //通过坐标点的方式获得node节点id + if(ChangLiang.phonetype.equals("0")){ + AblService.getInstance().clickPoint(72,1286, 300);//红米7a + }else { + // AblService.getInstance().clickPoint(648,1536, 300);//华为畅享20 [632,1521][664,1552] + } + Log.e("TIAOSHI###", "点击了首页按钮"); + + AblViewUtil.zhuanghaoMessage("停止"); + } + + break; + case AblSteps.STEP_154: //处理列表为空情况 + AblViewUtil.mySleep(3); + Guanzhu(AblService.getInstance()); + break; + case AblSteps.STEP_155: + //获取一屏幕数据:快照 + AccessibilityNodeInfo rootttt = AblService.getInstance().getRootInActiveWindow(); + List idsjjjj = rootttt.findAccessibilityNodeInfosByText("暂时没有更多了"); + if (idsjjjj.size() > 0) { + AccessibilityNodeInfo accessibilityNodeInfo = idsjjjj.get(0); + CharSequence text1 = accessibilityNodeInfo.getText(); + if (text1.equals("暂时没有更多了")) { + ChangLiang.zishuodong = "F"; + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + //通过坐标点的方式获得node节点id + if(ChangLiang.phonetype.equals("0")){ + AblService.getInstance().clickPoint(72,1286, 300);//红米7a + }else { + // AblService.getInstance().clickPoint(648,1536, 300);//华为畅享20 [632,1521][664,1552] + } + Log.e("TIAOSHI###", "点击了首页按钮"); + + AblViewUtil.zhuanghaoMessage("停止"); + } + } + if (ChangLiang.zishuodong.equals("T")) { + AblViewUtil.mySleep(1); + randomSwipe(); + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_74); + } + break; + default: + } + } + private void Guanzhu(AblService instance) { + // 在关注列表中,遍历寻找【已关注】的用户,点击【已关注】进行取关; + AblViewUtil.mySleep(2); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); + if("android.widget.LinearLayout".equals(child2.getClassName())) { + int childCount = child2.getChildCount(); + AccessibilityNodeInfo child7 = child2.getChild(1); + String s1 = child7.getText().toString(); + Log.e("TIAOSHI###", "----servenNode:" + s1); + AccessibilityNodeInfo child4 = child2.getChild(childCount - 1); + AblViewUtil.mySleep(1); + String s = child4.getText().toString(); + Log.e("TIAOSHI###", "----servenNode:" + s); + if(s.equals("关注")||s.equals("回关")) { + clickcommonthree(child4, "关注"); + // 修改数据库状态 + ZhanghaoDao instance1 = daoutil.getInstance(FuzhuApplication.getContext()); + List zhuanghaoBeanData = instance1.queryByCustom("name", s1); + if(zhuanghaoBeanData.size()>0) { + com.fisherbone.fuzhu.db.zhuanghaoBeanData zhuanghaoBeanData1 = zhuanghaoBeanData.get(0); + zhuanghaoBeanData1.setIsjiaguan("1"); + instance1.updateData(zhuanghaoBeanData1); + } + AblViewUtil.mySleep(2); + //关闭修改备注 + AccessibilityNodeInfo cancanl = AblViewUtil.findByText("确认", 0); + clickcommonfour(cancanl, "确认"); + AblViewUtil.mySleep(3); + } + } + } + } + } + } + + //向上滑动 + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_155); + } + + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickcommonthree(AccessibilityNodeInfo accessibilityNodeInfo, String s) { + if (accessibilityNodeInfo != null) { + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮"); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮,直接退出了。。。。"); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_75); + } + } + + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickcommonfour(AccessibilityNodeInfo accessibilityNodeInfo, String s) { + if (accessibilityNodeInfo != null) { + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮"); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮,直接退出了。。。。"); + AblViewUtil.mySleep(2); + } + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void randomSwipe() { + int a = 170 + RandumInt.getRandumInt4() * 8; + int b = 170 - RandumInt.getRandumInt4() * 10; + int c = 1200 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 + int d = 400 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 320); //延迟330毫秒 + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void swipe(float x1, float y1, float x2, float y2, long duration) { + Path path = new Path(); + path.moveTo(x1, y1); + path.lineTo(x2, y2); + + Log.e("TIAOSHI###", "MyAccessibilityService中滑动swipe()方法滑动点,reset:(" + x1 + "," + y1 + "),(" + x2 + "," + y2 + ")" + "滑动的时长是:" + duration); + GestureDescription.Builder builder = new GestureDescription.Builder(); + GestureDescription gestureDescription = builder + .addStroke(new GestureDescription.StrokeDescription(path, 0, duration)) + .build(); + boolean b = AblService.getInstance().dispatchGesture(gestureDescription, new AccessibilityService.GestureResultCallback() { + @Override + public void onCompleted(GestureDescription gestureDescription) { + super.onCompleted(gestureDescription); + Log.e("TIAOSHI###", "滑动结束..." + gestureDescription.getStrokeCount()); + + } + + @Override + public void onCancelled(GestureDescription gestureDescription) { + super.onCancelled(gestureDescription); + Log.e("TIAOSHI###", "滑动取消"); + } + }, null); + } + + + + + private void cancelGuanzhu(AblService instance) { + // 取消已关: + // 在关注列表中,遍历寻找【已关注】的用户,点击【已关注】进行取关; + AblViewUtil.mySleep(2); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + //遍历root下的子节点有哪些 + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + AccessibilityNodeInfo child1 = child.getChild(1); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { + for (int x = 0; x < child1.getChildCount(); x++) { + AccessibilityNodeInfo child2 = child1.getChild(x); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + for (int y = 0; y < child2.getChildCount(); y++) { + AccessibilityNodeInfo child3 = child2.getChild(y); + Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + y+child3.getText() + ":" + child3.getContentDescription()); + if (child3.getText().equals("已关注")) { + Log.e("TIAOSHI###", "----fourfive:" + child2.getChildCount()); + AccessibilityNodeInfo child4 = child2.getChild(child2.getChildCount()-1); + AblViewUtil.mySleep(1); + String s = child4.getText().toString(); + if (s.equals("已关注")) { + clickcommontwo(child4, "已关注"); + } + + } + } + } + } + } + } + } + private void cancelXianghu(AblService instance) { + // 取消已关: + // 在关注列表中,遍历寻找【已关注】的用户,点击【已关注】进行取关; + AblViewUtil.mySleep(2); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + //遍历root下的子节点有哪些 + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + AccessibilityNodeInfo child1 = child.getChild(1); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { + for (int x = 0; x < child1.getChildCount(); x++) { + AccessibilityNodeInfo child2 = child1.getChild(x); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + Log.e("TIAOSHI###", "----异常报错数:" + child2.getChildCount()); + for (int y = 0; y < child2.getChildCount(); y++) { + AccessibilityNodeInfo child3 = child2.getChild(y); + Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + y+child3.getText() + ":" + child3.getContentDescription()); + if (child3.getText().equals("互相关注")) { + Log.e("TIAOSHI###", "----fourfive:" + child2.getChildCount()); + AccessibilityNodeInfo child4 = child2.getChild(child2.getChildCount()-1); + AblViewUtil.mySleep(1); + String s = child4.getText().toString(); + if (s.equals("互相关注")) { + clickcommontwo(child4, "互相关注"); + } + + } + } +// for (int y = 0; y < child2.getChildCount(); y++) { +// AccessibilityNodeInfo child3 = child2.getChild(y); +// Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child3.getContentDescription()); +// if (child3.getText() != null) { +// if (child3.getText().equals("互相关注")) { +// AccessibilityNodeInfo child4 = child2.getChild(0); +// AccessibilityNodeInfo parent1 = child4.getParent(); +// AblViewUtil.mySleep(1); +// if(child2!=null) { +// instance.clickcommontwo(child2, "互相关注"); +// Log.e("TIAOSHI###", "点击了互相关注的条目,进入详情页面"); +// //条件不满足点击互相关注 +// AblViewUtil.mySleep(3); +// AccessibilityNodeInfo infos = AblViewUtil.findByText("互相关注", 0); +// AblService.getInstance().clickcommontwo(infos, "互相关注"); +// AblViewUtil.mySleep(2); +// //点击取消关注 +// AccessibilityNodeInfo quxiao = AblViewUtil.findByText("取消关注", 0); +// AblService.getInstance().clickcommontwo(quxiao, "取消关注"); +// AblViewUtil.mySleep(2); +// //返回上一页 +// AblViewUtil.back(); +// } +// } +// } +// } + + } + } + } + } + + //向上滑动 + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_18); + } + + + /** + * 获得关注数 + */ + private void getargone() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // if ("android.widget.LinearLayout".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); + + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child4 = child2.getChild(x); + Log.e("TIAOSHI###", "----fourNode:" + child4.getClassName() + ":" + child4.getText()); + for (int z = 0; z < child4.getChildCount(); z++) { + AccessibilityNodeInfo child5 = child4.getChild(z); + Log.e("TIAOSHI###", "----fiveNode:" + child5.getClassName() + ":" + child5.getText()); + if (child5.getText() != null) { + if (child5.getText().equals("关注")) { + AccessibilityNodeInfo parent = child5.getParent(); + child3 = parent.getChild(0); + Log.e("TIAOSHI###", "获得的关注数==" + child3.getText().toString()); + String guanzhunum = child3.getText().toString(); + if (child3.getText().toString().equals("-")) { + Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); + } + return; + } + + } + } + } + } + } + } + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep18.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep18.java new file mode 100644 index 0000000..da3fd09 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep18.java @@ -0,0 +1,78 @@ +package com.fisherbone.fuzhu.step; + +import android.accessibilityservice.AccessibilityService; +import android.accessibilityservice.GestureDescription; +import android.os.Message; +import android.util.Log; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.callback.GestureCallBack; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; + +/** + * 退出抖音 + */ +public class TestAblStep18 extends BaseAblStep { + @Override + public void onStep(int step, Message msg) { + switch (step) { + case AblSteps.STEP_192: + AblViewUtil.startApplication(); + AblStepHandler.sendMsg(AblSteps.STEP_193); + break; + case AblSteps.STEP_193: + AblViewUtil.mySleep(5); + //退出抖音的方案,点击菜单按钮,然后再左滑动退出抖音 + AblService.getInstance().performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS); + AblViewUtil.mySleep(1); + + + if("3".equals(ChangLiang.phonetype)){ + //左滑关闭抖音 + AblViewUtil.scrollHorizontal(380, 20, 100, 300, new GestureCallBack() { + @Override + public void succ(GestureDescription gestureDescription) { + AblViewUtil.mySleep(2); + AblService.getInstance().clickPoint(400, 1000, 300);//红米7a + Log.e("TIAOSHI###", "停止关闭抖音任务"); + AblViewUtil.mesagefinish("停止"); + } + + @Override + public void fail(GestureDescription gestureDescription) { + + } + }); + }else { + //左滑关闭抖音 + //左滑进入个人信息页 + AblViewUtil.scrollHorizontal(300, 20, 100, 300, new GestureCallBack() { + @Override + public void succ(GestureDescription gestureDescription) { + + AblViewUtil.mySleep(2); + if(ChangLiang.phonetype.equals("0")){ + AblService.getInstance().clickPoint(280, 760, 300);//红米7a + }else { + // AblService.getInstance().clickPoint(659, 922, 300);//华为畅享20 + } + + Log.e("TIAOSHI###", "停止关闭抖音任务"); + AblViewUtil.mesagefinish("停止"); + } + + @Override + public void fail(GestureDescription gestureDescription) { + + } + }); + } + break; + default: + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep19.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep19.java new file mode 100644 index 0000000..1d124af --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep19.java @@ -0,0 +1,186 @@ +package com.fisherbone.fuzhu.step; + +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.FuzhuApplication; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.db.CommentBeanData; +import com.fisherbone.fuzhu.db.dao.CommentDao; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +/** + * @param + * @description 关键词加关 + * @return + */ +public class TestAblStep19 extends BaseAblStep { + + private ArrayList objects = new ArrayList<>(); + + + @Override + public void onStep(int step, Message msg) { + switch (step) { + case AblSteps.STEP_110: + //初始化要加关的关键词 + + objects.add("任剑波"); + objects.add("幽兰"); + objects.add("繁华似锦"); + objects.add("芳芳"); + AblViewUtil.startApplication(); + AblViewUtil.mySleep(5); + //1.关闭检测到更新的弹框 + closedJDialog(AblService.getInstance()); + //2.关闭青少年弹窗 + closedQDialog(AblService.getInstance());//关闭我知道了弹窗 + closedBDialog(AblService.getInstance());//关闭个人信息保护指引 + AblStepHandler.sendMsg(AblSteps.STEP_111); + break; + case AblSteps.STEP_111: + //点击右上角搜索 + DianSou(); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_112); + break; + case AblSteps.STEP_112: + AblViewUtil.mySleep(1); + //输入关键词 + //判断有无要加关的关键词,如果有则执行112,没有则执行113 + if (objects.size() > 0) { + //复制文本粘贴在留言板 + AccessibilityNodeInfo findcomentt = findEditText(); + //AblViewUtil.paste(findcomentt, "哈喽,你好ya"); + String conment = objects.get(0); + Log.e("TIAOSHI###", "获得的评论内容" + conment); + AblViewUtil.mySleep(1); + if (ChangLiang.phonetype.equals("0")) { + //郝总的手机用第一个评论不上去 + // AblViewUtil.paste(findcomentt, conment);//红米7a + AblViewUtil.sayInput(conment, findcomentt); + } else { + AblViewUtil.sayInput(conment, findcomentt);//华为畅享20 + } + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_114); + } else { + AblStepHandler.sendMsg(AblSteps.STEP_115); + } + break; + case AblSteps.STEP_114: + //点击列表第一个,进入加关页面 + AccessibilityNodeInfo firstview = firstview(); + AblService.getInstance().clickcommontwo(firstview, "第一条"); + AblViewUtil.mySleep(1); + //添加关注 + AccessibilityNodeInfo guanzhu = AblViewUtil.findByText("关注", 0); + if (guanzhu != null) { + Log.e("TIAOSHI###", "关注"); + AblService.getInstance().clickcommontwo(guanzhu, "关注"); + AblViewUtil.mySleep(2); + } + AblViewUtil.mySleep(2); + objects.remove(0); + AblViewUtil.mySleep(2); + //返回上页 + AblViewUtil.back(); + AblStepHandler.sendMsg(AblSteps.STEP_112); + break; + case AblSteps.STEP_115: + //返回上页 + AblViewUtil.back(); + //无障碍暂停 + AblStepHandler.getInstance().setStop(true); + AblViewUtil.onMessage("停止"); + break; + default: + } + } + + + //点击右上角搜索 + //[624,67][688,131] + private void DianSou() { + + if (ChangLiang.phonetype.equals("0")) { + AblService.getInstance().clickPoint(656, 99, 300);//红米7a + } else { + AblService.getInstance().clickPoint(659, 922, 300);//华为畅享20 + } + Log.e("TIAOSHI###", "点击点赞按钮"); + } + + + /** + * 随机获取评论话术 + */ + private String getConment() { + CommentDao commentDao = new CommentDao(FuzhuApplication.getContext()); + List CommentBeanDatas = commentDao.queryInByCustom("type", "1"); + if (CommentBeanDatas.size() == 0) { + return "哈哈"; + } else if (CommentBeanDatas.size() == 1) { + CommentBeanData commentBeanData = CommentBeanDatas.get(0); + String comment = commentBeanData.getComment(); + return comment; + } else { + int i = new Random().nextInt(CommentBeanDatas.size() - 1); + CommentBeanData commentBeanData = CommentBeanDatas.get(i); + String comment = commentBeanData.getComment(); + return comment; + } + + } + + + /** + * 寻找搜索输入框 + */ + private AccessibilityNodeInfo findEditText() { + AccessibilityNodeInfo infooos = null; + AccessibilityNodeInfo rootttt = AblService.getInstance().getRootInActiveWindow(); + for (int j = 0; j < rootttt.getChildCount(); j++) { + AccessibilityNodeInfo child = rootttt.getChild(j); + Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + if ("android.widget.EditText".equals(child.getClassName())) { + infooos = child; + } + } + return infooos; + } + + + /** + * 列表第一条 + */ + private AccessibilityNodeInfo firstview() { + AccessibilityNodeInfo infooos = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + + for (int j = 0; j < root.getChildCount(); j++) { + AccessibilityNodeInfo child = root.getChild(j); + Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + Log.e("TIAOSHI###ViewPager", "----2Node:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(0); + infooos = child1; + } + } + return infooos; + + } + +} + + + diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep2.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep2.java new file mode 100644 index 0000000..386b3b9 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep2.java @@ -0,0 +1,228 @@ +package com.fisherbone.fuzhu.step; + +import android.graphics.Rect; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.List; + + +public class TestAblStep2 extends BaseAblStep { + @Override + public void onStep(int step, Message msg) { + switch (step) { + case AblSteps.STEP_3: + AblViewUtil.startApplication(); + AblViewUtil.mySleep(2); + allowed(); + AblViewUtil.mySleep(6); + AblStepHandler.sendMsg(AblSteps.STEP_4); + // AblService.getInstance().performGlobalAction(AccessibilityService.GLOBAL_ACTION_POWER_DIALOG); + //打开快速设置 + // AblService.getInstance().performGlobalAction(AccessibilityService.GLOBAL_ACTION_QUICK_SETTINGS); + // AblService.getInstance().performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS); + break; + case AblSteps.STEP_4: + closedtjDialog(AblService.getInstance()); + AblViewUtil.mySleep(1); + setdoyinQDialog(AblService.getInstance()); + AblViewUtil.mySleep(1); + //1.关闭检测到更新的弹框 + closedJDialog(AblService.getInstance()); + AblViewUtil.mySleep(1); + //2.关闭青少年弹窗 + closedQDialog(AblService.getInstance()); + AblViewUtil.mySleep(1); + closedBDialog(AblService.getInstance()); + AblViewUtil.mySleep(1); + + AblStepHandler.sendMsg(AblSteps.STEP_5); + break; + case AblSteps.STEP_5: + + AblService instance = AblService.getInstance(); + AblViewUtil.mySleep(2); + instance.clickPoint(972, 2112, 300); + Log.e("TIAOSHI###", "点击了我按钮"); + AblViewUtil.mySleep(2); + //Xiaomi M2007J22C Android 10, API 29 + //atom运行检查 + boolean normaa = wodeNorma(); + if (normaa) { + Log.e("TIAOSHI###", "页面在我的页面运行正常"); + againStart("1"); + } else { + Log.e("TIAOSHI###", "页面在我的页面运行异常"); + againStart("0"); + } + + + //等待2秒点击更多按钮([624,75][688,139]) + AblViewUtil.mySleep(2); + + instance.clickPoint(989, 170, 300); + Log.e("TIAOSHI###", "点击了更多按钮"); + + + //等待2秒点击设置按钮([220,1023][720,1143]) + AblViewUtil.mySleep(2); + + instance.clickPoint(584, 1790, 300); + Log.e("TIAOSHI###", "点击了设置按钮"); + + + //等待2秒向上滑动 + AblViewUtil.mySleep(2); + instance.randomSwipe(); + + //等待2秒点击切换账户 + AblViewUtil.mySleep(2); + AccessibilityNodeInfo zhaohao = AblViewUtil.findByText("切换帐号", 0); + if(zhaohao==null){ + Log.e("TIAOSHI###", "没有找到切换帐号" ); + }else { + Log.e("TIAOSHI###", "弹出了个人信息保护指引的弹窗" ); + clickNodeInfo(zhaohao,"切换帐号"); + } + + AblViewUtil.mySleep(2); + //atom运行检查 + boolean norma = ZhongHaoNorma(); + if (norma) { + Log.e("TIAOSHI###", "页面在切换账号页面运行正常"); + againStart("1"); + } else { + Log.e("TIAOSHI###", "页面在切换账号页面运行异常"); + againStart("0"); + } + //获取一屏幕数据:快照 + AccessibilityNodeInfo roott = instance.getRootInActiveWindow(); + String shortname = ChangLiang.task_short_name; + if(shortname.contains("T")){ + shortname = shortname.substring(0, shortname.indexOf("T")-1); + Log.e("TIAOSHI###", "----获取用户昵称:" +shortname); + } + List idsj = roott.findAccessibilityNodeInfosByText(shortname); + if(idsj.size()>0) { + String nodeInfofir = getNodeInfofir(); + Log.e("TIAOSHI###", "获得的昵称"+nodeInfofir+" shortname=="+shortname); + if (nodeInfofir.contains(shortname)) { + Log.e("TIAOSHI###", "有任务派的抖音号,并且在第一个位置上"); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + } else { + instance.clickcommon(idsj, ChangLiang.task_short_name); + } + }else { + Log.e("TIAOSHI###", "没有任务派的抖音号"); + UpdateTuoguan(); + } + break; + default: + } + } + private void UpdateTuoguan() { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("short_id", ChangLiang.short_id); + paramsPost.put("tuoguan_type", "1"); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appscanlogin_UpdateTuoguan).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if ("0".equals(success)) { + Log.e("TIAOSHI###", "提交帐号异常" + msg); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + + /** + * 寻找控件 + */ + public String getNodeInfofir() { + String name = ""; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); +// Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); +// nodeZuobiao(child1); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + nodeZuobiao(child2); + Rect rect = new Rect(); + if (child2 != null) { + child2.getBoundsInScreen(rect); + if (rect.top >= 253 && rect.bottom <= 404) { + Log.e("TIAOSHI###", "----fourNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + if ("android.widget.TextView".equals(child2.getClassName())) { + if (child2.getText() != null) { + String s = child2.getText().toString(); + name = s; + } + } + } + } + } + } + } + return name; + } + + public boolean allowed() { + boolean ifOpen = false; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.TextView".equals(child.getClassName())) { + if(child.getText()!=null) { + if (child.getText().toString().contains("正在尝试开启") || child.getText().toString().contains("是否允许")) { + int childCount = root.getChildCount(); + AccessibilityNodeInfo child1 = root.getChild(childCount - 1); + clickNodeInfo(child1, "点击了允许"); + } + } + ifOpen = true; + } + } + return ifOpen; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep21.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep21.java new file mode 100644 index 0000000..aa9c486 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep21.java @@ -0,0 +1,360 @@ +package com.fisherbone.fuzhu.step; + +import android.accessibilityservice.AccessibilityService; +import android.accessibilityservice.GestureDescription; +import android.graphics.Path; +import android.graphics.Rect; +import android.os.Build; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import androidx.annotation.RequiresApi; + +import com.blankj.utilcode.util.ToastUtils; +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.RandumInt; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; + +import java.util.List; + +/** + * @param + * @description 一键取关(取消已关注+取消互相关注) + * @return + */ +public class TestAblStep21 extends BaseAblStep { + private String substring;//当前的关注数 + private int numb;//阈值 + private String guanzhunum; + private AccessibilityNodeInfo child3; + + + @Override + public void onStep(int step, Message msg) { + + // Log.e("TIAOSHI###==获得一键取互相关注的参数",ChangLiang.cancelclosed+"---"+ChangLiang.cancelcrosscor+"---"+ChangLiang.passnumber+"---"+ChangLiang.swiinterval+"---"+ChangLiang.minthrthr+""); + switch (step) { + case AblSteps.STEP_60: + AblViewUtil.startApplication(); + AblViewUtil.mySleep(8); + AblStepHandler.sendMsg(AblSteps.STEP_61); + break; + case AblSteps.STEP_61: + ChangLiang.ishuodong = "T"; + AblViewUtil.mySleep(5); + AblService instance = AblService.getInstance(); + //1.关闭广告 + //2.关闭青少年弹窗 + //3.点击我的 + myClick(); + AblViewUtil.mySleep(2); + //获取关注数(对比关注数是否满足预设的取关值;)若不满足,则直接结束任务,若满足,则点击【关注】,进入关注页; + getargone(); + AblViewUtil.mySleep(1); + if (guanzhunum==null) { + Log.e("TIAOSHI###", "关注数==null结束任务"); + ToastUtils.showShort("关注数==null结束任务"); + AblStepHandler.getInstance().setStop(true); + // AblViewUtil.onMessage("停止"); + return; + } + Log.e("TIAOSHI###", "获得的关注数==" + guanzhunum); + if(guanzhunum!=null) { + int num = Integer.parseInt(guanzhunum.toString()); + Log.e("TIAOSHI###", "关注数" + num); + numb = Integer.parseInt(ChangLiang.minthrthr) - Integer.parseInt(ChangLiang.passnumber); + if (num <= Integer.parseInt(ChangLiang.minthrthr) - Integer.parseInt(ChangLiang.passnumber)) { + Log.e("TIAOSHI###", "关注数小于等于设定的取关数结束任务"); + ToastUtils.showLong("关注数小于等于设定的取关数结束任务"); + AblStepHandler.getInstance().setStop(true); + AblViewUtil.onMessage("停止"); + return; + } + //点击进入用户关注页 + AblViewUtil.mySleep(2); + // AblService.getInstance().clickcommontwo(child, "进入用户关注页"); + AblService.getInstance().clickcommontwo(child3, "进入用户关注页"); + AblStepHandler.sendMsg(AblSteps.STEP_62); + } + break; + case AblSteps.STEP_62: + //寻找到第一条互相关注的进入个人信息页面 + //AblViewUtil.mySleep(1); + int num2 = Integer.parseInt(getNum()); + if (num2 > numb) { + // AblViewUtil.mySleep(1); + cancelGuanzhu(AblService.getInstance()); + } else { + ChangLiang.ishuodong = "F"; + AblViewUtil.back(); + } + break; + case AblSteps.STEP_63: + //获取一屏幕数据:快照 + AccessibilityNodeInfo roott = AblService.getInstance().getRootInActiveWindow(); + List idsj = roott.findAccessibilityNodeInfosByText("查找好友并关注"); + if (idsj.size() > 0) { + AccessibilityNodeInfo accessibilityNodeInfo = idsj.get(0); + CharSequence text1 = accessibilityNodeInfo.getText(); + if (text1.equals("查找好友并关注")) { + ChangLiang.ishuodong = "F"; + AblViewUtil.back(); + } + } + if (ChangLiang.ishuodong.equals("T")) { + AblViewUtil.mySleep(1); + // randomSwipe(); + AccessibilityNodeInfo chilrecy = getrecy(); + chilrecy.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); //触发容器元素的滚动事件 + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_62); + } + break; + default: + } + } + + + private AccessibilityNodeInfo getrecy() { + AccessibilityNodeInfo chilrecy = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { + AccessibilityNodeInfo child1 = child.getChild(1); + Rect rect = new Rect(); + child1.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----fourNode:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { + chilrecy=child1; + } + } + } + return chilrecy; + } + + private void cancelGuanzhu(AblService instance) { + // 取消已关: + // 在关注列表中,遍历寻找【已关注】的用户,点击【已关注】进行取关; + AblViewUtil.mySleep(2); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + //遍历root下的子节点有哪些 + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + AccessibilityNodeInfo child1 = child.getChild(1); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { + for (int x = 0; x < child1.getChildCount(); x++) { + AccessibilityNodeInfo child2 = child1.getChild(x); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + if (child2.getChildCount() != 0) { + for (int w = 0; w < child2.getChildCount(); w++) { + AccessibilityNodeInfo childw = child2.getChild(w); + if(childw!=null) { + if (childw.getText().equals("已关注")) { + AblViewUtil.mySleep(2); + if (childw.getText() != null) { + if (childw.getText().toString().equals("已关注")) { + clickcommontwo(childw, "已关注"); + } + } + } + if (childw.getText().equals("互相关注")) { + AblViewUtil.mySleep(2); + if (childw.getText() != null) { + if (childw.getText().toString().equals("互相关注")) { + clickcommontwo(child2, "进入互相关注"); + AblViewUtil.mySleep(2); + //点击取消关注 + AccessibilityNodeInfo getquxiaoguanzhu = getquxiaoguanzhu(); + AblService.getInstance().clickcommontwo(getquxiaoguanzhu, "点击互相关注"); + AblViewUtil.mySleep(2); + //点击取消关注 + AccessibilityNodeInfo quxiao = AblViewUtil.findByText("取消关注", 1); + AblService.getInstance().clickcommonthree(quxiao, "取消关注"); + AblViewUtil.mySleep(2); + AblViewUtil.back(); + } + } + } + } + } + } + } + } + } + } + + //向上滑动 + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_63); + } + /** + * 获得取消关注 + */ + private AccessibilityNodeInfo getquxiaoguanzhu() { + AccessibilityNodeInfo nodeinfo = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { + // Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("android.widget.TextView".equals(child1.getClassName())) { + CharSequence text = child1.getText(); + if (text != null) { + if (text.toString().contains("互相关注")) { + nodeinfo=child1; + } + } + } + } + } + } + return nodeinfo; + } + + + /** + * 获得当前的关注数 + * + * @return + */ + private String getNum() { + //获取关注数 + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + //遍历root下的子节点有哪些 + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { + Log.e("TIAOSHI###HorizontalScrollView", "----twoNode:" + child.getChildCount()); + for (int j = 0; j < child.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child.getChild(j); + Log.e("TIAOSHI###", "----twoNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + } + AccessibilityNodeInfo child1 = child.getChild(0); + if ("androidx.appcompat.app.ActionBar$Tab".equals(child1.getClassName())) { + for (int x = 0; x < child1.getChildCount(); x++) { + AccessibilityNodeInfo child2 = child1.getChild(x); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + String s = child2.getText().toString(); + Log.e("TIAOSHI###", s + "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + substring = s.substring(3); + Log.e("TIAOSHI###", "----关注数:" + substring); + } + } + } + } + return substring; + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void randomSwipe() { + if (ChangLiang.phonetype.equals("0")) { + int a = 170 + RandumInt.getRandumInt4() * 8; + int b = 170 - RandumInt.getRandumInt4() * 10; + int c = 1200 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 + int d = 400 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 320); //延迟330毫秒 + } else { + int a = 500 + RandumInt.getRandumInt4() * 8; + int b = 500 - RandumInt.getRandumInt4() * 10; + int c = 1500 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 + int d = 700 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 420); //延迟330毫秒 + } + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void swipe(float x1, float y1, float x2, float y2, long duration) { + Path path = new Path(); + path.moveTo(x1, y1); + path.lineTo(x2, y2); + + Log.e("TIAOSHI###", "MyAccessibilityService中滑动swipe()方法滑动点,reset:(" + x1 + "," + y1 + "),(" + x2 + "," + y2 + ")" + "滑动的时长是:" + duration); + GestureDescription.Builder builder = new GestureDescription.Builder(); + GestureDescription gestureDescription = builder + .addStroke(new GestureDescription.StrokeDescription(path, 0, duration)) + .build(); + boolean b = AblService.getInstance().dispatchGesture(gestureDescription, new AccessibilityService.GestureResultCallback() { + @Override + public void onCompleted(GestureDescription gestureDescription) { + super.onCompleted(gestureDescription); + Log.e("TIAOSHI###", "滑动结束..." + gestureDescription.getStrokeCount()); + + } + + @Override + public void onCancelled(GestureDescription gestureDescription) { + super.onCancelled(gestureDescription); + Log.e("TIAOSHI###", "滑动取消"); + } + }, null); + } + + + /** + * 获得关注数 + */ + private void getargone() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + //if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + if ("dmt.viewpager.DmtViewPager$MyAccessibilityDelegate".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // if ("android.widget.LinearLayout".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); + + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child4 = child2.getChild(x); + Log.e("TIAOSHI###", "----fourNode:" + child4.getClassName() + ":" + child4.getText()); + for (int z = 0; z < child4.getChildCount(); z++) { + AccessibilityNodeInfo child5 = child4.getChild(z); + Log.e("TIAOSHI###", "----fiveNode:" + child5.getClassName() + ":" + child5.getText()); + if (child5.getText() != null) { + if (child5.getText().equals("关注")) { + AccessibilityNodeInfo parent = child5.getParent(); + child3 = parent.getChild(0); + Log.e("TIAOSHI###", "获得的关注数==" + child3.getText().toString()); + guanzhunum = child3.getText().toString(); + if (child3.getText().toString().equals("-")) { + Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); + } + return; + } + + } + } + } + } + } + } + } + } +} + diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep23.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep23.java new file mode 100644 index 0000000..c1effdc --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep23.java @@ -0,0 +1,443 @@ +package com.fisherbone.fuzhu.step; + +import android.accessibilityservice.AccessibilityService; +import android.accessibilityservice.GestureDescription; +import android.graphics.Path; +import android.os.Build; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import androidx.annotation.RequiresApi; + +import com.blankj.utilcode.util.ToastUtils; +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.FuzhuApplication; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.RandumInt; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.db.CommentBeanData; +import com.fisherbone.fuzhu.db.dao.CommentDao; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +/** + * @param + * @description 粉丝互动 + * @return + */ +public class TestAblStep23 extends BaseAblStep { + private String substring;//当前的关注数 + private int numb;//阈值 + private int numa=0;//执行发消息的次数 + private String guanzhunum;//粉丝数 + private AccessibilityNodeInfo child3; + private AccessibilityNodeInfo child2; + + @Override + public void onStep(int step, Message msg) { + + // Log.e("TIAOSHI###==获得一键取互相关注的参数",ChangLiang.cancelclosed+"---"+ChangLiang.cancelcrosscor+"---"+ChangLiang.passnumber+"---"+ChangLiang.swiinterval+"---"+ChangLiang.minthrthr+""); + switch (step) { + case AblSteps.STEP_180: + AblViewUtil.startApplication(); + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_181); + break; + case AblSteps.STEP_181: + ChangLiang.ishuodong = "T"; + AblViewUtil.mySleep(5); + myClick(); + AblViewUtil.mySleep(5); + //获取关注数(对比关注数是否满足预设的取关值;)若不满足,则直接结束任务,若满足,则点击【关注】,进入关注页; + numb = Integer.parseInt(ChangLiang.interanum); + getargone(); + AblViewUtil.mySleep(1); + if (guanzhunum==null) { + Log.e("TIAOSHI###", "关注数==null结束任务"); + ToastUtils.showShort("关注数==null结束任务"); + AblStepHandler.getInstance().setStop(true); + // AblViewUtil.onMessage("停止"); + return; + } + Log.e("TIAOSHI###", "获得的粉丝数==" + guanzhunum); + if(guanzhunum!=null) { + if(guanzhunum.contains("w")){ + String strrr = guanzhunum.substring(0, guanzhunum.indexOf("w")); + Double num = Double.parseDouble(strrr)*10000; + Log.e("TIAOSHI###", "粉丝数" + num); + } + + //点击进入用户关注页 + AblViewUtil.mySleep(2); + // AblService.getInstance().clickcommontwo(child, "进入用户关注页"); + AblService.getInstance().clickcommontwo(child3, "进入用户粉丝页"); + AblStepHandler.sendMsg(AblSteps.STEP_182); + } + break; + case AblSteps.STEP_182: + //寻找到第一条互相关注的进入个人信息页面 + if (numa < numb) { + cancelGuanzhu(AblService.getInstance()); + } else { + ChangLiang.ishuodong = "F"; + AblViewUtil.back(); + } + break; + case AblSteps.STEP_183: + AblViewUtil.mySleep(3); + //获取一屏幕数据:快照 + AccessibilityNodeInfo roott = AblService.getInstance().getRootInActiveWindow(); + List idsj = roott.findAccessibilityNodeInfosByText("查找好友并关注"); + // List idsj = AblViewUtil.findByText("查找好友并关注"); + if (idsj.size() > 0) { + AccessibilityNodeInfo accessibilityNodeInfo = idsj.get(0); + CharSequence text1 = accessibilityNodeInfo.getText(); + if (text1.equals("查找好友并关注")) { + ChangLiang.ishuodong = "F"; + AblViewUtil.back(); + } + } + if (ChangLiang.ishuodong.equals("T")) { + AblViewUtil.mySleep(1); + randomSwipe(); + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_182); + } + break; + default: + } + } + + + private void cancelGuanzhu(AblService instance) { + // 取消已关: + // 在关注列表中,遍历寻找【已关注】的用户,点击【已关注】进行取关; + AblViewUtil.mySleep(2); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + //遍历root下的子节点有哪些 + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { + // Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + AccessibilityNodeInfo child1 = child.getChild(2); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { + for (int x = 0; x < child1.getChildCount(); x++) { + AccessibilityNodeInfo child2 = child1.getChild(x); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + // Log.e("TIAOSHI###", "----异常报错数:" + child2.getChildCount()); + AblViewUtil.mySleep(2); + if ("android.widget.RelativeLayout".equals(child2.getClassName())) { + AblService.getInstance().clickcommontwo(child2, "点击条目"); + }else { + continue; + } + AblViewUtil.mySleep(5); + + + //通过坐标点的方式获得node节点id + if(ChangLiang.phonetype.equals("0")){ + instance.clickPoint(656, 107, 300);//红米7a //点击右上角菜单[624,75][688,139] + }else { + instance.clickPoint(664, 92, 300);//华为畅享20 [640,68][688,116] + } + + Log.e("TIAOSHI###", "点击了更多按钮"); + AblViewUtil.mySleep(2); + //点击发私信 + List list = AblViewUtil.findByText("发私信"); + for (AccessibilityNodeInfo item : list) { + clickcommontwo(item, "发私信"); + } + AblViewUtil.mySleep(2); +// //寻找编辑控件 + AccessibilityNodeInfo findcomentt = findcoment(); +// //复制粘贴内容 + String conment = getConment(); + // String conment = ChangLiang.interaContent; + + Log.e("TIAOSHI###", "获得的信息内容" + conment); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "获得的信息内容" + conment); + if (ChangLiang.phonetype.equals("0")) { + Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype); + //郝总的手机用第一个评论不上去 + // AblViewUtil.paste(findcomentt, conment);//红米7a + AblViewUtil.sayInput(conment, findcomentt); + } else { + Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype); + AblViewUtil.sayInput(conment, findcomentt);//华为畅享20 + } + //发送 + AblViewUtil.mySleep(2); +// //点击发送 + AccessibilityNodeInfo findcomenttt = findcomentt(); + if (findcomentt != null) { + AblService.getInstance().clickcommontwo(findcomenttt, "发送"); + AblViewUtil.mySleep(2); + } + AblViewUtil.mySleep(2); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + + } + } + } + } + + //向上滑动 + // AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_183); + } + + + /** + * 寻找发送 + */ + private AccessibilityNodeInfo findcomentt() { + AccessibilityNodeInfo child3 = null; + ArrayList objects = new ArrayList<>(); + AccessibilityNodeInfo rootttt = AblService.getInstance().getRootInActiveWindow(); + for (int j = 0; j < rootttt.getChildCount(); j++) { + AccessibilityNodeInfo child = rootttt.getChild(j); + Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child2 = child.getChild(y); + Log.e("TIAOSHI###", "----2Node:" + child2.getClassName() + ":" + child2.getText()); + + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child1 = child2.getChild(x); + Log.e("TIAOSHI###", "----3Node:" + child1.getClassName() + ":" + child1.getText()); + + if ("android.widget.ImageView".equals(child2.getChild(x).getClassName())) { + AccessibilityNodeInfo infooos = child2.getChild(x); + objects.add(infooos); + } + } + Log.e("TIAOSHI###", "----4Node:" + objects.size()); + if (objects.size() > 0) { + child3 = objects.get(objects.size() - 1); + } + } + } + return child3; + } + + + + /** + * 寻找留下你的精彩评论 + */ + private AccessibilityNodeInfo findcoment() { + AccessibilityNodeInfo infooos = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int j = 0; j < root.getChildCount(); j++) { + AccessibilityNodeInfo child = root.getChild(j); + Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----2Node:" + child1.getClassName() + ":" + child1.getText()); + for (int x = 0; x < child1.getChildCount(); x++) { + AccessibilityNodeInfo child6 = child1.getChild(x); + Log.e("TIAOSHI###", "----3Node:" + child6.getClassName() + ":" + child6.getText()); + if ("android.widget.EditText".equals(child6.getClassName())) { + infooos = child1.getChild(x); + Log.e("TIAOSHI###", "----4Node:" + infooos.getClassName() + ":" + infooos.getText()); + } + } + } +// } + } + return infooos; + } + + /** + * 随机获取评论话术 + */ + private String getConment() { + CommentDao commentDao = new CommentDao(FuzhuApplication.getContext()); + List CommentBeanDatas = commentDao.queryInByCustom("type", "4"); + if (CommentBeanDatas.size() == 0) { + return "哈哈"; + } else if (CommentBeanDatas.size() == 1) { + CommentBeanData commentBeanData = CommentBeanDatas.get(0); + String comment = commentBeanData.getComment(); + return comment; + } else { + int i = new Random().nextInt(CommentBeanDatas.size() - 1); + CommentBeanData commentBeanData = CommentBeanDatas.get(i); + String comment = commentBeanData.getComment(); + return comment; + } + + } + + /** + * 获得取消关注 + */ + private AccessibilityNodeInfo getquxiaoguanzhu() { + AccessibilityNodeInfo nodeinfo = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { + // Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("android.widget.TextView".equals(child1.getClassName())) { + CharSequence text = child1.getText(); + if (text != null) { + if (text.toString().contains("互相关注")) { + nodeinfo=child1; + } + } + } + } + } + } + return nodeinfo; + } + + + /** + * 获得当前的粉丝数 + * + * @return + */ + private String getNum() { + //获取关注数 + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + //遍历root下的子节点有哪些 + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { + // Log.e("TIAOSHI###HorizontalScrollView", "----twoNode:" + child.getChildCount()); + for (int j = 0; j < child.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child.getChild(j); + // Log.e("TIAOSHI###", "----twoNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + } + AccessibilityNodeInfo child1 = child.getChild(1); + if ("androidx.appcompat.app.ActionBar$Tab".equals(child1.getClassName())) { + for (int x = 0; x < child1.getChildCount(); x++) { + child2 = child1.getChild(x); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + String s = child2.getText().toString(); + // Log.e("TIAOSHI###", s + "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + substring = s.substring(3); + Log.e("TIAOSHI###", "----关注数:" + substring); + } + } + } + } + return substring; + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void randomSwipe() { + if (ChangLiang.phonetype.equals("0")) { + int a = 170 + RandumInt.getRandumInt4() * 8; + int b = 170 - RandumInt.getRandumInt4() * 10; + int c = 1200 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 + int d = 400 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 320); //延迟330毫秒 + } else { + int a = 500 + RandumInt.getRandumInt4() * 8; + int b = 500 - RandumInt.getRandumInt4() * 10; + int c = 1500 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 + int d = 700 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 420); //延迟330毫秒 + } + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void swipe(float x1, float y1, float x2, float y2, long duration) { + Path path = new Path(); + path.moveTo(x1, y1); + path.lineTo(x2, y2); + + Log.e("TIAOSHI###", "MyAccessibilityService中滑动swipe()方法滑动点,reset:(" + x1 + "," + y1 + "),(" + x2 + "," + y2 + ")" + "滑动的时长是:" + duration); + GestureDescription.Builder builder = new GestureDescription.Builder(); + GestureDescription gestureDescription = builder + .addStroke(new GestureDescription.StrokeDescription(path, 0, duration)) + .build(); + boolean b = AblService.getInstance().dispatchGesture(gestureDescription, new AccessibilityService.GestureResultCallback() { + @Override + public void onCompleted(GestureDescription gestureDescription) { + super.onCompleted(gestureDescription); + Log.e("TIAOSHI###", "滑动结束..." + gestureDescription.getStrokeCount()); + + } + + @Override + public void onCancelled(GestureDescription gestureDescription) { + super.onCancelled(gestureDescription); + Log.e("TIAOSHI###", "滑动取消"); + } + }, null); + } + + + /** + * 获得关注数 + */ + private void getargone() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + //if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + if ("dmt.viewpager.DmtViewPager$MyAccessibilityDelegate".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // if ("android.widget.LinearLayout".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); + + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child4 = child2.getChild(x); + Log.e("TIAOSHI###", "----fourNode:" + child4.getClassName() + ":" + child4.getText()); + for (int z = 0; z < child4.getChildCount(); z++) { + AccessibilityNodeInfo child5 = child4.getChild(z); + Log.e("TIAOSHI###", "----fiveNode:" + child5.getClassName() + ":" + child5.getText()); + if (child5.getText() != null) { + if (child5.getText().equals("粉丝")) { + AccessibilityNodeInfo parent = child5.getParent(); + child3 = parent.getChild(0); + Log.e("TIAOSHI###", "获得的关注数==" + child3.getText().toString()); + guanzhunum = child3.getText().toString(); + if (child3.getText().toString().equals("-")) { + Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); + } + return; + } + + } + } + } + } + } + } + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep24.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep24.java new file mode 100644 index 0000000..39ee248 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep24.java @@ -0,0 +1,580 @@ +package com.fisherbone.fuzhu.step; + +import android.accessibilityservice.AccessibilityService; +import android.accessibilityservice.GestureDescription; +import android.graphics.Path; +import android.os.Build; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import androidx.annotation.RequiresApi; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.RandumInt; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; + +import java.util.ArrayList; +import java.util.List; + +/** + * @param + * @description 大v粉丝加关 + * @return + */ +public class TestAblStep24 extends BaseAblStep { + private ArrayList objects = new ArrayList<>(); + private AccessibilityNodeInfo child3; + private List accessibilityNodeInfos; + private String guanzhunum; + private String fensinum; + private String zuopinnum; + private String huozannum; + + @Override + public void onStep(int step, Message msg) { + + // Log.e("TIAOSHI###==获得一键取互相关注的参数",ChangLiang.cancelclosed+"---"+ChangLiang.cancelcrosscor+"---"+ChangLiang.passnumber+"---"+ChangLiang.swiinterval+"---"+ChangLiang.minthrthr+""); + switch (step) { + case AblSteps.STEP_130: + AblViewUtil.startApplication(); + objects.clear(); + objects.add(ChangLiang.dav_douyinhao); + // objects.add("dyh48hvfd4yc"); + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_131); + break; + case AblSteps.STEP_131: + //点击右上角搜索 + DianSou(); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_132); + break; + case AblSteps.STEP_132: + AblViewUtil.mySleep(1); + ChangLiang.dav_ishuadong = "T"; + //输入关键词 + //判断有无要加关的关键词,如果有则执行112,没有则执行113 + if (objects.size() > 0) { + //复制文本粘贴在留言板 + AccessibilityNodeInfo findcomentt = findEditText(); + String conment = objects.get(0); + Log.e("TIAOSHI###", "获得的关键词内容" + conment); + AblViewUtil.mySleep(1); + if (ChangLiang.phonetype.equals("0")) { + AblViewUtil.sayInput(conment, findcomentt); + } else { + AblViewUtil.sayInput(conment, findcomentt);//华为畅享20 + } + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_133); + } + break; + case AblSteps.STEP_133: + //点击列表第一个,进入加关页面 + DianSou(); + AblViewUtil.mySleep(2); + // AblService.getInstance().inputClickId("用户");//红米7a + selecttype("1"); + AblViewUtil.mySleep(2); + //用坐标点的方式点击第一条 0,256 720,404 + AblService.getInstance().clickPoint(360, 330, 300); + AblViewUtil.mySleep(2); + getfensi(); + AblViewUtil.mySleep(2); + AblService.getInstance().clickcommontwo(child3, "进入用户粉丝页"); + AblStepHandler.sendMsg(AblSteps.STEP_134); + break; + case AblSteps.STEP_134: + AblViewUtil.mySleep(2); + if(ChangLiang.dav_ishuadong.equals("T")) { + getdouyin(); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_135); + } + break; + case AblSteps.STEP_135: + //获取一屏幕数据:快照 + AccessibilityNodeInfo roott = AblService.getInstance().getRootInActiveWindow(); + List idsj = roott.findAccessibilityNodeInfosByText("暂时没有更多"); + if (idsj.size() > 0) { + AccessibilityNodeInfo accessibilityNodeInfo = idsj.get(0); + CharSequence text1 = accessibilityNodeInfo.getText(); + if (text1.equals("暂时没有更多")) { + ChangLiang.dav_ishuadong = "F"; + AblViewUtil.back(); + } + } + if (ChangLiang.dav_ishuadong.equals("T")) { + randomSwipe(); + AblStepHandler.sendMsg(AblSteps.STEP_134); + } + break; + default: + + } + } + + /** + * 选择搜索的分类 + * 1为用户 2为直播 + */ + public void selecttype(String type) { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + + switch (type) { + case "1": + if ("android.widget.TextView".equals(child2.getClassName())) { + if (child2.getText() != null) { + if (child2.getText().toString().equals("用户")) { + AblService.getInstance().clickcommontwo(child2, ""); + } + } + } + break; + case "2": + if ("android.widget.TextView".equals(child2.getClassName())) { + if (child2.getText() != null) { + if (child2.getText().toString().equals("直播")) { + AblService.getInstance().clickcommontwo(child2, ""); + } + } + } + break; + default: + } + } + } + } + } + + @RequiresApi(api = Build.VERSION_CODES.N) + public void randomSwipe() { + if (ChangLiang.phonetype.equals("0")) { + int a = 170 + RandumInt.getRandumInt4() * 8; + int b = 170 - RandumInt.getRandumInt4() * 10; + int c = 1200 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 2160--1080 + int d = 400 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 320); //延迟330毫秒 + } else { + int a = 500 + RandumInt.getRandumInt4() * 8; + int b = 500 - RandumInt.getRandumInt4() * 10; + int c = 1500 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 + int d = 700 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 420); //延迟330毫秒 + } + } + @RequiresApi(api = Build.VERSION_CODES.N) + public void swipe(float x1, float y1, float x2, float y2, long duration) { + Path path = new Path(); + path.moveTo(x1, y1); + path.lineTo(x2, y2); + + Log.e("TIAOSHI###", "MyAccessibilityService中滑动swipe()方法滑动点,reset:(" + x1 + "," + y1 + "),(" + x2 + "," + y2 + ")" + "滑动的时长是:" + duration); + GestureDescription.Builder builder = new GestureDescription.Builder(); + GestureDescription gestureDescription = builder + .addStroke(new GestureDescription.StrokeDescription(path, 0, duration)) + .build(); + boolean b = AblService.getInstance().dispatchGesture(gestureDescription, new AccessibilityService.GestureResultCallback() { + @Override + public void onCompleted(GestureDescription gestureDescription) { + super.onCompleted(gestureDescription); + Log.e("TIAOSHI###", "滑动结束..." + gestureDescription.getStrokeCount()); + + } + + @Override + public void onCancelled(GestureDescription gestureDescription) { + super.onCancelled(gestureDescription); + Log.e("TIAOSHI###", "滑动取消"); + } + }, null); + } + + + /** + * 添加关注 + */ + private void getdouyin() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + + if (child2.getChildCount() != 0) { + for (int h = 0; h < child2.getChildCount(); h++) { + AccessibilityNodeInfo childh = child2.getChild(h); + Log.e("TIAOSHI###", "----fourNode:" + childh.getClassName() + ":" + childh.getText() + ":" + childh.getContentDescription()); + AblViewUtil.mySleep(1); + ChangLiang.dav_condition="0"; + if(childh.getText()!=null) { + if(childh.getText().toString().contains("用户")){ + continue; + } +// if (childh.getText().toString().equals("关注")) { +// clickcommontwo(childh, "关注"); +// } + + + if (childh.getText().toString().equals("关注")) { + //点击进入详情页 + clickcommontwo(child2, "进入互相关注"); + AblViewUtil.mySleep(2); + //获取参数 + getCondition(); + //是否加关 + AblViewUtil.mySleep(2); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + if(ChangLiang.dav_condition.equals("0")){ + clickcommontwo(childh, "关注"); + } + } + } + } + } + } + + } + } + } + + + private void getCondition() { + String getquxiaoguanzhu = getquxiaoguanzhu(); + if (getquxiaoguanzhu.equals("0")) { + Log.e("TIAOSHI###", "已经关注了,直接返回"); + ChangLiang.dav_condition = "1"; + return; + } + //___________________________________________________________________________________ + AblViewUtil.mySleep(1); + // getUserInfo(); + getargone(); + //判断作品数条件 + getargfour(); + if (guanzhunum != null) { + if (!guanzhunum.equals("-")) { + if (Integer.parseInt(guanzhunum) < Integer.parseInt(ChangLiang.dav_minimumlikes) || Integer.parseInt(guanzhunum) > Integer.parseInt(ChangLiang.dav_maxmumlikes)) { + Log.e("TIAOSHI###", "获取的该用户关注数" + Integer.parseInt(guanzhunum) + "小于设置的加关关注数(不在区间" + Integer.parseInt(ChangLiang.dav_minimumlikes) + "-" + Integer.parseInt(ChangLiang.dav_maxmumlikes) + "),关注数不满足条件"); + // AblViewUtil.onMessage("关注数不满足条件"); + ChangLiang.dav_condition = "1"; + return; + } else { + Log.e("TIAOSHI###", "获取的该用户关注数不小于设置的加关关注数,满足加关点赞评论条件"); + } + } else { + ChangLiang.dav_condition = "1"; + } + } + + //___________________________________________________________________________________ + AblViewUtil.mySleep(1); + if (fensinum != null) { + boolean status2 = fensinum.contains("w"); + boolean status3 = fensinum.contains("亿"); + if (status2 || status3) { + ChangLiang.dav_condition = "0"; + Log.e("TIAOSHI###", "获取的该用户粉丝数不小于设置的加关粉丝数,满足加关点赞评论条件"); + return; + } else { + if (fensinum != null) { + if (!fensinum.equals("-")) { + if (Integer.parseInt(fensinum) < Integer.parseInt(ChangLiang.dav_minimumcon) || Integer.parseInt(fensinum) > Integer.parseInt(ChangLiang.dav_maximumcon)) { + Log.e("TIAOSHI###", "获取的该用户粉丝数" + Integer.parseInt(fensinum) + "小于设置的加关粉丝数(不在区间" + Integer.parseInt(ChangLiang.dav_minimumcon) + "-" + Integer.parseInt(ChangLiang.dav_maximumcon) + "),粉丝数不满足条件"); + // AblViewUtil.onMessage("粉丝数不满足条件"); + ChangLiang.dav_condition = "1"; + return; + } else { + Log.e("TIAOSHI###", "获取的该用户粉丝数不小于设置的加关粉丝数,满足加关点赞评论条件"); + } + } else { + ChangLiang.dav_condition = "1"; + } + } + } + } + + } + + /** + * 获得取消关注 + */ + private String getquxiaoguanzhu() { + String quxiaoguanzhu = "1"; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + if ("dmt.viewpager.DmtViewPager$MyAccessibilityDelegate".equals(child.getClassName())) { + // Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("android.widget.TextView".equals(child1.getClassName())) { + CharSequence text = child1.getText(); + if (text != null) { + if (text.toString().equals("取消关注") || text.toString().equals("回关")) { + quxiaoguanzhu = "0"; + } + } + } + } + } + } + return quxiaoguanzhu; + } + + + /** + * 获得粉丝数 + */ + private void getfensi() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + //if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // if ("android.widget.LinearLayout".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); + if (child2.getText() != null) { + if (child2.getText().equals("粉丝")) { + AccessibilityNodeInfo parent = child2.getParent(); + child3 = parent.getChild(0); + Log.e("TIAOSHI###", "获得的关注数==" + child3.getText().toString()); + // guanzhunum = child3.getText().toString(); + if (child3.getText().toString().equals("-")) { + Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); + } + return; + } + } + } + } + } + } + } + + + /** + * 寻找搜索输入框 + */ + private AccessibilityNodeInfo findEditText() { + AccessibilityNodeInfo infooos = null; + AccessibilityNodeInfo rootttt = AblService.getInstance().getRootInActiveWindow(); + for (int j = 0; j < rootttt.getChildCount(); j++) { + AccessibilityNodeInfo child = rootttt.getChild(j); + Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + if ("android.widget.EditText".equals(child.getClassName())) { + infooos = child; + } + } + return infooos; + } + + + //点击右上角搜索 + //[624,67][688,131] + private void DianSou() { + + if (ChangLiang.phonetype.equals("0")) { + AblService.getInstance().clickPoint(656, 99, 300);//红米7a + } else { + AblService.getInstance().clickPoint(659, 922, 300);//华为畅享20 + } + Log.e("TIAOSHI###", "点击点赞按钮"); + } + + + + /** + * 列表第一条 + */ + private AccessibilityNodeInfo firstview() { + AccessibilityNodeInfo infooos = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + + for (int j = 0; j < root.getChildCount(); j++) { + AccessibilityNodeInfo child = root.getChild(j); + Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + Log.e("TIAOSHI###ViewPager", "----2Node:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(0); + infooos = child1; + } + } + return infooos; + + } + +// private void getUserInfo() { +// int num = 0; +// accessibilityNodeInfos = new ArrayList<>(); +// AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); +// for (int i = 0; i < root.getChildCount(); i++) { +// AccessibilityNodeInfo child = root.getChild(i); +// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); +// if ("dmt.viewpager.DmtViewPager$MyAccessibilityDelegate".equals(child.getClassName())) { +// Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); +// for (int y = 0; y < child.getChildCount(); y++) { +// AccessibilityNodeInfo child1 = child.getChild(y); +// Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); +// if ("android.widget.TextView".equals(child1.getClassName())) { +// if (num < 7) { +// accessibilityNodeInfos.add(child1); +// num = num + 1; +// } +// } +// +// } +// if(accessibilityNodeInfos.get(1).getText()!=null) { +// String customer_name = accessibilityNodeInfos.get(1).getText().toString(); +// String str = accessibilityNodeInfos.get(2).getText().toString(); +// String[] all = str.split(":"); +// String str3 = accessibilityNodeInfos.get(3).getText().toString(); +// fasStatistics(ChangLiang.short_id, customer_name, all[1], str3, huozannum, guanzhunum, fensinum, zuopinnum); +// } +// } +// } +// } + /** + * 获得最近作品时间 + */ + private void getargfour() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + //if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { + // Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int j = 0; j < child.getChildCount(); j++) { + AccessibilityNodeInfo child1 = child.getChild(j); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText()); + for (int x = 0; x < child1.getChildCount(); x++) { + AccessibilityNodeInfo child2 = child1.getChild(x); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); + if (child2 != null) { + if ("androidx.appcompat.app.ActionBar$Tab".equals(child2.getClassName())) { + for (int y = 0; y < child2.getChildCount(); y++) { + AccessibilityNodeInfo child3 = child2.getChild(y); + String text = child3.getText().toString(); + if (text != null) { + boolean status = text.contains("作品"); + if (status) { + if (text.length() > 2) { + zuopinnum = child3.getText().toString().substring(3); + Log.e("TIAOSHI###", "获得的作品数==" + zuopinnum); + if (!zuopinnum.equals("-") && zuopinnum != null) { + if (Integer.parseInt(zuopinnum) < Integer.parseInt(ChangLiang.dav_minimumzuopin) || Integer.parseInt(zuopinnum) > Integer.parseInt(ChangLiang.dav_maxmumzuopin)) { + Log.e("TIAOSHI###", "获取的该用户作品数" + Integer.parseInt(zuopinnum) + "小于设置的加关作品数(不在区间" + Integer.parseInt(ChangLiang.dav_minimumzuopin) + "-" + Integer.parseInt(ChangLiang.dav_maxmumzuopin) + "),作品数不满足条件"); + AblViewUtil.onMessage("作品数不满足条件"); + ChangLiang.dav_condition = "1"; + return; + } else { + Log.e("TIAOSHI###", "获取的该用户作品数不小于设置的加关作品数,满足加关点赞评论条件"); + } + } + } + } + } + } + } + } + } + } + // AblViewUtil.mySleep(2); + } + } + } + + /** + * 获得关注数 + */ + private void getargone() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { + // Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("android.widget.LinearLayout".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); + if (child2.getText() != null) { + if (child2.getText().equals("获赞")) { + AccessibilityNodeInfo parent = child2.getParent(); + AccessibilityNodeInfo child3 = parent.getChild(0); + Log.e("TIAOSHI###", "获得的获赞数==" + child3.getText().toString()); + huozannum = child3.getText().toString(); + if (child3.getText().toString().equals("-")) { + Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); + } + //return; + } + if (child2.getText().equals("关注")) { + AccessibilityNodeInfo parent = child2.getParent(); + AccessibilityNodeInfo child3 = parent.getChild(0); + Log.e("TIAOSHI###", "获得的关注数==" + child3.getText().toString()); + guanzhunum = child3.getText().toString(); + if (child3.getText().toString().equals("-")) { + Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); + } + //return; + } + if (child2.getText().equals("粉丝")) { + AccessibilityNodeInfo parent = child2.getParent(); + AccessibilityNodeInfo child3 = parent.getChild(0); + Log.e("TIAOSHI###", "获得的粉丝数==" + child3.getText().toString()); + fensinum = child3.getText().toString(); + if (child3.getText().toString().equals("-")) { + Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); + } + return; + } + } + } + } + } + } + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep25.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep25.java new file mode 100644 index 0000000..83c4ee9 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep25.java @@ -0,0 +1,339 @@ +package com.fisherbone.fuzhu.step; + +import android.graphics.Rect; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; + +import java.util.ArrayList; +import java.util.List; + +/** + * @param + * @description 潜在客户加关 + * @return + */ +public class TestAblStep25 extends TestAblStepBase { + private static final String TAG = "Conmon"; + private ArrayList objects = new ArrayList<>(); + + @Override + public void onStep(int step, Message msg) { + + // Log.e("TIAOSHI###==获得一键取互相关注的参数",ChangLiang.cancelclosed+"---"+ChangLiang.cancelcrosscor+"---"+ChangLiang.passnumber+"---"+ChangLiang.swiinterval+"---"+ChangLiang.minthrthr+""); + switch (step) { + case AblSteps.STEP_170: + AblViewUtil.startApplication(); + objects.clear(); + objects.add(ChangLiang.dav_douyinname); + AblViewUtil.mySleep(10); + AblStepHandler.sendMsg(AblSteps.STEP_171); + break; + case AblSteps.STEP_171: + + //点击右上角搜索 + DianSou(); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_172); + break; + case AblSteps.STEP_172: + AblViewUtil.mySleep(1); + // ChangLiang.dav_ishuadong = "T"; + //输入关键词 + //判断有无要加关的关键词,如果有则执行112,没有则执行113 + if (objects.size() > 0) { + //复制文本粘贴在留言板 + AccessibilityNodeInfo findcomentt = findEditText(); + // String conment = objects.get(0); + String conment = "赏金猎人"; + Log.e("TIAOSHI###", "获得的关键词内容" + conment); + AblViewUtil.mySleep(1); + if (ChangLiang.phonetype.equals("0")) { + AblViewUtil.sayInput(conment, findcomentt); + } else { + AblViewUtil.sayInput(conment, findcomentt);//华为畅享20 + } + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_173); + } + break; + case AblSteps.STEP_173: + //点击列表第一个,进入加关页面 +// AccessibilityNodeInfo firstview = firstview(); +// AblService.getInstance().clickcommontwo(firstview, "第一条"); + DianSou(); + AblViewUtil.mySleep(2); + AblService.getInstance().inputClickId("用户");//红米7a + AblViewUtil.mySleep(2); + //用坐标点的方式点击第一条 0,256 720,404 + AblService.getInstance().clickPoint(360, 330, 300); + AblViewUtil.mySleep(2); + getfensi(); + AblViewUtil.mySleep(1); + //点击进入用户关注页 + AblViewUtil.mySleep(1); + //用坐标点的方式点击第一条 0,256 720,404 + AblService.getInstance().clickPoint(160, 1280, 300); + AblStepHandler.sendMsg(AblSteps.STEP_174); + break; + case AblSteps.STEP_174: + AblViewUtil.mySleep(2); + String substring = getTime().substring(1); + Log.e("TIAOSHI###", "----获取的时间:" + substring); + boolean compliance = Compliance(substring); + Log.e("TIAOSHI###", "----是否是近7天的时间:" + compliance); + if (!compliance) { + //向上滑动 + AblService.getInstance().randomSwipetwo(); + AblViewUtil.mySleep(2); + String str1 = getTime().substring(1); + Log.e("TIAOSHI###", "----获取的时间:" + str1); + boolean comp1 = Compliance(str1); + Log.e("TIAOSHI###", "----是否是近7天的时间:" + comp1); + if (!comp1) { + //向上滑动 + AblService.getInstance().randomSwipetwo(); + AblViewUtil.mySleep(2); + String str2 = getTime().substring(1); + Log.e("TIAOSHI###", "----获取的时间:" + str2); + boolean comp2 = Compliance(str2); + Log.e("TIAOSHI###", "----是否是近7天的时间:" + comp2); + if (!comp2) { + //向上滑动 + AblService.getInstance().randomSwipetwo(); + AblViewUtil.mySleep(2); + String str3 = getTime().substring(1); + Log.e("TIAOSHI###", "----获取的时间:" + str3); + boolean comp3 = Compliance(str3); + Log.e("TIAOSHI###", "----是否是近7天的时间:" + comp3); + if (!comp3) { + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblStepHandler.getInstance().setStop(true); + AblViewUtil.potfinish(ChangLiang.dav_douyinname_id,"停止","1"); + AblViewUtil.mySleep(5); + return; + } + } + } + } + AblViewUtil.mySleep(2); + if (ChangLiang.phonetype.equals("0")) { + AblService.getInstance().clickPoint(659, 810, 300);//红米7a + } else { + AblService.getInstance().clickPoint(659, 1066, 300);//华为畅享20 3.评论 [619,1026][699,1106] + } + ChangLiang.dav_qianzai = "T"; + Log.e("TIAOSHI###", "点击评论按钮"); + AblStepHandler.sendMsg(AblSteps.STEP_175); + break; + case AblSteps.STEP_175: + //检索关键词 + cancelGuanzhu(AblService.getInstance()); + break; + case AblSteps.STEP_176: + break; + case AblSteps.STEP_177: + //发送私信 + fasongsixin(AblService.getInstance()); + break; + case AblSteps.STEP_178: + AblViewUtil.mySleep(1); + //向上滑动 + AblService.getInstance().randomSwipetwo(); + AblViewUtil.mySleep(1); + String substrin1 = getTime().substring(1); + Log.e("TIAOSHI###", "----获取的时间:" + substrin1); + boolean compliance1 = Compliance(substrin1); + Log.e("TIAOSHI###", "----是否是近7天的时间:" + compliance1); + if (compliance1) { + AblStepHandler.sendMsg(AblSteps.STEP_174); + } else { + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblStepHandler.getInstance().setStop(true); + AblViewUtil.potfinish(ChangLiang.dav_douyinname_id,"停止","1"); + AblViewUtil.mySleep(3); + } + break; + case AblSteps.STEP_179: + break; + default: + } + } + + private void cancelGuanzhu(AblService instance) { + AblViewUtil.mySleep(2); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode--:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.LinearLayout".equals(child.getClassName())) { + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode--:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("androidx.viewpager.widget.ViewPager".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode--:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child2.getClassName())) { + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + Log.e("TIAOSHI###", "----fourNode--:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); + Log.e("TIAOSHI###", "----fourNode--数量:" + child3.getChildCount()); + if (child3 != null) { + if (child3.getChildCount() == 7 || child3.getChildCount() == 8) { + for (int r = 0; r < child3.getChildCount(); r++) { + if (child3.getChild(r) != null) { + if ("android.widget.TextView".equals(child3.getChild(r).getClassName())) { + if (child3.getChild(r).getText() != null) { + // if (child3.getChild(r).getText().toString().contains(ChangLiang.dav_keyword)) { + if (isBaohan(child3.getChild(r).getText().toString())) { + Log.e("TIAOSHI###", "包含关键词----进入详情:" + child3.getChildCount()); + // clickcommonthree(child3.getChild(0), "头像" + child3.getChild(1).getText()); + if (child3.getChild(0) != null) { + Rect rect = new Rect(); + child3.getChild(0).getBoundsInScreen(rect); + if(ChangLiang.phonetype.equals("0")){//红米7A + if (rect.top >= 349 && rect.bottom <= 1238&&rect.right<=96) { + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + "用户头像" + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + }else { + Log.e("TIAOSHI###", "不在区间内"); + continue; + } + }else { + if (rect.top >= 628 && rect.bottom <= 1479&&rect.right<=96) { + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + "用户头像" + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + }else { + Log.e("TIAOSHI###", "不在区间内"); + continue; + } + } + + } else { + Log.e("TIAOSHI###", "没有找到" + "用户头像" + "按钮"); + return; + } + AblViewUtil.mySleep(2); + AblViewUtil.mySleep(2); + //添加关注 + AccessibilityNodeInfo getquxiaoguanzhu = getquxiaoguanzhu(); + AblViewUtil.mySleep(1); + clickcommonthree(getquxiaoguanzhu, "关注"); + AblViewUtil.mySleep(1); + fasongsixin(AblService.getInstance()); + + } + } + } + } + } + } + } + } + } + } + } + } + } + } + + AblViewUtil.mySleep(3); + //获取一屏幕数据:快照 + List itemss = AblService.getInstance().getRootInActiveWindow().findAccessibilityNodeInfosByText("部分评论因未授权"); + Log.e("TIAOSHI###", "----打印数据:" + itemss.size() + ChangLiang.dav_qianzai); + if (itemss.size() > 0) { + Log.e("TIAOSHI###", "大哥到底了"); + Log.d(TAG, "大哥到底了 "); + ChangLiang.dav_qianzai = "F"; + AblViewUtil.back(); + AblStepHandler.sendMsg(AblSteps.STEP_178); + return; + } + List itemsss = AblService.getInstance().getRootInActiveWindow().findAccessibilityNodeInfosByText("暂时没有更多了"); + Log.e("TIAOSHI###", "----打印数据:" + itemsss.size() + ChangLiang.dav_qianzai); + if (itemsss.size() > 0) { + Log.e("TIAOSHI###", "大哥到底了"); + Log.d(TAG, "大哥到底了 "); + ChangLiang.dav_qianzai = "F"; + AblViewUtil.back(); + AblStepHandler.sendMsg(AblSteps.STEP_178); + return; + } + if (ChangLiang.dav_qianzai.equals("T")) { + Log.e("TIAOSHI###", "----打印数据:" + "执行了"); + Log.e("TIAOSHI###", "----正常:" + ChangLiang.dav_qianzai); + AblViewUtil.mySleep(1); + // randomSwipe(); + AccessibilityNodeInfo chilrecy = getrecy(); + chilrecy.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); //触发容器元素的滚动事件 + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_175); + } + } + + private void fasongsixin(AblService instance) { + //通过坐标点的方式获得node节点id + if (ChangLiang.phonetype.equals("0")) { + instance.clickPoint(656, 107, 300);//红米7a //点击右上角菜单[624,75][688,139] + } else { + instance.clickPoint(664, 92, 300);//华为畅享20 [640,68][688,116] + } + Log.e("TIAOSHI###", "点击了更多按钮"); + AblViewUtil.mySleep(2); + //点击发私信 + List list = AblViewUtil.findByText("发私信"); + for (AccessibilityNodeInfo item : list) { + clickcommonthree(item, "发私信"); + } + AblViewUtil.mySleep(2); +// //寻找编辑控件 + AccessibilityNodeInfo findcomentt = findcoment(); +// //复制粘贴内容 + String conment = getConment(); + Log.e("TIAOSHI###", "获得的信息内容" + conment); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "获得的信息内容" + conment); + if (ChangLiang.phonetype.equals("0")) { + Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype); + //郝总的手机用第一个评论不上去 + // AblViewUtil.paste(findcomentt, conment);//红米7a + AblViewUtil.sayInput(conment, findcomentt); + } else { + Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype); + AblViewUtil.sayInput(conment, findcomentt);//华为畅享20 + } + //发送 + AblViewUtil.mySleep(2); +// //点击发送 + AccessibilityNodeInfo findcomenttt = findcomentt(); + if (findcomentt != null) { + AblService.getInstance().clickcommonthree(findcomenttt, "发送"); + AblViewUtil.mySleep(2); + } + AblViewUtil.mySleep(2); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep26.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep26.java new file mode 100644 index 0000000..fb204b9 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep26.java @@ -0,0 +1,271 @@ +package com.fisherbone.fuzhu.step; + +import android.graphics.Rect; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; + +import java.util.ArrayList; +import java.util.List; + +/** + * @param + * @description 潜在客户加关(关键词) + * @return + */ +public class TestAblStep26 extends TestAblStepBase { + private static final String TAG = "Conmon"; + private ArrayList objects = new ArrayList<>(); + + @Override + public void onStep(int step, Message msg) { + + // Log.e("TIAOSHI###==获得一键取互相关注的参数",ChangLiang.cancelclosed+"---"+ChangLiang.cancelcrosscor+"---"+ChangLiang.passnumber+"---"+ChangLiang.swiinterval+"---"+ChangLiang.minthrthr+""); + switch (step) { + case AblSteps.STEP_160: + AblViewUtil.startApplication(); + objects.clear(); + objects.add(ChangLiang.dav_douyinname); + AblViewUtil.mySleep(10); + AblStepHandler.sendMsg(AblSteps.STEP_161); + break; + case AblSteps.STEP_161: + //点击右上角搜索 + DianSou(); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_162); + break; + case AblSteps.STEP_162: + AblViewUtil.mySleep(1); + // ChangLiang.dav_ishuadong = "T"; + //输入关键词 + //判断有无要加关的关键词,如果有则执行112,没有则执行113 + if (objects.size() > 0) { + //复制文本粘贴在留言板 + AccessibilityNodeInfo findcomentt = findEditText(); + String conment = objects.get(0); + Log.e("TIAOSHI###", "获得的关键词内容" + conment); + AblViewUtil.mySleep(1); + if (ChangLiang.phonetype.equals("0")) { + AblViewUtil.sayInput(conment, findcomentt); + } else { + AblViewUtil.sayInput(conment, findcomentt);//华为畅享20 + } + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_163); + } + break; + case AblSteps.STEP_163: + //点击列表第一个,进入加关页面 + DianSou(); + AblViewUtil.mySleep(3); + //(344,191) + AblService.getInstance().clickPoint(244, 191, 300); + AblViewUtil.mySleep(1); + //点击进入用户关注页 + AblViewUtil.mySleep(5); + //用坐标点的方式点击第一条 0,256 720,404 + AblService.getInstance().clickPoint(160, 1280, 300); + AblStepHandler.sendMsg(AblSteps.STEP_164); + break; + case AblSteps.STEP_164: + AblViewUtil.mySleep(2); + if (ChangLiang.phonetype.equals("0")) { + AblService.getInstance().clickPoint(659, 810, 300);//红米7a + } else { + AblService.getInstance().clickPoint(659, 1066, 300);//华为畅享20 3.评论 [619,1026][699,1106] + } + ChangLiang.dav_qianzai = "T"; + Log.e("TIAOSHI###", "点击评论按钮"); + AblStepHandler.sendMsg(AblSteps.STEP_165); + break; + case AblSteps.STEP_165: + //检索关键词 + cancelGuanzhu(AblService.getInstance()); + break; + case AblSteps.STEP_166: + break; + case AblSteps.STEP_167: + //发送私信 + fasongsixin(AblService.getInstance()); + + break; + case AblSteps.STEP_168: + AblViewUtil.mySleep(1); + //向上滑动 + AblService.getInstance().randomSwipetwo(); + AblStepHandler.sendMsg(AblSteps.STEP_164); + break; + case AblSteps.STEP_169: + + break; + default: + + } + } + + private void cancelGuanzhu(AblService instance) { + AblViewUtil.mySleep(2); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode--:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.LinearLayout".equals(child.getClassName())) { + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode--:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("androidx.viewpager.widget.ViewPager".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode--:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child2.getClassName())) { + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + // Log.e("TIAOSHI###", "----fourNode--:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); + Log.e("TIAOSHI###", "----fourNode--数量:" + child3.getChildCount()); + if (child3 != null) { + if (child3.getChildCount() == 7 || child3.getChildCount() == 8) { + for (int r = 0; r < child3.getChildCount(); r++) { + if (child3.getChild(r) != null) { + if ("android.widget.TextView".equals(child3.getChild(r).getClassName())) { + if (child3.getChild(r).getText() != null) { + // if (child3.getChild(r).getText().toString().contains(ChangLiang.dav_keyword)) { + if (isBaohan(child3.getChild(r).getText().toString())) { + Log.e("TIAOSHI###", "包含关键词----进入详情:" + child3.getChildCount()); + // clickcommonthree(child3.getChild(0), "头像" + child3.getChild(1).getText()); + if (child3.getChild(0) != null) { + Rect rect = new Rect(); + child3.getChild(0).getBoundsInScreen(rect); + if (ChangLiang.phonetype.equals("0")) {//红米7A + if (rect.top >= 349 && rect.bottom <= 1238 && rect.right <= 96) { + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + "用户头像" + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "不在区间内"); + continue; + } + } else { + if (rect.top >= 628 && rect.bottom <= 1479 && rect.right <= 96) { + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + "用户头像" + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "不在区间内"); + continue; + } + } + + } else { + Log.e("TIAOSHI###", "没有找到" + "用户头像" + "按钮"); + return; + } + AblViewUtil.mySleep(2); + AblViewUtil.mySleep(2); + //添加关注 + AccessibilityNodeInfo getquxiaoguanzhu = getquxiaoguanzhu(); + AblViewUtil.mySleep(1); + clickcommonthree(getquxiaoguanzhu, "关注"); + AblViewUtil.mySleep(1); + fasongsixin(AblService.getInstance()); + + } + } + } + } + } + } + } + } + } + } + } + } + } + } + + AblViewUtil.mySleep(3); + //获取一屏幕数据:快照 + List itemss = AblService.getInstance().getRootInActiveWindow().findAccessibilityNodeInfosByText("部分评论因未授权"); + Log.e("TIAOSHI###", "----打印数据:" + itemss.size() + ChangLiang.dav_qianzai); + if (itemss.size() > 0) { + Log.e("TIAOSHI###", "大哥到底了"); + Log.d(TAG, "大哥到底了 "); + ChangLiang.dav_qianzai = "F"; + AblViewUtil.back(); + AblStepHandler.sendMsg(AblSteps.STEP_168); + return; + } + List itemsss = AblService.getInstance().getRootInActiveWindow().findAccessibilityNodeInfosByText("暂时没有更多了"); + Log.e("TIAOSHI###", "----打印数据:" + itemsss.size() + ChangLiang.dav_qianzai); + if (itemsss.size() > 0) { + Log.e("TIAOSHI###", "大哥到底了"); + Log.d(TAG, "大哥到底了 "); + ChangLiang.dav_qianzai = "F"; + AblViewUtil.back(); + AblStepHandler.sendMsg(AblSteps.STEP_168); + return; + } + if (ChangLiang.dav_qianzai.equals("T")) { + Log.e("TIAOSHI###", "----打印数据:" + "执行了"); + Log.e("TIAOSHI###", "----正常:" + ChangLiang.dav_qianzai); + AblViewUtil.mySleep(1); + // randomSwipe(); + AccessibilityNodeInfo chilrecy = getrecy(); + chilrecy.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); //触发容器元素的滚动事件 + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_165); + } + } + + private void fasongsixin(AblService instance) { + //通过坐标点的方式获得node节点id + if (ChangLiang.phonetype.equals("0")) { + instance.clickPoint(656, 107, 300);//红米7a //点击右上角菜单[624,75][688,139] + } else { + instance.clickPoint(664, 92, 300);//华为畅享20 [640,68][688,116] + } + + Log.e("TIAOSHI###", "点击了更多按钮"); + AblViewUtil.mySleep(2); + //点击发私信 + List list = AblViewUtil.findByText("发私信"); + for (AccessibilityNodeInfo item : list) { + clickcommonthree(item, "发私信"); + } + AblViewUtil.mySleep(2); +// //寻找编辑控件 + AccessibilityNodeInfo findcomentt = findcoment(); +// //复制粘贴内容 + String conment = getConment(); + Log.e("TIAOSHI###", "获得的信息内容" + conment); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "获得的信息内容" + conment); + if (ChangLiang.phonetype.equals("0")) { + Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype); + //郝总的手机用第一个评论不上去 + // AblViewUtil.paste(findcomentt, conment);//红米7a + AblViewUtil.sayInput(conment, findcomentt); + } else { + Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype); + AblViewUtil.sayInput(conment, findcomentt);//华为畅享20 + } + //发送 + AblViewUtil.mySleep(2); +// //点击发送 + AccessibilityNodeInfo findcomenttt = findcomentt(); + if (findcomentt != null) { + AblService.getInstance().clickcommonthree(findcomenttt, "发送"); + AblViewUtil.mySleep(2); + } + AblViewUtil.mySleep(2); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep27.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep27.java new file mode 100644 index 0000000..da396da --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep27.java @@ -0,0 +1,89 @@ +package com.fisherbone.fuzhu.step; + +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.entity.FensiBean; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; + +/** + * @param + * @description 作品分享(话术),和视频直播间的区别在于一个是发送自己的,一个是发送别人的 + * @return + */ +public class TestAblStep27 extends NoticeBase { + private static final String TAG = "Conmon"; + private int number=0; + @Override + public void onStep(int step, Message msg) { + + switch (step) { + case AblSteps.STEP_120: + AblViewUtil.startApplication(); + AblViewUtil.mySleep(10); + AblStepHandler.sendMsg(AblSteps.STEP_121); + break; + case AblSteps.STEP_121: + myClick(); + AblViewUtil.mySleep(2); + //0,1012 238,1329 + AblService.getInstance().clickPoint(119, 1170, 300); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_122); + break; + case AblSteps.STEP_122://勾选好友 + if(number== ChangLiang.bnumber){ + Log.e("TIAOSHI###", "达到循环发送私信的次数,开始执行停止。"); + //让服务暂停 + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.potgegin("停止"); + return; + } + number=number+1; + //619,910 699 990 + AblService.getInstance().clickPoint(659, 950, 300); + AblViewUtil.mySleep(2); + //40,1008 136,1104 + AblService.getInstance().clickPoint(88, 1056, 300); + AblViewUtil.mySleep(3); + AblService.getInstance().clickPoint(700, 449, 300);//点击a + AblViewUtil.mySleep(2); + //先进行定位 + FensiBean fensi = ProfileSpUtils.getInstance().getFensi(); + String nikename = fensi.getNikename(); + Log.e("TIAOSHI###nikename", nikename); + String zimu = fensi.getZimu(); + // getdouyin(); + if(!nikename.equals("")) { + AccessibilityNodeInfo chilrecy = getguanjian(); + scroll2PositionClick(AblService.getInstance(), nikename, chilrecy); + }else { + getdouyin(); + } + AblStepHandler.sendMsg(AblSteps.STEP_123); + break; + case AblSteps.STEP_123: + //发送私信 + fasongsixin(AblService.getInstance()); + break; + case AblSteps.STEP_124: + //619,910 699 990 + AblService.getInstance().clickPoint(659, 950, 300); + AblViewUtil.mySleep(2); + //40,1008 136,1104 + AblService.getInstance().clickPoint(88, 1056, 300); + AblViewUtil.mySleep(1); + break; + default: + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep28.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep28.java new file mode 100644 index 0000000..a0dae96 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep28.java @@ -0,0 +1,224 @@ +package com.fisherbone.fuzhu.step; + +import android.graphics.Rect; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.entity.FensiBean; +import com.fisherbone.fuzhu.entity.NoticeBean; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; + +import java.util.ArrayList; + +/** + * @param + * @description 作品分享(话术),和视频直播间的区别在于一个是发送自己的,一个是发送别人的 + * @return + */ +public class TestAblStep28 extends NoticeBase { + private static final String TAG = "Conmon"; + private ArrayList objects = new ArrayList<>(); + private String conment; + private int number=0; + + @Override + public void onStep(int step, Message msg) { + + switch (step) { + case AblSteps.STEP_80: + AblViewUtil.startApplication(); + objects.clear(); + // objects.add("赏金猎人"); + NoticeBean fensiNotice = ProfileSpUtils.getInstance().getFensiNotice(); + String douyin = fensiNotice.getDouyin(); + objects.add(douyin); + AblViewUtil.mySleep(10); + AblStepHandler.sendMsg(AblSteps.STEP_81); + break; + case AblSteps.STEP_81: + //点击右上角搜索 + DianSou(); + AblViewUtil.mySleep(2); + AblViewUtil.mySleep(1); + // ChangLiang.dav_ishuadong = "T"; + //输入关键词 + //判断有无要加关的关键词,如果有则执行112,没有则执行113 + if (objects.size() > 0) { + //复制文本粘贴在留言板 + AccessibilityNodeInfo findcomentt = findEditText(); + String conment = objects.get(0); + // String conment = "赏金猎人"; + Log.e("TIAOSHI###", "获得的关键词内容" + conment); + AblViewUtil.mySleep(1); + if (ChangLiang.phonetype.equals("0")) { + AblViewUtil.sayInput(conment, findcomentt); + } else { + AblViewUtil.sayInput(conment, findcomentt);//华为畅享20 + } + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_82); + } + break; + case AblSteps.STEP_82: + DianSou(); + AblViewUtil.mySleep(2); + AblService.getInstance().inputClickId("用户");//红米7a + AblViewUtil.mySleep(2); + //用坐标点的方式点击第一条 0,256 720,404 + AblService.getInstance().clickPoint(360, 330, 300); + AblViewUtil.mySleep(2); + AblViewUtil.mySleep(1); + //点击进入用户关注页 + AblViewUtil.mySleep(1); + //用坐标点的方式点击第一条 0,256 720,404 + AblService.getInstance().clickPoint(160, 1280, 300); + AblViewUtil.mySleep(3); + String substring = getTime().substring(1); + Log.e("TIAOSHI###", "----获取的时间2:" + substring); + boolean compliance = Compliance(substring); + Log.e("TIAOSHI###", "----是否是近7天的时间:" + compliance); + if(compliance){ + //进入该用户的第一条作品 + AblStepHandler.sendMsg(AblSteps.STEP_83); + }else { + Log.e("TIAOSHI###", "不在7天之内,开始执行停止。"); + //让服务暂停 + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.potgegin("停止"); + } + break; + case AblSteps.STEP_83: + //619,910 699 990 + if(number==ChangLiang.bnumber){ + Log.e("TIAOSHI###", "达到循环发送私信的次数,开始执行停止。"); + //让服务暂停 + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.potgegin("停止"); + return; + } + number=number+1; + AblService.getInstance().clickPoint(659, 950, 300); + AblViewUtil.mySleep(2); + //40,1008 136,1104 + AblService.getInstance().clickPoint(88, 1056, 300); + AblViewUtil.mySleep(2); + AblService.getInstance().clickPoint(700, 449, 300);//点击a + AblViewUtil.mySleep(3); + //先进行定位 + FensiBean fensi = ProfileSpUtils.getInstance().getFensi(); + String nikename = fensi.getNikename(); + Log.e("TIAOSHI###nikename", nikename); + String zimu = fensi.getZimu(); + if(!nikename.equals("")) { + AccessibilityNodeInfo chilrecy = getguanjian(); + scroll2PositionClick(AblService.getInstance(), nikename, chilrecy); + }else { + getdouyin(); + } + AblStepHandler.sendMsg(AblSteps.STEP_84); + break; + case AblSteps.STEP_84: + //发送私信 + fasongsixintwo(AblService.getInstance()); + break; + case AblSteps.STEP_85: + //619,910 699 990 + AblService.getInstance().clickPoint(659, 950, 300); + AblViewUtil.mySleep(2); + //40,1008 136,1104 + AblService.getInstance().clickPoint(88, 1056, 300); + AblViewUtil.mySleep(1); + break; + default: + } + } + + public String getTime() { + String substring = ""; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); + Rect rect = new Rect(); + child3.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----fourNode:" +"("+rect.left+","+rect.top+")"+","+"("+rect.right+","+rect.bottom+")"); + + + if(ChangLiang.phonetype.equals("0")){//红米7A + //(167,938),(408,973) + if (rect.top >= 934 && rect.bottom <= 1150) { + if("android.widget.TextView".equals(child3.getClassName())){ + String s = child3.getText().toString(); + substring = s.substring(1); + Log.e("TIAOSHI###", "----获取的时间1:" + substring); + + } + }else { + // Log.e("TIAOSHI###", "不在区间内"); + continue; + } + }else { + //(189,1130),(350,1170) + if (rect.top >= 1130 && rect.bottom <= 1401) { + if("android.widget.TextView".equals(child3.getClassName())){ + String s = child3.getText().toString(); + substring = s.substring(1); + Log.e("TIAOSHI###", "----获取的时间:" + substring); + } + }else { + // Log.e("TIAOSHI###", "不在区间内"); + continue; + } + } + } + } + } + } + return substring; + } + + /** + * 判断是否是近7天的时间 + * @param substring + * @return + * //2020年12月30日 01月01日 04月22 1天前 2天前 3天前 4天前 5天前 6天前 13小时前 5分钟前 + */ + public boolean Compliance(String substring){ + if(substring.contains("1天前")||substring.contains("2天前")||substring.contains("3天前")||substring.contains("4天前")||substring.contains("5天前")||substring.contains("6天前")||substring.contains("小时前")||substring.contains("分钟前")){ + // if(substring.contains("1天前")){ + return true; + }else { + return false; + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep29.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep29.java new file mode 100644 index 0000000..ca6b6ac --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep29.java @@ -0,0 +1,142 @@ +package com.fisherbone.fuzhu.step; + +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.entity.FensiBean; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; + +import java.util.ArrayList; + +/** + * @param + * @description 作品分享(话术),和视频直播间的区别在于一个是发送自己的,一个是发送别人的 + * @return + */ +public class TestAblStep29 extends NoticeBase { + private static final String TAG = "Conmon"; + private ArrayList objects = new ArrayList<>(); + private int number=0; + @Override + public void onStep(int step, Message msg) { + + switch (step) { + case AblSteps.STEP_201: + AblViewUtil.startApplication(); + objects.clear(); + // objects.add("红莲茶叶"); + objects.add("海岚香电子商务"); + AblViewUtil.mySleep(10); + AblStepHandler.sendMsg(AblSteps.STEP_202); + break; + case AblSteps.STEP_202: + // DianZhibo(); + DianSou(); + AblViewUtil.mySleep(3); + if (objects.size() > 0) { + //复制文本粘贴在留言板 + AccessibilityNodeInfo findcomentt = findEditText(); + String conment = objects.get(0); + // String conment = "赏金猎人"; + Log.e("TIAOSHI###", "获得的关键词内容" + conment); + AblViewUtil.mySleep(1); + if (ChangLiang.phonetype.equals("0")) { + AblViewUtil.sayInput(conment, findcomentt); + } else { + AblViewUtil.sayInput(conment, findcomentt);//华为畅享20 + } + AblViewUtil.mySleep(3); + DianSou(); + AblViewUtil.mySleep(3); + AccessibilityNodeInfo getdaohang = getdaohang(); + getdaohang.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); //触发容器元素的滚动事件 + AblViewUtil.mySleep(3); + selecttype("2");//1为用户 2为直播 + AblViewUtil.mySleep(3); + //进入直播间 + AblService.getInstance().clickPoint(100, 300, 300);//点击a + AblStepHandler.sendMsg(AblSteps.STEP_203); + } + break; + case AblSteps.STEP_203://勾选好友 + Log.e("TIAOSHI###", "测试次数"+number); + if(number==ChangLiang.bnumber){ + Log.e("TIAOSHI###", "达到循环发送私信的次数,开始执行停止。"); + //让服务暂停 + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.potgegin("停止"); + return; + } + number=number+1; + AblViewUtil.mySleep(3); + //点击下方的更多 + clickmoreli("2"); + AblViewUtil.mySleep(2); + //点击分享 + share("1"); + AblViewUtil.mySleep(2); + //点击私信朋友 + share("2"); + AblViewUtil.mySleep(2); + AblService.getInstance().clickPoint(700, 449, 300);//点击a + AblViewUtil.mySleep(1); + //先进行定位 + FensiBean fensi = ProfileSpUtils.getInstance().getFensi(); + String nikename = fensi.getNikename(); + Log.e("TIAOSHI###nikename", nikename); + String zimu = fensi.getZimu(); + if(!nikename.equals("")) { + AccessibilityNodeInfo chilrecy = getguanjian(); + scroll2PositionClick(AblService.getInstance(), nikename, chilrecy); + }else { + getdouyin(); + } + AblStepHandler.sendMsg(AblSteps.STEP_204); + break; + case AblSteps.STEP_204: + //发送私信 + fasongsixinthree(AblService.getInstance()); + break; + default: + } + } + //点击右上角搜索 + //[624,67][688,131] + public void DianZhibo() { + if (ChangLiang.phonetype.equals("0")) { + AblService.getInstance().clickPoint(64, 99, 300);//红米7a + } else { + AblService.getInstance().clickPoint(659, 99, 300);//华为畅享20 + } + Log.e("TIAOSHI###", "点击搜索按钮"); + } + + + /** + * 获得顶部导航控件 + * @return + */ + private AccessibilityNodeInfo getdaohang() { + AccessibilityNodeInfo childw=null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { + childw=child; + } + } + return childw; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep30.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep30.java new file mode 100644 index 0000000..690ac56 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep30.java @@ -0,0 +1,743 @@ +package com.fisherbone.fuzhu.step; + +import android.graphics.Rect; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.FuzhuApplication; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.RandumInt; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.db.CommentBeanData; +import com.fisherbone.fuzhu.db.dao.CommentDao; +import com.fisherbone.fuzhu.entity.LiveBean; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.fisherbone.fuzhu.utils.StringUtils; +import com.jeremyliao.liveeventbus.LiveEventBus; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +import io.reactivex.Flowable; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.Disposable; +import io.reactivex.functions.Action; +import io.reactivex.functions.Consumer; + +/** + * @param + * @author manggou + * @description 直播间加热 + * @return + */ +public class TestAblStep30 extends NoticeBase { + private static final String TAG = "Conmon"; + private ArrayList objects = new ArrayList<>(); + private int number = 0; + private int liwusubstring; + private LiveBean liveBean; + private String direction ="0";//0代表向上滑动,1代表向下 + + @Override + public void onStep(int step, Message msg) { + + switch (step) { + case AblSteps.STEP_210: + int time = getTime(); + Log.e("TIAOSHI###", "直播间停留时间" + time); + taskdaojishi(time); + AblViewUtil.startApplication(); + AblViewUtil.mySleep(3); + allowed(); + objects.clear(); + liveBean = ProfileSpUtils.getInstance().getLiveBean(); + objects.add(liveBean.getDouyinhao()); + AblViewUtil.mySleep(7); + AblStepHandler.sendMsg(AblSteps.STEP_211); + break; + case AblSteps.STEP_211: + //1.关闭检测到更新的弹框 + closedJDialog(AblService.getInstance()); + AblViewUtil.mySleep(1); + closedzsDialog(AblService.getInstance()); + AblViewUtil.mySleep(1); + //2.关闭青少年弹窗 + closedQDialog(AblService.getInstance()); + AblViewUtil.mySleep(1); + closedBDialog(AblService.getInstance()); + AblViewUtil.mySleep(1); + AblStepHandler.sendMsg(AblSteps.STEP_212); + break; + case AblSteps.STEP_212: + AblViewUtil.mySleep(3); + if (objects.size() == 0) { + Log.e("TIAOSHI###", "没有获得抖音号,停止往下运行"); + return; + } + String content = objects.get(0); + Log.e("TIAOSHI###", "获得的关键词内容" + content); + boolean b1 = enterLive(); + if (b1) { + runLog("成功进入第一个直播间"); + AblStepHandler.sendMsg(AblSteps.STEP_213); + } else { + // runLog("进入第一个直播间失败"); + AblViewUtil.mySleep(2); + boolean b2 = enterLivetwo(); + if (b2) { + runLog("成功进入第一个直播间"); + AblStepHandler.sendMsg(AblSteps.STEP_213); + } else { + // runLog("进入第一个直播间失败"); + AblViewUtil.mySleep(2); + boolean b3 = enterLivetwo(); + if (b3) { + runLog("成功进入第一个直播间"); + againStart("1"); + AblStepHandler.sendMsg(AblSteps.STEP_213); + } else { + runLog("进入第一个直播间失败"); + againStart("0"); + } + } + } + // AblStepHandler.sendMsg(AblSteps.STEP_213); + break; + case AblSteps.STEP_213: + moveLive( objects.get(0)); + break; + case AblSteps.STEP_214: + AblViewUtil.mySleep(1); + if(liveBean.getSwitchtwo()) { + //直播间点赞 + if ("3".equals(ChangLiang.phonetype)) { + //每秒点赞:4-9次 每次点赞:10-15秒 + //点赞次数40-145次 + int randumInt40 = RandumInt.getRandumInt40(); + zhibodianzanc(randumInt40); + } else { + int randumInt40 = RandumInt.getRandumInt40(); + zhibodianzan(randumInt40); + } + } + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_215); + break; + case AblSteps.STEP_215: + if(liveBean.getSwitchone()) { + AblViewUtil.mySleep(2); + String conment = getConment(); + //直播间发送评论 + fasongpinglun(conment); + AblViewUtil.mySleep(5); + } + AblStepHandler.sendMsg(AblSteps.STEP_216); + //AblStepHandler.sendMsg(AblSteps.STEP_217); + // AblStepHandler.sendMsg(AblSteps.STEP_213); + break; + case AblSteps.STEP_216: + if(liveBean.getSwitchfive()) { + //直播间刷礼物 + AblViewUtil.mySleep(2); + //点开礼物 + clickmoreli(); + AblViewUtil.mySleep(2); + clickmenu("5"); + AblViewUtil.mySleep(2); + List geliwu = geliwu(); + if (geliwu.size() > 0) { + //获得礼物数 + AccessibilityNodeInfo nodeinfo = geliwu.get(0); + AccessibilityNodeInfo child9 = nodeinfo.getChild(nodeinfo.getChildCount() - 1); + if (child9.getText() != null) { + String str1 = child9.getText().toString(); + if (str1.contains(IFCONTIAN)) { + String substring = str1.substring(1); + liwusubstring = Integer.valueOf(substring); + Log.e("TIAOSHI###", "----礼物个数=:" + substring); + } + } + clickcommonthree(nodeinfo, ""); + AblViewUtil.mySleep(1); + //获得刷礼物的次数 +// LiveBean livebean = ProfileSpUtils.getInstance().getLiveBean(); +// String liwucishu = livebean.getLiwucishu(); +// int liwunum = Integer.valueOf(liwucishu); +// if (liwusubstring >= liwunum) { +// } else { +// liwunum = liwusubstring; +// } +// for (int i = 0; i < liwunum; i++) { +// AblViewUtil.mySleep(1); +// clickcommonthree(nodeinfo, ""); +// AblViewUtil.mySleep(4); +// } + for (int i = 0; i < liwusubstring; i++) { + AblViewUtil.mySleep(1); + clickcommonthree(nodeinfo, ""); + AblViewUtil.mySleep(4); + } + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + }else { + AblViewUtil.back(); + } + } + // AblStepHandler.sendMsg(AblSteps.STEP_217); + AblStepHandler.sendMsg(AblSteps.STEP_214); + break; + case AblSteps.STEP_217: + //直播间刷红包 + AblViewUtil.mySleep(2); + //点击发红包 + int getdoubi = getdoubi(); + //获得刷礼物的次数 + LiveBean liveBean1 = ProfileSpUtils.getInstance().getLiveBean(); + String hongbaonum = liveBean1.getHongbaonum(); + int fastnum = Integer.valueOf(hongbaonum); + int fastdoubi = fastnum * 20; + if (getdoubi >= fastdoubi) { + } else { + fastdoubi = getdoubi; + } + double num = fastdoubi / 20; + int intnum = new Double(num).intValue(); + if (intnum > 0) { + for (int i = 0; i < intnum; i++) { + AblViewUtil.mySleep(1); + //点开礼物 + clickmoreli(); + //触发容器元素的滚动事件 + ArrayList getrecyy = getrecyy(); + getrecyy.get(0).performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); + AblViewUtil.mySleep(3); + List geliwwu = geliwu("红包"); + AccessibilityNodeInfo hognbaonode = geliwwu.get(0); + clickcommonthree(hognbaonode, ""); + String hongbaotime = ProfileSpUtils.getInstance().getLiveBean().getHongbaotime(); + int jiangetime = Integer.valueOf(hongbaotime); + AblViewUtil.mySleep(jiangetime); + } + } else { + Log.e("TIAOSHI###", "发红包的抖币不够了"); + } + + AblStepHandler.sendMsg(AblSteps.STEP_218); + break; + case AblSteps.STEP_218: + //开始直播间跟单 + ChangLiang.gendanopen = 1; + Log.e("TIAOSHI###", "开始跟单"); + taskdaojishitwo(10); + break; + default: + } + } + + private void moveLive(String content) { + AblViewUtil.mySleep(2); + String nodeName = getNodeName(); + Log.e("TIAOSHI###", "直播间名字"+content); + if(nodeName.equals(content)){ + Log.e("TIAOSHI###", "成功进入指定直播间"); + AblStepHandler.sendMsg(AblSteps.STEP_214); + }else { + if("0".equals(direction)) { + liveUp(); + }else { + liveDown(); + } + AblStepHandler.sendMsg(AblSteps.STEP_213); + } + } + /** + * 直播间上滑 + */ + public void liveUp() { + AccessibilityNodeInfo getdaohang = getdaohang(); + if (getdaohang != null) { + boolean b = getdaohang.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); + Log.e("TIAOSHI###", "测试向上滑动" + b); + if (b) { + againStart("1"); + } else { + againStart("0"); + direction = "1"; + } + } + } + + /** + * 直播间下滑 + */ + public void liveDown() { + AccessibilityNodeInfo getdaohang = getdaohang(); + if (getdaohang != null) { + boolean b = getdaohang.performAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD); + Log.e("TIAOSHI###", "测试向下滑动" + b); + if (b) { + againStart("1"); + } else { + againStart("0"); + direction = "0"; + } + } + } + + /** + * 获得左上角主播的昵称 + * @return + */ + private String getNodeName() { + String nikename= ""; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // nodeZuobiao(child1); + nikename = AblViewUtil.getString(nikename, child1,148,193,0,1080,"android.widget.TextView"); + } + } + return nikename; + } + + public boolean enterLivetwo() { + boolean ifEnterOne = false; + AccessibilityNodeInfo nodeInfoS = getNodeInfoS(); + if (nodeInfoS != null) { + ifEnterOne = true; + } + return ifEnterOne; + } + + private void runLog(String str) { + LiveEventBus.get("some_key").post(str); + Log.e("TIAOSHI###", str); + } + + public boolean enterLive() { + boolean ifEnterOne = true; + //进入推荐页(刷新) + AblViewUtil.mySleep(1); + getNodeInfo("2"); + Log.e("TIAOSHI###", "点击关注"); + AblViewUtil.mySleep(2); + getNodeInfo("2"); + Log.e("TIAOSHI###", "点击关注"); + AblViewUtil.mySleep(5); + enterOneNodeInfo(); + AblViewUtil.mySleep(4); + AccessibilityNodeInfo nodeInfoS = getNodeInfoS(); + if (nodeInfoS != null) { + ifEnterOne = true; + } + return ifEnterOne; + } + + + /** + * 说点什么节点 + * + * @return + */ + public AccessibilityNodeInfo getNodeInfoS() { + AccessibilityNodeInfo nodeinfo = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "one----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "one----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); +// Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); +// nodeZuobiao(child2); + if(child2!=null) { + if ("android.widget.TextView".equals(child2.getClassName())) { + if (child2.getText() != null) { + if ("说点什么...".equals(child2.getText().toString())) { + nodeinfo = child2; + } + } + } + } + } + } + } + return nodeinfo; + } + + /** + * 进入第一个直播间 + */ + public void enterOneNodeInfo() { + AblService.getInstance().clickPoint(121, 379, 300); + } + + /** + * 1.同城 + * 2.关注 + * 3.推荐 + */ + public void getNodeInfo(String type) { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // nodeZuobiao(child); + //显示节点的坐标:(261,99),(447,220) + switch (type) { + //同城 + case "1": + TextViewClick(child, "同城"); + break; + //关注 + case "2": + TextViewClick(child, "关注"); + break; + //推荐 + case "3": + TextViewClick(child, "推荐"); + break; + default: + + } + + } + } + + /** + * TextView的点击 + * + * @param child2 + * @param str + */ + private void TextViewClick(AccessibilityNodeInfo child2, String str) { + if ("android.widget.TextView".equals(child2.getClassName())) { + if (child2.getText() != null) { + if (child2.getText().toString().equals(str)) { + Rect rect = new Rect(); + child2.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----显示节点的坐标:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + if (rect.top >= 99 && rect.bottom <= 220 && rect.left >= 261 && rect.right <= 819) { + AblService.getInstance().clickcommontwo(child2, ""); + return; + } + } + } + } + } + + /** + * 获得顶部导航控件 + * + * @return + */ + private AccessibilityNodeInfo getdaohang() { + AccessibilityNodeInfo childw = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + if (root != null) { + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if(child!=null) { + if ("android.widget.FrameLayout".equals(child.getClassName())) { + AblViewUtil.mySleep(2); + Log.e("TIAOSHI###", "出现了取消关注的弹框,点击坐标540,500关闭"); + AblService.getInstance().clickPoint(540, 500, 300); + AblViewUtil.mySleep(2); + getdaohang(); + } + } + if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { + // nodeZuobiao(child); + childw = child; + } + } + } + return childw; + } + + + private void fasongpinglun(String conment) { + //直播间话术 + AblViewUtil.mySleep(2); + clickmoreli("1"); + AblViewUtil.mySleep(2); + //复制文本粘贴在留言板 + AccessibilityNodeInfo getedittext = getedittext(); + Log.e("TIAOSHI###", "获得的关键词内容" + conment); + AblViewUtil.mySleep(1); + if (SHEBEITIPE_VILUEONE.equals(ChangLiang.phonetype)) { + AblViewUtil.sayInput(conment, getedittext); + } else { + //华为畅享20 + AblViewUtil.sayInput(conment, getedittext); + } + AblViewUtil.mySleep(1); + AccessibilityNodeInfo geouyintdd = geouyintdd(); + AblService.getInstance().clickcommontwo(geouyintdd, "点击发送"); + AblViewUtil.mySleep(2); + } + + + /** + * 直播间点赞 + * + * @param mun + */ + private void zhibodianzan(int mun) { + for (int i = 0; i < mun; i++) { +// int a = 300 + RandumInt.getRandumInt4() * 8; +// int b = 600 - RandumInt.getRandumInt4() * 10; + int a = 300 + RandumInt.getRandumInt4() * 10; + int b = 600 - RandumInt.getRandumInt4() * 12; + int c = 600 - RandumInt.getRandumInt4() * 50; + AblService.getInstance().clickPoint(a, b, 300); + try { + //隔200 ms 滚动一次 + Thread.sleep(c); + } catch (InterruptedException e) { + e.printStackTrace(); + } + // Log.e("TIAOSHI###", "点击了"); + } + } + /** + * 直播间点赞 + *100-300 + * @param mun + */ + public void zhibodianzanc(int mun) { + for (int i = 0; i < mun; i++) { + int a = 540 + RandumInt.getRandumInt4() * 10; + int b = 500 - RandumInt.getRandumInt4() * 12; + int c = 200 - RandumInt.getRandumInt4() * 20; + AblService.getInstance().clickPoint(a, b, 100); + try { + //隔200 ms + Thread.sleep(c); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + + + private int getTime() { + int hournum = 0; + int minnum = 0; + LiveBean liveBean = ProfileSpUtils.getInstance().getLiveBean(); + String zhibomin = liveBean.getZhibomin(); + Log.e("TIAOSHI###", "直播分钟数" + zhibomin); + if (!StringUtils.isEmpty(zhibomin)) { + int min = Integer.parseInt(zhibomin); + minnum = min * 60; + } + return hournum + minnum; + } + + /** + * 停任务的倒计时 + * + * @param a + */ + private void taskdaojishitwo(final int a) { + //启动计时器 + //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 + Disposable mdDisposable = Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) + .observeOn(AndroidSchedulers.mainThread()) + .doOnNext(new Consumer() { + @Override + public void accept(Long aLong) throws Exception { + long b = a - aLong; + Log.e("TIAOSHI###", b + ""); + } + }) + .doOnComplete(new Action() { + @Override + public void run() throws Exception { + AblStepHandler.getInstance().setStop(false); + Log.e("TIAOSHI###", "倒计时结束"); + //开始直播间跟单 + ChangLiang.gendanopen = 0; + AblViewUtil.mySleep(20); + AblStepHandler.sendMsg(AblSteps.STEP_213); + } + }) + .subscribe(); + } + + /** + * 停任务的倒计时 + * + * @param a + */ + private void taskdaojishi(final int a) { + //启动计时器 + //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 + Disposable mdDisposable = Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) + .observeOn(AndroidSchedulers.mainThread()) + .doOnNext(new Consumer() { + @Override + public void accept(Long aLong) throws Exception { + long b = a - aLong; + // Log.e("TIAOSHI###", b + ""); + } + }) + .doOnComplete(new Action() { + @Override + public void run() throws Exception { + AblStepHandler.getInstance().setStop(false); + Log.e("TIAOSHI###", "开始执行关闭抖音程序"); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.potgegin("停止"); + + } + }) + .subscribe(); + } + + + private ArrayList getrecyy() { + ArrayList objects = new ArrayList<>(); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { + objects.add(child1); + } + } + } + return objects; + } + + /** + * 获得背包中第一个位置的了礼物 + */ + private List geliwu(String text) { + List liwus = new ArrayList<>(); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + if ("android.view.ViewGroup".equals(child2.getClassName())) { + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); + if (child3.getText() != null) { + if (text.equals(child3.getText().toString())) { + liwus.add(child2); + } + } + } + } + } + } + } + return liwus; + } + + /** + * 获得抖币 + * + * @return + */ + private int getdoubi() { + int doubinum = 0; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + if ("android.widget.TextView".equals(child2.getClassName())) { + if (child2.getText() != null) { + String doubi = child2.getText().toString(); + Log.e("TIAOSHI###", "----抖币数:" + doubi); + doubinum = Integer.valueOf(doubi); + + } + } + } + } + } + return doubinum; + } + + /** + * 随机获取评论话术 + */ + private String getConment() { + CommentDao commentDao = new CommentDao(FuzhuApplication.getContext()); + List CommentBeanDatas = commentDao.queryInByCustom("type", "3"); + if (CommentBeanDatas.size() == 0) { + return "哈哈"; + } else if (CommentBeanDatas.size() == 1) { + CommentBeanData commentBeanData = CommentBeanDatas.get(0); + String comment = commentBeanData.getComment(); + return comment; + } else { + int i = new Random().nextInt(CommentBeanDatas.size() - 1); + CommentBeanData commentBeanData = CommentBeanDatas.get(i); + String comment = commentBeanData.getComment(); + return comment; + } + } + + + /** + * 点击直播间下方的更多按钮(备注:通过搜索点击直播进去的可用) + * 1.说点什么 + * 2.更多 + * 3.礼物 + */ + public void clickmoreli() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + nodeZuobiao(child1); + if ("android.widget.RelativeLayout".equals(child1.getClassName())) { + if (child1.getContentDescription() != null) { + if (child1.getContentDescription().equals("礼物")) { + AblService.getInstance().clickcommontwo(child1, ""); + } + } + } + } + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep31.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep31.java new file mode 100644 index 0000000..d170670 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep31.java @@ -0,0 +1,799 @@ +package com.fisherbone.fuzhu.step; + +import android.graphics.Rect; +import android.os.Build; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import androidx.annotation.RequiresApi; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.entity.LiveSuiJiBean; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import io.reactivex.Flowable; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.Disposable; +import io.reactivex.functions.Action; +import io.reactivex.functions.Consumer; + +/** + * @author keriezhang + * @description 随机直播间抢福袋 + * @return + */ +public class TestAblStep31 extends HongbaoBase { + private List jiluBeans; + private List hongbaos; + private List times; + private int num3; + private boolean noqinmidu=true; + + @Override + public void onStep(int step, Message msg) { + + switch (step) { + case AblSteps.STEP_221: + AblViewUtil.startApplication(); + jiluBeans = new ArrayList<>(); + AblViewUtil.mySleep(3); + allowed(); + AblViewUtil.mySleep(5); + //点击直播1080 + AblService.getInstance().clickPoint(90, 163, 300); + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_222); + break; + case AblSteps.STEP_222: + Log.e("TIAOSHI###", "福袋测试STEP_222"); + AblViewUtil.mySleep(2); + //直播间的人数判断,不满足条件直接滑走 + String minnum = ProfileSpUtils.getInstance().getLiveSuiJiBean().getMinnum(); + int conminnum = Integer.valueOf(minnum); + String maxnum = ProfileSpUtils.getInstance().getLiveSuiJiBean().getMaxnum(); + int conmaxnum = Integer.valueOf(maxnum); + + //获取直播间人数 +// int personNum = getPersonNum(); +// AblViewUtil.mySleep(1); +// if(personNum<=conminnum||personNum>=conmaxnum){ +// huodong(); +// Log.e("TIAOSHI###", personNum+"直播间人数没有达到条件"+ChangLiang.phonetype); +// return; +// } + + //监听一次有没有控件 +// int jiedianhuoqutwo = jiedianhuoqutwo(); +// Log.e("TIAOSHI###", "获得的控件个数==" + jiedianhuoqutwo); +// if(jiedianhuoqutwo>=3){ +// huodong(); +// Log.e("TIAOSHI###", "控件数是>=3,肯定包含优惠卷和充能,滑走"+ChangLiang.phonetype); +// } +// if (jiedianhuoqutwo != 0) { +// AblStepHandler.sendMsg(AblSteps.STEP_223); +// } else { +// Log.e("TIAOSHI###", "没有监听到三个控件"); +// huodong(); +// } + + AblStepHandler.sendMsg(AblSteps.STEP_223); + break; + case AblSteps.STEP_223: + Log.e("TIAOSHI###", "福袋测试STEP_223"); + AblViewUtil.mySleep(2); + if (ifControlView()) { + AblViewUtil.mySleep(2); + kongjiandingweitwo(); + boolean shifouyoufudai = shifouyoufudai(); + Log.e("TIAOSHI###", "是否有福袋控件" + shifouyoufudai); + if (!shifouyoufudai) { + Log.e("TIAOSHI###", "页面布局发生变化,此位置上没有福袋控件"); + huodong(); + } + } else { + Log.e("TIAOSHI###", "页面上没有控件,滑走"); + huodong(); + } + break; + case AblSteps.STEP_224: + //直播间点赞 + Boolean switchtwo = ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchtwo(); + if(switchtwo) { + zhibodianzan(50); + } + AblStepHandler.sendMsg(AblSteps.STEP_225); + break; + case AblSteps.STEP_225: + AblViewUtil.mySleep(5); + Boolean switchone = ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchone(); + if(switchone) { + String conment = getConment(); + fasongpingluntwo(conment); + } + AblStepHandler.sendMsg(AblSteps.STEP_226); + break; + case AblSteps.STEP_226: + AblViewUtil.mySleep(5); + Boolean switchthree = ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchthree(); + if (switchthree) { + int num = jiedianhuoqutwo(); + if (num == 2) { + //做标记 + kongjiandingweitwo(); + //做时间判断,逻辑是福袋的时间比红包时间多60秒 + int hongbaoweizhi = hongbaoweizhi(); + int fudaiposition = fudaiposition(); + String hongbaotime = times.get(hongbaoweizhi); + String[] buff = hongbaotime.split(":"); + int num1 = Integer.valueOf(buff[0]); + int num2 = Integer.valueOf(buff[1]); + int num3 = num1 * 60 + num2; + Log.e("TIAOSHI###", "获得红包倒计时的秒数是----" + num3); + String fudaitime = times.get(fudaiposition); + String[] bufff = fudaitime.split(":"); + int num11 = Integer.valueOf(bufff[0]); + int num22 = Integer.valueOf(bufff[1]); + int num33 = num11 * 60 + num22; + Log.e("TIAOSHI###", "获得福袋倒计时的秒数是----" + num33); + if(num33-num3>60){ + Log.e("TIAOSHI###", "获得红包==倒计时的秒数是----" + num3); + //参与抢福袋 + int childCount = canyuqiangfeidai().getChildCount(); + if (childCount >= hongbaoweizhi) { + AccessibilityNodeInfo child = canyuqiangfeidai().getChild(hongbaoweizhi); + clickcommonthree(child, "点击红包"); + // AblViewUtil.mySleep(3); + //监听时间 + //这里需要再一次获取时间,确保时间同步,还没做 + homgbaodaojishi(num3-2); + } else { + Log.e("TIAOSHI###", "页面布局发生变化,次位置上没有控件"); + } + } + } + } + break; + default: + } + } + + + /** + * 定位结果中是否有红包 + */ + public boolean shifouyoufudai() { + boolean flag = false; + for (int i = 0; i < jiluBeans.size(); i++) { + String s = jiluBeans.get(i); + if ("福袋".equals(s)) { + flag = true; + break; + } + } + return flag; + } + + /** + * 向上滑动 + */ + private void huodong() { + AblService.getInstance().randomSwipetwo(); + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_222); + } + + /** + * 控件定位 + */ + public void kongjiandingweitwo() { + jiluBeans.clear(); + for (int j = 0; j < accessibilityNodeInfos.size(); j++) { + AccessibilityNodeInfo child2 = accessibilityNodeInfos.get(j); + if (child2 != null) { + clickNodeInfo(child2, ""); + Log.e("TIAOSHI###", "点击控件" + j); + Rect rect = new Rect(); + child2.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----显示控件点击的控件坐标:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + } + AblViewUtil.mySleep(2); + int pagetype = pagetype(); + if (pagetype == 1) { + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(540, 1663, 300); + AblViewUtil.mySleep(1); + int pagetype1 = pagetype(); + if (pagetype1 == 1) { + Log.e("TIAOSHI###", "第一次点击没有关掉"); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "再次点击关闭按钮"); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + } else { + Log.e("TIAOSHI###", "优惠卷弹框关闭了"); + } + } else if (pagetype == 2) { + jiluBeans.add("福袋"); + boolean enterfensituan = enterfensituan(); + if (enterfensituan) { + AblViewUtil.mySleep(1); + //开始计时间 + taskdaojishi(num3 + 10); + getdodsfsdfdsuyin(); + } else { + Log.e("TIAOSHI###", "不满足抢福袋的条件----"); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + huodong(); + } + break; + } else if (pagetype == 21) { + jiluBeans.add("红包"); + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + } else if (pagetype == 4) { + AblViewUtil.mySleep(2); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + } else { + jiluBeans.add("红包"); + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + } + } + } + /** + * 参与抢福袋 + */ + private AccessibilityNodeInfo canyuqiangfeidai() { + AccessibilityNodeInfo kongjian = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + if ("android.widget.HorizontalScrollView".equals(child1.getClassName())) { + kongjian = child1; + } + } + } + return kongjian; + } + + /** + * 获得红包的位置 + * + * @return + */ + private int hongbaoweizhi() { + int position = 0; + for (int i = 0; i < hongbaos.size(); i++) { + String s = hongbaos.get(i); + if ("红包".equals(s)) { + position = i; + break; + } + } + return position; + } + + /** + * 获得福袋的位置 + * + * @return + */ + private int fudaiposition() { + int position = 0; + for (int i = 0; i < hongbaos.size(); i++) { + String s = hongbaos.get(i); + if ("福袋".equals(s)) { + position = i; + break; + } + } + return position; + } + + /** + * 获取参与抢福袋的条件值 + * + * @return + */ + private boolean enterfensituan() { + /** + * 条件 + */ + boolean conditions = false; + /** + * 是否满足时间条件 + */ + boolean timeconditions = false; + /** + * 是否中奖概率 + */ + boolean winningpro = false; + noqinmidu=true; + /** + * 中奖的概率 + */ + int baifenshu = 0; + double fudainum = 0; + double renshunum = 1; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + for (int r = 0; r < child3.getChildCount(); r++) { + AccessibilityNodeInfo child4 = child3.getChild(r); + for (int m = 0; m < child4.getChildCount(); m++) { + AccessibilityNodeInfo child5 = child4.getChild(m); + for (int p = 0; p < child5.getChildCount(); p++) { + AccessibilityNodeInfo child6 = child5.getChild(p); + for (int t = 0; t < child6.getChildCount(); t++) { + AccessibilityNodeInfo child7 = child6.getChild(t); + // Log.e("TIAOSHI###", "----8Node:" + child7.getClassName() + ":" + child7.getText() + ":" + child7.getContentDescription()); + for (int u = 0; u < child7.getChildCount(); u++) { + AccessibilityNodeInfo child8 = child7.getChild(u); + Log.e("TIAOSHI###", "----9Node:" + child8.getClassName() + ":" + child8.getText() + ":" + child8.getContentDescription()); + nodeZuobiao(child8); + Rect rect = new Rect(); + child8.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----9Node:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + + if(SHEBEITIPE_VILUETHREE.equals(ChangLiang.phonetype)){ + if (rect.top >= 1351 && rect.bottom <= 1459 && rect.left >= 91 && rect.right <= 273) { + if ("android.view.View".equals(child8.getClassName())) { + String time = child8.getText().toString(); + Log.e("TIAOSHI###", "----获取的时间" + time); + if (!TextUtils.isEmpty(time)) { + String[] buff = time.split(":"); + int num1 = Integer.valueOf(buff[0]); + int num2 = Integer.valueOf(buff[1]); + num3 = num1 * 60 + num2; + Log.e("TIAOSHI###", "获得倒计时的秒数是----" + num3); + timeconditions = isfuhe(num3); + if (!isfuhe(num3)) { + Log.e("TIAOSHI###", "倒计时不在设置的参数范围内,直接滑走"); + } + } + } + } + if (rect.top >= 1354 && rect.bottom <= 1442 && rect.left >= 540) { + if ("android.view.View".equals(child8.getClassName())) { + String text = child8.getText().toString(); + if (!TextUtils.isEmpty(text)) { + // Log.e("TIAOSHI###", "----获取的内容:" + text); + if (text.contains("总") || text.contains("抖币")) { + } else { + Log.e("TIAOSHI###", "----获取的总抖币数量:" + text); + } + } + } + } + if (rect.top >= 1453 && rect.bottom <= 1497 && rect.left >= 540 && rect.right <= 784) { + if ("android.view.View".equals(child8.getClassName())) { + String text = child8.getText().toString(); + String[] all = child8.getText().toString().split("个"); + fudainum = Integer.valueOf(all[0]); + if (!TextUtils.isEmpty(text)) { + Log.e("TIAOSHI###", "----获取的福袋个数:" + all[0]); + } + } + } + if (rect.top >= 1453 && rect.bottom <= 1497 && rect.left >= 787 && rect.right <= 1000) { + if ("android.view.View".equals(child8.getClassName())) { + String text = child8.getText().toString(); + String[] all = child8.getText().toString().split("人"); + renshunum = Integer.valueOf(all[0]); + if (!TextUtils.isEmpty(text)) { + Log.e("TIAOSHI###", "----获取的参与人数:" + all[0]); + } + } + } + //获得发表的评论内容(60,1350),(288,1388) + if (rect.top >= 1758 && rect.bottom <= 1816 && rect.left >= 91 && rect.right <= 872) { + if ("android.view.View".equals(child8.getClassName())) { + String text = child8.getText().toString(); + if (!TextUtils.isEmpty(text)) { + String[] buff = text.split(":"); + String sdfsd = buff[buff.length - 1]; + Log.e("TIAOSHI###", "获取的评论内容----:" + sdfsd); + ChangLiang.fudaineirong = sdfsd; + } + } + } + } + for (int q = 0; q < child8.getChildCount(); q++) { + AccessibilityNodeInfo child9 = child8.getChild( q); + Log.e("TIAOSHI###", "----10Node:" + child9.getClassName() + ":" + child9.getText() + ":" + child9.getContentDescription()); + nodeZuobiao(child9); + if ("android.view.View".equals(child9.getClassName())) { + String text = child9.getText().toString(); + if (!TextUtils.isEmpty(text)) { + if ("提升亲密度".equals(text)) { + noqinmidu=false; + break; + } + if ("加入粉丝团(1抖币)".equals(text)) { + noqinmidu=true; + break; + } + if ("去发表评论".equals(text)) { + noqinmidu=true; + break; + } + if ("助力主播心愿".equals(text)) { + noqinmidu=false; + break; + } + } + } + } + } + } + } + } + } + } + } + } + } + Double baifenshuu = (int) fudainum / renshunum * 100; + baifenshu = baifenshuu.intValue(); + Log.e("TIAOSHI###", "抢福袋的抢种概率==" + baifenshu); + String winningrate = ProfileSpUtils.getInstance().getLiveSuiJiBean().getWinningrate(); + int winningratevalue = Integer.valueOf(winningrate); + if (baifenshu >= winningratevalue) { + winningpro = true; + }else { + Log.e("TIAOSHI###", "抢福袋的抢种概率<=参数值:"+winningratevalue); + } +// if(!noqinmidu){ +// Log.e("TIAOSHI###", "点开福袋后含有提升亲密度和加团1抖币"); +// noqinmidu=false; +// } + Log.e("TIAOSHI###", "timeconditions=="+timeconditions); + Log.e("TIAOSHI###", "winningpro=="+winningpro); + Log.e("TIAOSHI###", "noqinmidu=="+noqinmidu); + if (timeconditions && winningpro&&noqinmidu) { + conditions = true; + } + return conditions; + } + + + /** + * 判断福袋的时间是否在设置范围内 + * + * @param substring + * @return + */ + public boolean isfuhe(int substring) { + LiveSuiJiBean liveSuiJiBean = ProfileSpUtils.getInstance().getLiveSuiJiBean(); + int minute = Integer.valueOf(liveSuiJiBean.getMinute()) * 60; + int minutetwo = Integer.valueOf(liveSuiJiBean.getMinutetwo()) * 60; + if (substring <= minute && substring >= minutetwo) { + Log.e("TIAOSHI###", "倒计时在设置的参数范围内=="+minutetwo+"->"+minute); + return true; + } else { + Log.e("TIAOSHI###", "倒计时不在设置的参数范围内,直接滑走" + "==" + minute + "=====" + minutetwo); + return false; + } + } + + private void getdodsfsdfdsuyin() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + // Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); + for (int r = 0; r < child3.getChildCount(); r++) { + AccessibilityNodeInfo child4 = child3.getChild(r); + // Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText() + ":" + child4.getContentDescription()); + for (int m = 0; m < child4.getChildCount(); m++) { + AccessibilityNodeInfo child5 = child4.getChild(m); + // Log.e("TIAOSHI###", "----6Node:" + child5.getClassName() + ":" + child5.getText() + ":" + child5.getContentDescription()); + for (int p = 0; p < child5.getChildCount(); p++) { + AccessibilityNodeInfo child6 = child5.getChild(p); + // Log.e("TIAOSHI###", "----7Node:" + child6.getClassName() + ":" + child6.getText() + ":" + child6.getContentDescription()); + for (int t = 0; t < child6.getChildCount(); t++) { + AccessibilityNodeInfo child7 = child6.getChild(t); + // Log.e("TIAOSHI###", "----8Node:" + child7.getClassName() + ":" + child7.getText() + ":" + child7.getContentDescription()); + for (int u = 0; u < child7.getChildCount(); u++) { + AccessibilityNodeInfo child8 = child7.getChild(u); + // Log.e("TIAOSHI###", "----9Node:" + child8.getClassName() + ":" + child8.getText() + ":" + child8.getContentDescription()); + for (int q = 0; q < child8.getChildCount(); q++) { + AccessibilityNodeInfo child9 = child8.getChild( q); + Log.e("TIAOSHI###", "----10Node:" + child9.getClassName() + ":" + child9.getText() + ":" + child9.getContentDescription()); + nodeZuobiao(child9); + if ("android.view.View".equals(child9.getClassName())) { + String text = child9.getText().toString(); + if (!TextUtils.isEmpty(text)) { + if ("加入粉丝团(1抖币)".equals(text)) { + AblViewUtil.mySleep(2); + //点击加入粉丝团 + clickcommonthree(child9, "了加入粉丝团"); + AblViewUtil.mySleep(2); + closedzfDialog(AblService.getInstance()); + AblViewUtil.mySleep(3); + clickcommonthree(child9, "去发表评论"); + AblViewUtil.mySleep(2); + //去发表评论 + //直播间发送评论 + fasongpinglun(ChangLiang.fudaineirong); + break; + } else if ("去发表评论".equals(text)) { + AblViewUtil.mySleep(2); + clickcommonthree(child9, "去发表评论"); + AblViewUtil.mySleep(2); + //去发表评论 + //直播间发送评论 + fasongpinglun(ChangLiang.fudaineirong); + break; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + + private void fasongpinglun(String conment) { + //直播间话术 + AblViewUtil.mySleep(2); + AblViewUtil.mySleep(1); + AccessibilityNodeInfo geouyintdd = geouyintdd(); + AblService.getInstance().clickcommontwo(geouyintdd, "点击发送评论"); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_224); + + } + + /** + * 参与抢福袋的结束计时 + * + * @param a + */ + public void taskdaojishi(final int a) { + //启动计时器 + //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 + Disposable mdDisposable = Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) + .observeOn(AndroidSchedulers.mainThread()) + .doOnNext(new Consumer() { + @Override + public void accept(Long aLong) throws Exception { + long b = a - aLong; + Log.e("TIAOSHI###", b + ""); + if(b==30){ + //打开福袋 + if (ifControlView()) { + openFudai(); + } + } + } + }) + .doOnComplete(new Action() { + @Override + public void run() throws Exception { + //关闭结果弹框 + + AblService.getInstance().clickPoint(100, 100, 300); + // closedjieguo(); + //继续抢福袋 + AblStepHandler.sendMsg(AblSteps.STEP_222); + + } + }) + .subscribe(); + } + + private void openFudai(){ + for (int j = 0; j < accessibilityNodeInfos.size(); j++) { + AccessibilityNodeInfo child2 = accessibilityNodeInfos.get(j); + if (child2 != null) { + clickNodeInfo(child2, ""); + Log.e("TIAOSHI###", "点击控件" + j); + Rect rect = new Rect(); + child2.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----显示控件点击的控件坐标:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + } + AblViewUtil.mySleep(2); + int pagetype = pagetype(); + if (pagetype == 1) { + Log.e("TIAOSHI###","福袋测试1"); + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(540, 1663, 300); + AblViewUtil.mySleep(1); + int pagetype1 = pagetype(); + if (pagetype1 == 1) { + Log.e("TIAOSHI###", "第一次点击没有关掉"); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "再次点击关闭按钮"); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + } else { + Log.e("TIAOSHI###", "优惠卷弹框关闭了"); + } + } else if (pagetype == 2) { + break; + } else if (pagetype == 21) { + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + + } else if (pagetype == 4) { + AblViewUtil.mySleep(2); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + } else { + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + } + } + } + + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickcommonthree(AccessibilityNodeInfo accessibilityNodeInfo, String s) { + if (accessibilityNodeInfo != null) { + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮"); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮"); + } + } + + + /** + * 参与抢红包的结束计时 + * + * @param a + */ + private void homgbaodaojishi(final int a) { + //启动计时器 + //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 + Disposable mdDisposable = Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) + .observeOn(AndroidSchedulers.mainThread()) + .doOnNext(new Consumer() { + @Override + public void accept(Long aLong) throws Exception { + long b = a - aLong; + Log.e("TIAOSHI###", b + ""); + } + }) + .doOnComplete(new Action() { + @Override + public void run() throws Exception { + //抢红包 + // qianghongbaoo(); + AblService.getInstance().clickPoint(360, 714, 300); + AblService.getInstance().clickPoint(360, 714, 300); + AblService.getInstance().clickPoint(360, 714, 300); + AblService.getInstance().clickPoint(360, 714, 300); + AblService.getInstance().clickPoint(360, 714, 300); + AblService.getInstance().clickPoint(360, 714, 300); + AblViewUtil.mySleep(5); + //关闭红包 + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + + } + }) + .subscribe(); + } + + + /** + * 获得直播间人数 + */ + public int getPersonNum() { + int personnum = 0; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); +// Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); +// nodeZuobiao(child2); + Rect rect = new Rect(); + child2.getBoundsInScreen(rect); + // Log.e("TIAOSHI###", "----threeNode:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + //红米7A(560,77),(632,137) 畅想20(560,70),(632,130) 红米9(860,129),(959,212) + if (SHEBEITIPE_VILUEONE.equals(ChangLiang.phonetype)) { + if (rect.left > 360 && rect.top >= 77 && rect.bottom <= 137) { + if ("android.widget.Button".equals(child2.getClassName())) { + String person = child2.getText().toString(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + person); + if (person.contains("万")) { + String substring = person.substring(0, person.indexOf("万")); + double personmun = Double.parseDouble(substring) * 10000; + personnum = new Double(personmun).intValue(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + personnum); + } else { + personnum = Integer.valueOf(person); + } + break; + } + } + } else if (SHEBEITIPE_VILUETHREE.equals(ChangLiang.phonetype)) { + if (rect.left > 540 && rect.top >= 129 && rect.bottom <= 212) { + if ("android.widget.Button".equals(child2.getClassName())) { + String person = child2.getText().toString(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + person); + if (person.contains("万")) { + String substring = person.substring(0, person.indexOf("万")); + double personmun = Double.parseDouble(substring) * 10000; + personnum = new Double(personmun).intValue(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + personnum); + } else { + personnum = Integer.valueOf(person); + } + break; + } + } + } else { + // 16.5版本(561,69),(633,129) 14.6版本(560,70),(632,130) + if (rect.left > 360 && rect.top >= 68 && rect.bottom <= 130) { + if ("android.widget.Button".equals(child2.getClassName())) { + String person = child2.getText().toString(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + person); + if (person.contains("万")) { + String substring = person.substring(0, person.indexOf("万")); + double personmun = Double.parseDouble(substring) * 10000; + personnum = new Double(personmun).intValue(); + Log.e("TIAOSHI###", "----获取的直播间人数:" + personnum); + } else { + personnum = Integer.valueOf(person); + } + break; + } + } + } + } + } + } + return personnum; + } +} + + + diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep32.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep32.java new file mode 100644 index 0000000..7818ec9 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep32.java @@ -0,0 +1,168 @@ +package com.fisherbone.fuzhu.step; + +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.entity.AppoBean; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; + +import java.util.List; + +/** + * @author keriezhang + * @description 指定直播间加关 + * @return + */ +public class TestAblStep32 extends NoticeBase { + private List objects; + + @Override + public void onStep(int step, Message msg) { + + switch (step) { + case AblSteps.STEP_231: + AblViewUtil.startApplication(); + AblViewUtil.mySleep(5); + AppoBean appoBean = ProfileSpUtils.getInstance().getAppoBean(); + this.objects = appoBean.getData(); + Log.e("TIAOSHI###", "1234" ); + AblStepHandler.sendMsg(AblSteps.STEP_232); + break; + case AblSteps.STEP_232: + AblViewUtil.mySleep(3); + Log.e("TIAOSHI###", "56778" ); + if (this.objects.size() == 0) { + AblViewUtil.potgegin("停止"); + return; + } + DianSou(); + AblViewUtil.mySleep(3); + //复制文本粘贴在留言板 + AccessibilityNodeInfo findcomentt = findEditText(); + AppoBean.DataBean dataBean = this.objects.get(0); + String conment = dataBean.getRoom_shortid(); + Log.e("TIAOSHI###", "获得的关键词内容234" + conment); + AblViewUtil.mySleep(1); + if (SHEBEITIPE_VILUEONE.equals(ChangLiang.phonetype)) { + AblViewUtil.mySleep(1); + AblViewUtil.sayInput(conment, findcomentt); + } else { + //华为畅享20 + AblViewUtil.mySleep(1); + AblViewUtil.sayInput(conment, findcomentt); + } + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_233); + break; + case AblSteps.STEP_233: + DianSou(); + AblViewUtil.mySleep(3); +// AccessibilityNodeInfo getdaohang = getdaohang(); +// //触发容器元素的滚动事件 +// getdaohang.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); + AblViewUtil.mySleep(1); + //1为用户 2为直播 + selecttype("1"); + AblViewUtil.mySleep(3); + getNodeInfoy(); + AblStepHandler.sendMsg(AblSteps.STEP_234); + break; + case AblSteps.STEP_234: + AblViewUtil.mySleep(2); + this.objects.remove(0); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + //搜索下一个 + AblStepHandler.sendMsg(AblSteps.STEP_232); + break; + default: + } + } + + /** + * 寻找控件 + */ + public void getNodeInfoy() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + nodeZuobiao(child1); +// AccessibilityNodeInfo child2 = child1.getChild(child1.getChildCount()); +// Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + if (y == child.getChildCount() - 1) { + // Log.e("TIAOSHI###", "----threeNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + nodeZuobiao(child1); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----fourNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + if ("android.widget.FrameLayout".equals(child2.getClassName())) { + if (j == 0) { + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + Log.e("TIAOSHI###", "----fiveNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child3.getContentDescription()); + for (int h = 0; h < child3.getChildCount(); h++) { + AccessibilityNodeInfo child4 = child3.getChild(h); + Log.e("TIAOSHI###", "----sixNode:" + child4.getClassName() + ":" + child4.getText() + ":" + child4.getContentDescription()); + int childCount = child4.getChildCount(); + Log.e("TIAOSHI###", "----sixNode数量:" + childCount); + nodeZuobiao(child4); + for (int m = 0; m < child4.getChildCount(); m++) { + AccessibilityNodeInfo child5 = child4.getChild(m); + Log.e("TIAOSHI###", "----6Node:" + child5.getClassName() + ":" + child5.getText() + ":" + child5.getContentDescription()); + nodeZuobiao(child5); + for (int p = 0; p < child5.getChildCount(); p++) { + if(p==0){ + continue; + } + AccessibilityNodeInfo child6 = child5.getChild(p); + Log.e("TIAOSHI###", "----7Node:" + child6.getClassName() + ":" + child6.getText() + ":" + child6.getContentDescription()); + nodeZuobiao(child6); + if("关注".equals(child6.getContentDescription())) { + clickcommontwo(child6, ""); + } + } + } + } + } + } + } + } + } + } + } + } + + /** + * 获得顶部导航控件 + * + * @return + */ + public AccessibilityNodeInfo getdaohang() { + AccessibilityNodeInfo childw = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { + childw = child; + } + } + return childw; + } + +} + + + diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep33.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep33.java new file mode 100644 index 0000000..973db7c --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep33.java @@ -0,0 +1,272 @@ +package com.fisherbone.fuzhu.step; + +import android.graphics.Rect; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author keriezhang + * @description 巡检红包抖币数超过200的加关注 + * @return + */ +public class TestAblStep33 extends NoticeBase { + private List jiluBeans; + @Override + public void onStep(int step, Message msg) { + + switch (step) { + case AblSteps.STEP_241: + AblViewUtil.startApplication(); + AblViewUtil.mySleep(10); + AblStepHandler.sendMsg(AblSteps.STEP_242); + break; + case AblSteps.STEP_242: + AblViewUtil.mySleep(3); + //监听一次有没有控件 + int jiedianhuoqutwo = jiedianhuoqutwo(); + Log.e("TIAOSHI###", "个数==" + jiedianhuoqutwo); + if (jiedianhuoqutwo != 0) { + AblStepHandler.sendMsg(AblSteps.STEP_243); + } else { + Log.e("TIAOSHI###", "没有监听到三个控件"); + huodong(); + } + break; + case AblSteps.STEP_243: + //给控件做一次定位 + AblViewUtil.mySleep(1); + kongjiandingwei(); + //判断定位中是否有福袋 + if (shifouyouhongbao()) { + int hongbaoweizhi = hongbaoweizhi(); + //参与抢福袋 + AccessibilityNodeInfo canyuqiangfeidai = canyuqiangfeidai(); + if(canyuqiangfeidai!=null) { + int childCount = canyuqiangfeidai.getChildCount(); + if (childCount >hongbaoweizhi) { + AccessibilityNodeInfo child = canyuqiangfeidai.getChild(hongbaoweizhi); + clickcommonthree(child, "点击红包"); + AblViewUtil.mySleep(1); + boolean tianjian = tianjian(); + if (tianjian) { + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + clickGuanzhu(); + Log.e("TIAOSHI###", "点击加关注----"); + AblViewUtil.mySleep(2); + huodong(); + } else { + Log.e("TIAOSHI###", "不满足加关注的条件----"); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + huodong(); + } + } else { + Log.e("TIAOSHI###", "页面布局发生变化,次位置上没有控件"); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_242); + } + } + } else { + Log.e("TIAOSHI###", "页面布局发生变化,次位置上没有控件"); + huodong(); + } + break; + default: + } + } + + /** + * 查看红包的抖币数是否大于200 + * @return + */ + private boolean tianjian() { + boolean stutus=false; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + Rect rect = new Rect(); + child.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----oneNode:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + //(386,885),(412,918) + if (rect.top >= 885 && rect.bottom <= 918) { + if ("android.widget.TextView".equals(child.getClassName())) { + String person = child.getText().toString(); + if (person.contains("价值")) { + } else { + String doubi = child.getText().toString(); + Log.e("TIAOSHI###", "----获取的抖币数:" + doubi); + int doubinum = Integer.parseInt(doubi); + if(doubinum>=200){ + stutus=true; + } + break; + } + } + } + } + return stutus; + } + + + /** + * 参与抢福袋 + */ + private AccessibilityNodeInfo canyuqiangfeidai() { + AccessibilityNodeInfo kongjian = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + if(child1!=null) { + if ("android.widget.HorizontalScrollView".equals(child1.getClassName())) { + kongjian = child1; + } + } + } + } + return kongjian; + } + /** + * 向上滑动 + */ + private void huodong() { + AblService.getInstance().randomSwipetwo(); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_242); + AblViewUtil.mySleep(1); + } + /** + * 获得红包的位置 + * + * @return + */ + private int hongbaoweizhi() { + int position = 0; + for (int i = 0; i < jiluBeans.size(); i++) { + String s = jiluBeans.get(i); + if ("红包".equals(s)) { + position = i; + break; + } + } + return position; + } + /** + * 控件的监听 + * + * @return + */ + private int jiedianhuoqutwo() { + int kongjiannum = 0; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("android.widget.HorizontalScrollView".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + kongjiannum = child1.getChildCount(); + } + } + } + } + return kongjiannum; + } + /** + * 控件定位 + */ + private void kongjiandingwei() { + jiluBeans = new ArrayList<>(); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("android.widget.HorizontalScrollView".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + AblViewUtil.mySleep(1); + clickcommonthree(child2, ""); + AblViewUtil.mySleep(2); + int pagetype = pagetype(); + if (pagetype == 1) { + // jiluBeans.add("优惠卷"); + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(360, 1070, 300); + AblViewUtil.mySleep(1); + } else if (pagetype == 2) { + jiluBeans.add("福袋"); + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + } else { + jiluBeans.add("红包"); + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + } + } + } + } + } + String s = jiluBeans.toString(); + Log.e("TIAOSHI###", "----标记" + s); + } + + + /** + * 定位结果中是否有红包 + */ + private boolean shifouyouhongbao() { + boolean flag = false; + for (int i = 0; i < jiluBeans.size(); i++) { + String s = jiluBeans.get(i); + if ("红包".equals(s)) { + flag = true; + break; + } + } + return flag; + } + /** + * 判断页面类型 + * + * @return + */ + private int pagetype() { + int childCount = 0; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + childCount = root.getChildCount(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { + childCount = 4; + } + } + return childCount; + } +} + + + diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep34.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep34.java new file mode 100644 index 0000000..470f99a --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep34.java @@ -0,0 +1,936 @@ +package com.fisherbone.fuzhu.step; + + +import android.content.Context; +import android.graphics.Rect; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.db.RedenvBeanData; +import com.fisherbone.fuzhu.db.dao.RedenvDao; +import com.fisherbone.fuzhu.entity.RedEnvBean; +import com.fisherbone.fuzhu.hongbao.CursorRed; +import com.fisherbone.fuzhu.hongbao.RedEnv; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.fisherbone.fuzhu.utils.DateUtils; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.jeremyliao.liveeventbus.LiveEventBus; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.Random; + +public class TestAblStep34 extends HongbaoBase implements RedEnv.RedEnvFunc, RedEnv.TimeFunc, RedEnv.MoveFunc { + private List jiluBeans; + private RedEnvBean redEnvBean; + boolean isStart = true; + Context mcontext; + private RedenvDao redenvDao; + private CursorRed cursorRed; + private int livePosition = 0; + //true 为向下滑动状态 + private boolean slidingDir = true; + private boolean ifend; + + public TestAblStep34(Context mcontext) { + this.mcontext = mcontext; + } + + @Override + public void onStep(int step, Message msg) { + + switch (step) { + case AblSteps.STEP_249: + isStart = true; + livePosition = 0; + slidingDir = true; + jiluBeans = new ArrayList<>(); + cursorRed = new CursorRed(); + redEnvBean = ProfileSpUtils.getInstance().getRedEnvBean(); + redenvDao = new RedenvDao(mcontext); + AblViewUtil.startApplication(); + AblViewUtil.mySleep(3); + allowed(); + AblStepHandler.sendMsg(AblSteps.STEP_250); + break; + case AblSteps.STEP_250: + closedtjDialog(AblService.getInstance()); + AblViewUtil.mySleep(1); + //1.关闭检测到更新的弹框 + closedJDialog(AblService.getInstance()); + AblViewUtil.mySleep(1); + //2.关闭青少年弹窗 + closedQDialog(AblService.getInstance()); + AblViewUtil.mySleep(1); + closedBDialog(AblService.getInstance()); + AblViewUtil.mySleep(1); + AblStepHandler.sendMsg(AblSteps.STEP_251); + break; + case AblSteps.STEP_251: + AblViewUtil.mySleep(7); + boolean b = openTiktok(); + boolean b1 = ifShouye(); + if (b && b1) { + runLog("成功打开抖音"); + AccessibilityNodeInfo shouye = getShouye(); + clickNodeInfo(shouye, "首页"); + AblStepHandler.sendMsg(AblSteps.STEP_252); + } else { + runLog("没有打开抖音抖音不在首页"); + againStart("0"); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + boolean b2 = ifShouye(); + if (b2) { + AccessibilityNodeInfo shouye = getShouye(); + clickNodeInfo(shouye, "首页"); + AblStepHandler.sendMsg(AblSteps.STEP_252); + } else { + AblViewUtil.back(); + AblViewUtil.mySleep(2); + boolean b3 = ifShouye(); + if (b3) { + AccessibilityNodeInfo shouye = getShouye(); + clickNodeInfo(shouye, "首页"); + AblStepHandler.sendMsg(AblSteps.STEP_252); + } else { + runLog("没有打开抖音抖音不在首页"); + againStart("0"); + } + } + Log.e("TIAOSHI###", "是否有首页" + b); + } + break; + case AblSteps.STEP_252: + livePosition = 0; + slidingDir = true; + AblViewUtil.mySleep(2); + redenvDao.deletetwo(null); + boolean b12 = enterLive(); + if (b12) { + runLog("成功进入第一个直播间"); + AblStepHandler.sendMsg(AblSteps.STEP_253); + } else { + // runLog("进入第一个直播间失败"); + AblViewUtil.mySleep(2); + boolean b2 = enterLivetwo(); + if (b2) { + runLog("成功进入第一个直播间"); + AblStepHandler.sendMsg(AblSteps.STEP_253); + } else { + // runLog("进入第一个直播间失败"); + AblViewUtil.mySleep(2); + boolean b3 = enterLivetwo(); + if (b3) { + runLog("成功进入第一个直播间"); + AblStepHandler.sendMsg(AblSteps.STEP_253); + } else { + runLog("进入第一个直播间失败"); + } + } + } + break; + case AblSteps.STEP_253: + AblViewUtil.mySleep(2); + if (!ifControlView()) { + //获取直播间人数 + int personNum = getPersonNum(); + AblViewUtil.mySleep(1); + if (personNum <= 30 && personNum >= 0) { + Log.e("TIAOSHI###", "没有控件"); + Log.e("TIAOSHI###", personNum + "直播间人数没有达到条件" + ChangLiang.phonetype); + quGuanZhuBo(); + break; + } + } + runLog("开始抢抖币"); + //记录初始的抖币数量 + //点开礼物 + clickmoreli(); + Log.e("TIAOSHI###", "打开礼物"); + AblViewUtil.mySleep(1); + int doubinum = dangqianDoubi(); + redEnvBean.setLivedoubinumfir(doubinum + ""); + Log.e("TIAOSHI###", "初始抖币数" + redEnvBean.getLivedoubinumfir()); + taskDbTj("0" + "", redEnvBean.getLivedoubinumfir()); + AblViewUtil.back(); + tagControlView("", livePosition); + AblStepHandler.sendMsg(AblSteps.STEP_254); + break; + case AblSteps.STEP_254: +// boolean b2 = liveOver(); +// if(b2){ +// Log.e("TIAOSHI###", "当前直播间已退播"); +// AblViewUtil.mySleep(20); +// }else { +// Log.e("TIAOSHI###", "当前直播间未退播"); +// } + AccessibilityNodeInfo nodeInfoS = getNodeInfoS(); + if (nodeInfoS != null) { + Log.e("TIAOSHI###", "页面在直播页面"); + againStart("1"); + } else { + boolean b2 = liveOver(); + if (b2) { + } else { + Log.e("TIAOSHI###", "页面不在直播页面"); + againStart("0"); + } + } + + timeOrDoubi(); + + break; + case AblSteps.STEP_255: + if (ifControlView()) { + kongjiandingweitwo(); + AblViewUtil.mySleep(1); + boolean shifouyouhongbao = shifouyouhongbao(); + Log.e("TIAOSHI###", "是否有红包控件" + shifouyouhongbao); + if (!shifouyouhongbao) { + Log.e("TIAOSHI###", "页面布局发生变化,此位置上没有红包控件"); + move(); + } + } else { + Log.e("TIAOSHI###", "页面布局发生变化,没有了控件"); + move(); + } + break; + default: + } + } + + public boolean allowed() { + boolean ifOpen = false; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.TextView".equals(child.getClassName())) { + if (child.getText() != null) { + if (child.getText().toString().contains("正在尝试开启") || child.getText().toString().contains("是否允许")) { + int childCount = root.getChildCount(); + AccessibilityNodeInfo child1 = root.getChild(childCount - 1); + clickNodeInfo(child1, "点击了允许"); + } + } + ifOpen = true; + } + } + return ifOpen; + } + + /** + * 定位结果中是否有红包 + */ + public boolean shifouyouhongbao() { + boolean flag = false; + for (int i = 0; i < jiluBeans.size(); i++) { + String s = jiluBeans.get(i); + if ("红包".equals(s)) { + flag = true; + break; + } + } + return flag; + } + + private void pingLun() { + //是否评论 + boolean redswitchone = redEnvBean.isRedswitchone(); + if (redswitchone) { + AblViewUtil.mySleep(3); + String conment = getConment(); + fasongpingluntwo(conment); + } + AblViewUtil.mySleep(1); + } + + private void dianZan() { + //是否点赞 + Boolean switchtwo = redEnvBean.isRedswitchtwo(); + if (switchtwo) { + AblViewUtil.mySleep(1); + // zhibodianzan(new Random().nextInt(4)+1); + zhibodianzan(new Random().nextInt(30) + 10); + AblViewUtil.mySleep(1); + } + } + + private void timeOrDoubi() { + AblViewUtil.mySleep(1); + //记录抖币的数量 + recordDoubi(DateUtils.getNowString()); + Log.e("TIAOSHI###", "初始时间" + redEnvBean.getLivetimefir()); + Log.e("TIAOSHI###", "当前时间" + redEnvBean.getLivetime()); + + boolean redswitchone = ProfileSpUtils.getInstance().getSetBean().isRedswitchone(); + Log.e("TIAOSHI###", "当前sp==" + redswitchone); + if(redswitchone){ + ifend = runTimetwo(redEnvBean.getEndtime()); + }else { + ifend = liveTime(); + } + if (ifend) { + clickmoreli(); + Log.e("TIAOSHI###", "打开礼物"); + AblViewUtil.mySleep(1); + int doubinum = dangqianDoubi(); + redEnvBean.setLivedoubinum(doubinum + ""); + Log.e("TIAOSHI###", "当前抖币数" + redEnvBean.getLivedoubinum()); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + tongjidoubi(); + runLog("运行时间结束"); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + AblViewUtil.back(); + AblViewUtil.potgegin("停止"); + return; + } else { + AblViewUtil.mySleep(1); + AblStepHandler.sendMsg(AblSteps.STEP_255); + } + } + + private void tongjidoubi() { + String livedoubinumfir = redEnvBean.getLivedoubinumfir(); + String livedoubinum = redEnvBean.getLivedoubinum(); + int num1 = Integer.valueOf(livedoubinumfir); + int num2 = Integer.valueOf(livedoubinum); + int num = num2 - num1; + taskDbTj(num + "", livedoubinum); + } + + private void taskDbTj(String str1, String str2) { + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("short_id", ChangLiang.short_id); + paramsPost.put("task_id", ChangLiang.task_id); + paramsPost.put("id", ChangLiang.id); + paramsPost.put("task_type", ChangLiang.task_type); + paramsPost.put("func_type", ChangLiang.func_type); + paramsPost.put("add_db", str1); + paramsPost.put("total_db", str2); + new NetApi().getPostData(paramsPost, HttpConstants.URi_Device_Appscanlogin_taskDbTj).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + Log.e("上传抖币数量", body); + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + + } + }); + } + + private void runLog(String str) { + LiveEventBus.get("some_key").post(str); + Log.e("TIAOSHI###", str); + } + + /** + * 记录抖币的数量 ,任务开始执行的时候记录一次,以后每次循环记录一次 ||记录直播的时间 + */ + private void recordDoubi(String str2) { + if (isStart) { + redEnvBean.setLivetimefir(str2); + isStart = false; + } + redEnvBean.setLivetime(str2); + } + + + @Override + public boolean openTiktok() { + boolean ifOpen = false; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + ifOpen = true; + } + } + return ifOpen; + } + + @Override + public boolean enterLive() { + boolean ifEnterOne = true; + //进入推荐页(刷新) + AblViewUtil.mySleep(1); + getNodeInfo("2"); + Log.e("TIAOSHI###", "点击关注"); + AblViewUtil.mySleep(5); + enterOneNodeInfo(); + AblViewUtil.mySleep(4); + AccessibilityNodeInfo nodeInfoS = getNodeInfoS(); + if (nodeInfoS != null) { + ifEnterOne = true; + } + return ifEnterOne; + } + + public boolean enterLivetwo() { + boolean ifEnterOne = false; + AccessibilityNodeInfo nodeInfoS = getNodeInfoS(); + if (nodeInfoS != null) { + ifEnterOne = true; + } + return ifEnterOne; + } + + @Override + public boolean liveTime() { + boolean ifruntime = false; + Long diff = DateUtils.diff(redEnvBean.getLivetimefir(), redEnvBean.getLivetime()); + Log.e("TIAOSHI###", "----目前运行的时间:" + diff); + String runtime = redEnvBean.getRuntime(); + Log.e("TIAOSHI###", "----总运行的时间:" + runtime + "分钟"); + Long ltwo = Long.parseLong(runtime); + if (diff.longValue() >= ltwo.longValue() * 60 * 1000) { + ifruntime = true; + } + return ifruntime; + } + + public boolean runTimetwo(String end_time) { + boolean ifruntime = false; + Date date=new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + String dateString=end_time; + Date date2= null; + try { + date2 = sdf.parse(dateString); + } catch (ParseException e) { + e.printStackTrace(); + } + if(date.getTime() 0) { + redenvDao.updateData(redenvBeanData); + } else { + redenvDao.addInsert(redenvBeanData); + } + return false; + } + + @Override + public int dangqianDoubi() { + int doubinumr = 0; + String getdoubinum = getdoubinum(); + if (getdoubinum.equals("")) { + getdoubinum = "0"; + } + if ("充值".equals(getdoubinum)) { + doubinumr = 0; + } else { + doubinumr = Integer.valueOf(getdoubinum); + } + return doubinumr; + } + + @Override + public boolean quGuanZhuBo() { + //取消关注当前主播 + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(90, 163, 300); + AblViewUtil.mySleep(4); + // AblService.getInstance().clickPoint(180, 2132, 300); + clickyiguanzhu(); + AblViewUtil.mySleep(4); + //点击确定 + AblService.getInstance().clickPoint(815, 1235, 300); + AblViewUtil.mySleep(5); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + //刷新 + // AblStepHandler.sendMsg(AblSteps.STEP_252); + livePosition = 0; + slidingDir = true; + AblViewUtil.mySleep(2); + redenvDao.deletetwo(null); + boolean b1 = enterLive(); + if (b1) { + runLog("成功进入第一个直播间"); + AblStepHandler.sendMsg(AblSteps.STEP_253); + } else { + // runLog("进入第一个直播间失败"); + AblViewUtil.mySleep(2); + boolean b2 = enterLivetwo(); + if (b2) { + runLog("成功进入第一个直播间"); + AblStepHandler.sendMsg(AblSteps.STEP_253); + } else { + // runLog("进入第一个直播间失败"); + AblViewUtil.mySleep(2); + boolean b3 = enterLivetwo(); + if (b3) { + runLog("成功进入第一个直播间"); + againStart("1"); + AblStepHandler.sendMsg(AblSteps.STEP_253); + } else { + runLog("进入第一个直播间失败"); + againStart("0"); + } + } + } + return false; + } + + + /** + * 控件定位 + */ + public void kongjiandingweitwo() { + jiluBeans.clear(); + for (int j = 0; j < accessibilityNodeInfos.size(); j++) { + AccessibilityNodeInfo child2 = accessibilityNodeInfos.get(j); + if (child2 != null) { + clickNodeInfo(child2, ""); + Log.e("TIAOSHI###", "点击控件" + j); + Rect rect = new Rect(); + child2.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----显示控件点击的控件坐标:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + } + AblViewUtil.mySleep(2); + int pagetype = pagetype(); + if (pagetype == 1) { + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(540, 1663, 300); + AblViewUtil.mySleep(1); + int pagetype1 = pagetype(); + if (pagetype1 == 1) { + Log.e("TIAOSHI###", "第一次点击没有关掉"); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "再次点击关闭按钮"); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + } else { + Log.e("TIAOSHI###", "优惠卷弹框关闭了"); + } + } else if (pagetype == 2) { + jiluBeans.add("福袋"); + AblViewUtil.mySleep(1); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + } else if (pagetype == 21) { + jiluBeans.add("红包"); + AblViewUtil.mySleep(1); + boolean getdoubi = getdoubi(); + if (getdoubi) { + getNodeInQiangtwo(); + } else { + Log.e("TIAOSHI###", "----抖币数不够条件"); + } + break; + } else if (pagetype == 4) { + AblViewUtil.mySleep(2); + AblService.getInstance().clickPoint(100, 100, 300); + AblViewUtil.mySleep(1); + } else { + jiluBeans.add("红包"); + // AblService.getInstance().clickPoint(540, 926, 300); + AblViewUtil.mySleep(1); + boolean getdoubi = getdoubi(); + if (getdoubi) { + // getNodeInQiang(); + } else { + Log.e("TIAOSHI###", "----抖币数不够条件"); + + } + break; + } + } + } + + public boolean getdoubi() { + boolean flag = true; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + nodeZuobiao(child1); + if (child1 != null) { + Rect rect = new Rect(); + child1.getBoundsInScreen(rect); + //(547,1437),(613,1510) + if (rect.top >= 1437 && rect.bottom <= 1510) { + if ("android.widget.TextView".equals(child1.getClassName())) { + String doubigeshu = child1.getText().toString(); + Log.e("TIAOSHI###", "----获取的抖币数:" + doubigeshu); + int doubi = Integer.valueOf(doubigeshu); + int doubic = Integer.valueOf(10); + Log.e("TIAOSHI###", "----获取的条件抖币数:" + doubic); + if (doubi > doubic) { + flag = true; + } else { + flag = false; + } + break; + } + } + } + } + } + return flag; + } + + /** + * 获取抢的控件 + * ----oneNode:android.widget.TextView:200:null + * ----显示节点的坐标:(521,1342),(620,1416) + *

+ * ----oneNode:android.widget.TextView:520:null + * ----显示节点的坐标:(565,1398),(624,1443) + */ + public void getNodeInQiangtwo() { + AccessibilityNodeInfo timechild = null; + boolean flag = false; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + nodeZuobiao(child1); + Rect rect = new Rect(); + child1.getBoundsInScreen(rect); + if (rect.top >= 1192 && rect.bottom <= 1286) { + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + timechild = child1; + flag = true; + } else { + Log.e("TIAOSHI###", "没有控件"); + } + } + } + if (flag) { + Log.e("TIAOSHI###", "红包有时间"); + qiangHongbao(timechild); + } else { + Log.e("TIAOSHI###", "红包没有时间"); + // (462,1192),(618,1286) + AblService.getInstance().clickPoint(540, 1239, 300); + AblViewUtil.mySleep(2); + AblViewUtil.back(); + AblStepHandler.sendMsg(AblSteps.STEP_254); + AblViewUtil.mySleep(1); + } + + } + + private void qiangHongbao(AccessibilityNodeInfo child1) { + String s = child1.getText().toString(); + int daojishimiao = daojishimiao(s); + String qiehuantime = redEnvBean.getQiehuantime(); + int qihuanshijian = Integer.valueOf(qiehuantime); + if (daojishimiao < qihuanshijian) { + if (redEnvBean.isRedswitchone() || redEnvBean.isRedswitchtwo()) { + if (daojishimiao >= qihuanshijian - 20) { + Log.e("TIAOSHI###", "进行点赞评论"); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + dianZan(); + pingLun(); + AblStepHandler.sendMsg(AblSteps.STEP_254); + } else { + Log.e("TIAOSHI###", "时间在" + qihuanshijian + "秒内"); + List datas = redenvDao.queryByCustom("Id", livePosition + ""); + if (datas.size() > 0) { + RedenvBeanData redenvBeanData1 = datas.get(0); + redenvBeanData1.setRedenvtime("0"); + redenvDao.updateData(redenvBeanData1); + } + //等待抢红包 + taskdaojishi(daojishimiao - 2); + } + } else { + Log.e("TIAOSHI###", "时间在" + qihuanshijian + "秒内"); + List datas = redenvDao.queryByCustom("Id", livePosition + ""); + if (datas.size() > 0) { + RedenvBeanData redenvBeanData1 = datas.get(0); + redenvBeanData1.setRedenvtime("0"); + redenvDao.updateData(redenvBeanData1); + } + //等待抢红包 + taskdaojishi(daojishimiao - 2); + } + + } else { + //更新时间 + Log.e("TIAOSHI###", "更新时间"); + RedenvBeanData redenvBeanData = new RedenvBeanData(); + redenvBeanData.setRedenvtime(daojishimiao + ""); + + List datas = redenvDao.queryByCustom("Id", livePosition + ""); + if (datas.size() > 0) { + RedenvBeanData redenvBeanData1 = datas.get(0); + redenvBeanData1.setRedenvtime(daojishimiao + ""); + redenvDao.updateData(redenvBeanData1); + } + AblViewUtil.mySleep(2); + int pagetype = pagetype(); + if (pagetype == 21 ) { + Log.e("TIAOSHI###", "有倒计时红包弹框,点击返回"); + AblViewUtil.back(); + } else { + Log.e("TIAOSHI###", "有红包倒计时,没有有红包弹框,不点击返回"); + } + //AblViewUtil.back(); + AblViewUtil.mySleep(1); + move(); + } + } + + /** + * 滑动 + */ + private void move() { + //判断有没有直播间的红包快开奖了,赶紧滑过去 +// int redpostion = redEnvPostions(); +// Log.e("TIAOSHI###", "满足时间筛选的开奖直播间位置==" + redpostion); +// if (redpostion != -1) { +// Log.e("TIAOSHI###", redpostion + "位置的红包要开了"); +// Log.e("TIAOSHI###", "当前直播间的位置==" + livePosition); +// moveZhiBoJian(livePosition, redpostion); +// return; +// } + + if (slidingDir) { + // AblService.getInstance().randomSwipetwo(); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "滑——向上滑前直播间的位置" + livePosition); + if (Integer.valueOf(redEnvBean.getLivenum()) > 1) { + liveUp(); + } + String livenum = redEnvBean.getLivenum(); + int livenumd = Integer.valueOf(livenum); + Log.e("TIAOSHI###", livenumd + "个直播间"); + if (livePosition == livenumd - 1) { + slidingDir = false; + } + Log.e("TIAOSHI###", "slidingDir==" + slidingDir); + } else { + // AblService.getInstance().randomSwipethree(); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "滑——向下滑前直播间的位置" + livePosition); + if (Integer.valueOf(redEnvBean.getLivenum()) > 1) { + liveDown(); + } + if (livePosition == 0) { + slidingDir = true; + } + Log.e("TIAOSHI###", "slidingDir==" + slidingDir); + } + Log.e("TIAOSHI###", "滑——滑动后直播间的位置" + livePosition); + AblViewUtil.mySleep(3); + tagControlView("", livePosition); + AblStepHandler.sendMsg(AblSteps.STEP_254); + + } + + /** + * 直播间上滑 + */ + public void liveUp() { + AccessibilityNodeInfo getdaohang = getdaohang(); + if (getdaohang != null) { + boolean b = getdaohang.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); + Log.e("TIAOSHI###", "测试向上滑动" + b); + if (b) { + livePosition = livePosition + 1; + againStart("1"); + } else { + againStart("0"); + } + } + } + + /** + * 直播间下滑 + */ + public void liveDown() { + AccessibilityNodeInfo getdaohang = getdaohang(); + if (getdaohang != null) { + boolean b = getdaohang.performAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD); + Log.e("TIAOSHI###", "测试向下滑动" + b); + if (b) { + livePosition = livePosition - 1; + againStart("1"); + } else { + againStart("0"); + } + } + } + + /** + * 计算红包的倒计时 + * + * @param str 红包控件的值 + * @return + */ + private int daojishimiao(String str) { + int daojishitiem = 0; + if (str.contains("可抢")) { + String[] str1 = str.split("秒"); + String str2 = str1[0]; + String[] str3 = str2.split("分"); + String str4 = str3[0]; + daojishitiem = Integer.valueOf(str4) * 60 + Integer.valueOf(str3[1]); + } else { + daojishitiem = Integer.valueOf(str); + } + Log.e("TIAOSHI###", "倒计时" + daojishitiem); + return daojishitiem; + } + + @Override + public int redEnvPostion() { + int targetlocation = 0; + ArrayList redenvBeanData = redenvDao.queryAll(); + ArrayList redenvData2 = new ArrayList<>(); + for (int i = 0; i < redenvBeanData.size(); i++) { + RedenvBeanData redenvBeanData1 = redenvBeanData.get(i); + String redenvtime = redenvBeanData1.getRedenvtime(); + if (!"0".equals(redenvtime)) { + redenvData2.add(redenvBeanData1); + } + } + //排序 + Collections.sort(redenvData2, new Comparator() { + @Override + public int compare(RedenvBeanData o1, RedenvBeanData o2) { + double aDouble1 = Double.valueOf(o1.getRedenvtime()); + double aDouble2 = Double.valueOf(o2.getRedenvtime()); + // return Double.compare( Integer.parseInt(o1.getSortcode()), Integer.parseInt(o2.getSortcode())); + return Double.compare(aDouble1, aDouble2); + } + }); + for (int i = 0; i < redenvData2.size(); i++) { + Log.e("TIAOSHI###", "红包开奖时间==" + redenvBeanData.get(i).getRedenvtime()); + } + if (redenvData2.size() > 0) { + String id = redenvData2.get(0).getId(); + targetlocation = Integer.valueOf(id); + } + return targetlocation; + } + + public int redEnvPostions() { + int targetlocation = -1; + ArrayList redenvBeanData = redenvDao.queryAll(); + ArrayList redenvData2 = new ArrayList<>(); + for (int i = 0; i < redenvBeanData.size(); i++) { + RedenvBeanData redenvBeanData1 = redenvBeanData.get(i); + String redenvtime = redenvBeanData1.getRedenvtime(); + if (!"0".equals(redenvtime)) { + redenvData2.add(redenvBeanData1); + } + } + Log.e("TIAOSHI###", "红包开奖时间集合个数s==" + redenvData2.size()); + //排序 + Collections.sort(redenvData2, new Comparator() { + @Override + public int compare(RedenvBeanData o1, RedenvBeanData o2) { + double aDouble1 = Double.valueOf(o1.getRedenvtime()); + double aDouble2 = Double.valueOf(o2.getRedenvtime()); + // return Double.compare( Integer.parseInt(o1.getSortcode()), Integer.parseInt(o2.getSortcode())); + return Double.compare(aDouble1, aDouble2); + } + }); + for (int i = 0; i < redenvData2.size(); i++) { + Log.e("TIAOSHI###", "红包开奖时间s==" + redenvBeanData.get(i).getRedenvtime()); + } + if (redenvData2.size() > 0) { + for (int i = 0; i < redenvData2.size(); i++) { + String redenvtime = redenvData2.get(i).getRedenvtime(); + int timenum = Integer.valueOf(redenvtime); + if (30 >= timenum && timenum <= 60) { + String id1 = redenvData2.get(i).getId(); + targetlocation = Integer.valueOf(id1); + } + } + } + return targetlocation; + } + + @Override + public boolean moveZhiBoJian(int postion, int postion2) { + int huadongNum = postion2 - postion; + if (huadongNum == 0) { + //不用滑动 + } + if (huadongNum > 0) { + Log.e("TIAOSHI###", "需要向上滑动" + huadongNum + "次"); + //向上滑动huadongNum次 + for (int i = 0; i < huadongNum; i++) { + AblService.getInstance().randomSwipetwo(); + livePosition = livePosition + 1; + AblViewUtil.mySleep(3); + } + } + if (huadongNum < 0) { + Log.e("TIAOSHI###", "需要向下滑动" + huadongNum + "次"); + //向下滑动huadongNum次 + for (int i = 0; i < -huadongNum; i++) { + AblService.getInstance().randomSwipethree(); + livePosition = livePosition - 1; + AblViewUtil.mySleep(3); + } + } + + AblStepHandler.sendMsg(AblSteps.STEP_254); + + return false; + } + +} + + + diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep6.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep6.java new file mode 100644 index 0000000..1ca0cc7 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep6.java @@ -0,0 +1,336 @@ +package com.fisherbone.fuzhu.step; + +import android.accessibilityservice.AccessibilityService; +import android.accessibilityservice.GestureDescription; +import android.graphics.Path; +import android.graphics.Rect; +import android.os.Build; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import androidx.annotation.RequiresApi; + +import com.blankj.utilcode.util.ToastUtils; +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.RandumInt; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; + +import java.util.List; + +/** + * @param + * @description 一键取关(取消已关注) + * @return + */ +public class TestAblStep6 extends BaseAblStep { + + + private String substring = "1000000";//当前的关注数 + private int numb;//阈值 + private String guanzhunum; + private AccessibilityNodeInfo child3; + + @Override + public void onStep(int step, Message msg) { + + // Log.e("TIAOSHI###==获得一键取关的参数",ChangLiang.cancelclosed+"---"+ChangLiang.cancelcrosscor+"---"+ChangLiang.passnumber+"---"+ChangLiang.swiinterval+"---"+ChangLiang.minthrthr+""); + switch (step) { + case AblSteps.STEP_11: + AblViewUtil.startApplication(); + AblViewUtil.mySleep(8); + AblStepHandler.sendMsg(AblSteps.STEP_12); + break; + case AblSteps.STEP_12: + ChangLiang.ishuodong = "T"; + AblViewUtil.mySleep(5); + AblService instance = AblService.getInstance(); + //1.关闭广告 + //2.关闭青少年弹窗 + //3.点击我的 + myClick(); + AblViewUtil.mySleep(2); + //获取关注数(对比关注数是否满足预设的取关值;)若不满足,则直接结束任务,若满足,则点击【关注】,进入关注页; + getargone(); + AblViewUtil.mySleep(1); + if (guanzhunum == null) { + Log.e("TIAOSHI###", "关注数==null结束任务"); + ToastUtils.showShort("关注数==null结束任务"); + AblStepHandler.getInstance().setStop(true); + // AblViewUtil.onMessage("停止"); + return; + } + Log.e("TIAOSHI###", "获得的关注数==" + guanzhunum); + int num = Integer.parseInt(guanzhunum); + Log.e("TIAOSHI###", "关注数" + num); + numb = Integer.parseInt(ChangLiang.minthrthr) - Integer.parseInt(ChangLiang.passnumber); + if (num <= Integer.parseInt(ChangLiang.minthrthr) - Integer.parseInt(ChangLiang.passnumber)) { + Log.e("TIAOSHI###", "关注数小于等于设定的取关数结束任务"); + ToastUtils.showShort("关注数小于等于设定的取关数结束任务"); + AblStepHandler.getInstance().setStop(true); + // AblViewUtil.onMessage("停止"); + return; + } + //点击进入用户关注页 + AblViewUtil.mySleep(2); + AblService.getInstance().clickcommontwo(child3, "进入用户关注页"); + AblStepHandler.sendMsg(AblSteps.STEP_13); + break; + case AblSteps.STEP_13: + int num2 = Integer.parseInt(getNum()); + if (num2 > numb) { + // AblViewUtil.mySleep(1); + cancelGuanzhu(AblService.getInstance()); + // AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_14); + } else { + ChangLiang.ishuodong = "F"; + AblViewUtil.back(); + } + break; + case AblSteps.STEP_14: + //获取一屏幕数据:快照 + AccessibilityNodeInfo roott = AblService.getInstance().getRootInActiveWindow(); + List idsj = roott.findAccessibilityNodeInfosByText("查找好友并关注"); + if (idsj.size() > 0) { + AccessibilityNodeInfo accessibilityNodeInfo = idsj.get(0); + CharSequence text1 = accessibilityNodeInfo.getText(); + if (text1.equals("查找好友并关注")) { + ChangLiang.ishuodong = "F"; + AblViewUtil.back(); + } + } + if (ChangLiang.ishuodong.equals("T")) { + AblViewUtil.mySleep(1); + // randomSwipe(); + AccessibilityNodeInfo chilrecy = getrecy(); + chilrecy.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); //触发容器元素的滚动事件 + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_13); + } + break; + default: + } + } + + private AccessibilityNodeInfo getrecy() { + AccessibilityNodeInfo chilrecy = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { + AccessibilityNodeInfo child1 = child.getChild(1); + Rect rect = new Rect(); + child1.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----fourNode:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { + chilrecy=child1; + } + } + } + return chilrecy; + } + + /** + * 获得当前的关注数 + * + * @return + */ + private String getNum() { + //获取关注数 + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + //遍历root下的子节点有哪些 + if (root != null) { + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { + Log.e("TIAOSHI###HorizontalScrollView", "----twoNode:" + child.getChildCount()); + for (int j = 0; j < child.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child.getChild(j); + Log.e("TIAOSHI###", "----twoNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + } + AccessibilityNodeInfo child1 = child.getChild(0); + if ("androidx.appcompat.app.ActionBar$Tab".equals(child1.getClassName())) { + for (int x = 0; x < child1.getChildCount(); x++) { + AccessibilityNodeInfo child2 = child1.getChild(x); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + String s = child2.getText().toString(); + Log.e("TIAOSHI###", s + "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + substring = s.substring(3); + Log.e("TIAOSHI###", "----关注数:" + substring); + } + } + } + } + } + return substring; + } + + private void cancelGuanzhu(AblService instance) { + // 取消已关: + // 在关注列表中,遍历寻找【已关注】的用户,点击【已关注】进行取关; + AblViewUtil.mySleep(2); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + //遍历root下的子节点有哪些 + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + AccessibilityNodeInfo child1 = child.getChild(1); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { + for (int x = 0; x < child1.getChildCount(); x++) { + AccessibilityNodeInfo child2 = child1.getChild(x); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + yiguanzhu(child2); + } + } + } + } + } + + // 3.遍历info中的子节点 (优化方法,正在测试) + public void yiguanzhu(AccessibilityNodeInfo child2) { + if (child2.getChildCount() != 0) { + for (int i = 0; i < child2.getChildCount(); i++) { + AccessibilityNodeInfo child = child2.getChild(i); + if (child.getText() != null) { + if (!child.getText().toString().equals("已关注")) { + continue; + } + } + + AblViewUtil.mySleep(1); + if (child.getText() != null) { + if (child.getText().toString().equals("已关注")) { + clickcommontwo(child, "已关注"); + } + } + + } + } + } + + public void clickcommontwo(AccessibilityNodeInfo accessibilityNodeInfo, String s) { + if (accessibilityNodeInfo != null) { + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮,直接退出了。。。。"); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_14); + } + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void randomSwipe() { + if (ChangLiang.phonetype.equals("0")) { + int a = 170 + RandumInt.getRandumInt4() * 8; + int b = 170 - RandumInt.getRandumInt4() * 10; + int c = 1200 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 2160--1080 + int d = 400 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 320); //延迟330毫秒 + } else { + int a = 500 + RandumInt.getRandumInt4() * 8; + int b = 500 - RandumInt.getRandumInt4() * 10; + int c = 1500 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 + int d = 700 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 420); //延迟330毫秒 + } + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void swipe(float x1, float y1, float x2, float y2, long duration) { + Path path = new Path(); + path.moveTo(x1, y1); + path.lineTo(x2, y2); + + Log.e("TIAOSHI###", "MyAccessibilityService中滑动swipe()方法滑动点,reset:(" + x1 + "," + y1 + "),(" + x2 + "," + y2 + ")" + "滑动的时长是:" + duration); + GestureDescription.Builder builder = new GestureDescription.Builder(); + GestureDescription gestureDescription = builder + .addStroke(new GestureDescription.StrokeDescription(path, 0, duration)) + .build(); + boolean b = AblService.getInstance().dispatchGesture(gestureDescription, new AccessibilityService.GestureResultCallback() { + @Override + public void onCompleted(GestureDescription gestureDescription) { + super.onCompleted(gestureDescription); + Log.e("TIAOSHI###", "滑动结束..." + gestureDescription.getStrokeCount()); + + } + + @Override + public void onCancelled(GestureDescription gestureDescription) { + super.onCancelled(gestureDescription); + Log.e("TIAOSHI###", "滑动取消"); + } + }, null); + } + + /** + * 获得关注数 + */ + private void getargone() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) {//13.1版本写法 + if ("dmt.viewpager.DmtViewPager$MyAccessibilityDelegate".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + if (child1 != null) { + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // if ("android.widget.LinearLayout".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + if (child2 != null) { + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); + + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child4 = child2.getChild(x); + if (child4 != null) { + Log.e("TIAOSHI###", "----fourNode:" + child4.getClassName() + ":" + child4.getText()); + for (int z = 0; z < child4.getChildCount(); z++) { + AccessibilityNodeInfo child5 = child4.getChild(z); + if (child5 != null) { + Log.e("TIAOSHI###", "----fiveNode:" + child5.getClassName() + ":" + child5.getText()); + if (child5.getText() != null) { + if (child5.getText().equals("关注")) { + AccessibilityNodeInfo parent = child5.getParent(); + child3 = parent.getChild(0); + Log.e("TIAOSHI###", "获得的关注数==" + child3.getText().toString()); + guanzhunum = child3.getText().toString(); + if (child3.getText().toString().equals("-")) { + Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); + } + return; + } + + } + } + } + } + } + } + } + } + } + } + } + } +} + diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep7.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep7.java new file mode 100644 index 0000000..2a2e2fe --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep7.java @@ -0,0 +1,385 @@ +package com.fisherbone.fuzhu.step; + +import android.accessibilityservice.AccessibilityService; +import android.accessibilityservice.GestureDescription; +import android.graphics.Path; +import android.graphics.Rect; +import android.os.Build; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import androidx.annotation.RequiresApi; + +import com.blankj.utilcode.util.ToastUtils; +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.RandumInt; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; + +import java.util.List; + +/** + * @param + * @description 一键取关(取消互关) + * @return + */ +public class TestAblStep7 extends BaseAblStep { + private String substring;//当前的关注数 + private int numb;//阈值 + private String guanzhunum; + private AccessibilityNodeInfo child3; + private AccessibilityNodeInfo child2; + + @Override + public void onStep(int step, Message msg) { + + // Log.e("TIAOSHI###==获得一键取互相关注的参数",ChangLiang.cancelclosed+"---"+ChangLiang.cancelcrosscor+"---"+ChangLiang.passnumber+"---"+ChangLiang.swiinterval+"---"+ChangLiang.minthrthr+""); + switch (step) { + case AblSteps.STEP_15: + AblViewUtil.startApplication(); + AblViewUtil.mySleep(8); + AblStepHandler.sendMsg(AblSteps.STEP_16); + break; + case AblSteps.STEP_16: + ChangLiang.ishuodong = "T"; + AblViewUtil.mySleep(5); + AblService instance = AblService.getInstance(); + //1.关闭广告 + //2.关闭青少年弹窗 + //3.点击我的 + myClick(); + AblViewUtil.mySleep(2); + //获取关注数(对比关注数是否满足预设的取关值;)若不满足,则直接结束任务,若满足,则点击【关注】,进入关注页; + getargone(); + AblViewUtil.mySleep(1); + if (guanzhunum==null) { + Log.e("TIAOSHI###", "关注数==null结束任务"); + ToastUtils.showShort("关注数==null结束任务"); + AblStepHandler.getInstance().setStop(true); + // AblViewUtil.onMessage("停止"); + return; + } + Log.e("TIAOSHI###", "获得的关注数==" + guanzhunum); + if(guanzhunum!=null) { + int num = Integer.parseInt(guanzhunum.toString()); + Log.e("TIAOSHI###", "关注数" + num); + numb = Integer.parseInt(ChangLiang.minthrthr) - Integer.parseInt(ChangLiang.passnumber); + if (num <= Integer.parseInt(ChangLiang.minthrthr) - Integer.parseInt(ChangLiang.passnumber)) { + Log.e("TIAOSHI###", "关注数小于等于设定的取关数结束任务"); + ToastUtils.showLong("关注数小于等于设定的取关数结束任务"); + AblStepHandler.getInstance().setStop(true); + AblViewUtil.onMessage("停止"); + return; + } + //点击进入用户关注页 + AblViewUtil.mySleep(2); + // AblService.getInstance().clickcommontwo(child, "进入用户关注页"); + AblService.getInstance().clickcommontwo(child3, "进入用户关注页"); + AblStepHandler.sendMsg(AblSteps.STEP_17); + } + break; + case AblSteps.STEP_17: + //寻找到第一条互相关注的进入个人信息页面 + //AblViewUtil.mySleep(1); + int num2 = Integer.parseInt(getNum()); + if (num2 > numb) { + // AblViewUtil.mySleep(1); + cancelGuanzhu(AblService.getInstance()); + } else { + ChangLiang.ishuodong = "F"; + AblViewUtil.back(); + } + break; + case AblSteps.STEP_18: + AblViewUtil.mySleep(3); + //获取一屏幕数据:快照 + AccessibilityNodeInfo roott = AblService.getInstance().getRootInActiveWindow(); + List idsj = roott.findAccessibilityNodeInfosByText("查找好友并关注"); + // List idsj = AblViewUtil.findByText("查找好友并关注"); + if (idsj.size() > 0) { + AccessibilityNodeInfo accessibilityNodeInfo = idsj.get(0); + CharSequence text1 = accessibilityNodeInfo.getText(); + if (text1.equals("查找好友并关注")) { + ChangLiang.ishuodong = "F"; + AblViewUtil.back(); + } + } + if (ChangLiang.ishuodong.equals("T")) { + AblViewUtil.mySleep(1); + // randomSwipe(); + AccessibilityNodeInfo chilrecy = getrecy(); + chilrecy.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); //触发容器元素的滚动事件 + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_17); + } + break; + default: + } + } + + private AccessibilityNodeInfo getrecy() { + AccessibilityNodeInfo chilrecy = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { + AccessibilityNodeInfo child1 = child.getChild(1); + Rect rect = new Rect(); + child1.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----fourNode:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); + if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { + chilrecy=child1; + } + } + } + return chilrecy; + } + + + private void cancelGuanzhu(AblService instance) { + // 取消已关: + // 在关注列表中,遍历寻找【已关注】的用户,点击【已关注】进行取关; + AblViewUtil.mySleep(2); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + //遍历root下的子节点有哪些 + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if(child!=null){ + if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + AccessibilityNodeInfo child1 = child.getChild(1); + if(child1!=null) { + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { + for (int x = 0; x < child1.getChildCount(); x++) { + AccessibilityNodeInfo child2 = child1.getChild(x); + if(child1!=null) { + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + if (child2.getChildCount() != 0) { + for (int w = 0; w < child2.getChildCount(); w++) { + AccessibilityNodeInfo childw = child2.getChild(w); + if (childw != null) { + if (childw.getText() != null) { + if (!childw.getText().toString().equals("互相关注")) { + continue; + } + } + + AblViewUtil.mySleep(1); + if (childw.getText() != null) { + if (childw.getText().toString().equals("互相关注")) { + //clickcommontwo(child2, "进入互相关注"); + if (child2 != null) { + Rect rect = new Rect(); + child2.getBoundsInScreen(rect); + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + "进入互相关注" + "按钮"); + Log.e("TIAOSHI###", "点击" + "进入互相关注" + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + "进入互相关注" + "按钮,直接退出了。。。。"); + return; + } + AblViewUtil.mySleep(2); + //点击取消关注 + AccessibilityNodeInfo getquxiaoguanzhu = getquxiaoguanzhu(); + //AblService.getInstance().clickcommontwo(getquxiaoguanzhu, "点击互相关注"); + if (getquxiaoguanzhu != null) { + Rect rect = new Rect(); + getquxiaoguanzhu.getBoundsInScreen(rect); + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + "互相关注" + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + AblViewUtil.mySleep(2); + //点击取消关注 + AccessibilityNodeInfo quxiao = AblViewUtil.findByText("取消关注", 1); + AblService.getInstance().clickcommonthree(quxiao, "取消关注"); + AblViewUtil.mySleep(2); + AblViewUtil.back(); + } else { + Log.e("TIAOSHI###", "没有找到" + "互相关注" + "按钮,直接退出了。。。。"); + AblViewUtil.mySleep(2); + AblViewUtil.back(); + + } + + } + } + } + } + } + } + } + } + } + }} + } + + //向上滑动 + // AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_18); + } + + /** + * 获得取消关注 + */ + private AccessibilityNodeInfo getquxiaoguanzhu() { + AccessibilityNodeInfo nodeinfo = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { + // Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("android.widget.TextView".equals(child1.getClassName())) { + CharSequence text = child1.getText(); + if (text != null) { + if (text.toString().contains("# 互相关注")) { + nodeinfo=child1; + } + } + } + } + } + } + return nodeinfo; + } + + + /** + * 获得当前的关注数 + * + * @return + */ + private String getNum() { + //获取关注数 + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + //遍历root下的子节点有哪些 + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { + // Log.e("TIAOSHI###HorizontalScrollView", "----twoNode:" + child.getChildCount()); + for (int j = 0; j < child.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child.getChild(j); + // Log.e("TIAOSHI###", "----twoNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + } + AccessibilityNodeInfo child1 = child.getChild(0); + if ("androidx.appcompat.app.ActionBar$Tab".equals(child1.getClassName())) { + for (int x = 0; x < child1.getChildCount(); x++) { + child2 = child1.getChild(x); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + String s = child2.getText().toString(); + // Log.e("TIAOSHI###", s + "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + substring = s.substring(3); + Log.e("TIAOSHI###", "----关注数:" + substring); + } + } + } + } + return substring; + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void randomSwipe() { + if (ChangLiang.phonetype.equals("0")) { + int a = 170 + RandumInt.getRandumInt4() * 8; + int b = 170 - RandumInt.getRandumInt4() * 10; + int c = 1200 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 + int d = 400 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 320); //延迟330毫秒 + } else { + int a = 500 + RandumInt.getRandumInt4() * 8; + int b = 500 - RandumInt.getRandumInt4() * 10; + int c = 1500 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 + int d = 700 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 420); //延迟330毫秒 + } + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void swipe(float x1, float y1, float x2, float y2, long duration) { + Path path = new Path(); + path.moveTo(x1, y1); + path.lineTo(x2, y2); + + Log.e("TIAOSHI###", "MyAccessibilityService中滑动swipe()方法滑动点,reset:(" + x1 + "," + y1 + "),(" + x2 + "," + y2 + ")" + "滑动的时长是:" + duration); + GestureDescription.Builder builder = new GestureDescription.Builder(); + GestureDescription gestureDescription = builder + .addStroke(new GestureDescription.StrokeDescription(path, 0, duration)) + .build(); + boolean b = AblService.getInstance().dispatchGesture(gestureDescription, new AccessibilityService.GestureResultCallback() { + @Override + public void onCompleted(GestureDescription gestureDescription) { + super.onCompleted(gestureDescription); + Log.e("TIAOSHI###", "滑动结束..." + gestureDescription.getStrokeCount()); + + } + + @Override + public void onCancelled(GestureDescription gestureDescription) { + super.onCancelled(gestureDescription); + Log.e("TIAOSHI###", "滑动取消"); + } + }, null); + } + + + /** + * 获得关注数 + */ + private void getargone() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + //if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + if ("dmt.viewpager.DmtViewPager$MyAccessibilityDelegate".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // if ("android.widget.LinearLayout".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); + + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child4 = child2.getChild(x); + Log.e("TIAOSHI###", "----fourNode:" + child4.getClassName() + ":" + child4.getText()); + for (int z = 0; z < child4.getChildCount(); z++) { + AccessibilityNodeInfo child5 = child4.getChild(z); + Log.e("TIAOSHI###", "----fiveNode:" + child5.getClassName() + ":" + child5.getText()); + if (child5.getText() != null) { + if (child5.getText().equals("关注")) { + AccessibilityNodeInfo parent = child5.getParent(); + child3 = parent.getChild(0); + Log.e("TIAOSHI###", "获得的关注数==" + child3.getText().toString()); + guanzhunum = child3.getText().toString(); + if (child3.getText().toString().equals("-")) { + Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); + } + return; + } + + } + } + } + } + } + } + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep8.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep8.java new file mode 100644 index 0000000..fa407e2 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep8.java @@ -0,0 +1,161 @@ +package com.fisherbone.fuzhu.step; + +import android.accessibilityservice.AccessibilityService; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; + +/** + * @param + * @description 退出登录并换号重新登录(手机号+验证码)和TestAblStep3逻辑差不多 + * @return + */ +public class TestAblStep8 extends BaseAblStep { + @Override + public void onStep(int step, Message msg) { + switch (step) { + case AblSteps.STEP_19: + AblViewUtil.startApplication(); + AblStepHandler.sendMsg(AblSteps.STEP_20); + break; + case AblSteps.STEP_20: + + AblService instance = AblService.getInstance(); + AblViewUtil.mySleep(10); + + //通过坐标点的方式获得node节点id + instance.clickPoint(648,1286, 300); + Log.e("TIAOSHI###", "点击了我按钮"); + //等待2秒点击更多按钮([624,75][688,139]) + AblViewUtil.mySleep(2); + //通过id的方式获得node节点id + instance.clickPoint(656,107, 300); + Log.e("TIAOSHI###", "点击了更多按钮"); + //等待2秒点击设置按钮([220,1023][720,1143]) + AblViewUtil.mySleep(2); + //通过id的方式获得node节点id + instance.clickPoint(470,1083, 300); + Log.e("TIAOSHI###", "点击了设置按钮"); + //等待2秒向上滑动 + AblViewUtil.mySleep(2); + instance.randomSwipe(); + //等待2秒点击切换账户 + AblViewUtil.mySleep(2); + instance.clickPoint(360,1069, 300); + AblViewUtil.mySleep(2); + AccessibilityNodeInfo tuichu = AblViewUtil.findByText("退出", 1); + instance.clickcommontwo(tuichu,"退出"); + AblViewUtil.mySleep(10); + //通过坐标点的方式获得node节点id + instance.clickPoint(648, 1286, 300); + Log.e("TIAOSHI###", "点击了我按钮"); + AblViewUtil.mySleep(4); +// AccessibilityNodeInfo denglu = AblViewUtil.findByText("其他手机号码登录", 1); +// instance.clickcommontwo(denglu,"其他手机号码登录"); + instance.clickPoint(360,786, 300); + Log.e("TIAOSHI###", "点击了其他手机号码登录按钮"); + AblViewUtil.mySleep(5); + //点击删除[570,356][656,452] + instance.clickPoint(613,404, 300); + Log.e("TIAOSHI###", "点击删除按钮"); + AblViewUtil.mySleep(4); + AblService.getInstance().performGlobalAction(AccessibilityService.GLOBAL_ACTION_HOME); + AblViewUtil.mySleep(1); + AblViewUtil.startApplication(); + AblViewUtil.mySleep(2); + //复制文本粘贴在留言板 + AccessibilityNodeInfo findcomentt = phoneEditview(); + AblViewUtil.paste(findcomentt, ChangLiang.phonenum); + AblViewUtil.mySleep(2); + AccessibilityNodeInfo yanzhengma = yanzhengma(); + instance.clickcommontwo(yanzhengma,"获取短信验证码"); + AblViewUtil.mySleep(2); + + break; + case AblSteps.STEP_21: + //获得验证码 + AblService.getInstance().performGlobalAction(AccessibilityService.GLOBAL_ACTION_HOME); + AblViewUtil.mySleep(1); + AblViewUtil.startApplication(); + AblViewUtil.mySleep(2); + Log.e("TIAOSHI###", "粘贴验证码"); + //复制验证码给文本 + AccessibilityNodeInfo findcomenttt = yanzheng(); + AblViewUtil.paste(findcomenttt, ChangLiang.code); + break; + default: + } + } + + /** + * 寻找+电话输入框 + */ + private AccessibilityNodeInfo phoneEditview() { + AccessibilityNodeInfo infooos = null; + AccessibilityNodeInfo rootttt = AblService.getInstance().getRootInActiveWindow(); + for (int j = 0; j < rootttt.getChildCount(); j++) { + AccessibilityNodeInfo child = rootttt.getChild(j); + Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----2Node:" + child1.getClassName() + ":" + child1.getText()); + if("android.widget.EditText".equals(child1.getClassName())){ + infooos=child.getChild(y); + } + } + } + + return infooos; + } + + /** + * 寻找+获取短信验证码 + */ + private AccessibilityNodeInfo yanzhengma() { + AccessibilityNodeInfo infooos = null; + AccessibilityNodeInfo rootttt = AblService.getInstance().getRootInActiveWindow(); + for (int j = 0; j < rootttt.getChildCount(); j++) { + AccessibilityNodeInfo child = rootttt.getChild(j); + Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----2Node:" + child1.getClassName() + ":" + child1.getText()); + if("android.widget.LinearLayout".equals(child1.getClassName())){ + infooos=child.getChild(y); + } + } + } + + return infooos; + } + + + /** + * 获得验证码 + */ + private AccessibilityNodeInfo yanzheng() { + AccessibilityNodeInfo infooos = null; + AccessibilityNodeInfo rootttt = AblService.getInstance().getRootInActiveWindow(); + for (int j = 0; j < rootttt.getChildCount(); j++) { + AccessibilityNodeInfo child = rootttt.getChild(j); + Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----2Node:" + child1.getClassName() + ":" + child1.getText()); + if("android.widget.EditText".equals(child1.getClassName())){ + infooos=child.getChild(y); + } + } + } + + return infooos; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep9.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep9.java new file mode 100644 index 0000000..ad1e56e --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep9.java @@ -0,0 +1,212 @@ +package com.fisherbone.fuzhu.step; + +import android.accessibilityservice.AccessibilityService; +import android.accessibilityservice.GestureDescription; +import android.graphics.Path; +import android.graphics.Rect; +import android.os.Build; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import androidx.annotation.RequiresApi; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.RandumInt; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; + +import java.util.List; + +/** + * @param + * @description 幢号 + * @return + */ +public class TestAblStep9 extends BaseAblStep { + @Override + public void onStep(int step, Message msg) { + switch (step) { + case AblSteps.STEP_22: + AblViewUtil.startApplication(); + + + AblService instance = AblService.getInstance(); + AblViewUtil.mySleep(10); + + //通过坐标点的方式获得node节点id + if(ChangLiang.phonetype.equals("0")){ + instance.clickPoint(648,1286, 300);//红米7a + }else { + instance.clickPoint(648,1536, 300);//华为畅享20 [632,1521][664,1552] + } + Log.e("TIAOSHI###", "点击了我按钮"); + + //等待2秒点击➕朋友[540,274][688,346] + AblViewUtil.mySleep(2); + if(ChangLiang.phonetype.equals("0")){ + instance.clickPoint(614,310, 300);//红米7a + }else { + instance.clickPoint(614,298, 300);//华为畅享20 [540,262][688,334] + } + AblViewUtil.mySleep(8); + + //点击查看通讯录好友[540,274][688,346] + AblViewUtil.mySleep(2); + if(ChangLiang.phonetype.equals("0")){ + instance.clickPoint(388,306, 300);//红米7a + }else { + instance.clickPoint(316,304, 300);//华为畅享20 [152,262][480,347] + } + AblStepHandler.sendMsg(AblSteps.STEP_23); + break; + case AblSteps.STEP_23: + + AblViewUtil.mySleep(3); + Guanzhu(AblService.getInstance()); + break; + case AblSteps.STEP_24: + //获取一屏幕数据:快照 + AccessibilityNodeInfo roott = AblService.getInstance().getRootInActiveWindow(); + List idsj = roott.findAccessibilityNodeInfosByText("暂时没有更多了"); + if (idsj.size() > 0) { + AccessibilityNodeInfo accessibilityNodeInfo = idsj.get(0); + CharSequence text1 = accessibilityNodeInfo.getText(); + if (text1.equals("暂时没有更多了")) { + ChangLiang.zishuodong = "F"; + AblViewUtil.back(); + } + } + if (ChangLiang.zishuodong.equals("T")) { + AblViewUtil.mySleep(1); + randomSwipe(); + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_23); + } + break; + case AblSteps.STEP_25: + AblService.getInstance().performGlobalAction(AccessibilityService.GLOBAL_ACTION_POWER_DIALOG); + AblViewUtil.mySleep(2); + //[163,770][303,910] + AblService.getInstance().clickPoint(233,840, 300);//红米7a + AblViewUtil.mySleep(2); + //[261,621][458,818] + AblService.getInstance().clickPoint(359,720, 300);//红米7a + break; + default: + } + } + + + private void Guanzhu(AblService instance) { + // 在关注列表中,遍历寻找【已关注】的用户,点击【已关注】进行取关; + AblViewUtil.mySleep(2); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); + if("android.widget.LinearLayout".equals(child2.getClassName())) { + int childCount = child2.getChildCount(); + AccessibilityNodeInfo child4 = child2.getChild(childCount - 1); + AblViewUtil.mySleep(1); + String s = child4.getText().toString(); + if(s.equals("关注")||s.equals("回关")) { + clickcommonthree(child4, "关注"); + AblViewUtil.mySleep(2); + //关闭修改备注 + AccessibilityNodeInfo cancanl = AblViewUtil.findByText("取消", 0); + clickcommonfour(cancanl, "取消"); + AblViewUtil.mySleep(3); + } + } + } + } + } + } + + //向上滑动 + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_24); + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickcommonthree(AccessibilityNodeInfo accessibilityNodeInfo, String s) { + if (accessibilityNodeInfo != null) { + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮"); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮,直接退出了。。。。"); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_14); + } + } + + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickcommonfour(AccessibilityNodeInfo accessibilityNodeInfo, String s) { + if (accessibilityNodeInfo != null) { + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮"); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮,直接退出了。。。。"); + AblViewUtil.mySleep(2); + } + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void randomSwipe() { + int a = 170 + RandumInt.getRandumInt4() * 8; + int b = 170 - RandumInt.getRandumInt4() * 10; + int c = 1200 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 + int d = 400 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 320); //延迟330毫秒 + } + + + @RequiresApi(api = Build.VERSION_CODES.N) + public void swipe(float x1, float y1, float x2, float y2, long duration) { + Path path = new Path(); + path.moveTo(x1, y1); + path.lineTo(x2, y2); + + Log.e("TIAOSHI###", "MyAccessibilityService中滑动swipe()方法滑动点,reset:(" + x1 + "," + y1 + "),(" + x2 + "," + y2 + ")" + "滑动的时长是:" + duration); + GestureDescription.Builder builder = new GestureDescription.Builder(); + GestureDescription gestureDescription = builder + .addStroke(new GestureDescription.StrokeDescription(path, 0, duration)) + .build(); + boolean b = AblService.getInstance().dispatchGesture(gestureDescription, new AccessibilityService.GestureResultCallback() { + @Override + public void onCompleted(GestureDescription gestureDescription) { + super.onCompleted(gestureDescription); + Log.e("TIAOSHI###", "滑动结束..." + gestureDescription.getStrokeCount()); + + } + + @Override + public void onCancelled(GestureDescription gestureDescription) { + super.onCancelled(gestureDescription); + Log.e("TIAOSHI###", "滑动取消"); + } + }, null); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStepBase.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStepBase.java new file mode 100644 index 0000000..ae06ad0 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStepBase.java @@ -0,0 +1,672 @@ +package com.fisherbone.fuzhu.step; + +import android.accessibilityservice.AccessibilityService; +import android.accessibilityservice.GestureDescription; +import android.graphics.Path; +import android.graphics.Rect; +import android.os.Build; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import androidx.annotation.RequiresApi; + +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.RandumInt; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.db.KeyWordBean; +import com.fisherbone.fuzhu.db.LetterBean; +import com.fisherbone.fuzhu.entity.PotCusBean; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +/** + * @param + * @description 潜在客户加关 + * @return + */ +public class TestAblStepBase extends BaseAblStep { + private static final String TAG = "Conmon"; + private ArrayList objects = new ArrayList<>(); + private AccessibilityNodeInfo child3; + + @Override + public void onStep(int step, Message msg) { + + // Log.e("TIAOSHI###==获得一键取互相关注的参数",ChangLiang.cancelclosed+"---"+ChangLiang.cancelcrosscor+"---"+ChangLiang.passnumber+"---"+ChangLiang.swiinterval+"---"+ChangLiang.minthrthr+""); + switch (step) { + case AblSteps.STEP_170: + AblViewUtil.startApplication(); + objects.add(ChangLiang.dav_douyinname); + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_171); + break; + case AblSteps.STEP_171: + + //点击右上角搜索 + DianSou(); + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_172); + break; + case AblSteps.STEP_172: + AblViewUtil.mySleep(1); + // ChangLiang.dav_ishuadong = "T"; + //输入关键词 + //判断有无要加关的关键词,如果有则执行112,没有则执行113 + if (objects.size() > 0) { + //复制文本粘贴在留言板 + AccessibilityNodeInfo findcomentt = findEditText(); + String conment = objects.get(0); + Log.e("TIAOSHI###", "获得的关键词内容" + conment); + AblViewUtil.mySleep(1); + if (ChangLiang.phonetype.equals("0")) { + AblViewUtil.sayInput(conment, findcomentt); + } else { + AblViewUtil.sayInput(conment, findcomentt);//华为畅享20 + } + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_173); + } + break; + case AblSteps.STEP_173: + //点击列表第一个,进入加关页面 +// AccessibilityNodeInfo firstview = firstview(); +// AblService.getInstance().clickcommontwo(firstview, "第一条"); + DianSou(); + AblViewUtil.mySleep(2); + AblService.getInstance().inputClickId("用户");//红米7a + AblViewUtil.mySleep(2); + //用坐标点的方式点击第一条 0,256 720,404 + AblService.getInstance().clickPoint(360, 330, 300); + AblViewUtil.mySleep(2); + getfensi(); + AblViewUtil.mySleep(1); + //点击进入用户关注页 + AblViewUtil.mySleep(1); + //用坐标点的方式点击第一条 0,256 720,404 + AblService.getInstance().clickPoint(160, 1280, 300); + AblStepHandler.sendMsg(AblSteps.STEP_174); + break; + case AblSteps.STEP_174: + AblViewUtil.mySleep(2); + if (ChangLiang.phonetype.equals("0")) { + AblService.getInstance().clickPoint(659, 810, 300);//红米7a + } else { + AblService.getInstance().clickPoint(659, 1066, 300);//华为畅享20 3.评论 [619,1026][699,1106] + } + ChangLiang.dav_qianzai = "T"; + Log.e("TIAOSHI###", "点击评论按钮"); + AblStepHandler.sendMsg(AblSteps.STEP_175); + break; + case AblSteps.STEP_175: + //检索关键词 + cancelGuanzhu(AblService.getInstance()); + break; + case AblSteps.STEP_176: + break; + case AblSteps.STEP_177: + //发送私信 + fasongsixin(AblService.getInstance()); + + break; + case AblSteps.STEP_178: + AblViewUtil.mySleep(1); + //向上滑动 + AblService.getInstance().randomSwipetwo(); + AblStepHandler.sendMsg(AblSteps.STEP_174); + break; + case AblSteps.STEP_179: + break; + default: + } + } + + private void cancelGuanzhu(AblService instance) { + AblViewUtil.mySleep(2); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode--:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.LinearLayout".equals(child.getClassName())) { + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode--:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("androidx.viewpager.widget.ViewPager".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode--:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child2.getClassName())) { + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + // Log.e("TIAOSHI###", "----fourNode--:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); + Log.e("TIAOSHI###", "----fourNode--数量:" + child3.getChildCount()); + if (child3 != null) { + if (child3.getChildCount() == 7 || child3.getChildCount() == 8) { + for (int r = 0; r < child3.getChildCount(); r++) { + if (child3.getChild(r) != null) { + if ("android.widget.TextView".equals(child3.getChild(r).getClassName())) { + if (child3.getChild(r).getText() != null) { + // if (child3.getChild(r).getText().toString().contains(ChangLiang.dav_keyword)) { + if (isBaohan(child3.getChild(r).getText().toString())) { + Log.e("TIAOSHI###", "包含关键词----进入详情:" + child3.getChildCount()); + // clickcommonthree(child3.getChild(0), "头像" + child3.getChild(1).getText()); + if (child3.getChild(0) != null) { + Rect rect = new Rect(); + child3.getChild(0).getBoundsInScreen(rect); + + if (rect.top >= 349 && rect.bottom <= 1238&&rect.right<=96) { + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + "用户头像" + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + }else { + Log.e("TIAOSHI###", "不在区间内"); + continue; + } + + } else { + Log.e("TIAOSHI###", "没有找到" + "用户头像" + "按钮"); + return; + } + AblViewUtil.mySleep(2); + AblViewUtil.mySleep(2); + //添加关注 + AccessibilityNodeInfo getquxiaoguanzhu = getquxiaoguanzhu(); + AblViewUtil.mySleep(1); + clickcommonthree(getquxiaoguanzhu, "关注"); + AblViewUtil.mySleep(1); + fasongsixin(AblService.getInstance()); + + } + } + } + } + } + } + } + } + } + } + } + } + } + } + + AblViewUtil.mySleep(3); + //获取一屏幕数据:快照 + List itemss = AblService.getInstance().getRootInActiveWindow().findAccessibilityNodeInfosByText("部分评论因未授权"); + Log.e("TIAOSHI###", "----打印数据:" + itemss.size() + ChangLiang.dav_qianzai); + if (itemss.size() > 0) { + Log.e("TIAOSHI###", "大哥到底了"); + Log.d(TAG, "大哥到底了 "); + ChangLiang.dav_qianzai = "F"; + AblViewUtil.back(); + AblStepHandler.sendMsg(AblSteps.STEP_178); + return; + } + List itemsss = AblService.getInstance().getRootInActiveWindow().findAccessibilityNodeInfosByText("暂时没有更多了"); + Log.e("TIAOSHI###", "----打印数据:" + itemsss.size() + ChangLiang.dav_qianzai); + if (itemsss.size() > 0) { + Log.e("TIAOSHI###", "大哥到底了"); + Log.d(TAG, "大哥到底了 "); + ChangLiang.dav_qianzai = "F"; + AblViewUtil.back(); + AblStepHandler.sendMsg(AblSteps.STEP_178); + return; + } + if (ChangLiang.dav_qianzai.equals("T")) { + Log.e("TIAOSHI###", "----打印数据:" + "执行了"); + Log.e("TIAOSHI###", "----正常:" + ChangLiang.dav_qianzai); + AblViewUtil.mySleep(1); + randomSwipe(); + AblViewUtil.mySleep(3); + AblStepHandler.sendMsg(AblSteps.STEP_175); + } + } + + private void fasongsixin(AblService instance) { + //通过坐标点的方式获得node节点id + if (ChangLiang.phonetype.equals("0")) { + instance.clickPoint(656, 107, 300);//红米7a //点击右上角菜单[624,75][688,139] + } else { + instance.clickPoint(664, 92, 300);//华为畅享20 [640,68][688,116] + } + + Log.e("TIAOSHI###", "点击了更多按钮"); + AblViewUtil.mySleep(2); + //点击发私信 + List list = AblViewUtil.findByText("发私信"); + for (AccessibilityNodeInfo item : list) { + clickcommonthree(item, "发私信"); + } + AblViewUtil.mySleep(2); +// //寻找编辑控件 + AccessibilityNodeInfo findcomentt = findcoment(); +// //复制粘贴内容 + String conment = getConment(); + Log.e("TIAOSHI###", "获得的信息内容" + conment); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "获得的信息内容" + conment); + if (ChangLiang.phonetype.equals("0")) { + Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype); + //郝总的手机用第一个评论不上去 + // AblViewUtil.paste(findcomentt, conment);//红米7a + AblViewUtil.sayInput(conment, findcomentt); + } else { + Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype); + AblViewUtil.sayInput(conment, findcomentt);//华为畅享20 + } + //发送 + AblViewUtil.mySleep(2); +// //点击发送 + AccessibilityNodeInfo findcomenttt = findcomentt(); + if (findcomentt != null) { + AblService.getInstance().clickcommonthree(findcomenttt, "发送"); + AblViewUtil.mySleep(2); + } + AblViewUtil.mySleep(2); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + AblViewUtil.back(); + AblViewUtil.mySleep(2); + //检索关键词 +// AccessibilityNodeInfo chilrecy = getguanjian(); +// chilrecy.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); //触发容器元素的滚动事件 +// AblViewUtil.mySleep(1); +// AblStepHandler.sendMsg(AblSteps.STEP_175); + } + + private AccessibilityNodeInfo getguanjian() { + AccessibilityNodeInfo chilrecy = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child2.getClassName())) { + chilrecy = child1.getChild(j); + // Log.e("TIAOSHI###", "----thrxxxxNode:" + chilrecy.getClassName() + ":" + chilrecy.getText() + ":" + chilrecy.getContentDescription()); + + } + } + } + } + return chilrecy; + } + + @RequiresApi(api = Build.VERSION_CODES.N) + public void clickcommonthree(AccessibilityNodeInfo accessibilityNodeInfo, String s) { + if (accessibilityNodeInfo != null) { + Rect rect = new Rect(); + accessibilityNodeInfo.getBoundsInScreen(rect); + AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); + Log.e("TIAOSHI###", "点击" + s + "按钮"); + Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); + } else { + Log.e("TIAOSHI###", "没有找到" + s + "按钮"); + + + } + } + + @RequiresApi(api = Build.VERSION_CODES.N) + public void randomSwipe() { + if (ChangLiang.phonetype.equals("0")) { + int a = 170 + RandumInt.getRandumInt4() * 8; + int b = 170 - RandumInt.getRandumInt4() * 10; + int c = 1200 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 2160--1080 + int d = 400 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 320); //延迟330毫秒 + } else { + int a = 500 + RandumInt.getRandumInt4() * 8; + int b = 500 - RandumInt.getRandumInt4() * 10; + int c = 1500 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 + int d = 700 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 + // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 + swipe(a, c, b, d, 420); //延迟330毫秒 + } + } + + @RequiresApi(api = Build.VERSION_CODES.N) + public void swipe(float x1, float y1, float x2, float y2, long duration) { + Path path = new Path(); + path.moveTo(x1, y1); + path.lineTo(x2, y2); + + Log.e("TIAOSHI###", "MyAccessibilityService中滑动swipe()方法滑动点,reset:(" + x1 + "," + y1 + "),(" + x2 + "," + y2 + ")" + "滑动的时长是:" + duration); + GestureDescription.Builder builder = new GestureDescription.Builder(); + GestureDescription gestureDescription = builder + .addStroke(new GestureDescription.StrokeDescription(path, 0, duration)) + .build(); + boolean b = AblService.getInstance().dispatchGesture(gestureDescription, new AccessibilityService.GestureResultCallback() { + @Override + public void onCompleted(GestureDescription gestureDescription) { + super.onCompleted(gestureDescription); + Log.e("TIAOSHI###", "滑动结束..." + gestureDescription.getStrokeCount()); + + } + + @Override + public void onCancelled(GestureDescription gestureDescription) { + super.onCancelled(gestureDescription); + Log.e("TIAOSHI###", "滑动取消"); + } + }, null); + } + + /** + * 获得取消关注 + */ + public AccessibilityNodeInfo getquxiaoguanzhu() { + AccessibilityNodeInfo child2 = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { + // Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("android.widget.TextView".equals(child1.getClassName())) { + CharSequence text = child1.getText(); + if (text != null) { + if (text.toString().equals("# 关注")) { + child2 = child.getChild(y); + } + } + } + } + } + } + return child2; + } + + + /** + * 获得粉丝数 + */ + public void getfensi() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + //if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // if ("android.widget.LinearLayout".equals(child1.getClassName())) { + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); + if (child2.getText() != null) { + if (child2.getText().equals("粉丝")) { + AccessibilityNodeInfo parent = child2.getParent(); + child3 = parent.getChild(0); + Log.e("TIAOSHI###", "获得的关注数==" + child3.getText().toString()); + // guanzhunum = child3.getText().toString(); + if (child3.getText().toString().equals("-")) { + Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); + } + return; + } + } + } + } + } + } + } + + + /** + * 寻找搜索输入框 + */ + public AccessibilityNodeInfo findEditText() { + AccessibilityNodeInfo infooos = null; + AccessibilityNodeInfo rootttt = AblService.getInstance().getRootInActiveWindow(); + for (int j = 0; j < rootttt.getChildCount(); j++) { + AccessibilityNodeInfo child = rootttt.getChild(j); + // Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + if ("android.widget.EditText".equals(child.getClassName())) { + infooos = child; + } + } + return infooos; + } + + + //点击右上角搜索 + //[624,67][688,131] + public void DianSou() { + + if (ChangLiang.phonetype.equals("0")) { + AblService.getInstance().clickPoint(656, 99, 300);//红米7a + } else { + AblService.getInstance().clickPoint(659, 99, 300);//华为畅享20 + } + Log.e("TIAOSHI###", "点击搜索按钮"); + } + + + /** + * 寻找发送 + */ + public AccessibilityNodeInfo findcomentt() { + AccessibilityNodeInfo child3 = null; + ArrayList objects = new ArrayList<>(); + AccessibilityNodeInfo rootttt = AblService.getInstance().getRootInActiveWindow(); + for (int j = 0; j < rootttt.getChildCount(); j++) { + AccessibilityNodeInfo child = rootttt.getChild(j); + // Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child2 = child.getChild(y); + // Log.e("TIAOSHI###", "----2Node:" + child2.getClassName() + ":" + child2.getText()); + + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child1 = child2.getChild(x); + // Log.e("TIAOSHI###", "----3Node:" + child1.getClassName() + ":" + child1.getText()); + + if ("android.widget.ImageView".equals(child2.getChild(x).getClassName())) { + AccessibilityNodeInfo infooos = child2.getChild(x); + objects.add(infooos); + } + } + // Log.e("TIAOSHI###", "----4Node:" + objects.size()); + if (objects.size() > 0) { + child3 = objects.get(objects.size() - 1); + } + } + } + return child3; + } + + + /** + * 寻找留下你的精彩评论 + */ + public AccessibilityNodeInfo findcoment() { + AccessibilityNodeInfo infooos = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int j = 0; j < root.getChildCount(); j++) { + AccessibilityNodeInfo child = root.getChild(j); + // Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----2Node:" + child1.getClassName() + ":" + child1.getText()); + for (int x = 0; x < child1.getChildCount(); x++) { + AccessibilityNodeInfo child6 = child1.getChild(x); + // Log.e("TIAOSHI###", "----3Node:" + child6.getClassName() + ":" + child6.getText()); + if ("android.widget.EditText".equals(child6.getClassName())) { + infooos = child1.getChild(x); + // Log.e("TIAOSHI###", "----4Node:" + infooos.getClassName() + ":" + infooos.getText()); + } + } + } +// } + } + return infooos; + } + + + /** + * 随机获取评论话术 + */ + public String getConment() { + PotCusBean pot = ProfileSpUtils.getInstance().getPot(); + List CommentBeanDatas = pot.getLetterdatas(); + if (CommentBeanDatas.size() == 0) { + return ""; + } else if (CommentBeanDatas.size() == 1) { + LetterBean letterBean = CommentBeanDatas.get(0); + String comment = letterBean.getComment(); + return comment; + } else { + int i = new Random().nextInt(CommentBeanDatas.size() - 1); + LetterBean letterBean = CommentBeanDatas.get(i); + String comment = letterBean.getComment(); + return comment; + } + } + + + public boolean isBaohan(String str) { + PotCusBean pot = ProfileSpUtils.getInstance().getPot(); + List keywords = pot.getKeyworddatas(); + boolean iscontain = false; + for (int i = 0; i < keywords.size(); i++) { + + boolean contains = str.contains(keywords.get(i).getComment()); + Log.e("TIAOSHI###包含关键词==contains", contains + ""); + if (contains) { + Log.e("TIAOSHI###包含关键词==", keywords.get(i).getComment()); + iscontain = contains; + break; + } + } + return iscontain; + } + + + public String getTime() { + String substring = ""; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); + Rect rect = new Rect(); + child3.getBoundsInScreen(rect); + Log.e("TIAOSHI###", "----fourNode:" +"("+rect.left+","+rect.top+")"+","+"("+rect.right+","+rect.bottom+")"); + + + if(ChangLiang.phonetype.equals("0")){//红米7A + //(167,938),(408,973) + if (rect.top >= 934 && rect.bottom <= 1150) { + if("android.widget.TextView".equals(child3.getClassName())){ + String s = child3.getText().toString(); + substring = s.substring(1); + Log.e("TIAOSHI###", "----获取的时间:" + substring); + } + }else { + // Log.e("TIAOSHI###", "不在区间内"); + continue; + } + }else { + //(189,1130),(350,1170) + if (rect.top >= 1130 && rect.bottom <= 1401) { + if("android.widget.TextView".equals(child3.getClassName())){ + String s = child3.getText().toString(); + substring = s.substring(1); + Log.e("TIAOSHI###", "----获取的时间:" + substring); + } + }else { + // Log.e("TIAOSHI###", "不在区间内"); + continue; + } + } + } + } + } + } + return substring; + } + + /** + * 判断是否是近7天的时间 + * @param substring + * @return + * //2020年12月30日 01月01日 04月22 1天前 2天前 3天前 4天前 5天前 6天前 13小时前 5分钟前 + */ + public boolean Compliance(String substring){ + if(substring.contains("1天前")||substring.contains("2天前")||substring.contains("3天前")||substring.contains("4天前")||substring.contains("5天前")||substring.contains("6天前")||substring.contains("小时前")||substring.contains("分钟前")){ + // if(substring.contains("1天前")){ + return true; + }else { + return false; + } + } + + public AccessibilityNodeInfo getrecy(){ + AccessibilityNodeInfo chilrecy = null; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); + if ("androidx.recyclerview.widget.RecyclerView".equals(child2.getClassName())) { + chilrecy = child1.getChild(j); + // Log.e("TIAOSHI###", "----thrxxxxNode:" + chilrecy.getClassName() + ":" + chilrecy.getText() + ":" + chilrecy.getContentDescription()); + + } + } + } + } + return chilrecy; + } + + + /** + * 获取一条随机字符串 + * @param length + * @return + */ + public String getRandomString(int length) { //length表示生成字符串的长度 + String base = "abcdefghijklmnopqrstuvwxyz0123456789"; + Random random = new Random(); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < length; i++) { + int number = random.nextInt(base.length()); + sb.append(base.charAt(number)); + } + Log.e("提交的字符串s", "getRandomString: " + sb.toString()); + return sb.toString(); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStepXin5.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStepXin5.java new file mode 100644 index 0000000..e475e79 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStepXin5.java @@ -0,0 +1,867 @@ +package com.fisherbone.fuzhu.step; + +import android.accessibilityservice.GestureDescription; +import android.content.Context; +import android.graphics.Rect; +import android.os.Message; +import android.util.Log; +import android.view.accessibility.AccessibilityNodeInfo; + +import com.blankj.utilcode.util.ToastUtils; +import com.fisherbone.fuzhu.ChangLiang; +import com.fisherbone.fuzhu.FuzhuApplication; +import com.fisherbone.fuzhu.abllib.AblService; +import com.fisherbone.fuzhu.abllib.AblStepHandler; +import com.fisherbone.fuzhu.abllib.AblSteps; +import com.fisherbone.fuzhu.abllib.BaseAblStep; +import com.fisherbone.fuzhu.abllib.callback.GestureCallBack; +import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.db.CommentBeanData; +import com.fisherbone.fuzhu.db.dao.CommentDao; +import com.fisherbone.fuzhu.entity.RecFollowBean; +import com.fisherbone.fuzhu.okgonet.HttpConstants; +import com.fisherbone.fuzhu.okgonet.NetApi; +import com.fisherbone.fuzhu.utils.DateUtils; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; +import com.lzy.okgo.model.HttpParams; +import com.lzy.okgo.model.Response; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Random; + +/** + * @param + * @description 推荐加关(匹配抖音14.6版本) + * @return + */ +public class TestAblStepXin5 extends BaseAblStep { + private List accessibilityNodeInfos; + private String guanzhunum; + private String fensinum; + private String zuopinnum; + private String huozannum; + public String SHEBEITIPE_VILUETHREE = "3"; + private RecFollowBean userProfie; + boolean isStart = true; + private Context mContext; + private boolean ifend; + + public TestAblStepXin5(Context nContext) { + super(); + this.mContext=nContext; + } + + @Override + public void onStep(int step, Message msg) { + switch (step) { + case AblSteps.STEP_9: + isStart = true; + ChangLiang.guanzhunum=0; + userProfie = ProfileSpUtils.getInstance().getUserProfie(); + AblViewUtil.startApplication(); + AblViewUtil.mySleep(2); + allowed(); + AblViewUtil.mySleep(3); + AblService.getInstance().randomSwipetwo();//上滑一页 + AblViewUtil.mySleep(2); + AblStepHandler.sendMsg(AblSteps.STEP_27); + + break; + case AblSteps.STEP_27: + + closedtjDialog(AblService.getInstance()); + AblViewUtil.mySleep(1); + //1.关闭检测到更新的弹框 + closedJDialog(AblService.getInstance()); + AblViewUtil.mySleep(1); + //2.关闭青少年弹窗 + closedQDialog(AblService.getInstance()); + AblViewUtil.mySleep(1); + closedBDialog(AblService.getInstance()); + AblViewUtil.mySleep(1); + AblStepHandler.sendMsg(AblSteps.STEP_28); + + // LiveEventBus.get("jiaguantime").post(Integer.parseInt(userProfie.getRunningtime()) * 3600+""); + + break; + case AblSteps.STEP_28: + recordDoubi(DateUtils.getNowString()); + Log.e("TIAOSHI###", "初始时间" + userProfie.getLivetimefir()); + Log.e("TIAOSHI###", "当前时间" + userProfie.getLivetime()); +// String sp = (String) SPUtils.getSp(mContext, FZConfig.KEY_YUN_ISOPEN, "1"); +// Log.e("TIAOSHI###", "当前sp==" + sp); + + boolean redswitchone = ProfileSpUtils.getInstance().getSetBean().isRedswitchone(); + Log.e("TIAOSHI###", "当前sp==" + redswitchone); + if(redswitchone){ + ifend = runTimetwo(userProfie.getEnd_time()); + }else { + ifend = runTime(); + } + if (ifend) { + Log.e("TIAOSHI###", "运行时间已到,停止自动加关"); + AblStepHandler.getInstance().setStop(true); + AblViewUtil.onMessage("停止"); + return; + } else { + int a = Integer.parseInt(userProfie.getMaxvideotime()) - Integer.parseInt(userProfie.getVideotime()); + if (a != 0) { + Random rand = new Random(); + int randnum = rand.nextInt(a); + AblViewUtil.mySleep(2 + randnum); + } + + Rect rect = new Rect(); + if (rect.top >= 0 && rect.bottom <= 2111 && rect.left >= 0 && rect.right <= 1080) { + AccessibilityNodeInfo liebiaokongg = AblViewUtil.findByText("广告", 0); + if (liebiaokongg != null) { + liebiaokongg.getBoundsInScreen(rect); + } + if (liebiaokongg != null) { + Log.e("TIAOSHI###", "此视频包含广告"); + AblStepHandler.sendMsg(AblSteps.STEP_31); + return; + } + AccessibilityNodeInfo zhibojian = AblViewUtil.findByText("点击进入直播间", 0); + if (zhibojian != null) { + Log.e("TIAOSHI###", "此视频包含点击进入直播间"); + AblStepHandler.sendMsg(AblSteps.STEP_31); + return; + } + AccessibilityNodeInfo guangbo = AblViewUtil.findByText("广播", 0); + if (guangbo != null) { + Log.e("TIAOSHI###", "此视频包含广播"); + AblStepHandler.sendMsg(AblSteps.STEP_31); + return; + } + AccessibilityNodeInfo xiangqing = AblViewUtil.findByText("查看详情", 0); + if (xiangqing != null) { + Log.e("TIAOSHI###", "此视频包含查看详情"); + AblStepHandler.sendMsg(AblSteps.STEP_31); + return; + } + //如果有查看详情,则滑动到下一个视频 + zhijieshanghua(); + } + AblStepHandler.sendMsg(AblSteps.STEP_29); + } + + + + + break; + case AblSteps.STEP_29: + if (SHEBEITIPE_VILUETHREE.equals(ChangLiang.phonetype)) { + //左滑进入个人信息页 + AblViewUtil.scrollHorizontal(720, 10, 100, 300, new GestureCallBack() { + @Override + public void succ(GestureDescription gestureDescription) { + AblViewUtil.mySleep(2); + + //atom运行检查 + boolean norma = Norma(); + if (norma) { + Log.e("TIAOSHI###", "页面在二级页面运行正常"); + againStart("1"); + } else { + Log.e("TIAOSHI###", "页面在二级页面运行异常"); + againStart("0"); + } + + ChangLiang.condition = "0"; + boolean guanzhu = isGuanzhu(); + if(!guanzhu) { + boolean condition = getCondition(); + if ((condition)){ + ChangLiang.condition = "0"; + }else { + ChangLiang.condition = "1"; + } + } + AblStepHandler.sendMsg(AblSteps.STEP_30); + } + + @Override + public void fail(GestureDescription gestureDescription) { + + } + }); + } else { + //左滑进入个人信息页 + AblViewUtil.scrollHorizontal(500, 10, 100, 300, new GestureCallBack() { + @Override + public void succ(GestureDescription gestureDescription) { + AblViewUtil.mySleep(2); + + //atom运行检查 + boolean norma = Norma(); + if (norma) { + Log.e("TIAOSHI###", "页面在二级页面运行正常"); + againStart("1"); + } else { + Log.e("TIAOSHI###", "页面在二级页面运行异常"); + againStart("0"); + } + ChangLiang.condition = "0"; + boolean guanzhu = isGuanzhu(); + if(!guanzhu) { + boolean condition = getCondition(); + if ((condition)){ + ChangLiang.condition = "0"; + }else { + ChangLiang.condition = "1"; + } + } + AblStepHandler.sendMsg(AblSteps.STEP_30); + } + + @Override + public void fail(GestureDescription gestureDescription) { + + } + }); + } + break; + case AblSteps.STEP_30: + //加关注(659,576) 加关注有最大关注数的条件限制 + int maxnumber = Integer.parseInt(userProfie.getMaxnumcon()); + if (ChangLiang.guanzhunum < maxnumber) { + //满足条件执行点赞关注评论 + if (ChangLiang.condition.equals("0")) { + AblViewUtil.back(); + Log.e("TIAOSHI###", "满足点赞关注评论条件"+ ChangLiang.condition); + operation(); + } else { + Log.e("TIAOSHI###", "不满足点赞关注评论条件"); + AblViewUtil.back(); + AblViewUtil.mySleep(1); + } + AblService.getInstance().randomSwipetwo(); + int num = ChangLiang.tasknum; + Log.e("TIAOSHI###", "执行第" + num + "次循环"); + int num1 = num + 1; + ChangLiang.tasknum = num1; + AblStepHandler.sendMsg(AblSteps.STEP_28); + } else { + Log.e("TIAOSHI###", "已经达到最大关注数,停止自动加关"); + ToastUtils.showShort("已经达到最大关注数,停止自动加关"); + AblViewUtil.back(); + AblStepHandler.getInstance().setStop(true); + AblViewUtil.onMessage("停止"); + } + break; + + case AblSteps.STEP_31: + AblService.getInstance().randomSwipetwo(); + AblStepHandler.sendMsg(AblSteps.STEP_28); + break; + default: + } + } + + + private boolean getCondition() { + boolean flag=false; + AblViewUtil.mySleep(1); + getargone(); + //判断作品数条件 + boolean getargfour = getargfour(); + // getUserInfo(); + boolean b1 = guanzhuCon(); + AblViewUtil.mySleep(1); + boolean b = fensiCon(); + // if(b&&b1){ + if(b&&b1&&getargfour){ + flag=true; + } + return flag; + } + + /** + * 是否关注过 + * @return + */ + private boolean isGuanzhu() { + boolean flag=false; + String getquxiaoguanzhu = getquxiaoguanzhu(); + if (getquxiaoguanzhu.equals("0")) { + Log.e("TIAOSHI###", "已经关注了,直接返回"); + flag=true; + } + return flag; + } + + /** + * 关注数条件判断 + * @return + */ + private boolean guanzhuCon() { + boolean flag=true; + if (guanzhunum != null) { + if (!guanzhunum.equals("-")) { + if (guanzhunum.contains("w")) { + String substring = guanzhunum.substring(0, guanzhunum.indexOf("w")); + double personmun = Double.parseDouble(substring) * 10000; + int personnum = new Double(personmun).intValue(); + Log.e("数据", "----获取的直播间人数:" + personnum); + guanzhunum = personnum + ""; + } + if (Integer.parseInt(guanzhunum) < Integer.parseInt(userProfie.getMinimumlikes()) || Integer.parseInt(guanzhunum) > Integer.parseInt(userProfie.getMaxmumlikes())) { + Log.e("TIAOSHI###", "获取的该用户关注数" + Integer.parseInt(guanzhunum) + "小于设置的加关关注数(不在区间" + Integer.parseInt(userProfie.getMinimumlikes()) + "-" + Integer.parseInt(userProfie.getMaxmumlikes()) + "),关注数不满足条件"); + flag=false; + } else { + Log.e("TIAOSHI###", "获取的该用户关注数不小于设置的加关关注数,满足加关点赞评论条件"); + } + } else { + flag=false; + } + } + return flag; + } + + /** + * 粉丝数条件判断 + */ + + private boolean fensiCon() { + boolean flag=true; + if (fensinum != null) { + boolean status2 = fensinum.contains("w"); + boolean status3 = fensinum.contains("亿"); + if (status2 || status3) { + Log.e("TIAOSHI###", "获取的该用户粉丝数不小于设置的加关粉丝数,满足加关点赞评论条件"); + } else { + if (fensinum != null) { + if (!fensinum.equals("-")) { + if (Integer.parseInt(fensinum) < Integer.parseInt(userProfie.getMinimumcon()) || Integer.parseInt(fensinum) > Integer.parseInt(userProfie.getMaximumcon())) { + Log.e("TIAOSHI###", "获取的该用户粉丝数" + Integer.parseInt(fensinum) + "小于设置的加关粉丝数(不在区间" + Integer.parseInt(userProfie.getMinimumcon()) + "-" + Integer.parseInt(userProfie.getMaximumcon()) + "),粉丝数不满足条件"); + flag=false; + } else { + Log.e("TIAOSHI###", "获取的该用户粉丝数不小于设置的加关粉丝数,满足加关点赞评论条件"); + } + } else { + flag=false; + } + } + } + } + return flag; + } + + + //点赞 + 评论 + 关注 + private void operation() { + AblViewUtil.mySleep(1); + //随机评论打开 + if (userProfie.getRandomlikes()) { + Log.e("TIAOSHI###", "点赞参数" + userProfie.getRandomlikes()); + homeDianzan(); + } + AblViewUtil.mySleep(2); + if (userProfie.getRandomattention()) { + addguanzhu(); + } + AblViewUtil.mySleep(2); + //评论 + if (userProfie.getRandomreview()) { + pinglun(); + } + AblViewUtil.mySleep(2); + } + + private void homeDianzan() { + if (ChangLiang.phonetype.equals("0")) { + //红米7a + AblService.getInstance().clickPoint(659, 666, 300); + } else if ("3".equals(ChangLiang.phonetype)) { + //红米9a + AblService.getInstance().clickPoint(996, 1267, 300); + } else { + //华为畅享20 + AblService.getInstance().clickPoint(659, 922, 300); + } + Log.e("TIAOSHI###", "点击点赞按钮"); + } + + private void pinglun() { + commentClick(AblService.getInstance()); + AblViewUtil.mySleep(3); + if (ChangLiang.phonetype.equals("0")) { + //红米7a + AblService.getInstance().clickPoint(153, 1292, 300); + } else if ("3".equals(ChangLiang.phonetype)) { + //红米9a + AblService.getInstance().clickPoint(288, 2121, 300); + } else { + //华为 + AblService.getInstance().clickPoint(288, 1548, 300); + } + AblViewUtil.mySleep(2); + //复制文本粘贴在留言板 + AccessibilityNodeInfo findcomentt = findcoment(); + String conment = getConment(); + Log.e("TIAOSHI###", "获得的评论内容" + conment); + AblViewUtil.mySleep(1); + Log.e("TIAOSHI###", "获得的评论内容" + conment); + if (findcomentt != null) { + if (ChangLiang.phonetype.equals("0")) { + Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype); + //郝总的手机用第一个评论不上去 + // AblViewUtil.paste(findcomentt, conment);//红米7a + AblViewUtil.sayInput(conment, findcomentt); + } else { + Log.e("TIAOSHI###", "获得手机类型" + ChangLiang.phonetype); + AblViewUtil.sayInput(conment, findcomentt);//华为畅享20 + } + } + //发送 + AblViewUtil.mySleep(2); + AccessibilityNodeInfo findcomenttt = findcomentt(); + if (findcomenttt != null) { + AblService.getInstance().clickcommontwo(findcomenttt, "发送"); + AblViewUtil.mySleep(2); + } + //返回上级页面 + AblViewUtil.back(); + } + + /** + * 随机获取评论话术 + */ + private String getConment() { + CommentDao commentDao = new CommentDao(FuzhuApplication.getContext()); + List CommentBeanDatas = commentDao.queryInByCustom("type", "1"); + if (CommentBeanDatas.size() == 0) { + return "哈哈"; + } else if (CommentBeanDatas.size() == 1) { + CommentBeanData commentBeanData = CommentBeanDatas.get(0); + String comment = commentBeanData.getComment(); + return comment; + } else { + int i = new Random().nextInt(CommentBeanDatas.size() - 1); + CommentBeanData commentBeanData = CommentBeanDatas.get(i); + String comment = commentBeanData.getComment(); + return comment; + } + + } + + + private void addguanzhu() { + if (ChangLiang.phonetype.equals("0")) { + //红米7a + AblService.getInstance().clickPoint(659, 576, 300); + } else if ("3".equals(ChangLiang.phonetype)) { + //红米9a + AblService.getInstance().clickPoint(996, 1122, 300); + } else { + //华为畅享20 1.关注 [635,792][683,840] + AblService.getInstance().clickPoint(659, 816, 300); + } + Log.e("TIAOSHI###", "点击了添加关注按钮"); + int num = ChangLiang.guanzhunum; + Log.e("TIAOSHI###", "执行第" + num + "加关注"); + int num1 = num + 1; + ChangLiang.guanzhunum = num1; + } + + /** + * 点击评论 + * + * @param instance + */ + private void commentClick(AblService instance) { + if (ChangLiang.phonetype.equals("0")) { + instance.clickPoint(659, 810, 300);//红米7a + } else if ("3".equals(ChangLiang.phonetype)) { + //红米9a + AblService.getInstance().clickPoint(996, 1469, 300); + } else { + instance.clickPoint(659, 1066, 300);//华为畅享20 3.评论 [619,1026][699,1106] + } + Log.e("TIAOSHI###", "点击评论按钮"); + } + + /** + * 寻找留下你的精彩评论 + */ + private AccessibilityNodeInfo findcoment() { + AccessibilityNodeInfo infooos = null; + AccessibilityNodeInfo rootttt = AblService.getInstance().getRootInActiveWindow(); + for (int j = 0; j < rootttt.getChildCount(); j++) { + AccessibilityNodeInfo child = rootttt.getChild(j); + Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + if (!"dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + Log.e("TIAOSHI###ViewPager", "----2Node:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + Log.e("TIAOSHI###", "----2Node:" + child1.getClassName() + ":" + child1.getText()); + // if ("android.widget.LinearLayout".equals(child1.getClassName())) { + for (int x = 0; x < child1.getChildCount(); x++) { + AccessibilityNodeInfo child6 = child1.getChild(x); + Log.e("TIAOSHI###", "----3Node:" + child6.getClassName() + ":" + child6.getText()); + if ("android.widget.EditText".equals(child6.getClassName())) { + infooos = child1.getChild(x); + Log.e("TIAOSHI###", "----4Node:" + infooos.getClassName() + ":" + infooos.getText()); + } + } + } + } + } + return infooos; + } + + /** + * 寻找发送 + */ + private AccessibilityNodeInfo findcomentt() { + AccessibilityNodeInfo child3 = null; + ArrayList objects = new ArrayList<>(); + AccessibilityNodeInfo rootttt = AblService.getInstance().getRootInActiveWindow(); + for (int j = 0; j < rootttt.getChildCount(); j++) { + AccessibilityNodeInfo child = rootttt.getChild(j); + Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + if (!"dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + // Log.e("TIAOSHI###ViewPager", "----2Node:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child2 = child.getChild(y); + Log.e("TIAOSHI###", "----2Node:" + child2.getClassName() + ":" + child2.getText()); + + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child1 = child2.getChild(x); + Log.e("TIAOSHI###", "----3Node:" + child1.getClassName() + ":" + child1.getText()); + + if ("android.widget.ImageView".equals(child2.getChild(x).getClassName())) { + AccessibilityNodeInfo infooos = child2.getChild(x); + objects.add(infooos); + } + } + // Log.e("TIAOSHI###", "----4Node:" + objects.size()); + if (objects.size() > 0) { + child3 = objects.get(objects.size() - 1); + } + } + } + } + return child3; + } + + /** + * 获得取消关注 + */ + private String getquxiaoguanzhu() { + String quxiaoguanzhu = "1"; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.TextView".equals(child.getClassName())) { + CharSequence text = child.getText(); + if (text != null) { + if (text.toString().equals("已关注") || text.toString().equals("回关") || text.toString().equals("# 互相关注")) { + quxiaoguanzhu = "0"; + Log.e("TIAOSHI###", "----满足了状态:" + text.toString()); + } + } + } + } + return quxiaoguanzhu; + } + + + /** + * 获得关注数 + */ + private void getargone() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if (child1 != null) { + if (child1.getText() != null) { + if (child1.getText().equals("获赞")) { + AccessibilityNodeInfo parent = child1.getParent(); + AccessibilityNodeInfo child3 = parent.getChild(1); + if (child3.getText() != null) { + Log.e("TIAOSHI###", "获得的获赞数==" + child3.getText().toString()); + huozannum = child3.getText().toString(); + if (child3.getText().toString().equals("-")) { + Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); + } + } + } + if (child1.getText().equals("关注")) { + AccessibilityNodeInfo parent = child1.getParent(); + AccessibilityNodeInfo child3 = parent.getChild(1); + if (child3.getText() != null) { + Log.e("TIAOSHI###", "获得的关注数==" + child3.getText().toString()); + guanzhunum = child3.getText().toString(); + + if (child3.getText().toString().equals("-")) { + Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); + } + } + } + if (child1.getText().equals("粉丝")) { + AccessibilityNodeInfo parent = child1.getParent(); + AccessibilityNodeInfo child3 = parent.getChild(1); + if (child3.getText() != null) { + Log.e("TIAOSHI###", "获得的粉丝数==" + child3.getText().toString()); + fensinum = child3.getText().toString(); + if (child3.getText().toString().equals("-")) { + Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); + } + } + return; + } + } + } + } + } + } + + + /** + * 获得最近作品时间 + */ + private boolean getargfour() { + boolean flag = true; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + for (int j = 0; j < child.getChildCount(); j++) { + AccessibilityNodeInfo child1 = child.getChild(j); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText()); + for (int x = 0; x < child1.getChildCount(); x++) { + AccessibilityNodeInfo child2 = child1.getChild(x); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); + if (child2.getText() != null) { + String text = child2.getText().toString(); + if (text != null) { + boolean status = text.contains("作品"); + if (status) { + if (text.length() > 2) { + zuopinnum = child2.getText().toString().substring(3); + Log.e("TIAOSHI###", "获得的作品数==" + zuopinnum); + if (!zuopinnum.equals("-") && zuopinnum != null) { + if (Integer.parseInt(zuopinnum) < Integer.parseInt(userProfie.getMinimumzuopin()) || Integer.parseInt(zuopinnum) > Integer.parseInt(userProfie.getMaxmumzuopin())) { + Log.e("TIAOSHI###", "获取的该用户作品数" + Integer.parseInt(zuopinnum) + "小于设置的加关作品数(不在区间" + Integer.parseInt(userProfie.getMinimumzuopin()) + "-" + Integer.parseInt(userProfie.getMaxmumzuopin()) + "),作品数不满足条件"); + flag=false; + } else { + Log.e("TIAOSHI###", "获取的该用户作品数不小于设置的加关作品数,满足加关点赞评论条件"); + } + } + } + } + } + } + } + } + } + return flag; + } + + + + /** + * 直接上滑 + */ + private void zhijieshanghua() { + AccessibilityNodeInfo rootttt = AblService.getInstance().getRootInActiveWindow(); + if (rootttt != null) { + for (int j = 0; j < rootttt.getChildCount(); j++) { + AccessibilityNodeInfo child = rootttt.getChild(j); + // Log.e("TIAOSHI###", "----1Node:" + child.getClassName() + ":" + child.getText()); + //if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + // Log.e("TIAOSHI###ViewPager", "----2Node:" + child.getChildCount()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----2Node:" + child1.getClassName() + ":" + child1.getText()); + + for (int x = 0; x < child1.getChildCount(); x++) { + AccessibilityNodeInfo child6 = child1.getChild(x); + // Log.e("TIAOSHI###", "----3Node:" + child6.getClassName() + ":" + child6.getText()); + for (int z = 0; z < child6.getChildCount(); z++) { + AccessibilityNodeInfo child7 = child6.getChild(z); + // Log.e("TIAOSHI###", "----4Node:" + child7.getClassName() + ":" + child7.getText()); + for (int r = 0; r < child7.getChildCount(); r++) { + AccessibilityNodeInfo child2 = child7.getChild(r); + // Log.e("TIAOSHI###", "----5Node:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + + for (int m = 0; m < child2.getChildCount(); m++) { + AccessibilityNodeInfo child3 = child2.getChild(m); + // Log.e("TIAOSHI###", "----6Node:" + child3.getClassName() + ":" + child3.getText() + ":" + child3.getContentDescription()); + for (int p = 0; p < child3.getChildCount(); p++) { + AccessibilityNodeInfo child9 = child3.getChild(p); + // Log.e("TIAOSHI###", "----7Node:" + child9.getClassName() + ":" + child9.getText() + ":" + child9.getContentDescription()); + if (child9.getText() != null) { + if (child9.getText().toString().equals("查看详情")) { + //直接上滑 + Log.e("TIAOSHI###", "有查看详情的广告,直接滑动到下一个视频"); +// AblService.getInstance().randomSwipetwo(); +// AblViewUtil.mySleep(5); + AblStepHandler.sendMsg(AblSteps.STEP_31); + return; + } + } + } + + } + + } + } + } + + // } + } + } + } else { + Log.e("TIAOSHI###", "节点为null,直接滑动到下一个视频"); + AblStepHandler.sendMsg(AblSteps.STEP_31); + } + } + + + /** + * 抖音加粉托管账号每日数据统计 + * E/TIAOSHI###: 0取消关注 + * E/TIAOSHI###: 1猫眼看世界 + * E/TIAOSHI###: 2抖音号:dyhdfum81nqc + * E/TIAOSHI###: 3时光不居,天道酬勤~ + * E/TIAOSHI###: 449岁 + * E/TIAOSHI###: 5兰州 + * E/TIAOSHI###: 6猫眼看世界 + */ + private void fasStatistics(String short_id, String customer_name, String customer_shortid, String customer_remarks, String hz_num, String gz_num, String fs_num, String zp_num) { + + final HttpParams paramsPost = new HttpParams(); + paramsPost.put("short_id", short_id);//抖音号 + paramsPost.put("customer_name", customer_name);//昵称 + paramsPost.put("customer_shortid", customer_shortid);//抖音号 + paramsPost.put("customer_remarks", customer_remarks);//备注 + paramsPost.put("hz_num", hz_num);//获赞量 + paramsPost.put("gz_num", gz_num);//关注量 + paramsPost.put("fs_num", fs_num);//粉丝量 + paramsPost.put("zp_num", zp_num);//作品量 + + new NetApi().getPostData(paramsPost, HttpConstants.URi_device_Appoperate_getAtomBrushCus).subscribe(new com.fisherbone.fuzhu.okgonet.Observer() { + @Override + public void onNext(Response response) { + String body = (String) response.body(); + try { + JSONObject jsonObject = new JSONObject(body); + String msg = jsonObject.getString("msg"); + String success = jsonObject.getString("success"); + if (success.equals("0")) { + Log.e("TIAOSHI###", "获取到账号登录紧急任务,需要用户发送验证码或短信 -- 阿童木调取蜂狐接口==" + msg); + } + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Exception e) { + e.printStackTrace(); + } + }); + } + + + private void getUserInfo() { + int num = 0; + accessibilityNodeInfos = new ArrayList<>(); + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.TextView".equals(child.getClassName())) { + if (num < 7) { + accessibilityNodeInfos.add(child); + num = num + 1; + } + } + } + if (accessibilityNodeInfos.size() > 0) { + if (accessibilityNodeInfos.get(4).getText() != null) { + String customer_name = accessibilityNodeInfos.get(4).getText().toString(); + String str = accessibilityNodeInfos.get(5).getText().toString(); + String[] all = str.split(":"); + if (all.length > 1) { + String str3 = accessibilityNodeInfos.get(6).getText().toString(); + Log.e("TIAOSHI###ViewPager", "----twoNode:" + customer_name); + Log.e("TIAOSHI###ViewPager", "----twoNode:" + all[1]); + Log.e("TIAOSHI###ViewPager", "----twoNode:" + str3); + fasStatistics(ChangLiang.short_id, customer_name, all[1], str3, huozannum, guanzhunum, fensinum, zuopinnum); + } else { + String str3 = accessibilityNodeInfos.get(6).getText().toString(); + Log.e("TIAOSHI###ViewPager", "----twoNode:" + customer_name); + Log.e("TIAOSHI###ViewPager", "----twoNode:" + all[0]); + Log.e("TIAOSHI###ViewPager", "----twoNode:" + str3); + fasStatistics(ChangLiang.short_id, customer_name, all[0], str3, huozannum, guanzhunum, fensinum, zuopinnum); + } + } + } + } + + public boolean runTime() { + boolean ifruntime = false; + Long diff = DateUtils.diff(userProfie.getLivetimefir(), userProfie.getLivetime()); + Log.e("TIAOSHI###", "----当前的时间:" + userProfie.getLivetime()); + Log.e("TIAOSHI###", "----第一次的时间:" + userProfie.getLivetimefir()); + Log.e("TIAOSHI###", "----目前运行的时间:" + diff); + String runtime = Integer.parseInt(userProfie.getRunningtime()) +""; + Log.e("TIAOSHI###", "----总运行的时间:" + runtime + "小时"); + Long ltwo = Long.parseLong(runtime); + if (diff.longValue() >= ltwo.longValue() * 60 * 60 * 1000) { + ifruntime = true; + } + return ifruntime; + } + + public boolean runTimetwo(String end_time) { + boolean ifruntime = false; + Date date=new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + String dateString=end_time; + Date date2= null; + try { + date2 = sdf.parse(dateString); + } catch (ParseException e) { + e.printStackTrace(); + } + if(date.getTime() dateFormater = new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy-MM-dd"); + } + }; + // private final static ThreadLocal dateFormater = new ThreadLocal() { +// @Override +// protected SimpleDateFormat initialValue() { +// return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// } +// }; + private final static ThreadLocal dateFormater2 = new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy-MM-dd"); + } + }; + private static ThreadLocal DateLocal = new ThreadLocal(); + + /** + * 判断是否为今天(效率比较高) + * + * @param day 传入的 时间 "2016-06-28 10:10:30" "2016-06-28" 都可以 + * @return true今天 false不是 + * @throws ParseException + */ + public static boolean IsToday(String day) throws ParseException { + + Calendar pre = Calendar.getInstance(); + Date predate = new Date(System.currentTimeMillis()); + pre.setTime(predate); + + Calendar cal = Calendar.getInstance(); + Date date = getDateFormat().parse(day); + cal.setTime(date); + + if (cal.get(Calendar.YEAR) == (pre.get(Calendar.YEAR))) { + int diffDay = cal.get(Calendar.DAY_OF_YEAR) + - pre.get(Calendar.DAY_OF_YEAR); + + if (diffDay == 0) { + return true; + } + } + return false; + } + + /** + * 判断是否为昨天(效率比较高) + * + * @param day 传入的 时间 "2016-06-28 10:10:30" "2016-06-28" 都可以 + * @return true今天 false不是 + * @throws ParseException + */ + public static boolean IsYesterday(String day) throws ParseException { + + Calendar pre = Calendar.getInstance(); + Date predate = new Date(System.currentTimeMillis()); + pre.setTime(predate); + + Calendar cal = Calendar.getInstance(); + Date date = getDateFormat().parse(day); + cal.setTime(date); + + if (cal.get(Calendar.YEAR) == (pre.get(Calendar.YEAR))) { + int diffDay = cal.get(Calendar.DAY_OF_YEAR) + - pre.get(Calendar.DAY_OF_YEAR); + + if (diffDay == -1) { + return true; + } + } + return false; + } + + public static SimpleDateFormat getDateFormat() { + if (null == DateLocal.get()) { + DateLocal.set(new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA)); + } + return DateLocal.get(); + } + + /** + * 获取当前时间字符串 + * + * @return + */ + public static String getNowString() { + return dateFormat(new Date()); + } + + public static String getNowStringtwo() { + return dateFormattwo(new Date()); + } + + /** + * 从时间格式化字符串 + * 默认格式为:yyyy-MM-dd HH:mm:ss + * + * @param date + * @return + */ + public static String dateFormat(Date date) { + return dateFormat(date, DATE_LONG); + } + + public static String dateFormattwo(Date date) { + return dateFormat(date, DATE_NORMAL); + } + + + /** + * @title: dateCompare + * @description: 比较日期大小 + * @return + */ +// public static int dateCompare(String dateFirst, String dateLast) { +// int dateFirstIntVal = Integer.parseInt(dateFirst); +// int dateLastIntVal = Integer.parseInt(dateLast); +// if (dateFirstIntVal > dateLastIntVal) { +// return 1; +// } else if (dateFirstIntVal < dateLastIntVal) { +// return -1; +// } +// return 0; +// } + + /** + * @param date1 日期1 + * @param date2 日期2 + * @return + * @title: dateCompare + * @description: 比较日期大小 + */ + public static int dateCompare(String String1, String String2) { + // SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + + Date date1 = dateFormat.parse(String1); + Date date2 = dateFormat.parse(String2); + String dateFirst = dateFormat.format(date1); + String dateLast = dateFormat.format(date2); + int dateFirstIntVal = Integer.parseInt(dateFirst); + int dateLastIntVal = Integer.parseInt(dateLast); + if (dateFirstIntVal > dateLastIntVal) { + return 1; + } else if (dateFirstIntVal < dateLastIntVal) { + return -1; + } + } catch (ParseException e) { + e.printStackTrace(); + } + + return 0; + } + + + /** + * 从时间格式化字符串 + * + * @param date + * @param format + * @return + */ + public static String dateFormat(Date date, String format) { + if (date == null) { + date = new Date(); + } + if (format == null || format.equals("")) { + format = DATE_LONG; + } + SimpleDateFormat sdf = new SimpleDateFormat(format); + return sdf.format(date); + } + + /** + * 从字符串格式化时间 + * + * @param dateStr + * @param format + * @return + */ + public static Date dateFromString(String dateStr, String format) { + if (!dateStr.equals("") && !format.equals("")) { + DateFormat sdf = new SimpleDateFormat(format); + try { + return sdf.parse(dateStr); + } catch (ParseException e) { + e.printStackTrace(); + } + } + return null; + } + + /** + * 增加时间数 + * + * @param date + * @param field + * @param interval + * @return + */ + public static Date addOnField(Date date, int field, int interval) { + Calendar ca = Calendar.getInstance(); + ca.setTime(date); + ca.add(field, interval); + return ca.getTime(); + } + + /** + * 获取某个块 + * + * @param date + * @param field + * @return + */ + public static int getFieldOfDate(Date date, int field) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + return calendar.get(field); + } + + public static String formatDataTime(long date) { + return DATE_FORMAT_DATETIME.format(new Date(date)); + } + + public static String formatDate(long date) { + return DATE_FORMAT_DATE.format(new Date(date)); + } + + public static String formatTime(long date) { + return DATE_FORMAT_TIME.format(new Date(date)); + } + + public static String formatDateCustom(String beginDate, String format) { + return new SimpleDateFormat(format).format(new Date(Long.parseLong(beginDate))); + } + + public static String formatDateCustom(Date beginDate, String format) { + return new SimpleDateFormat(format).format(beginDate); + } + + public static Date string2Date(String s, String style) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(); + simpleDateFormat.applyPattern(style); + Date date = null; + if (s == null || s.length() < 6) { + return null; + } + try { + date = simpleDateFormat.parse(s); + } catch (ParseException e) { + e.printStackTrace(); + } + return date; + } + + public static String getTime() { + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(System.currentTimeMillis()); + return cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ":" + cal.get(Calendar.SECOND); + } + + /** + * 获得当前日期 + * + * @return + */ + public static String getDate() { + return DATE_FORMAT_DATE.format(System.currentTimeMillis()); + } + + /** + * 获取月末日期 + * + * @return + */ + public static String getLastDayOfMonth() { + Calendar cale = null; + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + String lastday; + cale = Calendar.getInstance(); + cale.add(Calendar.MONTH, 1); + cale.set(Calendar.DAY_OF_MONTH, 0); + lastday = format.format(cale.getTime()); + return lastday; + } + + + public static String getDateTime() { + return DATE_FORMAT_DATETIME.format(System.currentTimeMillis()); + } + + public static String getDateTime(String format) { + return new SimpleDateFormat(format).format(System.currentTimeMillis()); + } + + public static long subtractDate(Date dateStart, Date dateEnd) { + return dateEnd.getTime() - dateStart.getTime(); + } + + public static Date getDateAfter(Date d, int day) { + Calendar now = Calendar.getInstance(); + now.setTime(d); + now.set(Calendar.DATE, now.get(Calendar.DATE) + day); + return now.getTime(); + } + + public static int getWeekOfMonth() { + Calendar calendar = Calendar.getInstance(); + int week = calendar.get(Calendar.WEEK_OF_MONTH); + return week - 1; + } + + public static int getDayOfWeek() { + Calendar calendar = Calendar.getInstance(); + int day = calendar.get(Calendar.DAY_OF_WEEK); + if (day == 1) { + day = 7; + } else { + day = day - 1; + } + return day; + } + + public static String getNextDay() { + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_MONTH, 1); + String nextDay = sf.format(calendar.getTime()); + return nextDay; + } + + public static String gettimenow() { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA); + String now = sdf.format(new Date()); + return now; + } + + public static String gettime() { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");// HH:mm:ss + Date date = new Date(System.currentTimeMillis()); + String format = simpleDateFormat.format(date); + Log.d(TAG, "当前的系统时间==" + format); + return format; + } + + private static String gettimethtee() { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");// HH:mm:ss + Date date = new Date(System.currentTimeMillis()); + String format = simpleDateFormat.format(date); + return format; + } + + public static String gettimetwo() { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日");// HH:mm:ss + Date date = new Date(System.currentTimeMillis()); + String format = simpleDateFormat.format(date); + Log.d(TAG, "当前的系统时间(年月日格式)==" + format); + return format; + } + + public static String gettimethree() { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月");// HH:mm:ss + Date date = new Date(System.currentTimeMillis()); + String format = simpleDateFormat.format(date); + Log.d(TAG, "当前的系统时间(年月格式)==" + format); + return format; + } + + + /** + * 判断时间是不是今天 + * + * @param date + * @return 是返回true,不是返回false + */ + public static boolean isNow(Date date) { + //当前时间 + Date now = new Date(); + SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd"); + //获取今天的日期 + String nowDay = sf.format(now); + //对比的时间 + String day = sf.format(date); + return day.equals(nowDay); + } + + + /** + * 获取明天的时间 + * + * @return + */ + public static String getTomorrowTime() { + //获取当前时间 + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); + Calendar c = Calendar.getInstance(); + // System.out.println("当前日期:"+sf.format(c.getTime())); + c.add(Calendar.DAY_OF_MONTH, 1); + // System.out.println("增加一天后日期:"+sf.format(c.getTime())); + return sf.format(c.getTime()); + } + + /** + * 返回时间差 + * + * @return + */ + public static Long diff(String starttime, String endtime) { + long minutes = 0; + try { + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date startTime = df.parse(starttime); + Date endTime = df.parse(endtime); + minutes = endTime.getTime() - startTime.getTime(); + } catch (Exception e) { + } + return minutes; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/DateUtilss.java b/app/src/main/java/com/fisherbone/fuzhu/utils/DateUtilss.java new file mode 100644 index 0000000..635c611 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/DateUtilss.java @@ -0,0 +1,594 @@ +/* + * Copyright (C) 2016 android@19code.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.utils; + +import android.util.Log; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; + +/** + * Create by h4de5ing 2016/5/7 007 + * 日期工具类 + * + */ +public class DateUtilss { + private static final String TAG = "InviteMessageFragment"; + private static final SimpleDateFormat DATE_FORMAT_DATETIME = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + private static final SimpleDateFormat DATE_FORMAT_DATE = new SimpleDateFormat("yyyy-MM-dd"); + private static final SimpleDateFormat DATE_FORMAT_TIME = new SimpleDateFormat("HH:mm:ss"); + /** + * 日期格式:yyyy-MM-dd HH:mm:ss + */ + public static final String DATE_LONG = "yyyy-MM-dd HH:mm:ss"; + /** + * 日期格式:yyyy-MM-dd + */ + public static final String DATE_SHORT = "yyyy-MM-dd"; + /** + * 日期格式:yyyy-MM + */ + public static final String MONTH_SHORT = "yyyy-MM"; + /** + * 日期格式 yyyyMMdd + */ + public static final String DATE_NORMAL = "yyyyMMdd"; + + /** + * 将字符串转位日期类型 + * + * @param sdate + * @return + */ + public static Date toDate(String sdate) { + try { + return dateFormater.get().parse(sdate); + } catch (ParseException e) { + return null; + } + } + + private final static ThreadLocal dateFormater = new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy-MM-dd"); + } + }; +// private final static ThreadLocal dateFormater = new ThreadLocal() { +// @Override +// protected SimpleDateFormat initialValue() { +// return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// } +// }; + private final static ThreadLocal dateFormater2 = new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy-MM-dd"); + } + }; + private static ThreadLocal DateLocal = new ThreadLocal(); + + /** + * 判断是否为今天(效率比较高) + * + * @param day 传入的 时间 "2016-06-28 10:10:30" "2016-06-28" 都可以 + * @return true今天 false不是 + * @throws ParseException + */ + public static boolean IsToday(String day) throws ParseException { + + Calendar pre = Calendar.getInstance(); + Date predate = new Date(System.currentTimeMillis()); + pre.setTime(predate); + + Calendar cal = Calendar.getInstance(); + Date date = getDateFormat().parse(day); + cal.setTime(date); + + if (cal.get(Calendar.YEAR) == (pre.get(Calendar.YEAR))) { + int diffDay = cal.get(Calendar.DAY_OF_YEAR) + - pre.get(Calendar.DAY_OF_YEAR); + + if (diffDay == 0) { + return true; + } + } + return false; + } + + /** + * 判断是否为昨天(效率比较高) + * + * @param day 传入的 时间 "2016-06-28 10:10:30" "2016-06-28" 都可以 + * @return true今天 false不是 + * @throws ParseException + */ + public static boolean IsYesterday(String day) throws ParseException { + + Calendar pre = Calendar.getInstance(); + Date predate = new Date(System.currentTimeMillis()); + pre.setTime(predate); + + Calendar cal = Calendar.getInstance(); + Date date = getDateFormat().parse(day); + cal.setTime(date); + + if (cal.get(Calendar.YEAR) == (pre.get(Calendar.YEAR))) { + int diffDay = cal.get(Calendar.DAY_OF_YEAR) + - pre.get(Calendar.DAY_OF_YEAR); + + if (diffDay == -1) { + return true; + } + } + return false; + } + + public static SimpleDateFormat getDateFormat() { + if (null == DateLocal.get()) { + DateLocal.set(new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA)); + } + return DateLocal.get(); + } + + /** + * 获取当前时间字符串 + * + * @return + */ + public static String getNowString() { + return dateFormat(new Date()); + } + + public static Date getNowDate() { + return new Date(); + } + + /** + * 获取精确到秒的时间戳 + * @param date + * @return + */ + public static int getSecondTimestampTwo(Date date){ + if (null == date) { + return 0; + } + String timestamp = String.valueOf(date.getTime()/1000); + return Integer.valueOf(timestamp); + } + + + /** + * @description 获取两个时间相差多少秒 + * @param + * @return + */ + public static int calLastedTime(Date startDate) { + long a = new Date().getTime(); + long b = startDate.getTime(); + int c = (int)((b - a) / 1000); + return c; + } + + /** + * Java Date与String的相互转换 + */ + + public static Date stringToDate(String time) { + DateFormat format = new SimpleDateFormat("yyyy-MM-dd");//日期格式 + Date date = null; + try { + date = format.parse(time); + } catch (ParseException e) { + e.printStackTrace(); + } + return date; + } + + + /** + * JDate转为String + */ + + public static String dateToString(Date date) { + SimpleDateFormat sformat = new SimpleDateFormat("yyyy-MM-dd");//日期格式 + String tiem = sformat.format(date); + + return tiem; + } + + + + /** + * 从时间格式化字符串 + * 默认格式为:yyyy-MM-dd HH:mm:ss + * + * @param date + * @return + */ + public static String dateFormat(Date date) { + return dateFormat(date, DATE_LONG); + } + + /** + * 从时间格式化字符串 + * + * @param date + * @param format + * @return + */ + public static String dateFormat(Date date, String format) { + if (date == null) { + date = new Date(); + } + if (format == null || format.equals("")) { + format = DATE_LONG; + } + SimpleDateFormat sdf = new SimpleDateFormat(format); + return sdf.format(date); + } + + /** + * 从字符串格式化时间 + * + * @param dateStr + * @param format + * @return + */ + public static Date dateFromString(String dateStr, String format) { + if (!dateStr.equals("") && !format.equals("")) { + DateFormat sdf = new SimpleDateFormat(format); + try { + return sdf.parse(dateStr); + } catch (ParseException e) { + e.printStackTrace(); + } + } + return null; + } + + /** + * 增加时间数 + * + * @param date + * @param field + * @param interval + * @return + */ + public static Date addOnField(Date date, int field, int interval) { + Calendar ca = Calendar.getInstance(); + ca.setTime(date); + ca.add(field, interval); + return ca.getTime(); + } + + /** + * 获取某个块 + * + * @param date + * @param field + * @return + */ + public static int getFieldOfDate(Date date, int field) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + return calendar.get(field); + } + + public static String formatDataTime(long date) { + return DATE_FORMAT_DATETIME.format(new Date(date)); + } + + public static String formatDate(long date) { + return DATE_FORMAT_DATE.format(new Date(date)); + } + + public static String formatTime(long date) { + return DATE_FORMAT_TIME.format(new Date(date)); + } + + public static String formatDateCustom(String beginDate, String format) { + return new SimpleDateFormat(format).format(new Date(Long.parseLong(beginDate))); + } + + public static String formatDateCustom(Date beginDate, String format) { + return new SimpleDateFormat(format).format(beginDate); + } + + public static Date string2Date(String s, String style) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(); + simpleDateFormat.applyPattern(style); + Date date = null; + if (s == null || s.length() < 6) { + return null; + } + try { + date = simpleDateFormat.parse(s); + } catch (ParseException e) { + e.printStackTrace(); + } + return date; + } + + public static String getTime() { + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(System.currentTimeMillis()); + return cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE) + ":" + cal.get(Calendar.SECOND); + } + + /** + * 获得当前日期 + * @return + */ + public static String getDate() { + return DATE_FORMAT_DATE.format(System.currentTimeMillis()); + } + + /** + *获取月末日期 + * @return + */ + public static String getLastDayOfMonth() { + Calendar cale = null; + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + String lastday; + cale = Calendar.getInstance(); + cale.add(Calendar.MONTH, 1); + cale.set(Calendar.DAY_OF_MONTH, 0); + lastday = format.format(cale.getTime()); + return lastday; + } + + + public static String getDateTime(){ + return DATE_FORMAT_DATETIME.format(System.currentTimeMillis()); + } + public static String getDateTime(String format){ + return new SimpleDateFormat(format).format(System.currentTimeMillis()); + } + + public static long subtractDate(Date dateStart, Date dateEnd) { + return dateEnd.getTime() - dateStart.getTime(); + } + + public static Date getDateAfter(Date d, int day) { + Calendar now = Calendar.getInstance(); + now.setTime(d); + now.set(Calendar.DATE, now.get(Calendar.DATE) + day); + return now.getTime(); + } + + public static int getWeekOfMonth() { + Calendar calendar = Calendar.getInstance(); + int week = calendar.get(Calendar.WEEK_OF_MONTH); + return week - 1; + } + + public static int getDayOfWeek() { + Calendar calendar = Calendar.getInstance(); + int day = calendar.get(Calendar.DAY_OF_WEEK); + if (day == 1) { + day = 7; + } else { + day = day - 1; + } + return day; + } + + public static String getNextDay(){ + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_MONTH,1); + String nextDay = sf.format(calendar.getTime()); + return nextDay; + } + public static String gettimenow() { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA); + String now = sdf.format(new Date()); + return now; + } + + public static String gettime() { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");// HH:mm:ss + Date date = new Date(System.currentTimeMillis()); + String format = simpleDateFormat.format(date); + Log.d(TAG, "当前的系统时间==" + format); + return format; + } + private static String gettimethtee() { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");// HH:mm:ss + Date date = new Date(System.currentTimeMillis()); + String format = simpleDateFormat.format(date); + return format; + } + public static String gettimetwo() { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日");// HH:mm:ss + Date date = new Date(System.currentTimeMillis()); + String format = simpleDateFormat.format(date); + Log.d(TAG, "当前的系统时间(年月日格式)==" + format); + return format; + } + + public static String gettimethree() { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月");// HH:mm:ss + Date date = new Date(System.currentTimeMillis()); + String format = simpleDateFormat.format(date); + Log.d(TAG, "当前的系统时间(年月格式)==" + format); + return format; + } + + + + + /** + * 判断时间是不是今天 + * @param date + * @return 是返回true,不是返回false + */ + public static boolean isNow(Date date) { + //当前时间 + Date now = new Date(); + SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd"); + //获取今天的日期 + String nowDay = sf.format(now); + //对比的时间 + String day = sf.format(date); + return day.equals(nowDay); + } + + + /** + * 获取明天的时间 + * + * @return + */ + public static String getTomorrowTime() { + //获取当前时间 + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); + Calendar c = Calendar.getInstance(); + // System.out.println("当前日期:"+sf.format(c.getTime())); + c.add(Calendar.DAY_OF_MONTH, 1); + // System.out.println("增加一天后日期:"+sf.format(c.getTime())); + return sf.format(c.getTime()); + } + + + + + /** + * 将秒数转换为基于00:00的时间 + * 如541=9*60+1,表示09:01 + * @param minutes + * @return + */ + public static String getTimeByMinutes(int minutes){ + //处理小时 + int hour = minutes / 60; + String hourTime = ""; + if(hour >= 0 && hour < 10){ + hourTime = "0" + hour;// 1 --> 01 + }else if(hour >= 10 && hour < 24){ + hourTime = "" + hour; + }else if(hour >= 24){ + hourTime = "0" + (hour-24); + } + //处理分钟 + int min = minutes % 60; + String minTime = ""; + if(min >= 0 && min < 10){ + minTime = "0" + min;// 1 --> 01 + }else{ + minTime = "" + min; + } + + return hourTime + ":" + minTime; + } + + + /** + * 秒钟转换成这种格式的时间00:00:10 + * @param time + * @return + */ + public static String secToTime(int time) { + + String timeStr = null; + int hour = time / 3600; + int minute = time / 60 % 60; + int second = time % 60; + timeStr = unitFormat(hour) + ":" + unitFormat(minute) + ":" + unitFormat(second); + return timeStr; + } + public static String unitFormat(int i) { + String retStr = null; + if (i >= 0 && i < 10) + retStr = "0" + Integer.toString(i); + else + retStr = "" + i; + return retStr; + } + + /** + * 00:00:10 这种格式的时间转化成秒钟 + * @param time + * @return + */ + public static int timeToSec(String time){ + String[] timeArray = time.split(":"); + int hour = Integer.parseInt(timeArray[0])*3600; + int min = Integer.parseInt(timeArray[1])*60; + int sec = Integer.parseInt(timeArray[2]); + return hour+min+sec; + } + + + + + /** + * 毫秒换算 + * 将毫秒换算成天、时、分、秒 + * + */ + + public static String formatDuring(long mss) { + + long days = mss / (1000 * 60 * 60 * 24); + + long hours = (mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60); + + long minutes = (mss % (1000 * 60 * 60)) / (1000 * 60); + + long seconds = (mss % (1000 * 60)) / 1000; + +// return days + "天" + hours + "时" + minutes + "分" +// + seconds + "秒 "; + return days + "天" + hours + ":" + minutes + ":" + + seconds + " "; + + } + + public static java.sql.Date getBeforeAfterDate(String datestr, int day) { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + java.sql.Date olddate = null; + try { + df.setLenient(false); + olddate = new java.sql.Date(df.parse(datestr).getTime()); + } catch (ParseException e) { + throw new RuntimeException("日期转换错误"); + } + Calendar cal = new GregorianCalendar(); + cal.setTime(olddate); + + int Year = cal.get(Calendar.YEAR); + int Month = cal.get(Calendar.MONTH); + int Day = cal.get(Calendar.DAY_OF_MONTH); + + int NewDay = Day + day; + + cal.set(Calendar.YEAR, Year); + cal.set(Calendar.MONTH, Month); + cal.set(Calendar.DAY_OF_MONTH, NewDay); + + return new java.sql.Date(cal.getTimeInMillis()); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/DeviceUtils.java b/app/src/main/java/com/fisherbone/fuzhu/utils/DeviceUtils.java new file mode 100644 index 0000000..59dff6a --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/DeviceUtils.java @@ -0,0 +1,147 @@ +package com.fisherbone.fuzhu.utils; + +import android.Manifest; +import android.content.Context; +import android.content.pm.PackageManager; +import android.os.Build; +import android.os.Environment; +import android.provider.Settings; +import android.telephony.TelephonyManager; +import android.util.Log; + +import androidx.core.app.ActivityCompat; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Date; +import java.util.UUID; + +public class DeviceUtils { + private static final String UUID_FILE_NAME = "android10biaoshi"; + private static final String TODO = null; + public static String getUniqueId(Context context){ + String androidID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); + Log.e("设备号加密前为:",androidID);//红米7==b5b6d728393424b8 小米8==48d70d2f60d2ac2b + // String id = androidID + Build.SERIAL; + String id = androidID; + try { + return toMD5(id); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + return id; + } + } + + + public static String toMD5(String text) throws NoSuchAlgorithmException { + //获取摘要器 MessageDigest + MessageDigest messageDigest = MessageDigest.getInstance("MD5"); + //通过摘要器对字符串的二进制字节数组进行hash计算 + byte[] digest = messageDigest.digest(text.getBytes()); + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < digest.length; i++) { + //循环每个字符 将计算结果转化为正整数; + int digestInt = digest[i] & 0xff; + //将10进制转化为较短的16进制 + String hexString = Integer.toHexString(digestInt); + //转化结果如果是个位数会省略0,因此判断并补0 + if (hexString.length() < 2) { + sb.append(0); + } + //将循环结果添加到缓冲区 + sb.append(hexString); + } + //返回整个结果 + return sb.toString(); + } + + + /** + * 适配安卓10(Q)(API29)及以上 + * + * @return + */ + public static String getIMEI(Context context) { + if (Build.VERSION.SDK_INT >= 29) { + String UUIDStr = readSD(); + if (UUIDStr == null || UUIDStr.isEmpty()) {//如果为空或者空字符串就生成UUID创建文件并写入UUID + String uuid = new Date().getTime() + "_AndroidQ_" + UUID.randomUUID().toString(); + + String s = writeSD(uuid); + return s; + } else { + return UUIDStr; + } + } else { + TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE); + if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { + + return TODO; + } + String imei = telephonyManager.getDeviceId(); + + return imei; + } + } + + /** + * 保存文件到SD卡(写入SD卡需要权限,在AndroidManifest.xml中设置android.permission.WRITE_EXTERNAL_STORAGE) + */ + public static String writeSD(String content) { + //文件输出流 + FileOutputStream out = null; + //设置文件路径 + File file = new File(Environment.getExternalStorageDirectory(), UUID_FILE_NAME); + try { + out = new FileOutputStream(file); + out.write(content.getBytes()); + return content; + } catch (Exception e) { + e.printStackTrace(); + return ""; + } finally { + try { + if (out != null) { + out.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + /** + * 从SD卡中读取文件(读取SD卡需要权限,在AndroidManifest.xml中设置android.permission.READ_EXTERNAL_STORAGE) + */ + public static String readSD() { + //文件输入流 + FileInputStream in = null; + //设置文件路径 + File file = new File(Environment.getExternalStorageDirectory(), UUID_FILE_NAME); + try { + in = new FileInputStream(file); + //使用缓冲来读 + byte[] buf = new byte[1024];//每1024字节读一次 + StringBuilder builder = new StringBuilder(); + while (in.read(buf) != -1) { + builder.append(new String(buf).trim()); + } + return builder.toString(); + } catch (Exception e) { + e.printStackTrace(); + return ""; + } finally { + try { + if (in != null) { + in.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/EmojiFilter.java b/app/src/main/java/com/fisherbone/fuzhu/utils/EmojiFilter.java new file mode 100644 index 0000000..f46b039 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/EmojiFilter.java @@ -0,0 +1,79 @@ +package com.fisherbone.fuzhu.utils; + +public class EmojiFilter { + + /** + * 检测是否有emoji字符 + * @param source + * @return FALSE,包含图片 + */ + public static boolean containsEmoji(String source) { + if (source.equals("")) { + return false; + } + + int len = source.length(); + + for (int i = 0; i < len; i++) { + char codePoint = source.charAt(i); + + if (isEmojiCharacter(codePoint)) { + //do nothing,判断到了这里表明,确认有表情字符 + return true; + } + } + + return false; + } + + private static boolean isEmojiCharacter(char codePoint) { + return (codePoint == 0x0) || + (codePoint == 0x9) || + (codePoint == 0xA) || + (codePoint == 0xD) || + ((codePoint >= 0x20) && (codePoint <= 0xD7FF)) || + ((codePoint >= 0xE000) && (codePoint <= 0xFFFD)) || + ((codePoint >= 0x10000) && (codePoint <= 0x10FFFF)); + } + + /** + * 过滤emoji 或者 其他非文字类型的字符 + * @param source + * @return + */ + public static String filterEmoji(String source) { + + if (!containsEmoji(source)) { + return source;//如果不包含,直接返回 + } + //到这里铁定包含 + StringBuilder buf = null; + + int len = source.length(); + + for (int i = 0; i < len; i++) { + char codePoint = source.charAt(i); + + if (isEmojiCharacter(codePoint)) { + if (buf == null) { + buf = new StringBuilder(source.length()); + } + + buf.append(codePoint); + } else { + } + } + + if (buf == null) { + return source;//如果没有找到 emoji表情,则返回源字符串 + } else { + if (buf.length() == len) {//这里的意义在于尽可能少的toString,因为会重新生成字符串 + buf = null; + return source; + } else { + return buf.toString(); + } + } + + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/GetJsonDataUtil.java b/app/src/main/java/com/fisherbone/fuzhu/utils/GetJsonDataUtil.java new file mode 100644 index 0000000..96f12df --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/GetJsonDataUtil.java @@ -0,0 +1,38 @@ +package com.fisherbone.fuzhu.utils; + +import android.content.Context; +import android.content.res.AssetManager; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +/** + * <读取Json文件的工具类> + * + * @author: 小嵩 + * @date: 2017/3/16 16:22 + + */ + +public class GetJsonDataUtil { + + + public String getJson(Context context,String fileName) { + + StringBuilder stringBuilder = new StringBuilder(); + try { + AssetManager assetManager = context.getAssets(); + BufferedReader bf = new BufferedReader(new InputStreamReader( + assetManager.open(fileName))); + String line; + while ((line = bf.readLine()) != null) { + stringBuilder.append(line); + } + } catch (IOException e) { + e.printStackTrace(); + } + return stringBuilder.toString(); + } +} + diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/JsonUtils.java b/app/src/main/java/com/fisherbone/fuzhu/utils/JsonUtils.java new file mode 100644 index 0000000..d1ad07b --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/JsonUtils.java @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2016 android@19code.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.utils; + +import com.google.gson.Gson; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.JSONTokener; + +import java.lang.reflect.Array; +import java.util.Collection; +import java.util.Map; + +/** + * Json工具类 + * + * Create by h4de5ing 2016/5/7 007 + */ +public class JsonUtils { + public static String toJson(Object obj) { + Gson gson = new Gson(); + return gson.toJson(obj); + } + + public static T fromJson(String str, Class type) { + Gson gson = new Gson(); + return gson.fromJson(str, type); + } + + public static JSONObject map2Json(Map data) { + JSONObject object = new JSONObject(); + + for (Map.Entry entry : data.entrySet()) { + String key = (String) entry.getKey(); + if (key == null) { + throw new NullPointerException("key == null"); + } + try { + object.put(key, wrap(entry.getValue())); + } catch (JSONException e) { + e.printStackTrace(); + } + } + + return object; + } + + public static JSONArray collection2Json(Collection data) { + JSONArray jsonArray = new JSONArray(); + if (data != null) { + for (Object aData : data) { + jsonArray.put(wrap(aData)); + } + } + return jsonArray; + } + + public static JSONArray object2Json(Object data) throws JSONException { + if (!data.getClass().isArray()) { + throw new JSONException("Not a primitive data: " + data.getClass()); + } + final int length = Array.getLength(data); + JSONArray jsonArray = new JSONArray(); + for (int i = 0; i < length; ++i) { + jsonArray.put(wrap(Array.get(data, i))); + } + + return jsonArray; + } + + private static Object wrap(Object o) { + if (o == null) { + return null; + } + if (o instanceof JSONArray || o instanceof JSONObject) { + return o; + } + try { + if (o instanceof Collection) { + return collection2Json((Collection) o); + } else if (o.getClass().isArray()) { + return object2Json(o); + } + if (o instanceof Map) { + return map2Json((Map) o); + } + + if (o instanceof Boolean || o instanceof Byte || o instanceof Character || o instanceof Double || o instanceof Float || o instanceof Integer || o instanceof Long + || o instanceof Short || o instanceof String) { + return o; + } + if (o.getClass().getPackage().getName().startsWith("java.")) { + return o.toString(); + } + } catch (Exception ignored) { + } + return null; + } + + public static JSONObject string2JSONObject(String json) { + JSONObject jsonObject = null; + try { + JSONTokener jsonParser = new JSONTokener(json); + jsonObject = (JSONObject) jsonParser.nextValue(); + } catch (Exception e) { + e.printStackTrace(); + } + return jsonObject; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/JumpUtils.java b/app/src/main/java/com/fisherbone/fuzhu/utils/JumpUtils.java new file mode 100644 index 0000000..f4d7c40 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/JumpUtils.java @@ -0,0 +1,89 @@ +package com.fisherbone.fuzhu.utils; + +import android.app.Activity; +import android.content.Intent; + +import java.io.Serializable; + +public class JumpUtils { + + + /** + * activity跳转 + * + * @param poFrom + * @param poTo + * @param pbFinish + * 是否关闭poFrom + * @param lsKey + * 参数key + * @param pmExtra + * 参数 Value Serializable + */ + public static void gotoActivity(Activity poFrom, Class poTo, + boolean pbFinish, String lsKey, Object pmExtra) { + Intent loIntent = new Intent(poFrom, poTo); + if (pmExtra != null) { + loIntent.putExtra(lsKey, (Serializable) pmExtra); + } + poFrom.startActivity(loIntent); + + if (pbFinish) { + poFrom.finish(); + } + } + + + /** + * activity跳转 + * + * @param poFrom + * @param poTo + * @param pbFinish + * 是否关闭poFrom + * @param requestCode + * @param lsKey + * 参数key + * @param pmExtra + * 参数 Value Serializable + */ + + public static void gotoForResultActivity(Activity poFrom, Class poTo, + boolean pbFinish, int requestCode, String lsKey, Object pmExtra) { + Intent loIntent = new Intent(poFrom, poTo); + if (pmExtra != null) { + loIntent.putExtra(lsKey, (Serializable) pmExtra); + } + poFrom.startActivityForResult(loIntent, requestCode); + + if (pbFinish) { + poFrom.finish(); + } + } + + /** + * activity跳转 + * + * @param poFrom + * @param poTo + * @param pbFinish + * 是否关闭poFrom + * @param requestCode + * @param lsKey + * 参数key + * @param pmExtra + * 参数 Value Serializable + */ + public static void gotoResultActivity(Activity poFrom, Class poTo, + boolean pbFinish, int requestCode, String lsKey, Object pmExtra) { + Intent loIntent = new Intent(poFrom, poTo); + if (pmExtra != null) { + loIntent.putExtra(lsKey, (Serializable) pmExtra); + } + if (pbFinish) + poFrom.finish(); + poFrom.setResult(requestCode, loIntent); + poFrom.finish(); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/MyLogger.java b/app/src/main/java/com/fisherbone/fuzhu/utils/MyLogger.java new file mode 100644 index 0000000..39904a3 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/MyLogger.java @@ -0,0 +1,45 @@ +package com.fisherbone.fuzhu.utils; + +import android.util.Log; + +/** + * 日志工具类 + * + * @author apple + */ +public final class MyLogger { + + //开关 + private final static boolean flag = true;//true 测试 false 上线 + + public static void v(String tag, String msg) { + if (flag) { + Log.v(tag, msg); + } + } + + public static void d(String tag, String msg) { + if (flag) { + Log.d(tag, msg); + } + } + + public static void i(String tag, String msg) { + if (flag) { + Log.i(tag, msg); + } + } + + public static void w(String tag, String msg) { + if (flag) { + Log.w(tag, msg); + } + } + + public static void e(String tag, String msg) { + if (flag) { + Log.e(tag, msg); + } + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/MyToast.java b/app/src/main/java/com/fisherbone/fuzhu/utils/MyToast.java new file mode 100644 index 0000000..1b7b1ac --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/MyToast.java @@ -0,0 +1,20 @@ +package com.fisherbone.fuzhu.utils; + +import android.content.Context; +import android.widget.Toast; + +/** + * Created by Apple on 2016/9/26. + * 吐司的工具类 + */ +public final class MyToast { + + public static void show(Context context, String msg) { + Toast.makeText(context, msg, Toast.LENGTH_SHORT).show(); + } + public static void show(Context context, String msg,Boolean b) { + if(b){ + Toast.makeText(context, msg, Toast.LENGTH_SHORT).show(); + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/NetUtils.java b/app/src/main/java/com/fisherbone/fuzhu/utils/NetUtils.java new file mode 100644 index 0000000..e8b0730 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/NetUtils.java @@ -0,0 +1,224 @@ +/* + * Copyright (C) 2016 android@19code.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.utils; + +import android.app.Activity; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.net.wifi.ScanResult; +import android.net.wifi.WifiInfo; +import android.net.wifi.WifiManager; +import android.telephony.TelephonyManager; +import android.text.TextUtils; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.List; + +/** + * Blog : http://blog.csdn.net/u011240877 + * 网络工具 + * + */ +public class NetUtils { + + public static final String NETWORK_TYPE_WIFI = "wifi"; + public static final String NETWORK_TYPE_3G = "3g"; + public static final String NETWORK_TYPE_2G = "2g"; + public static final String NETWORK_TYPE_WAP = "wap"; + public static final String NETWORK_TYPE_UNKNOWN = "unknown"; + public static final String NETWORK_TYPE_DISCONNECT = "disconnect"; + + public static int getNetworkType(Context context) { + ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo networkInfo = connectivityManager == null ? null : connectivityManager.getActiveNetworkInfo(); + return networkInfo == null ? -1 : networkInfo.getType(); + } + + public static String getNetworkTypeName(Context context) { + ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo networkInfo; + String type = NETWORK_TYPE_DISCONNECT; + if (manager == null || (networkInfo = manager.getActiveNetworkInfo()) == null) { + return type; + } + + if (networkInfo.isConnected()) { + String typeName = networkInfo.getTypeName(); + if ("WIFI".equalsIgnoreCase(typeName)) { + type = NETWORK_TYPE_WIFI; + } else if ("MOBILE".equalsIgnoreCase(typeName)) { + //String proxyHost = android.net.Proxy.getDefaultHost();//deprecated + String proxyHost = System.getProperty("http.proxyHost"); + type = TextUtils.isEmpty(proxyHost) ? (isFastMobileNetwork(context) ? NETWORK_TYPE_3G : NETWORK_TYPE_2G) : NETWORK_TYPE_WAP; + } else { + type = NETWORK_TYPE_UNKNOWN; + } + } + return type; + } + + public static boolean isConnected(Context context) { + ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo info = cm.getActiveNetworkInfo(); + if (info != null && info.isConnected()) { + if (info.getState() == NetworkInfo.State.CONNECTED) { + return true; + } + } + return false; + } + + public static boolean isNetworkAvailable(Context context) { + if (context == null) { + return false; + } + try { + ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + if (connectivity != null) { + NetworkInfo info = connectivity.getActiveNetworkInfo(); + return info.isAvailable(); + } + } catch (Exception e) { + return false; + } + return false; + } + + public static boolean isWiFi(Context cxt) { + ConnectivityManager cm = (ConnectivityManager) cxt.getSystemService(Context.CONNECTIVITY_SERVICE); + // wifi的状态:ConnectivityManager.TYPE_WIFI + // 3G的状态:ConnectivityManager.TYPE_MOBILE + return cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI; + } + + //unchecked + public static void openNetSetting(Activity act) { + Intent intent = new Intent(); + ComponentName cm = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings"); + intent.setComponent(cm); + intent.setAction("android.intent.action.VIEW"); + act.startActivityForResult(intent, 0); + } + + + /** + * Whether is fast mobile network + */ + + private static boolean isFastMobileNetwork(Context context) { + TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); + if (telephonyManager == null) { + return false; + } + + switch (telephonyManager.getNetworkType()) { + case TelephonyManager.NETWORK_TYPE_1xRTT: + return false; + case TelephonyManager.NETWORK_TYPE_CDMA: + return false; + case TelephonyManager.NETWORK_TYPE_EDGE: + return false; + case TelephonyManager.NETWORK_TYPE_EVDO_0: + return true; + case TelephonyManager.NETWORK_TYPE_EVDO_A: + return true; + case TelephonyManager.NETWORK_TYPE_GPRS: + return false; + case TelephonyManager.NETWORK_TYPE_HSDPA: + return true; + case TelephonyManager.NETWORK_TYPE_HSPA: + return true; + case TelephonyManager.NETWORK_TYPE_HSUPA: + return true; + case TelephonyManager.NETWORK_TYPE_UMTS: + return true; + case TelephonyManager.NETWORK_TYPE_EHRPD: + return true; + case TelephonyManager.NETWORK_TYPE_EVDO_B: + return true; + case TelephonyManager.NETWORK_TYPE_HSPAP: + return true; + case TelephonyManager.NETWORK_TYPE_IDEN: + return false; + case TelephonyManager.NETWORK_TYPE_LTE: + return true; + case TelephonyManager.NETWORK_TYPE_UNKNOWN: + return false; + default: + return false; + } + } + + public static void setWifiEnabled(Context context, boolean enabled) { + WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); + wifiManager.setWifiEnabled(enabled); + } + + public static void setDataEnabled(Context context, boolean enabled) { + ConnectivityManager conMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + Class conMgrClass = null; + Field iConMgrField = null; + Object iConMgr = null; + Class iConMgrClass = null; + Method setMobileDataEnabledMethod = null; + try { + conMgrClass = Class.forName(conMgr.getClass().getName()); + iConMgrField = conMgrClass.getDeclaredField("mService"); + iConMgrField.setAccessible(true); + iConMgr = iConMgrField.get(conMgr); + iConMgrClass = Class.forName(iConMgr.getClass().getName()); + setMobileDataEnabledMethod = iConMgrClass.getDeclaredMethod("setMobileDataEnabled", Boolean.TYPE); + setMobileDataEnabledMethod.setAccessible(true); + setMobileDataEnabledMethod.invoke(iConMgr, enabled); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static List getWifiScanResults(Context context) { + WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); + return wifiManager.startScan() ? wifiManager.getScanResults() : null; + } + + public static ScanResult getScanResultsByBSSID(Context context, String bssid) { + WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); + ScanResult scanResult = null; + boolean f = wifiManager.startScan(); + if (!f) { + getScanResultsByBSSID(context, bssid); + } + List list = wifiManager.getScanResults(); + if (list != null) { + for (int i = 0; i < list.size(); i++) { + scanResult = list.get(i); + if (scanResult.BSSID.equals(bssid)) { + break; + } + } + } + return scanResult; + } + + public static WifiInfo getWifiConnectionInfo(Context context) { + WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); + return wifiManager.getConnectionInfo(); + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/Observerlife.java b/app/src/main/java/com/fisherbone/fuzhu/utils/Observerlife.java new file mode 100644 index 0000000..b90f62e --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/Observerlife.java @@ -0,0 +1,12 @@ +package com.fisherbone.fuzhu.utils; + +import androidx.lifecycle.Observer; + +/** + * Time: 2021/7/13 + * Author: jianbo + * Description: + */ +public interface Observerlife extends Observer { + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/PrefUtils.java b/app/src/main/java/com/fisherbone/fuzhu/utils/PrefUtils.java new file mode 100644 index 0000000..03e1223 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/PrefUtils.java @@ -0,0 +1,58 @@ +package com.fisherbone.fuzhu.utils; + +import android.content.Context; +import android.content.SharedPreferences; + +/** + * 专门访问和设置SharePreference的工具类, 保存和配置一些设置信息 + * + * @author Kevin + */ +public class PrefUtils { + + private static final String SHARE_PREFS_NAME = "vicmob"; + + public static void putBoolean(Context ctx, String key, boolean value) { + SharedPreferences pref = ctx.getSharedPreferences(SHARE_PREFS_NAME, + Context.MODE_PRIVATE); + + pref.edit().putBoolean(key, value).commit(); + } + + public static boolean getBoolean(Context ctx, String key, + boolean defaultValue) { + SharedPreferences pref = ctx.getSharedPreferences(SHARE_PREFS_NAME, + Context.MODE_PRIVATE); + + return pref.getBoolean(key, defaultValue); + } + + public static void putString(Context ctx, String key, String value) { + SharedPreferences pref = ctx.getSharedPreferences(SHARE_PREFS_NAME, + Context.MODE_PRIVATE); + + pref.edit().putString(key, value).commit(); + } + + public static String getString(Context ctx, String key, String defaultValue) { + SharedPreferences pref = ctx.getSharedPreferences(SHARE_PREFS_NAME, + Context.MODE_PRIVATE); + + return pref.getString(key, defaultValue); + } + + public static void putInt(Context ctx, String key, int value) { + SharedPreferences pref = ctx.getSharedPreferences(SHARE_PREFS_NAME, + Context.MODE_PRIVATE); + + pref.edit().putInt(key, value).commit(); + } + + public static int getInt(Context ctx, String key, int defaultValue) { + SharedPreferences pref = ctx.getSharedPreferences(SHARE_PREFS_NAME, + Context.MODE_PRIVATE); + + return pref.getInt(key, defaultValue); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/ProfileSpUtils.java b/app/src/main/java/com/fisherbone/fuzhu/utils/ProfileSpUtils.java new file mode 100644 index 0000000..c8ef3e3 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/ProfileSpUtils.java @@ -0,0 +1,521 @@ +package com.fisherbone.fuzhu.utils; + +import android.content.Context; +import android.content.SharedPreferences; +import android.text.TextUtils; + +import com.fisherbone.fuzhu.db.KeyWordBean; +import com.fisherbone.fuzhu.db.LetterBean; +import com.fisherbone.fuzhu.entity.AppoBean; +import com.fisherbone.fuzhu.entity.AppointBean; +import com.fisherbone.fuzhu.entity.CancleFollowBean; +import com.fisherbone.fuzhu.entity.DavBean; +import com.fisherbone.fuzhu.entity.FensiBean; +import com.fisherbone.fuzhu.entity.InteraBean; +import com.fisherbone.fuzhu.entity.LiveBean; +import com.fisherbone.fuzhu.entity.LiveSuiJiBean; +import com.fisherbone.fuzhu.entity.NoticeBean; +import com.fisherbone.fuzhu.entity.PotCusBean; +import com.fisherbone.fuzhu.entity.RecFollowBean; +import com.fisherbone.fuzhu.entity.RedEnvBean; +import com.fisherbone.fuzhu.entity.SettingBean; +import com.fisherbone.fuzhu.entity.dakaVideoListBean; +import com.google.gson.Gson; + +import java.util.ArrayList; +import java.util.List; + +/** + * ProfileSpUtils + * (๑• . •๑) + * 类描述:轻量级资料存储工具 + * Created by LeiXiaoXing on 2017/4/11 11:01 + */ +public class ProfileSpUtils { + private static final String SP_NAME = "user_profile"; + private static final String SP_NAME_SHOW_ADD_FRIEND_RED="show_red_dot"; + private static final String SP_PUSH_NAME="user_push"; + /** + * 用户设置信息存储 + */ + private static final String SETTING_SP_NAME = "user_setting"; + private static final String KEY_USER = "User"; + private static final String KEY_CAN = "Can"; + private static final String KEY_FENSICAN = "FenCan"; + private static final String KEY_DAVCAN = "DavCan"; + private static final String KEY_DOTCAN = "DotCan"; + private static final String KEY_FENSI = "FenSi"; + private static final String KEY_FENSINOTICE = "FenSiNotice"; + private static final String KEY_LIVEBEAN = "LiveBeanCan"; + private static final String KEY_APPOBEAN = "AppoBean"; + private static final String KEY_APPOINTBEAN = "AppointBean"; + private static final String KEY_REDENVBEAN= "RedEnvBean"; + private static final String KEY_SETBEAN= "SetBean"; + private static final String KEY_LIVESUIJIBEAN = "LiveSuiJiBeanCan"; + private static final String KEY_LOGIN = "login"; + /** + * 手机号 + */ + private static final String KEY_MOBILE = "MOBILE"; + /** + * 密码 + */ + private static final String KEY_PASSWORD = "PASSWORD"; + private static ProfileSpUtils ourInstance = null; + /** + * 小米和华为推送相关id + */ + private static final String KEY_MI_PUSH="regId"; + private static final String KEY_HW_PUSH="tmId"; + + private static SharedPreferences sharedPreferences; + private static SharedPreferences settingSharedPreferences; + private static SharedPreferences showAddFriendRedSharedPreferences; + private static SharedPreferences pushSharedPreferences;//小米和华为; + + private boolean isFirst = true;//是否是第一次登陆 + + public ProfileSpUtils() { + } + + public static ProfileSpUtils getInstance() { + if (ourInstance == null) { + synchronized (ProfileSpUtils.class) { + if (ourInstance == null) { + ourInstance = new ProfileSpUtils(); + } + } + } + + return ourInstance; + } + + /** + * 初始化 + * + * @param context 上下文对象,建议使用Application的Context + */ + public static void init(Context context) { + sharedPreferences = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); + settingSharedPreferences = context.getSharedPreferences(SETTING_SP_NAME, Context.MODE_PRIVATE); + showAddFriendRedSharedPreferences=context.getSharedPreferences(SP_NAME_SHOW_ADD_FRIEND_RED, + Context.MODE_PRIVATE); + pushSharedPreferences=context.getSharedPreferences(SP_PUSH_NAME, Context.MODE_PRIVATE); + } + + /** + * 保存用户登录状态 + * + * @param isLogin 用户登录状态 + */ + public void saveLoginSatus(boolean isLogin) { + SharedPreferences.Editor edit = sharedPreferences.edit(); + if (!isLogin) { + //退出的登录,清除用户数据 + edit.clear(); + } + + edit.putBoolean(KEY_LOGIN, isLogin) + .apply(); + } + + + + + + + /** + * 记住密码 + */ + public void savePassword(String mobile, String password) { + settingSharedPreferences.edit() + .putString(KEY_MOBILE, mobile) + .putString(KEY_PASSWORD, password) + .apply(); + } + + /** + * 获取保存的用户账号 + * + * @return + */ + public String getKeyMobile() { + return settingSharedPreferences.getString(KEY_MOBILE, ""); + } + + /** + * 获取保存的密码 + * + * @return + */ + public String getKeyPassword() { + return settingSharedPreferences.getString(KEY_PASSWORD, ""); + } + + /** + * 获取用户登录状态 + * + * @return 用户登录状态 + */ + public boolean isLogin() { + return sharedPreferences.getBoolean(KEY_LOGIN, false); + } + + + /** + * 保存用户资料 + * + * @param loginbean 用户资料实体类 + */ +// public void saveProfile(LoginBean loginbean) { +// //头像数据转存 +// LoginBean loginBean = new LoginBean(); +// loginBean.getResult().getData().setHead_img(loginbean.getResult().getData().getHead_img()); + + + +// loginBean.setHome_Page_Size(treeUserEntity.getHome_Page_Size()); +// loginBean.setOrigin(treeUserEntity.getOrigin_img()); +// loginBean.setInfo_page_size(treeUserEntity.getInfo_page_size()); +// loginBean.setUser_list_size(treeUserEntity.getUser_list_size()); +// +// sharedPreferences.edit() +// .putString(KEY_USER, new Gson().toJson(treeUserEntity)) +// .putString(KEY_HEAD, new Gson().toJson(userHeadEntity)) +// .apply(); + + /** + * 获取SP存储的加关参数 + * + * @return SP存储的加关参数 + */ + public RecFollowBean getUserProfie() { + String userStr = sharedPreferences.getString(KEY_USER, ""); + if (TextUtils.isEmpty(userStr)) { + return new RecFollowBean("6", "5","15", false, true, true, "4990", "100", "100", "5", "3","10000","3500","20000",""); + } + return new Gson().fromJson(userStr, RecFollowBean.class); + } + + /** + * 保存加关参数 + * + * @param treeUserEntity 加关参数实体类 + */ + public void saveProfile(RecFollowBean treeUserEntity) { + sharedPreferences.edit() + .putString(KEY_USER, new Gson().toJson(treeUserEntity)) + .apply(); + + } + + /** + * 保存取关参数 + * + * @param treeUserEntity 取关参数实体类 + */ + public void saveCan(CancleFollowBean treeUserEntity) { + sharedPreferences.edit() + .putString(KEY_CAN, new Gson().toJson(treeUserEntity)) + .apply(); + + } + + /** + * 获取SP存储的取关参数 + * + * @return SP存储的取关参数 + */ + public CancleFollowBean getCan() { + String userStr = sharedPreferences.getString(KEY_CAN, ""); + if (TextUtils.isEmpty(userStr)) { + return new CancleFollowBean(true, false, "0", "1", "3000", "3000"); + } + return new Gson().fromJson(userStr, CancleFollowBean.class); + } + + + + /** + * 保存粉丝互动参数 + * + * @param treeUserEntity 粉丝互动参数实体类 + */ + public void saveFensiCan(InteraBean treeUserEntity) { + sharedPreferences.edit() + .putString(KEY_FENSICAN, new Gson().toJson(treeUserEntity)) + .apply(); + + } + + /** + * 获取SP存储的取关参数 + * + * @return SP存储的取关参数 + */ + public InteraBean getFensiCan() { + String userStr = sharedPreferences.getString(KEY_FENSICAN, ""); + if (TextUtils.isEmpty(userStr)) { + return new InteraBean( "你好呀", "3000"); + } + return new Gson().fromJson(userStr, InteraBean.class); + } + + + /** + * 保存大v粉丝截流参数 + * + * @param treeUserEntity 粉丝互动参数实体类 + */ + public void saveDavCan(DavBean treeUserEntity) { + sharedPreferences.edit() + .putString(KEY_DAVCAN, new Gson().toJson(treeUserEntity)) + .apply(); + + } + + /** + * 获取大v粉丝截流参数 + * + * @return SP存储的取关参数 + */ + public DavBean getDavCan() { + String userStr = sharedPreferences.getString(KEY_DAVCAN, ""); + if (TextUtils.isEmpty(userStr)) { + return new DavBean( "2", "200","dedede","互关;互赞;用户","100","100","5","10000","20000","10000"); + } + return new Gson().fromJson(userStr, DavBean.class); + } + + + /** + * 保存潜在加关参数 + * + * @param treeUserEntity 潜在加关参数实体类 + */ + public void savePot(PotCusBean treeUserEntity) { + sharedPreferences.edit() + .putString(KEY_DOTCAN, new Gson().toJson(treeUserEntity)) + .apply(); + + } + + /** + * 保存粉丝群发的参数 + * + * @param treeUserEntity 粉丝群发的参数 + */ + public void saveFensi(FensiBean treeUserEntity) { + sharedPreferences.edit() + .putString(KEY_FENSI, new Gson().toJson(treeUserEntity)) + .apply(); + } + /** + * 保存粉丝通知的参数 + * + * @param treeUserEntity 粉丝通知的参数 + */ + public void saveFensiNotice(NoticeBean treeUserEntity) { + sharedPreferences.edit() + .putString(KEY_FENSINOTICE, new Gson().toJson(treeUserEntity)) + .apply(); + } + /** + * 获取粉丝通知的参数 + * + * @param + */ + public NoticeBean getFensiNotice() { + String userStr = sharedPreferences.getString(KEY_FENSINOTICE, ""); + if (TextUtils.isEmpty(userStr)) { + return new NoticeBean( "1", "赏金猎人","200","7"); + } + return new Gson().fromJson(userStr, NoticeBean.class); + } + + /** + * 获取粉丝群发的参数 + * + * @param + */ + public FensiBean getFensi() { + String userStr = sharedPreferences.getString(KEY_FENSI, ""); + if (TextUtils.isEmpty(userStr)) { + return new FensiBean( "A", "贝儿"); + } + return new Gson().fromJson(userStr, FensiBean.class); + } + + + /** + * 获取大v粉丝截流参数 + * + * @return SP存储的取关参数 + */ + public PotCusBean getPot() { + String userStr = sharedPreferences.getString(KEY_DOTCAN, ""); + if (TextUtils.isEmpty(userStr)) { + PotCusBean potCusBean = new PotCusBean(); + List bigshotData = new ArrayList<>(); + dakaVideoListBean.DataBean bigshotData1 = new dakaVideoListBean.DataBean(); + bigshotData1.setName("地产S姐"); + bigshotData.add(bigshotData1); + potCusBean.setBigshotdatas(bigshotData); + ArrayList keyWordBeans = new ArrayList<>(); + KeyWordBean keyWordBean = new KeyWordBean(); + keyWordBean.setComment("位置"); + keyWordBeans.add(keyWordBean); + KeyWordBean keyWordBean1 = new KeyWordBean(); + keyWordBean1.setComment("二手房"); + keyWordBeans.add(keyWordBean1); + potCusBean.setKeyworddatas(keyWordBeans); + ArrayList letterBeans = new ArrayList<>(); + LetterBean letterBean = new LetterBean(); + letterBean.setComment("哈哈"); + letterBeans.add(letterBean); + potCusBean.setLetterdatas(letterBeans); + return potCusBean; + } + return new Gson().fromJson(userStr, PotCusBean.class); + } + + /** + * 保存指定直播间加热的参数 + * + * @param treeUserEntity 粉丝通知的参数 + */ + public void saveLiveBean(LiveBean treeUserEntity) { + sharedPreferences.edit() + .putString(KEY_LIVEBEAN, new Gson().toJson(treeUserEntity)) + .apply(); + } + /** + * 获取直播间加热的参数 + * + * @param + */ + public LiveBean getLiveBean() { + String userStr = sharedPreferences.getString(KEY_LIVEBEAN, ""); + if (TextUtils.isEmpty(userStr)) { + return new LiveBean("178421572","","","","","","","",false,false,false,"0",false,false,false,false); + } + return new Gson().fromJson(userStr, LiveBean.class); + } + + /** + * 保存随机直播间抢福袋的参数 + * + * @param treeUserEntity 粉丝通知的参数 + */ + public void saveLiveSuiJiBean(LiveSuiJiBean treeUserEntity) { + sharedPreferences.edit() + .putString(KEY_LIVESUIJIBEAN, new Gson().toJson(treeUserEntity)) + .apply(); + } + /** + * 获取随机直播间抢福袋的参数 + * + * @param + */ + public LiveSuiJiBean getLiveSuiJiBean() { + String userStr = sharedPreferences.getString(KEY_LIVESUIJIBEAN, ""); + if (TextUtils.isEmpty(userStr)) { + return new LiveSuiJiBean("50","1000","5","20",false,false,false,false,"1"); + } + return new Gson().fromJson(userStr, LiveSuiJiBean.class); + } + + /** + * 保存指定的直播间名称 + * + * @param treeUserEntity 粉丝通知的参数 + */ + public void saveAppoBean(AppoBean treeUserEntity) { + sharedPreferences.edit() + .putString(KEY_APPOBEAN, new Gson().toJson(treeUserEntity)) + .apply(); + } + /** + * 获取指定的直播间名称 + * + * @param + */ + public AppoBean getAppoBean() { + String userStr = sharedPreferences.getString(KEY_APPOBEAN, ""); + if (TextUtils.isEmpty(userStr)) { + return new AppoBean(null); + } + return new Gson().fromJson(userStr, AppoBean.class); + } + + + /** + * 保存指定的直播间页面参数 + * + * @param treeUserEntity 粉丝通知的参数 + */ + public void saveAppointBean(AppointBean treeUserEntity) { + sharedPreferences.edit() + .putString(KEY_APPOINTBEAN, new Gson().toJson(treeUserEntity)) + .apply(); + } + /** + * 获取指定的直播间页面参数 + * + * @param + */ + public AppointBean getAppointBean() { + String userStr = sharedPreferences.getString(KEY_APPOINTBEAN, ""); + if (TextUtils.isEmpty(userStr)) { + return new AppointBean(true); + } + return new Gson().fromJson(userStr, AppointBean.class); + } + + /** + * 保存抢抖币页面参数 + * + * @param treeUserEntity 粉丝通知的参数 + */ + public void saveRedEnvBean(RedEnvBean treeUserEntity) { + sharedPreferences.edit() + .putString(KEY_REDENVBEAN, new Gson().toJson(treeUserEntity)) + .apply(); + } + /** + * 获取抢抖币页面参数 + * + * @param + */ + public RedEnvBean getRedEnvBean() { + String userStr = sharedPreferences.getString(KEY_REDENVBEAN, ""); + if (TextUtils.isEmpty(userStr)) { + return new RedEnvBean("120","5","120","100",true,false,false); + } + return new Gson().fromJson(userStr, RedEnvBean.class); + } + + /** + * 保存设置页面参数 + * + * @param treeUserEntity + */ + public void saveSetBean(SettingBean treeUserEntity) { + sharedPreferences.edit() + .putString(KEY_SETBEAN, new Gson().toJson(treeUserEntity)) + .apply(); + } + /** + * 获取设置页面参数 + * + * @param + */ + public SettingBean getSetBean() { + String userStr = sharedPreferences.getString(KEY_SETBEAN, ""); + if (TextUtils.isEmpty(userStr)) { + return new SettingBean(false); + } + return new Gson().fromJson(userStr, SettingBean.class); + } +} + diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/QrCode.java b/app/src/main/java/com/fisherbone/fuzhu/utils/QrCode.java new file mode 100644 index 0000000..4530609 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/QrCode.java @@ -0,0 +1,47 @@ +package com.fisherbone.fuzhu.utils; + +import android.app.Activity; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.os.Build; + +import androidx.core.content.ContextCompat; + +import com.fisherbone.fuzhu.zxing.activity.CaptureActivity; + + +public class QrCode { + + public static final int REQUEST_QRCODE = 0x01; + Activity context; + + public QrCode(Activity context) { + this.context = context; + } + + // 开始扫码 + public void startQrCode() { + + if (Build.VERSION.SDK_INT > 22) { + if (ContextCompat.checkSelfPermission(context, + android.Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { + //先判断有没有权限 ,没有就在这里进行权限的申请 + ToastUtils.showToast(context, "没有权限,请手动开启相机权限"); + context.requestPermissions(new String[]{android.Manifest.permission.CAMERA}, Configs.REQ_PERM_CAMERA); + + } else { + //说明已经获取到摄像头权限了 想干嘛干嘛 + // 二维码扫码 + Intent intent = new Intent(context, CaptureActivity.class); + intent.putExtra("type", "dabiao"); + context.startActivityForResult(intent, REQUEST_QRCODE); + } + } else { +//这个说明系统版本在6.0之下,不需要动态获取权限。 + // 二维码扫码 + Intent intent = new Intent(context, CaptureActivity.class); + intent.putExtra("type", "dabiao"); + context.startActivityForResult(intent, REQUEST_QRCODE); + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/SPUtils.java b/app/src/main/java/com/fisherbone/fuzhu/utils/SPUtils.java new file mode 100644 index 0000000..835c10f --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/SPUtils.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2016 android@19code.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.utils; + +import android.content.Context; +import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; + +/** + * Create by h4de5ing 2016/5/7 007 + * SharedPreferences工具 + * + */ +public class SPUtils { + + public static void setSP(Context context, String key, Object object) { + String type = object.getClass().getSimpleName(); + String packageName = context.getPackageName(); + SharedPreferences sp = context.getSharedPreferences(packageName, Context.MODE_PRIVATE); + Editor edit = sp.edit(); + if ("String".equals(type)) { + edit.putString(key, (String) object); + } else if ("Integer".equals(type)) { + edit.putInt(key, (Integer) object); + } else if ("Boolean".equals(type)) { + edit.putBoolean(key, (Boolean) object); + } else if ("Float".equals(type)) { + edit.putFloat(key, (Float) object); + } else if ("Long".equals(type)) { + edit.putLong(key, (Long) object); + } + edit.apply(); + } + + public static Object getSp(Context context, String key, Object defaultObject) { + String type = defaultObject.getClass().getSimpleName(); + String packageName = context.getPackageName(); + SharedPreferences sp = context.getSharedPreferences(packageName, Context.MODE_PRIVATE); + if ("String".equals(type)) { + return sp.getString(key, (String) defaultObject); + } else if ("Integer".equals(type)) { + return sp.getInt(key, (Integer) defaultObject); + } else if ("Boolean".equals(type)) { + return sp.getBoolean(key, (Boolean) defaultObject); + } else if ("Float".equals(type)) { + return sp.getFloat(key, (Float) defaultObject); + } else if ("Long".equals(type)) { + return sp.getLong(key, (Long) defaultObject); + } + return null; + } + + public static void cleanAllSP(Context context) { + String packageName = context.getPackageName(); + SharedPreferences sp = context.getSharedPreferences(packageName, Context.MODE_PRIVATE); + Editor editor = sp.edit(); + editor.clear(); + editor.apply(); + } + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/StatusBarUtil.java b/app/src/main/java/com/fisherbone/fuzhu/utils/StatusBarUtil.java new file mode 100644 index 0000000..1ffeca3 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/StatusBarUtil.java @@ -0,0 +1,205 @@ +package com.fisherbone.fuzhu.utils; + +import android.annotation.TargetApi; +import android.app.Activity; +import android.graphics.Color; +import android.os.Build; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; + +import com.readystatesoftware.systembartint.SystemBarTintManager; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +/** + * Created by XiaoQiang on 2017/6/21. + */ +public class StatusBarUtil { + + /** + * 修改状态栏为全透明 + * @param activity + */ + @TargetApi(19) + public static void transparencyBar(Activity activity){ + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + Window window = activity.getWindow(); + window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); + window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + window.setStatusBarColor(Color.WHITE); + + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + Window window =activity.getWindow(); + window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, + WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + } + } + + /** + * 修改状态栏颜色,支持4.4以上版本 + * @param activity + * @param colorId + */ + public static void setStatusBarColor(Activity activity,int colorId) { + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + Window window = activity.getWindow(); +// window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + window.setStatusBarColor(activity.getResources().getColor(colorId)); + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + //使用SystemBarTint库使4.4版本状态栏变色,需要先将状态栏设置为透明 + transparencyBar(activity); + SystemBarTintManager tintManager = new SystemBarTintManager(activity); + tintManager.setStatusBarTintEnabled(true); + tintManager.setStatusBarTintResource(colorId); + } + } + + /** + *状态栏亮色模式,设置状态栏黑色文字、图标, + * 适配4.4以上版本MIUIV、Flyme和6.0以上版本其他Android + * @param activity + * @return 1:MIUUI 2:Flyme 3:android6.0 + */ + public static int StatusBarLightMode(Activity activity){ + int result=0; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + if(MIUISetStatusBarLightMode(activity, true)){ + result=1; + }else if(FlymeSetStatusBarLightMode(activity.getWindow(), true)){ + result=2; + }else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + activity.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + result=3; + }else{ + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + Window window = activity.getWindow(); + window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); + window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + window.setStatusBarColor(Color.BLACK); + + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + Window window =activity.getWindow(); + window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, + WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + } + } + } + return result; + } + + /** + * 已知系统类型时,设置状态栏黑色文字、图标。 + * 适配4.4以上版本MIUIV、Flyme和6.0以上版本其他Android + * @param activity + * @param type 1:MIUUI 2:Flyme 3:android6.0 + */ + public static void StatusBarLightMode(Activity activity,int type){ + if(type==1){ + MIUISetStatusBarLightMode(activity, true); + }else if(type==2){ + FlymeSetStatusBarLightMode(activity.getWindow(), true); + }else if(type==3){ + activity.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + } + + } + + /** + * 状态栏暗色模式,清除MIUI、flyme或6.0以上版本状态栏黑色文字、图标 + */ + public static void StatusBarDarkMode(Activity activity,int type){ + if(type==1){ + MIUISetStatusBarLightMode(activity, false); + }else if(type==2){ + FlymeSetStatusBarLightMode(activity.getWindow(), false); + }else if(type==3){ + activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); + } + + } + + + /** + * 设置状态栏图标为深色和魅族特定的文字风格 + * 可以用来判断是否为Flyme用户 + * @param window 需要设置的窗口 + * @param dark 是否把状态栏文字及图标颜色设置为深色 + * @return boolean 成功执行返回true + * + */ + public static boolean FlymeSetStatusBarLightMode(Window window, boolean dark) { + boolean result = false; + if (window != null) { + try { + WindowManager.LayoutParams lp = window.getAttributes(); + Field darkFlag = WindowManager.LayoutParams.class + .getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON"); + Field meizuFlags = WindowManager.LayoutParams.class + .getDeclaredField("meizuFlags"); + darkFlag.setAccessible(true); + meizuFlags.setAccessible(true); + int bit = darkFlag.getInt(null); + int value = meizuFlags.getInt(lp); + if (dark) { + value |= bit; + } else { + value &= ~bit; + } + meizuFlags.setInt(lp, value); + window.setAttributes(lp); + result = true; + } catch (Exception e) { + + } + } + return result; + } + + /** + * 需要MIUIV6以上 + * @param activity + * @param dark 是否把状态栏文字及图标颜色设置为深色 + * @return boolean 成功执行返回true + * + */ + public static boolean MIUISetStatusBarLightMode(Activity activity, boolean dark) { + boolean result = false; + Window window=activity.getWindow(); + if (window != null) { + Class clazz = window.getClass(); + try { + int darkModeFlag = 0; + Class layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams"); + Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE"); + darkModeFlag = field.getInt(layoutParams); + Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class); + if(dark){ + extraFlagField.invoke(window,darkModeFlag,darkModeFlag);//状态栏透明且黑色字体 + }else{ + extraFlagField.invoke(window, 0, darkModeFlag);//清除黑色字体 + } + result=true; + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + //开发版 7.7.13 及以后版本采用了系统API,旧方法无效但不会报错,所以两个方式都要加上 + if(dark){ + activity.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN| View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + }else { + activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); + } + } + }catch (Exception e){ + + } + } + return result; + } +} + diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/StringUtils.java b/app/src/main/java/com/fisherbone/fuzhu/utils/StringUtils.java new file mode 100644 index 0000000..5ec1e4c --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/StringUtils.java @@ -0,0 +1,248 @@ +/* + * Copyright (C) 2016 android@19code.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.utils; + +import java.text.DecimalFormat; + +/** + * 字符串工具 + * Created by Gh0st on 2016/6/2 002. + */ +public class StringUtils { + /** + * The pyvalue. + */ + private static int[] pyvalue = new int[]{-20319, -20317, -20304, -20295, -20292, -20283, -20265, -20257, -20242, -20230, -20051, -20036, -20032, + -20026, -20002, -19990, -19986, -19982, -19976, -19805, -19784, -19775, -19774, -19763, -19756, -19751, -19746, -19741, -19739, -19728, + -19725, -19715, -19540, -19531, -19525, -19515, -19500, -19484, -19479, -19467, -19289, -19288, -19281, -19275, -19270, -19263, -19261, + -19249, -19243, -19242, -19238, -19235, -19227, -19224, -19218, -19212, -19038, -19023, -19018, -19006, -19003, -18996, -18977, -18961, + -18952, -18783, -18774, -18773, -18763, -18756, -18741, -18735, -18731, -18722, -18710, -18697, -18696, -18526, -18518, -18501, -18490, + -18478, -18463, -18448, -18447, -18446, -18239, -18237, -18231, -18220, -18211, -18201, -18184, -18183, -18181, -18012, -17997, -17988, + -17970, -17964, -17961, -17950, -17947, -17931, -17928, -17922, -17759, -17752, -17733, -17730, -17721, -17703, -17701, -17697, -17692, + -17683, -17676, -17496, -17487, -17482, -17468, -17454, -17433, -17427, -17417, -17202, -17185, -16983, -16970, -16942, -16915, -16733, + -16708, -16706, -16689, -16664, -16657, -16647, -16474, -16470, -16465, -16459, -16452, -16448, -16433, -16429, -16427, -16423, -16419, + -16412, -16407, -16403, -16401, -16393, -16220, -16216, -16212, -16205, -16202, -16187, -16180, -16171, -16169, -16158, -16155, -15959, + -15958, -15944, -15933, -15920, -15915, -15903, -15889, -15878, -15707, -15701, -15681, -15667, -15661, -15659, -15652, -15640, -15631, + -15625, -15454, -15448, -15436, -15435, -15419, -15416, -15408, -15394, -15385, -15377, -15375, -15369, -15363, -15362, -15183, -15180, + -15165, -15158, -15153, -15150, -15149, -15144, -15143, -15141, -15140, -15139, -15128, -15121, -15119, -15117, -15110, -15109, -14941, + -14937, -14933, -14930, -14929, -14928, -14926, -14922, -14921, -14914, -14908, -14902, -14894, -14889, -14882, -14873, -14871, -14857, + -14678, -14674, -14670, -14668, -14663, -14654, -14645, -14630, -14594, -14429, -14407, -14399, -14384, -14379, -14368, -14355, -14353, + -14345, -14170, -14159, -14151, -14149, -14145, -14140, -14137, -14135, -14125, -14123, -14122, -14112, -14109, -14099, -14097, -14094, + -14092, -14090, -14087, -14083, -13917, -13914, -13910, -13907, -13906, -13905, -13896, -13894, -13878, -13870, -13859, -13847, -13831, + -13658, -13611, -13601, -13406, -13404, -13400, -13398, -13395, -13391, -13387, -13383, -13367, -13359, -13356, -13343, -13340, -13329, + -13326, -13318, -13147, -13138, -13120, -13107, -13096, -13095, -13091, -13076, -13068, -13063, -13060, -12888, -12875, -12871, -12860, + -12858, -12852, -12849, -12838, -12831, -12829, -12812, -12802, -12607, -12597, -12594, -12585, -12556, -12359, -12346, -12320, -12300, + -12120, -12099, -12089, -12074, -12067, -12058, -12039, -11867, -11861, -11847, -11831, -11798, -11781, -11604, -11589, -11536, -11358, + -11340, -11339, -11324, -11303, -11097, -11077, -11067, -11055, -11052, -11045, -11041, -11038, -11024, -11020, -11019, -11018, -11014, + -10838, -10832, -10815, -10800, -10790, -10780, -10764, -10587, -10544, -10533, -10519, -10331, -10329, -10328, -10322, -10315, -10309, + -10307, -10296, -10281, -10274, -10270, -10262, -10260, -10256, -10254}; + + /** + * The pystr. + */ + public static String[] pystr = new String[]{"a", "ai", "an", "ang", "ao", "ba", "bai", "ban", "bang", "bao", "bei", "ben", "beng", "bi", "bian", + "biao", "bie", "bin", "bing", "bo", "bu", "ca", "cai", "can", "cang", "cao", "ce", "ceng", "cha", "chai", "chan", "chang", "chao", "che", + "chen", "cheng", "chi", "chong", "chou", "chu", "chuai", "chuan", "chuang", "chui", "chun", "chuo", "ci", "cong", "cou", "cu", "cuan", + "cui", "cun", "cuo", "da", "dai", "dan", "dang", "dao", "de", "deng", "di", "dian", "diao", "die", "ding", "diu", "dong", "dou", "du", + "duan", "dui", "dun", "duo", "e", "en", "er", "fa", "fan", "fang", "fei", "fen", "feng", "fo", "fou", "fu", "ga", "gai", "gan", "gang", + "gao", "ge", "gei", "gen", "geng", "gong", "gou", "gu", "gua", "guai", "guan", "guang", "gui", "gun", "guo", "ha", "hai", "han", "hang", + "hao", "he", "hei", "hen", "heng", "hong", "hou", "hu", "hua", "huai", "huan", "huang", "hui", "hun", "huo", "ji", "jia", "jian", + "jiang", "jiao", "jie", "jin", "jing", "jiong", "jiu", "ju", "juan", "jue", "jun", "ka", "kai", "kan", "kang", "kao", "ke", "ken", + "keng", "kong", "kou", "ku", "kua", "kuai", "kuan", "kuang", "kui", "kun", "kuo", "la", "lai", "lan", "lang", "lao", "le", "lei", "leng", + "li", "lia", "lian", "liang", "liao", "lie", "lin", "ling", "liu", "long", "lou", "lu", "lv", "luan", "lue", "lun", "luo", "ma", "mai", + "man", "mang", "mao", "me", "mei", "men", "meng", "mi", "mian", "miao", "mie", "min", "ming", "miu", "mo", "mou", "mu", "na", "nai", + "nan", "nang", "nao", "ne", "nei", "nen", "neng", "ni", "nian", "niang", "niao", "nie", "nin", "ning", "niu", "nong", "nu", "nv", "nuan", + "nue", "nuo", "o", "ou", "pa", "pai", "pan", "pang", "pao", "pei", "pen", "peng", "pi", "pian", "piao", "pie", "pin", "ping", "po", "pu", + "qi", "qia", "qian", "qiang", "qiao", "qie", "qin", "qing", "qiong", "qiu", "qu", "quan", "que", "qun", "ran", "rang", "rao", "re", + "ren", "reng", "ri", "rong", "rou", "ru", "ruan", "rui", "run", "ruo", "sa", "sai", "san", "sang", "sao", "se", "sen", "seng", "sha", + "shai", "shan", "shang", "shao", "she", "shen", "sheng", "shi", "shou", "shu", "shua", "shuai", "shuan", "shuang", "shui", "shun", + "shuo", "si", "song", "sou", "su", "suan", "sui", "sun", "suo", "ta", "tai", "tan", "tang", "tao", "te", "teng", "ti", "tian", "tiao", + "tie", "ting", "tong", "tou", "tu", "tuan", "tui", "tun", "tuo", "wa", "wai", "wan", "wang", "wei", "wen", "weng", "wo", "wu", "xi", + "xia", "xian", "xiang", "xiao", "xie", "xin", "xing", "xiong", "xiu", "xu", "xuan", "xue", "xun", "ya", "yan", "yang", "yao", "ye", "yi", + "yin", "ying", "yo", "yong", "you", "yu", "yuan", "yue", "yun", "za", "zai", "zan", "zang", "zao", "ze", "zei", "zen", "zeng", "zha", + "zhai", "zhan", "zhang", "zhao", "zhe", "zhen", "zheng", "zhi", "zhong", "zhou", "zhu", "zhua", "zhuai", "zhuan", "zhuang", "zhui", + "zhun", "zhuo", "zi", "zong", "zou", "zu", "zuan", "zui", "zun", "zuo"}; + + + public static int getChsAscii(String chs) { + int asc = 0; + try { + byte[] bytes = chs.getBytes("gb2312"); + /*if (bytes == null || bytes.length > 2 || bytes.length <= 0) { + throw new RuntimeException("illegal resource string"); + }*/ + if (bytes.length == 1) { + asc = bytes[0]; + } + if (bytes.length == 2) { + int hightByte = 256 + bytes[0]; + int lowByte = 256 + bytes[1]; + asc = (256 * hightByte + lowByte) - 256 * 256; + } + } catch (Exception e) { + System.out.println("ERROR:ChineseSpelling.class-getChsAscii(String chs)" + e); + } + return asc; + } + + public static String convert(String str) { + String result = null; + int ascii = getChsAscii(str); + if (ascii > 0 && ascii < 160) { + result = String.valueOf((char) ascii); + } else { + for (int i = (pyvalue.length - 1); i >= 0; i--) { + if (pyvalue[i] <= ascii) { + result = pystr[i]; + break; + } + } + } + return result; + } + + public String getSelling(String chs) { + String key, value; + StringBuilder buffer = new StringBuilder(); + for (int i = 0; i < chs.length(); i++) { + key = chs.substring(i, i + 1); + if (key.getBytes().length >= 2) { + value = convert(key); + if (value == null) { + value = "unknown"; + } + } else { + value = key; + } + buffer.append(value); + } + return buffer.toString(); + } + + public static String parseEmpty(String str) { + if (str == null || "null".equals(str.trim())) { + str = ""; + } + return str.trim(); + } + + public static boolean isEmpty(String str) { + return str == null || str.trim().length() == 0; + } + + public static int chineseLength(String str) { + int valueLength = 0; + String chinese = "[\u0391-\uFFE5]"; + if (!isEmpty(str)) { + for (int i = 0; i < str.length(); i++) { + String temp = str.substring(i, i + 1); + if (temp.matches(chinese)) { + valueLength += 2; + } + } + } + return valueLength; + } + + public static int strLength(String str) { + int valueLength = 0; + String chinese = "[\u0391-\uFFE5]"; + if (!isEmpty(str)) { + for (int i = 0; i < str.length(); i++) { + String temp = str.substring(i, i + 1); + if (temp.matches(chinese)) { + valueLength += 2; + } else { + valueLength += 1; + } + } + } + return valueLength; + } + + public static int subStringLength(String str, int maxL) { + int currentIndex = 0; + int valueLength = 0; + String chinese = "[\u0391-\uFFE5]"; + for (int i = 0; i < str.length(); i++) { + String temp = str.substring(i, i + 1); + if (temp.matches(chinese)) { + valueLength += 2; + } else { + valueLength += 1; + } + if (valueLength >= maxL) { + currentIndex = i; + break; + } + } + return currentIndex; + } + + public static Boolean isChinese(String str) { + Boolean isChinese = true; + String chinese = "[\u0391-\uFFE5]"; + if (!isEmpty(str)) { + for (int i = 0; i < str.length(); i++) { + String temp = str.substring(i, i + 1); + isChinese = temp.matches(chinese); + } + } + return isChinese; + } + + public static Boolean isContainChinese(String str) { + Boolean isChinese = false; + String chinese = "[\u0391-\uFFE5]"; + if (!isEmpty(str)) { + for (int i = 0; i < str.length(); i++) { + String temp = str.substring(i, i + 1); + isChinese = temp.matches(chinese); + } + } + return isChinese; + } + + public static String strFormat2(String str) { + try { + if (str.length() <= 1) { + str = "0" + str; + } + } catch (Exception e) { + e.printStackTrace(); + } + return str; + } + + public static int convert2Int(Object value, int defaultValue) { + if (value == null || "".equals(value.toString().trim())) { + return defaultValue; + } + try { + return Double.valueOf(value.toString()).intValue(); + } catch (Exception e) { + e.printStackTrace(); + return defaultValue; + } + } + + public static String decimalFormat(float s, String format) { + DecimalFormat decimalFormat = new DecimalFormat(format); + return decimalFormat.format(s); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/SystemUtil.java b/app/src/main/java/com/fisherbone/fuzhu/utils/SystemUtil.java new file mode 100644 index 0000000..5b55ccd --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/SystemUtil.java @@ -0,0 +1,59 @@ +package com.fisherbone.fuzhu.utils; + +import java.util.Locale; + +/** + * Time: 2021/6/23 + * Author: jianbo + * Description: + */ +public class SystemUtil { + + + /** + * 获取当前手机系统语言。 + * + * @return 返回当前系统语言。例如:当前设置的是“中文-中国”,则返回“zh-CN” + */ + public static String getSystemLanguage() { + return Locale.getDefault().getLanguage(); + } + + /** + * 获取当前系统上的语言列表(Locale列表) + * + * @return 语言列表 + */ + public static Locale[] getSystemLanguageList() { + return Locale.getAvailableLocales(); + } + + /** + * 获取当前手机系统版本号 + * + * @return 系统版本号 + */ + public static String getSystemVersion() { + return android.os.Build.VERSION.RELEASE; + } + + /** + * 获取手机型号 + * + * @return 手机型号 + */ + public static String getSystemModel() { + return android.os.Build.MODEL; + } + + /** + * 获取手机厂商 + * + * @return 手机厂商 + */ + public static String getDeviceBrand() { + return android.os.Build.BRAND; + } + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/ToastUtils.java b/app/src/main/java/com/fisherbone/fuzhu/utils/ToastUtils.java new file mode 100644 index 0000000..01d2bc7 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/ToastUtils.java @@ -0,0 +1,58 @@ +package com.fisherbone.fuzhu.utils; + +import android.content.Context; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.WindowManager; +import android.widget.TextView; +import android.widget.Toast; + +import com.fisherbone.fuzhu.R; + + +/** + * Created by gh0st on 2017/1/17. + * 吐司工具类 + */ + +public class ToastUtils { + private static Toast mToast; + private static String message; + private static TextView mTextView; + + + public static void showToast1(Context context, String string) { + Toast.makeText(context , string , Toast.LENGTH_SHORT).show(); + } + public static void showToast(Context context, int string) { + Toast.makeText(context , string , Toast.LENGTH_SHORT).show(); + } + + public static void showToast(Context context, String message) { + //加载Toast布局 + View toastRoot = LayoutInflater.from(context).inflate(R.layout.toast, null); + //初始化布局控件 + mTextView = (TextView) toastRoot.findViewById(R.id.message); +// mImageView = (ImageView) toastRoot.findViewById(R.id.imageView); + //为控件设置属性 + mTextView.setText(message); +// mImageView.setImageResource(R.mipmap.ic_launcher); + //Toast的初始化 + Toast toastStart = new Toast(context); + //获取屏幕高度 + WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); + int height = wm.getDefaultDisplay().getHeight(); + //Toast的Y坐标是屏幕高度的1/3,不会出现不适配的问题 + toastStart.setGravity(Gravity.BOTTOM, 0, height / 3); + toastStart.setDuration(Toast.LENGTH_LONG); + toastStart.setView(toastRoot); + toastStart.show(); + } + + + + + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/UpdateManager.java b/app/src/main/java/com/fisherbone/fuzhu/utils/UpdateManager.java new file mode 100644 index 0000000..1e195ac --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/UpdateManager.java @@ -0,0 +1,228 @@ +package com.fisherbone.fuzhu.utils; + +import android.app.AlertDialog.Builder; +import android.app.Dialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.DialogInterface.OnClickListener; +import android.content.Intent; +import android.net.Uri; +import android.os.Build; +import android.os.Environment; +import android.os.Handler; +import android.os.Message; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.ProgressBar; + +import androidx.core.content.FileProvider; + +import com.fisherbone.fuzhu.R; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; + + +public class UpdateManager { + + private Context mContext; + + //提示语 + private String updateMsg = "有最新的软件包哦,亲快下载吧~"; + + //返回的安装包url + private String apkUrl; + + private Dialog noticeDialog; + + private Dialog downloadDialog; + /* 下载包安装路径 */ + private static final String savePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath(); + + private static final String saveFileName = savePath + "/atom-latest.apk"; + + /* 进度条与通知ui刷新的handler和msg常量 */ + private ProgressBar mProgress; + + private static final int DOWN_UPDATE = 1; + + private static final int DOWN_OVER = 2; + + private int progress; + + private Thread downLoadThread; + + private boolean interceptFlag = false; + + + private Handler mHandler = new Handler(){ + public void handleMessage(Message msg) { + switch (msg.what) { + case DOWN_UPDATE: + mProgress.setProgress(progress); + break; + case DOWN_OVER: + installApk(mContext); + break; + default: + break; + } + }; + }; + + public UpdateManager(Context context, String apkUrl){ + this.mContext = context; + this.apkUrl=apkUrl; + } + + //外部接口让主Activity调用 + public void checkUpdateInfo(){ + showNoticeDialog(); + } + //外部接口让主Activity调用 + public void checkUpdateDownload(){ + showDownloadDialog(); + } + + /* + * 版本更新提示 + */ + private void showNoticeDialog(){ + Builder builder = new Builder(mContext); + builder.setTitle("软件版本更新"); + builder.setMessage(updateMsg); + builder.setPositiveButton("下载", new OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + showDownloadDialog(); + } + }); + builder.setNegativeButton("以后再说", new OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }); + noticeDialog = builder.create(); + noticeDialog.show(); + } + + /** + * 更新提示 + */ + private void showDownloadDialog(){ + Builder builder = new Builder(mContext); + builder.setTitle("软件版本更新"); + builder.setMessage("正在下载"); + final LayoutInflater inflater = LayoutInflater.from(mContext); + View v = inflater.inflate(R.layout.progress, null); + mProgress = (ProgressBar)v.findViewById(R.id.progress); + + builder.setView(v); + builder.setNegativeButton("取消", new OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + interceptFlag = true; + } + }); + downloadDialog = builder.create(); + downloadDialog.show(); + + downloadApk(); + } + + private Runnable mdownApkRunnable = new Runnable() { + @Override + public void run() { + try { + URL url = new URL(apkUrl); + + HttpURLConnection conn = (HttpURLConnection)url.openConnection(); + conn.connect(); + int length = conn.getContentLength(); + InputStream is = conn.getInputStream(); + + File file = new File(savePath); + if(!file.exists()){ + file.mkdir(); + } + String apkFile = saveFileName; + File ApkFile = new File(apkFile); + FileOutputStream fos = new FileOutputStream(ApkFile); + + int count = 0; + byte buf[] = new byte[1024]; + + do{ + int numread = is.read(buf); + count += numread; + progress =(int)(((float)count / length) * 100); + //更新进度 + mHandler.sendEmptyMessage(DOWN_UPDATE); + if(numread <= 0){ + //下载完成通知安装 + mHandler.sendEmptyMessage(DOWN_OVER); + break; + } + fos.write(buf,0,numread); + }while(!interceptFlag);//点击取消就停止下载. + + fos.close(); + is.close(); + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch(IOException e){ + e.printStackTrace(); + } + + } + }; + + /** + * 下载apk + * @param + */ + + private void downloadApk(){ + downLoadThread = new Thread(mdownApkRunnable); + downLoadThread.start(); + } + + /** + * 安装apk + * @param + */ + + public static void installApk(Context context) { + + File apkfile = new File(saveFileName); + if (!apkfile.exists()) { + return; + } + + + File file = new File( + Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + , "atom-latest.apk"); + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + if(Build.VERSION.SDK_INT>=24) { //判读版本是否在7.0以上 + + Uri apkUri = FileProvider.getUriForFile(context, "com.fisherbone.fuzhu.fileProvider", file); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + intent.setDataAndType(apkUri, "application/vnd.android.package-archive"); + }else{ + intent.setDataAndType(Uri.fromFile(apkfile), + "application/vnd.android.package-archive"); + } + context.startActivity(intent); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/VersionUtils.java b/app/src/main/java/com/fisherbone/fuzhu/utils/VersionUtils.java new file mode 100644 index 0000000..f277e4c --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/VersionUtils.java @@ -0,0 +1,52 @@ +package com.fisherbone.fuzhu.utils; + + +import android.util.Log; + + +public class VersionUtils { + + /** + * 版本号比较 + * + * @return + */ + public static int compareVersion(String dangqianversion,String newVersion) { + if (String.valueOf(dangqianversion).equals(newVersion)) { + return 0; + } + String[] version1Array = String.valueOf(dangqianversion).split("\\."); + String[] version2Array = newVersion.split("\\."); + Log.d("HomePageActivity", "version1Array==" + version1Array.length); + Log.d("HomePageActivity", "version2Array==" + version2Array.length); + int index = 0; + // 获取最小长度值 + int minLen = Math.min(version1Array.length, version2Array.length); + int diff = 0; + // 循环判断每位的大小 + Log.d("HomePageActivity", "verTag2=2222=" + version1Array[index]); + while (index < minLen + && (diff = Integer.parseInt(version1Array[index]) + - Integer.parseInt(version2Array[index])) == 0) { + index++; + } + if (diff == 0) { + // 如果位数不一致,比较多余位数 + for (int i = index; i < version1Array.length; i++) { + if (Integer.parseInt(version1Array[i]) > 0) { + return 1; + } + } + + for (int i = index; i < version2Array.length; i++) { + if (Integer.parseInt(version2Array[i]) > 0) { + return -1; + } + } + return 0; + } else { + return diff > 0 ? 1 : -1; + } + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/utils/WidgetTools.java b/app/src/main/java/com/fisherbone/fuzhu/utils/WidgetTools.java new file mode 100644 index 0000000..b53d639 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/utils/WidgetTools.java @@ -0,0 +1,137 @@ +/* + ******************************************* + * File: WidgetTools.java + * Author: Lijc + * Date: 2015-3-20 + * Company: BlueMobi + ********************************************/ +package com.fisherbone.fuzhu.utils; + +import android.content.Context; +import android.text.TextUtils; +import android.widget.EditText; +import android.widget.TextView; + +public class WidgetTools { + /** + * @Title: setText + * @Description: TODO 设置TextView的text 为空时默认显示 -- + * @param tv + * @param text + * @return void + * @throws + */ + public static void setText(TextView tv, String text) { + if ("null".equals(text) || "".equals(text)||null == text) { + setText(tv, "— —", "— —"); + } else { + setText(tv, text, "— —"); + } + + } + + public static void setEditText(EditText tv, String text1,String test2) { + if (("null".equals(text1) || "".equals(text1)||null == text1)&&"null".equals(test2) || "".equals(test2)||null == test2) { + setText(tv, text1+test2, ""); + } else { + setText(tv, text1+test2, ""); + } + + } + + //viewpage滑动折叠卡片效果 + public static void setTexttwo(TextView tv, String text,String texttwo) { + if ("null".equals(text) || "".equals(text)||null == text) { + setText(tv, texttwo+"— —", texttwo+"— —"); + } else { + setText(tv, texttwo+text, texttwo+"— —"); + } + + } + + + public static void setTextfive(TextView tv,String mctext, String text) { + if ("null".equals(text) || "".equals(text)||null == text) { + setText(tv, mctext+"— —", mctext+"— —"); + } else { + setText(tv,mctext+text, mctext+"— —"); + } + + } + public static void setTextsix(TextView tv,String mctext, String text) { + if ("null".equals(text) || "".equals(text)||null == text) { + setText(tv, mctext+"", mctext+""); + } else { + setText(tv,mctext+text, mctext+""); + } + + } + + /** + * @Title: setText + * @Description: TODO 设置TextView的text + * @param tv + * @param text + * @param defaultText + * 默认显示 + * @return void + * @throws + */ + public static void setText(TextView tv, String text, String defaultText) { + if (TextUtils.isEmpty(text)) { + tv.setText(defaultText); + } else { + tv.setText(text); + } + } + + /** + * @Title: setText + * @Description: TODO String资源文件的format方法 + * @param @param tv + * @param @param context + * @param @param text + * @param @param resId + * @return void + * @throws + */ + public static void setText(TextView tv, Context context, String text, + int resId) { + String format = context.getResources().getString(resId); + tv.setText(String.format(format, text)); + } + + /** + * @Title: setText + * @Description: TODO String资源文件的format方法 + * @param tv + * @param context + * @param i + * @param resId + * @return void + * @throws + */ + public static void setText(TextView tv, Context context, int i, int resId) { + String format = context.getResources().getString(resId); + tv.setText(String.format(format, i)); + } + + /** + * @Title: setText + * @Description: TODO String资源文件的format方法 + * @param @param tv + * @param @param context + * @param @param text1 + * @param @param text2 + * @param @param resId + * @return void + * @throws + */ + public static void setText(TextView tv, Context context, String text1, + String text2, int resId) { + String format = context.getResources().getString(resId); + tv.setText(String.format(format, text1, text2)); + } + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/views/CircleImageView.java b/app/src/main/java/com/fisherbone/fuzhu/views/CircleImageView.java new file mode 100644 index 0000000..cd7c7f8 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/views/CircleImageView.java @@ -0,0 +1,305 @@ +package com.fisherbone.fuzhu.views; + + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Bitmap; +import android.graphics.BitmapShader; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.ColorFilter; +import android.graphics.Matrix; +import android.graphics.Paint; +import android.graphics.RectF; +import android.graphics.Shader; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.ColorDrawable; +import android.graphics.drawable.Drawable; +import android.net.Uri; +import android.util.AttributeSet; + +import androidx.annotation.ColorRes; +import androidx.annotation.DrawableRes; + +import com.fisherbone.fuzhu.R; + + +/** + * + * 自定义圆形用户头像 + * Created by Administrator on 2017/6/22 0022. + */ +public class CircleImageView extends androidx.appcompat.widget.AppCompatImageView { + + private static final ScaleType SCALE_TYPE = ScaleType.CENTER_CROP; + + private static final Bitmap.Config BITMAP_CONFIG = Bitmap.Config.ARGB_8888; + private static final int COLORDRAWABLE_DIMENSION = 2; + + private static final int DEFAULT_BORDER_WIDTH = 0; + private static final int DEFAULT_BORDER_COLOR = Color.BLACK; + private static final boolean DEFAULT_BORDER_OVERLAY = false; + + private final RectF mDrawableRect = new RectF(); + private final RectF mBorderRect = new RectF(); + + private final Matrix mShaderMatrix = new Matrix(); + private final Paint mBitmapPaint = new Paint(); + private final Paint mBorderPaint = new Paint(); + + private int mBorderColor = DEFAULT_BORDER_COLOR; + private int mBorderWidth = DEFAULT_BORDER_WIDTH; + + private Bitmap mBitmap; + private BitmapShader mBitmapShader; + private int mBitmapWidth; + private int mBitmapHeight; + + private float mDrawableRadius; + private float mBorderRadius; + + private ColorFilter mColorFilter; + + private boolean mReady; + private boolean mSetupPending; + private boolean mBorderOverlay; + + public CircleImageView(Context context) { + super(context); + + init(); + } + + public CircleImageView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public CircleImageView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView, defStyle, 0); + + mBorderWidth = a.getDimensionPixelSize(R.styleable.CircleImageView_border_width, DEFAULT_BORDER_WIDTH); + mBorderColor = a.getColor(R.styleable.CircleImageView_border_color, DEFAULT_BORDER_COLOR); + mBorderOverlay = a.getBoolean(R.styleable.CircleImageView_border_overlay, DEFAULT_BORDER_OVERLAY); + + a.recycle(); + + init(); + } + + private void init() { + super.setScaleType(SCALE_TYPE); + mReady = true; + + if (mSetupPending) { + setup(); + mSetupPending = false; + } + } + + @Override + public ScaleType getScaleType() { + return SCALE_TYPE; + } + + @Override + public void setScaleType(ScaleType scaleType) { + if (scaleType != SCALE_TYPE) { + throw new IllegalArgumentException(String.format("ScaleType %s not supported.", scaleType)); + } + } + + @Override + public void setAdjustViewBounds(boolean adjustViewBounds) { + if (adjustViewBounds) { + throw new IllegalArgumentException("adjustViewBounds not supported."); + } + } + + @Override + protected void onDraw(Canvas canvas) { + if (getDrawable() == null) { + return; + } + + canvas.drawCircle(getWidth() / 2, getHeight() / 2, mDrawableRadius, mBitmapPaint); + if (mBorderWidth != 0) { + canvas.drawCircle(getWidth() / 2, getHeight() / 2, mBorderRadius, mBorderPaint); + } + } + + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + super.onSizeChanged(w, h, oldw, oldh); + setup(); + } + + public int getBorderColor() { + return mBorderColor; + } + + public void setBorderColor(int borderColor) { + if (borderColor == mBorderColor) { + return; + } + + mBorderColor = borderColor; + mBorderPaint.setColor(mBorderColor); + invalidate(); + } + + public void setBorderColorResource(@ColorRes int borderColorRes) { + setBorderColor(getContext().getResources().getColor(borderColorRes)); + } + + public int getBorderWidth() { + return mBorderWidth; + } + + public void setBorderWidth(int borderWidth) { + if (borderWidth == mBorderWidth) { + return; + } + + mBorderWidth = borderWidth; + setup(); + } + + public boolean isBorderOverlay() { + return mBorderOverlay; + } + + public void setBorderOverlay(boolean borderOverlay) { + if (borderOverlay == mBorderOverlay) { + return; + } + + mBorderOverlay = borderOverlay; + setup(); + } + + @Override + public void setImageBitmap(Bitmap bm) { + super.setImageBitmap(bm); + mBitmap = bm; + setup(); + } + + @Override + public void setImageDrawable(Drawable drawable) { + super.setImageDrawable(drawable); + mBitmap = getBitmapFromDrawable(drawable); + setup(); + } + + @Override + public void setImageResource(@DrawableRes int resId) { + super.setImageResource(resId); + mBitmap = getBitmapFromDrawable(getDrawable()); + setup(); + } + + @Override + public void setImageURI(Uri uri) { + super.setImageURI(uri); + mBitmap = getBitmapFromDrawable(getDrawable()); + setup(); + } + + @Override + public void setColorFilter(ColorFilter cf) { + if (cf == mColorFilter) { + return; + } + + mColorFilter = cf; + mBitmapPaint.setColorFilter(mColorFilter); + invalidate(); + } + + private Bitmap getBitmapFromDrawable(Drawable drawable) { + if (drawable == null) { + return null; + } + + if (drawable instanceof BitmapDrawable) { + return ((BitmapDrawable) drawable).getBitmap(); + } + + try { + Bitmap bitmap; + + if (drawable instanceof ColorDrawable) { + bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG); + } else { + bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG); + } + + Canvas canvas = new Canvas(bitmap); + drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); + drawable.draw(canvas); + return bitmap; + } catch (OutOfMemoryError e) { + return null; + } + } + + private void setup() { + if (!mReady) { + mSetupPending = true; + return; + } + + if (mBitmap == null) { + return; + } + + mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); + + mBitmapPaint.setAntiAlias(true); + mBitmapPaint.setShader(mBitmapShader); + + mBorderPaint.setStyle(Paint.Style.STROKE); + mBorderPaint.setAntiAlias(true); + mBorderPaint.setColor(mBorderColor); + mBorderPaint.setStrokeWidth(mBorderWidth); + + mBitmapHeight = mBitmap.getHeight(); + mBitmapWidth = mBitmap.getWidth(); + + mBorderRect.set(0, 0, getWidth(), getHeight()); + mBorderRadius = Math.min((mBorderRect.height() - mBorderWidth) / 2, (mBorderRect.width() - mBorderWidth) / 2); + + mDrawableRect.set(mBorderRect); + if (!mBorderOverlay) { + mDrawableRect.inset(mBorderWidth, mBorderWidth); + } + mDrawableRadius = Math.min(mDrawableRect.height() / 2, mDrawableRect.width() / 2); + + updateShaderMatrix(); + invalidate(); + } + + private void updateShaderMatrix() { + float scale; + float dx = 0; + float dy = 0; + + mShaderMatrix.set(null); + + if (mBitmapWidth * mDrawableRect.height() > mDrawableRect.width() * mBitmapHeight) { + scale = mDrawableRect.height() / (float) mBitmapHeight; + dx = (mDrawableRect.width() - mBitmapWidth * scale) * 0.5f; + } else { + scale = mDrawableRect.width() / (float) mBitmapWidth; + dy = (mDrawableRect.height() - mBitmapHeight * scale) * 0.5f; + } + + mShaderMatrix.setScale(scale, scale); + mShaderMatrix.postTranslate((int) (dx + 0.5f) + mDrawableRect.left, (int) (dy + 0.5f) + mDrawableRect.top); + + mBitmapShader.setLocalMatrix(mShaderMatrix); + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/views/ConfirmDialog.java b/app/src/main/java/com/fisherbone/fuzhu/views/ConfirmDialog.java new file mode 100644 index 0000000..9b00956 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/views/ConfirmDialog.java @@ -0,0 +1,70 @@ +package com.fisherbone.fuzhu.views; + +import android.app.Dialog; +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; + +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.config.Callback; + + +/** + * Created by Teprinciple on 2016/10/13. + *

+ * 自定义对话框 + */ +public class ConfirmDialog extends Dialog implements View.OnClickListener { + + Callback callback; + private TextView content; + private TextView sureBtn; + private TextView cancleBtn; + + /** + * 高仿苹果自定义对话框 + * + * @param context + * @param callback + */ + public ConfirmDialog(Context context, Callback callback) { + super(context, R.style.CustomDialog); + this.callback = callback; + setCustomDialog(); + } + + private void setCustomDialog() { + View mView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_confirm, null); + sureBtn = (TextView) mView.findViewById(R.id.dialog_confirm_sure); + cancleBtn = (TextView) mView.findViewById(R.id.dialog_confirm_cancle); + content = (TextView) mView.findViewById(R.id.dialog_confirm_title); + sureBtn.setOnClickListener(this); + cancleBtn.setOnClickListener(this); + super.setContentView(mView); + } + + + public ConfirmDialog setContent(String s) { + content.setText(s); + return this; + } + + + @Override + public void onClick(View v) { + switch (v.getId()) { + case R.id.dialog_confirm_cancle: + callback.Negative(); + this.cancel(); + break; + + case R.id.dialog_confirm_sure: + callback.Positive(); + this.cancel(); + break; + default: + } + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/views/FoldLayout.java b/app/src/main/java/com/fisherbone/fuzhu/views/FoldLayout.java new file mode 100644 index 0000000..88a51b2 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/views/FoldLayout.java @@ -0,0 +1,200 @@ +package com.fisherbone.fuzhu.views; + +import android.animation.ValueAnimator; +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; + +import com.fisherbone.fuzhu.R; + +import java.util.List; + +/** + * ItemFoldLayout + * Created by Song on 2016/11/11. + */ +public class FoldLayout extends LinearLayout implements View.OnClickListener { + + private boolean init; + private int layoutId; + private boolean isShow; + private int contentHeight; + private List itemList; + private LinearLayout content; + private ValueAnimator showAnimator; + private ValueAnimator hideAnimator; + + private OnItemClickListener mOnItemClickListener; + + public FoldLayout(Context context) { + this(context, null); + } + + public FoldLayout(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public FoldLayout(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.FoldLayout, defStyleAttr, 0); + layoutId = ta.getResourceId(R.styleable.FoldLayout_layoutId, -1); + init(context); + } + + private void init(Context context) { + setOrientation(VERTICAL); + addDefaultLayout(context); + } + + /** + * 初始化Menu和Item容器 + * + * @param context + */ + private void addDefaultLayout(Context context) { + + View defaultView = LayoutInflater.from(context).inflate(layoutId, this, true); + defaultView.setOnClickListener(this); + content = new LinearLayout(context); + LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT); + // content.setShowDividers(SHOW_DIVIDER_BEGINNING|SHOW_DIVIDER_MIDDLE); + // content.setDividerDrawable(ContextCompat.getDrawable(context,R.drawable.item_divider)); + content.setOrientation(VERTICAL); + addView(content, layoutParams); + } + + @Override + public void onClick(View v) { +// if(isShow) { +// hideItem(); +// } else { +// showItem(); +// } + } + + /** + * 内容栏的开启 + */ +// public void isopen() { +// if(isShow) { +// hideItem(); +// } else { +// showItem(); +// } +// } + + /** + * 内容栏的开启 + */ + public void isopen() { + showItem(); + + } + + /** + * 内容栏的关闭 + */ + public void isclosed() { + if (isShow) { + hideItem(); + } + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + initAnimation(); + } + + /** + * 动画 + */ + private void initAnimation() { + + contentHeight = content.getMeasuredHeight(); + if (!init) { + showAnimator = ValueAnimator.ofInt(0, contentHeight); + showAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + + LayoutParams layoutParams = (LayoutParams) content.getLayoutParams(); + layoutParams.height = (int) animation.getAnimatedValue(); + content.setLayoutParams(layoutParams); + } + }); + + hideAnimator = ValueAnimator.ofInt(contentHeight, 0); + hideAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + + LayoutParams layoutParams = (LayoutParams) content.getLayoutParams(); + layoutParams.height = (int) animation.getAnimatedValue(); + content.setLayoutParams(layoutParams); + } + }); + init = true; + hide(); + } + } + + /** + * 添加Item + * + * @param views + */ + public void addItemView(List views) { + this.itemList = views; + for (int i = 0; i < views.size(); i++) { + final int position = i; + content.addView(views.get(i)); + views.get(i).setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if (null != mOnItemClickListener) { + mOnItemClickListener.onItemClick(v, position); + } + } + }); + } + } + + /** + * 默认隐藏 + */ + public void hide() { + LayoutParams layoutParams = (LayoutParams) content.getLayoutParams(); + layoutParams.height = 0; + content.setLayoutParams(layoutParams); + } + + /** + * 显示 + */ + public void showItem() { + isShow = true; + showAnimator.start(); + } + + /** + * 隐藏 + */ + public void hideItem() { + isShow = false; + hideAnimator.start(); + } + + interface OnItemClickListener { + void onItemClick(View view, int position); + } + + public void setOnItemClickListener(OnItemClickListener onItemClickListener) { + this.mOnItemClickListener = onItemClickListener; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/views/LoadingDialog.java b/app/src/main/java/com/fisherbone/fuzhu/views/LoadingDialog.java new file mode 100644 index 0000000..6d3ab8c --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/views/LoadingDialog.java @@ -0,0 +1,35 @@ +package com.fisherbone.fuzhu.views; + +import android.app.Dialog; +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextView; + +import com.fisherbone.fuzhu.R; + + +/** + * Created by vicmob_yf002 on 2017/6/21. + *

+ * 读取进度 + */ +public class LoadingDialog extends Dialog { + private TextView content; + + public LoadingDialog(Context context) { + super(context, R.style.CustomDialog); + setCustomDialog(); + } + + private void setCustomDialog() { + View mView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_load, null); + content = (TextView) mView.findViewById(R.id.dialog_customer_title); + super.setContentView(mView); + } + + public LoadingDialog setContent(String s) { + content.setText(s); + return this; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/widget/TitleBar.java b/app/src/main/java/com/fisherbone/fuzhu/widget/TitleBar.java new file mode 100644 index 0000000..ce5027a --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/widget/TitleBar.java @@ -0,0 +1,318 @@ +package com.fisherbone.fuzhu.widget; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.View; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.annotation.ColorRes; +import androidx.annotation.DrawableRes; +import androidx.annotation.StringRes; +import androidx.core.content.ContextCompat; + +import com.fisherbone.fuzhu.R; + + +/** + * Created by Administrator on 2016/12/23. + * 作者:xudiwei + *

+ * 描述:标题栏组合控件 + *

+ * sample: + *

+ * .xml: + *

+ * + *

+ * + *

+ * .java: + *

+ * TitleBar titleBar ....findViewById(R.id...); + * titleBar.setTitle("...") + * ...... + */ + +public class TitleBar extends RelativeLayout implements View.OnClickListener { + + private ImageView mIvLeftBtn; + private ImageView mIvRightBtn; + private TextView mTvtitle; + private OnTitleBarClickListener mListener; + private OnTitleBarAllClickListener mAllClickListener; + private TextView mTvRightText; + private RelativeLayout mRlMain; + private View mVBottomLine; + private View mRootView; + private Button mBtnRed; + + public TitleBar(Context context) { + this(context, null); + } + + public TitleBar(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public TitleBar(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + initView(context); + } + /** + * @description 隐藏横线 + * @param + * @return + */ + public void hideline(){ + mVBottomLine.setVisibility(GONE); + } + private void initView(Context context) { + mRootView = inflate(context, R.layout.widget_title_bar, this); + + //左边按钮 + mIvLeftBtn = (ImageView) mRootView.findViewById(R.id.iv_left_btn); + //右边按扭 + mIvRightBtn = (ImageView) mRootView.findViewById(R.id.iv_right_btn); + //标题 + mTvtitle = (TextView) mRootView.findViewById(R.id.tv_title); + //右边文字按钮 + mTvRightText = (TextView) mRootView.findViewById(R.id.tv_right_text); + + //右边红点 + mBtnRed = (Button) mRootView.findViewById(R.id.btn_red); + + mRlMain = (RelativeLayout) mRootView.findViewById(R.id.rl_main); + // 底部线 + mVBottomLine = mRootView.findViewById(R.id.v_bottom_line); + + mIvLeftBtn.setOnClickListener(this); + mIvRightBtn.setOnClickListener(this); + mTvRightText.setOnClickListener(this); + + } + + /** + * 设置暗黑模式 + */ + public void setDarkTheme() { + mRootView.findViewById(R.id.rl_main).setBackgroundColor(ContextCompat.getColor(getContext(), R.color.colorLightBlack)); + mTvtitle.setTextColor(ContextCompat.getColor(getContext(), R.color.colorWhite)); + mIvLeftBtn.setImageResource(R.mipmap.nav_white_back); + } + + @Override + public void onClick(View view) { + switch (view.getId()) { + //左边按钮 + case R.id.iv_left_btn: + if (null != mListener) { + mListener.onLeftButtonClick(view); + } + if (null != mAllClickListener) { + mAllClickListener.onLeftButtonClick(view); + } + break; + //右边按钮 + case R.id.iv_right_btn: + if (null != mListener) { + mListener.onRightButtonClick(view); + } + if (null != mAllClickListener) { + mAllClickListener.onRightButtonClick(view); + } + break; + //右边文本按钮 + case R.id.tv_right_text: + if (null != mAllClickListener) { + mAllClickListener.onRightTextButtonClick(view); + } + break; + default: + } + } + + /** + * 底部线是否显示,默认是显示 + * + * @param show + */ + public void showBottomLine(boolean show) { + mVBottomLine.setVisibility(show ? View.VISIBLE : View.GONE); + } + + /** + * 显示或隐藏左边按钮 + * + * @param visible + */ + public void visibleIvLeftBtn(boolean visible) { + mIvLeftBtn.setVisibility(visible ? View.VISIBLE : View.GONE); + } + + /** + * 显示或隐藏右边按钮 + * + * @param visible + */ + public void visibleIvRightBtn(boolean visible) { + mIvRightBtn.setVisibility(visible ? View.VISIBLE : View.GONE); + } + + /** + * 显示或隐藏右边文本按钮 + * + * @param visible + */ + public void visibleTvRightTextBtn(boolean visible) { + mTvRightText.setVisibility(visible ? View.VISIBLE : View.GONE); + } + + /** + * 显示或隐藏右边红点 + * + * @param visible + */ + public void visibleRightRedDot(boolean visible) { + mBtnRed.setVisibility(visible ? View.VISIBLE : View.GONE); + } + + /** + * 设置左边按钮图标 + * + * @param ids + */ + public void setIvLeftBtnDrawable(@DrawableRes int ids) { + mIvLeftBtn.setImageResource(ids); + } + + /** + * 设置右边按钮图标 + * + * @param ids + */ + public void setIvRightBtnDrawable(@DrawableRes int ids) { + mIvRightBtn.setImageResource(ids); + } + + /** + * 设置标题 + * + * @param ids + */ + public void setTitle(@StringRes int ids) { + setTitle(getContext().getResources().getString(ids)); + } + + /** + * 设置标题 + * + * @param titleText + */ + public void setTitle(String titleText) { + mTvtitle.setText(titleText); + } + + /** + * 设置标题颜色 + * + * @param colorIds + */ + public void setTitleColor(@ColorRes int colorIds) { + mTvtitle.setTextColor(getResources().getColor(colorIds)); + } + + /** + * 设置标题背景色 + * + * @param colorIds + */ + public void setTitleBg(@ColorRes int colorIds) { + mRlMain.setBackgroundResource(colorIds); + } + + /** + * 设置右边文本按钮的文本 + * + * @param rightButtonText + */ + public void setTvRightText(String rightButtonText) { + mTvRightText.setText(rightButtonText); + } + + /** + * 设置右边文本按钮的颜色 + * + * @param color + */ + public void setTvRightTextColor(@ColorRes int color) { + mTvRightText.setTextColor(getResources().getColor(color)); + } + + /** + * 设置右边文本使能 + * @param enable + */ + public void setTvRightTextEnable(boolean enable){ + mTvRightText.setEnabled(enable); + } + + /** + * 设置标题栏点击事件监听器这个监听器只响应左边按钮与右边按钮。若还想响应右边 + * 文本按的按钮请使用{@link #setOnTitleBarAllClickListener(OnTitleBarAllClickListener)} + * + * @param clickListener {@link OnTitleBarClickListener} + */ + public void setOnTitleBarClickListener(OnTitleBarClickListener clickListener) { + this.mListener = clickListener; + } + + /** + * 设置标题栏的上的按钮全部点击事件监听器能响应左边按钮,右边按钮,右边文本按钮 + * + * @param clickListener + */ + public void setOnTitleBarAllClickListener(OnTitleBarAllClickListener clickListener) { + this.mAllClickListener = clickListener; + } + + + /** + * 标题栏的点击事件回调接口,响应两个按钮的 + */ + public interface OnTitleBarClickListener { + /** + * 左边按钮被点击 + * + * @param view + */ + void onLeftButtonClick(View view); + + /** + * 右边按钮被点击 + * + * @param view + */ + void onRightButtonClick(View view); + } + + /** + * 标题栏的点击事件回调接口,响应三个按钮的 + */ + public interface OnTitleBarAllClickListener extends OnTitleBarClickListener { + /** + * 右边文本按钮点击事件 + * + * @param view + */ + void onRightTextButtonClick(View view); + + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/widget/streamlist/Contant.java b/app/src/main/java/com/fisherbone/fuzhu/widget/streamlist/Contant.java new file mode 100644 index 0000000..4a914e8 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/widget/streamlist/Contant.java @@ -0,0 +1,13 @@ +package com.fisherbone.fuzhu.widget.streamlist; + +/** + * Created by Administrator on 2017/3/15 0015. + */ + +public class Contant { + + public static final int ONLY_TEXT = 0; + public static final int TEXT_DELETE = 1; + public static final int VIEW_TEXT = 2; + public static final int VIEW_TEXT_DELETE = 3; +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/widget/streamlist/StreamList.java b/app/src/main/java/com/fisherbone/fuzhu/widget/streamlist/StreamList.java new file mode 100644 index 0000000..43022f2 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/widget/streamlist/StreamList.java @@ -0,0 +1,306 @@ +package com.fisherbone.fuzhu.widget.streamlist; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Color; +import android.util.AttributeSet; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.entity.dakaVideoListBean; + +import java.util.List; + +/** + * Created by Administrator on 2017/3/15 0015. + */ + +public class StreamList extends ViewGroup implements View.OnClickListener { + + private int horizontalSpace = 10; + + private int verticalSpace = 10; + + private int type = Contant.ONLY_TEXT; + + private int textSize = 15; + + private int textColor = Color.parseColor("#000000"); + + private int viewid = -1; + + addDakaCallBack adddakaCallBack; + + public StreamList(Context context) { + super(context); + } + + public StreamList(Context context, AttributeSet attrs) { + super(context, attrs); + TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.item); + textSize = typedArray.getInteger(R.styleable.item_textSize, 15); + horizontalSpace = typedArray.getInteger(R.styleable.item_horizontalSpace, 10); + verticalSpace = typedArray.getInteger(R.styleable.item_verticalSpace, 10); + String string = typedArray.getString(R.styleable.item_textColor); + if (string != null) { + textColor = Color.parseColor(string); + } + typedArray.recycle(); + } + List list; + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + int count = getChildCount(); + int maxWidth = 0; + int maxHeight = 0; + + int viewWidth = getMeasuredWidth(); + + for (int i = 0; i < count; i++) { + + View childAt = getChildAt(i); + + if (maxWidth + childAt.getMeasuredWidth() + getPaddingLeft() + getPaddingRight() <= viewWidth) { + childAt.layout(getPaddingLeft() + maxWidth, getPaddingTop() + maxHeight, getPaddingLeft() + maxWidth + childAt.getMeasuredWidth(), getPaddingTop() + maxHeight + childAt.getMeasuredHeight()); + maxWidth += childAt.getMeasuredWidth() + horizontalSpace; + } else { + maxHeight += childAt.getMeasuredHeight() + verticalSpace; + maxWidth = 0; + childAt.layout(getPaddingLeft() + maxWidth, getPaddingTop() + maxHeight, getPaddingLeft() + maxWidth + childAt.getMeasuredWidth(), getPaddingTop() + maxHeight + childAt.getMeasuredHeight()); + maxWidth += childAt.getMeasuredWidth() + horizontalSpace; + } + } + } + + public void setType(int type) { + this.type = type; + } + + public void setViewResouce(int view) { + this.viewid = view; + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + int count = getChildCount(); + int maxWidth = 0; + int maxHeight = 0; + + int viewWidth = MeasureSpec.getSize(widthMeasureSpec); + + for (int i = 0; i < count; i++) { + + View childAt = getChildAt(i); + measureChild(childAt, widthMeasureSpec, heightMeasureSpec); + + if (maxWidth + childAt.getMeasuredWidth() + getPaddingLeft() + getPaddingRight() <= viewWidth) { + maxWidth += childAt.getMeasuredWidth() + horizontalSpace; + if (maxHeight == 0) { + maxHeight = childAt.getMeasuredHeight(); + } + } else { + maxHeight += childAt.getMeasuredHeight() + verticalSpace; + maxWidth = 0; + maxWidth += childAt.getMeasuredWidth() + horizontalSpace; + } + } + setMeasuredDimension(viewWidth, maxHeight + getPaddingTop() + getPaddingBottom()); + } + + public void setData(List list) { + this.list=list; + if (type == Contant.ONLY_TEXT) { + for (int i = 0; i < list.size(); i++) { + + + // addView(getTextView(list.get(i))); + } + } else if (type == Contant.TEXT_DELETE) { + + for (int i = 0; i < list.size(); i++) { + View view = getView(list.get(i)); + addView(view); + } + View addView = getAddView("+"); + addView(addView); + } else if (type == Contant.VIEW_TEXT_DELETE) { + if (viewid == -1) { + throw new RuntimeException("must call setViewResouce()"); + } else { + for (int i = 0; i < list.size(); i++) { + addView(getCusView(list.get(i))); + } + } + } else if (type == Contant.VIEW_TEXT) { + if (viewid == -1) { + throw new RuntimeException("must call setViewResouce()"); + } else { + for (int i = 0; i < list.size(); i++) { + TextView textView = (TextView) View.inflate(getContext(), viewid, null); + textView.setText(list.get(i).getName()); + addView(textView); + } + } + } + invalidate(); + } + + + private View getCusView(dakaVideoListBean.DataBean string) { + View view = View.inflate(getContext(), viewid, null); + ImageView imageView = (ImageView) view.findViewById(R.id.iv_delete); + TextView textView = (TextView) view.findViewById(R.id.tv_item); + if (imageView == null || textView == null) { + throw new RuntimeException("the child id must is tv_item and iv_delete"); + } + textView.setText(string.getName()); + imageView.setOnClickListener(this); + return view; + } + + public void removeAllView() { + // removeAllView(); + + removeAllViewsInLayout(); + requestLayout(); + invalidate(); + } + + private View getView(final dakaVideoListBean.DataBean item) { + View view = View.inflate(getContext(), R.layout.item_text_delete, null); + ImageView imageView = (ImageView) view.findViewById(R.id.iv_delete); + TextView textView = (TextView) view.findViewById(R.id.tv_item); + LinearLayout ly_01 = (LinearLayout) view.findViewById(R.id.ly_01); + textView.setText(item.getName()); +// textView.setTextColor(textColor); +// textView.setTextSize(textSize); + imageView.setOnClickListener(this); + // textView.setOnClickListener(this); + if(item.isIsseclect()){ + ly_01.setBackgroundResource(R.drawable.shape_xuanzhong); + textView.setTextColor(Color.parseColor("#ffffff")); + }else { + ly_01.setBackgroundResource(R.drawable.shape); + textView.setTextColor(Color.parseColor("#B9B9B9")); + } + imageView.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + LinearLayout parent = (LinearLayout) v.getParent(); + removeView(parent); + adddakaCallBack.deleteDaka(item.getId()); + } + }); + textView.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + Log.e("点击了",item+""); + // Toast.makeText(getContext(), "点击了"+item, Toast.LENGTH_SHORT).show(); + + removeAllView(); + + + if(!item.isIsseclect()){ + for(int i=0;i key); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/widget/streamlist/dataBean.java b/app/src/main/java/com/fisherbone/fuzhu/widget/streamlist/dataBean.java new file mode 100644 index 0000000..e041dc4 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/widget/streamlist/dataBean.java @@ -0,0 +1,33 @@ +package com.fisherbone.fuzhu.widget.streamlist; + +/** + * Time: 2021/4/19 + * Author: jianbo + * Description: + */ +public class dataBean { + private String content=""; + + public String getContent() { + return content; + } + + public dataBean(String content, boolean isseclect) { + this.content = content; + this.isseclect = isseclect; + } + + public void setContent(String content) { + this.content = content; + } + + public boolean isIsseclect() { + return isseclect; + } + + public void setIsseclect(boolean isseclect) { + this.isseclect = isseclect; + } + + private boolean isseclect=false; +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/activity/CaptureActivity.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/activity/CaptureActivity.java new file mode 100644 index 0000000..acb6a70 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/activity/CaptureActivity.java @@ -0,0 +1,358 @@ +package com.fisherbone.fuzhu.zxing.activity; + +import android.app.ProgressDialog; +import android.content.Intent; +import android.content.res.AssetFileDescriptor; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.media.AudioManager; +import android.media.MediaPlayer; +import android.media.MediaPlayer.OnCompletionListener; +import android.os.Bundle; +import android.os.Handler; +import android.os.Vibrator; +import android.text.TextUtils; +import android.view.SurfaceHolder; +import android.view.SurfaceHolder.Callback; +import android.view.SurfaceView; +import android.view.View; +import android.widget.Button; +import android.widget.LinearLayout; +import android.widget.TextView; +import android.widget.Toast; + +import com.fisherbone.fuzhu.BaseActivity; +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.activity.ShouQuanActivity; +import com.fisherbone.fuzhu.utils.JumpUtils; +import com.fisherbone.fuzhu.utils.ToastUtils; +import com.fisherbone.fuzhu.zxing.camera.CameraManager; +import com.fisherbone.fuzhu.zxing.decoding.CaptureActivityHandler; +import com.fisherbone.fuzhu.zxing.decoding.InactivityTimer; +import com.fisherbone.fuzhu.zxing.decoding.RGBLuminanceSource; +import com.fisherbone.fuzhu.zxing.view.ViewfinderView; +import com.google.zxing.BarcodeFormat; +import com.google.zxing.BinaryBitmap; +import com.google.zxing.ChecksumException; +import com.google.zxing.DecodeHintType; +import com.google.zxing.FormatException; +import com.google.zxing.NotFoundException; +import com.google.zxing.Result; +import com.google.zxing.common.HybridBinarizer; +import com.google.zxing.qrcode.QRCodeReader; + +import java.io.IOException; +import java.util.Hashtable; +import java.util.Vector; + + +/** + * Initial the camera + * + * @author Ryan.Tang + */ +public class CaptureActivity extends BaseActivity implements Callback, View.OnClickListener { + + private static final int REQUEST_CODE_SCAN_GALLERY = 100; + + private CaptureActivityHandler handler; + private ViewfinderView viewfinderView; + + private boolean hasSurface; + private Vector decodeFormats; + private String characterSet; + private InactivityTimer inactivityTimer; + private MediaPlayer mediaPlayer; + private boolean playBeep; + private static final float BEEP_VOLUME = 0.10f; + private boolean vibrate; + private ProgressDialog mProgress; + private String photo_path; + private Bitmap scanBitmap; + // private Button cancelScanButton; + SurfaceView surfaceView; + SurfaceHolder surfaceHolder; + String storeId = "";//商家id + String onlyId = "";//时间戳 + String price = ""; + private Button mBtnBack; + private TextView mTvTitle; + private String type=""; + private LinearLayout ll_scan_code; + + /** + * Called when the activity is first created. + */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_scanner); + type = getIntent().getStringExtra("type"); + initView(); + hasSurface = false; + CameraManager.init(getApplication()); + viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_content); + ll_scan_code = (LinearLayout) findViewById(R.id.ll_scan_code); + inactivityTimer = new InactivityTimer(this); + ll_scan_code.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ToastUtils.showToast(CaptureActivity.this, "点击了输入激活码"); + JumpUtils.gotoActivity(CaptureActivity.this, ShouQuanActivity.class, false, "", ""); + finish(); + } + }); + + } + + + //方法一:用JAVA自带的函数 + public boolean isNumeric(String str) { + for (int i = str.length(); --i >= 0; ) { + if (!Character.isDigit(str.charAt(i))) { + return false; + } + } + return true; + } + + /** + * 扫描二维码图片的方法 + * + * @param path + * @return + */ + public Result scanningImage(String path) { + if (TextUtils.isEmpty(path)) { + return null; + } + Hashtable hints = new Hashtable<>(); + hints.put(DecodeHintType.CHARACTER_SET, "UTF8"); //设置二维码内容的编码 + + BitmapFactory.Options options = new BitmapFactory.Options(); + options.inJustDecodeBounds = true; // 先获取原大小 + scanBitmap = BitmapFactory.decodeFile(path, options); + options.inJustDecodeBounds = false; // 获取新的大小 + int sampleSize = (int) (options.outHeight / (float) 200); + if (sampleSize <= 0) + sampleSize = 1; + options.inSampleSize = sampleSize; + scanBitmap = BitmapFactory.decodeFile(path, options); + RGBLuminanceSource source = new RGBLuminanceSource(scanBitmap); + BinaryBitmap bitmap1 = new BinaryBitmap(new HybridBinarizer(source)); + QRCodeReader reader = new QRCodeReader(); + try { + return reader.decode(bitmap1, hints); + } catch (NotFoundException e) { + e.printStackTrace(); + } catch (ChecksumException e) { + e.printStackTrace(); + } catch (FormatException e) { + e.printStackTrace(); + } + return null; + } + + @Override + protected void onResume() { + super.onResume(); + surfaceView = (SurfaceView) findViewById(R.id.scanner_view); + surfaceHolder = surfaceView.getHolder(); + if (hasSurface) { + initCamera(surfaceHolder); + } else { + surfaceHolder.addCallback(this); + surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); + } + decodeFormats = null; + characterSet = null; + + playBeep = true; + AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE); + if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) { + playBeep = false; + } + initBeepSound(); + vibrate = true; + + //quit the scan view +// cancelScanButton.setOnClickListener(new OnClickListener() { +// +// @Override +// public void onClick(View v) { +// CaptureActivity.this.finish(); +// } +// }); + } + + @Override + protected void onPause() { + super.onPause(); + if (handler != null) { + handler.quitSynchronously(); + handler = null; + } + CameraManager.get().closeDriver(); + } + + @Override + protected void onDestroy() { + inactivityTimer.shutdown(); + super.onDestroy(); + } + + /** + * Handler scan result + * + * @param result + * @param barcode + */ + public void handleDecode(Result result, Bitmap barcode) { + inactivityTimer.onActivity(); + playBeepSoundAndVibrate(); + String resultString = result.getText(); + //FIXME + if (TextUtils.isEmpty(resultString)) { + Toast.makeText(CaptureActivity.this, "扫码失败", Toast.LENGTH_SHORT).show(); + } else { + + +// Intent mIntent = new Intent(); +// mIntent.putExtra("SCAN_RESULT", result.getText()); +// this.setResult(RESULT_OK, mIntent); + + + Intent mIntent = new Intent(); + mIntent.putExtra("SCAN_RESULT", result.getText()); + this.setResult(RESULT_OK, mIntent); + + + } + CaptureActivity.this.finish(); + } + + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (resultCode == RESULT_OK) { + + if (requestCode == 0x121) { + this.finish(); + } + + } + } + + private void initCamera(SurfaceHolder surfaceHolder) { + try { + CameraManager.get().openDriver(surfaceHolder); + } catch (IOException ioe) { + return; + } catch (RuntimeException e) { + return; + } + if (handler == null) { + handler = new CaptureActivityHandler(this, decodeFormats, + characterSet); + } + } + + @Override + public void surfaceChanged(SurfaceHolder holder, int format, int width, + int height) { + + } + + @Override + public void surfaceCreated(SurfaceHolder holder) { + if (!hasSurface) { + hasSurface = true; + initCamera(holder); + } + + } + + @Override + public void surfaceDestroyed(SurfaceHolder holder) { + hasSurface = false; + + } + + public ViewfinderView getViewfinderView() { + return viewfinderView; + } + + public Handler getHandler() { + return handler; + } + + public void drawViewfinder() { + viewfinderView.drawViewfinder(); + + } + + private void initBeepSound() { + if (playBeep && mediaPlayer == null) { + // The volume on STREAM_SYSTEM is not adjustable, and users found it + // too loud, + // so we now play on the music stream. + setVolumeControlStream(AudioManager.STREAM_MUSIC); + mediaPlayer = new MediaPlayer(); + mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); + mediaPlayer.setOnCompletionListener(beepListener); + + AssetFileDescriptor file = getResources().openRawResourceFd( + R.raw.beep); + try { + mediaPlayer.setDataSource(file.getFileDescriptor(), + file.getStartOffset(), file.getLength()); + file.close(); + mediaPlayer.setVolume(BEEP_VOLUME, BEEP_VOLUME); + mediaPlayer.prepare(); + } catch (IOException e) { + mediaPlayer = null; + } + } + } + + private static final long VIBRATE_DURATION = 200L; + + private void playBeepSoundAndVibrate() { + if (playBeep && mediaPlayer != null) { + mediaPlayer.start(); + } + if (vibrate) { + Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); + vibrator.vibrate(VIBRATE_DURATION); + } + } + + /** + * When the beep has finished playing, rewind to queue up another one. + */ + private final OnCompletionListener beepListener = new OnCompletionListener() { + public void onCompletion(MediaPlayer mediaPlayer) { + mediaPlayer.seekTo(0); + } + }; + + + private void initView() { + mBtnBack = (Button) findViewById(R.id.btn_back); + mBtnBack.setOnClickListener(this); + mTvTitle = (TextView) findViewById(R.id.tv_title); + mTvTitle.setText("激活授权"); + } + + @Override + public void onClick(View v) { + switch (v.getId()) { + default: + break; + case R.id.btn_back: + finish(); + break; + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/AutoFocusCallback.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/AutoFocusCallback.java new file mode 100644 index 0000000..fdc8e55 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/AutoFocusCallback.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.zxing.camera; + +import android.hardware.Camera; +import android.os.Handler; +import android.os.Message; +import android.util.Log; + +final class AutoFocusCallback implements Camera.AutoFocusCallback { + + private static final String TAG = AutoFocusCallback.class.getSimpleName(); + + private static final long AUTOFOCUS_INTERVAL_MS = 1500L; + + private Handler autoFocusHandler; + private int autoFocusMessage; + + void setHandler(Handler autoFocusHandler, int autoFocusMessage) { + this.autoFocusHandler = autoFocusHandler; + this.autoFocusMessage = autoFocusMessage; + } + + public void onAutoFocus(boolean success, Camera camera) { + if (autoFocusHandler != null) { + Message message = autoFocusHandler.obtainMessage(autoFocusMessage, success); + autoFocusHandler.sendMessageDelayed(message, AUTOFOCUS_INTERVAL_MS); + autoFocusHandler = null; + } else { + Log.d(TAG, "Got auto-focus callback, but no handler for it"); + } + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/CameraConfigurationManager.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/CameraConfigurationManager.java new file mode 100644 index 0000000..210e960 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/CameraConfigurationManager.java @@ -0,0 +1,278 @@ +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.zxing.camera; + +import android.content.Context; +import android.graphics.Point; +import android.hardware.Camera; +import android.os.Build; +import android.util.Log; +import android.view.Display; +import android.view.WindowManager; + +import java.util.regex.Pattern; + +final class CameraConfigurationManager { + + private static final String TAG = CameraConfigurationManager.class.getSimpleName(); + + private static final int TEN_DESIRED_ZOOM = 27; + private static final int DESIRED_SHARPNESS = 30; + + private static final Pattern COMMA_PATTERN = Pattern.compile(","); + + private final Context context; + private Point screenResolution; + private Point cameraResolution; + private int previewFormat; + private String previewFormatString; + + CameraConfigurationManager(Context context) { + this.context = context; + } + + /** + * Reads, one time, values from the camera that are needed by the app. + */ + void initFromCameraParameters(Camera camera) { + Camera.Parameters parameters = camera.getParameters(); + previewFormat = parameters.getPreviewFormat(); + previewFormatString = parameters.get("preview-format"); + Log.d(TAG, "Default preview format: " + previewFormat + '/' + previewFormatString); + WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); + Display display = manager.getDefaultDisplay(); + screenResolution = new Point(display.getWidth(), display.getHeight()); + Log.d(TAG, "Screen resolution: " + screenResolution); + + //图片拉伸 + Point screenResolutionForCamera = new Point(); + screenResolutionForCamera.x = screenResolution.x; + screenResolutionForCamera.y = screenResolution.y; + // preview size is always something like 480*320, other 320*480 + if (screenResolution.x < screenResolution.y) { + screenResolutionForCamera.x = screenResolution.y; + screenResolutionForCamera.y = screenResolution.x; + } + + cameraResolution = getCameraResolution(parameters, screenResolutionForCamera); + Log.d(TAG, "Camera resolution: " + screenResolution); + + } + + /** + * Sets the camera up to take preview images which are used for both preview and decoding. + * We detect the preview format here so that buildLuminanceSource() can build an appropriate + * LuminanceSource subclass. In the future we may want to force YUV420SP as it's the smallest, + * and the planar Y can be used for barcode scanning without a copy in some cases. + */ + void setDesiredCameraParameters(Camera camera) { + Camera.Parameters parameters = camera.getParameters(); + Log.d(TAG, "Setting preview size: " + cameraResolution); + parameters.setPreviewSize(cameraResolution.x, cameraResolution.y); + setFlash(parameters); + setZoom(parameters); + //setSharpness(parameters); + //modify here + camera.setDisplayOrientation(90); + camera.setParameters(parameters); + } + + Point getCameraResolution() { + return cameraResolution; + } + + Point getScreenResolution() { + return screenResolution; + } + + int getPreviewFormat() { + return previewFormat; + } + + String getPreviewFormatString() { + return previewFormatString; + } + + private static Point getCameraResolution(Camera.Parameters parameters, Point screenResolution) { + + String previewSizeValueString = parameters.get("preview-size-values"); + // saw this on Xperia + if (previewSizeValueString == null) { + previewSizeValueString = parameters.get("preview-size-value"); + } + + Point cameraResolution = null; + + if (previewSizeValueString != null) { + Log.d(TAG, "preview-size-values parameter: " + previewSizeValueString); + cameraResolution = findBestPreviewSizeValue(previewSizeValueString, screenResolution); + } + + if (cameraResolution == null) { + // Ensure that the camera resolution is a multiple of 8, as the screen may not be. + cameraResolution = new Point( + (screenResolution.x >> 3) << 3, + (screenResolution.y >> 3) << 3); + } + + return cameraResolution; + } + + private static Point findBestPreviewSizeValue(CharSequence previewSizeValueString, Point screenResolution) { + int bestX = 0; + int bestY = 0; + int diff = Integer.MAX_VALUE; + for (String previewSize : COMMA_PATTERN.split(previewSizeValueString)) { + + previewSize = previewSize.trim(); + int dimPosition = previewSize.indexOf('x'); + if (dimPosition < 0) { + Log.w(TAG, "Bad preview-size: " + previewSize); + continue; + } + + int newX; + int newY; + try { + newX = Integer.parseInt(previewSize.substring(0, dimPosition)); + newY = Integer.parseInt(previewSize.substring(dimPosition + 1)); + } catch (NumberFormatException nfe) { + Log.w(TAG, "Bad preview-size: " + previewSize); + continue; + } + + int newDiff = Math.abs(newX - screenResolution.x) + Math.abs(newY - screenResolution.y); + if (newDiff == 0) { + bestX = newX; + bestY = newY; + break; + } else if (newDiff < diff) { + bestX = newX; + bestY = newY; + diff = newDiff; + } + + } + + if (bestX > 0 && bestY > 0) { + return new Point(bestX, bestY); + } + return null; + } + + private static int findBestMotZoomValue(CharSequence stringValues, int tenDesiredZoom) { + int tenBestValue = 0; + for (String stringValue : COMMA_PATTERN.split(stringValues)) { + stringValue = stringValue.trim(); + double value; + try { + value = Double.parseDouble(stringValue); + } catch (NumberFormatException nfe) { + return tenDesiredZoom; + } + int tenValue = (int) (10.0 * value); + if (Math.abs(tenDesiredZoom - value) < Math.abs(tenDesiredZoom - tenBestValue)) { + tenBestValue = tenValue; + } + } + return tenBestValue; + } + + private void setFlash(Camera.Parameters parameters) { + // FIXME: This is a hack to turn the flash off on the Samsung Galaxy. + // And this is a hack-hack to work around a different value on the Behold II + // Restrict Behold II check to Cupcake, per Samsung's advice + //if (Build.MODEL.contains("Behold II") && + // CameraManager.SDK_INT == Build.VERSION_CODES.CUPCAKE) { + if (Build.MODEL.contains("Behold II") && CameraManager.SDK_INT == 3) { // 3 = Cupcake + parameters.set("flash-value", 1); + } else { + parameters.set("flash-value", 2); + } + // This is the standard setting to turn the flash off that all devices should honor. + parameters.set("flash-mode", "off"); + } + + private void setZoom(Camera.Parameters parameters) { + + String zoomSupportedString = parameters.get("zoom-supported"); + if (zoomSupportedString != null && !Boolean.parseBoolean(zoomSupportedString)) { + return; + } + + int tenDesiredZoom = TEN_DESIRED_ZOOM; + + String maxZoomString = parameters.get("max-zoom"); + if (maxZoomString != null) { + try { + int tenMaxZoom = (int) (10.0 * Double.parseDouble(maxZoomString)); + if (tenDesiredZoom > tenMaxZoom) { + tenDesiredZoom = tenMaxZoom; + } + } catch (NumberFormatException nfe) { + Log.w(TAG, "Bad max-zoom: " + maxZoomString); + } + } + + String takingPictureZoomMaxString = parameters.get("taking-picture-zoom-max"); + if (takingPictureZoomMaxString != null) { + try { + int tenMaxZoom = Integer.parseInt(takingPictureZoomMaxString); + if (tenDesiredZoom > tenMaxZoom) { + tenDesiredZoom = tenMaxZoom; + } + } catch (NumberFormatException nfe) { + Log.w(TAG, "Bad taking-picture-zoom-max: " + takingPictureZoomMaxString); + } + } + + String motZoomValuesString = parameters.get("mot-zoom-values"); + if (motZoomValuesString != null) { + tenDesiredZoom = findBestMotZoomValue(motZoomValuesString, tenDesiredZoom); + } + + String motZoomStepString = parameters.get("mot-zoom-step"); + if (motZoomStepString != null) { + try { + double motZoomStep = Double.parseDouble(motZoomStepString.trim()); + int tenZoomStep = (int) (10.0 * motZoomStep); + if (tenZoomStep > 1) { + tenDesiredZoom -= tenDesiredZoom % tenZoomStep; + } + } catch (NumberFormatException nfe) { + // continue + } + } + + // Set zoom. This helps encourage the user to pull back. + // Some devices like the Behold have a zoom parameter + if (maxZoomString != null || motZoomValuesString != null) { + parameters.set("zoom", String.valueOf(tenDesiredZoom / 10.0)); + } + + // Most devices, like the Hero, appear to expose this zoom parameter. + // It takes on values like "27" which appears to mean 2.7x zoom + if (takingPictureZoomMaxString != null) { + parameters.set("taking-picture-zoom", tenDesiredZoom); + } + } + + public static int getDesiredSharpness() { + return DESIRED_SHARPNESS; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/CameraManager.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/CameraManager.java new file mode 100644 index 0000000..6f1fabf --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/CameraManager.java @@ -0,0 +1,356 @@ +/* + * Copyright (C) 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.zxing.camera; + +import android.content.Context; +import android.graphics.PixelFormat; +import android.graphics.Point; +import android.graphics.Rect; +import android.hardware.Camera; +import android.os.Build; +import android.os.Handler; +import android.view.SurfaceHolder; + +import java.io.IOException; + +/** + * This object wraps the Camera service object and expects to be the only one talking to it. The + * implementation encapsulates the steps needed to take preview-sized images, which are used for + * both preview and decoding. + * + */ +public final class CameraManager { + + private static final String TAG = CameraManager.class.getSimpleName(); + + private static final int MIN_FRAME_WIDTH = 240; + private static final int MIN_FRAME_HEIGHT = 240; + private static final int MAX_FRAME_WIDTH = 480; + private static final int MAX_FRAME_HEIGHT = 360; + + private static CameraManager cameraManager; + + static final int SDK_INT; // Later we can use Build.VERSION.SDK_INT + static { + int sdkInt; + try { + sdkInt = Integer.parseInt(Build.VERSION.SDK); + } catch (NumberFormatException nfe) { + // Just to be safe + sdkInt = 10000; + } + SDK_INT = sdkInt; + } + + private final Context context; + private final CameraConfigurationManager configManager; + private Camera camera; + private Rect framingRect; + private Rect framingRectInPreview; + private boolean initialized; + private boolean previewing; + private final boolean useOneShotPreviewCallback; + /** + * Preview frames are delivered here, which we pass on to the registered handler. Make sure to + * clear the handler so it will only receive one message. + */ + private final PreviewCallback previewCallback; + /** Autofocus callbacks arrive here, and are dispatched to the Handler which requested them. */ + private final AutoFocusCallback autoFocusCallback; + + /** + * Initializes this static object with the Context of the calling Activity. + * + * @param context The Activity which wants to use the camera. + */ + public static void init(Context context) { + if (cameraManager == null) { + cameraManager = new CameraManager(context); + } + } + + /** + * Gets the CameraManager singleton instance. + * + * @return A reference to the CameraManager singleton. + */ + public static CameraManager get() { + return cameraManager; + } + + private CameraManager(Context context) { + + this.context = context; + this.configManager = new CameraConfigurationManager(context); + + // Camera.setOneShotPreviewCallback() has a race condition in Cupcake, so we use the older + // Camera.setPreviewCallback() on 1.5 and earlier. For Donut and later, we need to use + // the more efficient one shot callback, as the older one can swamp the system and cause it + // to run out of memory. We can't use SDK_INT because it was introduced in the Donut SDK. + //useOneShotPreviewCallback = Integer.parseInt(Build.VERSION.SDK) > Build.VERSION_CODES.CUPCAKE; + useOneShotPreviewCallback = Integer.parseInt(Build.VERSION.SDK) > 3; // 3 = Cupcake + + previewCallback = new PreviewCallback(configManager, useOneShotPreviewCallback); + autoFocusCallback = new AutoFocusCallback(); + } + + /** + * Opens the camera driver and initializes the hardware parameters. + * + * @param holder The surface object which the camera will draw preview frames into. + * @throws IOException Indicates the camera driver failed to open. + */ + public void openDriver(SurfaceHolder holder) throws IOException { + if (camera == null) { + camera = Camera.open(); + if (camera == null) { + throw new IOException(); + } + camera.setPreviewDisplay(holder); + + if (!initialized) { + initialized = true; + configManager.initFromCameraParameters(camera); + } + configManager.setDesiredCameraParameters(camera); + + //FIXME + // SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + //�Ƿ�ʹ��ǰ�� +// if (prefs.getBoolean(PreferencesActivity.KEY_FRONT_LIGHT, false)) { +// FlashlightManager.enableFlashlight(); +// } + FlashlightManager.enableFlashlight(); + } + } + + /** + * Closes the camera driver if still in use. + */ + public void closeDriver() { + if (camera != null) { + FlashlightManager.disableFlashlight(); + if (previewing) { + camera.stopPreview(); + } + + camera.release(); + camera = null; + previewing=false; + } + } + + /** + * Asks the camera hardware to begin drawing preview frames to the screen. + */ + public void startPreview() { + if (camera != null && !previewing) { + camera.startPreview(); + previewing = true; + } + } + + /** + * Tells the camera to stop drawing preview frames. + */ + public void stopPreview() { + if (camera != null && previewing) { + if (!useOneShotPreviewCallback) { + camera.setPreviewCallback(null); + } + camera.stopPreview(); + previewCallback.setHandler(null, 0); + autoFocusCallback.setHandler(null, 0); + previewing = false; + } + } + + /** + * A single preview frame will be returned to the handler supplied. The data will arrive as byte[] + * in the message.obj field, with width and height encoded as message.arg1 and message.arg2, + * respectively. + * + * @param handler The handler to send the message to. + * @param message The what field of the message to be sent. + */ + public void requestPreviewFrame(Handler handler, int message) { + if (camera != null && previewing) { + previewCallback.setHandler(handler, message); + if (useOneShotPreviewCallback) { + camera.setOneShotPreviewCallback(previewCallback); + } else { + camera.setPreviewCallback(previewCallback); + } + } + } + + /** + * Asks the camera hardware to perform an autofocus. + * + * @param handler The Handler to notify when the autofocus completes. + * @param message The message to deliver. + */ + public void requestAutoFocus(Handler handler, int message) { + if (camera != null && previewing) { + autoFocusCallback.setHandler(handler, message); + //Log.d(TAG, "Requesting auto-focus callback"); + camera.autoFocus(autoFocusCallback); + } + } + + /** + * Calculates the framing rect which the UI should draw to show the user where to place the + * barcode. This target helps with alignment as well as forces the user to hold the device + * far enough away to ensure the image will be in focus. + * + * @return The rectangle to draw on screen in window coordinates. + */ + public Rect getFramingRect() { + Point screenResolution = configManager.getScreenResolution(); + if(screenResolution == null) + return null; + if (framingRect == null) { + if (camera == null) { + return null; + } + + //修改之后 + int width = screenResolution.x * 7 / 10; + int height = screenResolution.y * 7 / 10; + + if(height >= width) { //竖屏 + height = width; + } else { //黑屏 + width = height; + } + + int leftOffset = (screenResolution.x - width) / 2; + int topOffset = (screenResolution.y - height) / 2; + framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height); + + } + return framingRect; + } +// public Rect getFramingRect() { +// Point screenResolution = configManager.getScreenResolution(); +// if (framingRect == null) { +// if (camera == null) { +// return null; +// } +// int width = screenResolution.x * 3 / 4; +// if (width < MIN_FRAME_WIDTH) { +// width = MIN_FRAME_WIDTH; +// } else if (width > MAX_FRAME_WIDTH) { +// width = MAX_FRAME_WIDTH; +// } +// int height = screenResolution.y * 3 / 4; +// if (height < MIN_FRAME_HEIGHT) { +// height = MIN_FRAME_HEIGHT; +// } else if (height > MAX_FRAME_HEIGHT) { +// height = MAX_FRAME_HEIGHT; +// } +// int leftOffset = (screenResolution.x - width) / 2; +// int topOffset = (screenResolution.y - height) / 2; +// framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height); +// Log.d(TAG, "Calculated framing rect: " + framingRect); +// } +// return framingRect; +// } + + /** + * Like {@link #getFramingRect} but coordinates are in terms of the preview frame, + * not UI / screen. + */ + public Rect getFramingRectInPreview() { + if (framingRectInPreview == null) { + Rect rect = new Rect(getFramingRect()); + Point cameraResolution = configManager.getCameraResolution(); + Point screenResolution = configManager.getScreenResolution(); + //modify here +// rect.left = rect.left * cameraResolution.x / screenResolution.x; +// rect.right = rect.right * cameraResolution.x / screenResolution.x; +// rect.top = rect.top * cameraResolution.y / screenResolution.y; +// rect.bottom = rect.bottom * cameraResolution.y / screenResolution.y; + rect.left = rect.left * cameraResolution.y / screenResolution.x; + rect.right = rect.right * cameraResolution.y / screenResolution.x; + rect.top = rect.top * cameraResolution.x / screenResolution.y; + rect.bottom = rect.bottom * cameraResolution.x / screenResolution.y; + framingRectInPreview = rect; + } + return framingRectInPreview; + } + + /** + * Converts the result points from still resolution coordinates to screen coordinates. + * + * @param points The points returned by the Reader subclass through Result.getResultPoints(). + * @return An array of Points scaled to the size of the framing rect and offset appropriately + * so they can be drawn in screen coordinates. + */ + /* + public Point[] convertResultPoints(ResultPoint[] points) { + Rect frame = getFramingRectInPreview(); + int count = points.length; + Point[] output = new Point[count]; + for (int x = 0; x < count; x++) { + output[x] = new Point(); + output[x].x = frame.left + (int) (points[x].getX() + 0.5f); + output[x].y = frame.top + (int) (points[x].getY() + 0.5f); + } + return output; + } + */ + + /** + * A factory method to build the appropriate LuminanceSource object based on the format + * of the preview buffers, as described by Camera.Parameters. + * + * @param data A preview frame. + * @param width The width of the image. + * @param height The height of the image. + * @return A PlanarYUVLuminanceSource instance. + */ + public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) { + Rect rect = getFramingRectInPreview(); + int previewFormat = configManager.getPreviewFormat(); + String previewFormatString = configManager.getPreviewFormatString(); + switch (previewFormat) { + // This is the standard Android format which all devices are REQUIRED to support. + // In theory, it's the only one we should ever care about. + case PixelFormat.YCbCr_420_SP: + // This format has never been seen in the wild, but is compatible as we only care + // about the Y channel, so allow it. + case PixelFormat.YCbCr_422_SP: + return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top, + rect.width(), rect.height()); + default: + // The Samsung Moment incorrectly uses this variant instead of the 'sp' version. + // Fortunately, it too has all the Y data up front, so we can read it. + if ("yuv420p".equals(previewFormatString)) { + return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top, + rect.width(), rect.height()); + } + } + throw new IllegalArgumentException("Unsupported picture format: " + + previewFormat + '/' + previewFormatString); + } + + public Context getContext() { + return context; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/FlashlightManager.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/FlashlightManager.java new file mode 100644 index 0000000..ab59496 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/FlashlightManager.java @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.zxing.camera; + +import android.os.IBinder; +import android.util.Log; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * This class is used to activate the weak light on some camera phones (not flash) + * in order to illuminate surfaces for scanning. There is no official way to do this, + * but, classes which allow access to this function still exist on some devices. + * This therefore proceeds through a great deal of reflection. + * + * See + * http://almondmendoza.com/2009/01/05/changing-the-screen-brightness-programatically/ and + * + * http://code.google.com/p/droidled/source/browse/trunk/src/com/droidled/demo/DroidLED.java. + * Thanks to Ryan Alford for pointing out the availability of this class. + */ +final class FlashlightManager { + + private static final String TAG = FlashlightManager.class.getSimpleName(); + + private static final Object iHardwareService; + private static final Method setFlashEnabledMethod; + static { + iHardwareService = getHardwareService(); + setFlashEnabledMethod = getSetFlashEnabledMethod(iHardwareService); + if (iHardwareService == null) { + Log.v(TAG, "This device does supports control of a flashlight"); + } else { + Log.v(TAG, "This device does not support control of a flashlight"); + } + } + + private FlashlightManager() { + } + + /** + * �����������ƿ��� + */ + //FIXME + static void enableFlashlight() { + setFlashlight(false); + } + + static void disableFlashlight() { + setFlashlight(false); + } + + private static Object getHardwareService() { + Class serviceManagerClass = maybeForName("android.os.ServiceManager"); + if (serviceManagerClass == null) { + return null; + } + + Method getServiceMethod = maybeGetMethod(serviceManagerClass, "getService", String.class); + if (getServiceMethod == null) { + return null; + } + + Object hardwareService = invoke(getServiceMethod, null, "hardware"); + if (hardwareService == null) { + return null; + } + + Class iHardwareServiceStubClass = maybeForName("android.os.IHardwareService$Stub"); + if (iHardwareServiceStubClass == null) { + return null; + } + + Method asInterfaceMethod = maybeGetMethod(iHardwareServiceStubClass, "asInterface", IBinder.class); + if (asInterfaceMethod == null) { + return null; + } + + return invoke(asInterfaceMethod, null, hardwareService); + } + + private static Method getSetFlashEnabledMethod(Object iHardwareService) { + if (iHardwareService == null) { + return null; + } + Class proxyClass = iHardwareService.getClass(); + return maybeGetMethod(proxyClass, "setFlashlightEnabled", boolean.class); + } + + private static Class maybeForName(String name) { + try { + return Class.forName(name); + } catch (ClassNotFoundException cnfe) { + // OK + return null; + } catch (RuntimeException re) { + Log.w(TAG, "Unexpected error while finding class " + name, re); + return null; + } + } + + private static Method maybeGetMethod(Class clazz, String name, Class... argClasses) { + try { + return clazz.getMethod(name, argClasses); + } catch (NoSuchMethodException nsme) { + // OK + return null; + } catch (RuntimeException re) { + Log.w(TAG, "Unexpected error while finding method " + name, re); + return null; + } + } + + private static Object invoke(Method method, Object instance, Object... args) { + try { + return method.invoke(instance, args); + } catch (IllegalAccessException e) { + Log.w(TAG, "Unexpected error while invoking " + method, e); + return null; + } catch (InvocationTargetException e) { + Log.w(TAG, "Unexpected error while invoking " + method, e.getCause()); + return null; + } catch (RuntimeException re) { + Log.w(TAG, "Unexpected error while invoking " + method, re); + return null; + } + } + + private static void setFlashlight(boolean active) { + if (iHardwareService != null) { + invoke(setFlashEnabledMethod, iHardwareService, active); + } + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/PlanarYUVLuminanceSource.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/PlanarYUVLuminanceSource.java new file mode 100644 index 0000000..9de9576 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/PlanarYUVLuminanceSource.java @@ -0,0 +1,133 @@ +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.zxing.camera; + +import android.graphics.Bitmap; + +import com.google.zxing.LuminanceSource; + +/** + * This object extends LuminanceSource around an array of YUV data returned from the camera driver, + * with the option to crop to a rectangle within the full data. This can be used to exclude + * superfluous pixels around the perimeter and speed up decoding. + * + * It works for any pixel format where the Y channel is planar and appears first, including + * YCbCr_420_SP and YCbCr_422_SP. + * + * @author dswitkin@google.com (Daniel Switkin) + */ +public final class PlanarYUVLuminanceSource extends LuminanceSource { + private final byte[] yuvData; + private final int dataWidth; + private final int dataHeight; + private final int left; + private final int top; + + public PlanarYUVLuminanceSource(byte[] yuvData, int dataWidth, int dataHeight, int left, int top, + int width, int height) { + super(width, height); + + if (left + width > dataWidth || top + height > dataHeight) { + throw new IllegalArgumentException("Crop rectangle does not fit within image data."); + } + + this.yuvData = yuvData; + this.dataWidth = dataWidth; + this.dataHeight = dataHeight; + this.left = left; + this.top = top; + } + + @Override + public byte[] getRow(int y, byte[] row) { + if (y < 0 || y >= getHeight()) { + throw new IllegalArgumentException("Requested row is outside the image: " + y); + } + int width = getWidth(); + if (row == null || row.length < width) { + row = new byte[width]; + } + int offset = (y + top) * dataWidth + left; + System.arraycopy(yuvData, offset, row, 0, width); + return row; + } + + @Override + public byte[] getMatrix() { + int width = getWidth(); + int height = getHeight(); + + // If the caller asks for the entire underlying image, save the copy and give them the + // original data. The docs specifically warn that result.length must be ignored. + if (width == dataWidth && height == dataHeight) { + return yuvData; + } + + int area = width * height; + byte[] matrix = new byte[area]; + int inputOffset = top * dataWidth + left; + + // If the width matches the full width of the underlying data, perform a single copy. + if (width == dataWidth) { + System.arraycopy(yuvData, inputOffset, matrix, 0, area); + return matrix; + } + + // Otherwise copy one cropped row at a time. + byte[] yuv = yuvData; + for (int y = 0; y < height; y++) { + int outputOffset = y * width; + System.arraycopy(yuv, inputOffset, matrix, outputOffset, width); + inputOffset += dataWidth; + } + return matrix; + } + + @Override + public boolean isCropSupported() { + return true; + } + + public int getDataWidth() { + return dataWidth; + } + + public int getDataHeight() { + return dataHeight; + } + + public Bitmap renderCroppedGreyscaleBitmap() { + int width = getWidth(); + int height = getHeight(); + int[] pixels = new int[width * height]; + byte[] yuv = yuvData; + int inputOffset = top * dataWidth + left; + + for (int y = 0; y < height; y++) { + int outputOffset = y * width; + for (int x = 0; x < width; x++) { + int grey = yuv[inputOffset + x] & 0xff; + pixels[outputOffset + x] = 0xFF000000 | (grey * 0x00010101); + } + inputOffset += dataWidth; + } + + Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + bitmap.setPixels(pixels, 0, width, 0, 0, width, height); + return bitmap; + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/PreviewCallback.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/PreviewCallback.java new file mode 100644 index 0000000..f13094d --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/camera/PreviewCallback.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.zxing.camera; + +import android.graphics.Point; +import android.hardware.Camera; +import android.os.Handler; +import android.os.Message; +import android.util.Log; + +final class PreviewCallback implements Camera.PreviewCallback { + + private static final String TAG = PreviewCallback.class.getSimpleName(); + + private final CameraConfigurationManager configManager; + private final boolean useOneShotPreviewCallback; + private Handler previewHandler; + private int previewMessage; + + PreviewCallback(CameraConfigurationManager configManager, boolean useOneShotPreviewCallback) { + this.configManager = configManager; + this.useOneShotPreviewCallback = useOneShotPreviewCallback; + } + + void setHandler(Handler previewHandler, int previewMessage) { + this.previewHandler = previewHandler; + this.previewMessage = previewMessage; + } + + public void onPreviewFrame(byte[] data, Camera camera) { + Point cameraResolution = configManager.getCameraResolution(); + if (!useOneShotPreviewCallback) { + camera.setPreviewCallback(null); + } + if (previewHandler != null) { + Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x, + cameraResolution.y, data); + message.sendToTarget(); + previewHandler = null; + } else { + Log.d(TAG, "Got preview callback, but no handler for it"); + } + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/CaptureActivityHandler.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/CaptureActivityHandler.java new file mode 100644 index 0000000..89817ac --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/CaptureActivityHandler.java @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.zxing.decoding; + +import android.app.Activity; +import android.content.Intent; +import android.graphics.Bitmap; +import android.net.Uri; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.util.Log; + +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.zxing.activity.CaptureActivity; +import com.fisherbone.fuzhu.zxing.camera.CameraManager; +import com.fisherbone.fuzhu.zxing.view.ViewfinderResultPointCallback; +import com.google.zxing.BarcodeFormat; +import com.google.zxing.Result; + +import java.util.Vector; + + +/** + * This class handles all the messaging which comprises the state machine for capture. + */ +public final class CaptureActivityHandler extends Handler { + + private static final String TAG = CaptureActivityHandler.class.getSimpleName(); + + private final CaptureActivity activity; + private final DecodeThread decodeThread; + private State state; + + private enum State { + PREVIEW, + SUCCESS, + DONE + } + + public CaptureActivityHandler(CaptureActivity activity, Vector decodeFormats, + String characterSet) { + this.activity = activity; + decodeThread = new DecodeThread(activity, decodeFormats, characterSet, + new ViewfinderResultPointCallback(activity.getViewfinderView())); + decodeThread.start(); + state = State.SUCCESS; + // Start ourselves capturing previews and decoding. + CameraManager.get().startPreview(); + restartPreviewAndDecode(); + } + + @Override + public void handleMessage(Message message) { + switch (message.what) { + case R.id.auto_focus: + //Log.d(TAG, "Got auto-focus message"); + // When one auto focus pass finishes, start another. This is the closest thing to + // continuous AF. It does seem to hunt a bit, but I'm not sure what else to do. + if (state == State.PREVIEW) { + CameraManager.get().requestAutoFocus(this, R.id.auto_focus); + } + break; + case R.id.restart_preview: + Log.d(TAG, "Got restart preview message"); + restartPreviewAndDecode(); + break; + case R.id.decode_succeeded: + Log.d(TAG, "Got decode succeeded message"); + state = State.SUCCESS; + Bundle bundle = message.getData(); + + /***********************************************************************/ + Bitmap barcode = bundle == null ? null : + (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);//���ñ����߳� + + activity.handleDecode((Result) message.obj, barcode);//���ؽ�� + /***********************************************************************/ + break; + case R.id.decode_failed: + // We're decoding as fast as possible, so when one decode fails, start another. + state = State.PREVIEW; + CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode); + break; + case R.id.return_scan_result: + Log.d(TAG, "Got return scan result message"); + activity.setResult(Activity.RESULT_OK, (Intent) message.obj); + activity.finish(); + break; + case R.id.launch_product_query: + Log.d(TAG, "Got product query message"); + String url = (String) message.obj; + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); + activity.startActivity(intent); + break; + default: + } + } + + public void quitSynchronously() { + state = State.DONE; + CameraManager.get().stopPreview(); + Message quit = Message.obtain(decodeThread.getHandler(), R.id.quit); + quit.sendToTarget(); + try { + decodeThread.join(); + } catch (InterruptedException e) { + // continue + } + + // Be absolutely sure we don't send any queued up messages + removeMessages(R.id.decode_succeeded); + removeMessages(R.id.decode_failed); + } + + private void restartPreviewAndDecode() { + if (state == State.SUCCESS) { + state = State.PREVIEW; + CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode); + CameraManager.get().requestAutoFocus(this, R.id.auto_focus); + activity.drawViewfinder(); + } + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/DecodeFormatManager.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/DecodeFormatManager.java new file mode 100644 index 0000000..6edca96 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/DecodeFormatManager.java @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.zxing.decoding; + +import android.content.Intent; +import android.net.Uri; + +import com.google.zxing.BarcodeFormat; + +import java.util.Arrays; +import java.util.List; +import java.util.Vector; +import java.util.regex.Pattern; + +final class DecodeFormatManager { + + private static final Pattern COMMA_PATTERN = Pattern.compile(","); + + static final Vector PRODUCT_FORMATS; + static final Vector ONE_D_FORMATS; + static final Vector QR_CODE_FORMATS; + static final Vector DATA_MATRIX_FORMATS; + static { + PRODUCT_FORMATS = new Vector(5); + PRODUCT_FORMATS.add(BarcodeFormat.UPC_A); + PRODUCT_FORMATS.add(BarcodeFormat.UPC_E); + PRODUCT_FORMATS.add(BarcodeFormat.EAN_13); + PRODUCT_FORMATS.add(BarcodeFormat.EAN_8); + ONE_D_FORMATS = new Vector(PRODUCT_FORMATS.size() + 4); + ONE_D_FORMATS.addAll(PRODUCT_FORMATS); + ONE_D_FORMATS.add(BarcodeFormat.CODE_39); + ONE_D_FORMATS.add(BarcodeFormat.CODE_93); + ONE_D_FORMATS.add(BarcodeFormat.CODE_128); + ONE_D_FORMATS.add(BarcodeFormat.ITF); + QR_CODE_FORMATS = new Vector(1); + QR_CODE_FORMATS.add(BarcodeFormat.QR_CODE); + DATA_MATRIX_FORMATS = new Vector(1); + DATA_MATRIX_FORMATS.add(BarcodeFormat.DATA_MATRIX); + } + + private DecodeFormatManager() {} + + static Vector parseDecodeFormats(Intent intent) { + List scanFormats = null; + String scanFormatsString = intent.getStringExtra(Intents.Scan.SCAN_FORMATS); + if (scanFormatsString != null) { + scanFormats = Arrays.asList(COMMA_PATTERN.split(scanFormatsString)); + } + return parseDecodeFormats(scanFormats, intent.getStringExtra(Intents.Scan.MODE)); + } + + static Vector parseDecodeFormats(Uri inputUri) { + List formats = inputUri.getQueryParameters(Intents.Scan.SCAN_FORMATS); + if (formats != null && formats.size() == 1 && formats.get(0) != null){ + formats = Arrays.asList(COMMA_PATTERN.split(formats.get(0))); + } + return parseDecodeFormats(formats, inputUri.getQueryParameter(Intents.Scan.MODE)); + } + + private static Vector parseDecodeFormats(Iterable scanFormats, + String decodeMode) { + if (scanFormats != null) { + Vector formats = new Vector(); + try { + for (String format : scanFormats) { + formats.add(BarcodeFormat.valueOf(format)); + } + return formats; + } catch (IllegalArgumentException iae) { + // ignore it then + } + } + if (decodeMode != null) { + if (Intents.Scan.PRODUCT_MODE.equals(decodeMode)) { + return PRODUCT_FORMATS; + } + if (Intents.Scan.QR_CODE_MODE.equals(decodeMode)) { + return QR_CODE_FORMATS; + } + if (Intents.Scan.DATA_MATRIX_MODE.equals(decodeMode)) { + return DATA_MATRIX_FORMATS; + } + if (Intents.Scan.ONE_D_MODE.equals(decodeMode)) { + return ONE_D_FORMATS; + } + } + return null; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/DecodeHandler.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/DecodeHandler.java new file mode 100644 index 0000000..6cf0f2a --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/DecodeHandler.java @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.zxing.decoding; + +import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.util.Log; + +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.zxing.activity.CaptureActivity; +import com.fisherbone.fuzhu.zxing.camera.CameraManager; +import com.fisherbone.fuzhu.zxing.camera.PlanarYUVLuminanceSource; +import com.google.zxing.BinaryBitmap; +import com.google.zxing.DecodeHintType; +import com.google.zxing.MultiFormatReader; +import com.google.zxing.ReaderException; +import com.google.zxing.Result; +import com.google.zxing.common.HybridBinarizer; + +import java.util.Hashtable; + + +final class DecodeHandler extends Handler { + + private static final String TAG = DecodeHandler.class.getSimpleName(); + + private final CaptureActivity activity; + private final MultiFormatReader multiFormatReader; + + DecodeHandler(CaptureActivity activity, Hashtable hints) { + multiFormatReader = new MultiFormatReader(); + multiFormatReader.setHints(hints); + this.activity = activity; + } + + @Override + public void handleMessage(Message message) { + switch (message.what) { + case R.id.decode: + //Log.d(TAG, "Got decode message"); + decode((byte[]) message.obj, message.arg1, message.arg2); + break; + case R.id.quit: + Looper.myLooper().quit(); + break; + default: + } + } + + /** + * Decode the data within the viewfinder rectangle, and time how long it took. For efficiency, + * reuse the same reader objects from one decode to the next. + * + * @param data The YUV preview frame. + * @param width The width of the preview frame. + * @param height The height of the preview frame. + */ + private void decode(byte[] data, int width, int height) { + long start = System.currentTimeMillis(); + Result rawResult = null; + + //modify here + byte[] rotatedData = new byte[data.length]; + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) + rotatedData[x * height + height - y - 1] = data[x + y * width]; + } + int tmp = width; // Here we are swapping, that's the difference to #11 + width = height; + height = tmp; + + PlanarYUVLuminanceSource source = CameraManager.get().buildLuminanceSource(rotatedData, width, height); + BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); + try { + rawResult = multiFormatReader.decodeWithState(bitmap); + } catch (ReaderException re) { + // continue + } finally { + multiFormatReader.reset(); + } + + if (rawResult != null) { + long end = System.currentTimeMillis(); + Log.d(TAG, "Found barcode (" + (end - start) + " ms):\n" + rawResult.toString()); + Message message = Message.obtain(activity.getHandler(), R.id.decode_succeeded, rawResult); + Bundle bundle = new Bundle(); + bundle.putParcelable(DecodeThread.BARCODE_BITMAP, source.renderCroppedGreyscaleBitmap()); + message.setData(bundle); + //Log.d(TAG, "Sending decode succeeded message..."); + message.sendToTarget(); + } else { + Message message = Message.obtain(activity.getHandler(), R.id.decode_failed); + message.sendToTarget(); + } + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/DecodeThread.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/DecodeThread.java new file mode 100644 index 0000000..80aa626 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/DecodeThread.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.zxing.decoding; + +import android.os.Handler; +import android.os.Looper; + +import com.fisherbone.fuzhu.zxing.activity.CaptureActivity; +import com.google.zxing.BarcodeFormat; +import com.google.zxing.DecodeHintType; +import com.google.zxing.ResultPointCallback; + +import java.util.Hashtable; +import java.util.Vector; +import java.util.concurrent.CountDownLatch; + +/** + * This thread does all the heavy lifting of decoding the images. + * �����߳� + */ +final class DecodeThread extends Thread { + + public static final String BARCODE_BITMAP = "barcode_bitmap"; + private final CaptureActivity activity; + private final Hashtable hints; + private Handler handler; + private final CountDownLatch handlerInitLatch; + + DecodeThread(CaptureActivity activity, + Vector decodeFormats, + String characterSet, + ResultPointCallback resultPointCallback) { + + this.activity = activity; + handlerInitLatch = new CountDownLatch(1); + + hints = new Hashtable(3); + + if (decodeFormats == null || decodeFormats.isEmpty()) { + decodeFormats = new Vector(); + decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS); + decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS); + decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS); + } + + hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats); + + if (characterSet != null) { + hints.put(DecodeHintType.CHARACTER_SET, characterSet); + } + + hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback); + } + + Handler getHandler() { + try { + handlerInitLatch.await(); + } catch (InterruptedException ie) { + // continue? + } + return handler; + } + + @Override + public void run() { + Looper.prepare(); + handler = new DecodeHandler(activity, hints); + handlerInitLatch.countDown(); + Looper.loop(); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/FinishListener.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/FinishListener.java new file mode 100644 index 0000000..80fa4ac --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/FinishListener.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.zxing.decoding; + +import android.app.Activity; +import android.content.DialogInterface; + +/** + * Simple listener used to exit the app in a few cases. + * + */ +public final class FinishListener + implements DialogInterface.OnClickListener, DialogInterface.OnCancelListener, Runnable { + + private final Activity activityToFinish; + + public FinishListener(Activity activityToFinish) { + this.activityToFinish = activityToFinish; + } + + public void onCancel(DialogInterface dialogInterface) { + run(); + } + + public void onClick(DialogInterface dialogInterface, int i) { + run(); + } + + public void run() { + activityToFinish.finish(); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/InactivityTimer.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/InactivityTimer.java new file mode 100644 index 0000000..0e2ed75 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/InactivityTimer.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.zxing.decoding; + +import android.app.Activity; + +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; + +/** + * Finishes an activity after a period of inactivity. + */ +public final class InactivityTimer { + + private static final int INACTIVITY_DELAY_SECONDS = 5 * 60; + + private final ScheduledExecutorService inactivityTimer = + Executors.newSingleThreadScheduledExecutor(new DaemonThreadFactory()); + private final Activity activity; + private ScheduledFuture inactivityFuture = null; + + public InactivityTimer(Activity activity) { + this.activity = activity; + onActivity(); + } + + public void onActivity() { + cancel(); + inactivityFuture = inactivityTimer.schedule(new FinishListener(activity), + INACTIVITY_DELAY_SECONDS, + TimeUnit.SECONDS); + } + + private void cancel() { + if (inactivityFuture != null) { + inactivityFuture.cancel(true); + inactivityFuture = null; + } + } + + public void shutdown() { + cancel(); + inactivityTimer.shutdown(); + } + + private static final class DaemonThreadFactory implements ThreadFactory { + public Thread newThread(Runnable runnable) { + Thread thread = new Thread(runnable); + thread.setDaemon(true); + return thread; + } + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/Intents.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/Intents.java new file mode 100644 index 0000000..422a860 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/Intents.java @@ -0,0 +1,190 @@ +/* + * Copyright (C) 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.zxing.decoding; + +/** + * This class provides the constants to use when sending an Intent to Barcode Scanner. + * These strings are effectively API and cannot be changed. + */ +public final class Intents { + private Intents() { + } + + public static final class Scan { + /** + * Send this intent to open the Barcodes app in scanning mode, find a barcode, and return + * the results. + */ + public static final String ACTION = "com.google.zxing.client.android.SCAN"; + + /** + * By default, sending Scan.ACTION will decode all barcodes that we understand. However it + * may be useful to limit scanning to certain formats. Use Intent.putExtra(MODE, value) with + * one of the values below ({@link #PRODUCT_MODE}, {@link #ONE_D_MODE}, {@link #QR_CODE_MODE}). + * Optional. + * + * Setting this is effectively shorthnad for setting explicit formats with {@link #SCAN_FORMATS}. + * It is overridden by that setting. + */ + public static final String MODE = "SCAN_MODE"; + + /** + * Comma-separated list of formats to scan for. The values must match the names of + * {@link com.google.zxing.BarcodeFormat}s, such as {@link com.google.zxing.BarcodeFormat#EAN_13}. + * Example: "EAN_13,EAN_8,QR_CODE" + * + * This overrides {@link #MODE}. + */ + public static final String SCAN_FORMATS = "SCAN_FORMATS"; + + /** + * @see com.google.zxing.DecodeHintType#CHARACTER_SET + */ + public static final String CHARACTER_SET = "CHARACTER_SET"; + + /** + * Decode only UPC and EAN barcodes. This is the right choice for shopping apps which get + * prices, reviews, etc. for products. + */ + public static final String PRODUCT_MODE = "PRODUCT_MODE"; + + /** + * Decode only 1D barcodes (currently UPC, EAN, Code 39, and Code 128). + */ + public static final String ONE_D_MODE = "ONE_D_MODE"; + + /** + * Decode only QR codes. + */ + public static final String QR_CODE_MODE = "QR_CODE_MODE"; + + /** + * Decode only Data Matrix codes. + */ + public static final String DATA_MATRIX_MODE = "DATA_MATRIX_MODE"; + + /** + * If a barcode is found, Barcodes returns RESULT_OK to onActivityResult() of the app which + * requested the scan via startSubActivity(). The barcodes contents can be retrieved with + * intent.getStringExtra(RESULT). If the user presses Back, the result code will be + * RESULT_CANCELED. + */ + public static final String RESULT = "SCAN_RESULT"; + + /** + * Call intent.getStringExtra(RESULT_FORMAT) to determine which barcode format was found. + * See Contents.Format for possible values. + */ + public static final String RESULT_FORMAT = "SCAN_RESULT_FORMAT"; + + /** + * Setting this to false will not save scanned codes in the history. + */ + public static final String SAVE_HISTORY = "SAVE_HISTORY"; + + private Scan() { + } + } + + public static final class Encode { + /** + * Send this intent to encode a piece of data as a QR code and display it full screen, so + * that another person can scan the barcode from your screen. + */ + public static final String ACTION = "com.google.zxing.client.android.ENCODE"; + + /** + * The data to encode. Use Intent.putExtra(DATA, data) where data is either a String or a + * Bundle, depending on the type and format specified. Non-QR Code formats should + * just use a String here. For QR Code, see Contents for details. + */ + public static final String DATA = "ENCODE_DATA"; + + /** + * The type of data being supplied if the format is QR Code. Use + * Intent.putExtra(TYPE, type) with one of Contents.Type. + */ + public static final String TYPE = "ENCODE_TYPE"; + + /** + * The barcode format to be displayed. If this isn't specified or is blank, + * it defaults to QR Code. Use Intent.putExtra(FORMAT, format), where + * format is one of Contents.Format. + */ + public static final String FORMAT = "ENCODE_FORMAT"; + + private Encode() { + } + } + + public static final class SearchBookContents { + /** + * Use Google Book Search to search the contents of the book provided. + */ + public static final String ACTION = "com.google.zxing.client.android.SEARCH_BOOK_CONTENTS"; + + /** + * The book to search, identified by ISBN number. + */ + public static final String ISBN = "ISBN"; + + /** + * An optional field which is the text to search for. + */ + public static final String QUERY = "QUERY"; + + private SearchBookContents() { + } + } + + public static final class WifiConnect { + /** + * Internal intent used to trigger connection to a wi-fi network. + */ + public static final String ACTION = "com.google.zxing.client.android.WIFI_CONNECT"; + + /** + * The network to connect to, all the configuration provided here. + */ + public static final String SSID = "SSID"; + + /** + * The network to connect to, all the configuration provided here. + */ + public static final String TYPE = "TYPE"; + + /** + * The network to connect to, all the configuration provided here. + */ + public static final String PASSWORD = "PASSWORD"; + + private WifiConnect() { + } + } + + + public static final class Share { + /** + * Give the user a choice of items to encode as a barcode, then render it as a QR Code and + * display onscreen for a friend to scan with their phone. + */ + public static final String ACTION = "com.google.zxing.client.android.SHARE"; + + private Share() { + } + } +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/RGBLuminanceSource.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/RGBLuminanceSource.java new file mode 100644 index 0000000..9dec810 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/decoding/RGBLuminanceSource.java @@ -0,0 +1,104 @@ +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.zxing.decoding; + +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; + +import com.google.zxing.LuminanceSource; + +import java.io.FileNotFoundException; + +/** + * This class is used to help decode images from files which arrive as RGB data + * from Android bitmaps. It does not support cropping or rotation. + * + */ +public final class RGBLuminanceSource extends LuminanceSource { + + private final byte[] luminances; + + public RGBLuminanceSource(String path) throws FileNotFoundException { + this(loadBitmap(path)); + } + + public RGBLuminanceSource(Bitmap bitmap) { + super(bitmap.getWidth(), bitmap.getHeight()); + + int width = bitmap.getWidth(); + int height = bitmap.getHeight(); + + int[] pixels = new int[width * height]; + bitmap.getPixels(pixels, 0, width, 0, 0, width, height); + + // In order to measure pure decoding speed, we convert the entire image + // to a greyscale array + // up front, which is the same as the Y channel of the + // YUVLuminanceSource in the real app. + luminances = new byte[width * height]; + for (int y = 0; y < height; y++) { + int offset = y * width; + for (int x = 0; x < width; x++) { + int pixel = pixels[offset + x]; + int r = (pixel >> 16) & 0xff; + int g = (pixel >> 8) & 0xff; + int b = pixel & 0xff; + if (r == g && g == b) { + // Image is already greyscale, so pick any channel. + luminances[offset + x] = (byte) r; + } else { + // Calculate luminance cheaply, favoring green. + luminances[offset + x] = (byte) ((r + g + g + b) >> 2); + } + } + } + } + + + + + @Override + public byte[] getRow(int y, byte[] row) { + if (y < 0 || y >= getHeight()) { + throw new IllegalArgumentException("Requested row is outside the image: " + y); + } + int width = getWidth(); + if (row == null || row.length < width) { + row = new byte[width]; + } + + System.arraycopy(luminances, y * width, row, 0, width); + return row; + } + + // Since this class does not support cropping, the underlying byte array + // already contains + // exactly what the caller is asking for, so give it to them without a copy. + @Override + public byte[] getMatrix() { + return luminances; + } + + private static Bitmap loadBitmap(String path) throws FileNotFoundException { + Bitmap bitmap = BitmapFactory.decodeFile(path); + if (bitmap == null) { + throw new FileNotFoundException("Couldn't open " + path); + } + return bitmap; + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/encoding/CodeCreator.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/encoding/CodeCreator.java new file mode 100644 index 0000000..dc301b3 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/encoding/CodeCreator.java @@ -0,0 +1,103 @@ +package com.fisherbone.fuzhu.zxing.encoding; + +import android.graphics.Bitmap; +import android.graphics.Matrix; +import android.text.TextUtils; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.EncodeHintType; +import com.google.zxing.MultiFormatWriter; +import com.google.zxing.WriterException; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; + +import java.util.Hashtable; + +public class CodeCreator { + + + /*生成二维码*/ + public static Bitmap createQRCode(String content, int w, int h, Bitmap logo) { + + + if (TextUtils.isEmpty(content)) { + return null; + } + /*偏移量*/ + int offsetX = w / 2; + int offsetY = h / 2; + + /*生成logo*/ + Bitmap logoBitmap = null; + + if (logo != null) { + Matrix matrix = new Matrix(); + float scaleFactor = Math.min(w * 1.0f / 5 / logo.getWidth(), h * 1.0f / 5 / logo.getHeight()); + matrix.postScale(scaleFactor, scaleFactor); + logoBitmap = Bitmap.createBitmap(logo, 0, 0, logo.getWidth(), logo.getHeight(), matrix, true); + } + + + /*如果log不为null,重新计算偏移量*/ + int logoW = 0; + int logoH = 0; + if (logoBitmap != null) { + logoW = logoBitmap.getWidth(); + logoH = logoBitmap.getHeight(); + offsetX = (w - logoW) / 2; + offsetY = (h - logoH) / 2; + } + + /*指定为UTF-8*/ + Hashtable hints = new Hashtable(); + hints.put(EncodeHintType.CHARACTER_SET, "utf-8"); + //容错级别 + hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); + //设置空白边距的宽度 + hints.put(EncodeHintType.MARGIN, 0); + // 生成二维矩阵,编码时指定大小,不要生成了图片以后再进行缩放,这样会模糊导致识别失败 + BitMatrix matrix = null; + try { + matrix = new MultiFormatWriter().encode(content, + BarcodeFormat.QR_CODE, w, h, hints); + + // 二维矩阵转为一维像素数组,也就是一直横着排了 + int[] pixels = new int[w * h]; + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + if (x >= offsetX && x < offsetX + logoW && y >= offsetY && y < offsetY + logoH) { + int pixel = logoBitmap.getPixel(x - offsetX, y - offsetY); + if (pixel == 0) { + if (matrix.get(x, y)) { + pixel = 0xff000000; + } else { + pixel = 0xffffffff; + } + } + pixels[y * w + x] = pixel; + } else { + if (matrix.get(x, y)) { + pixels[y * w + x] = 0xff000000; + } else { + pixels[y * w + x] = 0xffffffff; + } + } + } + } + + Bitmap bitmap = Bitmap.createBitmap(w, h, + Bitmap.Config.ARGB_8888); + bitmap.setPixels(pixels, 0, w, 0, 0, w, h); + return bitmap; + + + } catch (WriterException e) { + + System.out.print(e); + return null; + } + + + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/encoding/EncodingHandler.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/encoding/EncodingHandler.java new file mode 100644 index 0000000..6cb2414 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/encoding/EncodingHandler.java @@ -0,0 +1,43 @@ +package com.fisherbone.fuzhu.zxing.encoding; + +import android.graphics.Bitmap; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.EncodeHintType; +import com.google.zxing.MultiFormatWriter; +import com.google.zxing.WriterException; +import com.google.zxing.common.BitMatrix; + +import java.util.Hashtable; + +/** + * @author Ryan Tang + * + */ +public final class EncodingHandler { + private static final int BLACK = 0xff000000; + + public static Bitmap createQRCode(String str, int widthAndHeight) throws WriterException { + Hashtable hints = new Hashtable(); + hints.put(EncodeHintType.CHARACTER_SET, "utf-8"); + BitMatrix matrix = new MultiFormatWriter().encode(str, + BarcodeFormat.QR_CODE, widthAndHeight, widthAndHeight); + int width = matrix.getWidth(); + int height = matrix.getHeight(); + int[] pixels = new int[width * height]; + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + if (matrix.get(x, y)) { + pixels[y * width + x] = BLACK; + } + } + } + Bitmap bitmap = Bitmap.createBitmap(width, height, + Bitmap.Config.ARGB_8888); + bitmap.setPixels(pixels, 0, width, 0, 0, width, height); + return bitmap; + } + + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/view/ViewfinderResultPointCallback.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/view/ViewfinderResultPointCallback.java new file mode 100644 index 0000000..c92d62f --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/view/ViewfinderResultPointCallback.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.zxing.view; + +import com.google.zxing.ResultPoint; +import com.google.zxing.ResultPointCallback; + +public final class ViewfinderResultPointCallback implements ResultPointCallback { + private final ViewfinderView viewfinderView; + + public ViewfinderResultPointCallback(ViewfinderView viewfinderView) { + this.viewfinderView = viewfinderView; + } + + public void foundPossibleResultPoint(ResultPoint point) { + viewfinderView.addPossibleResultPoint(point); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/zxing/view/ViewfinderView.java b/app/src/main/java/com/fisherbone/fuzhu/zxing/view/ViewfinderView.java new file mode 100644 index 0000000..4321193 --- /dev/null +++ b/app/src/main/java/com/fisherbone/fuzhu/zxing/view/ViewfinderView.java @@ -0,0 +1,285 @@ +/* + * Copyright (C) 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.fisherbone.fuzhu.zxing.view; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.ComposeShader; +import android.graphics.LinearGradient; +import android.graphics.Paint; +import android.graphics.PorterDuff; +import android.graphics.RadialGradient; +import android.graphics.Rect; +import android.graphics.RectF; +import android.graphics.Shader; +import android.graphics.SweepGradient; +import android.util.AttributeSet; +import android.view.View; + +import com.fisherbone.fuzhu.R; +import com.fisherbone.fuzhu.zxing.camera.CameraManager; +import com.google.zxing.ResultPoint; + +import java.util.Collection; +import java.util.HashSet; + + +/** + * This view is overlaid on top of the camera preview. It adds the viewfinder rectangle and partial + * transparency outside it, as well as the laser scanner animation and result points. + * @author dswitkin@google.com (Daniel Switkin) + */ +public final class ViewfinderView extends View { + + private static final int[] SCANNER_ALPHA = {0, 64, 128, 192, 255, 192, 128, 64}; + private static final long ANIMATION_DELAY = 10L; + private static final int OPAQUE = 0xFF; + private static final int CORNER_RECT_WIDTH = 8; //扫描区边角的宽 + private static final int CORNER_RECT_HEIGHT = 40; //扫描区边角的高 + private static final int SCANNER_LINE_MOVE_DISTANCE = 5; //扫描线移动距离 + private static final int SCANNER_LINE_HEIGHT = 10; //扫描线宽度 + + private final Paint paint; + private Bitmap resultBitmap; + //模糊区域颜色 + private final int maskColor; + private final int resultColor; + //扫描区域边框颜色 + private final int frameColor; + //扫描线颜色 + private final int laserColor; + //四角颜色 + private final int cornerColor; + //扫描点的颜色 + private final int resultPointColor; + private int scannerAlpha; + //扫描区域提示文本 + private final String labelText; + //扫描区域提示文本颜色 + private final int labelTextColor; + private final float labelTextSize; + + public static int scannerStart = 0; + public static int scannerEnd = 0; + + private Collection possibleResultPoints; + private Collection lastPossibleResultPoints; + + // This constructor is used when the class is built from an XML resource. + public ViewfinderView(Context context, AttributeSet attrs) { + super(context, attrs); + + //初始化自定义属性信息 + TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.ViewfinderView); + laserColor = array.getColor(R.styleable.ViewfinderView_laser_color, 0x00FF00); + cornerColor = array.getColor(R.styleable.ViewfinderView_corner_color, 0x00FF00); + frameColor = array.getColor(R.styleable.ViewfinderView_frame_color, 0xFFFFFF); + resultPointColor = array.getColor(R.styleable.ViewfinderView_result_point_color, 0xC0FFFF00); + maskColor = array.getColor(R.styleable.ViewfinderView_mask_color, 0x60000000); + resultColor = array.getColor(R.styleable.ViewfinderView_result_color, 0xB0000000); + labelTextColor = array.getColor(R.styleable.ViewfinderView_label_text_color, 0x90FFFFFF); + labelText = array.getString(R.styleable.ViewfinderView_label_text); + labelTextSize = array.getFloat(R.styleable.ViewfinderView_label_text_size, 36f); + + // Initialize these once for performance rather than calling them every time in onDraw(). + paint = new Paint(); + paint.setAntiAlias(true); + scannerAlpha = 0; + possibleResultPoints = new HashSet(5); + + + } + + @Override + public void onDraw(Canvas canvas) { + CameraManager.init(this.getContext()); + Rect frame = CameraManager.get().getFramingRect(); + if (frame == null) { + return; + } + if(scannerStart == 0 || scannerEnd == 0) { + scannerStart = frame.top; + scannerEnd = frame.bottom; + } + + int width = canvas.getWidth(); + int height = canvas.getHeight(); + // Draw the exterior (i.e. outside the framing rect) darkened + drawExterior(canvas, frame, width, height); + + + if (resultBitmap != null) { + // Draw the opaque result bitmap over the scanning rectangle + paint.setAlpha(OPAQUE); + canvas.drawBitmap(resultBitmap, frame.left, frame.top, paint); + } else { + // Draw a two pixel solid black border inside the framing rect + drawFrame(canvas, frame); + // 绘制边角 + drawCorner(canvas, frame); + + // Draw a red "laser scanner" line through the middle to show decoding is active + drawLaserScanner(canvas, frame); +//绘制提示信息 + drawTextInfo(canvas, frame); + Collection currentPossible = possibleResultPoints; + Collection currentLast = lastPossibleResultPoints; + if (currentPossible.isEmpty()) { + lastPossibleResultPoints = null; + } else { + possibleResultPoints = new HashSet(5); + lastPossibleResultPoints = currentPossible; + paint.setAlpha(OPAQUE); + paint.setColor(resultPointColor); + for (ResultPoint point : currentPossible) { + canvas.drawCircle(frame.left + point.getX(), frame.top + point.getY(), 6.0f, paint); + } + } + if (currentLast != null) { + paint.setAlpha(OPAQUE / 2); + paint.setColor(resultPointColor); + for (ResultPoint point : currentLast) { + canvas.drawCircle(frame.left + point.getX(), frame.top + point.getY(), 3.0f, paint); + } + } + + // Request another update at the animation interval, but only repaint the laser line, + // not the entire viewfinder mask. + //指定重绘区域,该方法会在子线程中执行 + postInvalidateDelayed(ANIMATION_DELAY, frame.left, frame.top, frame.right, frame.bottom); + } + } + + //绘制文本 + private void drawTextInfo(Canvas canvas, Rect frame) { + paint.setColor(labelTextColor); + paint.setTextSize(labelTextSize); + paint.setTextAlign(Paint.Align.CENTER); + canvas.drawText(labelText, frame.left + frame.width() / 2, frame.top - CORNER_RECT_HEIGHT, paint); + } + + + //绘制边角 + private void drawCorner(Canvas canvas, Rect frame) { + paint.setColor(cornerColor); + //左上 + canvas.drawRect(frame.left, frame.top, frame.left + CORNER_RECT_WIDTH, frame.top + CORNER_RECT_HEIGHT, paint); + canvas.drawRect(frame.left, frame.top, frame.left + CORNER_RECT_HEIGHT, frame.top + CORNER_RECT_WIDTH, paint); + //右上 + canvas.drawRect(frame.right - CORNER_RECT_WIDTH, frame.top, frame.right, frame.top + CORNER_RECT_HEIGHT, paint); + canvas.drawRect(frame.right - CORNER_RECT_HEIGHT, frame.top, frame.right, frame.top + CORNER_RECT_WIDTH, paint); + //左下 + canvas.drawRect(frame.left, frame.bottom - CORNER_RECT_WIDTH, frame.left + CORNER_RECT_HEIGHT, frame.bottom, paint); + canvas.drawRect(frame.left, frame.bottom - CORNER_RECT_HEIGHT, frame.left + CORNER_RECT_WIDTH, frame.bottom, paint); + //右下 + canvas.drawRect(frame.right - CORNER_RECT_WIDTH, frame.bottom - CORNER_RECT_HEIGHT, frame.right, frame.bottom, paint); + canvas.drawRect(frame.right - CORNER_RECT_HEIGHT, frame.bottom - CORNER_RECT_WIDTH, frame.right, frame.bottom, paint); + } + + //绘制扫描线 + private void drawLaserScanner(Canvas canvas, Rect frame) { + paint.setColor(laserColor); + //扫描线闪烁效果 +// paint.setAlpha(SCANNER_ALPHA[scannerAlpha]); +// scannerAlpha = (scannerAlpha + 1) % SCANNER_ALPHA.length; +// int middle = frame.height() / 2 + frame.top; +// canvas.drawRect(frame.left + 2, middle - 1, frame.right - 1, middle + 2, paint); + //线性渐变 + LinearGradient linearGradient = new LinearGradient( + frame.left, scannerStart, + frame.left, scannerStart + SCANNER_LINE_HEIGHT, + shadeColor(laserColor), + laserColor, + Shader.TileMode.MIRROR); + + RadialGradient radialGradient = new RadialGradient( + (float)(frame.left + frame.width() / 2), + (float)(scannerStart + SCANNER_LINE_HEIGHT / 2), + 360f, + laserColor, + shadeColor(laserColor), + Shader.TileMode.MIRROR); + + SweepGradient sweepGradient = new SweepGradient( + (float)(frame.left + frame.width() / 2), + (float)(scannerStart + SCANNER_LINE_HEIGHT), + shadeColor(laserColor), + laserColor); + + ComposeShader composeShader = new ComposeShader(radialGradient, linearGradient, PorterDuff.Mode.ADD); + + paint.setShader(radialGradient); + if(scannerStart <= scannerEnd) { + //矩形 +// canvas.drawRect(frame.left, scannerStart, frame.right, scannerStart + SCANNER_LINE_HEIGHT, paint); + //椭圆 + RectF rectF = new RectF(frame.left + 2 * SCANNER_LINE_HEIGHT, scannerStart, frame.right - 2 * SCANNER_LINE_HEIGHT, scannerStart + SCANNER_LINE_HEIGHT); + canvas.drawOval(rectF, paint); + scannerStart += SCANNER_LINE_MOVE_DISTANCE; + } else { + scannerStart = frame.top; + } + paint.setShader(null); + } + + //处理颜色模糊 + public int shadeColor(int color) { + String hax = Integer.toHexString(color); + String result = "20"+hax.substring(2); + return Integer.valueOf(result, 16); + } + + // 绘制扫描区边框 Draw a two pixel solid black border inside the framing rect + private void drawFrame(Canvas canvas, Rect frame) { + paint.setColor(frameColor); + canvas.drawRect(frame.left, frame.top, frame.right + 1, frame.top + 2, paint); + canvas.drawRect(frame.left, frame.top + 2, frame.left + 2, frame.bottom - 1, paint); + canvas.drawRect(frame.right - 1, frame.top, frame.right + 1, frame.bottom - 1, paint); + canvas.drawRect(frame.left, frame.bottom - 1, frame.right + 1, frame.bottom + 1, paint); + } + + // 绘制模糊区域 Draw the exterior (i.e. outside the framing rect) darkened + private void drawExterior(Canvas canvas, Rect frame, int width, int height) { + paint.setColor(resultBitmap != null ? resultColor : maskColor); + canvas.drawRect(0, 0, width, frame.top, paint); + canvas.drawRect(0, frame.top, frame.left, frame.bottom + 1, paint); + canvas.drawRect(frame.right + 1, frame.top, width, frame.bottom + 1, paint); + canvas.drawRect(0, frame.bottom + 1, width, height, paint); + } + + public void drawViewfinder() { + resultBitmap = null; + invalidate(); + } + + /** + * Draw a bitmap with the result points highlighted instead of the live scanning display. + * + * @param barcode An image of the decoded barcode. + */ + public void drawResultBitmap(Bitmap barcode) { + resultBitmap = barcode; + invalidate(); + } + + public void addPossibleResultPoint(ResultPoint point) { + possibleResultPoints.add(point); + } + +} diff --git a/app/src/main/res/anim/dialog_dismiss.xml b/app/src/main/res/anim/dialog_dismiss.xml new file mode 100644 index 0000000..ed41627 --- /dev/null +++ b/app/src/main/res/anim/dialog_dismiss.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/src/main/res/anim/dialog_show.xml b/app/src/main/res/anim/dialog_show.xml new file mode 100644 index 0000000..21b700d --- /dev/null +++ b/app/src/main/res/anim/dialog_show.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/src/main/res/anim/push_bottom_in2.xml b/app/src/main/res/anim/push_bottom_in2.xml new file mode 100644 index 0000000..f7841af --- /dev/null +++ b/app/src/main/res/anim/push_bottom_in2.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/push_bottom_out2.xml b/app/src/main/res/anim/push_bottom_out2.xml new file mode 100644 index 0000000..fbc42ba --- /dev/null +++ b/app/src/main/res/anim/push_bottom_out2.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..1f6bb29 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/apple_pic.png b/app/src/main/res/drawable/apple_pic.png new file mode 100644 index 0000000..e3961a7 Binary files /dev/null and b/app/src/main/res/drawable/apple_pic.png differ diff --git a/app/src/main/res/drawable/back_btn.xml b/app/src/main/res/drawable/back_btn.xml new file mode 100644 index 0000000..0328919 --- /dev/null +++ b/app/src/main/res/drawable/back_btn.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/app/src/main/res/drawable/begin_button.xml b/app/src/main/res/drawable/begin_button.xml new file mode 100644 index 0000000..e625538 --- /dev/null +++ b/app/src/main/res/drawable/begin_button.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_daka.xml b/app/src/main/res/drawable/bg_daka.xml new file mode 100644 index 0000000..898d5eb --- /dev/null +++ b/app/src/main/res/drawable/bg_daka.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_confirm.xml b/app/src/main/res/drawable/bg_dialog_confirm.xml new file mode 100644 index 0000000..eb1d10c --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_confirm.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_dialog_hint.xml b/app/src/main/res/drawable/bg_dialog_hint.xml new file mode 100644 index 0000000..0a2fb42 --- /dev/null +++ b/app/src/main/res/drawable/bg_dialog_hint.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_edit_content.xml b/app/src/main/res/drawable/bg_edit_content.xml new file mode 100644 index 0000000..be0c54a --- /dev/null +++ b/app/src/main/res/drawable/bg_edit_content.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_fuzhi_tv.xml b/app/src/main/res/drawable/bg_fuzhi_tv.xml new file mode 100644 index 0000000..be0c54a --- /dev/null +++ b/app/src/main/res/drawable/bg_fuzhi_tv.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_live_suiji.xml b/app/src/main/res/drawable/bg_live_suiji.xml new file mode 100644 index 0000000..b070c7b --- /dev/null +++ b/app/src/main/res/drawable/bg_live_suiji.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_marking_username_edittext.xml b/app/src/main/res/drawable/bg_marking_username_edittext.xml new file mode 100644 index 0000000..d77592d --- /dev/null +++ b/app/src/main/res/drawable/bg_marking_username_edittext.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_recfollow_zhixing.xml b/app/src/main/res/drawable/bg_recfollow_zhixing.xml new file mode 100644 index 0000000..c4ad4f5 --- /dev/null +++ b/app/src/main/res/drawable/bg_recfollow_zhixing.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_version_btn.xml b/app/src/main/res/drawable/bg_version_btn.xml new file mode 100644 index 0000000..e9ac698 --- /dev/null +++ b/app/src/main/res/drawable/bg_version_btn.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_version_btn_two.xml b/app/src/main/res/drawable/bg_version_btn_two.xml new file mode 100644 index 0000000..b49281f --- /dev/null +++ b/app/src/main/res/drawable/bg_version_btn_two.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_version_dialog.xml b/app/src/main/res/drawable/bg_version_dialog.xml new file mode 100644 index 0000000..3f0baea --- /dev/null +++ b/app/src/main/res/drawable/bg_version_dialog.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_bg.xml b/app/src/main/res/drawable/button_bg.xml new file mode 100644 index 0000000..ab2ae31 --- /dev/null +++ b/app/src/main/res/drawable/button_bg.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/dialog_but_selector.xml b/app/src/main/res/drawable/dialog_but_selector.xml new file mode 100644 index 0000000..867e8fb --- /dev/null +++ b/app/src/main/res/drawable/dialog_but_selector.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/dialog_but_selector2.xml b/app/src/main/res/drawable/dialog_but_selector2.xml new file mode 100644 index 0000000..0c71e39 --- /dev/null +++ b/app/src/main/res/drawable/dialog_but_selector2.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/dialogwhite.xml b/app/src/main/res/drawable/dialogwhite.xml new file mode 100644 index 0000000..9d20f20 --- /dev/null +++ b/app/src/main/res/drawable/dialogwhite.xml @@ -0,0 +1,8 @@ + + + + + + + diff --git a/app/src/main/res/drawable/drawable_unread_bg.xml b/app/src/main/res/drawable/drawable_unread_bg.xml new file mode 100644 index 0000000..88ad43d --- /dev/null +++ b/app/src/main/res/drawable/drawable_unread_bg.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/gray_thumb.xml b/app/src/main/res/drawable/gray_thumb.xml new file mode 100644 index 0000000..1b89008 --- /dev/null +++ b/app/src/main/res/drawable/gray_thumb.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/gray_track.xml b/app/src/main/res/drawable/gray_track.xml new file mode 100644 index 0000000..10aa5ee --- /dev/null +++ b/app/src/main/res/drawable/gray_track.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/green_thumb.xml b/app/src/main/res/drawable/green_thumb.xml new file mode 100644 index 0000000..a076a30 --- /dev/null +++ b/app/src/main/res/drawable/green_thumb.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/green_track.xml b/app/src/main/res/drawable/green_track.xml new file mode 100644 index 0000000..279e32b --- /dev/null +++ b/app/src/main/res/drawable/green_track.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..0d025f9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/item_select_white.xml b/app/src/main/res/drawable/item_select_white.xml new file mode 100644 index 0000000..d25dba2 --- /dev/null +++ b/app/src/main/res/drawable/item_select_white.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/loading_01.png b/app/src/main/res/drawable/loading_01.png new file mode 100644 index 0000000..1c190a9 Binary files /dev/null and b/app/src/main/res/drawable/loading_01.png differ diff --git a/app/src/main/res/drawable/loading_02.png b/app/src/main/res/drawable/loading_02.png new file mode 100644 index 0000000..bc930f2 Binary files /dev/null and b/app/src/main/res/drawable/loading_02.png differ diff --git a/app/src/main/res/drawable/loading_03.png b/app/src/main/res/drawable/loading_03.png new file mode 100644 index 0000000..e461335 Binary files /dev/null and b/app/src/main/res/drawable/loading_03.png differ diff --git a/app/src/main/res/drawable/loading_04.png b/app/src/main/res/drawable/loading_04.png new file mode 100644 index 0000000..071af1e Binary files /dev/null and b/app/src/main/res/drawable/loading_04.png differ diff --git a/app/src/main/res/drawable/loading_05.png b/app/src/main/res/drawable/loading_05.png new file mode 100644 index 0000000..43ba85f Binary files /dev/null and b/app/src/main/res/drawable/loading_05.png differ diff --git a/app/src/main/res/drawable/loading_06.png b/app/src/main/res/drawable/loading_06.png new file mode 100644 index 0000000..67c6faa Binary files /dev/null and b/app/src/main/res/drawable/loading_06.png differ diff --git a/app/src/main/res/drawable/loading_07.png b/app/src/main/res/drawable/loading_07.png new file mode 100644 index 0000000..797c5d8 Binary files /dev/null and b/app/src/main/res/drawable/loading_07.png differ diff --git a/app/src/main/res/drawable/loading_08.png b/app/src/main/res/drawable/loading_08.png new file mode 100644 index 0000000..bbeecf2 Binary files /dev/null and b/app/src/main/res/drawable/loading_08.png differ diff --git a/app/src/main/res/drawable/loading_09.png b/app/src/main/res/drawable/loading_09.png new file mode 100644 index 0000000..397c08d Binary files /dev/null and b/app/src/main/res/drawable/loading_09.png differ diff --git a/app/src/main/res/drawable/loading_10.png b/app/src/main/res/drawable/loading_10.png new file mode 100644 index 0000000..2c4c58b Binary files /dev/null and b/app/src/main/res/drawable/loading_10.png differ diff --git a/app/src/main/res/drawable/loading_11.png b/app/src/main/res/drawable/loading_11.png new file mode 100644 index 0000000..587c1df Binary files /dev/null and b/app/src/main/res/drawable/loading_11.png differ diff --git a/app/src/main/res/drawable/loading_12.png b/app/src/main/res/drawable/loading_12.png new file mode 100644 index 0000000..162ffd4 Binary files /dev/null and b/app/src/main/res/drawable/loading_12.png differ diff --git a/app/src/main/res/drawable/open_back_ground.xml b/app/src/main/res/drawable/open_back_ground.xml new file mode 100644 index 0000000..cff1bb2 --- /dev/null +++ b/app/src/main/res/drawable/open_back_ground.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/progress_circle_loading.xml b/app/src/main/res/drawable/progress_circle_loading.xml new file mode 100644 index 0000000..7a9e9f9 --- /dev/null +++ b/app/src/main/res/drawable/progress_circle_loading.xml @@ -0,0 +1,44 @@ + + + +    + +    + +    + +    + +    + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape.xml b/app/src/main/res/drawable/shape.xml new file mode 100644 index 0000000..6737b4a --- /dev/null +++ b/app/src/main/res/drawable/shape.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_foot_add.xml b/app/src/main/res/drawable/shape_foot_add.xml new file mode 100644 index 0000000..26286a4 --- /dev/null +++ b/app/src/main/res/drawable/shape_foot_add.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_fuchuang.xml b/app/src/main/res/drawable/shape_fuchuang.xml new file mode 100644 index 0000000..6c205ac --- /dev/null +++ b/app/src/main/res/drawable/shape_fuchuang.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/app/src/main/res/drawable/shape_window.xml b/app/src/main/res/drawable/shape_window.xml new file mode 100644 index 0000000..085be57 --- /dev/null +++ b/app/src/main/res/drawable/shape_window.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/app/src/main/res/drawable/shape_xuanzhong.xml b/app/src/main/res/drawable/shape_xuanzhong.xml new file mode 100644 index 0000000..0efadd0 --- /dev/null +++ b/app/src/main/res/drawable/shape_xuanzhong.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/thumb.xml b/app/src/main/res/drawable/thumb.xml new file mode 100644 index 0000000..d70d2cc --- /dev/null +++ b/app/src/main/res/drawable/thumb.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/toast_bg.xml b/app/src/main/res/drawable/toast_bg.xml new file mode 100644 index 0000000..c4fbe32 --- /dev/null +++ b/app/src/main/res/drawable/toast_bg.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/track.xml b/app/src/main/res/drawable/track.xml new file mode 100644 index 0000000..dcee653 --- /dev/null +++ b/app/src/main/res/drawable/track.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/app/src/main/res/layout/activity_appoint.xml b/app/src/main/res/layout/activity_appoint.xml new file mode 100644 index 0000000..cd20ff1 --- /dev/null +++ b/app/src/main/res/layout/activity_appoint.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_cancle_follow.xml b/app/src/main/res/layout/activity_cancle_follow.xml new file mode 100644 index 0000000..fbec49d --- /dev/null +++ b/app/src/main/res/layout/activity_cancle_follow.xml @@ -0,0 +1,314 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_dav.xml b/app/src/main/res/layout/activity_dav.xml new file mode 100644 index 0000000..8ac5768 --- /dev/null +++ b/app/src/main/res/layout/activity_dav.xml @@ -0,0 +1,523 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_hong_bao.xml b/app/src/main/res/layout/activity_hong_bao.xml new file mode 100644 index 0000000..212a005 --- /dev/null +++ b/app/src/main/res/layout/activity_hong_bao.xml @@ -0,0 +1,510 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_intera.xml b/app/src/main/res/layout/activity_intera.xml new file mode 100644 index 0000000..56b6bad --- /dev/null +++ b/app/src/main/res/layout/activity_intera.xml @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_keyword.xml b/app/src/main/res/layout/activity_keyword.xml new file mode 100644 index 0000000..fbcf9a2 --- /dev/null +++ b/app/src/main/res/layout/activity_keyword.xml @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_keywordedit.xml b/app/src/main/res/layout/activity_keywordedit.xml new file mode 100644 index 0000000..08f5038 --- /dev/null +++ b/app/src/main/res/layout/activity_keywordedit.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_keywordsho.xml b/app/src/main/res/layout/activity_keywordsho.xml new file mode 100644 index 0000000..4255232 --- /dev/null +++ b/app/src/main/res/layout/activity_keywordsho.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_live.xml b/app/src/main/res/layout/activity_live.xml new file mode 100644 index 0000000..c894a5c --- /dev/null +++ b/app/src/main/res/layout/activity_live.xml @@ -0,0 +1,521 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_live_sui_ji.xml b/app/src/main/res/layout/activity_live_sui_ji.xml new file mode 100644 index 0000000..999b6c4 --- /dev/null +++ b/app/src/main/res/layout/activity_live_sui_ji.xml @@ -0,0 +1,481 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_live_three.xml b/app/src/main/res/layout/activity_live_three.xml new file mode 100644 index 0000000..25cc68c --- /dev/null +++ b/app/src/main/res/layout/activity_live_three.xml @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..7749d9c --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,520 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main1.xml b/app/src/main/res/layout/activity_main1.xml new file mode 100644 index 0000000..405c546 --- /dev/null +++ b/app/src/main/res/layout/activity_main1.xml @@ -0,0 +1,39 @@ + + + + + +