build: 没修改之前的代码升级agp8
This commit is contained in:
157
app/build.gradle
157
app/build.gradle
@@ -1,31 +1,18 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: "com.tencent.android.tpns"
|
|
||||||
|
|
||||||
static def appName() {
|
static def appName() {
|
||||||
return "FLYSN"
|
return "FLYSN"
|
||||||
}
|
}
|
||||||
|
|
||||||
static def releaseTime() {
|
static def releaseTime() {
|
||||||
return new Date().format("yyyyMMdd-HHmmss", TimeZone.getDefault())
|
return new Date().format("yyyyMMdd_HHmmss", TimeZone.getDefault())
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
// gradle.projectsEvaluated {
|
namespace "com.fuying.sn"
|
||||||
// tasks.withType(JavaCompile) {
|
|
||||||
// Set<File> fileSet = options.bootstrapClasspath.getFiles()
|
|
||||||
// List<File> newFileList = new ArrayList<>();
|
|
||||||
// //JAVA语法,可连续调用,输入参数建议为相对路径
|
|
||||||
// newFileList.add(new File("libs/framework.jar"))
|
|
||||||
// //最后将原始参数添加
|
|
||||||
// newFileList.addAll(fileSet)
|
|
||||||
// options.bootstrapClasspath = files(
|
|
||||||
// newFileList.toArray()
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
compileSdkVersion 29
|
compileSdkVersion 29
|
||||||
buildToolsVersion "29.0.3"
|
buildToolsVersion "36.0.0"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.fuying.sn"
|
applicationId "com.fuying.sn"
|
||||||
@@ -41,45 +28,54 @@ android {
|
|||||||
// 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
|
// 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
|
||||||
}
|
|
||||||
|
|
||||||
javaCompileOptions {
|
|
||||||
annotationProcessorOptions {
|
|
||||||
includeCompileClasspath true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
checkReleaseBuilds false
|
checkReleaseBuilds false
|
||||||
}
|
// Or, if you prefer, you can continue to check for errors in release builds,
|
||||||
|
// but continue the build even when errors are found:
|
||||||
dataBinding {
|
abortOnError false
|
||||||
enabled true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
XG_ACCESS_ID : "1500031216",
|
XG_ACCESS_ID : "1500031216",
|
||||||
XG_ACCESS_KEY: "A1HBG2922B9Z",
|
XG_ACCESS_KEY: "A1HBG2922B9Z",
|
||||||
]
|
]
|
||||||
buildConfigField "String", "SCREEN_URL", '"https://as.fuyingy.com:3018/wm/is_online"'
|
|
||||||
buildConfigField "String", "WEBSOCKET_URL", '"wss://47.111.23.154:3018"'
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
|
||||||
|
buildFeatures {
|
||||||
|
dataBinding true
|
||||||
|
buildConfig true
|
||||||
|
aidl true
|
||||||
}
|
}
|
||||||
|
|
||||||
//多版本
|
//多版本
|
||||||
productFlavors {
|
productFlavors {
|
||||||
// beta {
|
beta {
|
||||||
// flavorDimensions "default"
|
flavorDimensions "default"
|
||||||
// versionCode 33
|
versionCode 89
|
||||||
// versionName "4.2"
|
versionName "4.3"
|
||||||
// }
|
// applicationId "com.fuying.sn"
|
||||||
|
applicationId "com.fying.sntest"
|
||||||
|
|
||||||
|
buildConfigField "String", "ROOT_URL", '"https://fxyapi.17hxg.com/android/"'
|
||||||
|
buildConfigField "String", "SCREEN_URL", '"https://fxyapi.17hxg.com:3018/wm/is_online"'
|
||||||
|
// buildConfigField "String", "WEBSOCKET_URL", '"wss://47.111.23.154:3018"'
|
||||||
|
}
|
||||||
|
|
||||||
official {
|
official {
|
||||||
flavorDimensions "default"
|
flavorDimensions "default"
|
||||||
versionCode 87
|
versionCode 87
|
||||||
versionName "3.4.7"
|
versionName "3.4.7"
|
||||||
|
applicationId "com.fuying.sn"
|
||||||
|
|
||||||
|
buildConfigField "String", "ROOT_URL", '"https://as.fuyingy.com/android/"'
|
||||||
|
buildConfigField "String", "SCREEN_URL", '"https://as.fuyingy.com:3018/wm/is_online"'
|
||||||
|
// buildConfigField "String", "WEBSOCKET_URL", '"wss://47.111.23.154:3018"'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -450,48 +446,28 @@ android {
|
|||||||
debug {
|
debug {
|
||||||
buildConfigField "String", "platform", '"MTK"'
|
buildConfigField "String", "platform", '"MTK"'
|
||||||
versionNameSuffix "-debug"
|
versionNameSuffix "-debug"
|
||||||
//Zipalign优化
|
|
||||||
zipAlignEnabled true
|
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
signingConfig signingConfigs.mtk
|
signingConfig signingConfigs.mtk
|
||||||
applicationVariants.all { variant ->
|
|
||||||
variant.outputs.each { output ->
|
|
||||||
if (outputFile != null) {
|
|
||||||
def fileName = "${appName()}-${variant.versionCode}-V${variant.versionName}-${releaseTime()}-${buildType.name}.apk"
|
|
||||||
output.outputFileName = fileName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
release {
|
release {
|
||||||
buildConfigField "String", "platform", '"MTK"'
|
buildConfigField "String", "platform", '"MTK"'
|
||||||
//Zipalign优化
|
|
||||||
zipAlignEnabled true
|
|
||||||
//混淆
|
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
//前一部分代表系统默认的android程序的混淆文件,该文件已经包含了基本的混淆声明,后一个文件是自己的定义混淆文件
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
||||||
//签名
|
|
||||||
signingConfig signingConfigs.mtk
|
signingConfig signingConfigs.mtk
|
||||||
// 将release版本的包名重命名,加上版本及日期
|
|
||||||
applicationVariants.all { variant ->
|
|
||||||
variant.outputs.each { output ->
|
|
||||||
def outputFile = ""
|
|
||||||
if (outputFile != null) {
|
|
||||||
def fileName = "${appName()}-${variant.versionCode}-V${variant.versionName}-${releaseTime()}-${buildType.name}.apk"
|
|
||||||
output.outputFileName = new File(outputFile, fileName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lintOptions {
|
// Add application variant configuration here instead
|
||||||
checkReleaseBuilds false
|
applicationVariants.all { variant ->
|
||||||
// Or, if you prefer, you can continue to check for errors in release builds,
|
variant.outputs.each { output ->
|
||||||
// but continue the build even when errors are found:
|
def buildType = variant.buildType.name
|
||||||
abortOnError false
|
if (buildType.contains("debug")) {
|
||||||
|
output.outputFileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType}_debug.apk"
|
||||||
|
} else {
|
||||||
|
output.outputFileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType}.apk"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,8 +517,6 @@ dependencies {
|
|||||||
implementation 'com.tencent:mmkv-static:1.2.13'
|
implementation 'com.tencent:mmkv-static:1.2.13'
|
||||||
//bugly
|
//bugly
|
||||||
implementation 'com.tencent.bugly:crashreport:4.1.9.2'
|
implementation 'com.tencent.bugly:crashreport:4.1.9.2'
|
||||||
//腾讯移动推送 TPNS
|
|
||||||
implementation 'com.tencent.tpns:tpns:1.4.4.2-release'
|
|
||||||
//阿里云推送
|
//阿里云推送
|
||||||
implementation 'com.aliyun.ams:alicloud-android-push:3.8.0'
|
implementation 'com.aliyun.ams:alicloud-android-push:3.8.0'
|
||||||
//百度地图
|
//百度地图
|
||||||
@@ -563,23 +537,28 @@ dependencies {
|
|||||||
// implementation 'com.hjq:xxpermissions:6.0'
|
// implementation 'com.hjq:xxpermissions:6.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
preBuild {
|
// 在 dependencies 之后添加
|
||||||
doLast {
|
project.afterEvaluate {
|
||||||
def imlFile = file(project.name + ".iml")
|
android.applicationVariants.all { variant ->
|
||||||
println 'Change ' + project.name + '.iml order'
|
variant.javaCompileProvider.get().options.bootstrapClasspath = files(
|
||||||
try {
|
file('libs/framework.jar'),
|
||||||
def parsedXml = (new XmlParser()).parse(imlFile)
|
android.getBootClasspath()
|
||||||
def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' }
|
)
|
||||||
parsedXml.component[1].remove(jdkNode)
|
}
|
||||||
def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform"
|
}
|
||||||
println 'what' + sdkString
|
|
||||||
new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK'])
|
tasks.register('deleteAppSourceWhiteList', Exec) {
|
||||||
groovy.xml.XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile))
|
// Windows 系统使用 cmd /c, Mac/Linux 使用 sh -c
|
||||||
} catch (FileNotFoundException e) {
|
if (System.properties['os.name'].toLowerCase().contains('windows')) {
|
||||||
// nop, iml not found
|
commandLine 'cmd', '/c', 'adb', 'shell', 'settings', 'delete', 'system', 'app_source_white_list'
|
||||||
println "no iml found"
|
} else {
|
||||||
}
|
commandLine 'adb', 'shell', 'settings', 'delete', 'system', 'app_source_white_list'
|
||||||
|
}
|
||||||
|
|
||||||
|
// 即使命令执行失败也不中断构建(可选,防止因为没连手机导致编译失败)
|
||||||
|
ignoreExitValue = true
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
println "ADB command executed: settings delete system app_source_white_list"
|
||||||
}
|
}
|
||||||
//https://www.pianshen.com/article/93481144911/
|
|
||||||
//使用系统编译后的framework.jar
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,13 +73,6 @@
|
|||||||
<!-- 如果您的应用需要后台定位权限,且有可能运行在Android Q设备上,并且设置了target>28,必须增加这个权限声明 -->
|
<!-- 如果您的应用需要后台定位权限,且有可能运行在Android Q设备上,并且设置了target>28,必须增加这个权限声明 -->
|
||||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
||||||
|
|
||||||
|
|
||||||
<!-- 【必须】 移动推送 TPNS SDK VIP版本所需权限 -->
|
|
||||||
<permission
|
|
||||||
android:name="com.fuying.sn.permission.XGPUSH_RECEIVE"
|
|
||||||
android:protectionLevel="signature" />
|
|
||||||
<uses-permission android:name="com.fuying.sn.permission.XGPUSH_RECEIVE" />
|
|
||||||
|
|
||||||
<!-- 【必须】 移动推送 TPNS SDK 所需权限 -->
|
<!-- 【必须】 移动推送 TPNS SDK 所需权限 -->
|
||||||
<!-- <uses-permission android:name="android.permission.INTERNET" />-->
|
<!-- <uses-permission android:name="android.permission.INTERNET" />-->
|
||||||
<!-- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />-->
|
<!-- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />-->
|
||||||
@@ -206,7 +199,7 @@
|
|||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="com.fuying.sn.fileprovider"
|
android:authorities="${applicationId}.fileprovider"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:grantUriPermissions="true">
|
android:grantUriPermissions="true">
|
||||||
<meta-data
|
<meta-data
|
||||||
@@ -225,19 +218,6 @@
|
|||||||
android:name="org.apache.http.legacy"
|
android:name="org.apache.http.legacy"
|
||||||
android:required="false" />
|
android:required="false" />
|
||||||
|
|
||||||
<!-- 【可选】APP实现的Receiver,用于接收消息透传和操作结果的回调,请根据需要添加 -->
|
|
||||||
<!-- YOUR_PACKAGE_PATH.CustomPushReceiver需要改为自己的Receiver: -->
|
|
||||||
<receiver android:name=".push.tpush.MessageReceiver">
|
|
||||||
<intent-filter>
|
|
||||||
|
|
||||||
<!-- 接收消息透传 -->
|
|
||||||
<action android:name="com.tencent.android.xg.vip.action.PUSH_MESSAGE" />
|
|
||||||
|
|
||||||
<!-- 监听注册、反注册、设置/删除标签、通知被点击等处理结果 -->
|
|
||||||
<action android:name="com.tencent.android.xg.vip.action.FEEDBACK" />
|
|
||||||
</intent-filter>
|
|
||||||
</receiver>
|
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".push.alipush.AliyunMessageReceiver"
|
android:name=".push.alipush.AliyunMessageReceiver"
|
||||||
android:exported="false">
|
android:exported="false">
|
||||||
@@ -266,16 +246,6 @@
|
|||||||
<!-- </intent-filter> -->
|
<!-- </intent-filter> -->
|
||||||
<!-- </service> -->
|
<!-- </service> -->
|
||||||
|
|
||||||
<!-- 【必须】 请修改为 APP 的 AccessId,“15”开头的10位数字,中间没空格 -->
|
|
||||||
<meta-data
|
|
||||||
android:name="XG_V2_ACCESS_ID"
|
|
||||||
android:value="1500031216" />
|
|
||||||
|
|
||||||
<!-- 【必须】 请修改为APP的AccessKey,“A”开头的12位字符串,中间没空格 -->
|
|
||||||
<meta-data
|
|
||||||
android:name="XG_V2_ACCESS_KEY"
|
|
||||||
android:value="A1HBG2922B9Z" />
|
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.baidu.lbsapi.API_KEY"
|
android:name="com.baidu.lbsapi.API_KEY"
|
||||||
android:value="${AK}" />
|
android:value="${AK}" />
|
||||||
|
|||||||
@@ -34,9 +34,6 @@ import com.fuying.sn.utils.AppUsedTimeUtils;
|
|||||||
import com.fuying.sn.utils.JGYUtils;
|
import com.fuying.sn.utils.JGYUtils;
|
||||||
import com.fuying.sn.utils.SystemUtils;
|
import com.fuying.sn.utils.SystemUtils;
|
||||||
import com.fuying.sn.utils.Utils;
|
import com.fuying.sn.utils.Utils;
|
||||||
import com.tencent.android.tpush.XGIOperateCallback;
|
|
||||||
import com.tencent.android.tpush.XGPushConfig;
|
|
||||||
import com.tencent.android.tpush.XGPushManager;
|
|
||||||
import com.tencent.bugly.crashreport.CrashReport;
|
import com.tencent.bugly.crashreport.CrashReport;
|
||||||
import com.tencent.mmkv.MMKV;
|
import com.tencent.mmkv.MMKV;
|
||||||
|
|
||||||
@@ -79,7 +76,6 @@ public class BaseApplication extends Application {
|
|||||||
|
|
||||||
PushManager.init(this);
|
PushManager.init(this);
|
||||||
aliyunPushInit();
|
aliyunPushInit();
|
||||||
tPushInit();
|
|
||||||
|
|
||||||
JGYUtils.init(this);
|
JGYUtils.init(this);
|
||||||
CrashReport.initCrashReport(getApplicationContext(), "e5f026c8d5", false);
|
CrashReport.initCrashReport(getApplicationContext(), "e5f026c8d5", false);
|
||||||
@@ -196,36 +192,4 @@ public class BaseApplication extends Application {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tPushInit() {
|
|
||||||
XGPushConfig.enableDebug(this, true);
|
|
||||||
XGPushConfig.enablePullUpOtherApp(this, false);
|
|
||||||
XGPushManager.registerPush(this, new XGIOperateCallback() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Object data, int flag) {
|
|
||||||
//token在设备卸载重装的时候有可能会变
|
|
||||||
Log.e("TPush", "注册成功,设备token为:" + data);
|
|
||||||
List<XGPushManager.AccountInfo> accountInfoList = new ArrayList<>();
|
|
||||||
Log.e("TPush", "onSuccess: " + Utils.getSerial());
|
|
||||||
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial()));
|
|
||||||
// accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getIMEI(getApplicationContext())));
|
|
||||||
XGPushManager.upsertAccounts(getApplicationContext(), accountInfoList, new XGIOperateCallback() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Object data, int flag) {
|
|
||||||
Log.e("TPush", "upsertAccounts onSuccess, data:" + data + ", flag:" + flag);
|
|
||||||
NetInterfaceManager.getInstance().setPushTags();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFail(Object data, int errCode, String msg) {
|
|
||||||
Log.e("TPush", "upsertAccounts onFail, data:" + data + ", code:" + errCode + ", msg:" + msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFail(Object data, int errCode, String msg) {
|
|
||||||
Log.e("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class InfoDialog extends Dialog {
|
|||||||
private InfoDialog mDialog;
|
private InfoDialog mDialog;
|
||||||
|
|
||||||
public Builder(Context context) {
|
public Builder(Context context) {
|
||||||
mDialog = new InfoDialog(context, R.style.Theme_AppCompat_Dialog);
|
mDialog = new InfoDialog(context, R.style.CustomDialog);
|
||||||
LayoutInflater inflater =
|
LayoutInflater inflater =
|
||||||
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
//加载布局文件
|
//加载布局文件
|
||||||
|
|||||||
@@ -107,8 +107,6 @@ import com.google.gson.Gson;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.tencent.android.tpush.XGIOperateCallback;
|
|
||||||
import com.tencent.android.tpush.XGPushManager;
|
|
||||||
import com.tencent.mmkv.MMKV;
|
import com.tencent.mmkv.MMKV;
|
||||||
import com.trello.rxlifecycle4.RxLifecycle;
|
import com.trello.rxlifecycle4.RxLifecycle;
|
||||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||||
@@ -192,7 +190,7 @@ public class NetInterfaceManager {
|
|||||||
}
|
}
|
||||||
mRetrofit = new Retrofit.Builder()
|
mRetrofit = new Retrofit.Builder()
|
||||||
.client(okHttpClient)
|
.client(okHttpClient)
|
||||||
.baseUrl(UrlAddress.ROOT_URL)
|
.baseUrl(BuildConfig.ROOT_URL)
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
|
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
|
||||||
.build();
|
.build();
|
||||||
@@ -756,18 +754,6 @@ public class NetInterfaceManager {
|
|||||||
set.add(JGYUtils.G12NLTag);
|
set.add(JGYUtils.G12NLTag);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
XGPushManager.clearAndAppendTags(mContext, "clearAndAppendTags :" + System.currentTimeMillis(), set, new XGIOperateCallback() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Object o, int i) {
|
|
||||||
Log.e("clearAndAppendTags", "onSuccess: " + o + " tag " + set);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFail(Object o, int i, String s) {
|
|
||||||
Log.e("clearAndAppendTags", "onFail: " + o);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
String[] tagSets = new ArrayList<>(set).toArray(new String[set.size()]);
|
String[] tagSets = new ArrayList<>(set).toArray(new String[set.size()]);
|
||||||
CloudPushService pushService = PushServiceFactory.getCloudPushService();
|
CloudPushService pushService = PushServiceFactory.getCloudPushService();
|
||||||
pushService.bindTag(CloudPushService.DEVICE_TARGET, tagSets, null, new CommonCallback() {
|
pushService.bindTag(CloudPushService.DEVICE_TARGET, tagSets, null, new CommonCallback() {
|
||||||
@@ -792,17 +778,6 @@ public class NetInterfaceManager {
|
|||||||
if (!TextUtils.isEmpty(tag)) {
|
if (!TextUtils.isEmpty(tag)) {
|
||||||
tagSets.add(tag);
|
tagSets.add(tag);
|
||||||
}
|
}
|
||||||
XGPushManager.clearAndAppendTags(mContext, "clearAndAppendTags :" + System.currentTimeMillis(), tagSets, new XGIOperateCallback() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Object o, int i) {
|
|
||||||
Log.e("clearAndAppendTags", "onSuccess: " + o + " tag " + tagSets);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFail(Object o, int i, String s) {
|
|
||||||
Log.e("clearAndAppendTags", "onFail: " + o);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
String[] set = new ArrayList<>(tagSets).toArray(new String[tagSets.size()]);
|
String[] set = new ArrayList<>(tagSets).toArray(new String[tagSets.size()]);
|
||||||
CloudPushService pushService = PushServiceFactory.getCloudPushService();
|
CloudPushService pushService = PushServiceFactory.getCloudPushService();
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package com.fuying.sn.network;
|
package com.fuying.sn.network;
|
||||||
|
|
||||||
public class UrlAddress {
|
public class UrlAddress {
|
||||||
/*主页接口*/
|
|
||||||
static final String ROOT_URL = "http://47.111.23.154/android/";
|
|
||||||
|
|
||||||
//不需要做缓存的接口
|
//不需要做缓存的接口
|
||||||
|
|
||||||
/*获取app桌面管控配置*/
|
/*获取app桌面管控配置*/
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.fuying.sn.push.tpush;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by chacewang on 2019/7/5.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class Constants {
|
|
||||||
public static final int TEST_LOCAL_NOTIFICATION = 1;
|
|
||||||
public static final int TEST_NOTIFICATION = 2;
|
|
||||||
public static final int TEST_SET_TAG = 3;
|
|
||||||
public static final int TEST_DEL_TAG = 4;
|
|
||||||
public static final int TEST_SET_ACCOUNT = 5;
|
|
||||||
public static final int TEST_DEL_ACCOUNT = 6;
|
|
||||||
|
|
||||||
public static final String LOCAL_NOTIFICATION_TITLE = "localtest";
|
|
||||||
public static final String TEST_TAG_NAME = "DiagnosisTag";
|
|
||||||
}
|
|
||||||
@@ -1,297 +0,0 @@
|
|||||||
package com.fuying.sn.push.tpush;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.fuying.sn.push.tpush.common.NotificationService;
|
|
||||||
import com.fuying.sn.push.tpush.po.XGNotification;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import com.tencent.android.tpush.NotificationAction;
|
|
||||||
import com.tencent.android.tpush.XGPushBaseReceiver;
|
|
||||||
import com.tencent.android.tpush.XGPushClickedResult;
|
|
||||||
import com.tencent.android.tpush.XGPushRegisterResult;
|
|
||||||
import com.tencent.android.tpush.XGPushShowedResult;
|
|
||||||
import com.tencent.android.tpush.XGPushTextMessage;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
public class MessageReceiver extends XGPushBaseReceiver {
|
|
||||||
public static final String UPDATE_LISTVIEW_ACTION = "com.qq.xgdemo.activity.UPDATE_LISTVIEW";
|
|
||||||
public static final String TEST_ACTION = "com.qq.xgdemo.activity.TEST_ACTION";
|
|
||||||
public static final String LogTag = "xg.test";
|
|
||||||
|
|
||||||
private static final String TAG = "MessageReceiver";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 消息透传处理
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
* @param message 解析自定义的 JSON
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onTextMessage(Context context, XGPushTextMessage message) {
|
|
||||||
|
|
||||||
String text = "收到消息:" + message.toString();
|
|
||||||
// 获取自定义key-value
|
|
||||||
String customContent = message.getCustomContent();
|
|
||||||
if (customContent != null && customContent.length() != 0) {
|
|
||||||
JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject();
|
|
||||||
// key1为前台配置的key
|
|
||||||
if (!TextUtils.isEmpty(obj.get("key").getAsString())) {
|
|
||||||
String value = obj.get("key").getAsString();
|
|
||||||
Log.d(LogTag, "get custom value:" + value);
|
|
||||||
}
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
// APP自主处理消息的过程...
|
|
||||||
Log.e(LogTag, text);
|
|
||||||
show(context, text);
|
|
||||||
processCustomMessage(context, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知展示
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
* @param notifiShowedRlt 包含通知的内容
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onNotificationShowedResult(Context context, XGPushShowedResult notifiShowedRlt) {
|
|
||||||
if (context == null || notifiShowedRlt == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
XGNotification notific = new XGNotification();
|
|
||||||
notific.setMsg_id(notifiShowedRlt.getMsgId());
|
|
||||||
notific.setTitle(notifiShowedRlt.getTitle());
|
|
||||||
notific.setContent(notifiShowedRlt.getContent());
|
|
||||||
// notificationActionType==1为Activity,2为url,3为intent
|
|
||||||
notific.setNotificationActionType(notifiShowedRlt
|
|
||||||
.getNotificationActionType());
|
|
||||||
// Activity,url,intent都可以通过getActivity()获得
|
|
||||||
notific.setActivity(notifiShowedRlt.getActivity());
|
|
||||||
notific.setUpdate_time(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
|
||||||
.format(Calendar.getInstance().getTime()));
|
|
||||||
NotificationService.getInstance(context).save(notific);
|
|
||||||
|
|
||||||
Intent testIntent = new Intent(TEST_ACTION);
|
|
||||||
if (notifiShowedRlt.getTitle().equals(Constants.LOCAL_NOTIFICATION_TITLE)) {
|
|
||||||
testIntent.putExtra("step", Constants.TEST_LOCAL_NOTIFICATION);
|
|
||||||
} else {
|
|
||||||
testIntent.putExtra("step", Constants.TEST_NOTIFICATION);
|
|
||||||
}
|
|
||||||
context.sendBroadcast(testIntent);
|
|
||||||
|
|
||||||
Intent viewIntent = new Intent(UPDATE_LISTVIEW_ACTION);
|
|
||||||
context.sendBroadcast(viewIntent);
|
|
||||||
show(context, "您有1条新消息, " + "通知被展示 , " + notifiShowedRlt.toString());
|
|
||||||
Log.d(LogTag, "您有1条新消息, " + "通知被展示 , " + notifiShowedRlt.toString() + ", PushChannel:" + notifiShowedRlt.getPushChannel());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注册回调
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
* @param errorCode 0 为成功,其它为错误码
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onRegisterResult(Context context, int errorCode, XGPushRegisterResult message) {
|
|
||||||
if (context == null || message == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String text = "";
|
|
||||||
if (errorCode == XGPushBaseReceiver.SUCCESS) {
|
|
||||||
// 在这里拿token
|
|
||||||
String token = message.getToken();
|
|
||||||
text = "注册成功1. token:" + token;
|
|
||||||
} else {
|
|
||||||
text = message + "注册失败,错误码:" + errorCode;
|
|
||||||
}
|
|
||||||
Log.d(LogTag, text);
|
|
||||||
show(context, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 反注册回调
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
* @param errorCode 0 为成功,其它为错误码
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onUnregisterResult(Context context, int errorCode) {
|
|
||||||
if (context == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String text = "";
|
|
||||||
if (errorCode == XGPushBaseReceiver.SUCCESS) {
|
|
||||||
text = "反注册成功";
|
|
||||||
} else {
|
|
||||||
text = "反注册失败" + errorCode;
|
|
||||||
}
|
|
||||||
Log.d(LogTag, text);
|
|
||||||
show(context, text);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置标签回调
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
* @param errorCode 0 为成功,其它为错误码
|
|
||||||
* @param tagName 设置的 TAG
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onSetTagResult(Context context, int errorCode, String tagName) {
|
|
||||||
if (context == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String text = "";
|
|
||||||
if (errorCode == XGPushBaseReceiver.SUCCESS) {
|
|
||||||
text = "\"" + tagName + "\"设置成功";
|
|
||||||
} else {
|
|
||||||
text = "\"" + tagName + "\"设置失败,错误码:" + errorCode;
|
|
||||||
}
|
|
||||||
Log.d(LogTag, text);
|
|
||||||
show(context, text);
|
|
||||||
|
|
||||||
Intent testIntent = new Intent(TEST_ACTION);
|
|
||||||
testIntent.putExtra("step", Constants.TEST_SET_TAG);
|
|
||||||
context.sendBroadcast(testIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除标签的回调
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
* @param errorCode 0 为成功,其它为错误码
|
|
||||||
* @param tagName 设置的 TAG
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onDeleteTagResult(Context context, int errorCode, String tagName) {
|
|
||||||
if (context == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String text = "";
|
|
||||||
if (errorCode == XGPushBaseReceiver.SUCCESS) {
|
|
||||||
text = "\"" + tagName + "\"删除成功";
|
|
||||||
} else {
|
|
||||||
text = "\"" + tagName + "\"删除失败,错误码:" + errorCode;
|
|
||||||
}
|
|
||||||
Log.d(LogTag, text);
|
|
||||||
show(context, text);
|
|
||||||
|
|
||||||
Intent testIntent = new Intent(TEST_ACTION);
|
|
||||||
testIntent.putExtra("step", Constants.TEST_DEL_TAG);
|
|
||||||
context.sendBroadcast(testIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置账号回调
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
* @param errorCode 0 为成功,其它为错误码
|
|
||||||
* @param account 设置的账号
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onSetAccountResult(Context context, int errorCode, String account) {
|
|
||||||
Intent testIntent = new Intent(TEST_ACTION);
|
|
||||||
testIntent.putExtra("step", Constants.TEST_SET_ACCOUNT);
|
|
||||||
context.sendBroadcast(testIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除账号回调
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
* @param errorCode 0 为成功,其它为错误码
|
|
||||||
* @param account 设置的账号
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onDeleteAccountResult(Context context, int errorCode, String account) {
|
|
||||||
Intent testIntent = new Intent(TEST_ACTION);
|
|
||||||
testIntent.putExtra("step", Constants.TEST_DEL_ACCOUNT);
|
|
||||||
context.sendBroadcast(testIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSetAttributeResult(Context context, int i, String s) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDeleteAttributeResult(Context context, int i, String s) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onQueryTagsResult(Context context, int errorCode, String data, String operateName) {
|
|
||||||
Log.i(LogTag, "action - onQueryTagsResult, errorCode:" + errorCode + ", operateName:" + operateName + ", data: " + data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知点击回调 actionType=1为该消息被清除,actionType=0为该消息被点击
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
* @param message 包含被点击通知的内容
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onNotificationClickedResult(Context context, XGPushClickedResult message) {
|
|
||||||
if (context == null || message == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String text = "";
|
|
||||||
if (message.getActionType() == NotificationAction.clicked.getType()) {
|
|
||||||
// 通知在通知栏被点击啦。。。。。
|
|
||||||
// APP自己处理点击的相关动作
|
|
||||||
// 这个动作可以在activity的onResume也能监听,请看第3点相关内容
|
|
||||||
text = "通知被打开 :" + message;
|
|
||||||
} else if (message.getActionType() == NotificationAction.delete.getType()) {
|
|
||||||
// 通知被清除啦。。。。
|
|
||||||
// APP自己处理通知被清除后的相关动作
|
|
||||||
text = "通知被清除 :" + message;
|
|
||||||
}
|
|
||||||
Toast.makeText(context, "广播接收到通知被点击:" + message.toString(),
|
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
// 获取自定义key-value
|
|
||||||
String customContent = message.getCustomContent();
|
|
||||||
if (customContent != null && customContent.length() != 0) {
|
|
||||||
JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject();
|
|
||||||
// key1为前台配置的key
|
|
||||||
if (!TextUtils.isEmpty(obj.get("key").getAsString())) {
|
|
||||||
String value = obj.get("key").getAsString();
|
|
||||||
Log.d(LogTag, "get custom value:" + value);
|
|
||||||
}
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
// APP自主处理的过程。。。
|
|
||||||
Log.d(LogTag, text);
|
|
||||||
show(context, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void show(Context context, String text) {
|
|
||||||
// Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processCustomMessage(Context context, XGPushTextMessage message) {
|
|
||||||
if (context == null || message == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String title = message.getTitle();
|
|
||||||
String content = message.getContent();
|
|
||||||
JsonObject extrasJson = JsonParser.parseString(content).getAsJsonObject();
|
|
||||||
|
|
||||||
String extras = "";
|
|
||||||
if (extrasJson.get("extras") != null) {
|
|
||||||
extras = extrasJson.get("extras").toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// PushManager.getInstance().setPushContent(title, extras);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.fuying.sn.push.tpush.common;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
|
||||||
|
|
||||||
public class DBOpenHelper extends SQLiteOpenHelper {
|
|
||||||
|
|
||||||
public DBOpenHelper(Context context) {
|
|
||||||
super(context, "XGExample.db", null, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(SQLiteDatabase db) {
|
|
||||||
db.execSQL("CREATE TABLE notification (id integer primary key autoincrement,msg_id varchar(64),title varchar(128),activity varchar(256),notificationActionType varchar(512),content text,update_time varchar(16))");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
package com.fuying.sn.push.tpush.common;
|
|
||||||
|
|
||||||
import android.content.ContentValues;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
|
|
||||||
import com.fuying.sn.push.tpush.po.XGNotification;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class NotificationService {
|
|
||||||
private DBOpenHelper dbOpenHelper;
|
|
||||||
private static NotificationService instance = null;
|
|
||||||
|
|
||||||
public NotificationService(Context context) {
|
|
||||||
this.dbOpenHelper = new DBOpenHelper(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized static NotificationService getInstance(Context ctx) {
|
|
||||||
if (null == instance) {
|
|
||||||
instance = new NotificationService(ctx);
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save(XGNotification notification) {
|
|
||||||
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
|
|
||||||
ContentValues values = new ContentValues();
|
|
||||||
values.put("msg_id", notification.getMsg_id());
|
|
||||||
values.put("title", notification.getTitle());
|
|
||||||
values.put("content", notification.getContent());
|
|
||||||
values.put("activity", notification.getActivity());
|
|
||||||
values.put("notificationActionType", notification.getNotificationActionType());
|
|
||||||
values.put("update_time", notification.getUpdate_time());
|
|
||||||
db.insert("notification", null, values);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void delete(Integer id) {
|
|
||||||
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
|
|
||||||
db.delete("notification", "id=?", new String[] { id.toString() });
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteAll() {
|
|
||||||
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
|
|
||||||
db.delete("notification", "", null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(XGNotification notification) {
|
|
||||||
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
|
|
||||||
ContentValues values = new ContentValues();
|
|
||||||
values.put("msg_id", notification.getMsg_id());
|
|
||||||
values.put("title", notification.getTitle());
|
|
||||||
values.put("content", notification.getContent());
|
|
||||||
values.put("activity", notification.getActivity());
|
|
||||||
values.put("notificationActionType", notification.getNotificationActionType());
|
|
||||||
values.put("update_time", notification.getUpdate_time());
|
|
||||||
db.update("notification", values, "id=?", new String[] { notification
|
|
||||||
.getId().toString() });
|
|
||||||
}
|
|
||||||
|
|
||||||
public XGNotification find(Integer id) {
|
|
||||||
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
|
|
||||||
Cursor cursor = db
|
|
||||||
.query("notification",
|
|
||||||
new String[] { "id,msg_id,title,content,activity,notificationActionType,update_time" },
|
|
||||||
"id=?", new String[] { id.toString() }, null, null,
|
|
||||||
null, "1");
|
|
||||||
try {
|
|
||||||
if (cursor.moveToFirst()) {
|
|
||||||
return new XGNotification(cursor.getInt(cursor
|
|
||||||
.getColumnIndex("id")), cursor.getLong(cursor
|
|
||||||
.getColumnIndex("msg_id")), cursor.getString(cursor
|
|
||||||
.getColumnIndex("title")), cursor.getString(cursor
|
|
||||||
.getColumnIndex("content")), cursor.getString(cursor
|
|
||||||
.getColumnIndex("activity")), cursor.getInt(cursor
|
|
||||||
.getColumnIndex("notificationActionType")), cursor.getString(cursor
|
|
||||||
.getColumnIndex("update_time")));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
} finally {
|
|
||||||
cursor.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<XGNotification> getScrollData(int currentPage, int lineSize,
|
|
||||||
String msg_id) {
|
|
||||||
String firstResult = String.valueOf((currentPage - 1) * lineSize);
|
|
||||||
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
|
|
||||||
Cursor cursor = null;
|
|
||||||
try {
|
|
||||||
if (msg_id == null || "".equals(msg_id)) {
|
|
||||||
cursor = db
|
|
||||||
.query("notification",
|
|
||||||
new String[] { "id,msg_id,title,content,activity,notificationActionType,update_time" },
|
|
||||||
null, null, null, null, "update_time DESC",
|
|
||||||
firstResult + "," + lineSize);
|
|
||||||
} else {
|
|
||||||
cursor = db
|
|
||||||
.query("notification",
|
|
||||||
new String[] { "id,msg_id,title,content,activity,notificationActionType,update_time" },
|
|
||||||
"msg_id like ?", new String[] { msg_id + "%" },
|
|
||||||
null, null, "update_time DESC", firstResult
|
|
||||||
+ "," + lineSize);
|
|
||||||
}
|
|
||||||
List<XGNotification> notifications = new ArrayList<XGNotification>();
|
|
||||||
while (cursor.moveToNext()) {
|
|
||||||
notifications.add(new XGNotification(cursor.getInt(cursor
|
|
||||||
.getColumnIndex("id")), cursor.getLong(cursor
|
|
||||||
.getColumnIndex("msg_id")), cursor.getString(cursor
|
|
||||||
.getColumnIndex("title")), cursor.getString(cursor
|
|
||||||
.getColumnIndex("content")), cursor.getString(cursor
|
|
||||||
.getColumnIndex("activity")), cursor.getInt(cursor
|
|
||||||
.getColumnIndex("notificationActionType")), cursor.getString(cursor
|
|
||||||
.getColumnIndex("update_time"))));
|
|
||||||
}
|
|
||||||
return notifications;
|
|
||||||
} finally {
|
|
||||||
cursor.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCount() {
|
|
||||||
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
|
|
||||||
Cursor cursor = db.rawQuery("select count(*) from notification", null);
|
|
||||||
try {
|
|
||||||
cursor.moveToFirst();
|
|
||||||
return cursor.getInt(0);
|
|
||||||
} finally {
|
|
||||||
cursor.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
package com.fuying.sn.push.tpush.po;
|
|
||||||
|
|
||||||
public class XGNotification {
|
|
||||||
private Integer id;
|
|
||||||
private Long msg_id;
|
|
||||||
private String title;
|
|
||||||
private String content;
|
|
||||||
private String activity;
|
|
||||||
private int notificationActionType;
|
|
||||||
private String update_time;
|
|
||||||
|
|
||||||
public XGNotification() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public XGNotification(Integer id, Long msg_id, String title,
|
|
||||||
String content, String activity, int notificationActionType, String update_time) {
|
|
||||||
super();
|
|
||||||
this.id = id;
|
|
||||||
this.msg_id = msg_id;
|
|
||||||
this.title = title;
|
|
||||||
this.content = content;
|
|
||||||
this.activity = activity;
|
|
||||||
this.notificationActionType = notificationActionType;
|
|
||||||
this.update_time = update_time;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Integer id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getMsg_id() {
|
|
||||||
return msg_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMsg_id(Long msg_id) {
|
|
||||||
this.msg_id = msg_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getContent() {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setContent(String content) {
|
|
||||||
this.content = content;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUpdate_time() {
|
|
||||||
return update_time;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUpdate_time(String update_time) {
|
|
||||||
this.update_time = update_time;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getActivity() {
|
|
||||||
return activity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActivity(String activity) {
|
|
||||||
this.activity = activity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNotificationActionType() {
|
|
||||||
return notificationActionType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNotificationActionType(int notificationActionType) {
|
|
||||||
this.notificationActionType = notificationActionType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,9 +13,6 @@ import com.fuying.sn.config.CommonConfig;
|
|||||||
import com.fuying.sn.desktop.RunningAppManager;
|
import com.fuying.sn.desktop.RunningAppManager;
|
||||||
import com.fuying.sn.network.NetInterfaceManager;
|
import com.fuying.sn.network.NetInterfaceManager;
|
||||||
import com.fuying.sn.utils.Utils;
|
import com.fuying.sn.utils.Utils;
|
||||||
import com.tencent.android.tpush.XGIOperateCallback;
|
|
||||||
import com.tencent.android.tpush.XGPushConfig;
|
|
||||||
import com.tencent.android.tpush.XGPushManager;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -36,38 +33,6 @@ public class RemoteService extends Service {
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
Log.e(TAG, "onCreate: ");
|
Log.e(TAG, "onCreate: ");
|
||||||
tPushInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void tPushInit() {
|
|
||||||
XGPushConfig.enableDebug(this, true);
|
|
||||||
XGPushManager.registerPush(this, new XGIOperateCallback() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Object data, int flag) {
|
|
||||||
//token在设备卸载重装的时候有可能会变
|
|
||||||
Log.e("TPush", "注册成功,设备token为:" + data);
|
|
||||||
List<XGPushManager.AccountInfo> accountInfoList = new ArrayList<>();
|
|
||||||
Log.e("TPush", "onSuccess: " + Utils.getSerial());
|
|
||||||
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial()));
|
|
||||||
XGPushManager.upsertAccounts(RemoteService.this, accountInfoList, new XGIOperateCallback() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Object data, int flag) {
|
|
||||||
Log.e("TPush", "upsertAccounts onSuccess, data:" + data + ", flag:" + flag);
|
|
||||||
NetInterfaceManager.getInstance().setPushTags();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFail(Object data, int errCode, String msg) {
|
|
||||||
Log.e("TPush", "upsertAccounts onFail, data:" + data + ", code:" + errCode + ", msg:" + msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFail(Object data, int errCode, String msg) {
|
|
||||||
Log.e("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -45,9 +45,6 @@ import com.fuying.sn.utils.SPUtils;
|
|||||||
import com.fuying.sn.utils.TimeUtils;
|
import com.fuying.sn.utils.TimeUtils;
|
||||||
import com.fuying.sn.utils.ToastUtil;
|
import com.fuying.sn.utils.ToastUtil;
|
||||||
import com.fuying.sn.utils.Utils;
|
import com.fuying.sn.utils.Utils;
|
||||||
import com.tencent.android.tpush.XGIOperateCallback;
|
|
||||||
import com.tencent.android.tpush.XGPushConfig;
|
|
||||||
import com.tencent.android.tpush.XGPushManager;
|
|
||||||
import com.tencent.mmkv.MMKV;
|
import com.tencent.mmkv.MMKV;
|
||||||
import com.trello.rxlifecycle4.LifecycleProvider;
|
import com.trello.rxlifecycle4.LifecycleProvider;
|
||||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||||
@@ -109,7 +106,6 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
|||||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||||
SPUtils.put(MainService.this, CommonConfig.JGY_FIRST_BOOT, 1);
|
SPUtils.put(MainService.this, CommonConfig.JGY_FIRST_BOOT, 1);
|
||||||
tPushInit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 15000);
|
}, 15000);
|
||||||
@@ -247,7 +243,6 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initConfig() {
|
private void initConfig() {
|
||||||
tPushInit();
|
|
||||||
// Utils.getPublicIP(MainService.this);
|
// Utils.getPublicIP(MainService.this);
|
||||||
LocationClient locationClient = AmapManager.getInstance().getLocationClient();
|
LocationClient locationClient = AmapManager.getInstance().getLocationClient();
|
||||||
locationClient.stop();
|
locationClient.stop();
|
||||||
@@ -324,41 +319,9 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
|||||||
// am.setTime(aLong);
|
// am.setTime(aLong);
|
||||||
SystemClock.setCurrentTimeMillis(aLong);
|
SystemClock.setCurrentTimeMillis(aLong);
|
||||||
Log.e(TAG, "getTimeFromNtpServer: " + aLong);
|
Log.e(TAG, "getTimeFromNtpServer: " + aLong);
|
||||||
tPushInit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tPushInit() {
|
|
||||||
XGPushConfig.enableDebug(this, true);
|
|
||||||
XGPushManager.registerPush(this, new XGIOperateCallback() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Object data, int flag) {
|
|
||||||
//token在设备卸载重装的时候有可能会变
|
|
||||||
Log.e("TPush", "注册成功,设备token为:" + data);
|
|
||||||
List<XGPushManager.AccountInfo> accountInfoList = new ArrayList<>();
|
|
||||||
Log.e("TPush", "onSuccess: " + Utils.getSerial());
|
|
||||||
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial()));
|
|
||||||
XGPushManager.upsertAccounts(MainService.this, accountInfoList, new XGIOperateCallback() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Object data, int flag) {
|
|
||||||
Log.e("TPush", "upsertAccounts onSuccess, data:" + data + ", flag:" + flag);
|
|
||||||
NetInterfaceManager.getInstance().setPushTags();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFail(Object data, int errCode, String msg) {
|
|
||||||
Log.e("TPush", "upsertAccounts onFail, data:" + data + ", code:" + errCode + ", msg:" + msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFail(Object data, int errCode, String msg) {
|
|
||||||
Log.e("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerReceivers() {
|
private void registerReceivers() {
|
||||||
registerWiFiReceiver();
|
registerWiFiReceiver();
|
||||||
registerScreenReceiver();
|
registerScreenReceiver();
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"tpns": {
|
|
||||||
"access_id": "1500031216",
|
|
||||||
"access_key": "A1HBG2922B9Z"
|
|
||||||
},
|
|
||||||
"com.fuying.sn": {
|
|
||||||
"channel": {
|
|
||||||
"enable": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"debug": false,
|
|
||||||
"version": "1.4.3.4",
|
|
||||||
"upgrade": false
|
|
||||||
}
|
|
||||||
49
build.gradle
49
build.gradle
@@ -3,17 +3,18 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
// mavenCentral()
|
mavenCentral()
|
||||||
maven { url "https://jitpack.io" }
|
maven { url 'https://jitpack.io' }
|
||||||
|
maven { url 'https://maven.google.com' }
|
||||||
maven { url 'https://developer.huawei.com/repo/' }
|
maven { url 'https://developer.huawei.com/repo/' }
|
||||||
|
maven { url 'https://developer.hihonor.com/repo' }
|
||||||
maven { url 'https://maven.aliyun.com/repository/central' }
|
maven { url 'https://maven.aliyun.com/repository/central' }
|
||||||
maven { url "https://maven.aliyun.com/repository/jcenter" }
|
maven { url 'https://maven.aliyun.com/repository/jcenter' }
|
||||||
maven { url 'https://maven.aliyun.com/repository/public' }
|
maven { url 'https://maven.aliyun.com/repository/public' }
|
||||||
maven { url 'https://maven.aliyun.com/repository/google' }
|
maven { url 'https://maven.aliyun.com/repository/google' }
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.6.4'
|
classpath 'com.android.tools.build:gradle:8.13.2'
|
||||||
classpath "com.tencent.android.tpns:tpnsplugin:1.8.0"
|
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
@@ -21,16 +22,44 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
configurations.all {
|
||||||
|
resolutionStrategy {
|
||||||
|
force 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||||
|
force 'androidx.core:core:1.5.0'
|
||||||
|
|
||||||
|
//for targetSdkVersion 29
|
||||||
|
force 'androidx.activity:activity:1.2.2'
|
||||||
|
force 'androidx.lifecycle:lifecycle-livedata:2.3.1'
|
||||||
|
force 'androidx.lifecycle:lifecycle-livedata-core:2.3.1'
|
||||||
|
force 'androidx.lifecycle:lifecycle-runtime:2.3.1'
|
||||||
|
force 'androidx.lifecycle:lifecycle-viewmodel:2.3.1'
|
||||||
|
force 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1'
|
||||||
|
force 'androidx.lifecycle:lifecycle-service:2.3.1'
|
||||||
|
force 'androidx.lifecycle:lifecycle-process:2.3.1'
|
||||||
|
force 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
|
||||||
|
force 'androidx.savedstate:savedstate:1.1.0'
|
||||||
|
force 'androidx.profileinstaller:profileinstaller:1.1.0'
|
||||||
|
force 'androidx.startup:startup-runtime:1.0.0'
|
||||||
|
force 'androidx.arch.core:core-runtime:2.1.0'
|
||||||
|
force 'androidx.sqlite:sqlite:2.1.0'
|
||||||
|
force 'androidx.sqlite:sqlite-framework:2.1.0'
|
||||||
|
force 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
// mavenCentral()
|
mavenCentral()
|
||||||
maven { url "https://jitpack.io" }
|
maven { url 'https://jitpack.io' }
|
||||||
|
maven { url 'https://maven.google.com' }
|
||||||
maven { url 'https://developer.huawei.com/repo/' }
|
maven { url 'https://developer.huawei.com/repo/' }
|
||||||
|
maven { url 'https://developer.hihonor.com/repo' }
|
||||||
maven { url 'https://maven.aliyun.com/repository/central' }
|
maven { url 'https://maven.aliyun.com/repository/central' }
|
||||||
maven { url "https://maven.aliyun.com/repository/jcenter" }
|
maven { url 'https://maven.aliyun.com/repository/jcenter' }
|
||||||
maven { url 'https://maven.aliyun.com/repository/public' }
|
maven { url 'https://maven.aliyun.com/repository/public' }
|
||||||
maven { url 'https://maven.aliyun.com/repository/google' }
|
maven { url 'https://maven.aliyun.com/repository/google' }
|
||||||
}
|
}
|
||||||
|
|
||||||
gradle.projectsEvaluated {
|
gradle.projectsEvaluated {
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
//设置jar相对包路径或绝对路径
|
//设置jar相对包路径或绝对路径
|
||||||
@@ -39,6 +68,6 @@ allprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task clean(type: Delete) {
|
//task clean(type: Delete) {
|
||||||
// delete rootProject.buildDir
|
// delete rootProject.buildDir
|
||||||
}
|
//}
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip
|
||||||
|
|||||||
Reference in New Issue
Block a user