version:1.0
fix: update:基本布局实现
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
|
|||||||
apply plugin: "com.tencent.android.tpns"
|
apply plugin: "com.tencent.android.tpns"
|
||||||
|
|
||||||
def appName() {
|
def appName() {
|
||||||
return "科大讯飞学习桌面"
|
return "ZYLauncher"
|
||||||
}
|
}
|
||||||
|
|
||||||
def releaseTime() {
|
def releaseTime() {
|
||||||
@@ -74,9 +74,6 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
manifestPlaceholders = [
|
|
||||||
Baidu_AK: "ZauKWLbO0AfHSgR2j3unMkP0MwbBZHxO"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
release {
|
release {
|
||||||
@@ -101,9 +98,6 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
manifestPlaceholders = [
|
|
||||||
Baidu_AK: "ZauKWLbO0AfHSgR2j3unMkP0MwbBZHxO"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,7 +117,6 @@ dependencies {
|
|||||||
implementation "androidx.viewpager2:viewpager2:1.0.0"
|
implementation "androidx.viewpager2:viewpager2:1.0.0"
|
||||||
// Java language implementation
|
// Java language implementation
|
||||||
implementation "androidx.fragment:fragment:1.4.1"
|
implementation "androidx.fragment:fragment:1.4.1"
|
||||||
implementation "androidx.viewpager2:viewpager2:1.0.0"
|
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="com.uiui.zyos"
|
package="com.uiui.zyos">
|
||||||
android:sharedUserId="android.uid.system">
|
|
||||||
|
|
||||||
<queries>
|
<queries>
|
||||||
<intent>
|
<intent>
|
||||||
@@ -102,11 +101,6 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".activity.EmergencyActivity"
|
android:name=".activity.EmergencyActivity"
|
||||||
android:launchMode="singleTask" />
|
android:launchMode="singleTask" />
|
||||||
<activity
|
|
||||||
android:name=".activity.NoticeActivity"
|
|
||||||
android:excludeFromRecents="true"
|
|
||||||
android:screenOrientation="portrait"
|
|
||||||
android:theme="@style/activity_styles" />
|
|
||||||
<activity android:name=".activity.APPListActivity" />
|
<activity android:name=".activity.APPListActivity" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.alarm.AlarmClockActivity"
|
android:name=".activity.alarm.AlarmClockActivity"
|
||||||
@@ -282,9 +276,6 @@
|
|||||||
<meta-data
|
<meta-data
|
||||||
android:name="XG_V2_ACCESS_KEY"
|
android:name="XG_V2_ACCESS_KEY"
|
||||||
android:value="AZZXANJF4HBD" />
|
android:value="AZZXANJF4HBD" />
|
||||||
<meta-data
|
|
||||||
android:name="com.baidu.lbsapi.API_KEY"
|
|
||||||
android:value="${Baidu_AK}" />
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
// IGetInfoInterface.aidl
|
|
||||||
package com.uiui.sn;
|
|
||||||
|
|
||||||
// Declare any non-default types here with import statements
|
|
||||||
|
|
||||||
interface IGetInfoInterface {
|
|
||||||
/**
|
|
||||||
* Demonstrates some basic types that you can use as parameters
|
|
||||||
* and return values in AIDL.
|
|
||||||
*/
|
|
||||||
void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
|
|
||||||
double aDouble, String aString);
|
|
||||||
|
|
||||||
//获取sn
|
|
||||||
String getSerial();
|
|
||||||
//获取用户信息
|
|
||||||
String getUserInfo();
|
|
||||||
//获取隐藏APP
|
|
||||||
List<String> getHideAPP();
|
|
||||||
//获取禁止打开的APP
|
|
||||||
List<String> getForbidAPP();
|
|
||||||
|
|
||||||
//获取app设置
|
|
||||||
String getAppTimeControl();
|
|
||||||
//获取整机设置
|
|
||||||
String getSnTimeControl();
|
|
||||||
//获取系统设置
|
|
||||||
String getSetting();
|
|
||||||
//获取定位结果
|
|
||||||
String getMapResult();
|
|
||||||
}
|
|
||||||
@@ -1,14 +1,18 @@
|
|||||||
// IAlarmAidlInterface.aidl
|
// IGetInfoInterface.aidl
|
||||||
package com.alarmclock.uiui;
|
package com.uiui.zysn;
|
||||||
|
|
||||||
// Declare any non-default types here with import statements
|
// Declare any non-default types here with import statements
|
||||||
|
|
||||||
interface IAlarmAidlInterface {
|
interface IGetInfoInterface {
|
||||||
/**
|
/**
|
||||||
* Demonstrates some basic types that you can use as parameters
|
* Demonstrates some basic types that you can use as parameters
|
||||||
* and return values in AIDL.
|
* and return values in AIDL.
|
||||||
*/
|
*/
|
||||||
void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
|
void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
|
||||||
double aDouble, String aString);
|
double aDouble, String aString);
|
||||||
String getAlarm();
|
|
||||||
|
//获取sn
|
||||||
|
String getSerial();
|
||||||
|
//获取定位结果
|
||||||
|
String getMapResult();
|
||||||
}
|
}
|
||||||
@@ -1,209 +0,0 @@
|
|||||||
package com.uiui.zyos.activity;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.media.AudioManager;
|
|
||||||
import android.media.MediaPlayer;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.PowerManager;
|
|
||||||
import android.os.Vibrator;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
||||||
|
|
||||||
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.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;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import cn.jzvd.JZDataSource;
|
|
||||||
import cn.jzvd.Jzvd;
|
|
||||||
import io.reactivex.rxjava3.annotations.NonNull;
|
|
||||||
import io.reactivex.rxjava3.core.Observer;
|
|
||||||
import io.reactivex.rxjava3.disposables.Disposable;
|
|
||||||
|
|
||||||
public class NoticeActivity extends AppCompatActivity {
|
|
||||||
private String TAG = NoticeActivity.class.getSimpleName();
|
|
||||||
|
|
||||||
@BindView(R.id.tv_title)
|
|
||||||
TextView tv_title;
|
|
||||||
@BindView(R.id.bt_ok)
|
|
||||||
Button bt_ok;
|
|
||||||
@BindView(R.id.cl_voice)
|
|
||||||
ConstraintLayout cl_voice;
|
|
||||||
@BindView(R.id.cl_vp)
|
|
||||||
ConstraintLayout cl_vp;
|
|
||||||
@BindView(R.id.jz_video)
|
|
||||||
JzvdStdAssert jz_video;
|
|
||||||
@BindView(R.id.imageView)
|
|
||||||
ImageView imageView;
|
|
||||||
|
|
||||||
private AlarmClockData alarmClockData;
|
|
||||||
private int code;
|
|
||||||
private MediaPlayer mediaPlayer;
|
|
||||||
private PowerManager pm;
|
|
||||||
private PowerManager.WakeLock wakeLock;
|
|
||||||
private AudioManager audioManager;
|
|
||||||
|
|
||||||
private Vibrator vibrator;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_notice);
|
|
||||||
ButterKnife.bind(this);
|
|
||||||
Intent intent = getIntent();
|
|
||||||
code = intent.getIntExtra("id", -1);
|
|
||||||
pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
|
||||||
wakeLock = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK, "WakeAndLock");
|
|
||||||
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
|
||||||
if (code == -1) {
|
|
||||||
finish();
|
|
||||||
} else {
|
|
||||||
wakeLock.acquire(60 * 1000L);
|
|
||||||
long[] pattern = {1000, 5000, 1000, 5000};
|
|
||||||
vibrator.vibrate(pattern, 0);
|
|
||||||
WakeUpUtils.wakeUpAndUnlockScreen(this);
|
|
||||||
HashMap<Integer, AlarmClockData> oldData = AlarmUtils.getInstance().getOldData();
|
|
||||||
alarmClockData = oldData.get(code);
|
|
||||||
if (alarmClockData == null) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
Log.e(TAG, "onCreate: " + alarmClockData);
|
|
||||||
showData(alarmClockData);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showData(AlarmClockData alarmClockData) {
|
|
||||||
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
|
||||||
int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
|
||||||
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, maxVolume, AudioManager.FLAG_PLAY_SOUND);
|
|
||||||
tv_title.setText(alarmClockData.getTitle());
|
|
||||||
bt_ok.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
HashMap<Integer, AlarmClockData> oldData = AlarmUtils.getInstance().getOldData();
|
|
||||||
AlarmClockData alarm = oldData.get(code);
|
|
||||||
if (alarm != null) {
|
|
||||||
alarm.setFinished(true);
|
|
||||||
AlarmUtils.getInstance().updateAlarmFinished(alarm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
String voiceUrl = alarmClockData.getVoice();
|
|
||||||
String voicemd5 = alarmClockData.getVoice_md5();
|
|
||||||
String filePath = alarmClockData.getFile();
|
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(voiceUrl)) {
|
|
||||||
cl_voice.setVisibility(View.VISIBLE);
|
|
||||||
String fileName = Utils.getFileNamefromURL(voiceUrl);
|
|
||||||
File file = new File(Utils.getDownLoadPath(NoticeActivity.this) + fileName);
|
|
||||||
String fileMD5 = FileUtils.getFileMD5ToString(file);
|
|
||||||
// if (!md5.equals(fileMD5)) {
|
|
||||||
// // TODO: 2021/12/16
|
|
||||||
// } else {
|
|
||||||
mediaPlayer = new MediaPlayer();
|
|
||||||
try {
|
|
||||||
// 切歌之前先重置,释放掉之前的资源
|
|
||||||
mediaPlayer.reset();
|
|
||||||
FileInputStream fis = new FileInputStream(file);
|
|
||||||
mediaPlayer.setDataSource(fis.getFD());
|
|
||||||
// 设置播放源
|
|
||||||
// mediaPlayer.setDataSource(file.getAbsolutePath());
|
|
||||||
// 开始播放前的准备工作,加载多媒体资源,获取相关信息
|
|
||||||
mediaPlayer.prepare();
|
|
||||||
// 开始播放
|
|
||||||
mediaPlayer.start();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
Log.e(TAG, "showData: " + e.getMessage());
|
|
||||||
}
|
|
||||||
// }
|
|
||||||
} else {
|
|
||||||
cl_voice.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
if (!TextUtils.isEmpty(filePath)) {
|
|
||||||
cl_vp.setVisibility(View.VISIBLE);
|
|
||||||
String fileType = FileUtil.getFileType(filePath);
|
|
||||||
Log.e(TAG, "showData: " + fileType);
|
|
||||||
if (FileUtil.isPictureFile(fileType)) {
|
|
||||||
jz_video.setVisibility(View.GONE);
|
|
||||||
imageView.setVisibility(View.VISIBLE);
|
|
||||||
RequestOptions options = new RequestOptions().transform(new RoundedCorners(ScreenUtils.dip2px(this, 16F)));
|
|
||||||
Glide.with(NoticeActivity.this).load(filePath).apply(options).into(imageView);
|
|
||||||
} else if (FileUtil.isVideoFile(fileType)) {
|
|
||||||
jz_video.setVisibility(View.VISIBLE);
|
|
||||||
imageView.setVisibility(View.GONE);
|
|
||||||
String fileName = filePath.substring(filePath.lastIndexOf("/") + 1, filePath.length());
|
|
||||||
String realPath = Utils.getDownLoadPath(NoticeActivity.this) + fileName;
|
|
||||||
File file = new File(realPath);
|
|
||||||
JZDataSource jzDataSource;
|
|
||||||
if (!file.exists()) {
|
|
||||||
jzDataSource = new JZDataSource(filePath, "");
|
|
||||||
Log.e(TAG, "showData: not exists");
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "showData: exists " + file);
|
|
||||||
URI uri = file.toURI();
|
|
||||||
jzDataSource = new JZDataSource(uri.toString(), "");
|
|
||||||
}
|
|
||||||
jzDataSource.looping = true;
|
|
||||||
jz_video.setUp(jzDataSource, Jzvd.SCREEN_NORMAL);
|
|
||||||
jz_video.startPreloading();
|
|
||||||
jz_video.startVideoAfterPreloading();
|
|
||||||
jz_video.startVideo();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cl_vp.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
if (mediaPlayer != null) {
|
|
||||||
if (mediaPlayer.isPlaying()) {
|
|
||||||
mediaPlayer.stop();
|
|
||||||
}
|
|
||||||
mediaPlayer.release();
|
|
||||||
mediaPlayer = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
if (Jzvd.backPress()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
super.onBackPressed();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
Jzvd.releaseAllVideos();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,12 +6,10 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.ServiceConnection;
|
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -22,7 +20,6 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.viewpager.widget.ViewPager;
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
import com.alarmclock.uiui.IAlarmAidlInterface;
|
|
||||||
import com.flyco.tablayout.SlidingTabLayout;
|
import com.flyco.tablayout.SlidingTabLayout;
|
||||||
import com.tencent.mmkv.MMKV;
|
import com.tencent.mmkv.MMKV;
|
||||||
import com.uiui.zyos.BuildConfig;
|
import com.uiui.zyos.BuildConfig;
|
||||||
@@ -31,11 +28,14 @@ import com.uiui.zyos.base.BaseActivity;
|
|||||||
import com.uiui.zyos.base.BaseFragmentPagerAdapter;
|
import com.uiui.zyos.base.BaseFragmentPagerAdapter;
|
||||||
import com.uiui.zyos.config.CommonConfig;
|
import com.uiui.zyos.config.CommonConfig;
|
||||||
import com.uiui.zyos.dialog.PrivacyPolicyDialog;
|
import com.uiui.zyos.dialog.PrivacyPolicyDialog;
|
||||||
import com.uiui.zyos.fragment.custom.CustomFragment;
|
import com.uiui.zyos.fragment.biology.BiologyFragment;
|
||||||
|
import com.uiui.zyos.fragment.chemical.ChemicalFragment;
|
||||||
|
import com.uiui.zyos.fragment.chinese.ChineseFragment;
|
||||||
|
import com.uiui.zyos.fragment.english.EnglishFragment;
|
||||||
|
import com.uiui.zyos.fragment.math.MathFragment;
|
||||||
|
import com.uiui.zyos.fragment.physics.PhysicsFragment;
|
||||||
import com.uiui.zyos.service.NotificationService;
|
import com.uiui.zyos.service.NotificationService;
|
||||||
import com.uiui.zyos.utils.AppUsedTimeUtils;
|
|
||||||
import com.uiui.zyos.utils.HomeWatcher;
|
import com.uiui.zyos.utils.HomeWatcher;
|
||||||
import com.uiui.zyos.utils.LauncherUtils;
|
|
||||||
import com.uiui.zyos.utils.ToastUtil;
|
import com.uiui.zyos.utils.ToastUtil;
|
||||||
import com.uiui.zyos.view.ScaleCircleNavigator;
|
import com.uiui.zyos.view.ScaleCircleNavigator;
|
||||||
|
|
||||||
@@ -95,13 +95,13 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
|||||||
// fragmentTransaction.add(R.id.viewPager, appListFragment);
|
// fragmentTransaction.add(R.id.viewPager, appListFragment);
|
||||||
// fragmentTransaction.commit();
|
// fragmentTransaction.commit();
|
||||||
|
|
||||||
mFragments.add(new CustomFragment());
|
mFragments.add(new ChineseFragment());
|
||||||
mFragments.add(new CustomFragment());
|
mFragments.add(new MathFragment());
|
||||||
mFragments.add(new CustomFragment());
|
mFragments.add(new EnglishFragment());
|
||||||
mFragments.add(new CustomFragment());
|
mFragments.add(new PhysicsFragment());
|
||||||
mFragments.add(new CustomFragment());
|
mFragments.add(new ChemicalFragment());
|
||||||
mFragments.add(new CustomFragment());
|
mFragments.add(new BiologyFragment());
|
||||||
mFragments.add(new CustomFragment());
|
mFragments.add(new ChineseFragment());
|
||||||
|
|
||||||
scaleCircleNavigator = new ScaleCircleNavigator(this);
|
scaleCircleNavigator = new ScaleCircleNavigator(this);
|
||||||
scaleCircleNavigator.setCircleCount(mFragments.size());
|
scaleCircleNavigator.setCircleCount(mFragments.size());
|
||||||
@@ -129,36 +129,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
|||||||
registmNewAppReceiver();
|
registmNewAppReceiver();
|
||||||
registerSOSNumberReceiver();
|
registerSOSNumberReceiver();
|
||||||
registerUpdateDesktopReceiver();
|
registerUpdateDesktopReceiver();
|
||||||
mAlarmServiceConnection = new ServiceConnection() {
|
|
||||||
@Override
|
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
|
||||||
Log.e(TAG, "onServiceConnected: ");
|
|
||||||
mIAlarmAidlInterface = IAlarmAidlInterface.Stub.asInterface(service);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
|
||||||
Log.e(TAG, "onServiceDisconnected: ");
|
|
||||||
mIAlarmAidlInterface = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
bindAlarmService();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ServiceConnection mAlarmServiceConnection;
|
|
||||||
private IAlarmAidlInterface mIAlarmAidlInterface;
|
|
||||||
|
|
||||||
private void bindAlarmService() {
|
|
||||||
if (mIAlarmAidlInterface == null) {
|
|
||||||
//这是连接aidl服务的代码
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.setAction("com.alarmclock.uiui.IAlarmAidlInterface");
|
|
||||||
intent.setPackage("com.alarmclock.uiui");
|
|
||||||
intent.setComponent(new ComponentName("com.alarmclock.uiui", "com.alarmclock.uiui.AIDLAlarmService"));
|
|
||||||
bindService(intent, mAlarmServiceConnection, Context.BIND_AUTO_CREATE);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toggleNotificationListenerService(Context context) {
|
public static void toggleNotificationListenerService(Context context) {
|
||||||
@@ -171,9 +141,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
|||||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
||||||
public void onWindowFocusChanged(boolean hasFocus) {
|
public void onWindowFocusChanged(boolean hasFocus) {
|
||||||
super.onWindowFocusChanged(hasFocus);
|
super.onWindowFocusChanged(hasFocus);
|
||||||
if (hasFocus) {//表示渲染结束
|
if (hasFocus) {//表示渲染结束
|
||||||
@@ -254,7 +222,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
|||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
Log.e(TAG, "onStop: ");
|
Log.e(TAG, "onStop: ");
|
||||||
AppUsedTimeUtils.getInstance().setEndTime(System.currentTimeMillis());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -291,13 +258,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
|||||||
ToastUtil.show("请授予\"" + getString(R.string.app_name) + "\"使用通知权");
|
ToastUtil.show("请授予\"" + getString(R.string.app_name) + "\"使用通知权");
|
||||||
gotoNotificationAccessSetting(this);
|
gotoNotificationAccessSetting(this);
|
||||||
}
|
}
|
||||||
int is_activation = Settings.Global.getInt(getContentResolver(), CommonConfig.UIUI_ACTIVATION_KEY, 0);
|
|
||||||
Log.e(TAG, "onResume: is_activation = " + is_activation);
|
|
||||||
if (is_activation == 1) {
|
|
||||||
LauncherUtils.setDefaultDesktop(MainActivity.this, BuildConfig.APPLICATION_ID, this.getClass().getName());
|
|
||||||
} else {
|
|
||||||
LauncherUtils.setDefaultDesktop(MainActivity.this, LauncherUtils.Launcher3, LauncherUtils.Launcher3Class);
|
|
||||||
}
|
|
||||||
addHomeWatcher();
|
addHomeWatcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,15 +290,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
|||||||
public void onHomePressed() {
|
public void onHomePressed() {
|
||||||
//按了HOME键
|
//按了HOME键
|
||||||
Log.e(TAG, "onHomePressed: ");
|
Log.e(TAG, "onHomePressed: ");
|
||||||
int is_activation = Settings.Global.getInt(getContentResolver(), CommonConfig.UIUI_ACTIVATION_KEY, 0);
|
|
||||||
Log.e(TAG, "onHomePressed: is_activation = " + is_activation);
|
|
||||||
if (is_activation == 0) {
|
|
||||||
LauncherUtils.openLauncher3(MainActivity.this);
|
|
||||||
} else {
|
|
||||||
if (!LauncherUtils.isDefaultHome(MainActivity.this)) {
|
|
||||||
LauncherUtils.setDefaultDesktop(MainActivity.this, BuildConfig.APPLICATION_ID, this.getClass().getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
package com.uiui.zyos.alarm;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
|
||||||
import android.os.Environment;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class AlarmOpenHelper extends SQLiteOpenHelper {
|
|
||||||
|
|
||||||
public static final int DATABASE_VERSION = 1;
|
|
||||||
public static final String DATABASE_NAME = "AlarmDatabase.db";
|
|
||||||
public static final String DATABASE_FILE_NAME = Environment.getExternalStorageDirectory().getPath() + File.separator + DATABASE_NAME;
|
|
||||||
|
|
||||||
public static final String TABLE_ALARM = " AlarmTable";
|
|
||||||
|
|
||||||
public static final String KEY_ID = "id";
|
|
||||||
public static final String KEY_TYPE = "type";
|
|
||||||
public static final String KEY_TIME = "time";
|
|
||||||
public static final String KEY_TITLE = "title";
|
|
||||||
public static final String KEY_VOICE = "voice";
|
|
||||||
public static final String KEY_VOICE_MD5 = "voice_md5";
|
|
||||||
public static final String KEY_FILE = "file";
|
|
||||||
public static final String KEY_REMIND_TYPE = "remind_type";
|
|
||||||
public static final String KEY_IS_ONOFF = "is_onoff";
|
|
||||||
public static final String KEY_FINISHED = "finished";
|
|
||||||
|
|
||||||
String CREATE_ALARM_TABLE = "CREATE TABLE IF NOT EXISTS" + TABLE_ALARM +
|
|
||||||
"("
|
|
||||||
+ KEY_ID + " INTEGER PRIMARY KEY,"
|
|
||||||
+ KEY_TYPE + " INTEGER,"
|
|
||||||
+ KEY_TIME + " TEXT,"
|
|
||||||
+ KEY_TITLE + " TEXT,"
|
|
||||||
+ KEY_VOICE + " TEXT,"
|
|
||||||
+ KEY_VOICE_MD5 + " TEXT,"
|
|
||||||
+ KEY_FILE + " TEXT,"
|
|
||||||
+ KEY_REMIND_TYPE + " INTEGER,"
|
|
||||||
+ KEY_IS_ONOFF + " INTEGER,"
|
|
||||||
+ KEY_FINISHED + " BOOLEAN DEFAULT 0"
|
|
||||||
+ ")";
|
|
||||||
|
|
||||||
public AlarmOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
|
|
||||||
super(context, name, factory, version);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(SQLiteDatabase db) {
|
|
||||||
db.execSQL(CREATE_ALARM_TABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
|
||||||
if (oldVersion >= newVersion) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + TABLE_ALARM);
|
|
||||||
onCreate(db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.uiui.zyos.alarm;
|
|
||||||
|
|
||||||
import android.app.Service;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.IBinder;
|
|
||||||
|
|
||||||
public class AlarmService extends Service {
|
|
||||||
public AlarmService() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBinder onBind(Intent intent) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,670 +0,0 @@
|
|||||||
package com.uiui.zyos.alarm;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.AlarmManager;
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.content.ContentValues;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.arialyy.aria.core.Aria;
|
|
||||||
import com.blankj.utilcode.util.FileUtils;
|
|
||||||
import com.bumptech.glide.Glide;
|
|
||||||
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;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
public class AlarmUtils {
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
|
||||||
private static AlarmUtils sInstance;
|
|
||||||
private static String TAG = AlarmUtils.class.getSimpleName();
|
|
||||||
private Context mContext;
|
|
||||||
private AlarmManager alarmManager;
|
|
||||||
private SQLiteDatabase db;
|
|
||||||
private AlarmOpenHelper mAlarmOpenHelper;
|
|
||||||
|
|
||||||
public static final int ONE_DAY_TIME = 1000 * 60 * 60 * 24;
|
|
||||||
|
|
||||||
|
|
||||||
private AlarmUtils(Context context) {
|
|
||||||
this.mContext = context;
|
|
||||||
// this.mAlarmOpenHelper = new AlarmOpenHelper(context, AlarmOpenHelper.DATABASE_NAME, null, AlarmOpenHelper.DATABASE_VERSION);
|
|
||||||
this.mAlarmOpenHelper = new AlarmOpenHelper(context, AlarmOpenHelper.DATABASE_FILE_NAME, null, AlarmOpenHelper.DATABASE_VERSION);
|
|
||||||
this.db = mAlarmOpenHelper.getWritableDatabase();
|
|
||||||
alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void init(Context context) {
|
|
||||||
if (context == null) {
|
|
||||||
throw new RuntimeException("context is NULL");
|
|
||||||
}
|
|
||||||
if (sInstance == null) {
|
|
||||||
sInstance = new AlarmUtils(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AlarmUtils getInstance() {
|
|
||||||
if (sInstance == null) {
|
|
||||||
throw new IllegalStateException("You must be init AmapManager first");
|
|
||||||
}
|
|
||||||
return sInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void open() {
|
|
||||||
if (db == null || !db.isOpen()) {
|
|
||||||
db = mAlarmOpenHelper.getWritableDatabase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 增加数据
|
|
||||||
*
|
|
||||||
* @param alarmClockData
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean addAlarmClock(AlarmClockData alarmClockData) {
|
|
||||||
open();
|
|
||||||
ContentValues values = new ContentValues();
|
|
||||||
values.put(AlarmOpenHelper.KEY_ID, alarmClockData.getId());
|
|
||||||
values.put(AlarmOpenHelper.KEY_TYPE, alarmClockData.getType());
|
|
||||||
values.put(AlarmOpenHelper.KEY_TIME, alarmClockData.getTime());
|
|
||||||
values.put(AlarmOpenHelper.KEY_TITLE, alarmClockData.getTitle());
|
|
||||||
values.put(AlarmOpenHelper.KEY_VOICE, alarmClockData.getVoice());
|
|
||||||
values.put(AlarmOpenHelper.KEY_VOICE_MD5, alarmClockData.getVoice_md5());
|
|
||||||
values.put(AlarmOpenHelper.KEY_FILE, alarmClockData.getFile());
|
|
||||||
values.put(AlarmOpenHelper.KEY_REMIND_TYPE, alarmClockData.getRemind_type());
|
|
||||||
values.put(AlarmOpenHelper.KEY_IS_ONOFF, alarmClockData.getIs_onoff());
|
|
||||||
long id = 0;
|
|
||||||
db.beginTransaction();
|
|
||||||
try {
|
|
||||||
id = db.insert(AlarmOpenHelper.TABLE_ALARM, null, values);
|
|
||||||
} catch (Exception e) {
|
|
||||||
db.setTransactionSuccessful();
|
|
||||||
} finally {
|
|
||||||
db.endTransaction();
|
|
||||||
}
|
|
||||||
db.close();
|
|
||||||
return id > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新数据
|
|
||||||
*
|
|
||||||
* @param alarmClockData
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean updateAlarmClock(AlarmClockData alarmClockData) {
|
|
||||||
open();
|
|
||||||
ContentValues values = new ContentValues();
|
|
||||||
values.put(AlarmOpenHelper.KEY_ID, alarmClockData.getId());
|
|
||||||
values.put(AlarmOpenHelper.KEY_TYPE, alarmClockData.getType());
|
|
||||||
values.put(AlarmOpenHelper.KEY_TIME, alarmClockData.getTime());
|
|
||||||
values.put(AlarmOpenHelper.KEY_TITLE, alarmClockData.getTitle());
|
|
||||||
values.put(AlarmOpenHelper.KEY_VOICE, alarmClockData.getVoice());
|
|
||||||
values.put(AlarmOpenHelper.KEY_VOICE_MD5, alarmClockData.getVoice_md5());
|
|
||||||
values.put(AlarmOpenHelper.KEY_FILE, alarmClockData.getFile());
|
|
||||||
values.put(AlarmOpenHelper.KEY_REMIND_TYPE, alarmClockData.getRemind_type());
|
|
||||||
values.put(AlarmOpenHelper.KEY_IS_ONOFF, alarmClockData.getIs_onoff());
|
|
||||||
long id = 0;
|
|
||||||
db.beginTransaction();
|
|
||||||
try {
|
|
||||||
id = db.insertWithOnConflict(AlarmOpenHelper.TABLE_ALARM, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
|
||||||
db.setTransactionSuccessful();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "updateAlarmClock: " + e.getMessage());
|
|
||||||
} finally {
|
|
||||||
db.endTransaction();
|
|
||||||
}
|
|
||||||
db.close();
|
|
||||||
return id > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入数据
|
|
||||||
*
|
|
||||||
* @param list
|
|
||||||
*/
|
|
||||||
public void insertListValues(List<AlarmClockData> list) {
|
|
||||||
open();
|
|
||||||
List<ContentValues> contentValuesList = new ArrayList<>();
|
|
||||||
for (AlarmClockData alarmClockData : list) {
|
|
||||||
ContentValues values = new ContentValues();
|
|
||||||
values.put(AlarmOpenHelper.KEY_ID, alarmClockData.getId());
|
|
||||||
values.put(AlarmOpenHelper.KEY_TYPE, alarmClockData.getType());
|
|
||||||
values.put(AlarmOpenHelper.KEY_TIME, alarmClockData.getTime());
|
|
||||||
values.put(AlarmOpenHelper.KEY_TITLE, alarmClockData.getTitle());
|
|
||||||
values.put(AlarmOpenHelper.KEY_VOICE, alarmClockData.getVoice());
|
|
||||||
values.put(AlarmOpenHelper.KEY_VOICE_MD5, alarmClockData.getVoice_md5());
|
|
||||||
values.put(AlarmOpenHelper.KEY_FILE, alarmClockData.getFile());
|
|
||||||
values.put(AlarmOpenHelper.KEY_REMIND_TYPE, alarmClockData.getRemind_type());
|
|
||||||
values.put(AlarmOpenHelper.KEY_IS_ONOFF, alarmClockData.getIs_onoff());
|
|
||||||
values.put(AlarmOpenHelper.KEY_FINISHED, alarmClockData.isFinished());
|
|
||||||
contentValuesList.add(values);
|
|
||||||
}
|
|
||||||
db.beginTransaction();
|
|
||||||
try {
|
|
||||||
for (ContentValues v : contentValuesList) {
|
|
||||||
db.insertWithOnConflict(AlarmOpenHelper.TABLE_ALARM, null, v, SQLiteDatabase.CONFLICT_REPLACE);
|
|
||||||
}
|
|
||||||
db.setTransactionSuccessful();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "insertListValues: " + e.getMessage());
|
|
||||||
} finally {
|
|
||||||
db.endTransaction();
|
|
||||||
}
|
|
||||||
db.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除数据
|
|
||||||
*
|
|
||||||
* @param alarmClockData
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean deleteAlarmClock(AlarmClockData alarmClockData) {
|
|
||||||
if (alarmClockData == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return deleteAlarmClock(alarmClockData.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean deleteAlarmClock(int RowID) {
|
|
||||||
open();
|
|
||||||
long id = 0;
|
|
||||||
db.beginTransaction();
|
|
||||||
try {
|
|
||||||
id = db.delete(AlarmOpenHelper.TABLE_ALARM, "id =" + RowID, null);
|
|
||||||
db.setTransactionSuccessful();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "deleteAlarmClock: " + e.getMessage());
|
|
||||||
} finally {
|
|
||||||
db.endTransaction();
|
|
||||||
}
|
|
||||||
db.close();
|
|
||||||
return id > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteAllAlarmClock() {
|
|
||||||
HashSet<PendingIntent> pendingIntents = getOldPendingIntents();
|
|
||||||
Iterator<PendingIntent> pendingIntentIterator = pendingIntents.iterator();
|
|
||||||
while (pendingIntentIterator.hasNext()) {
|
|
||||||
PendingIntent pendingIntent = pendingIntentIterator.next();
|
|
||||||
alarmManager.cancel(pendingIntent);
|
|
||||||
pendingIntentIterator.remove();
|
|
||||||
}
|
|
||||||
List<AlarmClockData> alarmClockData = getAllAlarms();
|
|
||||||
for (AlarmClockData data : alarmClockData) {
|
|
||||||
deleteAlarmClock(data.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取所有Alarm
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public List<AlarmClockData> getAllAlarms() {
|
|
||||||
open();
|
|
||||||
List<AlarmClockData> list = new ArrayList<>();
|
|
||||||
String selectQuery = "SELECT * FROM " + AlarmOpenHelper.TABLE_ALARM;
|
|
||||||
open();
|
|
||||||
Cursor cursor = db.rawQuery(selectQuery, null);
|
|
||||||
if (cursor.moveToFirst()) {
|
|
||||||
do {
|
|
||||||
AlarmClockData alarmClockData = new AlarmClockData();
|
|
||||||
alarmClockData.setId(Integer.parseInt(cursor.getString(0)));
|
|
||||||
alarmClockData.setType(cursor.getInt(1));
|
|
||||||
alarmClockData.setTime(cursor.getString(2));
|
|
||||||
alarmClockData.setTitle(cursor.getString(3));
|
|
||||||
alarmClockData.setVoice(cursor.getString(4));
|
|
||||||
alarmClockData.setVoice_md5(cursor.getString(5));
|
|
||||||
alarmClockData.setFile(cursor.getString(6));
|
|
||||||
alarmClockData.setRemind_type(cursor.getInt(7));
|
|
||||||
alarmClockData.setIs_onoff(cursor.getInt(8));
|
|
||||||
if (cursor.getInt(9) == 1) {
|
|
||||||
alarmClockData.setFinished(true);
|
|
||||||
} else {
|
|
||||||
alarmClockData.setFinished(false);
|
|
||||||
}
|
|
||||||
list.add(alarmClockData);
|
|
||||||
} while (cursor.moveToNext());
|
|
||||||
}
|
|
||||||
cursor.close();
|
|
||||||
db.close();
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private HashSet<PendingIntent> pendingIntents;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置闹钟列表
|
|
||||||
*
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
public void setAlarmClockData(List<AlarmClockData> data) {
|
|
||||||
if (pendingIntents == null) {
|
|
||||||
pendingIntents = getOldPendingIntents();
|
|
||||||
}
|
|
||||||
Iterator<PendingIntent> pendingIntentIterator = pendingIntents.iterator();
|
|
||||||
while (pendingIntentIterator.hasNext()) {
|
|
||||||
PendingIntent pendingIntent = pendingIntentIterator.next();
|
|
||||||
alarmManager.cancel(pendingIntent);
|
|
||||||
pendingIntentIterator.remove();
|
|
||||||
}
|
|
||||||
// for (PendingIntent pendingIntent : pendingIntents) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
List<AlarmClockData> newData = mergeData(data);
|
|
||||||
for (AlarmClockData clockData : newData) {
|
|
||||||
setAlarm(clockData);
|
|
||||||
checkResource(clockData.getFile());
|
|
||||||
}
|
|
||||||
insertListValues(newData);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkResource(String url) {
|
|
||||||
if (TextUtils.isEmpty(url))
|
|
||||||
return;
|
|
||||||
String fileName = url.substring(url.lastIndexOf("/") + 1, url.length());
|
|
||||||
if (FileUtil.isVideoFile(fileName)) {
|
|
||||||
String realPath = Utils.getDownLoadPath(mContext) + fileName;
|
|
||||||
File file = new File(realPath);
|
|
||||||
if (!file.exists()) {
|
|
||||||
Aria.download(this)
|
|
||||||
.load(url) //读取下载地址
|
|
||||||
.setFilePath(Utils.getDownLoadPath(mContext) + fileName)
|
|
||||||
// .ignoreFilePathOccupy()
|
|
||||||
.create(); //启动下载}
|
|
||||||
}
|
|
||||||
}else if (FileUtil.isPictureFile(fileName)){
|
|
||||||
Glide.with(mContext).load(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 合并闹钟列表,删除不存在闹钟
|
|
||||||
*
|
|
||||||
* @param alarmClockDataList
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private List<AlarmClockData> mergeData(List<AlarmClockData> alarmClockDataList) {
|
|
||||||
HashMap<Integer, AlarmClockData> alarmClockDataMap = new HashMap<>();
|
|
||||||
if (alarmClockDataList != null) {
|
|
||||||
for (AlarmClockData alarmClockData : alarmClockDataList) {
|
|
||||||
alarmClockDataMap.put(alarmClockData.getId(), alarmClockData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
HashMap<Integer, AlarmClockData> oldData = getOldData();
|
|
||||||
List<AlarmClockData> deleteData = new ArrayList<>();
|
|
||||||
for (Map.Entry<Integer, AlarmClockData> entry : oldData.entrySet()) {
|
|
||||||
if (alarmClockDataMap.get(entry.getKey()) == null) {
|
|
||||||
deleteData.add(entry.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (AlarmClockData alarmClockData : deleteData) {
|
|
||||||
deleteAlarmClock(alarmClockData);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<AlarmClockData> newData = new ArrayList<>();
|
|
||||||
if (alarmClockDataList == null) {
|
|
||||||
return newData;
|
|
||||||
}
|
|
||||||
for (AlarmClockData alarm : alarmClockDataList) {
|
|
||||||
AlarmClockData oldAlarm = oldData.get(alarm.getId());
|
|
||||||
if (oldAlarm == null) {
|
|
||||||
newData.add(alarm);
|
|
||||||
} else {
|
|
||||||
if (oldAlarm.equals(alarm)) {
|
|
||||||
newData.add(oldAlarm);
|
|
||||||
} else {
|
|
||||||
newData.add(alarm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return newData;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新完成状态
|
|
||||||
*
|
|
||||||
* @param alarmClockData
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean updateAlarmFinished(AlarmClockData alarmClockData) {
|
|
||||||
open();
|
|
||||||
ContentValues values = new ContentValues();
|
|
||||||
values.put(AlarmOpenHelper.KEY_ID, alarmClockData.getId());
|
|
||||||
values.put(AlarmOpenHelper.KEY_TYPE, alarmClockData.getType());
|
|
||||||
values.put(AlarmOpenHelper.KEY_TIME, alarmClockData.getTime());
|
|
||||||
values.put(AlarmOpenHelper.KEY_TITLE, alarmClockData.getTitle());
|
|
||||||
values.put(AlarmOpenHelper.KEY_VOICE, alarmClockData.getVoice());
|
|
||||||
values.put(AlarmOpenHelper.KEY_VOICE_MD5, alarmClockData.getVoice_md5());
|
|
||||||
values.put(AlarmOpenHelper.KEY_FILE, alarmClockData.getFile());
|
|
||||||
values.put(AlarmOpenHelper.KEY_REMIND_TYPE, alarmClockData.getRemind_type());
|
|
||||||
values.put(AlarmOpenHelper.KEY_IS_ONOFF, alarmClockData.getIs_onoff());
|
|
||||||
values.put(AlarmOpenHelper.KEY_FINISHED, alarmClockData.isFinished());
|
|
||||||
long id = 0;
|
|
||||||
db.beginTransaction();
|
|
||||||
try {
|
|
||||||
id = db.update(AlarmOpenHelper.TABLE_ALARM, values, AlarmOpenHelper.KEY_ID + "=?", new String[]{String.valueOf(alarmClockData.getId())});
|
|
||||||
db.setTransactionSuccessful();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "updateAlarmFinished: " + e.getMessage());
|
|
||||||
} finally {
|
|
||||||
db.endTransaction();
|
|
||||||
}
|
|
||||||
db.close();
|
|
||||||
return id > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<Integer, AlarmClockData> getOldData() {
|
|
||||||
List<AlarmClockData> alarmClockData = getAllAlarms();
|
|
||||||
if (alarmClockData == null || alarmClockData.size() == 0) {
|
|
||||||
return new HashMap<>();
|
|
||||||
} else {
|
|
||||||
HashMap<Integer, AlarmClockData> hashMap = new HashMap<>();
|
|
||||||
for (AlarmClockData clockData : alarmClockData) {
|
|
||||||
hashMap.put(clockData.getId(), clockData);
|
|
||||||
}
|
|
||||||
return hashMap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取最近一次的闹钟
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public AlarmClockData getRecentAlarmClock() {
|
|
||||||
List<AlarmClockData> alarmClockData = getAllAlarms();
|
|
||||||
if (alarmClockData == null || alarmClockData.size() == 0) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
Collections.sort(alarmClockData, new Comparator<AlarmClockData>() {
|
|
||||||
@Override
|
|
||||||
public int compare(AlarmClockData o1, AlarmClockData o2) {
|
|
||||||
if ((o1.getTimeStamp()) <= (o2.getTimeStamp())) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return alarmClockData.get(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private HashSet<PendingIntent> getOldPendingIntents() {
|
|
||||||
HashSet<PendingIntent> pendingIntents = new HashSet<>();
|
|
||||||
HashMap<Integer, AlarmClockData> data = getOldData();
|
|
||||||
for (AlarmClockData alarmClockData : data.values()) {
|
|
||||||
pendingIntents.add(getPendingIntent(alarmClockData));
|
|
||||||
}
|
|
||||||
return pendingIntents;
|
|
||||||
}
|
|
||||||
|
|
||||||
private PendingIntent getPendingIntent(AlarmClockData alarmClock) {
|
|
||||||
Intent intent = new Intent(MainService.ALARMWAKEUP);
|
|
||||||
intent.putExtra("title", alarmClock.getTitle());
|
|
||||||
intent.putExtra("id", alarmClock.getId());
|
|
||||||
PendingIntent startPendingIntent = PendingIntent.getBroadcast(mContext, alarmClock.getId(), intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
|
||||||
return startPendingIntent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private long getTimestamp(String timeString) {
|
|
||||||
if (TextUtils.isEmpty(timeString)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (timeString.length() == 5) {
|
|
||||||
String[] timeSplit = timeString.split(":");
|
|
||||||
int hour = Integer.parseInt(timeSplit[0]);
|
|
||||||
int minute = Integer.parseInt(timeSplit[1]);
|
|
||||||
Calendar c = Calendar.getInstance();
|
|
||||||
int year = c.get(Calendar.YEAR);
|
|
||||||
int month = c.get(Calendar.MONTH);
|
|
||||||
int day = c.get(Calendar.DAY_OF_MONTH);
|
|
||||||
c.set(year, month, day, hour, minute, 0);
|
|
||||||
long mTimeInfo = c.getTimeInMillis();
|
|
||||||
Log.e(TAG, "getTimestamp: " + mTimeInfo);
|
|
||||||
// long actualTime = mTimeInfo > System.currentTimeMillis() ? mTimeInfo : mTimeInfo + ONE_DAY_TIME;
|
|
||||||
return mTimeInfo;
|
|
||||||
} else {
|
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
||||||
try {
|
|
||||||
Date date = simpleDateFormat.parse(timeString);
|
|
||||||
long timestamp = date.getTime();
|
|
||||||
Log.e(TAG, "getTimestamp2: " + timestamp);
|
|
||||||
return timestamp;
|
|
||||||
} catch (ParseException e) {
|
|
||||||
return System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private long getZeroTiemstamp() {
|
|
||||||
//设置时区
|
|
||||||
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+8"));
|
|
||||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
||||||
calendar.set(Calendar.MINUTE, 0);
|
|
||||||
calendar.set(Calendar.SECOND, 0);
|
|
||||||
long zeroTime = calendar.getTimeInMillis();
|
|
||||||
Log.e(TAG, "getZeroTiemstamp: " + zeroTime);
|
|
||||||
return zeroTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*一次性*/
|
|
||||||
public static final int ONCE = 1;
|
|
||||||
/*每天*/
|
|
||||||
public static final int LOOP = 2;
|
|
||||||
/*周一到周五*/
|
|
||||||
public static final int WORKING_DAY = 3;
|
|
||||||
/*休息日*/
|
|
||||||
public static final int OFF_DAY = 4;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置闹钟
|
|
||||||
*
|
|
||||||
* @param alarm
|
|
||||||
*/
|
|
||||||
public void setAlarm(AlarmClockData alarm) {
|
|
||||||
int id = alarm.getId();
|
|
||||||
int type = alarm.getType();
|
|
||||||
String timeString = alarm.getTime();
|
|
||||||
String title = alarm.getTitle();
|
|
||||||
Log.e(TAG, "setAlarm: " + title);
|
|
||||||
long timeStamp = getTimestamp(timeString);
|
|
||||||
Log.e(TAG, "setAlarm: " + timeStamp);
|
|
||||||
boolean finished = alarm.isFinished();
|
|
||||||
String url = alarm.getVoice();
|
|
||||||
String md5 = alarm.getVoice_md5();
|
|
||||||
if (!TextUtils.isEmpty(url)) {
|
|
||||||
ariaDownload(url, md5);
|
|
||||||
}
|
|
||||||
switch (type) {
|
|
||||||
case ONCE:
|
|
||||||
if (!finished) {
|
|
||||||
if (timeStamp < System.currentTimeMillis()) {
|
|
||||||
Intent intent = new Intent(MainService.ALARMWAKEUP);
|
|
||||||
intent.putExtra("title", title);
|
|
||||||
intent.putExtra("id", id);
|
|
||||||
mContext.sendBroadcast(intent);
|
|
||||||
} else {
|
|
||||||
setOnceAlarm(MainService.ALARMWAKEUP, title, id, timeStamp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case LOOP:
|
|
||||||
setDayLoopAlarm(MainService.ALARMWAKEUP, title, id, timeString);
|
|
||||||
break;
|
|
||||||
case WORKING_DAY:
|
|
||||||
setWorkDayAlarm(MainService.ALARMWAKEUP, title, id, timeString);
|
|
||||||
break;
|
|
||||||
case OFF_DAY:
|
|
||||||
setOffDayAlarm(MainService.ALARMWAKEUP, title, id, timeString);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param action
|
|
||||||
* @param requestCode
|
|
||||||
* @param timestamp 设置一次性闹钟
|
|
||||||
*/
|
|
||||||
public void setOnceAlarm(String action, String extra, int requestCode, long timestamp) {
|
|
||||||
Intent intent = new Intent(action);
|
|
||||||
intent.putExtra("title", extra);
|
|
||||||
intent.putExtra("id", requestCode);
|
|
||||||
PendingIntent startPendingIntent = PendingIntent.getBroadcast(mContext, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
|
||||||
pendingIntents.add(startPendingIntent);
|
|
||||||
alarmManager.setAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, timestamp, startPendingIntent);
|
|
||||||
Log.e(TAG, "setOnceAlarm: " + "id: " + requestCode + " title: " + extra + " timeString: " + timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param action
|
|
||||||
* @param requestCode
|
|
||||||
* @param timeString 设置循环周期为一天的闹钟
|
|
||||||
*/
|
|
||||||
public void setDayLoopAlarm(String action, String extra, int requestCode, String timeString) {
|
|
||||||
long timestamp = getTimestamp(timeString);
|
|
||||||
if (System.currentTimeMillis() > timestamp) {
|
|
||||||
timestamp += AlarmManager.INTERVAL_DAY;
|
|
||||||
}
|
|
||||||
Intent intent = new Intent(action);
|
|
||||||
intent.putExtra("title", extra);
|
|
||||||
intent.putExtra("id", requestCode);
|
|
||||||
PendingIntent startPendingIntent = PendingIntent.getBroadcast(mContext, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
|
||||||
pendingIntents.add(startPendingIntent);
|
|
||||||
alarmManager.setExact(AlarmManager.RTC_WAKEUP, timestamp, startPendingIntent);
|
|
||||||
Log.e(TAG, "setDayLoopAlarm: " + "title: " + extra + " timeString: " + timestamp);
|
|
||||||
// setLoopAlarm(action, extra, requestCode, AlarmManager.INTERVAL_DAY, timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param action
|
|
||||||
* @param requestCode
|
|
||||||
* @param timestamp 设置循环周期为一小时的闹钟
|
|
||||||
*/
|
|
||||||
public void setHourLoopAlarm(String action, String extra, int requestCode, long timestamp) {
|
|
||||||
setLoopAlarm(action, extra, requestCode, AlarmManager.INTERVAL_HOUR, timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param action
|
|
||||||
* @param requestCode
|
|
||||||
* @param intervalMillis
|
|
||||||
* @param timestamp 循环闹钟
|
|
||||||
*/
|
|
||||||
public void setLoopAlarm(String action, String extra, int requestCode, long intervalMillis, long timestamp) {
|
|
||||||
Intent intent = new Intent(action);
|
|
||||||
intent.putExtra("title", extra);
|
|
||||||
intent.putExtra("id", requestCode);
|
|
||||||
PendingIntent startPendingIntent = PendingIntent.getBroadcast(mContext, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
|
||||||
pendingIntents.add(startPendingIntent);
|
|
||||||
alarmManager.setWindow(AlarmManager.RTC_WAKEUP, timestamp, intervalMillis, startPendingIntent);
|
|
||||||
Log.e(TAG, "setLoopAlarm: " + "title: " + extra + " timeString: " + timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWorkDayAlarm(String action, String extra, int requestCode, String timeString) {
|
|
||||||
long timestamp = getTimestamp(timeString);
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
int day_of_week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
|
||||||
switch (day_of_week) {
|
|
||||||
case 6:
|
|
||||||
case 7:
|
|
||||||
timestamp += (8 - day_of_week) * AlarmManager.INTERVAL_DAY;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (System.currentTimeMillis() > timestamp) {
|
|
||||||
timestamp += AlarmManager.INTERVAL_DAY;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Intent intent = new Intent(action);
|
|
||||||
intent.putExtra("title", extra);
|
|
||||||
intent.putExtra("id", requestCode);
|
|
||||||
PendingIntent startPendingIntent = PendingIntent.getBroadcast(mContext, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
|
||||||
pendingIntents.add(startPendingIntent);
|
|
||||||
alarmManager.setExact(AlarmManager.RTC_WAKEUP, timestamp, startPendingIntent);
|
|
||||||
Log.e(TAG, "setWorkDayAlarm: " + "title: " + extra + " timeString: " + timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOffDayAlarm(String action, String extra, int requestCode, String timeString) {
|
|
||||||
long timestamp = getTimestamp(timeString);
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
int day_of_week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
|
||||||
switch (day_of_week) {
|
|
||||||
case 6:
|
|
||||||
if (System.currentTimeMillis() > timestamp) {
|
|
||||||
timestamp += AlarmManager.INTERVAL_DAY;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
timestamp += (6 - day_of_week) * AlarmManager.INTERVAL_DAY;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Intent intent = new Intent(action);
|
|
||||||
intent.putExtra("title", extra);
|
|
||||||
intent.putExtra("id", requestCode);
|
|
||||||
PendingIntent startPendingIntent = PendingIntent.getBroadcast(mContext, requestCode, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
|
||||||
pendingIntents.add(startPendingIntent);
|
|
||||||
alarmManager.setExact(AlarmManager.RTC_WAKEUP, timestamp, startPendingIntent);
|
|
||||||
Log.e(TAG, "setOffDayAlarm: " + "title: " + extra + " timeString: " + timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void ariaDownload(String url, String md5) {
|
|
||||||
String fileName = Utils.getFileNamefromURL(url);
|
|
||||||
File file = new File(Utils.getDownLoadPath(mContext) + fileName);
|
|
||||||
if (file.exists() && !file.isDirectory()) {
|
|
||||||
String fileMD5 = FileUtils.getFileMD5ToString(file);
|
|
||||||
Log.e("ariaDownload", "fileOnlineMD5=" + md5);
|
|
||||||
Log.e("ariaDownload", "fileMD5=" + fileMD5);
|
|
||||||
if (!md5.equals(fileMD5)) {
|
|
||||||
Aria.download(this)
|
|
||||||
.load(url) //读取下载地址
|
|
||||||
.setFilePath(Utils.getDownLoadPath(mContext) + fileName)
|
|
||||||
// .ignoreFilePathOccupy()
|
|
||||||
.setExtendField(md5)
|
|
||||||
.create(); //启动下载}
|
|
||||||
} else {
|
|
||||||
Log.e("ariaDownload", "fileName = " + fileName + " exists");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Aria.download(this)
|
|
||||||
.load(url) //读取下载地址
|
|
||||||
.setFilePath(Utils.getDownLoadPath(mContext) + fileName)
|
|
||||||
// .ignoreFilePathOccupy()
|
|
||||||
.setExtendField(md5)
|
|
||||||
.create(); //启动下载}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -12,12 +12,10 @@ import com.tencent.android.tpush.XGPushConfig;
|
|||||||
import com.tencent.android.tpush.XGPushManager;
|
import com.tencent.android.tpush.XGPushManager;
|
||||||
import com.tencent.mmkv.MMKV;
|
import com.tencent.mmkv.MMKV;
|
||||||
import com.uiui.zyos.BuildConfig;
|
import com.uiui.zyos.BuildConfig;
|
||||||
import com.uiui.zyos.alarm.AlarmUtils;
|
|
||||||
import com.uiui.zyos.manager.ConnectManager;
|
import com.uiui.zyos.manager.ConnectManager;
|
||||||
import com.uiui.zyos.manager.RemoteManager;
|
import com.uiui.zyos.manager.RemoteManager;
|
||||||
import com.uiui.zyos.network.NetInterfaceManager;
|
import com.uiui.zyos.network.NetInterfaceManager;
|
||||||
import com.uiui.zyos.service.main.MainService;
|
import com.uiui.zyos.service.main.MainService;
|
||||||
import com.uiui.zyos.utils.AppUsedTimeUtils;
|
|
||||||
import com.uiui.zyos.utils.SystemUtils;
|
import com.uiui.zyos.utils.SystemUtils;
|
||||||
import com.uiui.zyos.utils.Utils;
|
import com.uiui.zyos.utils.Utils;
|
||||||
|
|
||||||
@@ -43,8 +41,6 @@ public class BaseApplication extends Application {
|
|||||||
Aria.init(this);
|
Aria.init(this);
|
||||||
Aria.get(this).getDownloadConfig().setMaxTaskNum(1);
|
Aria.get(this).getDownloadConfig().setMaxTaskNum(1);
|
||||||
Aria.get(this).getDownloadConfig().setConvertSpeed(true);
|
Aria.get(this).getDownloadConfig().setConvertSpeed(true);
|
||||||
AppUsedTimeUtils.init(this);
|
|
||||||
AlarmUtils.init(this);
|
|
||||||
tpushInit();
|
tpushInit();
|
||||||
RemoteManager.init(this);
|
RemoteManager.init(this);
|
||||||
ConnectManager.init(this);
|
ConnectManager.init(this);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.uiui.zyos.view;
|
package com.uiui.zyos.base;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.uiui.zyos.view;
|
package com.uiui.zyos.base;
|
||||||
|
|
||||||
|
|
||||||
// add by codemx.cn ---- 20190712 ---plus- start
|
// add by codemx.cn ---- 20190712 ---plus- start
|
||||||
@@ -1,164 +0,0 @@
|
|||||||
package com.uiui.zyos.bean;
|
|
||||||
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import com.uiui.zyos.alarm.AlarmUtils;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class AlarmClockData implements Serializable {
|
|
||||||
private static final long serialVersionUID = -5856502480745183157L;
|
|
||||||
|
|
||||||
int id;
|
|
||||||
int type;//类型 1一次 2循环 3周一到周五 4 周六周日
|
|
||||||
String time;//"2021-11-15 18:33:23",//时间格式化字符串,循环类型是18:33:23
|
|
||||||
String title;//标题
|
|
||||||
String voice;//语音文件地址
|
|
||||||
String voice_md5;
|
|
||||||
String file;//图片或视频文件地址
|
|
||||||
int remind_type;
|
|
||||||
int is_onoff;//0关闭 1开启
|
|
||||||
|
|
||||||
boolean finished = false;
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(int type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTime() {
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTime(String time) {
|
|
||||||
this.time = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVoice() {
|
|
||||||
return voice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVoice(String voice) {
|
|
||||||
this.voice = voice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVoice_md5() {
|
|
||||||
return voice_md5;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVoice_md5(String voice_md5) {
|
|
||||||
this.voice_md5 = voice_md5;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFile() {
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFile(String file) {
|
|
||||||
this.file = file;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFinished() {
|
|
||||||
return finished;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFinished(boolean finished) {
|
|
||||||
this.finished = finished;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRemind_type() {
|
|
||||||
return remind_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRemind_type(int remind_type) {
|
|
||||||
this.remind_type = remind_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIs_onoff() {
|
|
||||||
return is_onoff;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIs_onoff(int is_onoff) {
|
|
||||||
this.is_onoff = is_onoff;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTimeStamp() {
|
|
||||||
if (TextUtils.isEmpty(time)) {
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
if (time.length() == 5) {
|
|
||||||
String[] timeSplit = time.split(":");
|
|
||||||
int hour = Integer.parseInt(timeSplit[0]);
|
|
||||||
int minute = Integer.parseInt(timeSplit[1]);
|
|
||||||
Calendar c = Calendar.getInstance();
|
|
||||||
c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH),
|
|
||||||
c.get(Calendar.DAY_OF_MONTH), hour, minute, 0);
|
|
||||||
long mTimeInfo = c.getTimeInMillis();
|
|
||||||
Log.e("AlarmClockData", "getTimeStamp: " + mTimeInfo);
|
|
||||||
long actualTime = mTimeInfo > System.currentTimeMillis() ? mTimeInfo : mTimeInfo + AlarmUtils.ONE_DAY_TIME;
|
|
||||||
return actualTime;
|
|
||||||
} else {
|
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
try {
|
|
||||||
Date date = simpleDateFormat.parse(time);
|
|
||||||
long timestamp = date.getTime();
|
|
||||||
return timestamp;
|
|
||||||
} catch (ParseException e) {
|
|
||||||
return System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(@Nullable Object obj) {
|
|
||||||
if (obj == null) return false;
|
|
||||||
if (!(obj instanceof AlarmClockData)) return false;
|
|
||||||
if (id != ((AlarmClockData) obj).id) return false;
|
|
||||||
if (type != ((AlarmClockData) obj).type) return false;
|
|
||||||
if (!time.equals(((AlarmClockData) obj).time)) return false;
|
|
||||||
if (!title.equals(((AlarmClockData) obj).title)) return false;
|
|
||||||
if (!voice.equals(((AlarmClockData) obj).voice)) return false;
|
|
||||||
if (!voice_md5.equals(((AlarmClockData) obj).voice_md5)) return false;
|
|
||||||
if (!file.equals(((AlarmClockData) obj).file)) return false;
|
|
||||||
if (remind_type != ((AlarmClockData) obj).remind_type) return false;
|
|
||||||
if (is_onoff != ((AlarmClockData) obj).is_onoff) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package com.uiui.zyos.fragment.biology;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.uiui.zyos.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple {@link Fragment} subclass.
|
||||||
|
* Use the {@link BiologyFragment#newInstance} factory method to
|
||||||
|
* create an instance of this fragment.
|
||||||
|
*/
|
||||||
|
public class BiologyFragment extends Fragment {
|
||||||
|
// 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 BiologyFragment() {
|
||||||
|
// 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 BiologyFragment.
|
||||||
|
*/
|
||||||
|
// TODO: Rename and change types and number of parameters
|
||||||
|
public static BiologyFragment newInstance(String param1, String param2) {
|
||||||
|
BiologyFragment fragment = new BiologyFragment();
|
||||||
|
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 View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
return inflater.inflate(R.layout.fragment_biology, container, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package com.uiui.zyos.fragment.chemical;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.uiui.zyos.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple {@link Fragment} subclass.
|
||||||
|
* Use the {@link ChemicalFragment#newInstance} factory method to
|
||||||
|
* create an instance of this fragment.
|
||||||
|
*/
|
||||||
|
public class ChemicalFragment extends Fragment {
|
||||||
|
// 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 ChemicalFragment() {
|
||||||
|
// 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 ChemicalFragment.
|
||||||
|
*/
|
||||||
|
// TODO: Rename and change types and number of parameters
|
||||||
|
public static ChemicalFragment newInstance(String param1, String param2) {
|
||||||
|
ChemicalFragment fragment = new ChemicalFragment();
|
||||||
|
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 View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
return inflater.inflate(R.layout.fragment_chemical, container, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.uiui.zyos.fragment.chinese;
|
||||||
|
|
||||||
|
|
||||||
|
import com.uiui.zyos.base.BasePresenter;
|
||||||
|
import com.uiui.zyos.base.BaseView;
|
||||||
|
|
||||||
|
public class ChineseContact {
|
||||||
|
public interface Presenter extends BasePresenter<CustomView> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface CustomView extends BaseView {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,294 @@
|
|||||||
|
package com.uiui.zyos.fragment.chinese;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.os.BatteryManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.blankj.utilcode.util.NetworkUtils;
|
||||||
|
import com.uiui.zyos.R;
|
||||||
|
import com.uiui.zyos.base.BaseFragment;
|
||||||
|
import com.uiui.zyos.manager.RemoteManager;
|
||||||
|
import com.uiui.zyos.tpush.MessageReceiver;
|
||||||
|
import com.uiui.zyos.utils.Utils;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple {@link Fragment} subclass.
|
||||||
|
* Use the {@link ChineseFragment#newInstance} factory method to
|
||||||
|
* create an instance of this fragment.
|
||||||
|
*/
|
||||||
|
public class ChineseFragment extends BaseFragment implements ChineseContact.CustomView, NetworkUtils.OnNetworkStatusChangedListener {
|
||||||
|
private static final String TAG = ChineseFragment.class.getSimpleName();
|
||||||
|
|
||||||
|
|
||||||
|
private View rootView;
|
||||||
|
private Activity mContext;
|
||||||
|
private ChinesePresenter mChinesePresenter;
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChineseFragment() {
|
||||||
|
// 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 ChineseFragment.
|
||||||
|
*/
|
||||||
|
// TODO: Rename and change types and number of parameters
|
||||||
|
public static ChineseFragment newInstance(String param1, String param2) {
|
||||||
|
ChineseFragment fragment = new ChineseFragment();
|
||||||
|
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);
|
||||||
|
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||||
|
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 void fetchData() {
|
||||||
|
Log.e(TAG, "fetchData: ");
|
||||||
|
RemoteManager.getInstance().getLocation();
|
||||||
|
initData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
rootView = inflater.inflate(R.layout.fragment_chinese, container, false);
|
||||||
|
mContext = (Activity) rootView.getContext();
|
||||||
|
mChinesePresenter = new ChinesePresenter(mContext);
|
||||||
|
mChinesePresenter.attachView(this);
|
||||||
|
mChinesePresenter.setLifecycle(lifecycleSubject);
|
||||||
|
ButterKnife.bind(this, rootView);
|
||||||
|
initView();
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
|
Log.e(TAG, "initView: " + Utils.getBatteryLevel(mContext));
|
||||||
|
registerBatteryReceiver();
|
||||||
|
registerAlarmClockReceiver();
|
||||||
|
registTimeReceiver();
|
||||||
|
mContext.registerReceiver(mbatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initData() {
|
||||||
|
initAmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void initAmap() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerAlarmClockReceiver() {
|
||||||
|
if (null == mAlarmClockReceiver) {
|
||||||
|
mAlarmClockReceiver = new AlarmClockReceiver();
|
||||||
|
}
|
||||||
|
IntentFilter filter = new IntentFilter();
|
||||||
|
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||||
|
filter.addAction(MessageReceiver.SET_ALARMCLOCK);
|
||||||
|
mContext.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerBatteryReceiver() {
|
||||||
|
if (null == batteryReceiver) {
|
||||||
|
batteryReceiver = new BatteryReceiver();
|
||||||
|
}
|
||||||
|
IntentFilter filter = new IntentFilter();
|
||||||
|
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||||
|
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||||
|
filter.addAction(Intent.ACTION_BATTERY_LOW);
|
||||||
|
filter.addAction(Intent.ACTION_BATTERY_OKAY);
|
||||||
|
filter.addAction(Intent.ACTION_POWER_CONNECTED);
|
||||||
|
filter.addAction(Intent.ACTION_POWER_DISCONNECTED);
|
||||||
|
mContext.registerReceiver(batteryReceiver, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BatteryReceiver batteryReceiver;
|
||||||
|
|
||||||
|
private class BatteryReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
String action = intent.getAction();
|
||||||
|
if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
|
||||||
|
// 当前电量
|
||||||
|
int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
||||||
|
// 最大电量
|
||||||
|
int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, 0);
|
||||||
|
int elec = (level * 100) / scale;
|
||||||
|
Log.i(TAG, "electricity:=" + elec + "%");
|
||||||
|
// tv_battery.setText(elec + "%");
|
||||||
|
} else if (Intent.ACTION_POWER_CONNECTED.equals(action)
|
||||||
|
|| Intent.ACTION_POWER_DISCONNECTED.equals(action)
|
||||||
|
|| Intent.ACTION_BATTERY_LOW.equals(action)
|
||||||
|
|| Intent.ACTION_BATTERY_OKAY.equals(action)
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private BroadcastReceiver mbatteryReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
String action = intent.getAction();
|
||||||
|
Log.i(TAG, "onReceive: " + action);
|
||||||
|
if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
|
||||||
|
int status = intent.getIntExtra("status", BatteryManager.BATTERY_STATUS_UNKNOWN);
|
||||||
|
if (status == BatteryManager.BATTERY_STATUS_CHARGING) {
|
||||||
|
if (rootView != null) {
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (rootView != null) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间
|
||||||
|
*/
|
||||||
|
private void registTimeReceiver() {
|
||||||
|
if (null == mTimeReceiver) {
|
||||||
|
mTimeReceiver = new TimeReceiver();
|
||||||
|
}
|
||||||
|
IntentFilter filter = new IntentFilter();
|
||||||
|
filter.addAction(Intent.ACTION_DATE_CHANGED);
|
||||||
|
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
||||||
|
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
||||||
|
filter.addAction(Intent.ACTION_TIME_TICK);
|
||||||
|
mContext.registerReceiver(mTimeReceiver, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unRegistTimeReceiver() {
|
||||||
|
if (null != mTimeReceiver) {
|
||||||
|
mContext.unregisterReceiver(mTimeReceiver);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TimeReceiver mTimeReceiver;
|
||||||
|
|
||||||
|
class TimeReceiver extends BroadcastReceiver {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
String action = intent.getAction();
|
||||||
|
if (action.equals(Intent.ACTION_DATE_CHANGED)
|
||||||
|
|| action.equals(Intent.ACTION_TIMEZONE_CHANGED)
|
||||||
|
|| action.equals(Intent.ACTION_TIME_CHANGED)
|
||||||
|
|| action.equals(Intent.ACTION_TIME_TICK)
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据日期取得星期几
|
||||||
|
public static String getWeek() {
|
||||||
|
Date date = new Date();
|
||||||
|
String[] weeks = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.setTime(date);
|
||||||
|
int weekIndex = cal.get(Calendar.DAY_OF_WEEK) - 1;
|
||||||
|
if (weekIndex < 0) {
|
||||||
|
weekIndex = 0;
|
||||||
|
}
|
||||||
|
return weeks[weekIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
mChinesePresenter.detachView();
|
||||||
|
NetworkUtils.unregisterNetworkStatusChangedListener(this);
|
||||||
|
if (batteryReceiver != null) {
|
||||||
|
mContext.unregisterReceiver(batteryReceiver);
|
||||||
|
}
|
||||||
|
if (mbatteryReceiver != null) {
|
||||||
|
mContext.unregisterReceiver(mbatteryReceiver);
|
||||||
|
}
|
||||||
|
if (mAlarmClockReceiver != null) {
|
||||||
|
mContext.unregisterReceiver(mAlarmClockReceiver);
|
||||||
|
}
|
||||||
|
unRegistTimeReceiver();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.uiui.zyos.fragment.chinese;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||||
|
|
||||||
|
import io.reactivex.rxjava3.annotations.NonNull;
|
||||||
|
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||||
|
|
||||||
|
public class ChinesePresenter implements ChineseContact.Presenter {
|
||||||
|
private static final String TAG = ChinesePresenter.class.getSimpleName();
|
||||||
|
private Context mContext;
|
||||||
|
private ChineseContact.CustomView mView;
|
||||||
|
|
||||||
|
public ChinesePresenter(Context context) {
|
||||||
|
this.mContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BehaviorSubject<FragmentEvent> lifecycle;
|
||||||
|
|
||||||
|
void setLifecycle(BehaviorSubject<FragmentEvent> lifecycle) {
|
||||||
|
this.lifecycle = lifecycle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BehaviorSubject<FragmentEvent> getLifecycle() {
|
||||||
|
return lifecycle;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void attachView(@NonNull ChineseContact.CustomView view) {
|
||||||
|
this.mView = view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void detachView() {
|
||||||
|
this.mView = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package com.uiui.zyos.fragment.custom;
|
|
||||||
|
|
||||||
|
|
||||||
import com.uiui.zyos.base.BasePresenter;
|
|
||||||
import com.uiui.zyos.base.BaseView;
|
|
||||||
import com.uiui.zyos.bean.AlarmClockData;
|
|
||||||
import com.uiui.zyos.bean.SnInfo;
|
|
||||||
import com.uiui.zyos.bean.UserAvatarInfo;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CustomContact {
|
|
||||||
public interface Presenter extends BasePresenter<CustomView> {
|
|
||||||
void getNetSnIsActivation();
|
|
||||||
void getSnIsActivation();
|
|
||||||
void getSnInfo();
|
|
||||||
void getUserAvatarInfo();
|
|
||||||
void getAlarmClock();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface CustomView extends BaseView {
|
|
||||||
void setNetSnIsActivation(boolean activation);
|
|
||||||
void setSnIsActivation(boolean activation);
|
|
||||||
void setSnInfo(SnInfo snInfo);
|
|
||||||
void setUserAvatarInfo(UserAvatarInfo userAvatarInfo);
|
|
||||||
void setAlarmClock(List<AlarmClockData> clockDataList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,745 +0,0 @@
|
|||||||
package com.uiui.zyos.fragment.custom;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.ActivityManager;
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.pm.ApplicationInfo;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.content.res.Configuration;
|
|
||||||
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.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
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.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import com.blankj.utilcode.util.NetworkUtils;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import com.king.view.circleprogressview.CircleProgressView;
|
|
||||||
import com.tencent.mmkv.MMKV;
|
|
||||||
import com.uiui.zyos.BuildConfig;
|
|
||||||
import com.uiui.zyos.R;
|
|
||||||
import com.uiui.zyos.base.BaseFragment;
|
|
||||||
import com.uiui.zyos.bean.AlarmClockData;
|
|
||||||
import com.uiui.zyos.bean.AlarmItem;
|
|
||||||
import com.uiui.zyos.bean.Contact;
|
|
||||||
import com.uiui.zyos.bean.HealthCode;
|
|
||||||
import com.uiui.zyos.bean.SnInfo;
|
|
||||||
import com.uiui.zyos.bean.UserAvatarInfo;
|
|
||||||
import com.uiui.zyos.config.CommonConfig;
|
|
||||||
import com.uiui.zyos.dialog.SingleDialog;
|
|
||||||
import com.uiui.zyos.disklrucache.CacheHelper;
|
|
||||||
import com.uiui.zyos.manager.RemoteManager;
|
|
||||||
import com.uiui.zyos.network.NetInterfaceManager;
|
|
||||||
import com.uiui.zyos.network.UrlAddress;
|
|
||||||
import com.uiui.zyos.tpush.MessageReceiver;
|
|
||||||
import com.uiui.zyos.utils.ApkUtils;
|
|
||||||
import com.uiui.zyos.utils.AppUtil;
|
|
||||||
import com.uiui.zyos.utils.DataUtil;
|
|
||||||
import com.uiui.zyos.utils.NetStateUtils;
|
|
||||||
import com.uiui.zyos.utils.SchemeUtils;
|
|
||||||
import com.uiui.zyos.utils.ToastUtil;
|
|
||||||
import com.uiui.zyos.utils.Utils;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple {@link Fragment} subclass.
|
|
||||||
* Use the {@link CustomFragment#newInstance} factory method to
|
|
||||||
* create an instance of this fragment.
|
|
||||||
*/
|
|
||||||
public class CustomFragment extends BaseFragment implements CustomContact.CustomView, NetworkUtils.OnNetworkStatusChangedListener {
|
|
||||||
private static final String TAG = CustomFragment.class.getSimpleName();
|
|
||||||
|
|
||||||
|
|
||||||
// @BindView(R.id.cl_alarm)
|
|
||||||
// ConstraintLayout cl_alarm;
|
|
||||||
@BindView(R.id.cl_weather)
|
|
||||||
ConstraintLayout cl_weather;
|
|
||||||
@BindView(R.id.cl_activation)
|
|
||||||
ConstraintLayout cl_activation;
|
|
||||||
@BindView(R.id.cl_clean)
|
|
||||||
ConstraintLayout cl_clean;
|
|
||||||
@BindView(R.id.cl_sos)
|
|
||||||
ConstraintLayout cl_sos;
|
|
||||||
@BindView(R.id.cl_guard)
|
|
||||||
ConstraintLayout cl_guard;
|
|
||||||
@BindView(R.id.cl_health)
|
|
||||||
ConstraintLayout cl_health;
|
|
||||||
@BindView(R.id.cl_contact)
|
|
||||||
ConstraintLayout cl_contact;
|
|
||||||
@BindView(R.id.cl_ai)
|
|
||||||
ConstraintLayout cl_ai;
|
|
||||||
@BindView(R.id.cl_app)
|
|
||||||
ConstraintLayout cl_app;
|
|
||||||
@BindView(R.id.cl_appstore)
|
|
||||||
ConstraintLayout cl_appstore;
|
|
||||||
|
|
||||||
// @BindView(R.id.cl_battery)
|
|
||||||
// ConstraintLayout cl_battery;
|
|
||||||
// @BindView(R.id.tv_add)
|
|
||||||
// TextView tv_add;
|
|
||||||
// @BindView(R.id.tv_battery)
|
|
||||||
// TextView tv_battery;
|
|
||||||
@BindView(R.id.tv_location)
|
|
||||||
TextView tv_location;
|
|
||||||
@BindView(R.id.tv_weather)
|
|
||||||
TextView tv_weather;
|
|
||||||
@BindView(R.id.iv_pic)
|
|
||||||
ImageView iv_pic;
|
|
||||||
@BindView(R.id.tv_temp)
|
|
||||||
TextView tv_temp;
|
|
||||||
@BindView(R.id.cpv)
|
|
||||||
CircleProgressView cpv;
|
|
||||||
// @BindView(R.id.iv_charging)
|
|
||||||
// ImageView iv_charging;
|
|
||||||
// @BindView(R.id.rv_noti)
|
|
||||||
// RecyclerView rv_noti;
|
|
||||||
// @BindView(R.id.rv_clock)
|
|
||||||
// RecyclerView rv_clock;
|
|
||||||
// @BindView(R.id.wifi_ssid)
|
|
||||||
// TextView wifi_ssid;
|
|
||||||
@BindView(R.id.iv_sos)
|
|
||||||
ImageView iv_sos;
|
|
||||||
@BindView(R.id.rv_sos)
|
|
||||||
RecyclerView rv_sos;
|
|
||||||
@BindView(R.id.iv_note_nodata)
|
|
||||||
ImageView iv_note_nodata;
|
|
||||||
// @BindView(R.id.iv_head)
|
|
||||||
// ImageView iv_head;
|
|
||||||
// @BindView(R.id.tv_name)
|
|
||||||
// TextView tv_name;
|
|
||||||
@BindView(R.id.iv_app)
|
|
||||||
ImageView iv_app;
|
|
||||||
@BindView(R.id.tv_time)
|
|
||||||
TextView tv_time;
|
|
||||||
|
|
||||||
// private int[] mShaderColors = new int[]{0xFFfa3db5, 0xFFF8867E, 0xFFF79F6B, 0xFFF79F6B, 0xFFF79F6B, 0xFFF8867E, 0xFFfa3db5};
|
|
||||||
private int[] mShaderColors = new int[]{0xFF27602f, 0xFF27602f, 0xFF27602f, 0xFF27602f, 0xFF27602f, 0xFF27602f, 0xFF27602f};
|
|
||||||
private int[] mShaderColorsRed = new int[]{0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000};
|
|
||||||
private View rootView;
|
|
||||||
private List<AlarmItem> alarmItemList;
|
|
||||||
// private NotificationAdapter notificationAdapter;
|
|
||||||
// private AlarmClockAdapter alarmClockAdapter;
|
|
||||||
private MMKV mMMKV;
|
|
||||||
private Activity mContext;
|
|
||||||
private ContentResolver mCRv;
|
|
||||||
private CacheHelper mCacheHelper;
|
|
||||||
private CustomPresenter mCustomPresenter;
|
|
||||||
|
|
||||||
// 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() {
|
|
||||||
// wifi_ssid.setText("WiFi未连接");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
|
||||||
if (networkType == NetworkUtils.NetworkType.NETWORK_WIFI) {
|
|
||||||
// wifi_ssid.setText(getConnectWifiSsid());
|
|
||||||
} else {
|
|
||||||
// wifi_ssid.setText("WiFi未连接");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getConnectWifiSsid() {
|
|
||||||
WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
|
|
||||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
|
||||||
Log.d("wifiInfo", wifiInfo.toString());
|
|
||||||
Log.d("SSID", wifiInfo.getSSID());
|
|
||||||
return wifiInfo.getSSID();
|
|
||||||
}
|
|
||||||
|
|
||||||
public CustomFragment() {
|
|
||||||
// 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 CustomFragment.
|
|
||||||
*/
|
|
||||||
// TODO: Rename and change types and number of parameters
|
|
||||||
public static CustomFragment newInstance(String param1, String param2) {
|
|
||||||
CustomFragment fragment = new CustomFragment();
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putString(ARG_PARAM1, param1);
|
|
||||||
args.putString(ARG_PARAM2, param2);
|
|
||||||
fragment.setArguments(args);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAlarmItem(List<AlarmItem> alarmItem) {
|
|
||||||
this.alarmItemList = alarmItem;
|
|
||||||
// setAlarm();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
|
||||||
if (getArguments() != null) {
|
|
||||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
|
||||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
|
||||||
}
|
|
||||||
mMMKV = MMKV.defaultMMKV();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
|
||||||
super.onConfigurationChanged(newConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fetchData() {
|
|
||||||
Log.e(TAG, "fetchData: ");
|
|
||||||
RemoteManager.getInstance().getLocation();
|
|
||||||
initData();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
rootView = inflater.inflate(R.layout.fragment_custom, container, false);
|
|
||||||
mContext = (Activity) rootView.getContext();
|
|
||||||
mCustomPresenter = new CustomPresenter(mContext);
|
|
||||||
mCustomPresenter.attachView(this);
|
|
||||||
mCustomPresenter.setLifecycle(lifecycleSubject);
|
|
||||||
mCacheHelper = new CacheHelper(mContext);
|
|
||||||
mCRv = mContext.getContentResolver();
|
|
||||||
ButterKnife.bind(this, rootView);
|
|
||||||
initView();
|
|
||||||
return rootView;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initView() {
|
|
||||||
Log.e(TAG, "initView: " + Utils.getBatteryLevel(mContext));
|
|
||||||
registerBatteryReceiver();
|
|
||||||
registerAlarmClockReceiver();
|
|
||||||
registTimeReceiver();
|
|
||||||
tv_time.setText(DataUtil.formatDateDay() + "\t" + getWeek());
|
|
||||||
mContext.registerReceiver(mbatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
|
||||||
if (Settings.Global.getInt(mCRv, "is_aihealth", 0) == 1) {
|
|
||||||
cl_appstore.setVisibility(View.GONE);
|
|
||||||
cl_ai.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
cl_appstore.setVisibility(View.VISIBLE);
|
|
||||||
cl_ai.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
// tv_battery.setText(Utils.getBatteryLevel(mContext) + "%");
|
|
||||||
cpv.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
killBackgroundApp();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// cl_alarm.setOnClickListener(new View.OnClickListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onClick(View v) {
|
|
||||||
// ApkUtils.openPackage(mContext, "com.alarmclock.uiui");
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
cl_guard.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (checkExpired()) {
|
|
||||||
showExpired();
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// notificationAdapter = new NotificationAdapter();
|
|
||||||
// notificationAdapter.setOnClickListener(new NotificationAdapter.OnClickListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onClick() {
|
|
||||||
// getAlarm();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// rv_noti.setOnClickListener(new View.OnClickListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onClick(View view) {
|
|
||||||
// getAlarm();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// rv_noti.setLayoutManager(new LinearLayoutManager(mContext));
|
|
||||||
// rv_noti.setAdapter(notificationAdapter);
|
|
||||||
if (isWifiConnect()) {
|
|
||||||
// wifi_ssid.setText(getConnectWifiSsid());
|
|
||||||
} else {
|
|
||||||
// wifi_ssid.setText("WiFi未连接");
|
|
||||||
}
|
|
||||||
cl_sos.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (checkExpired()) {
|
|
||||||
showExpired();
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cl_weather.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (checkExpired()) {
|
|
||||||
showExpired();
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cl_activation.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
ApkUtils.openApp(mContext, "com.uiui.sn");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cl_clean.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (checkExpired()) {
|
|
||||||
showExpired();
|
|
||||||
} else {
|
|
||||||
killBackgroundApp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cl_health.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cl_contact.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (checkExpired()) {
|
|
||||||
showExpired();
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cl_ai.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (checkExpired()) {
|
|
||||||
showExpired();
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cl_app.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (checkExpired()) {
|
|
||||||
showExpired();
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cl_app.setOnLongClickListener(new View.OnLongClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onLongClick(View view) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cl_appstore.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (checkExpired()) {
|
|
||||||
showExpired();
|
|
||||||
} else {
|
|
||||||
ApkUtils.openApp(mContext, "com.uiui.appstore");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
refreshMemory();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查wifi是否处开连接状态
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean isWifiConnect() {
|
|
||||||
ConnectivityManager connManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
||||||
NetworkInfo mWifiInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
|
||||||
return mWifiInfo.isConnected();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showExpired() {
|
|
||||||
SingleDialog dialog = new SingleDialog(mContext);
|
|
||||||
dialog.setTitle("温馨提示")
|
|
||||||
.setMessage("体验时间已到期,请激活")
|
|
||||||
.setPositive("确定")
|
|
||||||
// .setNegtive("拒绝")
|
|
||||||
// .setSingle(true)
|
|
||||||
.setOnClickBottomListener(new SingleDialog.OnClickBottomListener() {
|
|
||||||
@Override
|
|
||||||
public void onPositiveClick() {
|
|
||||||
ApkUtils.openApp(mContext, "com.uiui.sn");
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface Activation {
|
|
||||||
void ActivationCallback();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean checkExpired() {
|
|
||||||
int is_activation = Settings.Global.getInt(mContext.getContentResolver(), CommonConfig.UIUI_ACTIVATION_KEY, 0);
|
|
||||||
int code_type = Settings.Global.getInt(mContext.getContentResolver(), CommonConfig.UIUI_CODE_TYPE_KEY, -1);
|
|
||||||
long expire_time = Settings.Global.getLong(mContext.getContentResolver(), CommonConfig.UIUI_EXPIRE_TIME_KEY, -1);
|
|
||||||
if (is_activation == 0) {
|
|
||||||
return true;
|
|
||||||
} else if (is_activation == 1) {
|
|
||||||
if (code_type == 0) {
|
|
||||||
if (expire_time > 0) {
|
|
||||||
long time = System.currentTimeMillis() / 1000;
|
|
||||||
return time > expire_time;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else if (code_type == 1) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initData() {
|
|
||||||
mCustomPresenter.getSnIsActivation();
|
|
||||||
initAmap();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setNetSnIsActivation(boolean activation) {
|
|
||||||
if (activation) {
|
|
||||||
cl_weather.setVisibility(View.VISIBLE);
|
|
||||||
cl_activation.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
cl_weather.setVisibility(View.GONE);
|
|
||||||
cl_activation.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
mCustomPresenter.getSnInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSnIsActivation(boolean activation) {
|
|
||||||
if (activation) {
|
|
||||||
cl_weather.setVisibility(View.VISIBLE);
|
|
||||||
cl_activation.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
cl_weather.setVisibility(View.GONE);
|
|
||||||
cl_activation.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSnInfo(SnInfo snInfo) {
|
|
||||||
if (snInfo != null) {
|
|
||||||
if (TextUtils.isEmpty(snInfo.getSn_name())) {
|
|
||||||
// tv_name.setText("未设置");
|
|
||||||
} else {
|
|
||||||
// tv_name.setText(snInfo.getSn_name());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// tv_name.setText("未设置");
|
|
||||||
}
|
|
||||||
mCustomPresenter.getUserAvatarInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUserAvatarInfo(UserAvatarInfo userAvatarInfo) {
|
|
||||||
if (userAvatarInfo != null && userAvatarInfo.getAvatar() != null) {
|
|
||||||
if (!mContext.isDestroyed()) {
|
|
||||||
// Glide.with(iv_head).load(userAvatarInfo.getAvatar()).into(iv_head);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mCustomPresenter.getAlarmClock();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setAlarmClock(List<AlarmClockData> clockDataList) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
mCustomPresenter.getSnIsActivation();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void initAmap() {
|
|
||||||
String city = RemoteManager.getInstance().getCity();
|
|
||||||
tv_location.setText(city);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showNoData(String title, String msg) {
|
|
||||||
SingleDialog dialog = new SingleDialog(mContext);
|
|
||||||
dialog.setTitle(title)
|
|
||||||
.setMessage(msg)
|
|
||||||
.setPositive("确定")
|
|
||||||
// .setNegtive("拒绝")
|
|
||||||
// .setSingle(true)
|
|
||||||
.setOnClickBottomListener(new SingleDialog.OnClickBottomListener() {
|
|
||||||
@Override
|
|
||||||
public void onPositiveClick() {
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// dialog.setCancelable(false);
|
|
||||||
dialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void killBackgroundApp() {
|
|
||||||
List<String> pkgList = ApkUtils.queryFilterAppList(mContext);
|
|
||||||
for (String pkg : pkgList) {
|
|
||||||
if (pkg.equalsIgnoreCase(BuildConfig.APPLICATION_ID)
|
|
||||||
|| "com.tencent.mm".equals(pkg)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
killBackgroundProcesses(pkg);
|
|
||||||
}
|
|
||||||
refreshMemory();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void killBackgroundProcesses(String packageName) {
|
|
||||||
ActivityManager activityManager;
|
|
||||||
try {
|
|
||||||
activityManager = (ActivityManager)
|
|
||||||
mContext.getSystemService(Context.ACTIVITY_SERVICE);
|
|
||||||
activityManager.killBackgroundProcesses(packageName);
|
|
||||||
Method forceStopPackage = activityManager.getClass()
|
|
||||||
.getDeclaredMethod("forceStopPackage", String.class);
|
|
||||||
// Log.e(TAG, "killBackgroundProcesses: " + packageName);
|
|
||||||
forceStopPackage.setAccessible(true);
|
|
||||||
forceStopPackage.invoke(activityManager, packageName);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "killBackgroundProcesses: " + e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshMemory() {
|
|
||||||
long avail = AppUtil.getAvailMemory(mContext);
|
|
||||||
long total = AppUtil.getTotalMemory(mContext);
|
|
||||||
int x = (int) (((total - avail) / (double) total) * 100);
|
|
||||||
if (x > 80) {
|
|
||||||
cpv.setProgressColor(mShaderColorsRed);
|
|
||||||
} else {
|
|
||||||
cpv.setProgressColor(mShaderColors);
|
|
||||||
}
|
|
||||||
cpv.showAnimation(0, x, 1000);
|
|
||||||
float x2 = (((total - avail) / (float) total));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void registerAlarmClockReceiver() {
|
|
||||||
if (null == mAlarmClockReceiver) {
|
|
||||||
mAlarmClockReceiver = new AlarmClockReceiver();
|
|
||||||
}
|
|
||||||
IntentFilter filter = new IntentFilter();
|
|
||||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
|
||||||
filter.addAction(MessageReceiver.SET_ALARMCLOCK);
|
|
||||||
mContext.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)) {
|
|
||||||
Handler.getMain().postDelayed(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
mCustomPresenter.getAlarmClock();
|
|
||||||
}
|
|
||||||
}, 3456);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerBatteryReceiver() {
|
|
||||||
if (null == batteryReceiver) {
|
|
||||||
batteryReceiver = new BatteryReceiver();
|
|
||||||
}
|
|
||||||
IntentFilter filter = new IntentFilter();
|
|
||||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
|
||||||
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
|
||||||
filter.addAction(Intent.ACTION_BATTERY_LOW);
|
|
||||||
filter.addAction(Intent.ACTION_BATTERY_OKAY);
|
|
||||||
filter.addAction(Intent.ACTION_POWER_CONNECTED);
|
|
||||||
filter.addAction(Intent.ACTION_POWER_DISCONNECTED);
|
|
||||||
mContext.registerReceiver(batteryReceiver, filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private BatteryReceiver batteryReceiver;
|
|
||||||
|
|
||||||
private class BatteryReceiver extends BroadcastReceiver {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
String action = intent.getAction();
|
|
||||||
if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
|
|
||||||
// 当前电量
|
|
||||||
int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
|
||||||
// 最大电量
|
|
||||||
int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, 0);
|
|
||||||
int elec = (level * 100) / scale;
|
|
||||||
Log.i(TAG, "electricity:=" + elec + "%");
|
|
||||||
// tv_battery.setText(elec + "%");
|
|
||||||
} else if (Intent.ACTION_POWER_CONNECTED.equals(action)
|
|
||||||
|| Intent.ACTION_POWER_DISCONNECTED.equals(action)
|
|
||||||
|| Intent.ACTION_BATTERY_LOW.equals(action)
|
|
||||||
|| Intent.ACTION_BATTERY_OKAY.equals(action)
|
|
||||||
) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private BroadcastReceiver mbatteryReceiver = new BroadcastReceiver() {
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
String action = intent.getAction();
|
|
||||||
Log.i(TAG, "onReceive: " + action);
|
|
||||||
if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
|
|
||||||
int status = intent.getIntExtra("status", BatteryManager.BATTERY_STATUS_UNKNOWN);
|
|
||||||
if (status == BatteryManager.BATTERY_STATUS_CHARGING) {
|
|
||||||
if (rootView != null) {
|
|
||||||
// iv_charging.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (rootView != null) {
|
|
||||||
// iv_charging.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 时间
|
|
||||||
*/
|
|
||||||
private void registTimeReceiver() {
|
|
||||||
if (null == mTimeReceiver) {
|
|
||||||
mTimeReceiver = new TimeReceiver();
|
|
||||||
}
|
|
||||||
IntentFilter filter = new IntentFilter();
|
|
||||||
filter.addAction(Intent.ACTION_DATE_CHANGED);
|
|
||||||
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
|
||||||
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
|
||||||
filter.addAction(Intent.ACTION_TIME_TICK);
|
|
||||||
mContext.registerReceiver(mTimeReceiver, filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void unRegistTimeReceiver() {
|
|
||||||
if (null != mTimeReceiver) {
|
|
||||||
mContext.unregisterReceiver(mTimeReceiver);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private TimeReceiver mTimeReceiver;
|
|
||||||
|
|
||||||
class TimeReceiver extends BroadcastReceiver {
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
String action = intent.getAction();
|
|
||||||
if (action.equals(Intent.ACTION_DATE_CHANGED)
|
|
||||||
|| action.equals(Intent.ACTION_TIMEZONE_CHANGED)
|
|
||||||
|| action.equals(Intent.ACTION_TIME_CHANGED)
|
|
||||||
|| action.equals(Intent.ACTION_TIME_TICK)
|
|
||||||
) {
|
|
||||||
tv_time.setText(DataUtil.formatDateDay() + "\t" + getWeek());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据日期取得星期几
|
|
||||||
public static String getWeek() {
|
|
||||||
Date date = new Date();
|
|
||||||
String[] weeks = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
cal.setTime(date);
|
|
||||||
int weekIndex = cal.get(Calendar.DAY_OF_WEEK) - 1;
|
|
||||||
if (weekIndex < 0) {
|
|
||||||
weekIndex = 0;
|
|
||||||
}
|
|
||||||
return weeks[weekIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
mCustomPresenter.detachView();
|
|
||||||
NetworkUtils.unregisterNetworkStatusChangedListener(this);
|
|
||||||
if (batteryReceiver != null) {
|
|
||||||
mContext.unregisterReceiver(batteryReceiver);
|
|
||||||
}
|
|
||||||
if (mbatteryReceiver != null) {
|
|
||||||
mContext.unregisterReceiver(mbatteryReceiver);
|
|
||||||
}
|
|
||||||
if (mAlarmClockReceiver != null) {
|
|
||||||
mContext.unregisterReceiver(mAlarmClockReceiver);
|
|
||||||
}
|
|
||||||
unRegistTimeReceiver();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
package com.uiui.zyos.fragment.custom;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.provider.Settings;
|
|
||||||
|
|
||||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
|
||||||
import com.uiui.zyos.config.CommonConfig;
|
|
||||||
|
|
||||||
import io.reactivex.rxjava3.annotations.NonNull;
|
|
||||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
|
||||||
|
|
||||||
public class CustomPresenter implements CustomContact.Presenter {
|
|
||||||
private static final String TAG = CustomPresenter.class.getSimpleName();
|
|
||||||
private Context mContext;
|
|
||||||
private CustomContact.CustomView mView;
|
|
||||||
|
|
||||||
public CustomPresenter(Context context) {
|
|
||||||
this.mContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
private BehaviorSubject<FragmentEvent> lifecycle;
|
|
||||||
|
|
||||||
void setLifecycle(BehaviorSubject<FragmentEvent> lifecycle) {
|
|
||||||
this.lifecycle = lifecycle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BehaviorSubject<FragmentEvent> getLifecycle() {
|
|
||||||
return lifecycle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void attachView(@NonNull CustomContact.CustomView view) {
|
|
||||||
this.mView = view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void detachView() {
|
|
||||||
this.mView = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getNetSnIsActivation() {
|
|
||||||
// NetInterfaceManager.getInstance()
|
|
||||||
// .getSnIsActivationObservable()
|
|
||||||
// .compose(RxLifecycle.bindUntilEvent(lifecycle, FragmentEvent.DESTROY))
|
|
||||||
// .subscribe(new Observer<BaseResponse>() {
|
|
||||||
// @Override
|
|
||||||
// public void onSubscribe(@NonNull Disposable d) {
|
|
||||||
// Log.e("getSnIsActivation", "onSubscribe: ");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onNext(@NonNull BaseResponse baseResponse) {
|
|
||||||
// Log.e("getSnIsActivation", "onNext: " + baseResponse);
|
|
||||||
// if (baseResponse.code == 200) {
|
|
||||||
// JsonObject jsonObject = GsonUtils.getJsonObject(baseResponse.data.toString());
|
|
||||||
// int is_activation = jsonObject.get("is_activation").getAsInt();
|
|
||||||
// Settings.Global.putInt(mContext.getContentResolver(), CommonConfig.UIUI_ACTIVATION_KEY, is_activation);
|
|
||||||
// mView.setNetSnIsActivation(is_activation == 1);
|
|
||||||
// } else {
|
|
||||||
// mView.setNetSnIsActivation(false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onError(@NonNull Throwable e) {
|
|
||||||
// Log.e("getSnIsActivation", "onError: " + e.getMessage());
|
|
||||||
// int is_activation = Settings.Global.getInt(mContext.getContentResolver(), CommonConfig.UIUI_ACTIVATION_KEY, 0);
|
|
||||||
// mView.setNetSnIsActivation(is_activation == 1);
|
|
||||||
// onComplete();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onComplete() {
|
|
||||||
// Log.e("getSnIsActivation", "onComplete: ");
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getSnIsActivation() {
|
|
||||||
int is_activation = Settings.Global.getInt(mContext.getContentResolver(), CommonConfig.UIUI_ACTIVATION_KEY, 0);
|
|
||||||
mView.setSnIsActivation(is_activation == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getSnInfo() {
|
|
||||||
mView.setSnInfo(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getUserAvatarInfo() {
|
|
||||||
mView.setUserAvatarInfo(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getAlarmClock() {
|
|
||||||
// NetInterfaceManager.getInstance().getAlarmClockFragment(lifecycle, new NetInterfaceManager.AlarmClockCallback() {
|
|
||||||
// @Override
|
|
||||||
// public void setAlarmClock(List<AlarmClockData> alarmClockList) {
|
|
||||||
// AlarmClockData alarmClockData = AlarmUtils.getInstance().getRecentAlarmClock();
|
|
||||||
// if (alarmClockData != null) {
|
|
||||||
// List<AlarmClockData> data = new ArrayList<>();
|
|
||||||
// data.add(alarmClockData);
|
|
||||||
// mView.setAlarmClock(data);
|
|
||||||
// } else {
|
|
||||||
// mView.setAlarmClock(null);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void setAlarmClockEmpty() {
|
|
||||||
// mView.setAlarmClock(null);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onError() {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
mView.setAlarmClock(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package com.uiui.zyos.fragment.english;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.uiui.zyos.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple {@link Fragment} subclass.
|
||||||
|
* Use the {@link EnglishFragment#newInstance} factory method to
|
||||||
|
* create an instance of this fragment.
|
||||||
|
*/
|
||||||
|
public class EnglishFragment extends Fragment {
|
||||||
|
// 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 EnglishFragment() {
|
||||||
|
// 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 EnglishFragment.
|
||||||
|
*/
|
||||||
|
// TODO: Rename and change types and number of parameters
|
||||||
|
public static EnglishFragment newInstance(String param1, String param2) {
|
||||||
|
EnglishFragment fragment = new EnglishFragment();
|
||||||
|
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 View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
return inflater.inflate(R.layout.fragment_english, container, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package com.uiui.zyos.fragment.math;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.uiui.zyos.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple {@link Fragment} subclass.
|
||||||
|
* Use the {@link MathFragment#newInstance} factory method to
|
||||||
|
* create an instance of this fragment.
|
||||||
|
*/
|
||||||
|
public class MathFragment extends Fragment {
|
||||||
|
// 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 MathFragment() {
|
||||||
|
// 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 MathFragment.
|
||||||
|
*/
|
||||||
|
// TODO: Rename and change types and number of parameters
|
||||||
|
public static MathFragment newInstance(String param1, String param2) {
|
||||||
|
MathFragment fragment = new MathFragment();
|
||||||
|
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 View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
return inflater.inflate(R.layout.fragment_math, container, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package com.uiui.zyos.fragment.physics;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.uiui.zyos.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple {@link Fragment} subclass.
|
||||||
|
* Use the {@link PhysicsFragment#newInstance} factory method to
|
||||||
|
* create an instance of this fragment.
|
||||||
|
*/
|
||||||
|
public class PhysicsFragment extends Fragment {
|
||||||
|
// 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 PhysicsFragment() {
|
||||||
|
// 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 PhysicsFragment.
|
||||||
|
*/
|
||||||
|
// TODO: Rename and change types and number of parameters
|
||||||
|
public static PhysicsFragment newInstance(String param1, String param2) {
|
||||||
|
PhysicsFragment fragment = new PhysicsFragment();
|
||||||
|
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 View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
return inflater.inflate(R.layout.fragment_physics, container, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,8 +14,7 @@ import com.google.gson.reflect.TypeToken;
|
|||||||
import com.tencent.mmkv.MMKV;
|
import com.tencent.mmkv.MMKV;
|
||||||
import com.uiui.zyos.bean.MapBean;
|
import com.uiui.zyos.bean.MapBean;
|
||||||
import com.uiui.zyos.config.CommonConfig;
|
import com.uiui.zyos.config.CommonConfig;
|
||||||
import com.uiui.zyos.disklrucache.CacheHelper;
|
import com.uiui.zysn.IGetInfoInterface;
|
||||||
import com.uiui.sn.IGetInfoInterface;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
@@ -26,30 +25,33 @@ public class RemoteManager {
|
|||||||
private static RemoteManager sInstance;
|
private static RemoteManager sInstance;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||||
private CacheHelper mCacheHelper;
|
|
||||||
|
|
||||||
private IGetInfoInterface getInfoInterface;
|
private IGetInfoInterface mGetInfoInterface;
|
||||||
private ServiceConnection mIGetInfoConnection;
|
private ServiceConnection mServiceConnection;
|
||||||
|
|
||||||
|
private static final String SN_AIDL_NAME = "com.uiui.zysn.IGetInfoInterface";
|
||||||
|
private static final String SN_PACKAGE_NAME = "com.uiui.zysn";
|
||||||
|
private static final String SN_SERVICE_NAME = "com.uiui.zysn.service.RemoteService";
|
||||||
|
|
||||||
private RemoteManager(Context context) {
|
private RemoteManager(Context context) {
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
throw new RuntimeException("Context is NULL");
|
throw new RuntimeException("Context is NULL");
|
||||||
}
|
}
|
||||||
this.mContext = context;
|
this.mContext = context;
|
||||||
this.mCacheHelper = new CacheHelper(context);
|
mServiceConnection = new ServiceConnection() {
|
||||||
mIGetInfoConnection = new ServiceConnection() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
Log.e(TAG, "onServiceConnected: mIGetInfoConnection");
|
Log.e(TAG, "onServiceConnected: mIGetInfoConnection");
|
||||||
getInfoInterface = IGetInfoInterface.Stub.asInterface(service);
|
mGetInfoInterface = IGetInfoInterface.Stub.asInterface(service);
|
||||||
getLocation();
|
getLocation();
|
||||||
|
Log.e(TAG, "onServiceConnected: " + getSerial());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
Log.e(TAG, "onServiceDisconnected: mIGetInfoConnection");
|
Log.e(TAG, "onServiceDisconnected: mIGetInfoConnection");
|
||||||
getInfoInterface = null;
|
//置空,重连
|
||||||
|
mGetInfoInterface = null;
|
||||||
bindInfoService();
|
bindInfoService();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -71,20 +73,36 @@ public class RemoteManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void bindInfoService() {
|
private void bindInfoService() {
|
||||||
if (getInfoInterface == null) {
|
if (mGetInfoInterface == null) {
|
||||||
//这是连接aidl服务的代码
|
//这是连接aidl服务的代码
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction("com.uiui.sn.IGetInfoInterface");
|
intent.setAction(SN_AIDL_NAME);
|
||||||
intent.setPackage("com.uiui.sn");
|
intent.setPackage(SN_PACKAGE_NAME);
|
||||||
intent.setComponent(new ComponentName("com.uiui.sn", "com.uiui.sn.service.RemoteService"));
|
intent.setComponent(new ComponentName(SN_PACKAGE_NAME, SN_SERVICE_NAME));
|
||||||
mContext.bindService(intent, mIGetInfoConnection, Context.BIND_AUTO_CREATE);
|
mContext.bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getLocation() {
|
/**
|
||||||
if (getInfoInterface != null) {
|
* @return 获取sn
|
||||||
|
*/
|
||||||
|
public String getSerial() {
|
||||||
|
if (mGetInfoInterface != null) {
|
||||||
try {
|
try {
|
||||||
String jsonString = getInfoInterface.getMapResult();
|
return mGetInfoInterface.getSerial();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "getSerial: " + e.getMessage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
bindInfoService();
|
||||||
|
}
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getLocation() {
|
||||||
|
if (mGetInfoInterface != null) {
|
||||||
|
try {
|
||||||
|
String jsonString = mGetInfoInterface.getMapResult();
|
||||||
mMMKV.encode(CommonConfig.MAP_LOCATION_JSON_KEY, jsonString);
|
mMMKV.encode(CommonConfig.MAP_LOCATION_JSON_KEY, jsonString);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "getMapResult: " + e.getMessage());
|
Log.e(TAG, "getMapResult: " + e.getMessage());
|
||||||
@@ -120,14 +138,13 @@ public class RemoteManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getCityDistrict() {
|
public String getCityDistrict() {
|
||||||
MapBean mapBean = getMapBean();
|
MapBean mapBean = getMapBean();
|
||||||
if (mapBean == null) {
|
if (mapBean == null) {
|
||||||
getLocation();
|
getLocation();
|
||||||
return "北京";
|
return "北京";
|
||||||
} else {
|
} else {
|
||||||
return mapBean.getCity() + "\t" + mapBean.getDistrict();
|
return mapBean.getCity() + "\t" + mapBean.getDistrict();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +174,7 @@ public class RemoteManager {
|
|||||||
getLocation();
|
getLocation();
|
||||||
return "0.0";
|
return "0.0";
|
||||||
} else {
|
} else {
|
||||||
return mapBean.getLongitude() + "," + mapBean.getLatitude();
|
return mapBean.getLongitude() + "," + mapBean.getLatitude();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class ApkUtils {
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
private static HashSet<String> showPackageName = new HashSet<String>() {{
|
private static HashSet<String> showPackageName = new HashSet<String>() {{
|
||||||
this.add("com.uiui.sn");
|
this.add("com.uiui.zysn");
|
||||||
this.add("com.android.dialer");
|
this.add("com.android.dialer");
|
||||||
this.add("com.android.gallery3d");
|
this.add("com.android.gallery3d");
|
||||||
this.add("com.android.settings");
|
this.add("com.android.settings");
|
||||||
@@ -144,7 +144,7 @@ public class ApkUtils {
|
|||||||
this.add("com.android.gallery3d");
|
this.add("com.android.gallery3d");
|
||||||
this.add("com.android.camera2");
|
this.add("com.android.camera2");
|
||||||
this.add("com.android.settings");
|
this.add("com.android.settings");
|
||||||
this.add("com.uiui.sn");
|
this.add("com.uiui.zysn");
|
||||||
this.add("com.uiui.appstore");
|
this.add("com.uiui.appstore");
|
||||||
}};
|
}};
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ public class ApkUtils {
|
|||||||
}
|
}
|
||||||
if (Settings.Global.getInt(context.getContentResolver(), "is_activity", 0) == 0) {
|
if (Settings.Global.getInt(context.getContentResolver(), "is_activity", 0) == 0) {
|
||||||
resolveInfos.removeIf(resolveInfo -> "com.uiui.city".equals(resolveInfo.activityInfo.packageName));
|
resolveInfos.removeIf(resolveInfo -> "com.uiui.city".equals(resolveInfo.activityInfo.packageName));
|
||||||
// resolveInfos.removeIf(applicationInfo -> "com.uiui.sn".equals(applicationInfo.packageName));
|
// resolveInfos.removeIf(applicationInfo -> "com.uiui.zysn".equals(applicationInfo.packageName));
|
||||||
}
|
}
|
||||||
resolveInfos.sort(new Comparator<ResolveInfo>() {
|
resolveInfos.sort(new Comparator<ResolveInfo>() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,168 +0,0 @@
|
|||||||
package com.uiui.zyos.utils;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.provider.Settings;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class AppUsedTimeUtils {
|
|
||||||
private static final String TAG = AppUsedTimeUtils.class.getSimpleName();
|
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
|
||||||
private static AppUsedTimeUtils sInstance;
|
|
||||||
private Context mContext;
|
|
||||||
|
|
||||||
private SimpleDateFormat ruleSDF = new SimpleDateFormat("HH:mm:ss");
|
|
||||||
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
|
|
||||||
private AppTimeinfo appTimeinfo;
|
|
||||||
|
|
||||||
private AppUsedTimeUtils(Context context) {
|
|
||||||
this.mContext = context;
|
|
||||||
appTimeinfo = getAppTimeinfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void init(Context context) {
|
|
||||||
if (sInstance == null) {
|
|
||||||
sInstance = new AppUsedTimeUtils(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AppUsedTimeUtils getInstance() {
|
|
||||||
if (sInstance == null) {
|
|
||||||
throw new IllegalStateException("You must be init TimeUtils first");
|
|
||||||
}
|
|
||||||
return sInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String normalStartTime = "8:00:00";
|
|
||||||
private static String unusualStartTime = "22:00:00";
|
|
||||||
|
|
||||||
static class AppTimeinfo implements Serializable {
|
|
||||||
private static final long serialVersionUID = 5373751133823666192L;
|
|
||||||
|
|
||||||
AppTimeinfo() {
|
|
||||||
this.appPackageName = "";
|
|
||||||
this.endTime = 0;
|
|
||||||
this.startTime = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String appPackageName;
|
|
||||||
private long endTime;
|
|
||||||
private long startTime;
|
|
||||||
|
|
||||||
public String getAppPackageName() {
|
|
||||||
return appPackageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAppPackageName(String appPackageName) {
|
|
||||||
this.appPackageName = appPackageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getEndTime() {
|
|
||||||
return endTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEndTime(long endTime) {
|
|
||||||
this.endTime = endTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getStartTime() {
|
|
||||||
return startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStartTime(long startTime) {
|
|
||||||
this.startTime = startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized public void setAppPackageName(String name) {
|
|
||||||
appTimeinfo.setAppPackageName(name);
|
|
||||||
setAppTimeinfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized public String getAppPackageName() {
|
|
||||||
return appTimeinfo.getAppPackageName();
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized public void setStartTime(long time) {
|
|
||||||
appTimeinfo.setStartTime(time);
|
|
||||||
setAppTimeinfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized public long getStartTime() {
|
|
||||||
return appTimeinfo.getStartTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized public void setEndTime(long time) {
|
|
||||||
appTimeinfo.setEndTime(time);
|
|
||||||
setAppTimeinfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized public long getEndTime() {
|
|
||||||
return appTimeinfo.getEndTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized private AppTimeinfo getAppTimeinfo() {
|
|
||||||
String jsonString = Settings.System.getString(mContext.getContentResolver(), "runningAppInfo");
|
|
||||||
if (TextUtils.isEmpty(jsonString)) {
|
|
||||||
return new AppTimeinfo();
|
|
||||||
}
|
|
||||||
Log.e(TAG, "getAppTimeinfo: " + jsonString);
|
|
||||||
Type type = new TypeToken<AppTimeinfo>() {
|
|
||||||
}.getType();
|
|
||||||
Gson gson = new Gson();
|
|
||||||
AppTimeinfo appTimeinfo = gson.fromJson(jsonString, type);
|
|
||||||
return appTimeinfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized private void setAppTimeinfo() {
|
|
||||||
String jsonString = JsonParser.parseString(appTimeinfo.toString()).getAsJsonObject().toString();
|
|
||||||
Settings.System.putString(mContext.getContentResolver(), "runningAppInfo", jsonString);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final long DAY_TIME = 1000 * 60 * 60 * 24;
|
|
||||||
|
|
||||||
public boolean isNormalTime() {
|
|
||||||
long nowTime = System.currentTimeMillis();
|
|
||||||
String nowTimeString = ruleSDF.format(new Date(nowTime)); // 时间戳转换日期
|
|
||||||
try {
|
|
||||||
Date startDate = ruleSDF.parse(normalStartTime);
|
|
||||||
Date endDate = ruleSDF.parse(unusualStartTime);
|
|
||||||
Date now = ruleSDF.parse(nowTimeString);
|
|
||||||
Log.e(TAG, "isScreenshot: startDate = " + startDate);
|
|
||||||
Log.e(TAG, "isScreenshot: endDate = " + endDate);
|
|
||||||
Log.e(TAG, "isScreenshot: now = " + now);
|
|
||||||
if (startDate.getTime() <= now.getTime() && now.getTime() <= endDate.getTime()) {
|
|
||||||
return true;
|
|
||||||
} else if (endDate.getTime() < now.getTime() && now.getTime() <= startDate.getTime() + DAY_TIME) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (ParseException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
Log.e(TAG, "isScreenshot: " + e.getMessage());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2012 www.amsoft.cn
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.uiui.zyos.utils;
|
|
||||||
|
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.FileReader;
|
|
||||||
|
|
||||||
public class AppUtil {
|
|
||||||
private static String TAG = AppUtil.class.getSimpleName();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 描述:获取可用内存.
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static long getAvailMemory(Context context) {
|
|
||||||
// 获取android当前可用内存大小
|
|
||||||
ActivityManager activityManager = (ActivityManager) context
|
|
||||||
.getSystemService(Context.ACTIVITY_SERVICE);
|
|
||||||
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
|
|
||||||
activityManager.getMemoryInfo(memoryInfo);
|
|
||||||
// 当前系统可用内存 ,将获得的内存大小规格化
|
|
||||||
|
|
||||||
return memoryInfo.availMem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param context
|
|
||||||
* @return 可用的内存大小
|
|
||||||
*/
|
|
||||||
public static long getFreeMemory(Context context) {
|
|
||||||
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
|
||||||
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
|
|
||||||
activityManager.getMemoryInfo(memoryInfo);
|
|
||||||
long freeMem = memoryInfo.totalMem - memoryInfo.availMem;
|
|
||||||
// Log.e("getHardware", "getFreeMemory: " + freeMem);
|
|
||||||
return freeMem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 描述:总内存.
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static long getTotalMemory(Context context) {
|
|
||||||
// 系统内存信息文件
|
|
||||||
String file = "/proc/meminfo";
|
|
||||||
String memInfo;
|
|
||||||
String[] strs;
|
|
||||||
long memory = 0;
|
|
||||||
|
|
||||||
try {
|
|
||||||
FileReader fileReader = new FileReader(file);
|
|
||||||
BufferedReader bufferedReader = new BufferedReader(fileReader, 8192);
|
|
||||||
// 读取meminfo第一行,系统内存大小
|
|
||||||
memInfo = bufferedReader.readLine();
|
|
||||||
strs = memInfo.split("\\s+");
|
|
||||||
for (String str : strs) {
|
|
||||||
Log.e(TAG, "getTotalMemory: " + str + "\t");
|
|
||||||
}
|
|
||||||
// 获得系统总内存,单位KB
|
|
||||||
memory = Integer.valueOf(strs[1]).intValue();
|
|
||||||
bufferedReader.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
// Byte转位KB或MB
|
|
||||||
return memory * 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
package com.uiui.zyos.utils;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.PixelFormat;
|
|
||||||
import android.graphics.drawable.AdaptiveIconDrawable;
|
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Build;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
|
|
||||||
public class BitmapUtils {
|
|
||||||
public static Bitmap Bytes2Bimap(byte[] b) {
|
|
||||||
if (b.length != 0) {
|
|
||||||
return BitmapFactory.decodeByteArray(b, 0, b.length);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] Bitmap2Bytes(Bitmap bitmap) {
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
||||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
|
|
||||||
byte[] data = baos.toByteArray();
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Drawable转换成一个Bitmap
|
|
||||||
*
|
|
||||||
* @param drawable drawable对象
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static final Bitmap drawableToBitmap(Drawable drawable) {
|
|
||||||
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
|
|
||||||
drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
|
|
||||||
Canvas canvas = new Canvas(bitmap);
|
|
||||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
|
||||||
drawable.draw(canvas);
|
|
||||||
return bitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static Bitmap drawableToBitamp(Drawable drawable) {
|
|
||||||
Bitmap bitmap;
|
|
||||||
BitmapDrawable bd = (BitmapDrawable) drawable;
|
|
||||||
bitmap = bd.getBitmap();
|
|
||||||
return bitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Bitmap getIconBitmap(Context context, Drawable drawable) {
|
|
||||||
try {
|
|
||||||
if (drawable == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && drawable instanceof AdaptiveIconDrawable) {
|
|
||||||
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
|
|
||||||
Canvas canvas = new Canvas(bitmap);
|
|
||||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
|
||||||
drawable.draw(canvas);
|
|
||||||
return Utils.getRoundedBitmap(bitmap, context);
|
|
||||||
} else {
|
|
||||||
return Utils.getRoundedBitmap(((BitmapDrawable) drawable).getBitmap(), context);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2018 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.uiui.zyos.utils;
|
|
||||||
|
|
||||||
import android.util.MathUtils;
|
|
||||||
|
|
||||||
public class BrightnessUtils {
|
|
||||||
|
|
||||||
public static final int GAMMA_SPACE_MIN = 0;
|
|
||||||
public static final int GAMMA_SPACE_MAX = 65535;
|
|
||||||
|
|
||||||
// Hybrid Log Gamma constant values
|
|
||||||
private static final float R = 0.5f;
|
|
||||||
private static final float A = 0.17883277f;
|
|
||||||
private static final float B = 0.28466892f;
|
|
||||||
private static final float C = 0.55991073f;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A function for converting from the gamma space that the slider works in to the
|
|
||||||
* linear space that the setting works in.
|
|
||||||
* <p>
|
|
||||||
* The gamma space effectively provides us a way to make linear changes to the slider that
|
|
||||||
* result in linear changes in perception. If we made changes to the slider in the linear space
|
|
||||||
* then we'd see an approximately logarithmic change in perception (c.f. Fechner's Law).
|
|
||||||
* <p>
|
|
||||||
* Internally, this implements the Hybrid Log Gamma electro-optical transfer function, which is
|
|
||||||
* a slight improvement to the typical gamma transfer function for displays whose max
|
|
||||||
* brightness exceeds the 120 nit reference point, but doesn't set a specific reference
|
|
||||||
* brightness like the PQ function does.
|
|
||||||
* <p>
|
|
||||||
* Note that this transfer function is only valid if the display's backlight value is a linear
|
|
||||||
* control. If it's calibrated to be something non-linear, then a different transfer function
|
|
||||||
* should be used.
|
|
||||||
*
|
|
||||||
* @param val The slider value.
|
|
||||||
* @param min The minimum acceptable value for the setting.
|
|
||||||
* @param max The maximum acceptable value for the setting.
|
|
||||||
* @return The corresponding setting value.
|
|
||||||
*/
|
|
||||||
public static final int convertGammaToLinear(int val, int min, int max) {
|
|
||||||
final float normalizedVal = MathUtils.norm(GAMMA_SPACE_MIN, GAMMA_SPACE_MAX, val);
|
|
||||||
final float ret;
|
|
||||||
if (normalizedVal <= R) {
|
|
||||||
ret = MathUtils.sq(normalizedVal / R);
|
|
||||||
} else {
|
|
||||||
ret = MathUtils.exp((normalizedVal - C) / A) + B;
|
|
||||||
}
|
|
||||||
|
|
||||||
// HLG is normalized to the range [0, 12], so we need to re-normalize to the range [0, 1]
|
|
||||||
// in order to derive the correct setting value.
|
|
||||||
return Math.round(MathUtils.lerp(min, max, ret / 12));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Version of {@link #convertGammaToLinear} that takes and returns float values.
|
|
||||||
* TODO(flc): refactor Android Auto to use float version
|
|
||||||
*
|
|
||||||
* @param val The slider value.
|
|
||||||
* @param min The minimum acceptable value for the setting.
|
|
||||||
* @param max The maximum acceptable value for the setting.
|
|
||||||
* @return The corresponding setting value.
|
|
||||||
*/
|
|
||||||
public static final float convertGammaToLinearFloat(int val, float min, float max) {
|
|
||||||
final float normalizedVal = MathUtils.norm(GAMMA_SPACE_MIN, GAMMA_SPACE_MAX, val);
|
|
||||||
final float ret;
|
|
||||||
if (normalizedVal <= R) {
|
|
||||||
ret = MathUtils.sq(normalizedVal / R);
|
|
||||||
} else {
|
|
||||||
ret = MathUtils.exp((normalizedVal - C) / A) + B;
|
|
||||||
}
|
|
||||||
|
|
||||||
// HLG is normalized to the range [0, 12], ensure that value is within that range,
|
|
||||||
// it shouldn't be out of bounds.
|
|
||||||
final float normalizedRet = MathUtils.constrain(ret, 0, 12);
|
|
||||||
|
|
||||||
// Re-normalize to the range [0, 1]
|
|
||||||
// in order to derive the correct setting value.
|
|
||||||
return MathUtils.lerp(min, max, normalizedRet / 12);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A function for converting from the linear space that the setting works in to the
|
|
||||||
* gamma space that the slider works in.
|
|
||||||
* <p>
|
|
||||||
* The gamma space effectively provides us a way to make linear changes to the slider that
|
|
||||||
* result in linear changes in perception. If we made changes to the slider in the linear space
|
|
||||||
* then we'd see an approximately logarithmic change in perception (c.f. Fechner's Law).
|
|
||||||
* <p>
|
|
||||||
* Internally, this implements the Hybrid Log Gamma opto-electronic transfer function, which is
|
|
||||||
* a slight improvement to the typical gamma transfer function for displays whose max
|
|
||||||
* brightness exceeds the 120 nit reference point, but doesn't set a specific reference
|
|
||||||
* brightness like the PQ function does.
|
|
||||||
* <p>
|
|
||||||
* Note that this transfer function is only valid if the display's backlight value is a linear
|
|
||||||
* control. If it's calibrated to be something non-linear, then a different transfer function
|
|
||||||
* should be used.
|
|
||||||
*
|
|
||||||
* @param val The brightness setting value.
|
|
||||||
* @param min The minimum acceptable value for the setting.
|
|
||||||
* @param max The maximum acceptable value for the setting.
|
|
||||||
* @return The corresponding slider value
|
|
||||||
*/
|
|
||||||
public static final int convertLinearToGamma(int val, int min, int max) {
|
|
||||||
return convertLinearToGammaFloat((float) val, (float) min, (float) max);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Version of {@link #convertLinearToGamma} that takes float values.
|
|
||||||
* TODO: brightnessfloat merge with above method(?)
|
|
||||||
*
|
|
||||||
* @param val The brightness setting value.
|
|
||||||
* @param min The minimum acceptable value for the setting.
|
|
||||||
* @param max The maximum acceptable value for the setting.
|
|
||||||
* @return The corresponding slider value
|
|
||||||
*/
|
|
||||||
public static final int convertLinearToGammaFloat(float val, float min, float max) {
|
|
||||||
// For some reason, HLG normalizes to the range [0, 12] rather than [0, 1]
|
|
||||||
final float normalizedVal = MathUtils.norm(min, max, val) * 12;
|
|
||||||
final float ret;
|
|
||||||
if (normalizedVal <= 1f) {
|
|
||||||
ret = MathUtils.sqrt(normalizedVal) * R;
|
|
||||||
} else {
|
|
||||||
ret = A * MathUtils.log(normalizedVal - B) + C;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Math.round(MathUtils.lerp(GAMMA_SPACE_MIN, GAMMA_SPACE_MAX, ret));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package com.uiui.zyos.utils;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 作者 mjsheng
|
|
||||||
* 日期 2018/8/31 09:50
|
|
||||||
* 邮箱 501802639@qq.com
|
|
||||||
* 来自:
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class DataUtil {
|
|
||||||
private static SimpleDateFormat day = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
||||||
private static SimpleDateFormat hour = new SimpleDateFormat("HH:mm");
|
|
||||||
private static SimpleDateFormat minute = new SimpleDateFormat("mm");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 格式化日期(精确到天)
|
|
||||||
*/
|
|
||||||
public static String formatDateDay() {
|
|
||||||
return day.format(new Date());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 格式化日期(hour)
|
|
||||||
*/
|
|
||||||
public static String formatDateHour() {
|
|
||||||
return hour.format(new Date());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 格式化日期(minute)
|
|
||||||
*/
|
|
||||||
public static String formatDateMinute() {
|
|
||||||
return minute.format(new Date());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
183
app/src/main/java/com/uiui/zyos/utils/DimenTool.java
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
package com.uiui.zyos.utils;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Administrator on 2016/11/25.
|
||||||
|
* 华为版本 sw480 的内容替换成sw400
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class DimenTool {
|
||||||
|
|
||||||
|
public static void gen() {
|
||||||
|
|
||||||
|
File file = new File("./app/src/main/res/values/dimens.xml");
|
||||||
|
BufferedReader reader = null;
|
||||||
|
StringBuilder sw320 = new StringBuilder();
|
||||||
|
StringBuilder sw360 = new StringBuilder();
|
||||||
|
StringBuilder sw400 = new StringBuilder();
|
||||||
|
StringBuilder sw460 = new StringBuilder();
|
||||||
|
StringBuilder sw480 = new StringBuilder();
|
||||||
|
StringBuilder sw560 = new StringBuilder();
|
||||||
|
StringBuilder sw600 = new StringBuilder();
|
||||||
|
StringBuilder sw609 = new StringBuilder();
|
||||||
|
StringBuilder sw640 = new StringBuilder();
|
||||||
|
StringBuilder sw720 = new StringBuilder();
|
||||||
|
StringBuilder sw760 = new StringBuilder();
|
||||||
|
StringBuilder sw800 = new StringBuilder();
|
||||||
|
StringBuilder sw860 = new StringBuilder();
|
||||||
|
StringBuilder sw900 = new StringBuilder();
|
||||||
|
// StringBuilder mdpi = new StringBuilder();
|
||||||
|
// StringBuilder hdpi = new StringBuilder();
|
||||||
|
// StringBuilder xhdpi = new StringBuilder();
|
||||||
|
// StringBuilder xxhdpi = new StringBuilder();
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
System.out.println("生成不同分辨率:");
|
||||||
|
reader = new BufferedReader(new FileReader(file));
|
||||||
|
String tempString;
|
||||||
|
int line = 1;
|
||||||
|
// 一次读入一行,直到读入null为文件结束
|
||||||
|
|
||||||
|
java.text.DecimalFormat df = new java.text.DecimalFormat("#.##");
|
||||||
|
while ((tempString = reader.readLine()) != null) {
|
||||||
|
|
||||||
|
if (tempString.contains("</dimen>")) {
|
||||||
|
//tempString = tempString.replaceAll(" ", "");
|
||||||
|
String start = tempString.substring(0, tempString.indexOf(">") + 1);
|
||||||
|
String end = tempString.substring(tempString.lastIndexOf("<") - 2);
|
||||||
|
double num = Double.valueOf(tempString.substring(tempString.indexOf(">") + 1, tempString.indexOf("</dimen>") - 2));
|
||||||
|
|
||||||
|
sw320.append(start).append(df.format((double) num * 0.4)).append(end).append("\n");
|
||||||
|
sw360.append(start).append(df.format((double) num * 0.45)).append(end).append("\n");
|
||||||
|
sw400.append(start).append(df.format((double) num * 0.5)).append(end).append("\n");
|
||||||
|
sw460.append(start).append(df.format((double) num * 0.575)).append(end).append("\n");
|
||||||
|
sw480.append(start).append(df.format((double) num * 0.6)).append(end).append("\n");
|
||||||
|
|
||||||
|
|
||||||
|
sw560.append(start).append(df.format((double) num * 0.7)).append(end).append("\n");
|
||||||
|
sw600.append(start).append(df.format((double) num * 0.75)).append(end).append("\n");
|
||||||
|
sw609.append(start).append(df.format((double) num * 0.76125)).append(end).append("\n");
|
||||||
|
sw640.append(start).append(df.format((double) num * 0.85)).append(end).append("\n"); // 适配学仕宝
|
||||||
|
sw720.append(start).append(df.format((double) num * 0.9)).append(end).append("\n");
|
||||||
|
sw760.append(start).append(df.format((double) num * 0.95)).append(end).append("\n");
|
||||||
|
sw800.append(tempString).append("\n");
|
||||||
|
sw860.append(start).append(df.format((double) num * 1.06)).append(end).append("\n");
|
||||||
|
sw900.append(start).append(df.format((double) num * 1.125)).append(end).append("\n");
|
||||||
|
|
||||||
|
// mdpi.append(start).append(df.format((double) num * 0.75)).append(end).append("\n");
|
||||||
|
// hdpi.append(start).append(df.format((double) num * 1)).append(end).append("\n");
|
||||||
|
// xhdpi.append(start).append(df.format((double) num * 1.5)).append(end).append("\n");
|
||||||
|
// xxhdpi.append(start).append(df.format((double) num * 2)).append(end).append("\n");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
sw320.append(tempString).append("\n");
|
||||||
|
sw360.append(tempString).append("\n");
|
||||||
|
sw400.append(tempString).append("\n");
|
||||||
|
sw460.append(tempString).append("\n");
|
||||||
|
sw480.append(tempString).append("\n");
|
||||||
|
sw560.append(tempString).append("\n");
|
||||||
|
sw600.append(tempString).append("\n");
|
||||||
|
sw609.append(tempString).append("\n");
|
||||||
|
sw640.append(tempString).append("\n");
|
||||||
|
sw760.append(tempString).append("\n");
|
||||||
|
sw720.append(tempString).append("\n");
|
||||||
|
sw800.append(tempString).append("\n");
|
||||||
|
sw860.append(tempString).append("\n");
|
||||||
|
sw900.append(tempString).append("\n");
|
||||||
|
// mdpi.append(tempString).append("\n");
|
||||||
|
// hdpi.append(tempString).append("\n");
|
||||||
|
// xhdpi.append(tempString).append("\n");
|
||||||
|
// xxhdpi.append(tempString).append("\n");
|
||||||
|
}
|
||||||
|
line++;
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
System.out.println("<!-- sw480 -->");
|
||||||
|
System.out.println(sw480);
|
||||||
|
System.out.println("<!-- sw600 -->");
|
||||||
|
System.out.println(sw600);
|
||||||
|
|
||||||
|
System.out.println("<!-- sw720 -->");
|
||||||
|
System.out.println(sw720);
|
||||||
|
System.out.println("<!-- sw800 -->");
|
||||||
|
System.out.println(sw800);
|
||||||
|
|
||||||
|
String sw320file = "./app/src/main/res/values-sw310dp/dimens.xml";
|
||||||
|
String sw360file = "./app/src/main/res/values-sw350dp/dimens.xml";
|
||||||
|
String sw400file = "./app/src/main/res/values-sw390dp/dimens.xml";
|
||||||
|
String sw460file = "./app/src/main/res/values-sw450dp/dimens.xml";
|
||||||
|
String sw480file = "./app/src/main/res/values-sw470dp/dimens.xml";
|
||||||
|
String sw560file = "./app/src/main/res/values-sw550dp/dimens.xml";
|
||||||
|
String sw600file = "./app/src/main/res/values-sw500dp/dimens.xml";
|
||||||
|
String sw609file = "./app/src/main/res/values-sw609dp/dimens.xml";
|
||||||
|
String sw640file = "./app/src/main/res/values-sw630dp/dimens.xml";
|
||||||
|
String sw720file = "./app/src/main/res/values-sw710dp/dimens.xml";
|
||||||
|
String sw760file = "./app/src/main/res/values-sw760dp/dimens.xml";
|
||||||
|
String sw800file = "./app/src/main/res/values-sw800dp/dimens.xml";
|
||||||
|
String sw860file = "./app/src/main/res/values-sw850dp/dimens.xml";
|
||||||
|
String sw900file = "./app/src/main/res/values-sw890dp/dimens.xml";
|
||||||
|
// String mdpifile = "./app/src/main/res/values-mdpi/dimens.xml";
|
||||||
|
// String hdpifile = "./app/src/main/res/values-hdpi/dimens.xml";
|
||||||
|
// String xhdpifile = "./app/src/main/res/values-xhdpi/dimens.xml";
|
||||||
|
// String xxhdpifile = "./app/src/main/res/values-xxhdpi/dimens.xml";
|
||||||
|
writeFile(sw320file, sw320.toString());
|
||||||
|
writeFile(sw360file, sw360.toString());
|
||||||
|
writeFile(sw400file, sw400.toString());
|
||||||
|
writeFile(sw460file, sw460.toString());
|
||||||
|
writeFile(sw480file, sw480.toString());
|
||||||
|
writeFile(sw560file, sw560.toString());
|
||||||
|
writeFile(sw600file, sw600.toString());
|
||||||
|
|
||||||
|
writeFile(sw609file, sw609.toString());
|
||||||
|
|
||||||
|
writeFile(sw640file, sw640.toString());
|
||||||
|
writeFile(sw720file, sw720.toString());
|
||||||
|
writeFile(sw760file, sw720.toString());
|
||||||
|
writeFile(sw800file, sw800.toString());
|
||||||
|
writeFile(sw860file, sw860.toString());
|
||||||
|
writeFile(sw900file, sw900.toString());
|
||||||
|
// writeFile(mdpifile, mdpi.toString());
|
||||||
|
// writeFile(hdpifile, hdpi.toString());
|
||||||
|
// writeFile(xhdpifile, xhdpi.toString());
|
||||||
|
// writeFile(xxhdpifile, xxhdpi.toString());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (reader != null) {
|
||||||
|
try {
|
||||||
|
reader.close();
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeFile(String file, String text) {
|
||||||
|
PrintWriter out = null;
|
||||||
|
try {
|
||||||
|
File file1 = new File(file.replace("/dimens.xml","").trim());
|
||||||
|
if (!file1.exists()) {
|
||||||
|
file1.mkdirs();
|
||||||
|
}
|
||||||
|
out = new PrintWriter(new BufferedWriter(new FileWriter(file)));
|
||||||
|
out.println(text);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
gen();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package com.uiui.zyos.utils;
|
|
||||||
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
public class FileUtil {
|
|
||||||
public static String getFileType(String url) {
|
|
||||||
if (url.indexOf("/") == -1) {
|
|
||||||
return url.substring(url.indexOf("."), url.length());
|
|
||||||
} else {
|
|
||||||
String fileName = url.substring(url.lastIndexOf("/"));
|
|
||||||
return fileName.substring(fileName.indexOf("."), fileName.length());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static HashSet<String> videoFormat = new HashSet<String>() {{
|
|
||||||
this.add(".mp4");
|
|
||||||
this.add(".avi");
|
|
||||||
this.add(".nkv");
|
|
||||||
this.add(".flv");
|
|
||||||
}};
|
|
||||||
private static HashSet<String> pictureFormat = new HashSet<String>() {{
|
|
||||||
this.add(".png");
|
|
||||||
this.add(".jpg");
|
|
||||||
this.add(".jpeg");
|
|
||||||
this.add(".bmp");
|
|
||||||
}};
|
|
||||||
|
|
||||||
public static boolean isVideoFile(String fileName) {
|
|
||||||
if (TextUtils.isEmpty(fileName)) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (!fileName.startsWith(".")) {
|
|
||||||
return videoFormat.contains(getFileType(fileName));
|
|
||||||
} else {
|
|
||||||
return videoFormat.contains(fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isPictureFile(String fileName) {
|
|
||||||
if (TextUtils.isEmpty(fileName)) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (!fileName.startsWith(".")) {
|
|
||||||
return pictureFormat.contains(getFileType(fileName));
|
|
||||||
} else {
|
|
||||||
return pictureFormat.contains(fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
package com.uiui.zyos.utils;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class IconUtils {
|
|
||||||
public static List<String> appClassNameList = new ArrayList<String>() {{
|
|
||||||
this.add("com.uiui.sn");//设别信息
|
|
||||||
this.add("com.uiui.appstore");//应用市场
|
|
||||||
this.add("com.uiui.weather");//天气
|
|
||||||
this.add("com.android.browser");//浏览器
|
|
||||||
this.add("com.uiui.browser");//浏览器
|
|
||||||
this.add("com.aoleyun.browser");//浏览器
|
|
||||||
this.add("com.android.calculator2");//计算器
|
|
||||||
this.add("com.android.calendar");//日历
|
|
||||||
this.add("com.android.camera");//相机
|
|
||||||
this.add("com.mediatek.camera");//相机
|
|
||||||
this.add("com.android.camera2");//相机
|
|
||||||
this.add("com.android.contacts");//通讯录
|
|
||||||
this.add("com.android.deskclock");//时钟
|
|
||||||
this.add("com.android.dialer");//电话
|
|
||||||
this.add("com.android.dialer");//电话
|
|
||||||
this.add("com.android.gallery3d");//图库
|
|
||||||
this.add("com.android.mms");//信息
|
|
||||||
this.add("com.android.mms.ui");//信息
|
|
||||||
this.add("com.android.messaging");//信息
|
|
||||||
this.add("com.android.music");//音乐
|
|
||||||
this.add("com.android.providers.downloads.ui");//下载
|
|
||||||
this.add("com.android.quicksearchbox");//搜索
|
|
||||||
this.add("com.android.settings");//设置
|
|
||||||
this.add("com.android.soundrecorder");//录音机
|
|
||||||
this.add("com.android.stk.StkMain");//sim卡
|
|
||||||
this.add("com.android.stk");//sim卡
|
|
||||||
this.add("com.android.vdieo");//视频
|
|
||||||
this.add("com.mediatek.filemanager");//文件管理
|
|
||||||
this.add("com.android.documentsui");//下载
|
|
||||||
this.add("com.mediatek.fmradio");//收音机
|
|
||||||
this.add("com.android.fmradio");//收音机
|
|
||||||
this.add("com.android.email");//电子邮件
|
|
||||||
// this.add("com.ss.android.ugc.aweme");//抖音
|
|
||||||
// this.add("com.ss.android.article.news");//头条
|
|
||||||
// this.add("com.tencent.mm");//微信
|
|
||||||
}};
|
|
||||||
|
|
||||||
public static List<String> appIconList = new ArrayList<String>() {{
|
|
||||||
this.add("com_uiui_sn");
|
|
||||||
this.add("com_android_appstore");
|
|
||||||
this.add("com_uiui_weather");
|
|
||||||
this.add("com_android_browser");
|
|
||||||
this.add("com_android_browser");
|
|
||||||
this.add("com_android_browser");
|
|
||||||
this.add("com_android_calculator2");
|
|
||||||
this.add("com_android_calendar");
|
|
||||||
this.add("com_android_camera");
|
|
||||||
this.add("com_android_camera");
|
|
||||||
this.add("com_android_camera");
|
|
||||||
this.add("com_android_contacts");
|
|
||||||
this.add("com_android_deskclock");
|
|
||||||
this.add("com_android_dialer");
|
|
||||||
this.add("com_android_dialer");
|
|
||||||
this.add("com_android_gallery3d_app");
|
|
||||||
this.add("com_android_mms_ui");
|
|
||||||
this.add("com_android_mms_ui");
|
|
||||||
this.add("com_android_mms_ui");
|
|
||||||
this.add("com_android_music");
|
|
||||||
this.add("com_android_providers_downloads_ui");
|
|
||||||
this.add("com_android_quicksearchbox");
|
|
||||||
this.add("com_android_settings");
|
|
||||||
this.add("com_android_soundrecorder");
|
|
||||||
this.add("com_android_stk_stkmain");
|
|
||||||
this.add("com_android_stk_stkmain");
|
|
||||||
this.add("com_android_vdieo");
|
|
||||||
this.add("com_mediatek_filemanager");
|
|
||||||
this.add("com_mediatek_filemanager");
|
|
||||||
this.add("com_mediatek_fmradio");
|
|
||||||
this.add("com_mediatek_fmradio");//收音机
|
|
||||||
this.add("com_android_email");
|
|
||||||
// this.add("com_android_aweme2");
|
|
||||||
// this.add("com_android_news2");
|
|
||||||
// this.add("com_tencent_mm2");
|
|
||||||
}};
|
|
||||||
|
|
||||||
public static List<String> appIconList2 = new ArrayList<String>() {{
|
|
||||||
this.add("com_uiui_sn2");
|
|
||||||
this.add("com_android_appstore2");
|
|
||||||
this.add("com_uiui_weather2");
|
|
||||||
this.add("com_android_browser2");
|
|
||||||
this.add("com_android_browser2");
|
|
||||||
this.add("com_android_browser2");
|
|
||||||
this.add("com_android_calculator2");
|
|
||||||
this.add("com_android_calendar");
|
|
||||||
this.add("com_android_camera2");
|
|
||||||
this.add("com_android_camera2");
|
|
||||||
this.add("com_android_camera2");
|
|
||||||
this.add("com_android_contacts");
|
|
||||||
this.add("com_android_deskclock");
|
|
||||||
this.add("com_android_dialer2");
|
|
||||||
this.add("com_android_dialer2");
|
|
||||||
this.add("com_android_gallery3d_app2");
|
|
||||||
this.add("com_android_mms_ui2");
|
|
||||||
this.add("com_android_mms_ui2");
|
|
||||||
this.add("com_android_mms_ui2");
|
|
||||||
this.add("com_android_music");
|
|
||||||
this.add("com_android_providers_downloads_ui");
|
|
||||||
this.add("com_android_quicksearchbox");
|
|
||||||
this.add("com_android_settings2");
|
|
||||||
this.add("com_android_soundrecorder");
|
|
||||||
this.add("com_android_stk_stkmain");
|
|
||||||
this.add("com_android_stk_stkmain");
|
|
||||||
this.add("com_android_vdieo");
|
|
||||||
this.add("com_mediatek_filemanager");
|
|
||||||
this.add("com_mediatek_filemanager");
|
|
||||||
this.add("com_mediatek_fmradio");
|
|
||||||
this.add("com_mediatek_fmradio");//收音机
|
|
||||||
this.add("com_android_email");
|
|
||||||
this.add("com_android_aweme2");
|
|
||||||
this.add("com_android_news2");
|
|
||||||
this.add("com_tencent_mm2");
|
|
||||||
}};
|
|
||||||
|
|
||||||
static {
|
|
||||||
Log.e("IconUtils", "appClassNameList size: " + appClassNameList.size());
|
|
||||||
Log.e("IconUtils", "appIconList size: " + appIconList.size());
|
|
||||||
Log.e("IconUtils", "appIconList2 size: " + appIconList2.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
package com.uiui.zyos.utils;
|
|
||||||
|
|
||||||
import android.app.role.RoleManager;
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.content.pm.ResolveInfo;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.SystemProperties;
|
|
||||||
import android.os.UserHandle;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class LauncherUtils {
|
|
||||||
private static final String TAG = LauncherUtils.class.getSimpleName();
|
|
||||||
|
|
||||||
public static void openLauncher3(Context context) {
|
|
||||||
setDefaultDesktop(context, Launcher3, Launcher3Class);
|
|
||||||
if (!ApkUtils.openPackage(context, Launcher3)) {
|
|
||||||
setDefaultDesktop(context, Launcher3, Launcher3Class);
|
|
||||||
gotoLauncher(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void gotoLauncher(Context context) {
|
|
||||||
Intent i = new Intent(Intent.ACTION_MAIN);
|
|
||||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //android123提示如果是服务里调用,必须加入new task标识
|
|
||||||
i.addCategory(Intent.CATEGORY_HOME);
|
|
||||||
context.startActivity(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final String Launcher3 = "com.android.launcher3";
|
|
||||||
public static final String Launcher3Class = "com.android.launcher3.Launcher";
|
|
||||||
|
|
||||||
public static void setDefaultDesktop(Context context, String pkg, String className) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
||||||
setRoleHolderAsUser(context, pkg);
|
|
||||||
Log.e(TAG, "setDefaultDesktop: setRoleHolderAsUser");
|
|
||||||
} else {
|
|
||||||
//爱华设置,暂时屏蔽
|
|
||||||
// setDefaultLauncher(mContext, pkg, className);
|
|
||||||
Log.e(TAG, "setDefaultDesktop: setDefaultLauncher");
|
|
||||||
}
|
|
||||||
// String oldDesktop = (String) SPUtils.get(mContext, "default_launcher", "");
|
|
||||||
// if (Objects.equals(oldDesktop, pkg)) {
|
|
||||||
// Log.e(TAG, "setDefaultDesktop: " + "数据一致");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
Intent intent = new Intent("setDefaultLauncher");
|
|
||||||
intent.putExtra("package", pkg);
|
|
||||||
intent.putExtra("className", className);
|
|
||||||
// if (JGYUtils.getInstance().checkAppPlatform() == MTKPlatform) {
|
|
||||||
Log.e(TAG, "setDefaultDesktop: MTK");
|
|
||||||
//爱华定制
|
|
||||||
intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.AoleReceiver"));
|
|
||||||
// TODO: 2022/7/6 有问题
|
|
||||||
setDefaultLauncher(context, "com.android.transfer", "com.android.transfer.MainActivity");
|
|
||||||
SystemProperties.set("persist.sys.launcher.pkgname", pkg);
|
|
||||||
SystemProperties.set("persist.sys.launcher.classname", className);
|
|
||||||
// }
|
|
||||||
intent.setPackage("com.android.settings");
|
|
||||||
context.sendBroadcast(intent);
|
|
||||||
// ApkUtils.openPackage(mContext, pkg);
|
|
||||||
Log.e(TAG, "setDefaultDesktop: " + pkg + ":" + className);
|
|
||||||
Log.e(TAG, "setDefaultDesktop: " + "persist.sys.launcher.pkgname = " + SystemProperties.get("persist.sys.launcher.pkgname"));
|
|
||||||
Log.e(TAG, "setDefaultDesktop: " + "persist.sys.launcher.classname = " + SystemProperties.get("persist.sys.launcher.classname"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setDefaultLauncher(Context context, String defPackageName, String defClassName) {
|
|
||||||
try {
|
|
||||||
if (!TextUtils.isEmpty(defPackageName) && !TextUtils.isEmpty(defClassName)) {
|
|
||||||
IntentFilter filter = new IntentFilter();
|
|
||||||
filter.addAction("android.intent.action.MAIN");
|
|
||||||
filter.addCategory("android.intent.category.HOME");
|
|
||||||
filter.addCategory("android.intent.category.DEFAULT");
|
|
||||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
|
||||||
intent.addCategory(Intent.CATEGORY_HOME);
|
|
||||||
// 返回给定条件的所有ResolveInfo对象(本质上是Activity)
|
|
||||||
List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
|
||||||
int bestMatch = 0;
|
|
||||||
final int size = list.size();
|
|
||||||
ComponentName[] set = new ComponentName[size];
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
ResolveInfo ri = list.get(i);
|
|
||||||
set[i] = new ComponentName(ri.activityInfo.packageName, ri.activityInfo.name);
|
|
||||||
if (ri.match > bestMatch) {
|
|
||||||
bestMatch = ri.match;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ComponentName preActivity = new ComponentName(defPackageName, defClassName);
|
|
||||||
context.getPackageManager().addPreferredActivity(filter, bestMatch, set, preActivity);
|
|
||||||
}
|
|
||||||
} catch (java.lang.SecurityException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
Log.e(TAG, "setDefaultLauncher: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void setRoleHolderAsUser(Context context, String packageName) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
||||||
String roleName = "android.app.role.HOME";
|
|
||||||
boolean add = true;
|
|
||||||
int flags = 0;
|
|
||||||
UserHandle user = android.os.Process.myUserHandle();
|
|
||||||
Log.i("settingssssssstemf", (add ? "Adding" : "Removing") + " package as role holder, role: "
|
|
||||||
+ roleName + ", package: " + packageName);
|
|
||||||
// if (JGYUtils.getInstance().checkAppPlatform() != JGYUtils.MTKPlatform) {
|
|
||||||
RoleManager roleManager = context.getSystemService(RoleManager.class);
|
|
||||||
Executor executor = context.getMainExecutor();
|
|
||||||
Consumer<Boolean> callback = successful -> {
|
|
||||||
if (successful) {
|
|
||||||
Log.d("settingssssssstemf", "Package " + (add ? "added" : "removed")
|
|
||||||
+ " as role holder, role: " + roleName + ", package: " + packageName);
|
|
||||||
} else {
|
|
||||||
Log.d("settingssssssstemf", "Failed to " + (add ? "add" : "remove")
|
|
||||||
+ " package as role holder, role: " + roleName + ", package: "
|
|
||||||
+ packageName);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
roleManager.addRoleHolderAsUser(roleName, packageName, flags, user, executor, callback);
|
|
||||||
Log.i("settingssssssstemf", "addRoleHolderAsUser done");
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isDefaultHome(Context context) {
|
|
||||||
Intent intent = new Intent(Intent.ACTION_MAIN);//Intent.ACTION_VIEW
|
|
||||||
intent.addCategory("android.intent.category.HOME");
|
|
||||||
intent.addCategory("android.intent.category.DEFAULT");
|
|
||||||
PackageManager pm = context.getPackageManager();
|
|
||||||
ResolveInfo info = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
|
||||||
boolean isDefault = context.getPackageName().equals(info.activityInfo.packageName);
|
|
||||||
return isDefault;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.uiui.zyos.utils;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class SchemeUtils {
|
|
||||||
private static String TAG = SchemeUtils.class.getSimpleName();
|
|
||||||
|
|
||||||
public static final String SCHEME_TONGUE = "uiuihealth://tongue";
|
|
||||||
public static final String SCHEME_FACE = "uiuihealth://face";
|
|
||||||
public static final String SCHEME_HAND = "uiuihealth://hand";
|
|
||||||
|
|
||||||
public static void openScheme(Activity context, String uri) {
|
|
||||||
if (TextUtils.isEmpty(uri)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
|
|
||||||
try {
|
|
||||||
context.startActivity(intent);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "openScheme: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
package com.uiui.zyos.utils;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.KeyguardManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.PowerManager;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
|
|
||||||
import androidx.annotation.RequiresApi;
|
|
||||||
|
|
||||||
public class WakeUpUtils {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 唤醒手机屏幕并解锁
|
|
||||||
*/
|
|
||||||
public static void wakeUpAndUnlock(Activity activity) {
|
|
||||||
// 获取电源管理器对象
|
|
||||||
PowerManager pm = (PowerManager) activity.getApplicationContext()
|
|
||||||
.getSystemService(Context.POWER_SERVICE);
|
|
||||||
boolean screenOn = pm.isScreenOn();
|
|
||||||
Log.d("WakeScreen0", "screenOn: " + screenOn);
|
|
||||||
if (!screenOn) {
|
|
||||||
// 获取PowerManager.WakeLock对象,后面的参数|表示同时传入两个值,最后的是LogCat里用的Tag
|
|
||||||
@SuppressLint("InvalidWakeLockTag") PowerManager.WakeLock wl = pm.newWakeLock(
|
|
||||||
PowerManager.ACQUIRE_CAUSES_WAKEUP |
|
|
||||||
PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright");
|
|
||||||
wl.acquire(10000); // 点亮屏幕
|
|
||||||
wl.release(); // 释放
|
|
||||||
}
|
|
||||||
// 屏幕解锁
|
|
||||||
KeyguardManager keyguardManager = (KeyguardManager) activity.getApplicationContext()
|
|
||||||
.getSystemService(Context.KEYGUARD_SERVICE);
|
|
||||||
KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("unLock");
|
|
||||||
// 屏幕锁定
|
|
||||||
// keyguardLock.reenableKeyguard();
|
|
||||||
keyguardLock.disableKeyguard(); // 解锁
|
|
||||||
unLockScreen(activity);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void unLockScreen(Activity activity) {
|
|
||||||
final Window win = activity.getWindow();
|
|
||||||
win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
|
|
||||||
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
|
|
||||||
|
|
||||||
win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
|
||||||
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
|
||||||
| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 唤醒手机屏幕并解锁
|
|
||||||
*/
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
|
||||||
public static void wakeUpAndUnlockScreen(Activity activity) {
|
|
||||||
|
|
||||||
Window win = activity.getWindow();
|
|
||||||
win.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
|
|
||||||
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
|
|
||||||
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
|
|
||||||
|
|
||||||
PowerManager pm = (PowerManager) activity.getSystemService(Context.POWER_SERVICE);
|
|
||||||
@SuppressLint("InvalidWakeLockTag")
|
|
||||||
PowerManager.WakeLock wakelock = pm.newWakeLock(
|
|
||||||
PowerManager.FULL_WAKE_LOCK
|
|
||||||
| PowerManager.ACQUIRE_CAUSES_WAKEUP, "xx");
|
|
||||||
wakelock.acquire();
|
|
||||||
wakelock.release();
|
|
||||||
|
|
||||||
KeyguardManager keyguardManager = (KeyguardManager) activity.getApplicationContext()
|
|
||||||
.getSystemService(Context.KEYGUARD_SERVICE);
|
|
||||||
|
|
||||||
if (activity == null) return;
|
|
||||||
keyguardManager.requestDismissKeyguard(activity, new KeyguardManager.KeyguardDismissCallback() {
|
|
||||||
@Override
|
|
||||||
public void onDismissError() {
|
|
||||||
super.onDismissError();
|
|
||||||
Log.d("xxx-->", "1 onDismissError");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDismissSucceeded() {
|
|
||||||
super.onDismissSucceeded();
|
|
||||||
Log.d("xxx-->", "1 onDismissSucceeded");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDismissCancelled() {
|
|
||||||
super.onDismissCancelled();
|
|
||||||
Log.d("xxx-->", "1 onDismissCancelled");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (activity == null) return;
|
|
||||||
keyguardManager.requestDismissKeyguard(activity, new KeyguardManager.KeyguardDismissCallback() {
|
|
||||||
@Override
|
|
||||||
public void onDismissError() {
|
|
||||||
super.onDismissError();
|
|
||||||
Log.d("xxx-->", "2 onDismissError");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDismissSucceeded() {
|
|
||||||
super.onDismissSucceeded();
|
|
||||||
Log.d("xxx-->", "2 onDismissSucceeded");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDismissCancelled() {
|
|
||||||
super.onDismissCancelled();
|
|
||||||
Log.d("xxx-->", "2 onDismissCancelled");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 19 KiB |