version:1.0
fix: update:更换包名
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.uiui.aios"
|
||||
package="com.uiui.zyos"
|
||||
android:sharedUserId="android.uid.system">
|
||||
|
||||
<queries>
|
||||
@@ -10,9 +10,7 @@
|
||||
</intent>
|
||||
</queries>
|
||||
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
<!-- 清单文件中, 申明监听通话精确状态权限,该权限需要android:sharedUserId="android.uid.system" -->
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- 清单文件中, 申明监听通话精确状态权限,该权限需要android:sharedUserId="android.uid.system" -->
|
||||
<uses-permission android:name="android.permission.READ_PRECISE_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
|
||||
@@ -22,46 +20,33 @@
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
|
||||
|
||||
<!-- 允许访问网络,必选权限 -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<!-- 允许获取精确位置,精准定位必选 -->
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />-->
|
||||
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> <!-- 允许访问网络,必选权限 -->
|
||||
<uses-permission android:name="android.permission.INTERNET" /> <!-- 允许获取精确位置,精准定位必选 -->
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> -->
|
||||
<!-- 允许获取粗略位置,粗略定位必选 -->
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />-->
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> -->
|
||||
<!-- 允许获取设备和运营商信息,用于问题排查和网络定位(无gps情况下的定位),若需网络定位功能则必选 -->
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<!-- 允许获取网络状态,用于网络定位(无gps情况下的定位),若需网络定位功能则必选 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<!-- 允许获取wifi网络信息,用于网络定位(无gps情况下的定位),若需网络定位功能则必选 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<!-- 允许获取wifi状态改变,用于网络定位(无gps情况下的定位),若需网络定位功能则必选 -->
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
<!-- 后台获取位置信息,若需后台定位则必选 -->
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />-->
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <!-- 允许获取网络状态,用于网络定位(无gps情况下的定位),若需网络定位功能则必选 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 允许获取wifi网络信息,用于网络定位(无gps情况下的定位),若需网络定位功能则必选 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 允许获取wifi状态改变,用于网络定位(无gps情况下的定位),若需网络定位功能则必选 -->
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 后台获取位置信息,若需后台定位则必选 -->
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> -->
|
||||
<!-- 用于申请调用A-GPS模块,卫星定位加速 -->
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />-->
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> -->
|
||||
<!-- 允许写设备缓存,用于问题排查 -->
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||
<!-- 允许写入扩展存储,用于写入缓存定位数据 -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<!-- 允许读设备等信息,用于问题排查 -->
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" /> <!-- 允许写入扩展存储,用于写入缓存定位数据 -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- 允许读设备等信息,用于问题排查 -->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||
|
||||
<!-- 【必须】 移动推送 TPNS SDK VIP版本所需权限 -->
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" /> <!-- 【必须】 移动推送 TPNS SDK VIP版本所需权限 -->
|
||||
<permission
|
||||
android:name="${applicationId}.permission.XGPUSH_RECEIVE"
|
||||
android:protectionLevel="signature" />
|
||||
|
||||
<uses-permission android:name="${applicationId}.permission.XGPUSH_RECEIVE" />
|
||||
<!-- 【必须】 移动推送 TPNS SDK 所需权限 -->
|
||||
<uses-permission android:name="${applicationId}.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" />
|
||||
<!-- 【常用】 移动推送 TPNS SDK所需权限 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 【常用】 移动推送 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" />
|
||||
@@ -79,15 +64,20 @@
|
||||
android:restoreAnyVersion="true"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<service
|
||||
android:name=".service.DownloadService"
|
||||
android:enabled="false"
|
||||
android:exported="false"></service>
|
||||
|
||||
<activity
|
||||
android:name=".activity.main.MainActivity"
|
||||
android:screenOrientation="userLandscape"
|
||||
android:clearTaskOnLaunch="true"
|
||||
android:enabled="true"
|
||||
android:excludeFromRecents="true"
|
||||
android:launchMode="singleTask"
|
||||
android:resizeableActivity="true"
|
||||
android:resumeWhilePausing="true"
|
||||
android:screenOrientation="userLandscape"
|
||||
android:stateNotNeeded="true"
|
||||
android:taskAffinity="com.example.taskaffinity.newtask"
|
||||
android:windowSoftInputMode="adjustPan">
|
||||
@@ -173,19 +163,15 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.service.notification.NotificationListenerService" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<!-- <!– 声明service组件 –>-->
|
||||
<!-- <service-->
|
||||
<!-- android:name="com.baidu.location.f"-->
|
||||
<!-- android:enabled="true"-->
|
||||
<!-- android:process=":remote" />-->
|
||||
|
||||
<!-- <!– 应用的其它配置 –>-->
|
||||
<!-- <uses-library-->
|
||||
<!-- android:name="org.apache.http.legacy"-->
|
||||
<!-- android:required="false" />-->
|
||||
|
||||
</service> <!-- <!– 声明service组件 –> -->
|
||||
<!-- <service -->
|
||||
<!-- android:name="com.baidu.location.f" -->
|
||||
<!-- android:enabled="true" -->
|
||||
<!-- android:process=":remote" /> -->
|
||||
<!-- <!– 应用的其它配置 –> -->
|
||||
<!-- <uses-library -->
|
||||
<!-- android:name="org.apache.http.legacy" -->
|
||||
<!-- android:required="false" /> -->
|
||||
<activity
|
||||
android:name="com.tencent.android.tpush.TpnsActivity"
|
||||
android:exported="true"
|
||||
@@ -198,7 +184,7 @@
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<data
|
||||
android:host="com.uiui.aios"
|
||||
android:host="com.uiui.zyos"
|
||||
android:scheme="tpns" />
|
||||
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
@@ -222,7 +208,7 @@
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<data
|
||||
android:host="com.uiui.aios"
|
||||
android:host="com.uiui.zyos"
|
||||
android:scheme="stpns" />
|
||||
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
@@ -233,9 +219,7 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- 【必须】 信鸽receiver广播接收 -->
|
||||
</activity> <!-- 【必须】 信鸽receiver广播接收 -->
|
||||
<receiver
|
||||
android:name="com.tencent.android.tpush.XGPushReceiver"
|
||||
android:exported="false"
|
||||
@@ -247,13 +231,11 @@
|
||||
<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 -->
|
||||
</receiver> <!-- 【必须】移动推送 TPNS service -->
|
||||
<service
|
||||
android:name="com.tencent.android.tpush.service.XGVipPushService"
|
||||
android:persistent="true"
|
||||
android:process=":xg_vip_service" />
|
||||
<!-- 【必须】通知 service ,android:name 部分改为包名.XGVIP_PUSH_ACTION -->
|
||||
android:process=":xg_vip_service" /> <!-- 【必须】通知 service ,android:name 部分改为包名.XGVIP_PUSH_ACTION -->
|
||||
<service
|
||||
android:name="com.tencent.android.tpush.rpc.XGRemoteService"
|
||||
android:exported="false">
|
||||
@@ -262,22 +244,18 @@
|
||||
<!-- 【必须】请修改为当前APP名包.XGVIP_PUSH_ACTION -->
|
||||
<action android:name="${applicationId}.XGVIP_PUSH_ACTION" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
<!-- 【必须】【注意】authorities 修改为包名.XGVIP_PUSH_AUTH -->
|
||||
</service> <!-- 【必须】【注意】authorities 修改为包名.XGVIP_PUSH_AUTH -->
|
||||
<provider
|
||||
android:name="com.tencent.android.tpush.XGPushProvider"
|
||||
android:authorities="${applicationId}.XGVIP_PUSH_AUTH" />
|
||||
<!-- 【必须】【注意】authorities 修改为包名.TPUSH_PROVIDER -->
|
||||
android:authorities="${applicationId}.XGVIP_PUSH_AUTH" /> <!-- 【必须】【注意】authorities 修改为包名.TPUSH_PROVIDER -->
|
||||
<provider
|
||||
android:name="com.tencent.android.tpush.SettingsContentProvider"
|
||||
android:authorities="${applicationId}.TPUSH_PROVIDER" />
|
||||
<!-- 【可选】用于增强保活能力 -->
|
||||
android:authorities="${applicationId}.TPUSH_PROVIDER" /> <!-- 【可选】用于增强保活能力 -->
|
||||
<provider
|
||||
android:name="com.tencent.android.tpush.XGVipPushKAProvider"
|
||||
android:authorities="${applicationId}.AUTH_XGPUSH_KEEPALIVE"
|
||||
android:exported="true"
|
||||
tools:replace="android:exported" />
|
||||
<!-- 【可选】APP实现的Receiver,用于接收消息透传和操作结果的回调,请根据需要添加 -->
|
||||
tools:replace="android:exported" /> <!-- 【可选】APP实现的Receiver,用于接收消息透传和操作结果的回调,请根据需要添加 -->
|
||||
<!-- YOUR_PACKAGE_PATH.CustomPushReceiver需要改为自己的Receiver: -->
|
||||
<receiver android:name=".tpush.MessageReceiver">
|
||||
<intent-filter>
|
||||
@@ -287,9 +265,7 @@
|
||||
<!-- 监听注册、反注册、设置/删除标签、通知被点击等处理结果 -->
|
||||
<action android:name="com.tencent.android.xg.vip.action.FEEDBACK" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- MQTT START -->
|
||||
</receiver> <!-- MQTT START -->
|
||||
<service
|
||||
android:name="com.tencent.tpns.mqttchannel.services.MqttService"
|
||||
android:exported="false"
|
||||
@@ -298,20 +274,17 @@
|
||||
<provider
|
||||
android:name="com.tencent.tpns.baseapi.base.SettingsContentProvider"
|
||||
android:authorities="${applicationId}.XG_SETTINGS_PROVIDER"
|
||||
android:exported="false" />
|
||||
<!-- MQTT END -->
|
||||
|
||||
android:exported="false" /> <!-- MQTT END -->
|
||||
<!-- 【必须】 请修改为 APP 的 AccessId,“15”开头的10位数字,中间没空格 -->
|
||||
<meta-data
|
||||
android:name="XG_V2_ACCESS_ID"
|
||||
android:value="1500030457" />
|
||||
<!-- 【必须】 请修改为APP的AccessKey,“A”开头的12位字符串,中间没空格 -->
|
||||
android:value="1500030457" /> <!-- 【必须】 请修改为APP的AccessKey,“A”开头的12位字符串,中间没空格 -->
|
||||
<meta-data
|
||||
android:name="XG_V2_ACCESS_KEY"
|
||||
android:value="AZZXANJF4HBD" />
|
||||
<meta-data
|
||||
android:name="com.baidu.lbsapi.API_KEY"
|
||||
android:value="${Baidu_AK}" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,100 +0,0 @@
|
||||
package com.uiui.aios.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.adapter.APPListAdapter;
|
||||
import com.uiui.aios.base.BaseActivity;
|
||||
import com.uiui.aios.bean.AppListInfo;
|
||||
import com.uiui.aios.service.NotificationService;
|
||||
import com.uiui.aios.utils.ApkUtils;
|
||||
import com.uiui.aios.utils.BitmapUtils;
|
||||
import com.uiui.aios.view.RecyclerViewSpacesItemDecoration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class APPListActivity extends BaseActivity {
|
||||
private ImageView back;
|
||||
private RecyclerView mRecyclerView;
|
||||
private APPListAdapter adapter;
|
||||
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_applist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
back = findViewById(R.id.iv_back);
|
||||
back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
mRecyclerView = findViewById(R.id.recyclerview);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
List<ApplicationInfo> applicationInfoList = ApkUtils.getSystemApp(APPListActivity.this);
|
||||
PackageManager pm = getPackageManager();
|
||||
if (null != applicationInfoList) {
|
||||
List<AppListInfo> appinfoList = new ArrayList<>();
|
||||
for (ApplicationInfo applicationInfo : applicationInfoList) {
|
||||
AppListInfo info = new AppListInfo(
|
||||
applicationInfo.loadLabel(pm).toString(),
|
||||
applicationInfo.packageName,
|
||||
BitmapUtils.getIconBitmap(APPListActivity.this, applicationInfo.loadIcon(pm))
|
||||
);
|
||||
appinfoList.add(info);
|
||||
}
|
||||
HashMap<String, Integer> stringIntegerHashMap = new HashMap<>();
|
||||
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
wm.getDefaultDisplay().getRealMetrics(dm);
|
||||
float density = dm.density; // 屏幕密度(0.75 / 1.0 / 1.5)
|
||||
int orientation = 0;
|
||||
orientation = getResources().getConfiguration().orientation;
|
||||
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.TOP_DECORATION, (int) (density * 16));//top间距
|
||||
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.BOTTOM_DECORATION, (int) (density * 32));//top间距
|
||||
} else if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.TOP_DECORATION, (int) (density * 50));//top间距
|
||||
stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.BOTTOM_DECORATION, (int) (density * 100));//top间距
|
||||
}
|
||||
// stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.TOP_DECORATION, (int) (density * 40));//top间距
|
||||
// stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.BOTTOM_DECORATION, (int) (density * 20));//底部间距
|
||||
// stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.LEFT_DECORATION, (int) (density * 20));//左间距
|
||||
// stringIntegerHashMap.put(RecyclerViewSpacesItemDecoration.RIGHT_DECORATION, (int) (density * 20));//右间距
|
||||
adapter = new APPListAdapter(APPListActivity.this);
|
||||
mRecyclerView.setLayoutManager(new GridLayoutManager(APPListActivity.this, 3));
|
||||
// rv_list.addItemDecoration(new RecyclerItemDecoration(10, 10, 4));
|
||||
mRecyclerView.addItemDecoration(new RecyclerViewSpacesItemDecoration(stringIntegerHashMap));
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
adapter.setAppListInfos(appinfoList);
|
||||
NotificationService.setListener(new NotificationService.NotificationListener() {
|
||||
@Override
|
||||
public void onListenerUpdate() {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,253 +0,0 @@
|
||||
package com.uiui.aios.activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.Contact;
|
||||
import com.uiui.aios.config.CommonConfig;
|
||||
import com.uiui.aios.disklrucache.CacheHelper;
|
||||
import com.uiui.aios.network.NetInterfaceManager;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
import com.uiui.aios.receiver.BootReceiver;
|
||||
import com.uiui.aios.utils.ToastUtil;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
public class EmergencyActivity extends AppCompatActivity {
|
||||
private static final String TAG = EmergencyActivity.class.getSimpleName();
|
||||
|
||||
@BindView(R.id.tv_countdown)
|
||||
TextView tv_countdown;
|
||||
@BindView(R.id.iv_finish)
|
||||
ImageView iv_finish;
|
||||
private Disposable subscribe;
|
||||
private boolean needDial = false;
|
||||
private boolean isCalling = false;
|
||||
private List<Contact> phoneListSet;
|
||||
private CacheHelper mCacheHelper;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Log.e(TAG, "onCreate: ");
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_emergency);
|
||||
mCacheHelper = new CacheHelper(this);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
//发送紧急广播
|
||||
Intent bootIntent = new Intent(BootReceiver.SOS);
|
||||
bootIntent.setComponent(new ComponentName("com.uiui.sn", "com.uiui.sn.receiver.BootReceiver"));
|
||||
sendBroadcast(bootIntent);
|
||||
|
||||
Intent intent = getIntent();
|
||||
// String contactList = intent.getStringExtra("contactList");
|
||||
// if (TextUtils.isEmpty(contactList)) {
|
||||
// finish();
|
||||
// return;
|
||||
// }
|
||||
|
||||
String jsonString = mCacheHelper.getAsString(URLAddress.GET_MAIL_LIST);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
return;
|
||||
}
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<Contact>>() {
|
||||
}.getType();
|
||||
List<Contact> contactList = gson.fromJson(jsonString, type);
|
||||
if (contactList == null || contactList.size() == 0) {
|
||||
return;
|
||||
}
|
||||
phoneListSet = contactList.stream().filter(contact -> contact.getIs_urgent() == 1).collect(Collectors.toList());
|
||||
Log.e(TAG, "onCreate: " + phoneListSet);
|
||||
|
||||
final Long time = 3L;
|
||||
subscribe = Observable.interval(1, TimeUnit.SECONDS)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(aLong -> {
|
||||
Log.e("TAG", "倒计时:" + aLong);
|
||||
if (aLong < time && !subscribe.isDisposed()) {
|
||||
tv_countdown.setText("倒计时(" + (time - aLong - 1) + ")秒");
|
||||
Log.e(TAG, "accept: " + (time - aLong - 1));
|
||||
} else {
|
||||
MMKV mmkv = MMKV.defaultMMKV();
|
||||
String longitude = mmkv.decodeString(CommonConfig.MAP_LONGITUDE_KEY, "未知");
|
||||
String latitude = mmkv.decodeString(CommonConfig.MAP_LATITUDE_KEY, "未知");
|
||||
String address = mmkv.decodeString(CommonConfig.MAP_ADDRESS_KEY, "未知");
|
||||
NetInterfaceManager.getInstance()
|
||||
.getSOSRecordObservable(longitude, latitude, address)
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("SOSRecordApi", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||
Log.e("SOSRecordApi", "onNext: " + baseResponse);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("SOSRecordApi", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("SOSRecordApi", "onComplete: ");
|
||||
}
|
||||
});
|
||||
needDial = true;
|
||||
Intent intent1 = new Intent(Intent.ACTION_CALL);
|
||||
Uri data = Uri.parse("tel:" + phoneListSet.get(0).getMobile());
|
||||
intent1.setData(data);
|
||||
startActivity(intent1);
|
||||
isCalling = true;
|
||||
phoneListSet.remove(0);
|
||||
// finish();
|
||||
subscribe.dispose();
|
||||
}
|
||||
});
|
||||
iv_finish.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
// TelephonyManager telM = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
|
||||
// telM.listen(new PhoneStateListener() {
|
||||
// /**
|
||||
// * 当有精确通话状态时回调
|
||||
// * Callback invoked when precise device call state changes
|
||||
// * @hide 隐藏api, 给系统app使用的
|
||||
// */
|
||||
// public void onPreciseCallStateChanged(PreciseCallState callState) {
|
||||
// //当有精确通话状态时回调
|
||||
// Log.e(TAG, "onPreciseCallStateChanged: " + callState);
|
||||
// }
|
||||
// }, PhoneStateListener.LISTEN_PRECISE_CALL_STATE); //需要权限android.permission.READ_PRECISE_PHONE_STATE
|
||||
//
|
||||
// StatusBarManager mStatusBarManager = (StatusBarManager) getApplicationContext().getSystemService(Context.STATUS_BAR_SERVICE);
|
||||
//// mStatusBarManager.disable(StatusBarManager.DISABLE_HOME);//隐藏home键
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
Log.e(TAG, "onStart: ");
|
||||
Log.e(TAG, "onStart: " + phoneListSet);
|
||||
if (needDial) {
|
||||
if (phoneListSet == null || phoneListSet.size() == 0) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Intent intent1 = new Intent(Intent.ACTION_CALL);
|
||||
String phone = phoneListSet.get(0).getMobile();
|
||||
Uri data = Uri.parse("tel:" + phone);
|
||||
intent1.setData(data);
|
||||
startActivity(intent1);
|
||||
isCalling = true;
|
||||
phoneListSet.remove(0);
|
||||
}
|
||||
}, 2000);
|
||||
} else {
|
||||
if (phoneListSet == null) {
|
||||
ToastUtil.show("没有设置紧急联系人");
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
Log.e(TAG, "onDestroy: ");
|
||||
if (subscribe != null) {
|
||||
subscribe.dispose();
|
||||
subscribe = null;
|
||||
}
|
||||
}
|
||||
|
||||
// class MobileCallReceiver extends BroadcastReceiver {
|
||||
// @Override
|
||||
// public void onReceive(Context context, Intent intent) {
|
||||
// if (intent.getAction() == null) {
|
||||
// return;
|
||||
// }
|
||||
//// switch (intent.getAction()) {
|
||||
//// case CustomAction.PRECISE_CALL_STATE:
|
||||
//// int callState = intent.getIntExtra("foreground_state", -2);
|
||||
//// switch (callState) {
|
||||
//// case PreciseCallState.PRECISE_CALL_STATE_IDLE:
|
||||
//// Log.d(TAG, "IDLE");
|
||||
//// break;
|
||||
//// case PreciseCallState.PRECISE_CALL_STATE_DIALING:
|
||||
//// Log.d(TAG, "DIALING");
|
||||
//// break;
|
||||
//// case PreciseCallState.PRECISE_CALL_STATE_ALERTING:
|
||||
//// Log.d(TAG, "ALERTING isHandFree=" + isHandFree);
|
||||
//// break;
|
||||
//// case PreciseCallState.PRECISE_CALL_STATE_ACTIVE:
|
||||
//// Log.d(TAG, "ACTIVE");
|
||||
//// break;
|
||||
//// case PreciseCallState.PRECISE_CALL_STATE_INCOMING:
|
||||
//// Log.d(TAG, "INCOMING来电");
|
||||
//// break;
|
||||
//// case PreciseCallState.PRECISE_CALL_STATE_DISCONNECTING:
|
||||
//// Log.d(TAG, "DISCONNECTING");
|
||||
//// break;
|
||||
//// case PreciseCallState.PRECISE_CALL_STATE_DISCONNECTED:
|
||||
//// Log.d(TAG, "DISCONNECTED");
|
||||
//// break;
|
||||
//// }
|
||||
//// break;
|
||||
//// case TelephonyManager.ACTION_PHONE_STATE_CHANGED:
|
||||
//// break;
|
||||
//// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 精确的九大通话状态
|
||||
// public class PreciseCallState {
|
||||
// public static final int PRECISE_CALL_STATE_IDLE = 0; //通话空闲
|
||||
// public static final int PRECISE_CALL_STATE_ACTIVE = 1; //正在通话(活动中)
|
||||
// public static final int PRECISE_CALL_STATE_HOLDING = 2; //通话挂起(例如我和多个人通话,其中一个通话在活动,而其它通话就会进入挂起状态)
|
||||
// public static final int PRECISE_CALL_STATE_DIALING = 3; //拨号开始
|
||||
// public static final int PRECISE_CALL_STATE_ALERTING = 4; //正在呼出(提醒对方接电话)
|
||||
// public static final int PRECISE_CALL_STATE_INCOMING = 5; //对方来电
|
||||
// public static final int PRECISE_CALL_STATE_WAITING = 6; //第三方来电等待(例如我正在和某人通话,而其他人打入时就会就进入等待状态)
|
||||
// public static final int PRECISE_CALL_STATE_DISCONNECTED = 7; //挂断完成
|
||||
// public static final int PRECISE_CALL_STATE_DISCONNECTING = 8; //正在挂断
|
||||
// }
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
package com.uiui.aios.activity;
|
||||
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.uiui.aios.BuildConfig;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.adapter.AppSelectedAdapter;
|
||||
import com.uiui.aios.base.BaseActivity;
|
||||
import com.uiui.aios.bean.AppSelectBean;
|
||||
import com.uiui.aios.view.GridSpaceItemDecoration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class QuickAppActivity extends BaseActivity {
|
||||
private static final String TAG = QuickAppActivity.class.getSimpleName();
|
||||
|
||||
public static final String QUICK_APP_KEY = "QuickAppPackageKey";
|
||||
public static final String QUICK_APP_REFRESH_KEY = "QuickAppRefreshKey";
|
||||
public static final String QUICK_APP_ENABLED_KEY = "QuickAppEnabledKey";
|
||||
|
||||
private AppSelectedAdapter mAppSelectedAdapter;
|
||||
|
||||
@BindView(R.id.recyclerView)
|
||||
RecyclerView recyclerView;
|
||||
|
||||
private Set<String> hideApp = new HashSet<String>() {{
|
||||
this.add(BuildConfig.APPLICATION_ID);
|
||||
this.add("com.android.calendar");
|
||||
this.add("com.android.dreams.basic");
|
||||
this.add("com.android.musicfx");
|
||||
this.add("com.uiui.appstore");
|
||||
this.add("com.uiui.sn");
|
||||
}};
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_quick_app;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mAppSelectedAdapter = new AppSelectedAdapter();
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(this, 3));
|
||||
recyclerView.addItemDecoration(new GridSpaceItemDecoration(3, 50, 50));
|
||||
} else {
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
|
||||
recyclerView.addItemDecoration(new GridSpaceItemDecoration(2, 50, 50));
|
||||
}
|
||||
recyclerView.setAdapter(mAppSelectedAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
mAppSelectedAdapter.setAppSelectBeans(getPackageList());
|
||||
}
|
||||
|
||||
boolean listThirdParty = true;
|
||||
|
||||
private List<AppSelectBean> getPackageList() {
|
||||
PackageManager pm = getPackageManager();
|
||||
List<AppSelectBean> appSelectBeanList = new ArrayList<>();
|
||||
List<PackageInfo> applicationInfos = pm.getInstalledPackages(0);
|
||||
for (PackageInfo packageInfo : applicationInfos) {
|
||||
if (hideApp.contains(packageInfo.applicationInfo.packageName)) {
|
||||
continue;
|
||||
}
|
||||
final boolean isSystem = (packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
|
||||
if (!listThirdParty || !isSystem) {
|
||||
Log.e(TAG, "getPackageList: " + packageInfo.applicationInfo.packageName);
|
||||
AppSelectBean appSelectBean = new AppSelectBean(packageInfo.applicationInfo.loadLabel(pm).toString(), packageInfo.applicationInfo.packageName, packageInfo.applicationInfo.loadIcon(pm));
|
||||
appSelectBeanList.add(appSelectBean);
|
||||
}
|
||||
}
|
||||
return appSelectBeanList;
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
package com.uiui.aios.activity.alarm;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.adapter.AlarmAdapter;
|
||||
import com.uiui.aios.alarm.AlarmUtils;
|
||||
import com.uiui.aios.base.BaseActivity;
|
||||
import com.uiui.aios.bean.AlarmClockData;
|
||||
import com.uiui.aios.tpush.MessageReceiver;
|
||||
import com.uiui.aios.utils.ToastUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import cn.jzvd.Jzvd;
|
||||
|
||||
public class AlarmClockActivity extends BaseActivity implements AlarmClockContact.ClockView {
|
||||
private static final String TAG = AlarmClockActivity.class.getSimpleName();
|
||||
|
||||
@BindView(R.id.recyclerView)
|
||||
RecyclerView recyclerView;
|
||||
@BindView(R.id.iv_back)
|
||||
ImageView iv_back;
|
||||
|
||||
|
||||
private AlarmClockPresenter mPresenter;
|
||||
private AlarmAdapter mAlarmAdapter;
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_alarm_clock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mPresenter = new AlarmClockPresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
|
||||
mAlarmAdapter = new AlarmAdapter();
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(AlarmClockActivity.this));
|
||||
recyclerView.setAdapter(mAlarmAdapter);
|
||||
iv_back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
registerAlarmClockReceiver();
|
||||
mPresenter.getAlarmClock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showAlarmClock(List<AlarmClockData> alarmClockData) {
|
||||
mAlarmAdapter.setAlarmClockData(alarmClockData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlarmClockEmpty() {
|
||||
mAlarmAdapter.setAlarmClockData(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
ToastUtil.show("服务器连接失败,检查网络连接");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
Jzvd.releaseAllVideos();
|
||||
if (mAlarmClockReceiver != null) {
|
||||
unregisterReceiver(mAlarmClockReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerAlarmClockReceiver() {
|
||||
if (null == mAlarmClockReceiver) {
|
||||
mAlarmClockReceiver = new AlarmClockReceiver();
|
||||
}
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(MessageReceiver.SET_ALARMCLOCK);
|
||||
registerReceiver(mAlarmClockReceiver, filter);
|
||||
}
|
||||
|
||||
private AlarmClockReceiver mAlarmClockReceiver;
|
||||
|
||||
private class AlarmClockReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
Log.e(TAG, "onReceive: " + action);
|
||||
if (MessageReceiver.SET_ALARMCLOCK.equals(action)) {
|
||||
mPresenter.getAlarmClock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.uiui.aios.activity.alarm;
|
||||
|
||||
import com.uiui.aios.base.BasePresenter;
|
||||
import com.uiui.aios.base.BaseView;
|
||||
import com.uiui.aios.bean.AlarmClockData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AlarmClockContact {
|
||||
public interface Presenter extends BasePresenter<ClockView> {
|
||||
void getAlarmClock();
|
||||
}
|
||||
|
||||
public interface ClockView extends BaseView {
|
||||
void showAlarmClock(List<AlarmClockData> alarmClockData);
|
||||
void setAlarmClockEmpty();
|
||||
void onError();
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package com.uiui.aios.activity.alarm;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiui.aios.bean.AlarmClockData;
|
||||
import com.uiui.aios.network.NetInterfaceManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
public class AlarmClockPresenter implements AlarmClockContact.Presenter {
|
||||
|
||||
private AlarmClockContact.ClockView mView;
|
||||
private Context mContext;
|
||||
|
||||
AlarmClockPresenter(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
private BehaviorSubject<ActivityEvent> lifecycle;
|
||||
|
||||
void setLifecycle(BehaviorSubject<ActivityEvent> lifecycle) {
|
||||
this.lifecycle = lifecycle;
|
||||
}
|
||||
|
||||
public BehaviorSubject<ActivityEvent> getLifecycle() {
|
||||
return lifecycle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachView(@NonNull AlarmClockContact.ClockView view) {
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getAlarmClock() {
|
||||
NetInterfaceManager.getInstance().getAlarmClock(true, getLifecycle(), new NetInterfaceManager.AlarmClockCallback() {
|
||||
@Override
|
||||
public void setAlarmClock(List<AlarmClockData> alarmClockList) {
|
||||
mView.showAlarmClock(alarmClockList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlarmClockEmpty() {
|
||||
mView.setAlarmClockEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
mView.onError();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
package com.uiui.aios.activity.code;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.adapter.HealthCodeAdapter;
|
||||
import com.uiui.aios.base.BaseActivity;
|
||||
import com.uiui.aios.bean.HealthCode;
|
||||
import com.uiui.aios.utils.ToastUtil;
|
||||
import com.uiui.aios.view.ScaleCircleNavigator;
|
||||
|
||||
import net.lucode.hackware.magicindicator.MagicIndicator;
|
||||
import net.lucode.hackware.magicindicator.ViewPagerHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class FamilySpaceActivity extends BaseActivity implements FamilySpaceContact.CodeView {
|
||||
|
||||
@BindView(R.id.iv_back)
|
||||
ImageView iv_back;
|
||||
@BindView(R.id.viewPager)
|
||||
ViewPager mViewPager;
|
||||
@BindView(R.id.magicIndicator)
|
||||
MagicIndicator mMagicIndicator;
|
||||
@BindView(R.id.iv_nodata)
|
||||
ImageView iv_nodata;
|
||||
|
||||
private FamilySpacePresenter mPresenter;
|
||||
private HealthCodeAdapter mHealthCodeAdapter;
|
||||
private ScaleCircleNavigator scaleCircleNavigator;
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_family_space;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mPresenter = new FamilySpacePresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
iv_back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
mHealthCodeAdapter = new HealthCodeAdapter();
|
||||
mViewPager.setAdapter(mHealthCodeAdapter);
|
||||
scaleCircleNavigator = new ScaleCircleNavigator(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
mPresenter.getHealthCode();
|
||||
}
|
||||
|
||||
private void setImageViews(List<HealthCode> healthCodes) {
|
||||
mMagicIndicator.setNavigator(scaleCircleNavigator);
|
||||
scaleCircleNavigator.setCircleCount(healthCodes.size());
|
||||
scaleCircleNavigator.setNormalCircleColor(Color.DKGRAY);
|
||||
scaleCircleNavigator.setSelectedCircleColor(Color.LTGRAY);
|
||||
scaleCircleNavigator.setCircleClickListener(new ScaleCircleNavigator.OnCircleClickListener() {
|
||||
@Override
|
||||
public void onClick(int index) {
|
||||
|
||||
}
|
||||
});
|
||||
ViewPagerHelper.bind(mMagicIndicator, mViewPager);
|
||||
List<ImageView> imageViews = new ArrayList<>();
|
||||
for (HealthCode healthCode : healthCodes) {
|
||||
ImageView image = new ImageView(this);
|
||||
image.setAdjustViewBounds(true);
|
||||
image.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
Glide.with(this).load(healthCode.getImg()).into(image);
|
||||
imageViews.add(image);
|
||||
}
|
||||
mHealthCodeAdapter.setImageViews(imageViews);
|
||||
mHealthCodeAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHealthCode(List<HealthCode> codeList) {
|
||||
setImageViews(codeList);
|
||||
mViewPager.setVisibility(View.VISIBLE);
|
||||
mMagicIndicator.setVisibility(View.VISIBLE);
|
||||
iv_nodata.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHealthCodeNodata() {
|
||||
mViewPager.setVisibility(View.GONE);
|
||||
mMagicIndicator.setVisibility(View.GONE);
|
||||
iv_nodata.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
ToastUtil.show("连接服务器失败,请检查网络连接");
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.uiui.aios.activity.code;
|
||||
|
||||
import com.uiui.aios.base.BasePresenter;
|
||||
import com.uiui.aios.base.BaseView;
|
||||
import com.uiui.aios.bean.HealthCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FamilySpaceContact {
|
||||
public interface Presenter extends BasePresenter<CodeView> {
|
||||
void getHealthCode();
|
||||
}
|
||||
|
||||
public interface CodeView extends BaseView {
|
||||
void setHealthCode(List<HealthCode> codeList);
|
||||
void setHealthCodeNodata();
|
||||
void onError();
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package com.uiui.aios.activity.code;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiui.aios.bean.HealthCode;
|
||||
import com.uiui.aios.network.NetInterfaceManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
public class FamilySpacePresenter implements FamilySpaceContact.Presenter {
|
||||
private static final String TAG = FamilySpacePresenter.class.getSimpleName();
|
||||
private FamilySpaceContact.CodeView mView;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private BehaviorSubject<ActivityEvent> lifecycle;
|
||||
|
||||
void setLifecycle(BehaviorSubject<ActivityEvent> lifecycle) {
|
||||
this.lifecycle = lifecycle;
|
||||
}
|
||||
|
||||
public BehaviorSubject<ActivityEvent> getLifecycle() {
|
||||
return lifecycle;
|
||||
}
|
||||
|
||||
FamilySpacePresenter(Context context) {
|
||||
this.mContext = context;
|
||||
Log.e(TAG, "MainPresenter: " + context.getClass());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void attachView(@NonNull FamilySpaceContact.CodeView view) {
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getHealthCode() {
|
||||
NetInterfaceManager.getInstance().getHealthCode(true, getLifecycle(), new NetInterfaceManager.HealthCodeCallback() {
|
||||
@Override
|
||||
public void setHealthCode(List<HealthCode> healthCode) {
|
||||
mView.setHealthCode(healthCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noData() {
|
||||
mView.setHealthCodeNodata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
mView.onError();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
package com.uiui.aios.activity.contact;
|
||||
|
||||
import android.content.res.Configuration;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.adapter.ContactAdapter;
|
||||
import com.uiui.aios.base.BaseActivity;
|
||||
import com.uiui.aios.bean.Contact;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class ContactActivity extends BaseActivity implements ContactContact.ContactView {
|
||||
@BindView(R.id.rv_contact)
|
||||
RecyclerView rv_contact;
|
||||
@BindView(R.id.tv_people)
|
||||
TextView tv_people;
|
||||
@BindView(R.id.iv_back)
|
||||
ImageView iv_back;
|
||||
|
||||
@OnClick({R.id.iv_back})
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.iv_back:
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
private ContactPresenter mContactPresenter;
|
||||
private ContactAdapter mContactAdapter;
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_contact;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mContactPresenter = new ContactPresenter(this);
|
||||
mContactPresenter.attachView(this);
|
||||
mContactPresenter.setLifecycle(lifecycleSubject);
|
||||
mContactAdapter = new ContactAdapter();
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
rv_contact.setLayoutManager(new GridLayoutManager(this, 3));
|
||||
} else {
|
||||
rv_contact.setLayoutManager(new GridLayoutManager(this, 2));
|
||||
}
|
||||
rv_contact.setAdapter(mContactAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
mContactPresenter.getContact();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mContactPresenter.detachView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContact(List<Contact> contactList) {
|
||||
tv_people.setText(contactList.size() + "人");
|
||||
Contact contact = new Contact();
|
||||
contact.setName("拨号");
|
||||
contact.setMobile(ContactAdapter.DIALER_PACKAGE);
|
||||
contactList.add(0, contact);
|
||||
mContactAdapter.setContactList(contactList);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.uiui.aios.activity.contact;
|
||||
|
||||
import com.uiui.aios.base.BasePresenter;
|
||||
import com.uiui.aios.base.BaseView;
|
||||
import com.uiui.aios.bean.Contact;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ContactContact {
|
||||
public interface Presenter extends BasePresenter<ContactView> {
|
||||
void getContact();
|
||||
}
|
||||
|
||||
public interface ContactView extends BaseView {
|
||||
void setContact(List<Contact> contactList);
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
package com.uiui.aios.activity.contact;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.Contact;
|
||||
import com.uiui.aios.network.NetInterfaceManager;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
import com.uiui.aios.utils.GsonUtils;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
public class ContactPresenter implements ContactContact.Presenter {
|
||||
private Context mContext;
|
||||
private ContactContact.ContactView mView;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
|
||||
private BehaviorSubject<ActivityEvent> lifecycle;
|
||||
|
||||
void setLifecycle(BehaviorSubject<ActivityEvent> lifecycle) {
|
||||
this.lifecycle = lifecycle;
|
||||
}
|
||||
|
||||
public BehaviorSubject<ActivityEvent> getLifecycle() {
|
||||
return lifecycle;
|
||||
}
|
||||
|
||||
ContactPresenter(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachView(@NonNull ContactContact.ContactView view) {
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getContact() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getContactListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<Contact>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getContactList", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<Contact>> listBaseResponse) {
|
||||
Log.e("getContactList", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
mMMKV.putString(URLAddress.GET_MAIL_LIST, GsonUtils.toJsonString(listBaseResponse.data));
|
||||
mView.setContact(listBaseResponse.data);
|
||||
} else {
|
||||
mMMKV.putString(URLAddress.GET_MAIL_LIST, "");
|
||||
mView.setContact(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getContactList", "onError: " + e.getMessage());
|
||||
String jsonString = mMMKV.getString(URLAddress.GET_MAIL_LIST, null);
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<Contact>>() {
|
||||
}.getType();
|
||||
List<Contact> contacts = gson.fromJson(jsonString, type);
|
||||
if (contacts == null) {
|
||||
mView.setContact(new ArrayList<>());
|
||||
} else {
|
||||
mView.setContact(contacts);
|
||||
}
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getContactList", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.uiui.aios.activity.main;
|
||||
|
||||
import com.uiui.aios.base.BasePresenter;
|
||||
import com.uiui.aios.base.BaseView;
|
||||
|
||||
public class MainContact {
|
||||
public interface Presenter extends BasePresenter<MainView> {
|
||||
/*获取系统设置*/
|
||||
void getSystemSettings();
|
||||
/*获取桌面布局*/
|
||||
void getDesktopLayout();
|
||||
/*更新桌面布局*/
|
||||
void updateDesktopLayout();
|
||||
/*上传正在运行的APP*/
|
||||
void sendAPPUsage();
|
||||
/*上传后台运行的APP*/
|
||||
void sendRunningInfo();
|
||||
/*获取负二屏开关*/
|
||||
void getAdminSnSetting();
|
||||
}
|
||||
|
||||
public interface MainView extends BaseView {
|
||||
void setSystemSettings();
|
||||
void getDesktopLayoutFinish();
|
||||
void updateDesktopLayoutFinish();
|
||||
void sendAPPUsageFinish();
|
||||
void sendRunningInfoFinish();
|
||||
void setAdminSnSetting();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,215 +0,0 @@
|
||||
package com.uiui.aios.activity.main;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiui.aios.BuildConfig;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.Contact;
|
||||
import com.uiui.aios.bean.NetDesktopIcon;
|
||||
import com.uiui.aios.network.NetInterfaceManager;
|
||||
import com.uiui.aios.utils.ApkUtils;
|
||||
import com.uiui.aios.utils.AppUsedTimeUtils;
|
||||
import com.uiui.aios.utils.Utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
public class MainPresenter implements MainContact.Presenter {
|
||||
private static final String TAG = MainPresenter.class.getSimpleName();
|
||||
private MainContact.MainView mView;
|
||||
private Context mContext;
|
||||
|
||||
private BehaviorSubject<ActivityEvent> lifecycle;
|
||||
|
||||
void setLifecycle(BehaviorSubject<ActivityEvent> lifecycle) {
|
||||
this.lifecycle = lifecycle;
|
||||
}
|
||||
|
||||
public BehaviorSubject<ActivityEvent> getLifecycle() {
|
||||
return lifecycle;
|
||||
}
|
||||
|
||||
MainPresenter(Context context) {
|
||||
this.mContext = context;
|
||||
Log.e(TAG, "MainPresenter: " + context.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachView(MainContact.MainView view) {
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSystemSettings() {
|
||||
// NetInterfaceManager.getInstance().getSystemSettings(true, getLifecycle(), new NetInterfaceManager.ContactCallback() {
|
||||
// @Override
|
||||
// public void setContact(List<Contact> contactList) {
|
||||
// Intent intent = new Intent("setting_sos");
|
||||
// mContext.sendBroadcast(intent);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setEmergencyContact(List<Contact> emergencyContact) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setEmpty() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
mView.setSystemSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDesktopLayout() {
|
||||
// NetInterfaceManager.getInstance().getDesktopLayoutObservable()
|
||||
// .compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
// .subscribe(new Observer<BaseResponse<List<NetDesktopIcon>>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(@NonNull Disposable d) {
|
||||
// Log.e("getDesktopLayout", "onSubscribe: ");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(@NonNull BaseResponse<List<NetDesktopIcon>> listBaseResponse) {
|
||||
// Log.e("getDesktopLayout", "onNext: " + listBaseResponse);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(@NonNull Throwable e) {
|
||||
// Log.e("getDesktopLayout", "onError: " + e.getMessage());
|
||||
// onComplete();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// Log.e("getDesktopLayout", "onComplete: ");
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDesktopLayout() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendAPPUsage() {
|
||||
AppUsedTimeUtils.getInstance().setEndTime(System.currentTimeMillis());
|
||||
String packagename = AppUsedTimeUtils.getInstance().getAppPackageName();
|
||||
Log.e(TAG, "onRestart packagename == " + packagename);
|
||||
if (!TextUtils.isEmpty(packagename)) {
|
||||
Log.e(TAG, "onRestart: " + ApkUtils.getAppNameByPackage(mContext, packagename));
|
||||
Log.e(TAG, "onRestart: " + packagename);
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAppUsageRecordControl()
|
||||
.sendappUsageRecord(Utils.getSerial(),
|
||||
ApkUtils.getAppNameByPackage(mContext, packagename),
|
||||
packagename,
|
||||
AppUsedTimeUtils.getInstance().getStartTime() / 1000,
|
||||
AppUsedTimeUtils.getInstance().getEndTime() / 1000)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("sendAPPUsage", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("sendAPPUsage", "onNext: " + baseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("sendAPPUsage", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("sendAPPUsage", "onComplete: ");
|
||||
mView.sendAPPUsageFinish();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Log.e("onRestart", "app = null" + packagename);
|
||||
mView.sendAPPUsageFinish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRunningInfo() {
|
||||
AppUsedTimeUtils.getInstance().setAppPackageName(BuildConfig.APPLICATION_ID);
|
||||
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||
long time = AppUsedTimeUtils.getInstance().getStartTime();
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("app_package", BuildConfig.APPLICATION_ID);
|
||||
jsonObject.addProperty("version_name", ApkUtils.getAPPVersionName(mContext, BuildConfig.APPLICATION_ID));
|
||||
jsonObject.addProperty("start_time", time / 1000);
|
||||
String jsonString = jsonObject.toString();
|
||||
Log.e(TAG, "sendRunningInfo: " + jsonString);
|
||||
NetInterfaceManager.getInstance()
|
||||
.getRunningAppObservable(jsonString)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("sendRunningInfo", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("sendRunningInfo", "onNext: " + baseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("sendRunningInfo", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("sendRunningInfo", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAdminSnSetting() {
|
||||
NetInterfaceManager.getInstance().getAdminSnSetting(true, lifecycle, new NetInterfaceManager.onCompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
package com.uiui.aios.activity.weather;
|
||||
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.qweather.sdk.bean.weather.WeatherDailyBean;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.adapter.WeatherDayApdapter;
|
||||
import com.uiui.aios.base.BaseActivity;
|
||||
import com.uiui.aios.manager.RemoteManager;
|
||||
import com.uiui.aios.view.HorizontalItemDecoration;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class WeatherActivity extends BaseActivity implements WeatherContact.WeatherView {
|
||||
@BindView(R.id.rv_weather)
|
||||
RecyclerView rv_weather;
|
||||
@BindView(R.id.tv_location)
|
||||
TextView tv_location;
|
||||
@BindView(R.id.iv_back)
|
||||
ImageView iv_back;
|
||||
|
||||
private WeatherPresenter mPresenter;
|
||||
private WeatherDayApdapter mWeatherDayApdapter;
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_weather;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
mPresenter = new WeatherPresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
RemoteManager.getInstance().getLocation();
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
|
||||
Resources resources = getResources();
|
||||
if (resources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
||||
rv_weather.addItemDecoration(new HorizontalItemDecoration(30, this));//10表示10dp
|
||||
} else {
|
||||
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
||||
}
|
||||
rv_weather.setLayoutManager(linearLayoutManager);
|
||||
// rv_weather.setLayoutManager(new GridLayoutManager(this, 3));
|
||||
// rv_weather.addItemDecoration(new RecyclerItemDecoration(ScreenUtils.dp2px(resources, 10), ScreenUtils.dp2px(resources, 10), 3));
|
||||
mWeatherDayApdapter = new WeatherDayApdapter();
|
||||
rv_weather.setAdapter(mWeatherDayApdapter);
|
||||
iv_back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
mPresenter.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(String location) {
|
||||
tv_location.setText(location);
|
||||
mPresenter.getWeatherCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeatherCache(WeatherDailyBean weatherCache) {
|
||||
if (weatherCache != null) {
|
||||
mWeatherDayApdapter.setDailyBeans(weatherCache.getDaily());
|
||||
}
|
||||
mPresenter.getWeather();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeather(WeatherDailyBean weather) {
|
||||
if (weather != null) {
|
||||
mWeatherDayApdapter.setDailyBeans(weather.getDaily());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mPresenter.detachView();
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.uiui.aios.activity.weather;
|
||||
|
||||
import com.qweather.sdk.bean.weather.WeatherDailyBean;
|
||||
import com.uiui.aios.base.BasePresenter;
|
||||
import com.uiui.aios.base.BaseView;
|
||||
|
||||
public class WeatherContact {
|
||||
public interface Presenter extends BasePresenter<WeatherView> {
|
||||
//获取定位缓存
|
||||
void getLocation();
|
||||
//获取天气缓存
|
||||
void getWeatherCache();
|
||||
//获取天气
|
||||
void getWeather();
|
||||
}
|
||||
|
||||
public interface WeatherView extends BaseView {
|
||||
//设置定位缓存
|
||||
void setLocation(String location);
|
||||
//设置天气缓存
|
||||
void setWeatherCache(WeatherDailyBean weatherCache);
|
||||
//设置天气
|
||||
void setWeather(WeatherDailyBean weather);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package com.uiui.aios.activity.weather;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.qweather.sdk.bean.weather.WeatherDailyBean;
|
||||
import com.qweather.sdk.view.QWeather;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiui.aios.manager.RemoteManager;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
/**
|
||||
* MainActivity和MainService 的 Presenter
|
||||
*
|
||||
* @author jgy02
|
||||
*/
|
||||
public class WeatherPresenter implements WeatherContact.Presenter {
|
||||
private static final String TAG = WeatherPresenter.class.getSimpleName();
|
||||
private static final String WEATHER_DAILY_KEY = "WEATHER_DAILY_JSON_STRING";
|
||||
private WeatherContact.WeatherView mView;
|
||||
private Context mContext;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
|
||||
private BehaviorSubject<ActivityEvent> lifecycle;
|
||||
|
||||
public void setLifecycle(BehaviorSubject<ActivityEvent> lifecycle) {
|
||||
this.lifecycle = lifecycle;
|
||||
}
|
||||
|
||||
public BehaviorSubject<ActivityEvent> getLifecycle() {
|
||||
return lifecycle;
|
||||
}
|
||||
|
||||
public WeatherPresenter(Context context) {
|
||||
this.mContext = context;
|
||||
Log.e(TAG, "WeatherPresenter: " + context.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachView(@NonNull WeatherContact.WeatherView view) {
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getLocation() {
|
||||
String location = RemoteManager.getInstance().getCityDistrict();
|
||||
mView.setLocation(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getWeatherCache() {
|
||||
// TODO: 2022/1/21 读取json,反序列化,排序
|
||||
String jsonString = mMMKV.decodeString(WEATHER_DAILY_KEY, "");
|
||||
Type type = new TypeToken<WeatherDailyBean>() {
|
||||
}.getType();
|
||||
WeatherDailyBean weatherDailyBean = new Gson().fromJson(jsonString, type);
|
||||
mView.setWeatherCache(weatherDailyBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getWeather() {
|
||||
QWeather.getWeather7D(mContext, RemoteManager.getInstance().getLocationTude(), new QWeather.OnResultWeatherDailyListener() {
|
||||
@Override
|
||||
public void onError(Throwable throwable) {
|
||||
Log.e("getWeather", "onError: " + throwable.getMessage());
|
||||
if (mView != null) {
|
||||
mView.setWeather(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(WeatherDailyBean weatherDailyBean) {
|
||||
String jsonString = new Gson().toJson(weatherDailyBean);
|
||||
Log.d("getWeather", "onSuccess: " + jsonString);
|
||||
mMMKV.encode(WEATHER_DAILY_KEY, jsonString);
|
||||
if (mView != null) {
|
||||
mView.setWeather(weatherDailyBean);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
package com.uiui.aios.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.bean.AppListInfo;
|
||||
import com.uiui.aios.service.NotificationService;
|
||||
import com.uiui.aios.utils.ApkUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class APPListAdapter extends RecyclerView.Adapter<APPListAdapter.holder> {
|
||||
private Context mContext;
|
||||
private List<AppListInfo> mAppListInfos;
|
||||
|
||||
public APPListAdapter(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
public APPListAdapter(Context context, List<AppListInfo> list) {
|
||||
this.mContext = context;
|
||||
this.mAppListInfos = list;
|
||||
}
|
||||
|
||||
public void setAppListInfos(List<AppListInfo> listInfos) {
|
||||
this.mAppListInfos = listInfos;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new APPListAdapter.holder(LayoutInflater.from(mContext).inflate(R.layout.item_app, parent, false));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull holder holder, int position) {
|
||||
final AppListInfo info = mAppListInfos.get(position);
|
||||
String pkg = info.getPackageName();
|
||||
holder.icon.setImageBitmap(info.getIcon());
|
||||
holder.appname.setText(info.getAppName());
|
||||
holder.root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
ApkUtils.openPackage(mContext, pkg);
|
||||
}
|
||||
});
|
||||
int size = NotificationService.getNotificationLength(pkg);
|
||||
if (size == 0) {
|
||||
holder.bg.setVisibility(View.GONE);
|
||||
} else if (size < 99) {
|
||||
holder.bg.setVisibility(View.VISIBLE);
|
||||
holder.bg.setText(String.valueOf(size));
|
||||
} else {
|
||||
holder.bg.setVisibility(View.VISIBLE);
|
||||
holder.bg.setText("99+");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mAppListInfos == null ? 0 : mAppListInfos.size();
|
||||
}
|
||||
|
||||
class holder extends RecyclerView.ViewHolder {
|
||||
private ImageView icon;
|
||||
private TextView appname;
|
||||
private TextView bg;
|
||||
private ConstraintLayout root;
|
||||
|
||||
public holder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
icon = itemView.findViewById(R.id.iv_icon);
|
||||
appname = itemView.findViewById(R.id.tv_appname);
|
||||
bg = itemView.findViewById(R.id.bg);
|
||||
root = itemView.findViewById(R.id.root);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,228 +0,0 @@
|
||||
package com.uiui.aios.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.MediaPlayer;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.bean.AlarmClockData;
|
||||
import com.uiui.aios.utils.FFmpegUtils;
|
||||
import com.uiui.aios.utils.ScreenUtils;
|
||||
import com.uiui.aios.view.JzvdStdRound;
|
||||
import com.uiui.aios.view.MyJzvdStdNoTitleNoClarity;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class AlarmAdapter extends RecyclerView.Adapter<AlarmAdapter.holder> {
|
||||
|
||||
private FragmentActivity mContext;
|
||||
private List<AlarmClockData> mAlarmClockData;
|
||||
|
||||
public void setAlarmClockData(List<AlarmClockData> alarmClockData) {
|
||||
this.mAlarmClockData = alarmClockData;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
mContext = (FragmentActivity) parent.getContext();
|
||||
return new AlarmAdapter.holder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_alarm_clock, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull holder holder, int position) {
|
||||
AlarmClockData alarmClockData = mAlarmClockData.get(position);
|
||||
switch (alarmClockData.getType()) {
|
||||
case 1:
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
Date date = sdf.parse(alarmClockData.getTime());
|
||||
SimpleDateFormat hours = new SimpleDateFormat("HH:mm");
|
||||
String time = hours.format(date);
|
||||
holder.tv_time.setText(time);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
holder.tv_remind_type.setText("单次");
|
||||
break;
|
||||
case 2:
|
||||
holder.tv_time.setText(alarmClockData.getTime());
|
||||
holder.tv_remind_type.setText("循环");
|
||||
break;
|
||||
case 3:
|
||||
holder.tv_time.setText(alarmClockData.getTime());
|
||||
holder.tv_remind_type.setText("周一至周五");
|
||||
break;
|
||||
case 4:
|
||||
holder.tv_time.setText(alarmClockData.getTime());
|
||||
holder.tv_remind_type.setText("周六至周日");
|
||||
break;
|
||||
default:
|
||||
}
|
||||
String title = alarmClockData.getTitle();
|
||||
if (TextUtils.isEmpty(title)) {
|
||||
holder.tv_title.setText("无标题");
|
||||
} else {
|
||||
holder.tv_title.setText(title);
|
||||
}
|
||||
String voice = alarmClockData.getVoice();
|
||||
if (TextUtils.isEmpty(voice)) {
|
||||
holder.cl_voice.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.cl_voice.setVisibility(View.VISIBLE);
|
||||
MediaPlayer mMediaPlayer = new MediaPlayer();
|
||||
mMediaPlayer.setAudioAttributes(
|
||||
new AudioAttributes.Builder()
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
|
||||
.build()
|
||||
);
|
||||
mMediaPlayer.setOnCompletionListener(mp -> Log.e("setOnCompletionListener", "onCompletion: "));
|
||||
mMediaPlayer.setOnPreparedListener(mp -> Log.e("setOnPreparedListener", "onPrepared: "));
|
||||
mMediaPlayer.setOnErrorListener((mp, what, extra) -> false);
|
||||
//设置音频文件到MediaPlayer对象中
|
||||
try {
|
||||
mMediaPlayer.setDataSource(voice);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//让MediaPlayer对象准备,用这个方法防止加载时耗时导致anr
|
||||
mMediaPlayer.prepareAsync();
|
||||
FFmpegUtils.getDurationInMilliseconds(voice, new Observer<Integer>() {
|
||||
@Override
|
||||
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@io.reactivex.rxjava3.annotations.NonNull Integer integer) {
|
||||
holder.tv_voice.setText(integer + "秒");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
holder.cl_voice.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mMediaPlayer.start();
|
||||
}
|
||||
});
|
||||
}
|
||||
String url = alarmClockData.getFile();
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
holder.cl_vp.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.cl_vp.setVisibility(View.VISIBLE);
|
||||
if (isImgUrl(url)) {
|
||||
holder.imageView.setVisibility(View.VISIBLE);
|
||||
holder.jz_video.setVisibility(View.GONE);
|
||||
if (!mContext.isDestroyed()) {
|
||||
RequestOptions options = new RequestOptions().transform(new RoundedCorners(ScreenUtils.dip2px(mContext, 16F)));
|
||||
Glide.with(mContext).load(url).apply(options).into(holder.imageView);
|
||||
}
|
||||
} else {
|
||||
holder.imageView.setVisibility(View.GONE);
|
||||
holder.jz_video.setVisibility(View.VISIBLE);
|
||||
holder.jz_video.setUp(url, "");
|
||||
holder.jz_video.startButton.setImageDrawable(mContext.getDrawable(R.drawable.play));
|
||||
FFmpegUtils.loadVideoScreenshot(url, new Observer<Bitmap>() {
|
||||
@Override
|
||||
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@io.reactivex.rxjava3.annotations.NonNull Bitmap bitmap) {
|
||||
if (!mContext.isDestroyed()) {
|
||||
RequestOptions options = new RequestOptions().transform(new RoundedCorners(ScreenUtils.dip2px(mContext, 16F)));
|
||||
Glide.with(mContext).load(bitmap).apply(options).into(holder.jz_video.posterImageView);
|
||||
}
|
||||
holder.jz_video.startButton.setImageDrawable(mContext.getDrawable(R.drawable.play));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private Pattern mCompile = Pattern.compile(".*?(gif|jpeg|png|jpg|bmp|webp)");
|
||||
|
||||
private boolean isImgUrl(String url) {
|
||||
if (TextUtils.isEmpty(url) || url.trim().length() == 0) {
|
||||
return false;
|
||||
}
|
||||
return mCompile.matcher(url).matches();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mAlarmClockData == null ? 0 : mAlarmClockData.size();
|
||||
}
|
||||
|
||||
class holder extends RecyclerView.ViewHolder {
|
||||
TextView tv_time, tv_remind_type, tv_title, tv_voice;
|
||||
ConstraintLayout cl_voice, cl_vp;
|
||||
JzvdStdRound jz_video;
|
||||
ImageView imageView;
|
||||
Switch switch1;
|
||||
|
||||
public holder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
tv_time = itemView.findViewById(R.id.tv_time);
|
||||
tv_remind_type = itemView.findViewById(R.id.tv_remind_type);
|
||||
tv_title = itemView.findViewById(R.id.tv_title);
|
||||
tv_voice = itemView.findViewById(R.id.tv_voice);
|
||||
cl_voice = itemView.findViewById(R.id.cl_voice);
|
||||
switch1 = itemView.findViewById(R.id.switch1);
|
||||
cl_vp = itemView.findViewById(R.id.cl_vp);
|
||||
jz_video = itemView.findViewById(R.id.jz_video);
|
||||
imageView = itemView.findViewById(R.id.imageView);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.uiui.aios.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.bean.AlarmItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AlarmClockAdapter extends RecyclerView.Adapter<AlarmClockAdapter.ViewHolder> {
|
||||
private List<AlarmItem> alarmItemList;
|
||||
|
||||
public void setAlarmItemList(List<AlarmItem> alarmItems) {
|
||||
this.alarmItemList = alarmItems;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new AlarmClockAdapter.ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_alarmclock, parent, false));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
AlarmItem alarmItem = alarmItemList.get(position);
|
||||
holder.tv_time.setText(alarmItem.mTime);
|
||||
holder.tv_type.setText(alarmItem.mRepeatType);
|
||||
if (alarmItem.mActive) {
|
||||
holder.tv_status.setText("打开");
|
||||
} else {
|
||||
holder.tv_status.setText("关闭");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return alarmItemList == null ? 0 : alarmItemList.size();
|
||||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tv_time;
|
||||
TextView tv_status;
|
||||
TextView tv_type;
|
||||
|
||||
ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
tv_time = itemView.findViewById(R.id.tv_time);
|
||||
tv_status = itemView.findViewById(R.id.tv_status);
|
||||
tv_type = itemView.findViewById(R.id.tv_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package com.uiui.aios.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.activity.QuickAppActivity;
|
||||
import com.uiui.aios.bean.AppSelectBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AppSelectedAdapter extends RecyclerView.Adapter<AppSelectedAdapter.Holder> {
|
||||
private static final String TAG = AppSelectedAdapter.class.getSimpleName();
|
||||
|
||||
private Context mContext;
|
||||
private List<AppSelectBean> mAppSelectBeans;
|
||||
private int unselectedStatus = -1;
|
||||
private int selecedPosition = unselectedStatus;
|
||||
|
||||
public void setAppSelectBeans(List<AppSelectBean> appSelectBeanList) {
|
||||
this.mAppSelectBeans = appSelectBeanList;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
mContext = parent.getContext();
|
||||
return new Holder(LayoutInflater.from(mContext).inflate(R.layout.item_app_select, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Holder holder, int position) {
|
||||
AppSelectBean appSelectBean = mAppSelectBeans.get(position);
|
||||
holder.iv_icon.setImageDrawable(appSelectBean.getIcon());
|
||||
holder.tv_name.setText(appSelectBean.getAppName());
|
||||
if (selecedPosition == position) {
|
||||
holder.iv_select.setImageDrawable(mContext.getDrawable(R.drawable.icon_selected));
|
||||
} else {
|
||||
holder.iv_select.setImageDrawable(mContext.getDrawable(R.drawable.icon_unselected));
|
||||
}
|
||||
holder.iv_select.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (position != selecedPosition) {
|
||||
holder.iv_select.setImageDrawable(mContext.getDrawable(R.drawable.icon_selected));
|
||||
selecedPosition = position;
|
||||
Settings.Global.putString(mContext.getContentResolver(), QuickAppActivity.QUICK_APP_KEY, appSelectBean.getPackageName());
|
||||
Log.e(TAG, "setQuickApp: " + appSelectBean.getPackageName());
|
||||
|
||||
} else {
|
||||
holder.iv_select.setImageDrawable(mContext.getDrawable(R.drawable.icon_unselected));
|
||||
selecedPosition = -1;
|
||||
Settings.Global.putString(mContext.getContentResolver(),QuickAppActivity.QUICK_APP_KEY, "");
|
||||
Log.e(TAG, "setQuickApp: empty");
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mAppSelectBeans == null ? 0 : mAppSelectBeans.size();
|
||||
}
|
||||
|
||||
static class Holder extends RecyclerView.ViewHolder {
|
||||
ImageView iv_select, iv_icon;
|
||||
TextView tv_name;
|
||||
|
||||
Holder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
iv_select = itemView.findViewById(R.id.iv_select);
|
||||
iv_icon = itemView.findViewById(R.id.iv_icon);
|
||||
tv_name = itemView.findViewById(R.id.tv_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
package com.uiui.aios.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.shehuan.niv.NiceImageView;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.bean.Contact;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactHolder> {
|
||||
private List<Contact> mContactList;
|
||||
private Context mContext;
|
||||
|
||||
public static final String DIALER_PACKAGE = "com.android.dialer";
|
||||
|
||||
public void setContactList(List<Contact> contactList) {
|
||||
this.mContactList = contactList;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ContactHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
mContext = parent.getContext();
|
||||
return new ContactHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_contact, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ContactHolder contactHolder, int position) {
|
||||
Contact contact = mContactList.get(position);
|
||||
contactHolder.root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent1 = new Intent(Intent.ACTION_CALL);
|
||||
String phone = contact.getMobile();
|
||||
if (DIALER_PACKAGE.equals(phone)) {
|
||||
mContext.startActivity(new Intent(Intent.ACTION_DIAL));
|
||||
} else if (!TextUtils.isEmpty(phone)) {
|
||||
Uri data = Uri.parse("tel:" + phone);
|
||||
intent1.setData(data);
|
||||
mContext.startActivity(intent1);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
contactHolder.tv_name.setText(contact.getName());
|
||||
if (DIALER_PACKAGE.equals(contact.getMobile())) {
|
||||
contactHolder.tv_phone.setText("");
|
||||
Glide.with(contactHolder.iv_head).load(R.drawable.icon_dialer).error(R.drawable.icon_dialer).into(contactHolder.iv_head);
|
||||
} else {
|
||||
contactHolder.tv_phone.setText(contact.getMobile());
|
||||
Glide.with(contactHolder.iv_head).load(contact.getAvatar()).error(R.drawable.default_head).into(contactHolder.iv_head);
|
||||
}
|
||||
int index = position % 3;
|
||||
switch (index) {
|
||||
case 0:
|
||||
contactHolder.root.setBackground(mContext.getDrawable(R.drawable.background_weather_rain));
|
||||
break;
|
||||
case 1:
|
||||
contactHolder.root.setBackground(mContext.getDrawable(R.drawable.background_weather_sun));
|
||||
break;
|
||||
case 2:
|
||||
contactHolder.root.setBackground(mContext.getDrawable(R.drawable.background_weather_sunny));
|
||||
break;
|
||||
default:
|
||||
contactHolder.root.setBackground(mContext.getDrawable(R.drawable.background_weather_rain));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mContactList == null ? 0 : mContactList.size();
|
||||
}
|
||||
|
||||
static class ContactHolder extends RecyclerView.ViewHolder {
|
||||
ConstraintLayout root;
|
||||
NiceImageView iv_head;
|
||||
TextView tv_name;
|
||||
TextView tv_phone;
|
||||
|
||||
public ContactHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
root = itemView.findViewById(R.id.root);
|
||||
iv_head = itemView.findViewById(R.id.iv_head);
|
||||
tv_name = itemView.findViewById(R.id.tv_name);
|
||||
tv_phone = itemView.findViewById(R.id.tv_phone);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.uiui.aios.adapter;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HealthCodeAdapter extends PagerAdapter {
|
||||
private List<ImageView> mImageViews;
|
||||
|
||||
public void setImageViews(List<ImageView> imageViews) {
|
||||
this.mImageViews = imageViews;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mImageViews == null ? 0 : mImageViews.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
|
||||
return view == object;
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Object instantiateItem(@NonNull ViewGroup container, int position) {
|
||||
// 给 container 添加一个view
|
||||
container.addView(mImageViews.get(position));
|
||||
// 返回一个和该view相对的object
|
||||
return mImageViews.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
|
||||
container.removeView(mImageViews.get(position));
|
||||
}
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
package com.uiui.aios.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.MediaPlayer;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.bean.AlarmClockData;
|
||||
import com.uiui.aios.utils.FFmpegUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class NotificationAdapter extends RecyclerView.Adapter<NotificationAdapter.Holder> {
|
||||
private Context mContext;
|
||||
private List<AlarmClockData> dataList;
|
||||
private OnClickListener mOnClickListener;
|
||||
|
||||
public void setDataList(List<AlarmClockData> data) {
|
||||
this.dataList = data;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setOnClickListener(OnClickListener listener) {
|
||||
this.mOnClickListener = listener;
|
||||
}
|
||||
|
||||
public interface OnClickListener {
|
||||
void onClick();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
mContext = parent.getContext();
|
||||
return new Holder(LayoutInflater.from(mContext).inflate(R.layout.item_notification, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Holder holder, int position) {
|
||||
AlarmClockData alarmClockData = dataList.get(position);
|
||||
holder.tv_title.setText("提醒事件:" + alarmClockData.getTitle());
|
||||
String time = alarmClockData.getTime();
|
||||
if (time.length() > 5) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
SimpleDateFormat hours = new SimpleDateFormat("HH:mm");
|
||||
try {
|
||||
Date date = sdf.parse(time);
|
||||
String hourTime = hours.format(date);
|
||||
holder.tv_time.setText(hourTime);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
holder.tv_time.setText(time);
|
||||
}
|
||||
String voice = alarmClockData.getVoice();
|
||||
holder.root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mOnClickListener != null) {
|
||||
mOnClickListener.onClick();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (TextUtils.isEmpty(voice)) {
|
||||
holder.cl_voice.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.cl_voice.setVisibility(View.VISIBLE);
|
||||
MediaPlayer mMediaPlayer = new MediaPlayer();
|
||||
mMediaPlayer.setAudioAttributes(
|
||||
new AudioAttributes.Builder()
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
|
||||
.build()
|
||||
);
|
||||
mMediaPlayer.setOnCompletionListener(mp -> Log.e("setOnCompletionListener", "onCompletion: "));
|
||||
mMediaPlayer.setOnPreparedListener(mp -> Log.e("setOnPreparedListener", "onPrepared: "));
|
||||
mMediaPlayer.setOnErrorListener((mp, what, extra) -> false);
|
||||
//设置音频文件到MediaPlayer对象中
|
||||
try {
|
||||
mMediaPlayer.setDataSource(voice);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//让MediaPlayer对象准备,用这个方法防止加载时耗时导致anr
|
||||
mMediaPlayer.prepareAsync();
|
||||
FFmpegUtils.getDurationInMilliseconds(voice, new Observer<Integer>() {
|
||||
@Override
|
||||
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@io.reactivex.rxjava3.annotations.NonNull Integer integer) {
|
||||
holder.tv_voice.setText(integer + "秒");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
holder.cl_voice.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mMediaPlayer.start();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return dataList == null ? 0 : dataList.size();
|
||||
}
|
||||
|
||||
class Holder extends RecyclerView.ViewHolder {
|
||||
TextView tv_title;
|
||||
TextView tv_time;
|
||||
TextView tv_voice;
|
||||
ConstraintLayout cl_voice;
|
||||
ConstraintLayout root;
|
||||
|
||||
public Holder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
root = itemView.findViewById(R.id.root);
|
||||
tv_title = itemView.findViewById(R.id.tv_title);
|
||||
tv_time = itemView.findViewById(R.id.tv_time);
|
||||
tv_voice = itemView.findViewById(R.id.tv_voice);
|
||||
cl_voice = itemView.findViewById(R.id.cl_voice);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package com.uiui.aios.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.activity.EmergencyActivity;
|
||||
import com.uiui.aios.bean.Contact;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SOSNnmberAdapter extends RecyclerView.Adapter<SOSNnmberAdapter.ViewHolder> {
|
||||
private List<Contact> phoneNumberList;
|
||||
private Context mContext;
|
||||
|
||||
public void setPhoneNumberList(List<Contact> contactList) {
|
||||
this.phoneNumberList = contactList;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
mContext = parent.getContext();
|
||||
return new SOSNnmberAdapter.ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_sosnumber, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
Contact contact = phoneNumberList.get(position);
|
||||
holder.tv_number.setText(contact.getMobile());
|
||||
holder.root.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(mContext, EmergencyActivity.class);
|
||||
intent.putExtra("setting_sos", contact.getMobile());
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(intent);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return phoneNumberList == null ? 0 : phoneNumberList.size();
|
||||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tv_number;
|
||||
TextView tv_dial;
|
||||
ConstraintLayout root;
|
||||
|
||||
ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
tv_number = itemView.findViewById(R.id.tv_number);
|
||||
tv_dial = itemView.findViewById(R.id.tv_dial);
|
||||
root = itemView.findViewById(R.id.root);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
package com.uiui.aios.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.qweather.sdk.bean.weather.WeatherDailyBean;
|
||||
import com.uiui.aios.R;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class WeatherDayApdapter extends RecyclerView.Adapter<WeatherDayApdapter.WeatherHolder> {
|
||||
private static final String TAG = WeatherDayApdapter.class.getSimpleName();
|
||||
private List<WeatherDailyBean.DailyBean> mDailyBeans;
|
||||
private Context mContext;
|
||||
|
||||
public void setDailyBeans(List<WeatherDailyBean.DailyBean> dailyBeans) {
|
||||
this.mDailyBeans = dailyBeans;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public WeatherHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
mContext = parent.getContext();
|
||||
return new WeatherHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_weather, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull WeatherHolder holder, int position) {
|
||||
WeatherDailyBean.DailyBean dailyBean = mDailyBeans.get(position);
|
||||
String dateString;
|
||||
switch (position) {
|
||||
// case 0:
|
||||
// dateString = "今天";
|
||||
// break;
|
||||
// case 1:
|
||||
// dateString = "明天";
|
||||
// break;
|
||||
// case 2:
|
||||
// dateString = "后天";
|
||||
// break;
|
||||
default:
|
||||
dateString = dailyBean.getFxDate();
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date date = sdf.parse(dailyBean.getFxDate());
|
||||
SimpleDateFormat now = new SimpleDateFormat("MM月dd日");
|
||||
dateString = now.format(date);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
holder.tv_date.setText(dateString);
|
||||
holder.tv_temp.setText(dailyBean.getTempMin() + "℃ - " + dailyBean.getTempMax() + "℃");
|
||||
holder.tv_weather.setText(dailyBean.getTextDay());
|
||||
String iconDay = dailyBean.getIconDay();
|
||||
switch (iconDay) {
|
||||
case "100":
|
||||
case "150":
|
||||
holder.iv_bg.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.background_weather_sun));
|
||||
break;
|
||||
case "102":
|
||||
case "152":
|
||||
holder.iv_bg.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.background_weather_sunny));
|
||||
break;
|
||||
default:
|
||||
holder.iv_bg.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.background_weather_rain));
|
||||
}
|
||||
holder.iv_weather.setImageDrawable(getWeatherDrawable(iconDay));
|
||||
}
|
||||
|
||||
private Drawable getWeatherDrawable(String iconName) {
|
||||
int resID = mContext.getResources().getIdentifier("he" + iconName, "drawable", "com.uiui.aios");
|
||||
if (resID == 0) {
|
||||
Log.e(TAG, "getView: not found src : " + iconName);
|
||||
return mContext.getResources().getDrawable(R.drawable.he100);
|
||||
} else {
|
||||
return mContext.getResources().getDrawable(resID);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mDailyBeans == null ? 0 : mDailyBeans.size();
|
||||
}
|
||||
|
||||
static class WeatherHolder extends RecyclerView.ViewHolder {
|
||||
TextView tv_date;
|
||||
ImageView iv_weather;
|
||||
ImageView iv_bg;
|
||||
TextView tv_weather;
|
||||
TextView tv_temp;
|
||||
|
||||
public WeatherHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
tv_date = itemView.findViewById(R.id.tv_date);
|
||||
iv_weather = itemView.findViewById(R.id.iv_weather);
|
||||
iv_bg = itemView.findViewById(R.id.iv_bg);
|
||||
tv_weather = itemView.findViewById(R.id.tv_weather);
|
||||
tv_temp = itemView.findViewById(R.id.tv_temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,294 +0,0 @@
|
||||
package com.uiui.aios.bean;
|
||||
|
||||
import com.qweather.sdk.bean.Basic;
|
||||
import com.qweather.sdk.bean.Refer;
|
||||
import com.qweather.sdk.bean.base.Code;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class WeatherDailyJson implements Serializable {
|
||||
private static final long serialVersionUID = 1585791680452421396L;
|
||||
|
||||
private Code code;
|
||||
private Basic basic;
|
||||
private List<DailyJson> daily;
|
||||
private Refer refer;
|
||||
|
||||
public WeatherDailyJson() {
|
||||
}
|
||||
|
||||
public Refer getRefer() {
|
||||
return this.refer;
|
||||
}
|
||||
|
||||
public void setRefer(Refer var1) {
|
||||
this.refer = var1;
|
||||
}
|
||||
|
||||
public Code getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public void setCode(Code var1) {
|
||||
this.code = var1;
|
||||
}
|
||||
|
||||
public Basic getBasic() {
|
||||
return this.basic;
|
||||
}
|
||||
|
||||
public void setBasic(Basic var1) {
|
||||
this.basic = var1;
|
||||
}
|
||||
|
||||
public List<DailyJson> getDaily() {
|
||||
return this.daily;
|
||||
}
|
||||
|
||||
public void setDaily(List<DailyJson> var1) {
|
||||
this.daily = var1;
|
||||
}
|
||||
|
||||
public static class DailyJson {
|
||||
String fxDate = "";
|
||||
String sunrise = "";
|
||||
String sunset = "";
|
||||
String moonRise = "";
|
||||
String moonSet = "";
|
||||
String moonPhase = "";
|
||||
String tempMax = "";
|
||||
String tempMin = "";
|
||||
String iconDay = "";
|
||||
String textDay = "";
|
||||
String iconNight = "";
|
||||
String textNight = "";
|
||||
String wind360Day = "";
|
||||
String windDirDay = "";
|
||||
String windScaleDay = "";
|
||||
String windSpeedDay = "";
|
||||
String wind360Night = "";
|
||||
String windDirNight = "";
|
||||
String windScaleNight = "";
|
||||
String windSpeedNight = "";
|
||||
String humidity = "";
|
||||
String precip = "";
|
||||
String pressure = "";
|
||||
String vis = "";
|
||||
String cloud = "";
|
||||
String uvIndex = "";
|
||||
|
||||
public DailyJson() {
|
||||
|
||||
}
|
||||
|
||||
public String getFxDate() {
|
||||
return this.fxDate;
|
||||
}
|
||||
|
||||
public void setFxDate(String var1) {
|
||||
this.fxDate = var1;
|
||||
}
|
||||
|
||||
public String getSunrise() {
|
||||
return this.sunrise;
|
||||
}
|
||||
|
||||
public void setSunrise(String var1) {
|
||||
this.sunrise = var1;
|
||||
}
|
||||
|
||||
public String getSunset() {
|
||||
return this.sunset;
|
||||
}
|
||||
|
||||
public void setSunset(String var1) {
|
||||
this.sunset = var1;
|
||||
}
|
||||
|
||||
public String getMoonRise() {
|
||||
return this.moonRise;
|
||||
}
|
||||
|
||||
public void setMoonRise(String var1) {
|
||||
this.moonRise = var1;
|
||||
}
|
||||
|
||||
public String getMoonSet() {
|
||||
return this.moonSet;
|
||||
}
|
||||
|
||||
public void setMoonSet(String var1) {
|
||||
this.moonSet = var1;
|
||||
}
|
||||
|
||||
public String getMoonPhase() {
|
||||
return this.moonPhase;
|
||||
}
|
||||
|
||||
public void setMoonPhase(String var1) {
|
||||
this.moonPhase = var1;
|
||||
}
|
||||
|
||||
public String getTempMax() {
|
||||
return this.tempMax;
|
||||
}
|
||||
|
||||
public void setTempMax(String var1) {
|
||||
this.tempMax = var1;
|
||||
}
|
||||
|
||||
public String getTempMin() {
|
||||
return this.tempMin;
|
||||
}
|
||||
|
||||
public void setTempMin(String var1) {
|
||||
this.tempMin = var1;
|
||||
}
|
||||
|
||||
public String getIconDay() {
|
||||
return this.iconDay;
|
||||
}
|
||||
|
||||
public void setIconDay(String var1) {
|
||||
this.iconDay = var1;
|
||||
}
|
||||
|
||||
public String getTextDay() {
|
||||
return this.textDay;
|
||||
}
|
||||
|
||||
public void setTextDay(String var1) {
|
||||
this.textDay = var1;
|
||||
}
|
||||
|
||||
public String getIconNight() {
|
||||
return this.iconNight;
|
||||
}
|
||||
|
||||
public void setIconNight(String var1) {
|
||||
this.iconNight = var1;
|
||||
}
|
||||
|
||||
public String getTextNight() {
|
||||
return this.textNight;
|
||||
}
|
||||
|
||||
public void setTextNight(String var1) {
|
||||
this.textNight = var1;
|
||||
}
|
||||
|
||||
public String getWind360Day() {
|
||||
return this.wind360Day;
|
||||
}
|
||||
|
||||
public void setWind360Day(String var1) {
|
||||
this.wind360Day = var1;
|
||||
}
|
||||
|
||||
public String getWindDirDay() {
|
||||
return this.windDirDay;
|
||||
}
|
||||
|
||||
public void setWindDirDay(String var1) {
|
||||
this.windDirDay = var1;
|
||||
}
|
||||
|
||||
public String getWindScaleDay() {
|
||||
return this.windScaleDay;
|
||||
}
|
||||
|
||||
public void setWindScaleDay(String var1) {
|
||||
this.windScaleDay = var1;
|
||||
}
|
||||
|
||||
public String getWindSpeedDay() {
|
||||
return this.windSpeedDay;
|
||||
}
|
||||
|
||||
public void setWindSpeedDay(String var1) {
|
||||
this.windSpeedDay = var1;
|
||||
}
|
||||
|
||||
public String getWind360Night() {
|
||||
return this.wind360Night;
|
||||
}
|
||||
|
||||
public void setWind360Night(String var1) {
|
||||
this.wind360Night = var1;
|
||||
}
|
||||
|
||||
public String getWindDirNight() {
|
||||
return this.windDirNight;
|
||||
}
|
||||
|
||||
public void setWindDirNight(String var1) {
|
||||
this.windDirNight = var1;
|
||||
}
|
||||
|
||||
public String getWindScaleNight() {
|
||||
return this.windScaleNight;
|
||||
}
|
||||
|
||||
public void setWindScaleNight(String var1) {
|
||||
this.windScaleNight = var1;
|
||||
}
|
||||
|
||||
public String getWindSpeedNight() {
|
||||
return this.windSpeedNight;
|
||||
}
|
||||
|
||||
public void setWindSpeedNight(String var1) {
|
||||
this.windSpeedNight = var1;
|
||||
}
|
||||
|
||||
public String getHumidity() {
|
||||
return this.humidity;
|
||||
}
|
||||
|
||||
public void setHumidity(String var1) {
|
||||
this.humidity = var1;
|
||||
}
|
||||
|
||||
public String getPrecip() {
|
||||
return this.precip;
|
||||
}
|
||||
|
||||
public void setPrecip(String var1) {
|
||||
this.precip = var1;
|
||||
}
|
||||
|
||||
public String getPressure() {
|
||||
return this.pressure;
|
||||
}
|
||||
|
||||
public void setPressure(String var1) {
|
||||
this.pressure = var1;
|
||||
}
|
||||
|
||||
public String getVis() {
|
||||
return this.vis;
|
||||
}
|
||||
|
||||
public void setVis(String var1) {
|
||||
this.vis = var1;
|
||||
}
|
||||
|
||||
public String getCloud() {
|
||||
return this.cloud;
|
||||
}
|
||||
|
||||
public void setCloud(String var1) {
|
||||
this.cloud = var1;
|
||||
}
|
||||
|
||||
public String getUvIndex() {
|
||||
return this.uvIndex;
|
||||
}
|
||||
|
||||
public void setUvIndex(String var1) {
|
||||
this.uvIndex = var1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,358 +0,0 @@
|
||||
package com.uiui.aios.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.activity.code.FamilySpaceActivity;
|
||||
import com.uiui.aios.base.BaseFragment;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.DesktopIcon;
|
||||
import com.uiui.aios.config.CommonConfig;
|
||||
import com.uiui.aios.dialog.CustomDialog;
|
||||
import com.uiui.aios.dialog.PasswordDialog;
|
||||
import com.uiui.aios.network.NetInterfaceManager;
|
||||
import com.uiui.aios.service.NotificationService;
|
||||
import com.uiui.aios.utils.ApkUtils;
|
||||
import com.uiui.aios.utils.AppUsedTimeUtils;
|
||||
import com.uiui.aios.utils.BitmapUtils;
|
||||
import com.uiui.aios.utils.IconUtils;
|
||||
import com.uiui.aios.utils.LauncherUtils;
|
||||
import com.uiui.aios.utils.ToastUtil;
|
||||
import com.uiui.aios.view.MyGridLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link AppListFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class AppListFragment extends BaseFragment {
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
private Context mContext;
|
||||
private ArrayList<DesktopIcon> mDesktopIcons;
|
||||
private MyGridLayout gridLayout;
|
||||
private String TAG = AppListFragment.class.getSimpleName();
|
||||
|
||||
public AppListFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment AppListFragment.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static AppListFragment newInstance(String param1, String param2) {
|
||||
AppListFragment fragment = new AppListFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (savedInstanceState != null) {
|
||||
mDesktopIcons = savedInstanceState.getParcelableArrayList("applicationInfos");
|
||||
}
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchData() {
|
||||
|
||||
}
|
||||
|
||||
private View rootView;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
rootView = inflater.inflate(R.layout.fragment_applist, container, false);
|
||||
mContext = rootView.getContext();
|
||||
initView();
|
||||
return rootView;
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
if (mDesktopIcons.size() != 12) {
|
||||
mDesktopIcons.addAll(new ArrayList<>(Arrays.asList(new DesktopIcon[12 - mDesktopIcons.size()])));
|
||||
}
|
||||
gridLayout = rootView.findViewById(R.id.list);
|
||||
if (mContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
gridLayout.set(4, 3);
|
||||
} else {
|
||||
gridLayout.set(3, 4);
|
||||
}
|
||||
|
||||
gridLayout.setGridAdapter(new MyGridLayout.GridAdatper() {
|
||||
@Override
|
||||
public View getView(int index) {
|
||||
PackageManager pm = rootView.getContext().getPackageManager();
|
||||
View view = getLayoutInflater().inflate(R.layout.item_actions, null);
|
||||
ImageView iv = view.findViewById(R.id.iv);
|
||||
TextView tv = view.findViewById(R.id.tv);
|
||||
TextView bg = view.findViewById(R.id.bg);
|
||||
ConstraintLayout constraintLayout = view.findViewById(R.id.btn_booktag);
|
||||
DesktopIcon desktopIcon = mDesktopIcons.get(index);
|
||||
if (desktopIcon != null) {
|
||||
String pkg = desktopIcon.getPackageName();
|
||||
Log.e(TAG, "getView: " + pkg);
|
||||
int i = IconUtils.appClassNameList.indexOf(pkg);
|
||||
if (i != -1) {
|
||||
String val = IconUtils.appIconList.get(i);
|
||||
int resID = mContext.getResources().getIdentifier(val, "drawable", "com.uiui.aios");
|
||||
int size = NotificationService.getNotificationLength(pkg);
|
||||
if (size == 0) {
|
||||
bg.setVisibility(View.GONE);
|
||||
} else if (size < 99) {
|
||||
bg.setVisibility(View.VISIBLE);
|
||||
bg.setText(String.valueOf(size));
|
||||
} else {
|
||||
bg.setVisibility(View.VISIBLE);
|
||||
bg.setText("99+");
|
||||
}
|
||||
if (resID == 0) {
|
||||
Log.e(TAG, "getView: not found src : " + pkg);
|
||||
iv.setImageDrawable(desktopIcon.getIcon());
|
||||
} else {
|
||||
iv.setImageDrawable(mContext.getResources().getDrawable(resID));
|
||||
}
|
||||
} else {
|
||||
iv.setImageBitmap(BitmapUtils.getIconBitmap(rootView.getContext(), desktopIcon.getIcon()));
|
||||
}
|
||||
tv.setText(desktopIcon.getLable());
|
||||
// linearLayout.setEnabled(true);
|
||||
} else {
|
||||
// linearLayout.setEnabled(false);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
// return applicationInfos == null ? 0 : applicationInfos.size();
|
||||
return mDesktopIcons.size();
|
||||
}
|
||||
});
|
||||
gridLayout.setApplicationInfos(mDesktopIcons);
|
||||
gridLayout.setOnItemClickListener(new MyGridLayout.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View v, int index) {
|
||||
DesktopIcon desktopIcon = mDesktopIcons.get(index);
|
||||
if (desktopIcon != null) {
|
||||
Log.e(TAG, "onItemClick: " + desktopIcon.getPackageName());
|
||||
switch (desktopIcon.getPackageName()) {
|
||||
case "aios.exit":
|
||||
int is_activation = Settings.Global.getInt(mContext.getContentResolver(), CommonConfig.UIUI_ACTIVATION_KEY, 0);
|
||||
if (is_activation == 0) {
|
||||
LauncherUtils.openLauncher3(mContext);
|
||||
} else {
|
||||
showPassword();
|
||||
}
|
||||
break;
|
||||
case "aios.family":
|
||||
startActivity(new Intent(mContext, FamilySpaceActivity.class));
|
||||
break;
|
||||
case "com.android.dialer":
|
||||
int qch_call_forbid = Settings.System.getInt(mContext.getContentResolver(), "qch_call_forbid", 0);
|
||||
if (qch_call_forbid == 1) {
|
||||
ToastUtil.show("电话功能被禁用");
|
||||
return;
|
||||
} else {
|
||||
ApkUtils.openPackage(v.getContext(), desktopIcon.getPackageName(), desktopIcon.getClassName());
|
||||
AppUsedTimeUtils.getInstance().setAppPackageName(desktopIcon.getPackageName());
|
||||
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||
SendRunningApp(mContext);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ApkUtils.openPackage(v.getContext(), desktopIcon.getPackageName(), desktopIcon.getClassName());
|
||||
AppUsedTimeUtils.getInstance().setAppPackageName(desktopIcon.getPackageName());
|
||||
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||
SendRunningApp(mContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongClick(View v, int index) {
|
||||
DesktopIcon desktopIcon = mDesktopIcons.get(index);
|
||||
if (desktopIcon == null) return;
|
||||
String pkg = desktopIcon.getPackageName();
|
||||
Log.e(TAG, "onLongClick: " + pkg);
|
||||
switch (pkg) {
|
||||
case "aios.exit":
|
||||
case "com.uiui.sn":
|
||||
break;
|
||||
default:
|
||||
showHinDialog(pkg, desktopIcon.getLable());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateAppDisableStatus(String pkg, String label) {
|
||||
NetInterfaceManager.getInstance().getUpdateAppIconObservable(pkg, label, 0)
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, FragmentEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("updateAppDisableStatus", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||
Log.e("updateAppDisableStatus", "onNext: " + baseResponse);
|
||||
if (baseResponse.code == 200) {
|
||||
ApkUtils.disableApp(mContext, pkg);
|
||||
} else {
|
||||
ToastUtil.show("隐藏失败,检查网络连接");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("updateAppDisableStatus", "onError: ");
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("updateAppDisableStatus", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showHinDialog(String pkg, String label) {
|
||||
CustomDialog customDialog = new CustomDialog(mContext);
|
||||
customDialog.setTitle("隐藏应用");
|
||||
customDialog.setMessage("是否要隐藏:" + label);
|
||||
customDialog.setOnClickBottomListener(new CustomDialog.OnClickBottomListener() {
|
||||
@Override
|
||||
public void onPositiveClick() {
|
||||
updateAppDisableStatus(pkg, label);
|
||||
customDialog.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNegtiveClick() {
|
||||
customDialog.dismiss();
|
||||
}
|
||||
});
|
||||
customDialog.show();
|
||||
}
|
||||
|
||||
private void showPassword() {
|
||||
PasswordDialog passwordDialog = new PasswordDialog(mContext);
|
||||
passwordDialog.setTitle("退出关怀系统");
|
||||
passwordDialog.setOnClickBottomListener(new PasswordDialog.OnClickBottomListener() {
|
||||
@Override
|
||||
public void onPositiveClick() {
|
||||
if ("666666".equals(passwordDialog.getPassword())) {
|
||||
LauncherUtils.openLauncher3(mContext);
|
||||
passwordDialog.dismiss();
|
||||
} else {
|
||||
ToastUtil.show("密码错误");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNegtiveClick() {
|
||||
passwordDialog.dismiss();
|
||||
}
|
||||
});
|
||||
passwordDialog.show();
|
||||
passwordDialog.getWindow().setGravity(Gravity.CENTER);
|
||||
passwordDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
|
||||
passwordDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
}
|
||||
|
||||
private void SendRunningApp(Context context) {
|
||||
String packageName = AppUsedTimeUtils.getInstance().getAppPackageName();
|
||||
long time = AppUsedTimeUtils.getInstance().getStartTime();
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("app_package", packageName);
|
||||
jsonObject.addProperty("version_name", ApkUtils.getAPPVersionName(context, packageName));
|
||||
jsonObject.addProperty("start_time", time / 1000);
|
||||
String jsonString = jsonObject.toString();
|
||||
Log.e(TAG, "SendRunningApp: " + jsonString);
|
||||
NetInterfaceManager.getInstance()
|
||||
.getRunningAppObservable(jsonString)
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("SendRunningApp", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("SendRunningApp", "onSubscribe: " + baseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("SendRunningApp", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("SendRunningApp", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setAppList(ArrayList<DesktopIcon> appList) {
|
||||
this.mDesktopIcons = appList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
outState.putParcelableArrayList("applicationInfos", mDesktopIcons);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
}
|
||||
@@ -1,847 +0,0 @@
|
||||
package com.uiui.aios.fragment;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.hardware.camera2.CameraAccessException;
|
||||
import android.hardware.camera2.CameraCharacteristics;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
import android.media.AudioManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.config.CommonConfig;
|
||||
import com.uiui.aios.disklrucache.CacheHelper;
|
||||
import com.uiui.aios.manager.RemoteManager;
|
||||
import com.uiui.aios.utils.BrightnessUtils;
|
||||
import com.uiui.aios.view.RulerSeekBar;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link ControlFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class ControlFragment extends Fragment {
|
||||
private static final String TAG = ControlFragment.class.getSimpleName();
|
||||
|
||||
// @BindView(R.id.iv_back)
|
||||
// ImageView iv_back;
|
||||
|
||||
@BindView(R.id.tv_wifi)
|
||||
TextView tv_wifi;
|
||||
@BindView(R.id.tv_wifi_ssid)
|
||||
TextView tv_wifi_ssid;
|
||||
@BindView(R.id.tv_bt)
|
||||
TextView tv_bt;
|
||||
@BindView(R.id.tv_bt_ssid)
|
||||
TextView tv_bt_ssid;
|
||||
|
||||
// @BindView(R.id.tv_font_size)
|
||||
// TextView tv_font_size;
|
||||
@BindView(R.id.seekBar)
|
||||
RulerSeekBar seekBar;
|
||||
@BindView(R.id.seekbar_brightness)
|
||||
SeekBar seekbar_brightness;
|
||||
@BindView(R.id.seekbar_sound)
|
||||
SeekBar seekbar_sound;
|
||||
|
||||
@BindView(R.id.tv_sound)
|
||||
TextView tv_sound;
|
||||
|
||||
@BindView(R.id.tv_battery)
|
||||
TextView tv_battery;
|
||||
@BindView(R.id.tv_electricity)
|
||||
TextView tv_electricity;
|
||||
@BindView(R.id.tv_flashlight)
|
||||
TextView tv_flashlight;
|
||||
@BindView(R.id.tv_flashlight_switch)
|
||||
TextView tv_flashlight_switch;
|
||||
|
||||
@BindView(R.id.tv_brightness)
|
||||
TextView tv_brightness;
|
||||
@BindView(R.id.tv_location)
|
||||
TextView tv_location;
|
||||
|
||||
@BindView(R.id.cl_wifi)
|
||||
ConstraintLayout cl_wifi;
|
||||
@BindView(R.id.cl_bt)
|
||||
ConstraintLayout cl_bt;
|
||||
@BindView(R.id.cl_battery)
|
||||
ConstraintLayout cl_battery;
|
||||
@BindView(R.id.cl_flashlight)
|
||||
ConstraintLayout cl_flashlight;
|
||||
@BindView(R.id.cl_location)
|
||||
ConstraintLayout cl_location;
|
||||
|
||||
private View rootView;
|
||||
private Context mContext;
|
||||
private ContentResolver mCRv;
|
||||
private CacheHelper mCacheHelper;
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
public ControlFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment ControlFragment.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static ControlFragment newInstance(String param1, String param2) {
|
||||
ControlFragment fragment = new ControlFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
rootView = inflater.inflate(R.layout.fragment_control, container, false);
|
||||
mContext = rootView.getContext();
|
||||
mCRv = mContext.getContentResolver();
|
||||
mCacheHelper = new CacheHelper(mContext);
|
||||
ButterKnife.bind(this, rootView);
|
||||
initView();
|
||||
initData();
|
||||
return rootView;
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
tv_wifi_ssid.requestFocus();
|
||||
|
||||
getWifi();
|
||||
registerWiFiReceiver();
|
||||
getBluetooth();
|
||||
registerBluetoothReceiver();
|
||||
getBattery();
|
||||
registerBatteryReceiver();
|
||||
getFlashlight();
|
||||
getFontSize();
|
||||
getLocation();
|
||||
getBrightness();
|
||||
getSound();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
|
||||
}
|
||||
|
||||
private void getWifi() {
|
||||
cl_wifi.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS));
|
||||
}
|
||||
});
|
||||
if (isWifiEnabled()) {
|
||||
tv_wifi_ssid.setText(getConnectWifiSsid());
|
||||
cl_wifi.setBackground(mContext.getDrawable(R.drawable.control_background_item));
|
||||
} else {
|
||||
tv_wifi_ssid.setText("未连接");
|
||||
cl_wifi.setBackground(mContext.getDrawable(R.drawable.control_background_item_dis));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isWifiEnabled() {
|
||||
WifiManager wifiMgr = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
|
||||
if (wifiMgr.getWifiState() == WifiManager.WIFI_STATE_ENABLED) {
|
||||
ConnectivityManager connManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo wifiInfo = connManager
|
||||
.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||
return wifiInfo.isConnected();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private WifiReceiver mWifiReceiver;
|
||||
|
||||
private void registerWiFiReceiver() {
|
||||
if (mWifiReceiver == null) {
|
||||
mWifiReceiver = new WifiReceiver();
|
||||
}
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||
filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
|
||||
filter.addAction(WifiManager.RSSI_CHANGED_ACTION);
|
||||
filter.addAction(WifiManager.NETWORK_IDS_CHANGED_ACTION);
|
||||
filter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
|
||||
filter.addAction(WifiManager.CONFIGURED_NETWORKS_CHANGED_ACTION);
|
||||
filter.addAction(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION);
|
||||
filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
|
||||
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
mContext.registerReceiver(mWifiReceiver, filter);
|
||||
}
|
||||
|
||||
class WifiReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "wifiReceiver";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
switch (intent.getAction()) {
|
||||
case WifiManager.RSSI_CHANGED_ACTION:
|
||||
Log.e(TAG, "wifi信号强度变化");
|
||||
break;
|
||||
//wifi连接上与否
|
||||
case WifiManager.NETWORK_STATE_CHANGED_ACTION:
|
||||
NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
|
||||
if (info.getState().equals(NetworkInfo.State.DISCONNECTED)) {
|
||||
Log.e(TAG, "wifi断开");
|
||||
tv_wifi_ssid.setText("未连接");
|
||||
cl_wifi.setBackground(mContext.getDrawable(R.drawable.control_background_item_dis));
|
||||
} else if (info.getState().equals(NetworkInfo.State.CONNECTED)) {
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
//获取当前wifi名称
|
||||
String newSSID = wifiInfo.getSSID();
|
||||
tv_wifi_ssid.setText(newSSID.replaceAll("\"", ""));
|
||||
cl_wifi.setBackground(mContext.getDrawable(R.drawable.control_background_item));
|
||||
}
|
||||
break;
|
||||
//wifi打开与否
|
||||
case WifiManager.WIFI_STATE_CHANGED_ACTION:
|
||||
int wifistate = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_DISABLED);
|
||||
if (wifistate == WifiManager.WIFI_STATE_DISABLED) {
|
||||
Log.e(TAG, "系统关闭wifi");
|
||||
tv_wifi_ssid.setText("关");
|
||||
cl_wifi.setBackground(mContext.getDrawable(R.drawable.control_background_item_dis));
|
||||
} else if (wifistate == WifiManager.WIFI_STATE_ENABLED) {
|
||||
Log.e(TAG, "系统开启wifi");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
setBrightness();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前连接WIFI的SSID
|
||||
*/
|
||||
public String getSSID() {
|
||||
WifiManager wm = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
|
||||
if (wm != null) {
|
||||
WifiInfo winfo = wm.getConnectionInfo();
|
||||
if (winfo != null) {
|
||||
String s = winfo.getSSID();
|
||||
if (s.length() > 2 && s.charAt(0) == '"' && s.charAt(s.length() - 1) == '"') {
|
||||
return s.substring(1, s.length() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getConnectWifiSsid() {
|
||||
WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
// //去掉带引号的字符串方法一
|
||||
// String wifiInfo1 = wifiInfo.getSSID();
|
||||
// if (wifiInfo1.contains("\"")) {
|
||||
// wifiInfo1 = wifiInfo1.substring(1, wifiInfo1.length() - 1);
|
||||
// }
|
||||
//去掉带引号的字符串方法二
|
||||
String wifiSSID = wifiInfo.getSSID();
|
||||
String wifiInfo1 = wifiSSID.replaceAll("\"", "");
|
||||
return wifiInfo1;
|
||||
}
|
||||
|
||||
private BluetoothAdapter bluetoothAdapter;
|
||||
|
||||
private void getBluetooth() {
|
||||
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (bluetoothAdapter.isEnabled()) {
|
||||
if (isConnected()) {
|
||||
cl_bt.setBackground(mContext.getDrawable(R.drawable.control_background_item));
|
||||
tv_bt_ssid.setText(getBluetoothDeviceName());
|
||||
} else {
|
||||
cl_bt.setBackground(mContext.getDrawable(R.drawable.control_background_item_dis));
|
||||
tv_bt_ssid.setText("未连接");
|
||||
}
|
||||
} else {
|
||||
cl_bt.setBackground(mContext.getDrawable(R.drawable.control_background_item_dis));
|
||||
tv_bt_ssid.setText("已关闭");
|
||||
}
|
||||
getConnectedDevicesV1();
|
||||
cl_bt.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(Settings.ACTION_BLUETOOTH_SETTINGS));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
Set<BluetoothDevice> bondedDevices = bluetoothAdapter.getBondedDevices();
|
||||
List<BluetoothDevice> deviceList = bondedDevices.stream().filter(new Predicate<BluetoothDevice>() {
|
||||
@Override
|
||||
public boolean test(BluetoothDevice bluetoothDevice) {
|
||||
return bluetoothDevice.isConnected();
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
return deviceList.size() > 0;
|
||||
}
|
||||
|
||||
public String getBluetoothDeviceName() {
|
||||
Set<BluetoothDevice> bondedDevices = bluetoothAdapter.getBondedDevices();
|
||||
List<BluetoothDevice> deviceList = bondedDevices.stream().filter(new Predicate<BluetoothDevice>() {
|
||||
@Override
|
||||
public boolean test(BluetoothDevice bluetoothDevice) {
|
||||
return bluetoothDevice.isConnected();
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
if (deviceList.size() == 0) {
|
||||
return "未连接";
|
||||
} else {
|
||||
return deviceList.get(0).getName();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO 根据mac地址判断是否已连接(这里参数可以直接用BluetoothDevice对象)
|
||||
//但这么写其实更通用。
|
||||
public boolean isConnected(String macAddress) {
|
||||
if (!BluetoothAdapter.checkBluetoothAddress(macAddress)) {
|
||||
return false;
|
||||
}
|
||||
final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
BluetoothDevice device = bluetoothAdapter.getRemoteDevice(macAddress);
|
||||
|
||||
Method isConnectedMethod = null;
|
||||
boolean isConnected;
|
||||
try {
|
||||
isConnectedMethod = BluetoothDevice.class.getDeclaredMethod("isConnected", (Class[]) null);
|
||||
isConnectedMethod.setAccessible(true);
|
||||
isConnected = (boolean) isConnectedMethod.invoke(device, (Object[]) null);
|
||||
} catch (NoSuchMethodException e) {
|
||||
isConnected = false;
|
||||
} catch (IllegalAccessException e) {
|
||||
isConnected = false;
|
||||
} catch (InvocationTargetException e) {
|
||||
isConnected = false;
|
||||
}
|
||||
return isConnected;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统中已连接的蓝牙设备
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<BluetoothDevice> getConnectedDevicesV1() {
|
||||
Class<BluetoothAdapter> bluetoothAdapterClass = BluetoothAdapter.class;//得到BluetoothAdapter的Class对象
|
||||
Set<BluetoothDevice> deviceSet = new HashSet<>();
|
||||
//是否存在连接的蓝牙设备
|
||||
try {
|
||||
Method method = bluetoothAdapterClass.getDeclaredMethod("getMostRecentlyConnectedDevices", (Class[]) null);
|
||||
//打开权限
|
||||
method.setAccessible(true);
|
||||
List<BluetoothDevice> list = (List<BluetoothDevice>) method.invoke(BluetoothAdapter.getDefaultAdapter(), (Object[]) null);
|
||||
Log.e("zbh", "最近连接过的设备:");
|
||||
for (BluetoothDevice dev : list
|
||||
) {
|
||||
String Type = "";
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
switch (dev.getType()) {
|
||||
case BluetoothDevice.DEVICE_TYPE_CLASSIC:
|
||||
Type = "经典";
|
||||
break;
|
||||
case BluetoothDevice.DEVICE_TYPE_LE:
|
||||
Type = "BLE";
|
||||
break;
|
||||
case BluetoothDevice.DEVICE_TYPE_DUAL:
|
||||
Type = "双模";
|
||||
break;
|
||||
default:
|
||||
Type = "未知";
|
||||
break;
|
||||
}
|
||||
}
|
||||
String connect = "设备未连接";
|
||||
if (isConnected(dev.getAddress())) {
|
||||
deviceSet.add(dev);
|
||||
connect = "设备已连接";
|
||||
}
|
||||
Log.e("zbh", connect + ", address = " + dev.getAddress() + "(" + Type + "), name --> " + dev.getName());
|
||||
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return deviceSet;
|
||||
}
|
||||
|
||||
private BluetoothMonitorReceiver bleListenerReceiver;
|
||||
|
||||
private void registerBluetoothReceiver() {
|
||||
bleListenerReceiver = new BluetoothMonitorReceiver();
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
// 监视蓝牙关闭和打开的状态
|
||||
intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
|
||||
// 监视蓝牙设备与APP连接的状态
|
||||
intentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
|
||||
intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
|
||||
// 注册广播
|
||||
mContext.registerReceiver(this.bleListenerReceiver, intentFilter);
|
||||
}
|
||||
|
||||
class BluetoothMonitorReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
Log.e("BluetoothMonitorReceiver", "onReceive: " + action);
|
||||
if (!TextUtils.isEmpty(action)) {
|
||||
switch (action) {
|
||||
case BluetoothAdapter.ACTION_STATE_CHANGED:
|
||||
int blueState = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, 0);
|
||||
switch (blueState) {
|
||||
case BluetoothAdapter.STATE_TURNING_ON:
|
||||
tv_bt_ssid.setText("正在打开");
|
||||
cl_bt.setBackground(mContext.getDrawable(R.drawable.control_background_item));
|
||||
break;
|
||||
case BluetoothAdapter.STATE_ON:
|
||||
tv_bt_ssid.setText("已打开");
|
||||
cl_bt.setBackground(mContext.getDrawable(R.drawable.control_background_item));
|
||||
break;
|
||||
case BluetoothAdapter.STATE_TURNING_OFF:
|
||||
tv_bt_ssid.setText("正在关闭");
|
||||
cl_bt.setBackground(mContext.getDrawable(R.drawable.control_background_item));
|
||||
break;
|
||||
case BluetoothAdapter.STATE_OFF:
|
||||
tv_bt_ssid.setText("已关闭");
|
||||
cl_bt.setBackground(mContext.getDrawable(R.drawable.control_background_item_dis));
|
||||
break;
|
||||
default:
|
||||
}
|
||||
break;
|
||||
case BluetoothDevice.ACTION_ACL_CONNECTED:
|
||||
tv_bt_ssid.setText(getBluetoothDeviceName());
|
||||
cl_bt.setBackground(mContext.getDrawable(R.drawable.control_background_item));
|
||||
break;
|
||||
case BluetoothDevice.ACTION_ACL_DISCONNECTED:
|
||||
tv_bt_ssid.setText("未连接");
|
||||
cl_bt.setBackground(mContext.getDrawable(R.drawable.control_background_item_dis));
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getBattery() {
|
||||
tv_electricity.setText(getBatteryCapacity() + "%");
|
||||
if (isBatteryCharging()) {
|
||||
cl_battery.setBackground(mContext.getDrawable(R.drawable.control_background_item));
|
||||
} else {
|
||||
cl_battery.setBackground(mContext.getDrawable(R.drawable.control_background_item_dis));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 主动获取当前电池是否在充电 , 即数据线是否插在手机上
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isBatteryCharging() {
|
||||
boolean isBatteryCharging = false;
|
||||
// 主动发送包含是否正在充电状态的广播 , 该广播会持续发送
|
||||
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
|
||||
// 注册广播接受者
|
||||
Intent intent = mContext.registerReceiver(null, intentFilter);
|
||||
// 获取充电状态
|
||||
int batteryChargeState = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
|
||||
// 判定是否是 AC 交流电充电
|
||||
boolean isAc = batteryChargeState == BatteryManager.BATTERY_PLUGGED_AC;
|
||||
// 判断是否是 USB 充电
|
||||
boolean isUsb = batteryChargeState == BatteryManager.BATTERY_PLUGGED_USB;
|
||||
// 判断是否是 无线充电
|
||||
boolean isWireless = batteryChargeState == BatteryManager.BATTERY_PLUGGED_WIRELESS;
|
||||
// 如何上述任意一种为 true , 说明当前正在充电
|
||||
isBatteryCharging = isAc || isUsb || isWireless;
|
||||
return isBatteryCharging;
|
||||
}
|
||||
|
||||
|
||||
public int getBatteryCapacity() {
|
||||
try {
|
||||
BatteryManager batteryManager = (BatteryManager) mContext.getSystemService(Context.BATTERY_SERVICE);
|
||||
return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
|
||||
} catch (Exception e) {
|
||||
Log.e("getBattery", "getBattery" + e.getMessage());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private BatteryReceiver mBatteryReceiver;
|
||||
|
||||
private void registerBatteryReceiver() {
|
||||
if (mBatteryReceiver == null) {
|
||||
mBatteryReceiver = new BatteryReceiver();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(Intent.ACTION_POWER_CONNECTED);
|
||||
filter.addAction(Intent.ACTION_POWER_DISCONNECTED);
|
||||
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||
filter.addAction(Intent.ACTION_BATTERY_LEVEL_CHANGED);
|
||||
filter.addAction(Intent.ACTION_BATTERY_LOW);
|
||||
filter.addAction(Intent.ACTION_BATTERY_OKAY);
|
||||
mContext.registerReceiver(mBatteryReceiver, filter);
|
||||
}
|
||||
}
|
||||
|
||||
class BatteryReceiver extends BroadcastReceiver {
|
||||
public static final String TAG = "BatteryReceiver";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
// 获取广播事件
|
||||
String action = intent.getAction();
|
||||
if (TextUtils.isEmpty(action)) return;
|
||||
// Log.e(TAG, "onReceive: " + action);
|
||||
switch (action) {
|
||||
case Intent.ACTION_POWER_CONNECTED:
|
||||
cl_battery.setBackground(mContext.getDrawable(R.drawable.control_background_item));
|
||||
break;
|
||||
case Intent.ACTION_POWER_DISCONNECTED:
|
||||
cl_battery.setBackground(mContext.getDrawable(R.drawable.control_background_item_dis));
|
||||
break;
|
||||
case Intent.ACTION_BATTERY_LEVEL_CHANGED:
|
||||
tv_electricity.setText(getBatteryCapacity() + "%");
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean flashing = false;
|
||||
private CameraManager cameraManager;
|
||||
|
||||
BroadcastReceiver mTimeUpdateReceiver;
|
||||
|
||||
class TimeUpdateReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent == null) return;
|
||||
String action = intent.getAction();
|
||||
if (action == null || action.isEmpty()) return;
|
||||
|
||||
if (action.equals(Intent.ACTION_TIME_TICK)) {
|
||||
//系统每1分钟发送一次广播
|
||||
updateTimeUi();
|
||||
} else if (action.equals(Intent.ACTION_TIME_CHANGED)) {
|
||||
//系统手动更改时间发送广播
|
||||
updateTimeUi();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTimeUi() {
|
||||
long time = System.currentTimeMillis();
|
||||
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm");
|
||||
String timeText = timeFormat.format(time);
|
||||
tv_flashlight.setText(timeText);
|
||||
SimpleDateFormat format = new SimpleDateFormat("MM月dd日");
|
||||
String dataText = format.format(time);
|
||||
tv_flashlight_switch.setText(dataText);
|
||||
}
|
||||
|
||||
|
||||
private void getFlashlight() {
|
||||
if (mTimeUpdateReceiver == null) {
|
||||
mTimeUpdateReceiver = new TimeUpdateReceiver();
|
||||
}
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(Intent.ACTION_TIME_TICK);
|
||||
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
||||
mContext.registerReceiver(mTimeUpdateReceiver, filter);
|
||||
updateTimeUi();
|
||||
// if (isFlashlightAvailable()) {
|
||||
// tv_flashlight_switch.setText("关");
|
||||
// cl_flashlight.setBackground(mContext.getDrawable(R.drawable.control_background_item_dis));
|
||||
// } else {
|
||||
// tv_flashlight_switch.setText("不可用");
|
||||
// cl_flashlight.setBackground(mContext.getDrawable(R.drawable.control_background_item_dis));
|
||||
// return;
|
||||
// }
|
||||
//// if (isFlashlightEnabled()) {
|
||||
//// tv_flashlight_switch.setText("开");
|
||||
//// cl_flashlight.setBackground(getDrawable(R.drawable.control_background_item));
|
||||
//// } else {
|
||||
//// tv_flashlight_switch.setText("关");
|
||||
//// cl_flashlight.setBackground(getDrawable(R.drawable.control_background_item_dis));
|
||||
//// }
|
||||
//
|
||||
// cameraManager = (CameraManager) mContext.getSystemService(Context.CAMERA_SERVICE);
|
||||
//
|
||||
// cl_flashlight.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// if (flashing) {
|
||||
// try {
|
||||
// String CameraId = cameraManager.getCameraIdList()[0];
|
||||
// cameraManager.setTorchMode(CameraId, false);
|
||||
// } catch (CameraAccessException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// flashing = false;
|
||||
// tv_flashlight_switch.setText("关");
|
||||
// cl_flashlight.setBackground(mContext.getDrawable(R.drawable.control_background_item_dis));
|
||||
// } else {
|
||||
// try {
|
||||
// String CameraId = cameraManager.getCameraIdList()[0];
|
||||
// cameraManager.setTorchMode(CameraId, true);
|
||||
// } catch (CameraAccessException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// tv_flashlight_switch.setText("开");
|
||||
// cl_flashlight.setBackground(mContext.getDrawable(R.drawable.control_background_item));
|
||||
// flashing = true;
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
private boolean isFlashlightAvailable() {
|
||||
return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
|
||||
}
|
||||
|
||||
private static String getCameraId(Context context) throws CameraAccessException {
|
||||
final CameraManager cameraManager = context.getSystemService(CameraManager.class);
|
||||
final String[] ids = cameraManager.getCameraIdList();
|
||||
for (String id : ids) {
|
||||
CameraCharacteristics c = cameraManager.getCameraCharacteristics(id);
|
||||
Boolean flashAvailable = c.get(CameraCharacteristics.FLASH_INFO_AVAILABLE);
|
||||
Integer lensFacing = c.get(CameraCharacteristics.LENS_FACING);
|
||||
if (flashAvailable != null && flashAvailable
|
||||
&& lensFacing != null && lensFacing == CameraCharacteristics.LENS_FACING_BACK) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isFlashlightEnabled() {
|
||||
return Settings.Secure.getInt(mCRv, Settings.Secure.FLASHLIGHT_ENABLED, 0) == 1;
|
||||
}
|
||||
|
||||
private void getFontSize() {
|
||||
float fontScale = Settings.System.getFloat(mCRv, Settings.System.FONT_SCALE, 0.0f);
|
||||
Log.e(TAG, "getFontSize: fontScale = " + fontScale);
|
||||
List<String> mEntries = Arrays.asList(getResources().getStringArray(R.array.entries_font_size));
|
||||
String[] strEntryValues = getResources().getStringArray(R.array.entryvalues_font_size);
|
||||
float[] mValues = new float[strEntryValues.length];
|
||||
for (int i = 0; i < strEntryValues.length; ++i) {
|
||||
mValues[i] = Float.parseFloat(strEntryValues[i]);
|
||||
}
|
||||
seekBar.setMax(mEntries.size() - 1);
|
||||
String font_size;
|
||||
int index = Arrays.binarySearch(mValues, fontScale);
|
||||
Log.e(TAG, "getFontSize: index: " + index);
|
||||
if (index >= 0) {
|
||||
font_size = mEntries.get(index);
|
||||
} else {
|
||||
font_size = "默认";
|
||||
}
|
||||
// tv_font_size.setText(font_size);
|
||||
seekBar.setProgress(index);
|
||||
seekBar.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
|
||||
Log.e(TAG, "getFontSize: onProgressChanged: " + i);
|
||||
Log.e(TAG, "getFontSize: FONT_SCALE = " + Float.parseFloat(strEntryValues[i]));
|
||||
Settings.System.putFloat(mCRv, Settings.System.FONT_SCALE, Float.parseFloat(strEntryValues[i]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 1999);
|
||||
}
|
||||
|
||||
private void getLocation() {
|
||||
String addr = MMKV.defaultMMKV().decodeString(CommonConfig.MAP_ADDRESS_KEY);
|
||||
if (TextUtils.isEmpty(addr)) {
|
||||
tv_location.setText("未知");
|
||||
} else {
|
||||
tv_location.setText(addr);
|
||||
}
|
||||
cl_location.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
RemoteManager.getInstance().getLocation();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getBrightness() {
|
||||
seekbar_brightness.setMax(255);
|
||||
setBrightness();
|
||||
seekbar_brightness.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
|
||||
Log.e(TAG, "onProgressChanged: i = " + i);
|
||||
Settings.System.putInt(mCRv, Settings.System.SCREEN_BRIGHTNESS, i);
|
||||
int gamma = BrightnessUtils.convertLinearToGamma(i, 0, 255);
|
||||
Log.e(TAG, "onProgressChanged: gamma = " + gamma);
|
||||
int linear = BrightnessUtils.convertGammaToLinear(gamma, 0, 255);
|
||||
Log.e(TAG, "onProgressChanged: linear = " + linear);
|
||||
long percentage = Math.round((((double) gamma / 65535) * 100f));
|
||||
Log.e(TAG, "onProgressChanged: percentage = " + percentage);
|
||||
// tv_brightness.setText(percentage + "%");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setBrightness() {
|
||||
//亮度
|
||||
int brightness = Settings.System.getInt(mCRv, Settings.System.SCREEN_BRIGHTNESS, 0);
|
||||
seekbar_brightness.setProgress(brightness);
|
||||
Log.e(TAG, "getBrightness: brightness = " + brightness);
|
||||
int gamma = BrightnessUtils.convertLinearToGamma(brightness, 0, 255);
|
||||
Log.e(TAG, "getBrightness: gamma = " + gamma);
|
||||
long percentage = Math.round((((double) gamma / 65535) * 100f));
|
||||
// tv_brightness.setText(percentage + "%");
|
||||
Log.e(TAG, "getBrightness: percentage = " + percentage);
|
||||
}
|
||||
|
||||
private AudioManager mAudioManager;
|
||||
|
||||
private void getSound() {
|
||||
mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
||||
//最大音量
|
||||
int maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
||||
seekbar_sound.setMax(maxVolume);
|
||||
Log.e(TAG, "getSound: maxVolume = " + maxVolume);
|
||||
//音量
|
||||
int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
|
||||
seekbar_sound.setProgress(streamVolume);
|
||||
Log.e(TAG, "getSound: streamVolume = " + streamVolume);
|
||||
int currentVolume = (int) (((double) streamVolume / (double) maxVolume) * 100f);
|
||||
Log.e(TAG, "getSound: currentVolume = " + currentVolume);
|
||||
tv_sound.setText(currentVolume + "%");
|
||||
seekbar_sound.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
|
||||
int volume = (int) (((double) i / (double) maxVolume) * 100f);
|
||||
tv_sound.setText(volume + "%");
|
||||
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, i, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mWifiReceiver != null) mContext.unregisterReceiver(mWifiReceiver);
|
||||
if (mTimeUpdateReceiver != null) mContext.unregisterReceiver(mTimeUpdateReceiver);
|
||||
}
|
||||
}
|
||||
@@ -1,415 +0,0 @@
|
||||
package com.uiui.aios.fragment;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.shehuan.niv.NiceImageView;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.base.BaseFragment;
|
||||
import com.uiui.aios.bean.ActivityBean;
|
||||
import com.uiui.aios.bean.ArticleInfo;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.DemandBean;
|
||||
import com.uiui.aios.bean.GoodsInfo;
|
||||
import com.uiui.aios.network.NetInterfaceManager;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link SecondFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class SecondFragment extends BaseFragment implements NetworkUtils.OnNetworkStatusChangedListener {
|
||||
private static final String TAG = SecondFragment.class.getSimpleName();
|
||||
|
||||
@BindView(R.id.iv_img)
|
||||
ImageView iv_img;
|
||||
@BindView(R.id.tv_goods_name)
|
||||
TextView tv_goods_name;
|
||||
@BindView(R.id.tv_goods_desc)
|
||||
TextView tv_goods_desc;
|
||||
@BindView(R.id.tv_buying_price)
|
||||
TextView tv_buying_price;
|
||||
@BindView(R.id.progressBar)
|
||||
ProgressBar progressBar;
|
||||
@BindView(R.id.tv_snapup)
|
||||
TextView tv_snapup;
|
||||
|
||||
@BindView(R.id.iv_aimg)
|
||||
ImageView iv_aimg;
|
||||
@BindView(R.id.tv_title)
|
||||
TextView tv_title;
|
||||
@BindView(R.id.tv_content)
|
||||
TextView tv_content;
|
||||
|
||||
@BindView(R.id.iv_avatar_a)
|
||||
ImageView iv_avatar_a;
|
||||
@BindView(R.id.tv_title_a)
|
||||
TextView tv_title_a;
|
||||
@BindView(R.id.tc_joined_num_a)
|
||||
TextView tc_joined_num_a;
|
||||
@BindView(R.id.tv_time_a)
|
||||
TextView tv_time_a;
|
||||
@BindView(R.id.tv_address_a)
|
||||
TextView tv_address_a;
|
||||
|
||||
@BindView(R.id.iv_avatar_d)
|
||||
ImageView iv_avatar_d;
|
||||
@BindView(R.id.tv_title_d)
|
||||
TextView tv_title_d;
|
||||
@BindView(R.id.tc_joined_num_d)
|
||||
TextView tc_joined_num_d;
|
||||
@BindView(R.id.tv_time_d)
|
||||
TextView tv_time_d;
|
||||
@BindView(R.id.tv_address_d)
|
||||
TextView tv_address_d;
|
||||
|
||||
@BindView(R.id.iv1)
|
||||
ImageView iv1;
|
||||
@BindView(R.id.iv2)
|
||||
ImageView iv2;
|
||||
@BindView(R.id.iv3)
|
||||
ImageView iv3;
|
||||
@BindView(R.id.iv4)
|
||||
ImageView iv4;
|
||||
|
||||
@BindView(R.id.cl_activity)
|
||||
ConstraintLayout cl_activity;
|
||||
|
||||
@BindView(R.id.cl_demand)
|
||||
ConstraintLayout cl_demand;
|
||||
@BindView(R.id.cl1)
|
||||
ConstraintLayout cl1;
|
||||
@BindView(R.id.cl2)
|
||||
ConstraintLayout cl2;
|
||||
@BindView(R.id.cl3)
|
||||
ConstraintLayout cl3;
|
||||
@BindView(R.id.cl4)
|
||||
ConstraintLayout cl4;
|
||||
|
||||
@BindView(R.id.nv_pic)
|
||||
NiceImageView nv_pic;
|
||||
@BindView(R.id.tv_like)
|
||||
TextView tv_like;
|
||||
@BindView(R.id.tv_comment)
|
||||
TextView tv_comment;
|
||||
|
||||
private View rootView;
|
||||
private Context mContext;
|
||||
private ContentResolver mCRv;
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
||||
initData();
|
||||
}
|
||||
|
||||
public SecondFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment SecondFragment.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static SecondFragment newInstance(String param1, String param2) {
|
||||
SecondFragment fragment = new SecondFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
rootView = inflater.inflate(R.layout.fragment_second, container, false);
|
||||
mContext = rootView.getContext();
|
||||
mCRv = mContext.getContentResolver();
|
||||
ButterKnife.bind(this, rootView);
|
||||
initView();
|
||||
initData();
|
||||
return rootView;
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
getGoods();
|
||||
getArticle();
|
||||
getActivityList();
|
||||
getDemandList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
NetworkUtils.unregisterNetworkStatusChangedListener(this);
|
||||
}
|
||||
|
||||
private void getDemandList() {
|
||||
NetInterfaceManager.getInstance().getDemandList(true, lifecycleSubject, new NetInterfaceManager.DemandListCallback() {
|
||||
@Override
|
||||
public void setDemandList(List<DemandBean> demandBeans) {
|
||||
cl4.setVisibility(View.VISIBLE);
|
||||
iv4.setVisibility(View.GONE);
|
||||
DemandBean demandBean = demandBeans.get(0);
|
||||
setDemand(demandBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noData() {
|
||||
cl4.setVisibility(View.GONE);
|
||||
iv4.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setDemand(DemandBean demandBean) {
|
||||
Glide.with(iv_avatar_d).load(demandBean.getAvatar()).error(getResources().getDrawable(R.drawable.default_head)).into(iv_avatar_d);
|
||||
tv_title_d.setText(demandBean.getTitle());
|
||||
// tv_price.setText(String.valueOf(demandBean.getPrice()));
|
||||
tc_joined_num_d.setText(demandBean.getLike_count() + "人参加");
|
||||
tv_time_d.setText(getTime(demandBean.getDemand_time()));
|
||||
tv_address_d.setText(demandBean.getAddress());
|
||||
}
|
||||
|
||||
private void getActivityList() {
|
||||
NetInterfaceManager.getInstance().getActivityList(true, lifecycleSubject, new NetInterfaceManager.ActivitiesListCallback() {
|
||||
@Override
|
||||
public void setActivitiesList(List<ActivityBean> activityBeans) {
|
||||
cl3.setVisibility(View.VISIBLE);
|
||||
iv3.setVisibility(View.GONE);
|
||||
ActivityBean activityBean = activityBeans.get(0);
|
||||
setActivity(activityBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noData() {
|
||||
cl3.setVisibility(View.GONE);
|
||||
iv3.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setActivity(ActivityBean activity) {
|
||||
Glide.with(iv_avatar_a).load(activity.getAvatar()).error(getResources().getDrawable(R.drawable.default_head)).into(iv_avatar_a);
|
||||
tv_title_a.setText(activity.getName());
|
||||
tc_joined_num_a.setText(activity.getJoin_num() + "人参加");
|
||||
tv_time_a.setText(getTime(activity.getAdd_time()));
|
||||
tv_address_a.setText(activity.getLocation());
|
||||
Glide.with(nv_pic).load(activity.getFile()).centerCrop().into(nv_pic);
|
||||
tv_like.setText(activity.getLike_count() + "");
|
||||
tv_comment.setText(activity.getComment_count() + "");
|
||||
}
|
||||
|
||||
private String getTime(long second) {
|
||||
long ms = second * 1000L;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("MM月dd日");
|
||||
Date date = new Date(ms);
|
||||
String time = sdf.format(date);
|
||||
Log.e(TAG, "getTime: " + time);
|
||||
return time;
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
cl_activity.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openApp(0);
|
||||
}
|
||||
});
|
||||
cl_demand.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openApp(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void openApp(int position) {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
/*知道要跳转应用的包命与目标Activity*/
|
||||
ComponentName componentName = new ComponentName("com.uiui.city", "com.uiui.city.activity.MainActivity");
|
||||
intent.putExtra("position", position);
|
||||
intent.setComponent(componentName);
|
||||
intent.putExtra("", "");//这里Intent传值
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "openApp: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void getGoods() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getGoodsListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, FragmentEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<GoodsInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getGoods", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<GoodsInfo>> listBaseResponse) {
|
||||
Log.e("getGoods", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
cl1.setVisibility(View.VISIBLE);
|
||||
iv1.setVisibility(View.GONE);
|
||||
List<GoodsInfo> goodsInfoList = listBaseResponse.data;
|
||||
if (goodsInfoList != null && goodsInfoList.size() != 0) {
|
||||
GoodsInfo goodsInfo = goodsInfoList.get(0);
|
||||
setGoodsInfo(goodsInfo);
|
||||
}
|
||||
} else {
|
||||
cl1.setVisibility(View.GONE);
|
||||
iv1.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getGoods", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getGoods", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setGoodsInfo(GoodsInfo goodsInfo) {
|
||||
Glide.with(iv_img).load(goodsInfo.getImg()).into(iv_img);
|
||||
tv_goods_name.setText(goodsInfo.getGoods_name());
|
||||
tv_goods_desc.setText(goodsInfo.getGoods_desc());
|
||||
tv_buying_price.setText(String.valueOf(goodsInfo.getBuying_price()));
|
||||
}
|
||||
|
||||
private void getArticle() {
|
||||
NetInterfaceManager.getInstance().getArticleListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, FragmentEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<ArticleInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getArticle", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<ArticleInfo>> listBaseResponse) {
|
||||
Log.e("getArticle", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
cl2.setVisibility(View.VISIBLE);
|
||||
iv2.setVisibility(View.GONE);
|
||||
List<ArticleInfo> articleInfos = listBaseResponse.data;
|
||||
if (articleInfos != null && articleInfos.size() != 0) {
|
||||
ArticleInfo articleInfo = articleInfos.get(0);
|
||||
setArticleInfo(articleInfo);
|
||||
}
|
||||
} else {
|
||||
cl2.setVisibility(View.GONE);
|
||||
iv2.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getArticle", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getArticle", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setArticleInfo(ArticleInfo articleInfo) {
|
||||
Glide.with(iv_aimg).load(articleInfo.getImg()).into(iv_aimg);
|
||||
tv_title.setText(articleInfo.getTitle());
|
||||
tv_content.setText(articleInfo.getContent());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,53 +0,0 @@
|
||||
package com.uiui.aios.network;
|
||||
|
||||
public class URLAddress {
|
||||
public static final String ROOT_URL = "https://led.zuoyepad.com/android/";
|
||||
|
||||
/*获取设备是否激活*/
|
||||
public static final String GET_SN_IS_ACTIVATION = "sn/getSnIsActivation";
|
||||
/*设备信息接口*/
|
||||
public static final String SNINFO = "sn/getSnInfo";
|
||||
/*获取用户头像和信息*/
|
||||
public static final String GET_USER_AVATAR_INFO = "sn/getUserAvatarInfo";
|
||||
/*获取闹钟*/
|
||||
public static final String GET_ALARM_CLOCK = "getAlarmClock";
|
||||
/*应用使用记录*/
|
||||
public static final String APP_USAGE_RECORD = "appUsageRecord";
|
||||
/*正在运行的应用*/
|
||||
public static final String RUN_NEW_APP = "app/runNewApp";
|
||||
/*上传截图*/
|
||||
public static final String SEND_SCREENSHOT = "sn/uploadScreenshot";
|
||||
/*获取系统设置*/
|
||||
public final static String GET_SETTINGS = "control/getSetting";
|
||||
/*sos记录*/
|
||||
public static final String SOS_RECORD = "sosRecord";
|
||||
/*爱心提醒通知成功*/
|
||||
public static final String UPDATE_ALARM_CLOCK = "updateAlarmClock";
|
||||
/*更新桌面布局*/
|
||||
public static final String UPDATE_DESKTOP_LAYOUT = "updateDesktopLayout";
|
||||
/*获取桌面布局*/
|
||||
public static final String GET_DESKTOP_LAYOUT = "getDesktopLayout";
|
||||
/*获取抢购列表*/
|
||||
public static final String GET_GOODS_LIST = "getGoodsList";
|
||||
/*获取资讯列表*/
|
||||
public static final String GET_ARTICLE_LIST = "getArticleList";
|
||||
/*获取抢购详情*/
|
||||
public static final String GET_GOODS_DETAILS = "getGoodsDetails";
|
||||
/*获取资讯详情*/
|
||||
public static final String GET_ARTICLE_DETAILS = "getArticleDetails";
|
||||
/*同城活动列表*/
|
||||
public static final String GET_ACTIVITY_LIST = "activityList";
|
||||
/*同城需求列表*/
|
||||
public static final String GET_DEMAND_LIST = "demandList";
|
||||
/*获取健康吗*/
|
||||
public static final String GET_HEALTH_CODE = "getHealthCode";
|
||||
/*获取联系人*/
|
||||
public static final String GET_MAIL_LIST = "Control/getMailList";
|
||||
/*获取负二屏开关*/
|
||||
public static final String GET_ADMIN_SN_SETTING = "getAdminSnSetting";
|
||||
/*更新app隐藏或者显示状态*/
|
||||
public static final String APP_ICON_UPDATE = "Control/appIconUpdate";
|
||||
|
||||
|
||||
public static final String GET_USER_ID = "getUserId";
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.ActivityBean;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface ActivityListApi {
|
||||
@GET(URLAddress.GET_ACTIVITY_LIST)
|
||||
Observable<BaseResponse<List<ActivityBean>>> getActivityList(
|
||||
@Query("sn") String sn,
|
||||
@Query("startSize") int startSize,
|
||||
@Query("pageSize") int pageSize,
|
||||
@Query("user_id") int user_id
|
||||
);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.AlarmClockData;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface AlarmClockApi {
|
||||
@GET(URLAddress.GET_ALARM_CLOCK)
|
||||
Observable<BaseResponse<List<AlarmClockData>>> getAlarmClock(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface AppUsageRecordApi {
|
||||
@FormUrlEncoded
|
||||
@POST(URLAddress.APP_USAGE_RECORD)
|
||||
Observable<BaseResponse> sendappUsageRecord(
|
||||
@Field("sn") String sn,
|
||||
@Field("app_name") String app_name,
|
||||
@Field("app_package") String app_package,
|
||||
@Field("open_time") long open_time,
|
||||
@Field("close_time") long close_time
|
||||
);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.ArticleDetails;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface ArticleDetailsApi {
|
||||
@GET(URLAddress.GET_ARTICLE_DETAILS)
|
||||
Observable<BaseResponse<ArticleDetails>> getArticleDetails(
|
||||
@Query("id") int id
|
||||
);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.ArticleInfo;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface ArticleListApi {
|
||||
@GET(URLAddress.GET_ARTICLE_LIST)
|
||||
Observable<BaseResponse<List<ArticleInfo>>> getArticleList(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.DemandBean;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface DemandListApi {
|
||||
@GET(URLAddress.GET_DEMAND_LIST)
|
||||
Observable<BaseResponse<List<DemandBean>>> getDemandList(
|
||||
@Query("sn") String sn,
|
||||
@Query("startSize") int startSize,
|
||||
@Query("pageSize") int pageSize,
|
||||
@Query("user_id") int user_id
|
||||
);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetAdminSnSettingApi {
|
||||
@GET(URLAddress.GET_ADMIN_SN_SETTING)
|
||||
Observable<BaseResponse> getAdminSnSetting(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.NetDesktopIcon;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetDesktopApi {
|
||||
@GET(URLAddress.GET_DESKTOP_LAYOUT)
|
||||
Observable<BaseResponse<List<NetDesktopIcon>>> getDesktopLayout(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.Contact;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetMailList {
|
||||
@GET(URLAddress.GET_MAIL_LIST)
|
||||
Observable<BaseResponse<List<Contact>>> getContact(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.UserId;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetUserIDApi {
|
||||
@GET(URLAddress.GET_USER_ID)
|
||||
Observable<BaseResponse<UserId>> getUserID(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.GoodsDetails;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GoodsDetailsApi {
|
||||
@GET(URLAddress.GET_GOODS_DETAILS)
|
||||
Observable<BaseResponse<GoodsDetails>> getGoodsDetails(
|
||||
@Query("id") int id
|
||||
);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.GoodsInfo;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GoodsListApi {
|
||||
@GET(URLAddress.GET_GOODS_LIST)
|
||||
Observable<BaseResponse<List<GoodsInfo>>> getGoodsList(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.HealthCode;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface HealthCodeApi {
|
||||
@GET(URLAddress.GET_HEALTH_CODE)
|
||||
Observable<BaseResponse<List<HealthCode>>> getArticleDetails(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface RunNewApp {
|
||||
@FormUrlEncoded
|
||||
@POST(URLAddress.RUN_NEW_APP)
|
||||
Observable<BaseResponse> sendRunningInfo(
|
||||
@Field("sn") String sn,
|
||||
@Field("app") String app
|
||||
);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.SnInfo;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface SNInfoApi {
|
||||
@GET(URLAddress.SNINFO)
|
||||
Observable<BaseResponse<SnInfo>> getsninfo(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface SOSRecordApi {
|
||||
@FormUrlEncoded
|
||||
@POST(URLAddress.SOS_RECORD)
|
||||
Observable<BaseResponse> sendSOSRecord(
|
||||
@Field("sn") String sn,
|
||||
@Field("longitude") String longitude,
|
||||
@Field("latitude") String latitude,
|
||||
@Field("address") String address
|
||||
);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import okhttp3.MultipartBody;
|
||||
import retrofit2.http.Multipart;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Part;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface SendScreenshotApi {
|
||||
@Multipart
|
||||
@POST(URLAddress.SEND_SCREENSHOT)
|
||||
Observable<BaseResponse> sendScreenshot(
|
||||
@Query("sn") String sn,
|
||||
@Part MultipartBody.Part file
|
||||
);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.SystemSettings;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface Setting {
|
||||
@GET(URLAddress.GET_SETTINGS)
|
||||
Observable<BaseResponse<SystemSettings>> getSetting(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface SnIsActivationApi {
|
||||
@GET(URLAddress.GET_SN_IS_ACTIVATION)
|
||||
Observable<BaseResponse> getSnIsActivation(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface UpdateAlarmClockApi {
|
||||
@FormUrlEncoded
|
||||
@POST(URLAddress.UPDATE_ALARM_CLOCK)
|
||||
Observable<BaseResponse> updateAlarm(
|
||||
@Field("sn") String sn,
|
||||
@Field("id") int id
|
||||
);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface UpdateAppIconApi {
|
||||
@FormUrlEncoded
|
||||
@POST(URLAddress.APP_ICON_UPDATE)
|
||||
Observable<BaseResponse> appIconUpdate(
|
||||
@Field("sn") String sn,
|
||||
@Field("app_package") String app_package,
|
||||
@Field("type") int type,//类型 1显示 0隐藏
|
||||
@Field("app_name") String app_name
|
||||
);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface UpdateDesktopApi {
|
||||
@FormUrlEncoded
|
||||
@POST(URLAddress.UPDATE_DESKTOP_LAYOUT)
|
||||
Observable<BaseResponse> updateLayout(
|
||||
@Field("sn") String sn,
|
||||
@Field("app") String app
|
||||
);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.uiui.aios.network.api;
|
||||
|
||||
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.UserAvatarInfo;
|
||||
import com.uiui.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface UserInfoControl {
|
||||
@FormUrlEncoded
|
||||
@POST(URLAddress.GET_USER_AVATAR_INFO)
|
||||
Observable<BaseResponse<UserAvatarInfo>> getUserAvatarInfo(
|
||||
@Field("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.uiui.aios.service.main;
|
||||
|
||||
import com.uiui.aios.base.BasePresenter;
|
||||
import com.uiui.aios.base.BaseView;
|
||||
import com.uiui.aios.bean.AlarmClockData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MainSContact {
|
||||
public interface Presenter extends BasePresenter<MainSView> {
|
||||
//设置所有信息
|
||||
void getAlarmClock();
|
||||
}
|
||||
|
||||
public interface MainSView extends BaseView {
|
||||
//获取所有信息
|
||||
void setAlarmClock(List<AlarmClockData> dataList);
|
||||
}
|
||||
}
|
||||
@@ -1,433 +0,0 @@
|
||||
package com.uiui.aios.service.main;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.IBinder;
|
||||
import android.os.PowerManager;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.Log;
|
||||
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.task.DownloadTask;
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.uiui.aios.BuildConfig;
|
||||
import com.uiui.aios.activity.NoticeActivity;
|
||||
import com.uiui.aios.alarm.AlarmUtils;
|
||||
import com.uiui.aios.base.BaseService;
|
||||
import com.uiui.aios.bean.AlarmClockData;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.network.NetInterfaceManager;
|
||||
import com.uiui.aios.utils.ApkUtils;
|
||||
import com.uiui.aios.utils.CmdUtil;
|
||||
import com.uiui.aios.utils.ForegroundAppUtil;
|
||||
import com.uiui.aios.utils.AppUsedTimeUtils;
|
||||
import com.uiui.aios.utils.ToastUtil;
|
||||
import com.uiui.aios.utils.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.ObservableEmitter;
|
||||
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
|
||||
import io.reactivex.rxjava3.core.ObservableSource;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.functions.Function;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
public class MainService extends BaseService implements MainSContact.MainSView, NetworkUtils.OnNetworkStatusChangedListener {
|
||||
private static final String TAG = MainService.class.getSimpleName();
|
||||
public MainSPresenter mPresenter;
|
||||
|
||||
public MainService() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
||||
if (isScreenOn()) {
|
||||
mPresenter.getAlarmClock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
Log.e(TAG, "onBind: ");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Log.e(TAG, "onCreate: ");
|
||||
// ApkUtils.UninstallAPP(this, "com.joytv.live");
|
||||
// ApkUtils.UninstallAPP(this, "com.tencent.android.qqdownloader");
|
||||
|
||||
Aria.init(this);
|
||||
Aria.download(this).register();
|
||||
mPresenter = new MainSPresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||
mPresenter.getAlarmClock();
|
||||
registerAlarmReceiver();
|
||||
registerTimeReceiver();
|
||||
registerLockScreenReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Log.e(TAG, "onStartCommand: ");
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
mPresenter.detachView();
|
||||
NetworkUtils.unregisterNetworkStatusChangedListener(this);
|
||||
if (alarmReceiver != null) {
|
||||
unregisterReceiver(alarmReceiver);
|
||||
}
|
||||
if (mTimeChangedReceiver != null) {
|
||||
unregisterReceiver(mTimeChangedReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlarmClock(List<AlarmClockData> dataList) {
|
||||
|
||||
}
|
||||
|
||||
public boolean isScreenOn() {
|
||||
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
//true为打开,false为关闭
|
||||
return powerManager.isInteractive();
|
||||
}
|
||||
|
||||
public static final String ALARMWAKEUP = "ALARM_WAKEUP";
|
||||
|
||||
private void registerAlarmReceiver() {
|
||||
if (alarmReceiver == null) {
|
||||
alarmReceiver = new AlarmReceiver();
|
||||
}
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(ALARMWAKEUP);
|
||||
registerReceiver(alarmReceiver, filter);
|
||||
}
|
||||
|
||||
private AlarmReceiver alarmReceiver = new AlarmReceiver();
|
||||
|
||||
private class AlarmReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.e(TAG, "onReceive: " + System.currentTimeMillis());
|
||||
String action = intent.getAction();
|
||||
if (TextUtils.isEmpty(action)) return;
|
||||
Log.e(TAG, "onReceive: " + action);
|
||||
String title = intent.getStringExtra("title");
|
||||
int code = intent.getIntExtra("id", -1);
|
||||
Log.e(TAG, "onReceive: title = " + title);
|
||||
setNextAlarm(code);
|
||||
if (ALARMWAKEUP.equals(action)) {
|
||||
Intent noticeIntent = new Intent();
|
||||
noticeIntent.putExtra("id", code);
|
||||
noticeIntent.setClass(MainService.this, NoticeActivity.class);
|
||||
noticeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(noticeIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setNextAlarm(int code) {
|
||||
HashMap<Integer, AlarmClockData> clockDataHashMap = AlarmUtils.getInstance().getOldData();
|
||||
AlarmClockData alarmClockData = clockDataHashMap.get(code);
|
||||
Log.e(TAG, "setNextAlarm: " + alarmClockData);
|
||||
if (alarmClockData != null) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int day_of_week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
Log.e(TAG, "setNextAlarm: " + day_of_week);
|
||||
switch (alarmClockData.getType()) {
|
||||
case AlarmUtils.ONCE:
|
||||
break;
|
||||
case AlarmUtils.LOOP:
|
||||
AlarmUtils.getInstance().setDayLoopAlarm(MainService.ALARMWAKEUP, alarmClockData.getTitle(), alarmClockData.getId(), alarmClockData.getTime());
|
||||
break;
|
||||
case AlarmUtils.WORKING_DAY:
|
||||
if (day_of_week < 5 || day_of_week == 7) {
|
||||
AlarmUtils.getInstance().setWorkDayAlarm(MainService.ALARMWAKEUP, alarmClockData.getTitle(), alarmClockData.getId(), alarmClockData.getTime());
|
||||
}
|
||||
break;
|
||||
case AlarmUtils.OFF_DAY:
|
||||
AlarmUtils.getInstance().setOffDayAlarm(MainService.ALARMWAKEUP, alarmClockData.getTitle(), alarmClockData.getId(), alarmClockData.getTime());
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//监听时间和日期变化
|
||||
public void registerTimeReceiver() {
|
||||
mTimeChangedReceiver = new TimeChangedReceiver();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(Intent.ACTION_DATE_CHANGED);
|
||||
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
||||
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
||||
filter.addAction(Intent.ACTION_TIME_TICK);
|
||||
registerReceiver(mTimeChangedReceiver, filter);
|
||||
}
|
||||
|
||||
private TimeChangedReceiver mTimeChangedReceiver;
|
||||
|
||||
private class TimeChangedReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (Intent.ACTION_DATE_CHANGED.equals(intent.getAction())) {
|
||||
Log.e(TAG, "TimeChangedReceiver:" + "data changed");
|
||||
} else if (Intent.ACTION_TIME_CHANGED.equals(intent.getAction())) {
|
||||
Log.e(TAG, "TimeChangedReceiver:" + "time changed");
|
||||
} else if (Intent.ACTION_TIMEZONE_CHANGED.equals(intent.getAction())) {
|
||||
Log.e(TAG, "TimeChangedReceiver:" + "timezone changed");
|
||||
} else if (Intent.ACTION_TIME_TICK.equals(intent.getAction())) {
|
||||
Log.e(TAG, "TimeChangedReceiver:" + "time tick");
|
||||
// isScreenshot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final static long ONE_HOURS_TIME = 60 * 60 * 1000;
|
||||
private final static long TEN_MINUTES_TIME = 60 * 10 * 1000;
|
||||
|
||||
private void isScreenshot() {
|
||||
//1、检测应用使用情况,如果设备长时间运行一个应用,超过1小时,启动截屏一次。
|
||||
//2、检测设备在非正常时间使用时,使用第三方应用,在运行10分钟后,启动截屏功能一次
|
||||
//屏幕未点亮时不用截图
|
||||
// TODO: 2021/12/20 计算当前app打开时间
|
||||
String topPackageName = ForegroundAppUtil.getForegroundPackageName(MainService.this);
|
||||
Log.e(TAG, "isScreenshot: " + topPackageName);
|
||||
String pkg = AppUsedTimeUtils.getInstance().getAppPackageName();
|
||||
if (TextUtils.isEmpty(pkg) || BuildConfig.APPLICATION_ID.equals(pkg)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
//true为打开,false为关闭
|
||||
boolean screenOn = powerManager.isInteractive();
|
||||
Log.e(TAG, "isScreenshot: screenOn = " + screenOn);
|
||||
if (!screenOn) return;
|
||||
|
||||
long startTime = AppUsedTimeUtils.getInstance().getStartTime();
|
||||
if (AppUsedTimeUtils.getInstance().isNormalTime()) {//正常时间段
|
||||
if (System.currentTimeMillis() - startTime >= ONE_HOURS_TIME) {
|
||||
Log.e(TAG, "isScreenshot: " + "截图");
|
||||
doscreenshot(this);
|
||||
}
|
||||
} else {//非正常时间段
|
||||
if (System.currentTimeMillis() - startTime >= TEN_MINUTES_TIME) {
|
||||
Log.e(TAG, "isScreenshot: " + "截图");
|
||||
doscreenshot(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Observable<Integer> getScreenshot(Context context, String filePath) {
|
||||
Observable<Integer> screenshotObservable = Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> e) {
|
||||
int code = CmdUtil.execute("screencap -p " + filePath).code;
|
||||
e.onNext(code);
|
||||
e.onComplete();
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return screenshotObservable;
|
||||
}
|
||||
|
||||
private static Observable<BaseResponse> getSendFile(String path, MultipartBody.Part body) {
|
||||
return NetInterfaceManager.getInstance()
|
||||
.getScreenshotApi()
|
||||
.sendScreenshot(Utils.getSerial(), body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public static void doscreenshot(Context context) {
|
||||
long time = System.currentTimeMillis();
|
||||
String path = context.getExternalFilesDir("db").getAbsolutePath();
|
||||
String filePath = path + File.separator + time + ".png";
|
||||
getScreenshot(context, filePath).concatMap(new Function<Integer, ObservableSource<BaseResponse>>() {
|
||||
@Override
|
||||
public ObservableSource<BaseResponse> apply(Integer integer) throws Exception {
|
||||
if (integer != 0) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
File file = new File(filePath);
|
||||
if (!file.exists()) {
|
||||
throw new FileNotFoundException(filePath);
|
||||
}
|
||||
// Bitmap bitmap = BitmapFactory.decodeFile(filePath);
|
||||
// if (bitmap.getWidth() < bitmap.getHeight()) {
|
||||
// bitmap = ImageUtils.rotate(bitmap, -90, bitmap.getWidth(), bitmap.getHeight());
|
||||
// }
|
||||
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
// bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
|
||||
// file.createNewFile();
|
||||
// FileOutputStream fos = new FileOutputStream(file);
|
||||
// InputStream is = new ByteArrayInputStream(baos.toByteArray());
|
||||
// int x;
|
||||
// byte[] b = new byte[1024 * 100];
|
||||
// while ((x = is.read(b)) != -1) {
|
||||
// fos.write(b, 0, x);
|
||||
// }
|
||||
// fos.close();
|
||||
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file);
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("file", file.getName(), requestFile);
|
||||
return getSendFile(filePath, body);
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("screenshot", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("screenshot", "onNext: " + baseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("screenshot", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("screenshot", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private LockScreenReceiver lockScreenReceiver;
|
||||
|
||||
private void registerLockScreenReceiver() {
|
||||
if (lockScreenReceiver == null) {
|
||||
lockScreenReceiver = new LockScreenReceiver();
|
||||
}
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(Intent.ACTION_USER_PRESENT);
|
||||
filter.addAction(Intent.ACTION_SCREEN_ON);
|
||||
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||
registerReceiver(lockScreenReceiver, filter);
|
||||
}
|
||||
|
||||
static class LockScreenReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (TextUtils.isEmpty(action)) return;
|
||||
Log.e(TAG, "onReceive: " + action);
|
||||
switch (action) {
|
||||
default:
|
||||
break;
|
||||
case Intent.ACTION_USER_PRESENT:
|
||||
resetStartTime(context);
|
||||
break;
|
||||
case Intent.ACTION_SCREEN_ON:
|
||||
|
||||
break;
|
||||
case Intent.ACTION_SCREEN_OFF:
|
||||
//关闭屏幕上传数据
|
||||
sendAppUsed(context);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void resetStartTime(Context context) {
|
||||
String topPackageName = ForegroundAppUtil.getForegroundPackageName(context);
|
||||
Log.e(TAG, "resetStartTime: " + topPackageName);
|
||||
AppUsedTimeUtils.getInstance().setAppPackageName(topPackageName);
|
||||
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
private static void sendAppUsed(Context context) {
|
||||
String packagename = AppUsedTimeUtils.getInstance().getAppPackageName();
|
||||
Log.e(TAG, "onResume packagename == " + packagename);
|
||||
// AppUsedTimeUtils.getInstance().setEndTime(System.currentTimeMillis());
|
||||
if (!TextUtils.isEmpty(packagename)) {
|
||||
NetInterfaceManager.getInstance().getAppUsageRecordControl()
|
||||
.sendappUsageRecord(Utils.getSerial(),
|
||||
ApkUtils.getAppNameByPackage(context, packagename),
|
||||
packagename,
|
||||
AppUsedTimeUtils.getInstance().getStartTime() / 1000,
|
||||
AppUsedTimeUtils.getInstance().getEndTime() / 1000)
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("sendAppUsed", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("sendAppUsed", "onNext: " + baseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("sendAppUsed", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("sendAppUsed", "onComplete: ");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Log.e("fht", "app = null" + packagename);
|
||||
}
|
||||
}
|
||||
|
||||
//在这里处理任务执行中的状态,如进度进度条的刷新
|
||||
@Download.onTaskRunning
|
||||
protected void running(DownloadTask task) {
|
||||
Log.e("aria", "正在下载:" + task.getPercent() + ":" + task.getExtendField());
|
||||
// ToastUtil.show("正在下载:" + task.getPercent() + "%" + "\t" + Formatter.formatFileSize(MainService.this, task.getSpeed()) + "/s");
|
||||
}
|
||||
|
||||
@Download.onTaskComplete
|
||||
void taskComplete(DownloadTask task) {
|
||||
//在这里处理任务完成的状态
|
||||
Log.e(TAG, "taskComplete: " + task.getFilePath());
|
||||
}
|
||||
|
||||
@Download.onTaskFail
|
||||
void taskFail(DownloadTask task, Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.uiui.aios.activity;
|
||||
package com.uiui.zyos.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.media.AudioManager;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.os.Vibrator;
|
||||
@@ -22,16 +21,14 @@ import com.blankj.utilcode.util.FileUtils;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.alarm.AlarmUtils;
|
||||
import com.uiui.aios.bean.AlarmClockData;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.network.NetInterfaceManager;
|
||||
import com.uiui.aios.utils.FileUtil;
|
||||
import com.uiui.aios.utils.ScreenUtils;
|
||||
import com.uiui.aios.utils.Utils;
|
||||
import com.uiui.aios.utils.WakeUpUtils;
|
||||
import com.uiui.aios.view.JzvdStdAssert;
|
||||
import com.uiui.zyos.R;
|
||||
import com.uiui.zyos.alarm.AlarmUtils;
|
||||
import com.uiui.zyos.bean.AlarmClockData;
|
||||
import com.uiui.zyos.utils.FileUtil;
|
||||
import com.uiui.zyos.utils.ScreenUtils;
|
||||
import com.uiui.zyos.utils.Utils;
|
||||
import com.uiui.zyos.utils.WakeUpUtils;
|
||||
import com.uiui.zyos.view.JzvdStdAssert;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -114,32 +111,6 @@ public class NoticeActivity extends AppCompatActivity {
|
||||
alarm.setFinished(true);
|
||||
AlarmUtils.getInstance().updateAlarmFinished(alarm);
|
||||
}
|
||||
NetInterfaceManager.getInstance()
|
||||
.getUpdateAlarmObservable(alarmClockData.getId())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("showData", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||
Log.e("showData", "onNext: " + baseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("showData", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("showData", "onComplete: ");
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
String voiceUrl = alarmClockData.getVoice();
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.activity;
|
||||
package com.uiui.zyos.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@@ -6,7 +6,7 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.zyos.R;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.activity.main;
|
||||
package com.uiui.zyos.activity.main;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.BroadcastReceiver;
|
||||
@@ -12,14 +12,10 @@ import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.PersistableBundle;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
@@ -27,34 +23,25 @@ import androidx.fragment.app.FragmentManager;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.alarmclock.uiui.IAlarmAidlInterface;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.flyco.tablayout.SlidingTabLayout;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiui.aios.BuildConfig;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.base.BaseActivity;
|
||||
import com.uiui.aios.base.BaseFragmentPagerAdapter;
|
||||
import com.uiui.aios.bean.AlarmItem;
|
||||
import com.uiui.aios.bean.DesktopIcon;
|
||||
import com.uiui.aios.config.CommonConfig;
|
||||
import com.uiui.aios.dialog.PasswordDialog;
|
||||
import com.uiui.aios.dialog.PrivacyPolicyDialog;
|
||||
import com.uiui.aios.fragment.AppListFragment;
|
||||
import com.uiui.aios.fragment.ControlFragment;
|
||||
import com.uiui.aios.fragment.SecondFragment;
|
||||
import com.uiui.aios.fragment.custom.CustomFragment;
|
||||
import com.uiui.aios.service.NotificationService;
|
||||
import com.uiui.aios.utils.ApkUtils;
|
||||
import com.uiui.aios.utils.AppUsedTimeUtils;
|
||||
import com.uiui.aios.utils.HomeWatcher;
|
||||
import com.uiui.aios.utils.LauncherUtils;
|
||||
import com.uiui.aios.utils.ToastUtil;
|
||||
import com.uiui.aios.view.ScaleCircleNavigator;
|
||||
import com.uiui.zyos.BuildConfig;
|
||||
import com.uiui.zyos.R;
|
||||
import com.uiui.zyos.base.BaseActivity;
|
||||
import com.uiui.zyos.base.BaseFragmentPagerAdapter;
|
||||
import com.uiui.zyos.config.CommonConfig;
|
||||
import com.uiui.zyos.dialog.PrivacyPolicyDialog;
|
||||
import com.uiui.zyos.fragment.custom.CustomFragment;
|
||||
import com.uiui.zyos.service.NotificationService;
|
||||
import com.uiui.zyos.utils.AppUsedTimeUtils;
|
||||
import com.uiui.zyos.utils.HomeWatcher;
|
||||
import com.uiui.zyos.utils.LauncherUtils;
|
||||
import com.uiui.zyos.utils.ToastUtil;
|
||||
import com.uiui.zyos.view.ScaleCircleNavigator;
|
||||
|
||||
import net.lucode.hackware.magicindicator.MagicIndicator;
|
||||
import net.lucode.hackware.magicindicator.ViewPagerHelper;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -63,13 +50,16 @@ import butterknife.ButterKnife;
|
||||
|
||||
public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
private static final String TAG = MainActivity.class.getSimpleName();
|
||||
private MainPresenter mMainPresenter;
|
||||
|
||||
@BindView(R.id.main_sliding_tab_layout)
|
||||
SlidingTabLayout main_sliding_tab_layout;
|
||||
@BindView(R.id.viewPager)
|
||||
ViewPager mViewPager;
|
||||
@BindView(R.id.magicIndicator)
|
||||
MagicIndicator mMagicIndicator;
|
||||
|
||||
private MainPresenter mMainPresenter;
|
||||
|
||||
private ScaleCircleNavigator scaleCircleNavigator;
|
||||
|
||||
private FragmentManager mFragmentManager;
|
||||
@@ -77,13 +67,9 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
private BaseFragmentPagerAdapter mBaseFragmentPagerAdapter;
|
||||
|
||||
private List<Fragment> mFragments;
|
||||
private ControlFragment mControlFragment;
|
||||
private CustomFragment mCustomFragment;
|
||||
private SecondFragment mSecondFragment;
|
||||
|
||||
private boolean is_twoscreen = false;
|
||||
private int appListIndex = 2;
|
||||
private int defaultCurrent = 1;
|
||||
private int defaultCurrent = 0;
|
||||
private String[] title = new String[]{"语文","数学","英语","物理","化学","生物","其他",};
|
||||
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
|
||||
@@ -109,35 +95,13 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
// fragmentTransaction.add(R.id.viewPager, appListFragment);
|
||||
// fragmentTransaction.commit();
|
||||
|
||||
mControlFragment = new ControlFragment();
|
||||
mFragments.add(mControlFragment);
|
||||
|
||||
is_twoscreen = Settings.Global.getInt(getContentResolver(), "is_twoscreen", 0) == 1;
|
||||
if (is_twoscreen) {
|
||||
appListIndex = 3;
|
||||
defaultCurrent = 2;
|
||||
mSecondFragment = new SecondFragment();
|
||||
mFragments.add(mSecondFragment);
|
||||
}
|
||||
|
||||
mCustomFragment = new CustomFragment();
|
||||
mFragments.add(mCustomFragment);
|
||||
mMainPresenter.getSystemSettings();
|
||||
|
||||
ArrayList<DesktopIcon> desktopIcons = ApkUtils.queryFilterAppInfo(this);
|
||||
int x = 0;
|
||||
for (int i = 0; i <= desktopIcons.size(); i++) {
|
||||
if (i != 0 && i % APP_LIST_SIZE == 0) {
|
||||
AppListFragment appListFragment = new AppListFragment();
|
||||
appListFragment.setAppList(new ArrayList<>(desktopIcons.subList(x, i)));
|
||||
mFragments.add(appListFragment);
|
||||
x = i;
|
||||
} else if (i == desktopIcons.size()) {
|
||||
AppListFragment appListFragment = new AppListFragment();
|
||||
mFragments.add(appListFragment);
|
||||
appListFragment.setAppList(new ArrayList<>(desktopIcons.subList(x, i)));
|
||||
}
|
||||
}
|
||||
mFragments.add(new CustomFragment());
|
||||
mFragments.add(new CustomFragment());
|
||||
mFragments.add(new CustomFragment());
|
||||
mFragments.add(new CustomFragment());
|
||||
mFragments.add(new CustomFragment());
|
||||
mFragments.add(new CustomFragment());
|
||||
mFragments.add(new CustomFragment());
|
||||
|
||||
scaleCircleNavigator = new ScaleCircleNavigator(this);
|
||||
scaleCircleNavigator.setCircleCount(mFragments.size());
|
||||
@@ -151,37 +115,13 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
});
|
||||
|
||||
mViewPager.setAdapter(mBaseFragmentPagerAdapter);
|
||||
mViewPager.setOffscreenPageLimit(3);
|
||||
mViewPager.setOffscreenPageLimit(4);
|
||||
mMagicIndicator.setNavigator(scaleCircleNavigator);
|
||||
ViewPagerHelper.bind(mMagicIndicator, mViewPager);
|
||||
if (mFragments.size() > 1) {
|
||||
mViewPager.setCurrentItem(defaultCurrent);
|
||||
}
|
||||
}
|
||||
|
||||
private void showPassword() {
|
||||
PasswordDialog passwordDialog = new PasswordDialog(MainActivity.this);
|
||||
passwordDialog.setTitle("退出关怀系统");
|
||||
passwordDialog.setOnClickBottomListener(new PasswordDialog.OnClickBottomListener() {
|
||||
@Override
|
||||
public void onPositiveClick() {
|
||||
if ("666666".equals(passwordDialog.getPassword())) {
|
||||
LauncherUtils.openLauncher3(MainActivity.this);
|
||||
passwordDialog.dismiss();
|
||||
} else {
|
||||
ToastUtil.show("密码错误");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNegtiveClick() {
|
||||
passwordDialog.dismiss();
|
||||
}
|
||||
});
|
||||
passwordDialog.show();
|
||||
passwordDialog.getWindow().setGravity(Gravity.CENTER);
|
||||
passwordDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
|
||||
passwordDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
main_sliding_tab_layout.setViewPager(mViewPager,title);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -194,7 +134,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
Log.e(TAG, "onServiceConnected: ");
|
||||
mIAlarmAidlInterface = IAlarmAidlInterface.Stub.asInterface(service);
|
||||
getAlarmData();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -232,74 +171,14 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||
}
|
||||
|
||||
private void getAlarmData() {
|
||||
if (mIAlarmAidlInterface == null) {
|
||||
bindAlarmService();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
String json = mIAlarmAidlInterface.getAlarm();
|
||||
Log.e(TAG, "onServiceConnected: " + json);
|
||||
if ("暂无闹钟".equalsIgnoreCase(json) || TextUtils.isEmpty(json)) {
|
||||
mCustomFragment.setAlarmItem(null);
|
||||
return;
|
||||
}
|
||||
Type type = new TypeToken<List<AlarmItem>>() {
|
||||
}.getType();
|
||||
List<AlarmItem> alarmItem = new Gson().fromJson(json, type);
|
||||
mCustomFragment.setAlarmItem(alarmItem);
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
if (hasFocus) {//表示渲染结束
|
||||
addData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final static int APP_LIST_SIZE = 3 * 4;
|
||||
|
||||
private void addData() {
|
||||
Log.e(TAG, "addData: ");
|
||||
List<Fragment> fragmentList = new ArrayList<>();
|
||||
ArrayList<DesktopIcon> applicationInfoList = ApkUtils.queryFilterAppInfo(this);
|
||||
int x = 0;
|
||||
for (int i = 0; i <= applicationInfoList.size(); i++) {
|
||||
if (i != 0 && i % APP_LIST_SIZE == 0) {
|
||||
AppListFragment appListFragment = new AppListFragment();
|
||||
appListFragment.setAppList(new ArrayList<>(applicationInfoList.subList(x, i)));
|
||||
fragmentList.add(appListFragment);
|
||||
x = i;
|
||||
} else if (i == applicationInfoList.size()) {
|
||||
AppListFragment appListFragment = new AppListFragment();
|
||||
fragmentList.add(appListFragment);
|
||||
appListFragment.setAppList(new ArrayList<>(applicationInfoList.subList(x, i)));
|
||||
}
|
||||
}
|
||||
//从第三个开始改
|
||||
for (int i = 0; i < fragmentList.size(); i++) {
|
||||
if (i + appListIndex < mFragments.size()) {
|
||||
mBaseFragmentPagerAdapter.replaceFragment(i + appListIndex, fragmentList.get(i));
|
||||
// mFragments.remove(i + 2);
|
||||
// mFragments.add(i + 2, fragmentList.get(i));
|
||||
} else {
|
||||
// mFragments.add(fragmentList.get(i));
|
||||
// mBaseFragmentPagerAdapter.getFragments();
|
||||
mBaseFragmentPagerAdapter.addFragment(fragmentList.get(i));
|
||||
}
|
||||
}
|
||||
for (int i = mFragments.size(); i > fragmentList.size() + appListIndex; i--) {
|
||||
mFragments.remove(i - 1);
|
||||
}
|
||||
scaleCircleNavigator.setCircleCount(mFragments.size());
|
||||
scaleCircleNavigator.notifyDataSetChanged();
|
||||
mBaseFragmentPagerAdapter.notifyItemChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -341,9 +220,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
Log.e(TAG, "onStart: ");
|
||||
AppUsedTimeUtils.getInstance().setAppPackageName(BuildConfig.APPLICATION_ID);
|
||||
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||
getAlarmData();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -359,6 +235,57 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestart() {
|
||||
super.onRestart();
|
||||
Log.e(TAG, "onRestart: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
Log.e(TAG, "onPause: ");
|
||||
if (mHomeWatcher != null) {
|
||||
mHomeWatcher.stopWatch();// 在销毁时停止监听,不然会报错的。
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
Log.e(TAG, "onStop: ");
|
||||
AppUsedTimeUtils.getInstance().setEndTime(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mMainPresenter.detachView();
|
||||
if (mNewAppReceiver != null) {
|
||||
unregisterReceiver(mNewAppReceiver);
|
||||
}
|
||||
if (sosNumberReceiver != null) {
|
||||
unregisterReceiver(sosNumberReceiver);
|
||||
}
|
||||
if (updateDesktopReceiver != null) {
|
||||
unregisterReceiver(updateDesktopReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
Log.e(TAG, "onSaveInstanceState: ");
|
||||
Log.e(TAG, "onSaveInstanceState: " + System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
Log.e(TAG, "onRestoreInstanceState: ");
|
||||
Log.e(TAG, "onRestoreInstanceState: " + System.currentTimeMillis());
|
||||
}
|
||||
|
||||
private void getData() {
|
||||
if (!isNotificationListenersEnabled()) {
|
||||
ToastUtil.show("请授予\"" + getString(R.string.app_name) + "\"使用通知权");
|
||||
@@ -371,7 +298,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
} else {
|
||||
LauncherUtils.setDefaultDesktop(MainActivity.this, LauncherUtils.Launcher3, LauncherUtils.Launcher3Class);
|
||||
}
|
||||
addData();
|
||||
addHomeWatcher();
|
||||
}
|
||||
|
||||
@@ -468,60 +394,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestart() {
|
||||
super.onRestart();
|
||||
Log.e(TAG, "onRestart: ");
|
||||
mMainPresenter.sendAPPUsage();
|
||||
mMainPresenter.sendRunningInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
Log.e(TAG, "onPause: ");
|
||||
if (mHomeWatcher != null) {
|
||||
mHomeWatcher.stopWatch();// 在销毁时停止监听,不然会报错的。
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
Log.e(TAG, "onSaveInstanceState: ");
|
||||
Log.e(TAG, "onSaveInstanceState: " + System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
Log.e(TAG, "onRestoreInstanceState: ");
|
||||
Log.e(TAG, "onRestoreInstanceState: " + System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
Log.e(TAG, "onStop: ");
|
||||
AppUsedTimeUtils.getInstance().setEndTime(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mMainPresenter.detachView();
|
||||
if (mNewAppReceiver != null) {
|
||||
unregisterReceiver(mNewAppReceiver);
|
||||
}
|
||||
if (sosNumberReceiver != null) {
|
||||
unregisterReceiver(sosNumberReceiver);
|
||||
}
|
||||
if (updateDesktopReceiver != null) {
|
||||
unregisterReceiver(updateDesktopReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void registmNewAppReceiver() {
|
||||
mNewAppReceiver = new NewAppReceiver();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
@@ -545,7 +417,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
|| Intent.ACTION_PACKAGE_REMOVED.equals(action)
|
||||
// || Intent.ACTION_PACKAGE_CHANGED.equals(action)
|
||||
) {
|
||||
addData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -570,7 +441,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
if (TextUtils.isEmpty(setting_sos)) {
|
||||
return;
|
||||
}
|
||||
// mCustomFragment.setSosNumber();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -591,37 +461,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.e(TAG, "onReceive: " + intent.getAction());
|
||||
addData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSystemSettings() {
|
||||
mMainPresenter.getDesktopLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDesktopLayoutFinish() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDesktopLayoutFinish() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendAPPUsageFinish() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRunningInfoFinish() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAdminSnSetting() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.uiui.zyos.activity.main;
|
||||
|
||||
import com.uiui.zyos.base.BasePresenter;
|
||||
import com.uiui.zyos.base.BaseView;
|
||||
|
||||
public class MainContact {
|
||||
public interface Presenter extends BasePresenter<MainView> {
|
||||
|
||||
}
|
||||
|
||||
public interface MainView extends BaseView {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.uiui.zyos.activity.main;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
public class MainPresenter implements MainContact.Presenter {
|
||||
private static final String TAG = MainPresenter.class.getSimpleName();
|
||||
private MainContact.MainView mView;
|
||||
private Context mContext;
|
||||
|
||||
private BehaviorSubject<ActivityEvent> lifecycle;
|
||||
|
||||
void setLifecycle(BehaviorSubject<ActivityEvent> lifecycle) {
|
||||
this.lifecycle = lifecycle;
|
||||
}
|
||||
|
||||
public BehaviorSubject<ActivityEvent> getLifecycle() {
|
||||
return lifecycle;
|
||||
}
|
||||
|
||||
MainPresenter(Context context) {
|
||||
this.mContext = context;
|
||||
Log.e(TAG, "MainPresenter: " + context.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachView(MainContact.MainView view) {
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
this.mView = null;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.fragment.custom;
|
||||
package com.uiui.zyos.adapter;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.alarm;
|
||||
package com.uiui.zyos.alarm;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.alarm;
|
||||
package com.uiui.zyos.alarm;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.alarm;
|
||||
package com.uiui.zyos.alarm;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlarmManager;
|
||||
@@ -14,10 +14,10 @@ import android.util.Log;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.blankj.utilcode.util.FileUtils;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.uiui.aios.bean.AlarmClockData;
|
||||
import com.uiui.aios.service.main.MainService;
|
||||
import com.uiui.aios.utils.FileUtil;
|
||||
import com.uiui.aios.utils.Utils;
|
||||
import com.uiui.zyos.bean.AlarmClockData;
|
||||
import com.uiui.zyos.service.main.MainService;
|
||||
import com.uiui.zyos.utils.FileUtil;
|
||||
import com.uiui.zyos.utils.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.ParseException;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.base;
|
||||
package com.uiui.zyos.base;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.trello.rxlifecycle4.LifecycleTransformer;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.zyos.R;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.base;
|
||||
package com.uiui.zyos.base;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Intent;
|
||||
@@ -7,25 +7,23 @@ import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.qweather.sdk.view.HeConfig;
|
||||
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.uiui.aios.BuildConfig;
|
||||
import com.uiui.aios.alarm.AlarmUtils;
|
||||
import com.uiui.aios.manager.ConnectManager;
|
||||
import com.uiui.aios.manager.RemoteManager;
|
||||
import com.uiui.aios.network.NetInterfaceManager;
|
||||
import com.uiui.aios.service.main.MainService;
|
||||
import com.uiui.aios.utils.AppUsedTimeUtils;
|
||||
import com.uiui.aios.utils.SystemUtils;
|
||||
import com.uiui.aios.utils.Utils;
|
||||
import com.uiui.zyos.BuildConfig;
|
||||
import com.uiui.zyos.alarm.AlarmUtils;
|
||||
import com.uiui.zyos.manager.ConnectManager;
|
||||
import com.uiui.zyos.manager.RemoteManager;
|
||||
import com.uiui.zyos.network.NetInterfaceManager;
|
||||
import com.uiui.zyos.service.main.MainService;
|
||||
import com.uiui.zyos.utils.AppUsedTimeUtils;
|
||||
import com.uiui.zyos.utils.SystemUtils;
|
||||
import com.uiui.zyos.utils.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class BaseApplication extends Application {
|
||||
private static final String TAG = BaseApplication.class.getSimpleName();
|
||||
|
||||
@@ -48,9 +46,6 @@ public class BaseApplication extends Application {
|
||||
AppUsedTimeUtils.init(this);
|
||||
AlarmUtils.init(this);
|
||||
tpushInit();
|
||||
HeConfig.init("HE2206151627491952", "03125bfee8934cf4b640af48e8187c9d");
|
||||
//切换至开发版服务
|
||||
HeConfig.switchToDevService();
|
||||
RemoteManager.init(this);
|
||||
ConnectManager.init(this);
|
||||
NetInterfaceManager.init(this);
|
||||
@@ -113,6 +108,4 @@ public class BaseApplication extends Application {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.base;
|
||||
package com.uiui.zyos.base;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.base;
|
||||
package com.uiui.zyos.base;
|
||||
|
||||
import android.util.SparseArray;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.base;
|
||||
package com.uiui.zyos.base;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.base;
|
||||
package com.uiui.zyos.base;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.base;
|
||||
package com.uiui.zyos.base;
|
||||
|
||||
public interface BaseView {
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -8,7 +8,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.uiui.aios.alarm.AlarmUtils;
|
||||
import com.uiui.zyos.alarm.AlarmUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.ParseException;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
|
||||
import com.google.gson.Gson;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.bean;
|
||||
package com.uiui.zyos.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.config;
|
||||
package com.uiui.zyos.config;
|
||||
|
||||
public class CommonConfig {
|
||||
/*是否激活接口请求缓存*/
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.dialog;
|
||||
package com.uiui.zyos.dialog;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
@@ -10,7 +10,7 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.zyos.R;
|
||||
|
||||
|
||||
/**
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.dialog;
|
||||
package com.uiui.zyos.dialog;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
@@ -12,7 +12,7 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.zyos.R;
|
||||
|
||||
|
||||
/**
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.uiui.aios.dialog;
|
||||
package com.uiui.zyos.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
@@ -18,8 +17,8 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.activity.PolicyActivity;
|
||||
import com.uiui.zyos.R;
|
||||
import com.uiui.zyos.activity.PolicyActivity;
|
||||
|
||||
public class PrivacyPolicyDialog extends AlertDialog {
|
||||
private Context mContext;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.dialog;
|
||||
package com.uiui.zyos.dialog;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
@@ -10,7 +10,7 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.zyos.R;
|
||||
|
||||
|
||||
/**
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.uiui.aios.disklrucache;
|
||||
package com.uiui.zyos.disklrucache;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user