first commit
This commit is contained in:
@@ -1,163 +1,191 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.fisherbone.fuzhu">
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission
|
||||
android:name="android.permission.INJECT_EVENTS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||
<uses-permission android:name="android.permission.REORDER_TASKS" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- 这个权限用于进行网络定位 -->
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 这个权限用于访问GPS定位 -->
|
||||
<uses-permission android:name="android.permission.READ_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 读取手机通讯录 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 写入手机通讯录 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <!-- 这个权限用于进行网络定位 -->
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" /> <!-- 这个权限用于访问GPS定位 -->
|
||||
<uses-permission android:name="android.permission.WRITE_CONTACTS" /> <!-- 用于访问wifi网络信息,wifi信息会用于进行网络定位 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 用于读取手机当前的状态 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 写入扩展存储,向扩展卡写入数据,用于写入离线定位数据 -->
|
||||
<!-- 下载权限 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" /> <!-- 访问网络,网络定位需要上网 -->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!-- 腾讯bugly权限 -->
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" /> <!-- Bugly升级SDK权限配置开始 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <!-- 二维码扫描 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 震动权限 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 摄像头权限 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 用于申请调用A-GPS模块 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 这个权限用于获取wifi的获取权限,wifi信息会用来进行网络定位 -->
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 用于读取手机当前的状态 -->
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <!-- 写入扩展存储,向扩展卡写入数据,用于写入缓存定位数据 -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- 获取手机录音机使用权限,听写、识别、语义理解需要用到此权限 -->
|
||||
<uses-permission android:name="android.permission.INTERNET" /> <!-- 读取联系人权限,上传联系人需要用到此权限 -->
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <!-- 网络权限,加载网络网页需要联网 -->
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" /> <!-- 精确定位权限,允许一个程序访问精确位置(GPS定位) -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
|
||||
<application
|
||||
android:name=".FuzhuApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/atom_logo"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:roundIcon="@mipmap/atom_logo"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name="com.fisherbone.fuzhu.Main2Activity"></activity>
|
||||
<activity android:name="com.fisherbone.fuzhu.MainActivityy">
|
||||
|
||||
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.CancelThumbUpActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.HongBaoActivity"></activity>
|
||||
<activity android:name=".activity.AppointActivity" />
|
||||
<activity android:name=".LiveSuiJiActivity" />
|
||||
<activity android:name=".LiveActivity" />
|
||||
<activity android:name=".activity.ShouQuanActivity" />
|
||||
<activity android:name=".activity.CancleFollowActivity" />
|
||||
<activity android:name=".activity.KeyWordActivity" />
|
||||
<activity android:name=".activity.KeyWordShoActivity" />
|
||||
<activity android:name=".activity.KeyWordEditActivity" />
|
||||
<activity android:name=".activity.InteraActivity" />
|
||||
<activity android:name=".activity.DavActivity" />
|
||||
<activity android:name=".activity.ScriptSettingActivity" />
|
||||
<activity
|
||||
android:name=".activity.RecFollowActivity"
|
||||
android:windowSoftInputMode="stateAlwaysHidden" />
|
||||
<activity android:name=".activity.ScrSetActivity" />
|
||||
<activity android:name=".activity.SettingActivity" />
|
||||
<activity android:name=".activity.PriLetActivity" />
|
||||
<activity android:name=".activity.noticeActivity" />
|
||||
<activity android:name=".activity.DakaActivity" />
|
||||
<activity android:name=".activity.PriLetEditActivity" />
|
||||
<activity android:name=".zxing.activity.CaptureActivity" /> <!-- TODO 更改状态activity,对话框样式 -->
|
||||
<activity
|
||||
android:name=".activity.PublishActivity"
|
||||
android:theme="@style/ActivityDialog" />
|
||||
<activity android:name=".PhoneActivity" />
|
||||
<activity android:name=".activity.MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<provider
|
||||
android:name=".hook.AppInfoProvider"
|
||||
android:authorities="com.fisherbone.fuzhu.hook.AppInfoProvider"
|
||||
android:exported="true" />
|
||||
|
||||
<receiver android:name=".BootBroadcastReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
||||
<service android:name=".TestTwoService" />
|
||||
<service
|
||||
android:name=".abllib.AblService"
|
||||
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
|
||||
<intent-filter android:priority="1000">
|
||||
<action android:name="android.accessibilityservice.AccessibilityService" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.accessibilityservice"
|
||||
android:resource="@xml/abl_service" />
|
||||
</service>
|
||||
|
||||
<provider
|
||||
android:name=".MyProvider"
|
||||
android:authorities="${applicationId}.fileProvider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
<provider
|
||||
android:name=".MyFileProvider"
|
||||
android:authorities="${applicationId}.provider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
</application>
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.fisherbone.fuzhu">
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission
|
||||
android:name="android.permission.INJECT_EVENTS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||
<uses-permission android:name="android.permission.REORDER_TASKS" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- 这个权限用于进行网络定位 -->
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 这个权限用于访问GPS定位 -->
|
||||
<uses-permission android:name="android.permission.READ_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 读取手机通讯录 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 写入手机通讯录 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <!-- 这个权限用于进行网络定位 -->
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" /> <!-- 这个权限用于访问GPS定位 -->
|
||||
<uses-permission android:name="android.permission.WRITE_CONTACTS" /> <!-- 用于访问wifi网络信息,wifi信息会用于进行网络定位 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 用于读取手机当前的状态 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 写入扩展存储,向扩展卡写入数据,用于写入离线定位数据 -->
|
||||
<!-- 下载权限 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" /> <!-- 访问网络,网络定位需要上网 -->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!-- 腾讯bugly权限 -->
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" /> <!-- Bugly升级SDK权限配置开始 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <!-- 二维码扫描 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 震动权限 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 摄像头权限 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 用于申请调用A-GPS模块 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 这个权限用于获取wifi的获取权限,wifi信息会用来进行网络定位 -->
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 用于读取手机当前的状态 -->
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <!-- 写入扩展存储,向扩展卡写入数据,用于写入缓存定位数据 -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- 获取手机录音机使用权限,听写、识别、语义理解需要用到此权限 -->
|
||||
<uses-permission android:name="android.permission.INTERNET" /> <!-- 读取联系人权限,上传联系人需要用到此权限 -->
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <!-- 网络权限,加载网络网页需要联网 -->
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" /> <!-- 精确定位权限,允许一个程序访问精确位置(GPS定位) -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
|
||||
<application
|
||||
android:name=".FuzhuApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/atom_logo"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:roundIcon="@mipmap/atom_logo"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name="com.fisherbone.fuzhu.Main2Activity"
|
||||
android:exported="false"></activity>
|
||||
<activity android:name="com.fisherbone.fuzhu.MainActivityy"
|
||||
android:exported="false">
|
||||
|
||||
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.CancelThumbUpActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.HongBaoActivity"
|
||||
android:exported="false"></activity>
|
||||
<activity android:name=".activity.AppointActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".LiveSuiJiActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".LiveActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.ShouQuanActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.CancleFollowActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.KeyWordActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.KeyWordShoActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.KeyWordEditActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.InteraActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.DavActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.ScriptSettingActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.RecFollowActivity"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.ScrSetActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.SettingActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.PriLetActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.noticeActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.DakaActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.PriLetEditActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".zxing.activity.CaptureActivity"
|
||||
android:exported="false" /> <!-- TODO 更改状态activity,对话框样式 -->
|
||||
<activity
|
||||
android:name=".activity.PublishActivity"
|
||||
android:theme="@style/ActivityDialog"
|
||||
android:exported="false" />
|
||||
<activity android:name=".PhoneActivity"
|
||||
android:exported="false" />
|
||||
<activity android:name=".activity.MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<provider
|
||||
android:name=".hook.AppInfoProvider"
|
||||
android:authorities="com.fisherbone.fuzhu.hook.AppInfoProvider"
|
||||
android:exported="true" />
|
||||
|
||||
<receiver android:name=".BootBroadcastReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
||||
<service android:name=".TestTwoService"
|
||||
android:exported="false" />
|
||||
<service
|
||||
android:name=".abllib.AblService"
|
||||
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
|
||||
android:exported="true">
|
||||
<intent-filter android:priority="1000">
|
||||
<action android:name="android.accessibilityservice.AccessibilityService" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.accessibilityservice"
|
||||
android:resource="@xml/abl_service" />
|
||||
</service>
|
||||
|
||||
<provider
|
||||
android:name=".MyProvider"
|
||||
android:authorities="${applicationId}.fileProvider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
<provider
|
||||
android:name=".MyFileProvider"
|
||||
android:authorities="${applicationId}.provider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,170 +1,175 @@
|
||||
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.github.gzuliyujiang.oaid.DeviceID;
|
||||
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
|
||||
* <p>
|
||||
* on: 2017/3/13.
|
||||
* <p>
|
||||
* 描述: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;
|
||||
}
|
||||
private boolean privacyPolicyAgreed = true;
|
||||
|
||||
@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));
|
||||
|
||||
if (privacyPolicyAgreed) {
|
||||
DeviceID.register(this);
|
||||
privacyPolicyAgreed = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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.github.gzuliyujiang.oaid.DeviceID;
|
||||
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.blankj.utilcode.util.Utils;
|
||||
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
|
||||
* <p>
|
||||
* on: 2017/3/13.
|
||||
* <p>
|
||||
* 描述: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;
|
||||
}
|
||||
private boolean privacyPolicyAgreed = true;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
baseApplication = this;
|
||||
mContext = this;
|
||||
|
||||
// 初始化 utilcode 工具库(必须在最前面,其他工具可能依赖它)
|
||||
// Utils.init(this);
|
||||
|
||||
CrashReport.initCrashReport(getApplicationContext(), "e940e41c92", false);
|
||||
//用户资料存储工具
|
||||
ProfileSpUtils.init(this);
|
||||
DataBaseHelper.initOrmLite(this);
|
||||
initOkGo();
|
||||
MyCrashHandler.getInstance().init(this);
|
||||
NetworkApi.init(new XiangxueNetwork(this));
|
||||
|
||||
if (privacyPolicyAgreed) {
|
||||
DeviceID.register(this);
|
||||
privacyPolicyAgreed = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,249 +1,250 @@
|
||||
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
|
||||
*/
|
||||
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<ActivityManager.RunningServiceInfo> 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<Boolean>() {
|
||||
@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() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
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 {
|
||||
// 使用原生 Toast 替代 blankj 的 ToastUtils,避免在 Activity 未完全初始化时崩溃
|
||||
Toast.makeText(context, "请先开启允许显示在其他应用上权限", Toast.LENGTH_SHORT).show();
|
||||
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<ActivityManager.RunningServiceInfo> 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<Boolean>() {
|
||||
@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() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,231 +1,231 @@
|
||||
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<AccessibilityNodeInfo> 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<Response>() {
|
||||
@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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowed() {
|
||||
boolean ifOpen = false;
|
||||
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
|
||||
for (int i = 0; i < root.getChildCount(); i++) {
|
||||
AccessibilityNodeInfo child = root.getChild(i);
|
||||
if(child!=null) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
}
|
||||
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<AccessibilityNodeInfo> 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<Response>() {
|
||||
@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 <= 409) {
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowed() {
|
||||
boolean ifOpen = false;
|
||||
AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow();
|
||||
for (int i = 0; i < root.getChildCount(); i++) {
|
||||
AccessibilityNodeInfo child = root.getChild(i);
|
||||
if(child!=null) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.fisherbone.fuzhu.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* 安全的 Toast 工具类,用于替代 blankj 的 ToastUtils
|
||||
* 避免在 Application 上下文中使用 Toast 时出现 NullPointerException
|
||||
*/
|
||||
public class SafeToastUtils {
|
||||
|
||||
private static Toast lastToast;
|
||||
|
||||
/**
|
||||
* 显示短时 Toast
|
||||
*/
|
||||
public static void showShort(Context context, CharSequence text) {
|
||||
if (context == null || text == null) {
|
||||
return;
|
||||
}
|
||||
// 取消之前的 Toast
|
||||
if (lastToast != null) {
|
||||
lastToast.cancel();
|
||||
}
|
||||
// 使用原生 Toast,确保使用 Activity 上下文
|
||||
lastToast = Toast.makeText(context.getApplicationContext(), text, Toast.LENGTH_SHORT);
|
||||
lastToast.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示短时 Toast(使用字符串资源 ID)
|
||||
*/
|
||||
public static void showShort(Context context, int resId) {
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
showShort(context, context.getString(resId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示长时 Toast
|
||||
*/
|
||||
public static void showLong(Context context, CharSequence text) {
|
||||
if (context == null || text == null) {
|
||||
return;
|
||||
}
|
||||
// 取消之前的 Toast
|
||||
if (lastToast != null) {
|
||||
lastToast.cancel();
|
||||
}
|
||||
// 使用原生 Toast,确保使用 Activity 上下文
|
||||
lastToast = Toast.makeText(context.getApplicationContext(), text, Toast.LENGTH_LONG);
|
||||
lastToast.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示长时 Toast(使用字符串资源 ID)
|
||||
*/
|
||||
public static void showLong(Context context, int resId) {
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
showLong(context, context.getString(resId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消当前显示的 Toast
|
||||
*/
|
||||
public static void cancel() {
|
||||
if (lastToast != null) {
|
||||
lastToast.cancel();
|
||||
lastToast = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,70 +1,66 @@
|
||||
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.
|
||||
* <p/>
|
||||
* 自定义对话框
|
||||
*/
|
||||
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:
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
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.
|
||||
* <p/>
|
||||
* 自定义对话框
|
||||
*/
|
||||
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) {
|
||||
int id = v.getId();
|
||||
if (id == R.id.dialog_confirm_cancle) {
|
||||
callback.Negative();
|
||||
this.cancel();
|
||||
} else if (id == R.id.dialog_confirm_sure) {
|
||||
callback.Positive();
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,318 +1,314 @@
|
||||
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
|
||||
* <p>
|
||||
* 描述:标题栏组合控件
|
||||
* <p>
|
||||
* sample:
|
||||
* <p>
|
||||
* .xml:
|
||||
* <p>
|
||||
* <com.antiphon.hanyustore.weight.TitleBar
|
||||
* android:id="@+id/title_bar"
|
||||
* android:layout_width="match_parent"
|
||||
* android:layout_height="@dimen/title_height">
|
||||
* <p>
|
||||
* </com.antiphon.hanyustore.weight.TitleBar>
|
||||
* <p>
|
||||
* .java:
|
||||
* <p>
|
||||
* 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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
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
|
||||
* <p>
|
||||
* 描述:标题栏组合控件
|
||||
* <p>
|
||||
* sample:
|
||||
* <p>
|
||||
* .xml:
|
||||
* <p>
|
||||
* <com.antiphon.hanyustore.weight.TitleBar
|
||||
* android:id="@+id/title_bar"
|
||||
* android:layout_width="match_parent"
|
||||
* android:layout_height="@dimen/title_height">
|
||||
* <p>
|
||||
* </com.antiphon.hanyustore.weight.TitleBar>
|
||||
* <p>
|
||||
* .java:
|
||||
* <p>
|
||||
* 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) {
|
||||
int id = view.getId();
|
||||
//左边按钮
|
||||
if (id == R.id.iv_left_btn) {
|
||||
if (null != mListener) {
|
||||
mListener.onLeftButtonClick(view);
|
||||
}
|
||||
if (null != mAllClickListener) {
|
||||
mAllClickListener.onLeftButtonClick(view);
|
||||
}
|
||||
} else if (id == R.id.iv_right_btn) {
|
||||
//右边按钮
|
||||
if (null != mListener) {
|
||||
mListener.onRightButtonClick(view);
|
||||
}
|
||||
if (null != mAllClickListener) {
|
||||
mAllClickListener.onRightButtonClick(view);
|
||||
}
|
||||
} else if (id == R.id.tv_right_text) {
|
||||
//右边文本按钮
|
||||
if (null != mAllClickListener) {
|
||||
mAllClickListener.onRightTextButtonClick(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 底部线是否显示,默认是显示
|
||||
*
|
||||
* @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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,358 +1,355 @@
|
||||
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<BarcodeFormat> 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<DecodeHintType, String> 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;
|
||||
}
|
||||
}
|
||||
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<BarcodeFormat> 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<DecodeHintType, String> 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) {
|
||||
int id = v.getId();
|
||||
if (id == R.id.btn_back) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,140 +1,133 @@
|
||||
/*
|
||||
* 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<BarcodeFormat> 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);//<2F><><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
|
||||
activity.handleDecode((Result) message.obj, barcode);//<2F><><EFBFBD>ؽ<EFBFBD><D8BD>
|
||||
/***********************************************************************/
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* 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<BarcodeFormat> 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) {
|
||||
int what = message.what;
|
||||
if (what == 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);
|
||||
}
|
||||
} else if (what == R.id.restart_preview) {
|
||||
Log.d(TAG, "Got restart preview message");
|
||||
restartPreviewAndDecode();
|
||||
} else if (what == 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);//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
|
||||
activity.handleDecode((Result) message.obj, barcode);//<2F><><EFBFBD>ؽ<EFBFBD><EFBFBD>
|
||||
/***********************************************************************/
|
||||
} else if (what == 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);
|
||||
} else if (what == R.id.return_scan_result) {
|
||||
Log.d(TAG, "Got return scan result message");
|
||||
activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
|
||||
activity.finish();
|
||||
} else if (what == 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);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,113 +1,110 @@
|
||||
/*
|
||||
* 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<DecodeHintType, Object> 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* 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<DecodeHintType, Object> hints) {
|
||||
multiFormatReader = new MultiFormatReader();
|
||||
multiFormatReader.setHints(hints);
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message message) {
|
||||
int what = message.what;
|
||||
if (what == R.id.decode) {
|
||||
//Log.d(TAG, "Got decode message");
|
||||
decode((byte[]) message.obj, message.arg1, message.arg2);
|
||||
} else if (what == R.id.quit) {
|
||||
Looper.myLooper().quit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,394 +1,393 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
|
||||
<import type="android.view.View" />
|
||||
|
||||
<variable
|
||||
name="settingBean"
|
||||
type="com.fisherbone.fuzhu.entity.SettingBean" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.fisherbone.fuzhu.widget.TitleBar
|
||||
android:id="@+id/title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#fff5f5f5"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_switch"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="云端群控"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="16sp" />
|
||||
|
||||
|
||||
<Switch
|
||||
android:id="@+id/set_switch1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginEnd="26dp"
|
||||
android:layout_marginBottom="7dp"
|
||||
|
||||
android:switchMinWidth="20dp"
|
||||
android:textOff="off"
|
||||
android:textOn="on"
|
||||
android:thumb="@drawable/thumb"
|
||||
android:track="@drawable/track" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"
|
||||
android:background="@color/txt_color" />
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_env"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_env"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="获取当前手机的登录的抖音号"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_version"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="检查更新"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_vewsion"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:layout_marginRight="60dp"
|
||||
android:text="v.1.0"
|
||||
android:textColor="#999999"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_aut"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_aut"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="激活授权"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_can"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_can"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="注销授权"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_openwuzhangai"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="打开辅助服务设置"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_openfuchuang"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="打开允许在其他应用上显示权限"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_openapp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:visibility="gone"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="启动守护app"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_getdouyin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="调试"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_jihuo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:visibility="gone"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="激活"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_daoru"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="导入通讯录"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_lianxiren"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginBottom="7dp"
|
||||
android:layout_toLeftOf="@+id/et_hongbao_05"
|
||||
android:background="@null"
|
||||
android:hint=""
|
||||
android:inputType="number"
|
||||
android:textColor="#ff3d3d3d"
|
||||
android:textColorHint="#ffcccccc"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/et_hongbao_05"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginEnd="60dp"
|
||||
android:layout_marginBottom="7dp"
|
||||
android:gravity="center"
|
||||
android:hint="个"
|
||||
|
||||
android:inputType="number"
|
||||
android:textColor="#ff3d3d3d"
|
||||
android:textColorHint="#ffcccccc"
|
||||
android:textSize="12sp" />
|
||||
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_ceshi"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:visibility="invisible"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="测试"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</layout>
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
|
||||
<import type="android.view.View" />
|
||||
|
||||
<variable
|
||||
name="settingBean"
|
||||
type="com.fisherbone.fuzhu.entity.SettingBean" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.fisherbone.fuzhu.widget.TitleBar
|
||||
android:id="@+id/title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#fff5f5f5"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_switch"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="云端群控"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="16sp" />
|
||||
|
||||
|
||||
<Switch
|
||||
android:id="@+id/switchMsgNotification"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginEnd="26dp"
|
||||
android:layout_marginBottom="7dp"
|
||||
android:switchMinWidth="20dp"
|
||||
android:textOff="off"
|
||||
android:textOn="on"
|
||||
android:thumb="@drawable/thumb"
|
||||
android:track="@drawable/track" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"
|
||||
android:background="@color/txt_color" />
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_env"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_env"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="获取当前手机的登录的抖音号"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_version"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="检查更新"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_vewsion"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:layout_marginRight="60dp"
|
||||
android:text="v.1.0"
|
||||
android:textColor="#999999"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_aut"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_aut"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="激活授权"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_can"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_can"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="注销授权"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_openwuzhangai"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="打开辅助服务设置"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_openfuchuang"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="打开允许在其他应用上显示权限"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_openapp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:visibility="gone"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="启动守护app"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_getdouyin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="调试"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_jihuo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:visibility="gone"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="激活"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_daoru"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="导入通讯录"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_lianxiren"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginBottom="7dp"
|
||||
android:layout_toLeftOf="@+id/et_hongbao_05"
|
||||
android:background="@null"
|
||||
android:hint=""
|
||||
android:inputType="number"
|
||||
android:textColor="#ff3d3d3d"
|
||||
android:textColorHint="#ffcccccc"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/et_hongbao_05"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginEnd="60dp"
|
||||
android:layout_marginBottom="7dp"
|
||||
android:gravity="center"
|
||||
android:hint="个"
|
||||
|
||||
android:inputType="number"
|
||||
android:textColor="#ff3d3d3d"
|
||||
android:textColorHint="#ffcccccc"
|
||||
android:textSize="12sp" />
|
||||
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_ceshi"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:visibility="invisible"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="19dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="23dp"
|
||||
android:text="测试"
|
||||
android:textColor="#ff000000"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView style="@style/fragment_imag" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="#F5F5F5" />
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</layout>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user