version:1.2.4
fix: update:优化显示未读短信和未接来电,增加手电筒和数据开关
This commit is contained in:
@@ -13,15 +13,14 @@ import androidx.databinding.DataBindingUtil;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
|
||||
import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.adapter.APPListAdapter;
|
||||
import com.xxpatx.os.base.BaseDataBindingActivity;
|
||||
import com.xxpatx.os.bean.AppListInfo;
|
||||
import com.xxpatx.os.custom.RecyclerViewSpacesItemDecoration;
|
||||
import com.xxpatx.os.service.NotificationService;
|
||||
import com.xxpatx.os.utils.ApkUtils;
|
||||
import com.xxpatx.os.utils.BitmapUtils;
|
||||
import com.xxpatx.os.view.RecyclerViewSpacesItemDecoration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
124
app/src/main/java/com/xxpatx/os/activity/FlashlightActivity.java
Normal file
124
app/src/main/java/com/xxpatx/os/activity/FlashlightActivity.java
Normal file
@@ -0,0 +1,124 @@
|
||||
package com.xxpatx.os.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.ContentObserver;
|
||||
import android.hardware.camera2.CameraAccessException;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.base.BaseDataBindingActivity;
|
||||
import com.xxpatx.os.databinding.ActivityFlashlightBinding;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
public class FlashlightActivity extends BaseDataBindingActivity {
|
||||
|
||||
private ActivityFlashlightBinding mBinding;
|
||||
|
||||
private CameraManager cameraManager;
|
||||
|
||||
private ContentObserver mFlashLightObserver = new ContentObserver(new Handler(Looper.getMainLooper())) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange) {
|
||||
super.onChange(selfChange);
|
||||
Log.e("mFlashLightObserver", "onChange: " + Settings.System.getInt(getContentResolver(), Settings.Secure.FLASHLIGHT_ENABLED, 0));
|
||||
if (isFlashlightEnabled()) {
|
||||
mBinding.ivStatu.setImageDrawable(getDrawable(R.drawable.icon_flash_light_open));
|
||||
} else {
|
||||
mBinding.ivStatu.setImageDrawable(getDrawable(R.drawable.icon_flash_light_close));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataBinding() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_flashlight);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
UltimateBarX.addStatusBarTopPadding(mBinding.clExit);
|
||||
UltimateBarX.addNavigationBarBottomPadding(mBinding.clBottom);
|
||||
|
||||
getContentResolver().registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.FLASHLIGHT_ENABLED),
|
||||
true,
|
||||
mFlashLightObserver);
|
||||
|
||||
cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
|
||||
if (isFlashlightAvailable()) {
|
||||
if (isFlashlightEnabled()) {
|
||||
mBinding.ivStatu.setImageDrawable(getDrawable(R.drawable.icon_flash_light_open));
|
||||
} else {
|
||||
mBinding.ivStatu.setImageDrawable(getDrawable(R.drawable.icon_flash_light_close));
|
||||
}
|
||||
} else {
|
||||
mBinding.tvFlashlightStatu.setText("手电筒不可用");
|
||||
}
|
||||
mBinding.clTrun.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (isFlashlightAvailable()) {
|
||||
if (isFlashlightEnabled()) {
|
||||
try {
|
||||
String CameraId = cameraManager.getCameraIdList()[0];
|
||||
cameraManager.setTorchMode(CameraId, false);
|
||||
} catch (CameraAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mBinding.ivStatu.setImageDrawable(getDrawable(R.drawable.icon_flash_light_close));
|
||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.FLASHLIGHT_ENABLED, 0);
|
||||
} else {
|
||||
try {
|
||||
String CameraId = cameraManager.getCameraIdList()[0];
|
||||
cameraManager.setTorchMode(CameraId, true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mBinding.ivStatu.setImageDrawable(getDrawable(R.drawable.icon_flash_light_open));
|
||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.FLASHLIGHT_ENABLED, 1);
|
||||
}
|
||||
} else {
|
||||
Toaster.show("手电筒不可用");
|
||||
}
|
||||
}
|
||||
});
|
||||
mBinding.ivBack.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
getContentResolver().unregisterContentObserver(mFlashLightObserver);
|
||||
}
|
||||
|
||||
private boolean isFlashlightAvailable() {
|
||||
return getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
|
||||
}
|
||||
|
||||
private boolean isFlashlightEnabled() {
|
||||
return Settings.Secure.getInt(getContentResolver(), Settings.Secure.FLASHLIGHT_ENABLED, 0) == 1;
|
||||
}
|
||||
}
|
||||
55
app/src/main/java/com/xxpatx/os/activity/ImeiActivity.java
Normal file
55
app/src/main/java/com/xxpatx/os/activity/ImeiActivity.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package com.xxpatx.os.activity;
|
||||
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.base.BaseDataBindingActivity;
|
||||
import com.xxpatx.os.databinding.ActivityImeiBinding;
|
||||
import com.xxpatx.os.utils.Utils;
|
||||
|
||||
public class ImeiActivity extends BaseDataBindingActivity {
|
||||
private static final String TAG = "ImeiActivity";
|
||||
|
||||
private ActivityImeiBinding mBinding;
|
||||
|
||||
@Override
|
||||
public boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataBinding() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_imei);
|
||||
mBinding.setClick(new BtnClick());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
getWindow().setGravity(Gravity.BOTTOM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
mBinding.tvImei1.setText("IMEI1:" + Utils.getIMEI(this, 0));
|
||||
mBinding.tvImei2.setText("IMEI2:" + Utils.getIMEI(this, 1));
|
||||
mBinding.tvMeid.setText("MEID :" + Utils.getEmid(this));
|
||||
}
|
||||
|
||||
public class BtnClick {
|
||||
public void empty(View view) {
|
||||
|
||||
}
|
||||
|
||||
public void exit(View view) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
125
app/src/main/java/com/xxpatx/os/activity/NetworkActivity.java
Normal file
125
app/src/main/java/com/xxpatx/os/activity/NetworkActivity.java
Normal file
@@ -0,0 +1,125 @@
|
||||
package com.xxpatx.os.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.base.BaseDataBindingActivity;
|
||||
import com.xxpatx.os.databinding.ActivityNetworkBinding;
|
||||
import com.xxpatx.os.utils.Utils;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
public class NetworkActivity extends BaseDataBindingActivity implements NetworkUtils.OnNetworkStatusChangedListener {
|
||||
private static final String TAG = "NetworkActivity";
|
||||
|
||||
private ActivityNetworkBinding mBinding;
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
Log.e(TAG, "onDisconnected: ");
|
||||
setDataStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
||||
Log.e(TAG, "onConnected: ");
|
||||
setDataStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataBinding() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_network);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
UltimateBarX.addStatusBarTopPadding(mBinding.clExit);
|
||||
UltimateBarX.addNavigationBarBottomPadding(mBinding.clBottom);
|
||||
|
||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||
|
||||
setDataStatus();
|
||||
mBinding.clTrun.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (Utils.hasSimCard(NetworkActivity.this)) {
|
||||
if (getDataEnabled()) {
|
||||
setDataEnabled(false);
|
||||
} else {
|
||||
setDataEnabled(true);
|
||||
}
|
||||
setDataStatus();
|
||||
} else {
|
||||
Toaster.show("请插入SIM卡");
|
||||
}
|
||||
}
|
||||
});
|
||||
mBinding.ivBack.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setDataStatus() {
|
||||
if (getDataEnabled()) {
|
||||
mBinding.ivStatu.setImageDrawable(getDrawable(R.drawable.icon_flash_light_open));
|
||||
} else {
|
||||
mBinding.ivStatu.setImageDrawable(getDrawable(R.drawable.icon_flash_light_close));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
NetworkUtils.unregisterNetworkStatusChangedListener(this);
|
||||
}
|
||||
|
||||
public void setDataEnabled(int slotIdx, boolean enable) {
|
||||
int subid = SubscriptionManager.from(this).getActiveSubscriptionInfoForSimSlotIndex(slotIdx).getSubscriptionId();
|
||||
TelephonyManager telephonyService = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
||||
telephonyService.setDataEnabled(subid, enable);
|
||||
Log.e(TAG, "setDataEnabled: subid = " + subid + " enable = " + enable);
|
||||
|
||||
}
|
||||
|
||||
public boolean getDataEnabled(int slotIdx) {
|
||||
int subid = SubscriptionManager.from(this).getActiveSubscriptionInfoForSimSlotIndex(slotIdx).getSubscriptionId();
|
||||
TelephonyManager telephonyService = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
||||
boolean enabled = telephonyService.getDataEnabled(subid);
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setDataEnabled(boolean enable) {
|
||||
TelephonyManager telephonyService = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
||||
telephonyService.setDataEnabled(enable);
|
||||
Log.e(TAG, "setDataEnabled: enable = " + enable);
|
||||
|
||||
}
|
||||
|
||||
public boolean getDataEnabled() {
|
||||
TelephonyManager telephonyService = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
||||
boolean enabled = telephonyService.getDataEnabled();
|
||||
return enabled;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -22,8 +22,8 @@ import com.luck.picture.lib.interfaces.OnResultCallbackListener;
|
||||
import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.alarm.AlarmClockData;
|
||||
import com.xxpatx.os.alarm.AlarmUtils;
|
||||
import com.xxpatx.os.base.GlideEngine;
|
||||
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
||||
import com.xxpatx.os.custom.GlideEngine;
|
||||
import com.xxpatx.os.databinding.ActivityAlarmAddBinding;
|
||||
import com.xxpatx.os.service.main.MainService;
|
||||
import com.xxpatx.os.utils.FFmpegUtils;
|
||||
|
||||
@@ -5,12 +5,8 @@ import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bigkoo.pickerview.builder.TimePickerBuilder;
|
||||
import com.bigkoo.pickerview.listener.CustomListener;
|
||||
@@ -26,13 +22,12 @@ import com.luck.picture.lib.entity.LocalMedia;
|
||||
import com.luck.picture.lib.interfaces.OnResultCallbackListener;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.xiasuhuei321.loadingdialog.view.LoadingDialog;
|
||||
import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.alarm.AlarmClockData;
|
||||
import com.xxpatx.os.alarm.AlarmUtils;
|
||||
import com.xxpatx.os.base.GlideEngine;
|
||||
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.custom.GlideEngine;
|
||||
import com.xxpatx.os.databinding.ActivityAlarmEditBinding;
|
||||
import com.xxpatx.os.network.NetInterfaceManager;
|
||||
import com.xxpatx.os.utils.FFmpegUtils;
|
||||
|
||||
@@ -4,7 +4,7 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.config.CommonConfig;
|
||||
import com.xxpatx.os.databinding.ActivityAlarmListBinding;
|
||||
import com.xxpatx.os.dialog.DeleteDialog;
|
||||
import com.xxpatx.os.fragment.home.HomeFragment;
|
||||
import com.xxpatx.os.network.NetInterfaceManager;
|
||||
import com.xxpatx.os.push.PushManager;
|
||||
|
||||
@@ -81,7 +80,8 @@ public class AlarmListActivity extends BaseMvvmActivity<AlarmListViewModel, Acti
|
||||
@Override
|
||||
public void onLongClick(AlarmClockData alarmClockData) {
|
||||
boolean clockModify = mMMKV.decodeBool(CommonConfig.DISABLE_CLOCK_MODIFY, false);
|
||||
if (clockModify) {
|
||||
int alarm_clock_ctrl = Settings.Global.getInt(getContentResolver(), CommonConfig.ALARM_CLOCK_CTRL, 0);
|
||||
if (clockModify || alarm_clock_ctrl == 0) {
|
||||
Toaster.showLong("已禁用闹钟修改");
|
||||
} else {
|
||||
showDialog(alarmClockData);
|
||||
@@ -237,7 +237,8 @@ public class AlarmListActivity extends BaseMvvmActivity<AlarmListViewModel, Acti
|
||||
|
||||
public void add(View view) {
|
||||
boolean clockModify = mMMKV.decodeBool(CommonConfig.DISABLE_CLOCK_MODIFY, false);
|
||||
if (clockModify) {
|
||||
int alarm_clock_ctrl = Settings.Global.getInt(getContentResolver(), CommonConfig.ALARM_CLOCK_CTRL, 0);
|
||||
if (clockModify || alarm_clock_ctrl == 0) {
|
||||
Toaster.showLong("已禁用闹钟修改");
|
||||
} else {
|
||||
startActivity(new Intent(AlarmListActivity.this, AlarmAddActivity.class));
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
package com.xxpatx.os.activity.contact;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -19,9 +13,9 @@ import com.luck.picture.lib.interfaces.OnResultCallbackListener;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.base.GlideEngine;
|
||||
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.custom.GlideEngine;
|
||||
import com.xxpatx.os.databinding.ActivityAddContactBinding;
|
||||
import com.xxpatx.os.network.NetInterfaceManager;
|
||||
import com.xxpatx.os.utils.FileUtil;
|
||||
@@ -29,7 +23,6 @@ import com.xxpatx.os.utils.GlideLoadUtils;
|
||||
import com.xxpatx.os.utils.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -41,8 +34,6 @@ import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
import static com.xxpatx.os.utils.FileUtil.uriToFile;
|
||||
|
||||
public class AddContactActivity extends BaseMvvmActivity<AddContactViewModel, ActivityAddContactBinding> {
|
||||
private static final String TAG = "AddContactActivity";
|
||||
|
||||
@@ -114,7 +105,7 @@ public class AddContactActivity extends BaseMvvmActivity<AddContactViewModel, Ac
|
||||
avatarFile = FileUtil.drawableToFile(AddContactActivity.this, R.drawable.default_avatar, "avatar");
|
||||
} else {
|
||||
Uri uri = Uri.parse(avatarFilePath);
|
||||
avatarFile = uriToFile(uri, AddContactActivity.this);
|
||||
avatarFile = FileUtil.uriToFile(uri, AddContactActivity.this);
|
||||
}
|
||||
MediaType mediaType = MediaType.Companion.parse("image/png");
|
||||
RequestBody requestBody = RequestBody.Companion.create(avatarFile, mediaType);
|
||||
|
||||
@@ -21,9 +21,9 @@ import com.luck.picture.lib.entity.LocalMedia;
|
||||
import com.luck.picture.lib.interfaces.OnResultCallbackListener;
|
||||
import com.xiasuhuei321.loadingdialog.view.LoadingDialog;
|
||||
import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.base.GlideEngine;
|
||||
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
||||
import com.xxpatx.os.bean.Contact;
|
||||
import com.xxpatx.os.custom.GlideEngine;
|
||||
import com.xxpatx.os.databinding.ActivityAddWechatContactBinding;
|
||||
import com.xxpatx.os.db.ContactCacheUtils;
|
||||
import com.xxpatx.os.utils.ScreenUtil;
|
||||
|
||||
@@ -23,10 +23,10 @@ import com.luck.picture.lib.entity.LocalMedia;
|
||||
import com.luck.picture.lib.interfaces.OnResultCallbackListener;
|
||||
import com.xiasuhuei321.loadingdialog.view.LoadingDialog;
|
||||
import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.base.GlideEngine;
|
||||
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.Contact;
|
||||
import com.xxpatx.os.custom.GlideEngine;
|
||||
import com.xxpatx.os.databinding.ActivityEditContactBinding;
|
||||
import com.xxpatx.os.utils.FileUtil;
|
||||
import com.xxpatx.os.utils.ScreenUtil;
|
||||
|
||||
@@ -22,9 +22,9 @@ import com.xxpatx.os.adapter.CityAdapter;
|
||||
import com.xxpatx.os.adapter.DistrictAdapter;
|
||||
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
||||
import com.xxpatx.os.bean.AddressBean;
|
||||
import com.xxpatx.os.custom.RecyclerViewSpacesItemDecoration;
|
||||
import com.xxpatx.os.databinding.ActivityLocationBinding;
|
||||
import com.xxpatx.os.manager.AmapManager;
|
||||
import com.xxpatx.os.view.RecyclerViewSpacesItemDecoration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xxpatx.os.activity.main;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
@@ -9,11 +10,14 @@ import android.content.IntentFilter;
|
||||
import android.content.ServiceConnection;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.Cursor;
|
||||
import android.hardware.camera2.CameraAccessException;
|
||||
import android.hardware.camera2.CameraCharacteristics;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.CallLog;
|
||||
import android.provider.ContactsContract;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -22,13 +26,12 @@ import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.google.gson.Gson;
|
||||
@@ -44,7 +47,6 @@ import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.activity.dock.DockActivity;
|
||||
import com.xxpatx.os.activity.phone.PhoneActivity;
|
||||
import com.xxpatx.os.activity.update.UpdateActivity;
|
||||
import com.xxpatx.os.adapter.DockAppAdapter;
|
||||
import com.xxpatx.os.adapter.DockAppGridAdapter;
|
||||
import com.xxpatx.os.base.BaseFragmentPagerAdapter;
|
||||
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
|
||||
@@ -65,14 +67,15 @@ import com.xxpatx.os.utils.AppUsedTimeUtils;
|
||||
import com.xxpatx.os.utils.DayUtils;
|
||||
import com.xxpatx.os.utils.TimeUtils;
|
||||
import com.xxpatx.os.utils.Utils;
|
||||
import com.xxpatx.os.utils.WiFiUtils;
|
||||
import com.xxpatx.os.view.ScaleCircleNavigator;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
import net.lucode.hackware.magicindicator.ViewPagerHelper;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBinding> implements NetworkUtils.OnNetworkStatusChangedListener, NotificationService.NotificationListener {
|
||||
@@ -119,6 +122,7 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
public void onListenerUpdate() {
|
||||
Log.e(TAG, "onListenerUpdate: ");
|
||||
updateIconBg();
|
||||
mDockAppGridAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -284,6 +288,122 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 利用系统CallLog获取通话历史记录
|
||||
*
|
||||
* @param num 要读取记录的数量
|
||||
* @return
|
||||
*/
|
||||
public void getCallHistoryList(int num) {
|
||||
Cursor cs;
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_CALL_LOG)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this,
|
||||
new String[]{Manifest.permission.READ_CALL_LOG}, 1000);
|
||||
|
||||
}
|
||||
cs = getContentResolver().query(CallLog.Calls.CONTENT_URI, //系统方式获取通讯录存储地址
|
||||
new String[]{
|
||||
CallLog.Calls.CACHED_NAME, //姓名
|
||||
CallLog.Calls.NUMBER, //号码
|
||||
CallLog.Calls.TYPE, //呼入/呼出(2)/未接
|
||||
CallLog.Calls.DATE, //拨打时间
|
||||
CallLog.Calls.DURATION, //通话时长
|
||||
}, null, null, CallLog.Calls.DEFAULT_SORT_ORDER);
|
||||
int i = 0;
|
||||
if (cs != null && cs.getCount() > 0) {
|
||||
Date date = new Date(System.currentTimeMillis());
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String date_today = simpleDateFormat.format(date);
|
||||
for (cs.moveToFirst(); (!cs.isAfterLast()) && i < num; cs.moveToNext(), i++) {
|
||||
String callName = cs.getString(0); //名称
|
||||
String callNumber = cs.getString(1); //号码
|
||||
//如果名字为空,在通讯录查询一次有没有对应联系人
|
||||
if (callName == null || callName.equals("")) {
|
||||
String[] cols = {ContactsContract.PhoneLookup.DISPLAY_NAME};
|
||||
//设置查询条件
|
||||
String selection = ContactsContract.CommonDataKinds.Phone.NUMBER + "='" + callNumber + "'";
|
||||
Cursor cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
|
||||
cols, selection, null, null);
|
||||
int nameFieldColumnIndex = cursor.getColumnIndex(ContactsContract.PhoneLookup.DISPLAY_NAME);
|
||||
if (cursor.getCount() > 0) {
|
||||
cursor.moveToFirst();
|
||||
callName = cursor.getString(nameFieldColumnIndex);
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
//通话类型
|
||||
int callType = Integer.parseInt(cs.getString(2));
|
||||
String callTypeStr = "";
|
||||
switch (callType) {
|
||||
case CallLog.Calls.INCOMING_TYPE:
|
||||
callTypeStr = "CALLIN";
|
||||
break;
|
||||
case CallLog.Calls.OUTGOING_TYPE:
|
||||
callTypeStr = "CALLOUT";
|
||||
break;
|
||||
case CallLog.Calls.MISSED_TYPE:
|
||||
callTypeStr = "CAllMISS";
|
||||
break;
|
||||
default:
|
||||
//其他类型的,例如新增号码等记录不算进通话记录里,直接跳过
|
||||
Log.i("ssss", "" + callType);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
//拨打时间
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date callDate = new Date(Long.parseLong(cs.getString(3)));
|
||||
String callDateStr = sdf.format(callDate);
|
||||
if (callDateStr.equals(date_today)) { //判断是否为今天
|
||||
sdf = new SimpleDateFormat("HH:mm");
|
||||
callDateStr = sdf.format(callDate);
|
||||
} else if (date_today.contains(callDateStr.substring(0, 7))) { //判断是否为当月
|
||||
sdf = new SimpleDateFormat("dd");
|
||||
int callDay = Integer.valueOf(sdf.format(callDate));
|
||||
|
||||
int day = Integer.valueOf(sdf.format(date));
|
||||
if (day - callDay == 1) {
|
||||
callDateStr = "昨天";
|
||||
} else {
|
||||
sdf = new SimpleDateFormat("MM-dd");
|
||||
callDateStr = sdf.format(callDate);
|
||||
}
|
||||
} else if (date_today.contains(callDateStr.substring(0, 4))) { //判断是否为当年
|
||||
sdf = new SimpleDateFormat("MM-dd");
|
||||
callDateStr = sdf.format(callDate);
|
||||
}
|
||||
|
||||
//通话时长
|
||||
int callDuration = Integer.parseInt(cs.getString(4));
|
||||
int min = callDuration / 60;
|
||||
int sec = callDuration % 60;
|
||||
String callDurationStr = "";
|
||||
if (sec > 0) {
|
||||
if (min > 0) {
|
||||
callDurationStr = min + "分" + sec + "秒";
|
||||
} else {
|
||||
callDurationStr = sec + "秒";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* callName 名字
|
||||
* callNumber 号码
|
||||
* callTypeStr 通话类型
|
||||
* callDateStr 通话日期
|
||||
* callDurationStr 通话时长
|
||||
* 请在此处执行相关UI或存储操作,之后会查询下一条通话记录
|
||||
*/
|
||||
Log.i("Msg", "callName" + callName);
|
||||
Log.i("Msg", "callNumber" + callNumber);
|
||||
Log.i("Msg", "callTypeStr" + callTypeStr);
|
||||
Log.i("Msg", "callDateStr" + callDateStr);
|
||||
Log.i("Msg", "callDurationStr" + callDurationStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
mViewModel.getDesktopIconData().observe(this, new Observer<ArrayList<DesktopIcon>>() {
|
||||
@@ -716,6 +836,7 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
registerUpdateDesktopReceiver();
|
||||
registmUpdateAddressReceiver();
|
||||
registerTimeReceiver();
|
||||
registerMissCallReceiver();
|
||||
}
|
||||
|
||||
private void unregisterAllReceiver() {
|
||||
@@ -734,6 +855,9 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
if (mTimeChangedReceiver != null) {
|
||||
unregisterReceiver(mTimeChangedReceiver);
|
||||
}
|
||||
if (mMissCallReceiver != null) {
|
||||
unregisterReceiver(mMissCallReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
private void registNewAppReceiver() {
|
||||
@@ -785,7 +909,7 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
}
|
||||
}
|
||||
|
||||
public static final String ACTION_PACKAGE_HIDE = "com.uiui.aios.ACTION_PACKAGE_HIDE";
|
||||
public static final String ACTION_PACKAGE_HIDE = "com.xxpatx.os.ACTION_PACKAGE_HIDE";
|
||||
|
||||
private UpdateDesktopReceiver mUpdateDesktopReceiver;
|
||||
|
||||
@@ -859,6 +983,31 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
}
|
||||
}
|
||||
|
||||
private MissCallReceiver mMissCallReceiver;
|
||||
|
||||
public void registerMissCallReceiver() {
|
||||
if (mMissCallReceiver == null) {
|
||||
mMissCallReceiver = new MissCallReceiver();
|
||||
}
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction("com.android.phone.NotificationMgr.MissedCall_intent");
|
||||
registerReceiver(mMissCallReceiver, filter);
|
||||
}
|
||||
|
||||
private class MissCallReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if ("com.android.phone.NotificationMgr.MissedCall_intent".equals(action)) {
|
||||
int mMissCallCount = intent.getExtras().getInt("MissedCallNumber");
|
||||
Log.e("MissCallReceiver", "onReceive: " + mMissCallCount);
|
||||
mDockAppGridAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void setTime() {
|
||||
LiveEventBus
|
||||
.get("time")
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.xxpatx.os.activity.phone;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.provider.CallLog;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
@@ -73,7 +77,33 @@ public class PhoneActivity extends BaseMvvmActivity<PhoneViewModel, ActivityPhon
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
updateMissCallRecord();
|
||||
}
|
||||
|
||||
private void updateMissCallRecord() {
|
||||
Cursor cursor = getContentResolver().query(CallLog.Calls.CONTENT_URI,
|
||||
new String[]{CallLog.Calls._ID, CallLog.Calls.TYPE, CallLog.Calls.IS_READ},
|
||||
" " + CallLog.Calls.TYPE + "=? and " + CallLog.Calls.IS_READ + "=?",
|
||||
new String[]{String.valueOf(CallLog.Calls.MISSED_TYPE), "0"},
|
||||
CallLog.Calls.DEFAULT_SORT_ORDER);
|
||||
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
while (!cursor.isAfterLast()) {
|
||||
String id = cursor.getString(cursor.getColumnIndex(CallLog.Calls._ID));
|
||||
int is_read = cursor.getInt(cursor.getColumnIndex(CallLog.Calls.IS_READ));
|
||||
Log.e(TAG, "updateMissCallRecord: id = " + id + " is_read = " + is_read);
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(CallLog.Calls.IS_READ, 1);
|
||||
int rowsAffected = getContentResolver().update(CallLog.Calls.CONTENT_URI,
|
||||
values,
|
||||
CallLog.Calls._ID + "=?",
|
||||
new String[]{String.valueOf(id)}
|
||||
);
|
||||
Log.e(TAG, "updateMissCallRecord: rowsAffected = " + rowsAffected);
|
||||
cursor.moveToNext();
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,6 +9,8 @@ import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@@ -31,6 +33,16 @@ public class SelectNumberActivity extends BaseMvvmActivity<SelectNumberViewModel
|
||||
private TelecomManager telecomManager;
|
||||
private PhoneAdapter mPhoneAdapter;
|
||||
|
||||
@Override
|
||||
public boolean setNightMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setfitWindow() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_select_number;
|
||||
@@ -41,19 +53,21 @@ public class SelectNumberActivity extends BaseMvvmActivity<SelectNumberViewModel
|
||||
mViewModel.setCtx(this);
|
||||
mViewModel.setVDBinding(mViewDataBinding);
|
||||
mViewModel.setLifecycle(getLifecycleSubject());
|
||||
// mViewDataBinding.setClick(new BtnClick());
|
||||
mViewDataBinding.setClick(new BtnClick());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
Intent intent =getIntent();
|
||||
if (intent==null){
|
||||
getWindow().setGravity(Gravity.BOTTOM);
|
||||
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
String phone = intent.getStringExtra("phone_number");
|
||||
if (TextUtils.isEmpty(phone)){
|
||||
if (TextUtils.isEmpty(phone)) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
@@ -82,7 +96,7 @@ public class SelectNumberActivity extends BaseMvvmActivity<SelectNumberViewModel
|
||||
@Override
|
||||
public void initData() {
|
||||
List<SubscriptionInfo> subscriptionInfos = subscriptionManager.getActiveSubscriptionInfoList();
|
||||
List<String> stringList =new ArrayList<>();
|
||||
List<String> stringList = new ArrayList<>();
|
||||
for (SubscriptionInfo subscriptionInfo : subscriptionInfos) {
|
||||
Log.e(TAG, "initData: id = " + subscriptionInfo.getSubscriptionId());
|
||||
Log.e(TAG, "initData: mCardString = " + subscriptionInfo.getCardString());
|
||||
@@ -98,4 +112,14 @@ public class SelectNumberActivity extends BaseMvvmActivity<SelectNumberViewModel
|
||||
|
||||
Log.e(TAG, "initData: end");
|
||||
}
|
||||
|
||||
public class BtnClick {
|
||||
public void empty(View view) {
|
||||
|
||||
}
|
||||
|
||||
public void exit(View view) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class SettingActivity extends BaseMvvmActivity<SettingViewModel, Activity
|
||||
}
|
||||
|
||||
private void setStatus() {
|
||||
boolean showFloatWindow = mMMKV.decodeBool(CommonConfig.FLOAT_WINDOW, CommonConfig.FLOAT_WINDOW_STATU);
|
||||
boolean showFloatWindow = Settings.Global.getInt(getContentResolver(), CommonConfig.HOVER_HOME, CommonConfig.HOVER_HOME_STATUS) == 1;
|
||||
Log.e(TAG, "initView: showFloatWindow = " + showFloatWindow);
|
||||
mViewDataBinding.setFloatWindowEnable(showFloatWindow);
|
||||
|
||||
@@ -149,7 +149,7 @@ public class SettingActivity extends BaseMvvmActivity<SettingViewModel, Activity
|
||||
|
||||
private void showFloatingWindow() {
|
||||
mViewDataBinding.setFloatWindowEnable(true);
|
||||
mMMKV.encode(CommonConfig.FLOAT_WINDOW, true);
|
||||
Settings.Global.putInt(getContentResolver(), CommonConfig.HOVER_HOME, 1);
|
||||
startService(new Intent(SettingActivity.this, MainService.class));
|
||||
sendBroadcast(new Intent(MainService.ACTION_FLOAT_WINDOW_ON));
|
||||
}
|
||||
@@ -157,7 +157,7 @@ public class SettingActivity extends BaseMvvmActivity<SettingViewModel, Activity
|
||||
|
||||
private void hideFloatingWindow() {
|
||||
mViewDataBinding.setFloatWindowEnable(false);
|
||||
mMMKV.encode(CommonConfig.FLOAT_WINDOW, false);
|
||||
Settings.Global.putInt(getContentResolver(), CommonConfig.HOVER_HOME, 0);
|
||||
startService(new Intent(SettingActivity.this, MainService.class));
|
||||
sendBroadcast(new Intent(MainService.ACTION_FLOAT_WINDOW_OFF));
|
||||
}
|
||||
@@ -206,7 +206,7 @@ public class SettingActivity extends BaseMvvmActivity<SettingViewModel, Activity
|
||||
|
||||
public class BtnClick {
|
||||
public void openFloat(View view) {
|
||||
boolean floatWindowEnable = mMMKV.decodeBool(CommonConfig.FLOAT_WINDOW, CommonConfig.FLOAT_WINDOW_STATU);
|
||||
boolean floatWindowEnable = Settings.Global.getInt(getContentResolver(), CommonConfig.HOVER_HOME, CommonConfig.HOVER_HOME_STATUS) == 1;
|
||||
if (floatWindowEnable) {
|
||||
hideFloatingWindow();
|
||||
} else {
|
||||
@@ -267,7 +267,7 @@ public class SettingActivity extends BaseMvvmActivity<SettingViewModel, Activity
|
||||
intent.putExtra("auto_answer", !autoAccept);
|
||||
sendBroadcast(intent);
|
||||
} else {
|
||||
boolean floatWindowEnable = mMMKV.decodeBool(CommonConfig.FLOAT_WINDOW, CommonConfig.FLOAT_WINDOW_STATU);
|
||||
boolean floatWindowEnable = Settings.Global.getInt(getContentResolver(), CommonConfig.HOVER_HOME, CommonConfig.HOVER_HOME_STATUS) == 1;
|
||||
if (floatWindowEnable) {
|
||||
Toaster.showLong("因为系统限制,请先关闭悬浮窗功能,开启自动接听后再打开悬浮窗");
|
||||
} else {
|
||||
|
||||
@@ -58,6 +58,7 @@ public class CallRecordAdapter extends RecyclerView.Adapter<CallRecordAdapter.Ho
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Holder holder, int position) {
|
||||
RecordsInfo recordsInfo = mRecordsInfoList.get(position);
|
||||
// Log.e(TAG, "onBindViewHolder: _id = " + recordsInfo.getId());
|
||||
String phone = recordsInfo.getNumber();
|
||||
holder.tv_phone.setText(phone);
|
||||
holder.tv_name.setText(getName(phone));
|
||||
@@ -84,32 +85,14 @@ public class CallRecordAdapter extends RecyclerView.Adapter<CallRecordAdapter.Ho
|
||||
break;
|
||||
}
|
||||
holder.tv_time.setText(mSimpleDateFormat.format(new Date(recordsInfo.getDate())));
|
||||
holder.root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (Utils.isMultiSim(mContext)) {
|
||||
Intent intent = new Intent(mContext, SelectNumberActivity.class);
|
||||
intent.putExtra("phone_number", phone);
|
||||
mContext.startActivity(intent);
|
||||
} else {
|
||||
try {
|
||||
Intent dialIntent = new Intent(Intent.ACTION_CALL);
|
||||
Uri data = Uri.parse("tel:" + phone);
|
||||
dialIntent.setData(data);
|
||||
dialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(dialIntent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "callNumber: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
holder.iv_avatar.setOnClickListener(view -> call(phone));
|
||||
holder.cl_info.setOnClickListener(view -> call(phone));
|
||||
|
||||
holder.iv_remove.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String queryString = "number=" + recordsInfo.getNumber();
|
||||
try {
|
||||
mContext.getContentResolver().delete(CallLog.Calls.CONTENT_URI, queryString, null);
|
||||
mContext.getContentResolver().delete(CallLog.Calls.CONTENT_URI, CallLog.Calls._ID + "=?", new String[]{String.valueOf(recordsInfo.getId())});
|
||||
mRecordsInfoList.remove(position);
|
||||
notifyDataSetChanged();
|
||||
} catch (Exception e) {
|
||||
@@ -120,6 +103,24 @@ public class CallRecordAdapter extends RecyclerView.Adapter<CallRecordAdapter.Ho
|
||||
});
|
||||
}
|
||||
|
||||
private void call(String phone) {
|
||||
if (Utils.isMultiSim(mContext)) {
|
||||
Intent intent = new Intent(mContext, SelectNumberActivity.class);
|
||||
intent.putExtra("phone_number", phone);
|
||||
mContext.startActivity(intent);
|
||||
} else {
|
||||
try {
|
||||
Intent dialIntent = new Intent(Intent.ACTION_CALL);
|
||||
Uri data = Uri.parse("tel:" + phone);
|
||||
dialIntent.setData(data);
|
||||
dialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(dialIntent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "callNumber: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getName(String phone) {
|
||||
if (mContactMap != null) {
|
||||
if (mContactMap.get(phone) != null) {
|
||||
@@ -145,7 +146,7 @@ public class CallRecordAdapter extends RecyclerView.Adapter<CallRecordAdapter.Ho
|
||||
}
|
||||
|
||||
class Holder extends RecyclerView.ViewHolder {
|
||||
ConstraintLayout root;
|
||||
ConstraintLayout root, cl_info;
|
||||
NiceImageView iv_avatar;
|
||||
ImageView iv_remove;
|
||||
ImageView tv_state;
|
||||
@@ -156,6 +157,7 @@ public class CallRecordAdapter extends RecyclerView.Adapter<CallRecordAdapter.Ho
|
||||
public Holder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
root = itemView.findViewById(R.id.root);
|
||||
cl_info = itemView.findViewById(R.id.cl_info);
|
||||
iv_avatar = itemView.findViewById(R.id.iv_avatar);
|
||||
iv_remove = itemView.findViewById(R.id.iv_remove);
|
||||
tv_state = itemView.findViewById(R.id.tv_state);
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.xxpatx.os.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.provider.Settings;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -13,23 +13,19 @@ import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.activity.service.ServiceActivity;
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.DailyAppBean;
|
||||
import com.xxpatx.os.config.CommonConfig;
|
||||
import com.xxpatx.os.dialog.DailyAppDialog;
|
||||
import com.xxpatx.os.manager.AppStatusManager;
|
||||
import com.xxpatx.os.network.NetInterfaceManager;
|
||||
import com.xxpatx.os.service.NotificationService;
|
||||
import com.xxpatx.os.utils.ApkUtils;
|
||||
import com.xxpatx.os.utils.AppUsedTimeUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class DailyAppAdapter extends RecyclerView.Adapter<DailyAppAdapter.Holder> {
|
||||
private static final String TAG = "DailyAppAdapter";
|
||||
|
||||
@@ -95,6 +91,11 @@ public class DailyAppAdapter extends RecyclerView.Adapter<DailyAppAdapter.Holder
|
||||
|
||||
|
||||
private void showDialog(DailyAppBean dailyAppBean) {
|
||||
int appLockCtrl = Settings.Global.getInt(mContext.getContentResolver(), CommonConfig.APP_LOCK_CTRL, 0);
|
||||
if (appLockCtrl == 0) {
|
||||
Toaster.showLong("已禁止桌面编辑");
|
||||
return;
|
||||
}
|
||||
DailyAppDialog dailyAppDialog = new DailyAppDialog(mContext);
|
||||
dailyAppDialog.setTitle("放到桌面");
|
||||
dailyAppDialog.setMessage(dailyAppBean.getAppName());
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.xxpatx.os.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.provider.CallLog;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -20,6 +23,7 @@ import com.xxpatx.os.utils.ApkUtils;
|
||||
import java.util.List;
|
||||
|
||||
public class DockAppGridAdapter extends BaseAdapter {
|
||||
private static final String TAG = "DockAppGridAdapter";
|
||||
|
||||
private Context mContext;
|
||||
private List<DockApp> mDockApps;
|
||||
@@ -91,7 +95,16 @@ public class DockAppGridAdapter extends BaseAdapter {
|
||||
}
|
||||
}
|
||||
});
|
||||
int size = NotificationService.getNotificationLength(pkg);
|
||||
int size;
|
||||
switch (pkg) {
|
||||
case "com.android.dialer":
|
||||
case "xxpatx.os.dialer":
|
||||
size = readMissCall();
|
||||
Log.e(TAG, "getView: readMissCall = " + size);
|
||||
break;
|
||||
default:
|
||||
size = NotificationService.getNotificationLength(pkg);
|
||||
}
|
||||
if (size == 0) {
|
||||
holder.bg.setVisibility(View.GONE);
|
||||
} else if (size < 99) {
|
||||
@@ -105,6 +118,20 @@ public class DockAppGridAdapter extends BaseAdapter {
|
||||
return convertView;
|
||||
}
|
||||
|
||||
private int readMissCall() {
|
||||
int result = 0;
|
||||
Cursor cursor = mContext.getContentResolver().query(CallLog.Calls.CONTENT_URI,
|
||||
new String[]{CallLog.Calls._ID, CallLog.Calls.TYPE, CallLog.Calls.IS_READ},
|
||||
" " + CallLog.Calls.TYPE + "=? and " + CallLog.Calls.IS_READ + "=?",
|
||||
new String[]{String.valueOf(CallLog.Calls.MISSED_TYPE), "0"},
|
||||
CallLog.Calls.DEFAULT_SORT_ORDER);
|
||||
if (cursor != null) {
|
||||
result = cursor.getCount();
|
||||
cursor.close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static class ViewHolder {
|
||||
ConstraintLayout root;
|
||||
ImageView iv_icon;
|
||||
|
||||
@@ -90,14 +90,13 @@ public class PhoneAdapter extends RecyclerView.Adapter<PhoneAdapter.Holder> {
|
||||
|
||||
public class Holder extends RecyclerView.ViewHolder {
|
||||
ConstraintLayout root;
|
||||
TextView tv_sim, tv_number;
|
||||
TextView tv_number;
|
||||
ImageView iv_card;
|
||||
|
||||
public Holder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
root = itemView.findViewById(R.id.root);
|
||||
iv_card = itemView.findViewById(R.id.iv_card);
|
||||
tv_sim = itemView.findViewById(R.id.tv_sim);
|
||||
tv_number = itemView.findViewById(R.id.tv_number);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,21 @@ import java.io.Serializable;
|
||||
public class RecordsInfo implements Serializable {
|
||||
private static final long serialVersionUID = -8677336093725878416L;
|
||||
|
||||
String id;
|
||||
String name;
|
||||
String number;
|
||||
long date;
|
||||
int duration;
|
||||
int type;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class SystemSettings implements Serializable {
|
||||
|
||||
@@ -37,7 +36,7 @@ public class SystemSettings implements Serializable {
|
||||
int qch_restore;
|
||||
int setting_browserInput;
|
||||
int dev_mode;
|
||||
List<Contact> setting_sos;
|
||||
String setting_sos;
|
||||
String setting_volume;
|
||||
String setting_luminance;
|
||||
String setting_typeface;
|
||||
@@ -55,11 +54,22 @@ public class SystemSettings implements Serializable {
|
||||
int setting_location;
|
||||
int setting_charge;
|
||||
int setting_other_appInstaller;
|
||||
|
||||
int is_health;
|
||||
int is_shopping;
|
||||
int is_info;
|
||||
|
||||
int is_quickapp;//快捷应用开关 0关1开
|
||||
String quickapp; //快捷应用包名
|
||||
int is_seek;//查找模式开关 0关1开
|
||||
int is_lose;//丢失模式开关 0关1开
|
||||
String lose_str; //丢失模式描述文字
|
||||
int last_screen;
|
||||
int hover_home;
|
||||
int sos_ctrl;
|
||||
int alarm_clock_ctrl;
|
||||
int app_lock_ctrl;
|
||||
int exit_ctrl;
|
||||
int connect_page_ctrl;
|
||||
int connect_edit_ctrl;
|
||||
|
||||
public int getQch_restore() {
|
||||
return qch_restore;
|
||||
@@ -262,11 +272,11 @@ public class SystemSettings implements Serializable {
|
||||
this.setting_hotspot = setting_hotspot;
|
||||
}
|
||||
|
||||
public List<Contact> getSetting_sos() {
|
||||
public String getSetting_sos() {
|
||||
return setting_sos;
|
||||
}
|
||||
|
||||
public void setSetting_sos(List<Contact> setting_sos) {
|
||||
public void setSetting_sos(String setting_sos) {
|
||||
this.setting_sos = setting_sos;
|
||||
}
|
||||
|
||||
@@ -422,6 +432,110 @@ public class SystemSettings implements Serializable {
|
||||
this.is_info = is_info;
|
||||
}
|
||||
|
||||
public int getIs_quickapp() {
|
||||
return is_quickapp;
|
||||
}
|
||||
|
||||
public void setIs_quickapp(int is_quickapp) {
|
||||
this.is_quickapp = is_quickapp;
|
||||
}
|
||||
|
||||
public String getQuickapp() {
|
||||
return quickapp;
|
||||
}
|
||||
|
||||
public void setQuickapp(String quickapp) {
|
||||
this.quickapp = quickapp;
|
||||
}
|
||||
|
||||
public int getIs_seek() {
|
||||
return is_seek;
|
||||
}
|
||||
|
||||
public void setIs_seek(int is_seek) {
|
||||
this.is_seek = is_seek;
|
||||
}
|
||||
|
||||
public int getIs_lose() {
|
||||
return is_lose;
|
||||
}
|
||||
|
||||
public void setIs_lose(int is_lose) {
|
||||
this.is_lose = is_lose;
|
||||
}
|
||||
|
||||
public String getLose_str() {
|
||||
return lose_str;
|
||||
}
|
||||
|
||||
public void setLose_str(String lose_str) {
|
||||
this.lose_str = lose_str;
|
||||
}
|
||||
|
||||
public int getLast_screen() {
|
||||
return last_screen;
|
||||
}
|
||||
|
||||
public void setLast_screen(int last_screen) {
|
||||
this.last_screen = last_screen;
|
||||
}
|
||||
|
||||
public int getHover_home() {
|
||||
return hover_home;
|
||||
}
|
||||
|
||||
public void setHover_home(int hover_home) {
|
||||
this.hover_home = hover_home;
|
||||
}
|
||||
|
||||
public int getSos_ctrl() {
|
||||
return sos_ctrl;
|
||||
}
|
||||
|
||||
public void setSos_ctrl(int sos_ctrl) {
|
||||
this.sos_ctrl = sos_ctrl;
|
||||
}
|
||||
|
||||
public int getAlarm_clock_ctrl() {
|
||||
return alarm_clock_ctrl;
|
||||
}
|
||||
|
||||
public void setAlarm_clock_ctrl(int alarm_clock_ctrl) {
|
||||
this.alarm_clock_ctrl = alarm_clock_ctrl;
|
||||
}
|
||||
|
||||
public int getApp_lock_ctrl() {
|
||||
return app_lock_ctrl;
|
||||
}
|
||||
|
||||
public void setApp_lock_ctrl(int app_lock_ctrl) {
|
||||
this.app_lock_ctrl = app_lock_ctrl;
|
||||
}
|
||||
|
||||
public int getExit_ctrl() {
|
||||
return exit_ctrl;
|
||||
}
|
||||
|
||||
public void setExit_ctrl(int exit_ctrl) {
|
||||
this.exit_ctrl = exit_ctrl;
|
||||
}
|
||||
|
||||
public int getConnect_page_ctrl() {
|
||||
return connect_page_ctrl;
|
||||
}
|
||||
|
||||
public void setConnect_page_ctrl(int connect_page_ctrl) {
|
||||
this.connect_page_ctrl = connect_page_ctrl;
|
||||
}
|
||||
|
||||
public int getConnect_edit_ctrl() {
|
||||
return connect_edit_ctrl;
|
||||
}
|
||||
|
||||
public void setConnect_edit_ctrl(int connect_edit_ctrl) {
|
||||
this.connect_edit_ctrl = connect_edit_ctrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||||
|
||||
@@ -81,9 +81,11 @@ public class CommonConfig {
|
||||
public static final String VOICE_BROADCAST = "voice_broadcast_key";
|
||||
/*微信语音自动接听*/
|
||||
public static final String WECHAT_CALL_AUTO_ACCEPT = "wechat_call_auto_accept";
|
||||
|
||||
/*本地设置的*/
|
||||
/*悬浮窗*/
|
||||
public static final String FLOAT_WINDOW = "FloatWindowEnable";
|
||||
public static final boolean FLOAT_WINDOW_STATU = false;
|
||||
// public static final String FLOAT_WINDOW = "FloatWindowEnable";
|
||||
// public static final boolean FLOAT_WINDOW_STATU = false;
|
||||
/*禁用音量键*/
|
||||
public static final String DISABLE_VOLUME_KEY = "disable_volume_key";
|
||||
/*修改联系人禁用*/
|
||||
@@ -91,6 +93,20 @@ public class CommonConfig {
|
||||
/*禁用闹钟修改*/
|
||||
public static final String DISABLE_CLOCK_MODIFY = "disable_clock_modify_key";
|
||||
|
||||
|
||||
/*后台设置的*/
|
||||
/*主页按钮开关*/
|
||||
public static final String HOVER_HOME = "hover_home";
|
||||
/*默认状态*/
|
||||
public static final int HOVER_HOME_STATUS = 0;
|
||||
/*禁用SOS*/
|
||||
public static final String DISABLE_SOS = "sos_ctrl";
|
||||
/*禁用闹钟修改*/
|
||||
public static final String ALARM_CLOCK_CTRL = "alarm_clock_ctrl";
|
||||
/*应用锁定开关*/
|
||||
public static final String APP_LOCK_CTRL = "app_lock_ctrl";
|
||||
|
||||
|
||||
public final static String ACTION_STATUS_BAR_STATE = "xiaoxintong_statusBar_state";
|
||||
/*显示状态栏*/
|
||||
public final static String ACTION_SHOW_STATUS_BAR = "xiaoxintong_show_statusBar";
|
||||
@@ -100,4 +116,6 @@ public class CommonConfig {
|
||||
|
||||
public static final String AMAP_LOCATION_MAP_BEAN = "AMapLocation_MapBean_key";
|
||||
public static final String AMAP_LOCATION_DISTRICT = "AMapLocationMapBean_key";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xxpatx.os.view;
|
||||
package com.xxpatx.os.custom;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xxpatx.os.view;
|
||||
package com.xxpatx.os.custom;
|
||||
|
||||
|
||||
// add by codemx.cn ---- 20190712 ---plus- start
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xxpatx.os.base;
|
||||
package com.xxpatx.os.custom;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.ImageView;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xxpatx.os.view;
|
||||
package com.xxpatx.os.custom;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xxpatx.os.view;
|
||||
package com.xxpatx.os.custom;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xxpatx.os.view;
|
||||
package com.xxpatx.os.custom;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xxpatx.os.view;
|
||||
package com.xxpatx.os.custom;
|
||||
|
||||
import android.util.SparseArray;
|
||||
|
||||
@@ -27,8 +27,8 @@ import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.xxpatx.os.BuildConfig;
|
||||
import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.activity.screenlock.ScreenLockActivity;
|
||||
import com.xxpatx.os.activity.dailyapp.DailyAppActivity;
|
||||
import com.xxpatx.os.activity.screenlock.ScreenLockActivity;
|
||||
import com.xxpatx.os.activity.service.ServiceActivity;
|
||||
import com.xxpatx.os.base.BaseFragment;
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
@@ -48,7 +48,6 @@ import com.xxpatx.os.utils.IconUtils;
|
||||
import com.xxpatx.os.view.MyGridLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
@@ -403,6 +402,11 @@ public class AppListFragment extends BaseFragment {
|
||||
}
|
||||
|
||||
private void showHideDialog(DesktopIcon desktopIcon) {
|
||||
int appLockCtrl = Settings.Global.getInt(mContext.getContentResolver(), CommonConfig.APP_LOCK_CTRL, 0);
|
||||
if (appLockCtrl == 0) {
|
||||
Toaster.showLong("已禁止桌面编辑");
|
||||
return;
|
||||
}
|
||||
String label = desktopIcon.getTitle();
|
||||
String pkg = desktopIcon.getPackage();
|
||||
DailyAppDialog dailyAppDialog = new DailyAppDialog(mContext);
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.hardware.camera2.CameraAccessException;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -26,20 +25,19 @@ import com.qweather.sdk.bean.weather.WeatherNowBean;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.xxpatx.os.BuildConfig;
|
||||
import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.activity.FlashlightActivity;
|
||||
import com.xxpatx.os.activity.NetworkActivity;
|
||||
import com.xxpatx.os.activity.contact.AddWechatContactActivity;
|
||||
import com.xxpatx.os.activity.emergency.EmergencyActivity;
|
||||
import com.xxpatx.os.activity.setting.SettingActivity;
|
||||
import com.xxpatx.os.activity.weather.WeatherActivity;
|
||||
import com.xxpatx.os.alarm.AlarmClockData;
|
||||
import com.xxpatx.os.alarm.AlarmUtils;
|
||||
import com.xxpatx.os.base.mvvm.fragment.BaseMvvmFragment;
|
||||
import com.xxpatx.os.bean.Contact;
|
||||
import com.xxpatx.os.bean.DesktopIcon;
|
||||
import com.xxpatx.os.bean.MapBean;
|
||||
import com.xxpatx.os.config.CommonConfig;
|
||||
import com.xxpatx.os.databinding.FragmentHomeBinding;
|
||||
import com.xxpatx.os.dialog.SingleDialog;
|
||||
import com.xxpatx.os.network.NetInterfaceManager;
|
||||
import com.xxpatx.os.push.PushManager;
|
||||
import com.xxpatx.os.utils.ApkUtils;
|
||||
import com.xxpatx.os.utils.DayUtils;
|
||||
@@ -378,37 +376,6 @@ public class HomeFragment extends BaseMvvmFragment<HomeViewModel, FragmentHomeBi
|
||||
}
|
||||
}
|
||||
|
||||
private void checkSosNumber() {
|
||||
NetInterfaceManager.getInstance().getContactList(new NetInterfaceManager.ContactCallback() {
|
||||
@Override
|
||||
public void setContact(List<Contact> contactList) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEmergencyContact(List<Contact> emergencyContact) {
|
||||
if (emergencyContact == null || emergencyContact.size() == 0) {
|
||||
showNoData("温馨提示", "请在小程序上面设置紧急联系人");
|
||||
} else {
|
||||
Intent intent = new Intent(mContext, EmergencyActivity.class);
|
||||
// intent.putExtra("setting_sos", phone);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEmpty() {
|
||||
showNoData("温馨提示", "请在小程序上面设置紧急联系人");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showNoData(String title, String msg) {
|
||||
SingleDialog dialog = new SingleDialog(mContext);
|
||||
dialog.setTitle(title)
|
||||
@@ -501,24 +468,26 @@ public class HomeFragment extends BaseMvvmFragment<HomeViewModel, FragmentHomeBi
|
||||
}
|
||||
|
||||
public void openNetwork(View view) {
|
||||
startActivity(new Intent(Settings.ACTION_DATA_USAGE_SETTINGS));
|
||||
// startActivity(new Intent(Settings.ACTION_DATA_USAGE_SETTINGS));
|
||||
startActivity(new Intent(mContext, NetworkActivity.class));
|
||||
}
|
||||
|
||||
public void openFlash(View view) {
|
||||
try {
|
||||
String cameraId = cameraManager.getCameraIdList()[0];
|
||||
cameraManager.setTorchMode(cameraId, !flashing);
|
||||
flashing = !flashing;
|
||||
mViewDataBinding.setFlashing(flashing);
|
||||
} catch (CameraAccessException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "openFlash: " + e.getMessage());
|
||||
Toaster.show("打开手电筒失败");
|
||||
}
|
||||
startActivity(new Intent(mContext, FlashlightActivity.class));
|
||||
// try {
|
||||
// String cameraId = cameraManager.getCameraIdList()[0];
|
||||
// cameraManager.setTorchMode(cameraId, !flashing);
|
||||
// flashing = !flashing;
|
||||
// mViewDataBinding.setFlashing(flashing);
|
||||
// } catch (CameraAccessException e) {
|
||||
// e.printStackTrace();
|
||||
// Log.e(TAG, "openFlash: " + e.getMessage());
|
||||
// Toaster.show("打开手电筒失败");
|
||||
// }
|
||||
}
|
||||
|
||||
public void openCalendar(View view) {
|
||||
ApkUtils.openApp(mContext, "cn.etouch.ecalendar");
|
||||
ApkUtils.openApp(mContext, "com.honghui.huangli");
|
||||
}
|
||||
|
||||
public void toWeather(View view) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import android.view.View;
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.activity.ImeiActivity;
|
||||
import com.xxpatx.os.activity.contact.AddWechatContactActivity;
|
||||
import com.xxpatx.os.activity.selectnumber.SelectNumberActivity;
|
||||
import com.xxpatx.os.base.mvvm.fragment.BaseMvvmFragment;
|
||||
@@ -92,12 +93,16 @@ public class DialerFragment extends BaseMvvmFragment<DialerViewModel, FragmentDi
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
Log.e("initView", "onTextChanged: " + s);
|
||||
if ("*#*#4636#*#*".contentEquals(s)) {
|
||||
ApkUtils.openPackage(mContext, "com.android.settings", "com.android.settings.Settings$TestingSettingsActivity");
|
||||
} else if ("*#*#0011234#*#*".contentEquals(s)) {
|
||||
ApkUtils.openPackage(mContext, "com.mediatek.factorymode", "com.mediatek.factorymode.FactoryMode");
|
||||
} else if ("*#*#0011231#*#*".contentEquals(s)) {
|
||||
ApkUtils.openPackage(mContext, "com.android.agingtest", "com.android.agingtest.AgingTest");
|
||||
String code = s.toString();
|
||||
switch (code) {
|
||||
case "*#*#4636#*#*":
|
||||
case "*#*#0011234#*#*":
|
||||
case "*#*#0011231#*#*":
|
||||
case "*#06#":
|
||||
openCode(s);
|
||||
mViewDataBinding.etPhone.setText("");
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +111,32 @@ public class DialerFragment extends BaseMvvmFragment<DialerViewModel, FragmentDi
|
||||
Log.e("initView", "afterTextChanged: " + s);
|
||||
}
|
||||
});
|
||||
mViewDataBinding.ivDelete.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
mViewDataBinding.etPhone.setText("");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void openCode(CharSequence s) {
|
||||
String code = s.toString();
|
||||
switch (code) {
|
||||
case "*#*#4636#*#*":
|
||||
ApkUtils.openPackage(mContext, "com.android.settings", "com.android.settings.Settings$TestingSettingsActivity");
|
||||
break;
|
||||
case "*#*#0011234#*#*":
|
||||
ApkUtils.openPackage(mContext, "com.mediatek.factorymode", "com.mediatek.factorymode.FactoryMode");
|
||||
break;
|
||||
case "*#*#0011231#*#*":
|
||||
ApkUtils.openPackage(mContext, "com.android.agingtest", "com.android.agingtest.AgingTest");
|
||||
break;
|
||||
case "*#06#":
|
||||
startActivity(new Intent(mContext, ImeiActivity.class));
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -68,7 +68,8 @@ public class RecordViewModel extends BaseViewModel<FragmentRecordBinding, Fragme
|
||||
*
|
||||
*/
|
||||
Cursor cursor = resolver.query(CallLog.Calls.CONTENT_URI, // 查询通话记录的URI
|
||||
new String[]{CallLog.Calls.CACHED_NAME// 通话记录的联系人
|
||||
new String[]{CallLog.Calls._ID
|
||||
, CallLog.Calls.CACHED_NAME// 通话记录的联系人
|
||||
, CallLog.Calls.NUMBER// 通话记录的电话号码
|
||||
, CallLog.Calls.DATE// 通话记录的日期
|
||||
, CallLog.Calls.DURATION// 通话时长
|
||||
@@ -78,6 +79,7 @@ public class RecordViewModel extends BaseViewModel<FragmentRecordBinding, Fragme
|
||||
// 3.通过Cursor获得数据
|
||||
List<RecordsInfo> list = new ArrayList<>();
|
||||
while (cursor.moveToNext()) {
|
||||
String id = cursor.getString(cursor.getColumnIndex(CallLog.Calls._ID));
|
||||
String name = cursor.getString(cursor.getColumnIndex(CallLog.Calls.CACHED_NAME));
|
||||
String number = cursor.getString(cursor.getColumnIndex(CallLog.Calls.NUMBER));
|
||||
long dateLong = cursor.getLong(cursor.getColumnIndex(CallLog.Calls.DATE));
|
||||
@@ -86,6 +88,7 @@ public class RecordViewModel extends BaseViewModel<FragmentRecordBinding, Fragme
|
||||
int type = cursor.getInt(cursor.getColumnIndex(CallLog.Calls.TYPE));
|
||||
|
||||
RecordsInfo recordsInfo = new RecordsInfo();
|
||||
recordsInfo.setId(id);
|
||||
recordsInfo.setName(name);
|
||||
recordsInfo.setNumber(number);
|
||||
recordsInfo.setDate(dateLong);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.xxpatx.os.fragment.settings;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -154,7 +155,12 @@ public class SettingsFragment extends BaseMvvmFragment<SettingsViewModel, Fragme
|
||||
}
|
||||
|
||||
public void openEmergency(View view) {
|
||||
startActivity(new Intent(mContext, EmergencyActivity.class));
|
||||
int sos_ctrl = Settings.Global.getInt(mContext.getContentResolver(), CommonConfig.DISABLE_SOS, 1);
|
||||
if (sos_ctrl == 0) {
|
||||
Toaster.showLong("SOS功能已关闭");
|
||||
} else {
|
||||
startActivity(new Intent(mContext, EmergencyActivity.class));
|
||||
}
|
||||
}
|
||||
|
||||
public void toAppstore(View view) {
|
||||
|
||||
@@ -31,7 +31,7 @@ public class AppStatusManager {
|
||||
public static final String APP_STATUS_MANAGER_KEY = "AppStatusManagerSet";
|
||||
private static final Set<String> defaultHiedApp = new HashSet<String>() {{
|
||||
this.add("om.android.fmradio");//收音机
|
||||
this.add("com.android.mms");//信息
|
||||
// this.add("com.android.mms");//信息
|
||||
this.add("com.android.gallery3d");
|
||||
this.add("com.android.documentsui");
|
||||
this.add("com.android.calculator2");
|
||||
|
||||
@@ -68,9 +68,9 @@ import com.xxpatx.os.network.api.uiui.SnIsActivationApi;
|
||||
import com.xxpatx.os.network.api.uiui.UpdateAppIconApi;
|
||||
import com.xxpatx.os.network.api.uiui.UserInfoControl;
|
||||
import com.xxpatx.os.network.api.uiui.alarmclock.AlarmClockAddApi;
|
||||
import com.xxpatx.os.network.api.uiui.alarmclock.AlarmClockGetApi;
|
||||
import com.xxpatx.os.network.api.uiui.alarmclock.AlarmClockDeleteApi;
|
||||
import com.xxpatx.os.network.api.uiui.alarmclock.AlarmClockEditApi;
|
||||
import com.xxpatx.os.network.api.uiui.alarmclock.AlarmClockGetApi;
|
||||
import com.xxpatx.os.network.api.uiui.alarmclock.AlarmClockQueryApi;
|
||||
import com.xxpatx.os.network.api.uiui.alarmclock.AlarmClockUpdateApi;
|
||||
import com.xxpatx.os.network.api.uiui.app.RunNewApp;
|
||||
@@ -1203,18 +1203,7 @@ public class NetInterfaceManager {
|
||||
mMMKV.encode("is_health", systemSettings.getIs_health());
|
||||
mMMKV.encode("is_shopping", systemSettings.getIs_shopping());
|
||||
mMMKV.encode("is_info", systemSettings.getIs_info());
|
||||
List<Contact> setting_sos = systemSettings.getSetting_sos();
|
||||
if (setting_sos == null || setting_sos.size() == 0) {
|
||||
mCacheHelper.put(UrlAddress.GET_SETTINGS, "");
|
||||
if (callback != null) callback.setEmpty();
|
||||
} else {
|
||||
List<Contact> emergencyContact = setting_sos.stream().filter(contact -> contact.getIs_urgent() == 1).collect(Collectors.toList());
|
||||
mCacheHelper.put(UrlAddress.GET_SETTINGS, GsonUtils.toJSONString(setting_sos));
|
||||
if (callback != null) {
|
||||
callback.setContact(setting_sos);
|
||||
callback.setEmergencyContact(emergencyContact);
|
||||
}
|
||||
}
|
||||
String s = systemSettings.getSetting_sos();
|
||||
} else {
|
||||
mCacheHelper.put(UrlAddress.GET_SETTINGS, "");
|
||||
if (callback != null) callback.setEmpty();
|
||||
|
||||
@@ -153,12 +153,12 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
||||
// ApkUtils.UninstallAPP(this, "com.joytv.live");
|
||||
// ApkUtils.UninstallAPP(this, "com.tencent.android.qqdownloader");
|
||||
|
||||
mFloatWindowEnable = mMMKV.decodeBool(CommonConfig.FLOAT_WINDOW, CommonConfig.FLOAT_WINDOW_STATU);
|
||||
mFloatWindowEnable = Settings.Global.getInt(getContentResolver(), CommonConfig.HOVER_HOME, CommonConfig.HOVER_HOME_STATUS) == 1;
|
||||
mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
|
||||
showPopupWindow();
|
||||
|
||||
Aria.init(this);
|
||||
Aria.download(this).register();
|
||||
|
||||
mPresenter = new MainSPresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
@@ -532,8 +532,8 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
||||
}
|
||||
}
|
||||
|
||||
public static final String ACTION_FLOAT_WINDOW_ON = "com.tt.float.window.on";
|
||||
public static final String ACTION_FLOAT_WINDOW_OFF = "com.tt.float.window.off";
|
||||
public static final String ACTION_FLOAT_WINDOW_ON = "com.xxpatx.os.float.window.on";
|
||||
public static final String ACTION_FLOAT_WINDOW_OFF = "com.xxpatx.os.float.window.off";
|
||||
|
||||
private WindowReceiver mWindowReceiver;
|
||||
|
||||
@@ -557,12 +557,12 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
||||
}
|
||||
switch (action) {
|
||||
case ACTION_FLOAT_WINDOW_ON:
|
||||
mMMKV.encode(CommonConfig.FLOAT_WINDOW, true);
|
||||
// Settings.Global.putInt(getContentResolver(), CommonConfig.HOVER_HOME, 1);
|
||||
mFloatWindowEnable = true;
|
||||
showPopupWindow();
|
||||
break;
|
||||
case ACTION_FLOAT_WINDOW_OFF:
|
||||
mMMKV.encode(CommonConfig.FLOAT_WINDOW, false);
|
||||
// Settings.Global.putInt(getContentResolver(), CommonConfig.HOVER_HOME, 0);
|
||||
mFloatWindowEnable = false;
|
||||
if (mWindowManager != null && mBallView != null) {
|
||||
if (mBallView.isAttachedToWindow()) {
|
||||
@@ -638,7 +638,7 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
||||
}
|
||||
|
||||
private void killBackgroundApp() {
|
||||
List<String> pkgList = ApkUtils.queryFilterAppList(this);
|
||||
List<String> pkgList = ApkUtils.getRuningPackageList(this);
|
||||
for (String pkg : pkgList) {
|
||||
if (pkg.equalsIgnoreCase(BuildConfig.APPLICATION_ID)
|
||||
|| "com.xxpatx.sn".equals(pkg)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xxpatx.os.utils;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@@ -51,6 +52,8 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
@@ -386,12 +389,12 @@ public class ApkUtils {
|
||||
resolveInfos.add(resolveInfo);
|
||||
}
|
||||
} else {
|
||||
// if ("com.xxpatx.sn".equals(pkg)) {
|
||||
// resolveInfos.add(resolveInfo);
|
||||
// } else {
|
||||
Log.e(TAG, "getAppstoreAppInfo: pkgSet ! contains " + pkg);
|
||||
AppStatusManager.getInstance().addHidedApp(pkg);
|
||||
// }
|
||||
if ("com.android.mms".equals(pkg)) {
|
||||
resolveInfos.add(resolveInfo);
|
||||
} else {
|
||||
Log.e(TAG, "getAppstoreAppInfo: pkgSet ! contains " + pkg);
|
||||
AppStatusManager.getInstance().addHidedApp(pkg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (allPackages.contains(pkg) && !excludePackageName.contains(pkg)) {
|
||||
@@ -492,6 +495,34 @@ public class ApkUtils {
|
||||
return applicationInfos;
|
||||
}
|
||||
|
||||
public static List<String> getRuningPackageList(Context context) {
|
||||
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
List<ActivityManager.RunningAppProcessInfo> runningAppProcesses = activityManager.getRunningAppProcesses();
|
||||
Set<String> map = runningAppProcesses.stream().map(new Function<ActivityManager.RunningAppProcessInfo, String>() {
|
||||
@Override
|
||||
public String apply(ActivityManager.RunningAppProcessInfo runningAppProcessInfo) {
|
||||
String processName = runningAppProcessInfo.processName;
|
||||
String[] split = processName.split(":");
|
||||
return split[0];
|
||||
}
|
||||
}).collect(Collectors.toSet());
|
||||
map.remove("system");
|
||||
map.remove("android");
|
||||
map.remove("com.android.networkstack.process");
|
||||
map.remove("android.process.media");
|
||||
map.remove("com.android.dreams.basic");
|
||||
map.remove("com.android.musicfx");
|
||||
map.remove("say.whatever");
|
||||
Set<String> filter = map.stream().filter(new Predicate<String>() {
|
||||
@Override
|
||||
public boolean test(String s) {
|
||||
return !ApkUtils.isSystemApp(context, s);
|
||||
}
|
||||
}).collect(Collectors.toSet());
|
||||
Log.e(TAG, "getRuningPackageList: " + filter);
|
||||
return new ArrayList<>(filter);
|
||||
}
|
||||
|
||||
public static PackageInfo getPackageInfo(Context context, String pkg) {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
PackageInfo packageInfo = null;
|
||||
|
||||
@@ -324,19 +324,19 @@ public class Utils {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean isMultiSim(Context context){
|
||||
public static boolean isMultiSim(Context context) {
|
||||
boolean result = false;
|
||||
TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
|
||||
if(telecomManager != null){
|
||||
if (telecomManager != null) {
|
||||
List<PhoneAccountHandle> phoneAccountHandleList = telecomManager.getCallCapablePhoneAccounts();
|
||||
result = phoneAccountHandleList.size() >= 2;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void call(Context context, int id, String telNum){
|
||||
public static void call(Context context, int id, String telNum) {
|
||||
TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
|
||||
if(telecomManager != null){
|
||||
if (telecomManager != null) {
|
||||
List<PhoneAccountHandle> phoneAccountHandleList = telecomManager.getCallCapablePhoneAccounts();
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_CALL);
|
||||
@@ -346,4 +346,24 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("HardwareIds")
|
||||
public static String getIMEI(Context context, int slotIndex) {
|
||||
String imei;
|
||||
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
imei = tm.getImei(slotIndex);
|
||||
} else {
|
||||
imei = tm.getDeviceId(slotIndex);
|
||||
}
|
||||
if (TextUtils.isEmpty(imei)) {
|
||||
return "暂无数据";
|
||||
}
|
||||
return imei;
|
||||
}
|
||||
|
||||
public static String getEmid(Context context) {
|
||||
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
String meid = telephonyManager.getDeviceId();
|
||||
return meid;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user