version:
fix: update:增加TPNS,更新rxjava3,
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: "com.tencent.android.tpns"
|
||||
|
||||
def appName() {
|
||||
return "UIUIAppStore"
|
||||
@@ -24,6 +25,11 @@ android {
|
||||
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a'
|
||||
// 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
|
||||
}
|
||||
|
||||
manifestPlaceholders = [
|
||||
XG_ACCESS_ID : "1500026388",
|
||||
XG_ACCESS_KEY : "ACIM0JC38HVN",
|
||||
]
|
||||
}
|
||||
|
||||
compileOptions{
|
||||
@@ -41,22 +47,12 @@ android {
|
||||
flavorDimensions "default"
|
||||
versionCode 22
|
||||
versionName "3.1"
|
||||
manifestPlaceholders = [
|
||||
JPUSH_PKGNAME: "com.uiui.appstore",
|
||||
JPUSH_APPKEY : "c93d01f43046fa500d162817", //JPush 上注册的包名对应的 Appkey.
|
||||
JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
|
||||
]
|
||||
}
|
||||
|
||||
official {
|
||||
flavorDimensions "default"
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
manifestPlaceholders = [
|
||||
JPUSH_PKGNAME: "com.uiui.appstore",
|
||||
JPUSH_APPKEY : "c93d01f43046fa500d162817", //JPush 上注册的包名对应的 Appkey.
|
||||
JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,36 +163,41 @@ dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
|
||||
//butterknife
|
||||
implementation 'com.jakewharton:butterknife:10.2.1'
|
||||
implementation 'com.jakewharton:butterknife:10.2.3'
|
||||
// If you are using Kotlin, replace annotationProcessor with kapt.
|
||||
// annotationProcessor rootProject.ext.dependencies["butterknife-compiler"]
|
||||
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
|
||||
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
|
||||
//github第三方控件
|
||||
implementation 'io.github.h07000223:flycoTabLayout:3.0.0'
|
||||
//下拉刷新控件
|
||||
implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //1.0.5及以前版本的老用户升级需谨慎,API改动过大
|
||||
implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.1.0' //没有使用特殊Header,可以不加这行
|
||||
//glide
|
||||
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
||||
implementation 'com.github.bumptech.glide:glide:4.13.2'
|
||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.2'
|
||||
//aria
|
||||
implementation 'com.arialyy.aria:core:3.8.15'
|
||||
annotationProcessor 'com.arialyy.aria:compiler:3.8.15'
|
||||
//动态权限框架
|
||||
implementation 'com.hjq:xxpermissions:6.0'
|
||||
//okhttp
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
|
||||
//RxJava和Retrofit
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.5'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
|
||||
//Retrofit
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||
// implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava3:2.9.0'
|
||||
//RxJava
|
||||
implementation 'io.reactivex.rxjava3:rxjava:3.0.0'
|
||||
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
|
||||
|
||||
//google
|
||||
implementation 'com.google.code.gson:gson:2.8.7'
|
||||
implementation 'com.google.zxing:core:3.3.0'
|
||||
implementation 'com.google.code.gson:gson:2.9.0'
|
||||
implementation 'com.google.zxing:core:3.5.0'
|
||||
//fastjson
|
||||
implementation 'com.alibaba:fastjson:1.2.76'
|
||||
implementation 'com.alibaba:fastjson:1.2.83'
|
||||
//腾讯移动推送 TPNS
|
||||
implementation 'com.tencent.tpns:tpns:1.3.2.0-release'
|
||||
// //极光推送
|
||||
// implementation 'cn.jiguang.sdk:jpush:3.8.6' // 此处以JPush 3.4.1 版本为例。
|
||||
// implementation 'cn.jiguang.sdk:jcore:2.6.0' // 此处以JCore 2.2.4 版本为例。
|
||||
@@ -205,7 +206,7 @@ dependencies {
|
||||
//更换字体框架
|
||||
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
|
||||
//工具类
|
||||
implementation 'com.blankj:utilcodex:1.30.6'
|
||||
implementation 'com.blankj:utilcodex:1.31.0'
|
||||
//沉浸状态栏
|
||||
implementation 'com.gitee.zackratos:UltimateBarX:0.7.1'
|
||||
implementation 'com.gitee.zackratos:UltimateBarX:0.8.0'
|
||||
}
|
||||
|
||||
@@ -24,6 +24,25 @@
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="com.uiui.appstore.permission.JPUSH_MESSAGE" />
|
||||
|
||||
<!-- 【必须】 移动推送 TPNS SDK VIP版本所需权限 -->
|
||||
<permission
|
||||
android:name="com.uiui.appstore.permission.XGPUSH_RECEIVE"
|
||||
android:protectionLevel="signature" />
|
||||
<uses-permission android:name="com.uiui.appstore.permission.XGPUSH_RECEIVE" />
|
||||
|
||||
<!-- 【必须】 移动推送 TPNS SDK 所需权限 -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
|
||||
|
||||
<!-- 【常用】 移动推送 TPNS SDK所需权限 -->
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||
|
||||
<application
|
||||
android:name="com.uiui.appstore.base.BaseApplication"
|
||||
android:allowBackup="true"
|
||||
@@ -139,6 +158,132 @@
|
||||
|
||||
|
||||
|
||||
<activity android:name="com.tencent.android.tpush.TpnsActivity"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar"
|
||||
android:launchMode="singleInstance"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="${applicationId}.OPEN_TPNS_ACTIVITY" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<data
|
||||
android:scheme="tpns"
|
||||
android:host="${applicationId}"/>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.tencent.android.tpush.InnerTpnsActivity"
|
||||
android:exported="false"
|
||||
android:launchMode="singleInstance"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar">
|
||||
<intent-filter>
|
||||
<action android:name="${applicationId}.OPEN_TPNS_ACTIVITY_V2" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<data
|
||||
android:host="${applicationId}"
|
||||
android:scheme="stpns" />
|
||||
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- 【必须】 信鸽receiver广播接收 -->
|
||||
<receiver
|
||||
android:name="com.tencent.android.tpush.XGPushReceiver"
|
||||
android:exported="false"
|
||||
android:process=":xg_vip_service">
|
||||
|
||||
<intent-filter android:priority="0x7fffffff">
|
||||
|
||||
|
||||
<!-- 【必须】 信鸽SDK的内部广播 -->
|
||||
<action android:name="com.tencent.android.xg.vip.action.SDK" />
|
||||
<action android:name="com.tencent.android.xg.vip.action.INTERNAL_PUSH_MESSAGE" />
|
||||
<action android:name="com.tencent.android.xg.vip.action.ACTION_SDK_KEEPALIVE" />
|
||||
</intent-filter>
|
||||
|
||||
</receiver>
|
||||
|
||||
<!-- 【必须】移动推送 TPNS service -->
|
||||
<service
|
||||
android:name="com.tencent.android.tpush.service.XGVipPushService"
|
||||
android:persistent="true"
|
||||
android:process=":xg_vip_service"></service>
|
||||
|
||||
<!-- 【必须】通知 service ,android:name 部分改为包名.XGVIP_PUSH_ACTION -->
|
||||
<service android:name="com.tencent.android.tpush.rpc.XGRemoteService"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<!-- 【必须】请修改为当前APP名包.XGVIP_PUSH_ACTION -->
|
||||
<action android:name="com.uiui.appstore.XGVIP_PUSH_ACTION" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<!-- 【必须】【注意】authorities 修改为包名.XGVIP_PUSH_AUTH -->
|
||||
<provider
|
||||
android:name="com.tencent.android.tpush.XGPushProvider"
|
||||
android:authorities="com.uiui.appstore.XGVIP_PUSH_AUTH" />
|
||||
|
||||
<!-- 【必须】【注意】authorities 修改为包名.TPUSH_PROVIDER -->
|
||||
<provider
|
||||
android:name="com.tencent.android.tpush.SettingsContentProvider"
|
||||
android:authorities="com.uiui.appstore.TPUSH_PROVIDER" />
|
||||
|
||||
<!-- 【可选】用于增强保活能力 -->
|
||||
<provider
|
||||
android:name="com.tencent.android.tpush.XGVipPushKAProvider"
|
||||
android:authorities="com.uiui.appstore.AUTH_XGPUSH_KEEPALIVE"
|
||||
android:exported="true"
|
||||
tools:replace="android:exported" />
|
||||
|
||||
<!-- 【可选】APP实现的Receiver,用于接收消息透传和操作结果的回调,请根据需要添加 -->
|
||||
<!-- YOUR_PACKAGE_PATH.CustomPushReceiver需要改为自己的Receiver: -->
|
||||
<receiver android:name="com.uiui.appstore.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>
|
||||
|
||||
<!-- MQTT START -->
|
||||
<service android:exported="false"
|
||||
android:process=":xg_vip_service"
|
||||
android:name="com.tencent.tpns.mqttchannel.services.MqttService" />
|
||||
|
||||
<provider
|
||||
android:exported="false"
|
||||
android:name="com.tencent.tpns.baseapi.base.SettingsContentProvider"
|
||||
android:authorities="com.uiui.appstore.XG_SETTINGS_PROVIDER" />
|
||||
|
||||
<!-- MQTT END-->
|
||||
|
||||
<!-- 【必须】 请修改为 APP 的 AccessId,“15”开头的10位数字,中间没空格 -->
|
||||
<meta-data
|
||||
android:name="XG_V2_ACCESS_ID"
|
||||
android:value="1500026388" />
|
||||
<!-- 【必须】 请修改为APP的AccessKey,“A”开头的12位字符串,中间没空格 -->
|
||||
<meta-data
|
||||
android:name="XG_V2_ACCESS_KEY"
|
||||
android:value="ACIM0JC38HVN" />
|
||||
|
||||
</application>
|
||||
|
||||
|
||||
@@ -41,10 +41,10 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
public class DetailsActivity extends BaseActivity {
|
||||
private String TAG = DetailsActivity.class.getSimpleName();
|
||||
|
||||
@@ -12,7 +12,6 @@ import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
@@ -41,10 +40,11 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
|
||||
public class MainActivity extends BaseActivity {
|
||||
@@ -231,12 +231,12 @@ public class MainActivity extends BaseActivity {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse<UserInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@io.reactivex.annotations.NonNull BaseResponse<UserInfo> userInfoBaseResponse) {
|
||||
public void onNext(@NonNull BaseResponse<UserInfo> userInfoBaseResponse) {
|
||||
int code = userInfoBaseResponse.code;
|
||||
//已经绑定
|
||||
if (code == 200) {
|
||||
@@ -264,7 +264,7 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@io.reactivex.annotations.NonNull Throwable e) {
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e(TAG, "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@@ -281,12 +281,12 @@ public class MainActivity extends BaseActivity {
|
||||
.getQueryAllAppObservable()
|
||||
.subscribe(new Observer<BaseResponse<List<AppInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@io.reactivex.annotations.NonNull BaseResponse<List<AppInfo>> listBaseResponse) {
|
||||
public void onNext(@NonNull BaseResponse<List<AppInfo>> listBaseResponse) {
|
||||
int code = listBaseResponse.code;
|
||||
if (code == 200) {
|
||||
List<AppInfo> infos = listBaseResponse.data;
|
||||
@@ -305,7 +305,7 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@io.reactivex.annotations.NonNull Throwable e) {
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e(TAG, "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@ import com.uiui.appstore.utils.Utils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
|
||||
public class SearcherActivity extends BaseActivity {
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.content.IntentFilter;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@@ -19,12 +20,19 @@ import com.scwang.smartrefresh.layout.api.RefreshHeader;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
|
||||
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
|
||||
import com.tencent.android.tpush.XGIOperateCallback;
|
||||
import com.tencent.android.tpush.XGPushConfig;
|
||||
import com.tencent.android.tpush.XGPushManager;
|
||||
import com.uiui.appstore.R;
|
||||
import com.uiui.appstore.network.NetInterfaceManager;
|
||||
import com.uiui.appstore.receiver.AppManagerReceiver;
|
||||
import com.uiui.appstore.utils.JGYUtils;
|
||||
import com.uiui.appstore.utils.LogUtils;
|
||||
import com.uiui.appstore.utils.ToastUtil;
|
||||
import com.uiui.appstore.utils.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by asus on 2017/10/27.
|
||||
@@ -38,6 +46,10 @@ public class BaseApplication extends Application {
|
||||
return app;
|
||||
}
|
||||
|
||||
public Context getAppContext() {
|
||||
return getApplicationContext();
|
||||
}
|
||||
|
||||
//static 代码段可以防止内存泄露
|
||||
static {
|
||||
//设置全局的Header构建器
|
||||
@@ -63,6 +75,7 @@ public class BaseApplication extends Application {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
app = this;
|
||||
tPushInit();
|
||||
ToastUtil.init(this);
|
||||
JGYUtils.init(this);
|
||||
Aria.init(this);
|
||||
@@ -86,6 +99,36 @@ public class BaseApplication extends Application {
|
||||
// );
|
||||
}
|
||||
|
||||
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<>();
|
||||
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial()));
|
||||
XGPushManager.upsertAccounts(getApplicationContext(), accountInfoList, new XGIOperateCallback() {
|
||||
@Override
|
||||
public void onSuccess(Object data, int flag) {
|
||||
Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(Object data, int errCode, String msg) {
|
||||
Log.e("TPush", "onFail, data:" + data + ", code:" + errCode + ", msg:" + msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(Object data, int errCode, String msg) {
|
||||
Log.e("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private AppManagerReceiver mAppManagerReceiver;
|
||||
|
||||
private void registAppReceive() {
|
||||
@@ -129,8 +172,4 @@ public class BaseApplication extends Application {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Context getAppContext() {
|
||||
return getApplicationContext();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,12 +56,11 @@ import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Created by asus on 2017/10/23.
|
||||
|
||||
@@ -14,11 +14,11 @@ import com.uiui.appstore.bean.BaseResponse;
|
||||
import com.uiui.appstore.utils.FileUtils;
|
||||
import com.uiui.appstore.utils.JGYUtils;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
|
||||
public class HTTPInterface {
|
||||
@@ -35,12 +35,12 @@ public class HTTPInterface {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse<AppInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@io.reactivex.annotations.NonNull BaseResponse<AppInfo> appInfoBaseResponse) {
|
||||
public void onNext(@NonNull BaseResponse<AppInfo> appInfoBaseResponse) {
|
||||
int code = appInfoBaseResponse.code;
|
||||
if (code == 200) {
|
||||
AppInfo appInfo = appInfoBaseResponse.data;
|
||||
|
||||
@@ -6,7 +6,6 @@ import android.os.Environment;
|
||||
import com.uiui.appstore.bean.AppInfo;
|
||||
import com.uiui.appstore.bean.Banner;
|
||||
import com.uiui.appstore.bean.BaseResponse;
|
||||
import com.uiui.appstore.network.URLs.UrlAddress;
|
||||
import com.uiui.appstore.network.api.AdminApp;
|
||||
import com.uiui.appstore.network.api.BannerImage;
|
||||
import com.uiui.appstore.network.api.DownloadApp;
|
||||
@@ -22,15 +21,15 @@ import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.CallAdapter;
|
||||
import retrofit2.Converter;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class NetInterfaceManager {
|
||||
@@ -84,7 +83,7 @@ public class NetInterfaceManager {
|
||||
OK_HTTP_CLIENT = builder.build();
|
||||
}
|
||||
|
||||
private static CallAdapter.Factory rxJavaCallAdapterFactory = RxJava2CallAdapterFactory.create();
|
||||
private static CallAdapter.Factory rxJavaCallAdapterFactory = RxJava3CallAdapterFactory.create();
|
||||
private static Converter.Factory gsonConverterFactory = GsonConverterFactory.create();
|
||||
|
||||
public Observable<BaseResponse<Banner>> getBannerObservable() {
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.uiui.appstore.network.URLs;
|
||||
package com.uiui.appstore.network;
|
||||
|
||||
public class UrlAddress {
|
||||
public final static String ROOT_URL = "https://led.aolelearn.cn/android/";
|
||||
|
||||
/*获取批次*/
|
||||
public static final String GET_BATCH = "sn/getBatch";
|
||||
|
||||
//获取所有应用
|
||||
public final static String GET_ALL_APPINFO = "app/queryAllApp";
|
||||
//获取管理员所有应用
|
||||
@@ -2,13 +2,12 @@ package com.uiui.appstore.network.api;
|
||||
|
||||
import com.uiui.appstore.bean.AppInfo;
|
||||
import com.uiui.appstore.bean.BaseResponse;
|
||||
import com.uiui.appstore.network.URLs.UrlAddress;
|
||||
import com.uiui.appstore.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface AdminApp {
|
||||
@GET(UrlAddress.GET_ADMIN_APP)
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.uiui.appstore.network.api;
|
||||
|
||||
import com.uiui.appstore.bean.BaseResponse;
|
||||
import com.uiui.appstore.bean.ImageUrl;
|
||||
import com.uiui.appstore.network.URLs.UrlAddress;
|
||||
import com.uiui.appstore.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.uiui.appstore.network.api;
|
||||
|
||||
import com.uiui.appstore.bean.BaseResponse;
|
||||
import com.uiui.appstore.network.URLs.UrlAddress;
|
||||
import com.uiui.appstore.network.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
@@ -2,9 +2,9 @@ package com.uiui.appstore.network.api;
|
||||
|
||||
import com.uiui.appstore.bean.Banner;
|
||||
import com.uiui.appstore.bean.BaseResponse;
|
||||
import com.uiui.appstore.network.URLs.UrlAddress;
|
||||
import com.uiui.appstore.network.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
|
||||
public interface GetBanner {
|
||||
|
||||
@@ -4,9 +4,9 @@ package com.uiui.appstore.network.api;
|
||||
|
||||
import com.uiui.appstore.bean.AppInfo;
|
||||
import com.uiui.appstore.bean.BaseResponse;
|
||||
import com.uiui.appstore.network.URLs.UrlAddress;
|
||||
import com.uiui.appstore.network.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.uiui.appstore.network.api;
|
||||
|
||||
import com.uiui.appstore.bean.AppInfo;
|
||||
import com.uiui.appstore.bean.BaseResponse;
|
||||
import com.uiui.appstore.network.URLs.UrlAddress;
|
||||
import com.uiui.appstore.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ package com.uiui.appstore.network.api;
|
||||
|
||||
import com.uiui.appstore.bean.AppInfo;
|
||||
import com.uiui.appstore.bean.BaseResponse;
|
||||
import com.uiui.appstore.network.URLs.UrlAddress;
|
||||
import com.uiui.appstore.network.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ package com.uiui.appstore.network.api;
|
||||
|
||||
import com.uiui.appstore.bean.BaseResponse;
|
||||
import com.uiui.appstore.bean.UserInfo;
|
||||
import com.uiui.appstore.network.URLs.UrlAddress;
|
||||
import com.uiui.appstore.network.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.uiui.appstore.network.api;
|
||||
|
||||
import com.uiui.appstore.bean.AppInfo;
|
||||
import com.uiui.appstore.bean.BaseResponse;
|
||||
import com.uiui.appstore.network.URLs.UrlAddress;
|
||||
import com.uiui.appstore.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
|
||||
@@ -12,11 +12,11 @@ import com.uiui.appstore.utils.JGYUtils;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.ObservableEmitter;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class NewAppReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = NewAppReceiver.class.getSimpleName();
|
||||
|
||||
@@ -20,6 +20,9 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.task.DownloadTask;
|
||||
import com.uiui.appstore.KeepAliveConnection;
|
||||
import com.uiui.appstore.bean.BaseResponse;
|
||||
import com.uiui.appstore.network.NetInterfaceManager;
|
||||
@@ -29,16 +32,14 @@ import com.uiui.appstore.utils.LogUtils;
|
||||
import com.uiui.appstore.utils.SPUtils;
|
||||
import com.uiui.appstore.utils.ServiceAliveUtils;
|
||||
import com.uiui.appstore.utils.Utils;
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.task.DownloadTask;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
|
||||
/**
|
||||
@@ -58,7 +59,6 @@ public class GuardService extends Service {
|
||||
Intent i = new Intent(GuardService.this, MyDownloadService.class);
|
||||
startService(i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,12 +138,12 @@ public class GuardService extends Service {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@io.reactivex.annotations.NonNull BaseResponse baseResponse) {
|
||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||
int code = baseResponse.code;
|
||||
String msg = baseResponse.msg;
|
||||
Log.e("taskComplete", "onNext: " + "code" + code + ",msg:" + msg);
|
||||
@@ -151,7 +151,7 @@ public class GuardService extends Service {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@io.reactivex.annotations.NonNull Throwable e) {
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("taskComplete", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ import com.uiui.appstore.utils.SPUtils;
|
||||
import java.io.File;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.ObservableEmitter;
|
||||
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class InitJpushServer extends Service {
|
||||
public InitJpushServer() {
|
||||
|
||||
17
app/src/main/java/com/uiui/appstore/tpush/Constants.java
Normal file
17
app/src/main/java/com/uiui/appstore/tpush/Constants.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.uiui.appstore.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";
|
||||
}
|
||||
315
app/src/main/java/com/uiui/appstore/tpush/MessageReceiver.java
Normal file
315
app/src/main/java/com/uiui/appstore/tpush/MessageReceiver.java
Normal file
@@ -0,0 +1,315 @@
|
||||
package com.uiui.appstore.tpush;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
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 com.uiui.appstore.tpush.common.NotificationService;
|
||||
import com.uiui.appstore.tpush.po.XGNotification;
|
||||
|
||||
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.class.getSimpleName();
|
||||
|
||||
private Context mContext;
|
||||
private ContentResolver mResolver;
|
||||
private PackageManager mPackageManager;
|
||||
|
||||
/**
|
||||
* 消息透传处理
|
||||
*
|
||||
* @param context
|
||||
* @param message 解析自定义的 JSON
|
||||
*/
|
||||
@Override
|
||||
public void onTextMessage(Context context, XGPushTextMessage message) {
|
||||
this.mContext = context;
|
||||
this.mResolver = context.getContentResolver();
|
||||
this.mPackageManager = context.getPackageManager();
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
// 9.强制安装应用
|
||||
private static final String ACTION_FORCE_INSTALLAPK = "9";
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
switch (title) {
|
||||
case ACTION_FORCE_INSTALLAPK:
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.uiui.appstore.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) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.uiui.appstore.tpush.common;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
|
||||
import com.uiui.appstore.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.uiui.appstore.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;
|
||||
}
|
||||
}
|
||||
14
app/tpns-configs.json
Normal file
14
app/tpns-configs.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"tpns": {
|
||||
"access_id": "1500026388",
|
||||
"access_key": "ACIM0JC38HVN"
|
||||
},
|
||||
"com.uiui.appstore": {
|
||||
"channel": {
|
||||
"enable": true
|
||||
}
|
||||
},
|
||||
"debug": false,
|
||||
"version": "1.3.5.0-release",
|
||||
"upgrade": true
|
||||
}
|
||||
@@ -7,10 +7,12 @@ buildscript {
|
||||
mavenCentral()
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
|
||||
maven {url 'http://developer.huawei.com/repo/'}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.6.4'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "com.tencent.android.tpns:tpnsplugin:1.8.0"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
@@ -23,6 +25,7 @@ allprojects {
|
||||
mavenCentral()
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
|
||||
maven {url 'http://developer.huawei.com/repo/'}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user