version:1.4.8
fix:修复一键拨号 update:增加sim卡显示
This commit is contained in:
@@ -15,8 +15,8 @@ android {
|
|||||||
applicationId "com.xxpatx.os"
|
applicationId "com.xxpatx.os"
|
||||||
minSdkVersion 24
|
minSdkVersion 24
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 1048
|
versionCode 1049
|
||||||
versionName "1.4.8"
|
versionName "1.4.9"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import com.xxpatx.os.databinding.ActivityContactListBinding;
|
|||||||
import com.xxpatx.os.dialog.EditContactDialog;
|
import com.xxpatx.os.dialog.EditContactDialog;
|
||||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ContactListActivity extends BaseMvvmActivity<ContactListViewModel, ActivityContactListBinding> {
|
public class ContactListActivity extends BaseMvvmActivity<ContactListViewModel, ActivityContactListBinding> {
|
||||||
@@ -115,35 +114,6 @@ public class ContactListActivity extends BaseMvvmActivity<ContactListViewModel,
|
|||||||
mViewModel.getContact();
|
mViewModel.getContact();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static final String NAME = "name";
|
|
||||||
public static final String NUMBER = "number";
|
|
||||||
|
|
||||||
private List<Contact> getSIMContacts() {
|
|
||||||
getAll();
|
|
||||||
List<Contact> contactList = new ArrayList<>();
|
|
||||||
ContentResolver resolver = getContentResolver();
|
|
||||||
// 获取Sims卡联系人
|
|
||||||
Uri uri = Uri.parse("content://icc/adn");
|
|
||||||
Cursor phoneCursor = resolver.query(uri, null, null, null, null);
|
|
||||||
if (phoneCursor != null) {
|
|
||||||
int colName = phoneCursor.getColumnIndex(NAME);
|
|
||||||
int colNumber = phoneCursor.getColumnIndex(NUMBER);
|
|
||||||
while (phoneCursor.moveToNext()) {
|
|
||||||
String number = phoneCursor.getString(colNumber);
|
|
||||||
// 当手机号码为空的或者为空字段 跳过当前循环
|
|
||||||
String username = phoneCursor.getString(colName);
|
|
||||||
long id = phoneCursor.getLong(phoneCursor.getColumnIndex("_id"));
|
|
||||||
Log.e(TAG, "getSIMContacts: number = " + number + " username = " + username + " _id = " + id);
|
|
||||||
Contact contact = new Contact(username, number, true);
|
|
||||||
contact.setId(id);
|
|
||||||
contactList.add(contact);
|
|
||||||
}
|
|
||||||
phoneCursor.close();
|
|
||||||
}
|
|
||||||
return contactList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getAll() {
|
private void getAll() {
|
||||||
ContentResolver resolver = getContentResolver();
|
ContentResolver resolver = getContentResolver();
|
||||||
Cursor adnCursor = resolver.query(Uri.parse("content://icc/adn/subId/0"), null, null, null, null);
|
Cursor adnCursor = resolver.query(Uri.parse("content://icc/adn/subId/0"), null, null, null, null);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import com.xxpatx.os.bean.AppInfo;
|
|||||||
import com.xxpatx.os.bean.SystemSettings;
|
import com.xxpatx.os.bean.SystemSettings;
|
||||||
import com.xxpatx.os.config.CommonConfig;
|
import com.xxpatx.os.config.CommonConfig;
|
||||||
import com.xxpatx.os.databinding.ActivitySettingBinding;
|
import com.xxpatx.os.databinding.ActivitySettingBinding;
|
||||||
|
import com.xxpatx.os.dialog.CustomDialog;
|
||||||
import com.xxpatx.os.service.WeAccessibilityService;
|
import com.xxpatx.os.service.WeAccessibilityService;
|
||||||
import com.xxpatx.os.service.main.MainService;
|
import com.xxpatx.os.service.main.MainService;
|
||||||
import com.xxpatx.os.utils.AccessibilityUtils;
|
import com.xxpatx.os.utils.AccessibilityUtils;
|
||||||
@@ -301,13 +302,34 @@ public class SettingActivity extends BaseMvvmActivity<SettingViewModel, Activity
|
|||||||
public void setHourlyTimeSignal(View view) {
|
public void setHourlyTimeSignal(View view) {
|
||||||
boolean hourly_time = mMMKV.decodeBool(CommonConfig.HOURLY_TIME_SIGNAL_KEY, false);
|
boolean hourly_time = mMMKV.decodeBool(CommonConfig.HOURLY_TIME_SIGNAL_KEY, false);
|
||||||
Log.e(TAG, "setHourlyTimeSignal: hourly_time = " + hourly_time);
|
Log.e(TAG, "setHourlyTimeSignal: hourly_time = " + hourly_time);
|
||||||
mMMKV.encode(CommonConfig.HOURLY_TIME_SIGNAL_KEY, !hourly_time);
|
if (!hourly_time) {
|
||||||
mViewDataBinding.setHourlyTime(!hourly_time);
|
CustomDialog customDialog = new CustomDialog(SettingActivity.this);
|
||||||
|
customDialog.setTitle("温馨提示")
|
||||||
|
.setMessage("整点报时时间为7点至21点")
|
||||||
|
.setOnClickBottomListener(new CustomDialog.OnClickBottomListener() {
|
||||||
|
@Override
|
||||||
|
public void onPositiveClick() {
|
||||||
|
mMMKV.encode(CommonConfig.HOURLY_TIME_SIGNAL_KEY, true);
|
||||||
|
mViewDataBinding.setHourlyTime(true);
|
||||||
|
Intent intent = new Intent(MainService.XXOS_ACTION_TIME_CHANGED);
|
||||||
|
sendBroadcast(intent);
|
||||||
|
customDialog.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNegtiveClick() {
|
||||||
|
customDialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
customDialog.show();
|
||||||
|
} else {
|
||||||
|
mMMKV.encode(CommonConfig.HOURLY_TIME_SIGNAL_KEY, false);
|
||||||
|
mViewDataBinding.setHourlyTime(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatusBar(View view) {
|
public void setStatusBar(View view) {
|
||||||
int code = Settings.System.getInt(getContentResolver(), CommonConfig.ACTION_STATUS_BAR_STATE, 0);
|
boolean statusBar = Settings.System.getInt(getContentResolver(), CommonConfig.ACTION_STATUS_BAR_STATE, 0) == 1;
|
||||||
boolean statusBar = code == 1;
|
|
||||||
String statusbarStatus;
|
String statusbarStatus;
|
||||||
if (statusBar) {
|
if (statusBar) {
|
||||||
statusbarStatus = CommonConfig.ACTION_HIDE_STATUS_BAR;
|
statusbarStatus = CommonConfig.ACTION_HIDE_STATUS_BAR;
|
||||||
@@ -320,7 +342,7 @@ public class SettingActivity extends BaseMvvmActivity<SettingViewModel, Activity
|
|||||||
|
|
||||||
Log.e(TAG, "setStatusBar: old statusBar = " + statusBar);
|
Log.e(TAG, "setStatusBar: old statusBar = " + statusBar);
|
||||||
mViewDataBinding.setStatusBar(!statusBar);
|
mViewDataBinding.setStatusBar(!statusBar);
|
||||||
Settings.System.putInt(getContentResolver(), CommonConfig.ACTION_STATUS_BAR_STATE, code == 1 ? 0 : 1);
|
Settings.System.putInt(getContentResolver(), CommonConfig.ACTION_STATUS_BAR_STATE, statusBar ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSimCard(View view) {
|
public void setSimCard(View view) {
|
||||||
|
|||||||
@@ -16,12 +16,16 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
|||||||
|
|
||||||
|
|
||||||
public abstract class BaseRxService extends Service implements LifecycleProvider<ActivityEvent> {
|
public abstract class BaseRxService extends Service implements LifecycleProvider<ActivityEvent> {
|
||||||
public final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
|
private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
|
||||||
|
|
||||||
public BaseRxService() {
|
public BaseRxService() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BehaviorSubject<ActivityEvent> getLifecycleSubject() {
|
||||||
|
return lifecycleSubject;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Observable<ActivityEvent> lifecycle() {
|
public final Observable<ActivityEvent> lifecycle() {
|
||||||
return lifecycleSubject.hide();
|
return lifecycleSubject.hide();
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ public class CommonConfig {
|
|||||||
public static final String CONTACT_HOME_KEY = "contact_home_control";
|
public static final String CONTACT_HOME_KEY = "contact_home_control";
|
||||||
/*整点报时*/
|
/*整点报时*/
|
||||||
public static final String HOURLY_TIME_SIGNAL_KEY = "Hourly_Time_Signal";
|
public static final String HOURLY_TIME_SIGNAL_KEY = "Hourly_Time_Signal";
|
||||||
|
/*显示SIM卡联系人*/
|
||||||
|
public static final String SHOW_SIM_CARD_CONTACT = "show_sim_card_contact_key";
|
||||||
|
|
||||||
/*后台设置的*/
|
/*后台设置的*/
|
||||||
/*主页按钮开关*/
|
/*主页按钮开关*/
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.xxpatx.os.service.main;
|
package com.xxpatx.os.service.main;
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
|
import android.app.AlarmManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -46,6 +48,7 @@ import com.xxpatx.os.utils.ApkUtils;
|
|||||||
import com.xxpatx.os.utils.AppUsedTimeUtils;
|
import com.xxpatx.os.utils.AppUsedTimeUtils;
|
||||||
import com.xxpatx.os.utils.CmdUtil;
|
import com.xxpatx.os.utils.CmdUtil;
|
||||||
import com.xxpatx.os.utils.ForegroundAppUtil;
|
import com.xxpatx.os.utils.ForegroundAppUtil;
|
||||||
|
import com.xxpatx.os.utils.TimeUtils;
|
||||||
import com.xxpatx.os.utils.Utils;
|
import com.xxpatx.os.utils.Utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -88,8 +91,12 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
|||||||
private WindowManager.LayoutParams mBallParams;
|
private WindowManager.LayoutParams mBallParams;
|
||||||
public boolean isBallShown = false;
|
public boolean isBallShown = false;
|
||||||
|
|
||||||
private static final String Float_Window_X = "float_window_x_key";
|
private static final String FLOAT_WINDOW_X = "float_window_x_key";
|
||||||
private static final String Float_Window_Y = "float_window_y_key";
|
private static final String FLOAT_WINDOW_Y = "float_window_y_key";
|
||||||
|
|
||||||
|
private static final int TIME_REQUEST_CODE = 9999;
|
||||||
|
private static final String XXOS_ACTION_TIME_TICK = "xxos_time_tick";
|
||||||
|
public static final String XXOS_ACTION_TIME_CHANGED = "xxos_time_changed";
|
||||||
|
|
||||||
public MainService() {
|
public MainService() {
|
||||||
|
|
||||||
@@ -204,7 +211,7 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
|||||||
|
|
||||||
mPresenter = new MainSPresenter(this);
|
mPresenter = new MainSPresenter(this);
|
||||||
mPresenter.attachView(this);
|
mPresenter.attachView(this);
|
||||||
mPresenter.setLifecycle(lifecycleSubject);
|
mPresenter.setLifecycle(getLifecycleSubject());
|
||||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||||
mPresenter.addAlarmClock();
|
mPresenter.addAlarmClock();
|
||||||
|
|
||||||
@@ -219,9 +226,11 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
|||||||
}
|
}
|
||||||
mMMKV.encode(CommonConfig.APP_VERSION_CODE, BuildConfig.VERSION_CODE);
|
mMMKV.encode(CommonConfig.APP_VERSION_CODE, BuildConfig.VERSION_CODE);
|
||||||
|
|
||||||
|
setAlarmTime();
|
||||||
|
registerTimeChangedReceiver();
|
||||||
|
|
||||||
registerAlarmReceiver();
|
registerAlarmReceiver();
|
||||||
registerTimeReceiver();
|
registerFastCallReceive();
|
||||||
registFastCallReceive();
|
|
||||||
registerLockScreenReceiver();
|
registerLockScreenReceiver();
|
||||||
registerOperateAlarmClockReceiver();
|
registerOperateAlarmClockReceiver();
|
||||||
registerScreenLockReceiver();
|
registerScreenLockReceiver();
|
||||||
@@ -233,7 +242,7 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
|||||||
mTimeSignalCallback = emitter::onNext;
|
mTimeSignalCallback = emitter::onNext;
|
||||||
}
|
}
|
||||||
}).throttleFirst(1, TimeUnit.MINUTES)
|
}).throttleFirst(1, TimeUnit.MINUTES)
|
||||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new Observer<Integer>() {
|
.subscribe(new Observer<Integer>() {
|
||||||
@@ -244,8 +253,13 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(@NonNull Integer hour) {
|
public void onNext(@NonNull Integer hour) {
|
||||||
Log.e("mTimeSignalCallback", "onNext: ");
|
Log.e("mTimeSignalCallback", "onNext: " + hour);
|
||||||
|
if (hour > 6 && hour < 22) {
|
||||||
mSoundPool.play(soundMap.get(hour), 1, 1, 0, 0, 1);
|
mSoundPool.play(soundMap.get(hour), 1, 1, 0, 0, 1);
|
||||||
|
} else {
|
||||||
|
/*10点到86点不报时*/
|
||||||
|
Log.e("mTimeSignalCallback", "onNext: ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -260,6 +274,34 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setAlarmTime() {
|
||||||
|
/*Android 10 及以后息屏收不到time_tick广播*/
|
||||||
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
|
||||||
|
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||||
|
Intent intent = new Intent(XXOS_ACTION_TIME_TICK);
|
||||||
|
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, TIME_REQUEST_CODE, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
long triggerAtTime = getIntervalMillis();
|
||||||
|
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, triggerAtTime, pendingIntent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 获取下个整点的时间戳
|
||||||
|
*/
|
||||||
|
private long getIntervalMillis() {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||||
|
Log.e(TAG, "getIntervalMillis: hour = " + hour);
|
||||||
|
int min = calendar.get(Calendar.MINUTE);
|
||||||
|
Log.e(TAG, "getIntervalMillis: min = " + min);
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, hour + 1);
|
||||||
|
calendar.set(Calendar.MINUTE, 0);
|
||||||
|
calendar.set(Calendar.SECOND, 0);
|
||||||
|
long time = calendar.getTimeInMillis();
|
||||||
|
Log.e(TAG, "getIntervalMillis: time = " + TimeUtils.transferLongToDate(time));
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
Log.e(TAG, "onStartCommand: ");
|
Log.e(TAG, "onStartCommand: ");
|
||||||
@@ -398,7 +440,7 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 监听时间和日期变化
|
// 监听时间和日期变化
|
||||||
public void registerTimeReceiver() {
|
public void registerTimeChangedReceiver() {
|
||||||
mTimeChangedReceiver = new TimeChangedReceiver();
|
mTimeChangedReceiver = new TimeChangedReceiver();
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||||
@@ -406,6 +448,8 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
|||||||
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_TIME_TICK);
|
filter.addAction(Intent.ACTION_TIME_TICK);
|
||||||
|
filter.addAction(XXOS_ACTION_TIME_TICK);
|
||||||
|
filter.addAction(XXOS_ACTION_TIME_CHANGED);
|
||||||
registerReceiver(mTimeChangedReceiver, filter);
|
registerReceiver(mTimeChangedReceiver, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,15 +459,22 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (Intent.ACTION_DATE_CHANGED.equals(intent.getAction())) {
|
String action = intent.getAction();
|
||||||
Log.e(TAG, "TimeChangedReceiver:" + "data changed");
|
Log.e("TimeChangedReceiver", "onReceive: " + action);
|
||||||
} else if (Intent.ACTION_TIME_CHANGED.equals(intent.getAction())) {
|
switch (action) {
|
||||||
Log.e(TAG, "TimeChangedReceiver:" + "time changed");
|
case Intent.ACTION_DATE_CHANGED:
|
||||||
} else if (Intent.ACTION_TIMEZONE_CHANGED.equals(intent.getAction())) {
|
case Intent.ACTION_TIME_CHANGED:
|
||||||
Log.e(TAG, "TimeChangedReceiver:" + "timezone changed");
|
case Intent.ACTION_TIMEZONE_CHANGED:
|
||||||
} else if (Intent.ACTION_TIME_TICK.equals(intent.getAction())) {
|
case XXOS_ACTION_TIME_CHANGED:
|
||||||
Log.e(TAG, "TimeChangedReceiver:" + "time tick");
|
setAlarmTime();
|
||||||
|
break;
|
||||||
|
case Intent.ACTION_TIME_TICK:
|
||||||
hourlyTimeSignal();
|
hourlyTimeSignal();
|
||||||
|
break;
|
||||||
|
case XXOS_ACTION_TIME_TICK:
|
||||||
|
alarmWakeup();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -450,7 +501,20 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registFastCallReceive() {
|
private void alarmWakeup() {
|
||||||
|
boolean hourly_time = mMMKV.decodeBool(CommonConfig.HOURLY_TIME_SIGNAL_KEY, false);
|
||||||
|
if (hourly_time) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||||
|
Log.e(TAG, "hourlyTimeSignal: hour = " + hour);
|
||||||
|
mTimeSignalCallback.timeTick(hour);
|
||||||
|
setAlarmTime();
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "hourlyTimeSignal: not enable hourly time signal");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerFastCallReceive() {
|
||||||
if (null == mTimeSignalReceiver) {
|
if (null == mTimeSignalReceiver) {
|
||||||
mTimeSignalReceiver = new TimeSignalReceiver();
|
mTimeSignalReceiver = new TimeSignalReceiver();
|
||||||
}
|
}
|
||||||
@@ -728,8 +792,8 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
|||||||
if (mBallView.isAttachedToWindow()) {
|
if (mBallView.isAttachedToWindow()) {
|
||||||
mWindowManager.removeView(mBallView);
|
mWindowManager.removeView(mBallView);
|
||||||
}
|
}
|
||||||
mMMKV.encode(Float_Window_X, mBallParams.x);
|
mMMKV.encode(FLOAT_WINDOW_X, mBallParams.x);
|
||||||
mMMKV.encode(Float_Window_Y, mBallParams.y);
|
mMMKV.encode(FLOAT_WINDOW_Y, mBallParams.y);
|
||||||
}
|
}
|
||||||
isBallShown = false;
|
isBallShown = false;
|
||||||
break;
|
break;
|
||||||
@@ -789,8 +853,8 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
|||||||
mBallParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
|
mBallParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||||
mBallParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
mBallParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||||
// mBallParams.gravity = Gravity.TOP;
|
// mBallParams.gravity = Gravity.TOP;
|
||||||
int x = mMMKV.decodeInt(Float_Window_X, 360);
|
int x = mMMKV.decodeInt(FLOAT_WINDOW_X, 360);
|
||||||
int y = mMMKV.decodeInt(Float_Window_Y, -783);
|
int y = mMMKV.decodeInt(FLOAT_WINDOW_Y, -783);
|
||||||
mBallParams.x = x;
|
mBallParams.x = x;
|
||||||
mBallParams.y = y;
|
mBallParams.y = y;
|
||||||
mWindowManager.addView(mBallView, mBallParams);
|
mWindowManager.addView(mBallView, mBallParams);
|
||||||
@@ -879,8 +943,8 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
|||||||
mBallParams.y += tranY;
|
mBallParams.y += tranY;
|
||||||
// 更新悬浮窗位置
|
// 更新悬浮窗位置
|
||||||
mWindowManager.updateViewLayout(mBallView, mBallParams);
|
mWindowManager.updateViewLayout(mBallView, mBallParams);
|
||||||
mMMKV.encode(Float_Window_X, mBallParams.x);
|
mMMKV.encode(FLOAT_WINDOW_X, mBallParams.x);
|
||||||
mMMKV.encode(Float_Window_Y, mBallParams.y);
|
mMMKV.encode(FLOAT_WINDOW_Y, mBallParams.y);
|
||||||
// 记录当前坐标作为下一次计算的上一次移动的位置坐标
|
// 记录当前坐标作为下一次计算的上一次移动的位置坐标
|
||||||
lastX = nowX;
|
lastX = nowX;
|
||||||
lastY = nowY;
|
lastY = nowY;
|
||||||
|
|||||||
@@ -15,9 +15,11 @@ import android.text.TextUtils;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.tencent.mmkv.MMKV;
|
||||||
import com.xxpatx.os.R;
|
import com.xxpatx.os.R;
|
||||||
import com.xxpatx.os.bean.Contact;
|
import com.xxpatx.os.bean.Contact;
|
||||||
import com.xxpatx.os.bean.ContactId;
|
import com.xxpatx.os.bean.ContactId;
|
||||||
|
import com.xxpatx.os.config.CommonConfig;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -640,5 +642,34 @@ public class ContactsUtils {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final String NAME = "name";
|
||||||
|
public static final String NUMBER = "number";
|
||||||
|
|
||||||
|
public static List<Contact> getSIMContacts(Context context) {
|
||||||
|
List<Contact> contactList = new ArrayList<>();
|
||||||
|
MMKV mmkv = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||||
|
boolean show_sim = mmkv.decodeInt(CommonConfig.SHOW_SIM_CARD_CONTACT, 0) == 1;
|
||||||
|
if (!show_sim) {
|
||||||
|
return contactList;
|
||||||
|
}
|
||||||
|
ContentResolver resolver = context.getContentResolver();
|
||||||
|
// 获取Sims卡联系人
|
||||||
|
Uri uri = Uri.parse("content://icc/adn");
|
||||||
|
Cursor phoneCursor = resolver.query(uri, null, null, null, null);
|
||||||
|
if (phoneCursor != null) {
|
||||||
|
final int colName = phoneCursor.getColumnIndex(NAME);
|
||||||
|
final int colNumber = phoneCursor.getColumnIndex(NUMBER);
|
||||||
|
while (phoneCursor.moveToNext()) {
|
||||||
|
String number = phoneCursor.getString(colNumber);
|
||||||
|
// 当手机号码为空的或者为空字段 跳过当前循环
|
||||||
|
String username = phoneCursor.getString(colName);
|
||||||
|
Log.e(TAG, "getSIMContacts: number = " + number + " username = " + username);
|
||||||
|
Contact contact = new Contact(username, number, true);
|
||||||
|
contactList.add(contact);
|
||||||
|
}
|
||||||
|
phoneCursor.close();
|
||||||
|
}
|
||||||
|
return contactList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user