version:2.1.4
bugfixes: update:优化天气,自动接听和联系人修改增加弹窗
This commit is contained in:
@@ -16,8 +16,8 @@ android {
|
|||||||
minSdkVersion 24
|
minSdkVersion 24
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
|
|
||||||
versionCode 212
|
versionCode 214
|
||||||
versionName "2.1.2"
|
versionName "2.1.4"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
|||||||
@@ -176,6 +176,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".activity.contact.EditContactActivity"
|
android:name=".activity.contact.EditContactActivity"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
|
android:theme="@style/AppTheme"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.phone.PhoneActivity"
|
android:name=".activity.phone.PhoneActivity"
|
||||||
|
|||||||
@@ -156,32 +156,20 @@ public class AlarmEditActivity extends BaseMvvmActivity<AlarmEditViewModel, Acti
|
|||||||
|
|
||||||
private void checkContent() {
|
private void checkContent() {
|
||||||
pvTime.returnData();
|
pvTime.returnData();
|
||||||
if (TextUtils.isEmpty(mViewDataBinding.etActivation.getText())) {
|
// if (TextUtils.isEmpty(mViewDataBinding.etActivation.getText())) {
|
||||||
Toaster.show("请输入标题");
|
// Toaster.show("请输入标题");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
// if (TextUtils.isEmpty(mPictrueFilePath)) {
|
// if (TextUtils.isEmpty(mPictrueFilePath)) {
|
||||||
// Toaster.show("请重新选择图片");
|
// Toaster.show("请重新选择图片");
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
String timeStamp = getTime(mDate);
|
String timeStamp = getTime(mDate);
|
||||||
Log.e(TAG, "checkContent: " + timeStamp);
|
Log.e(TAG, "checkContent: timeStamp = " + timeStamp);
|
||||||
Log.e(TAG, "checkContent: " + mPictrueFilePath);
|
Log.e(TAG, "checkContent: mPictrueFilePath = " + mPictrueFilePath);
|
||||||
// Uri uri = Uri.parse(pictrueFilePath);
|
// Uri uri = Uri.parse(pictrueFilePath);
|
||||||
// File picFile = FileUtil.uriToFile(uri, AlarmClockAddActivity.this);
|
// File picFile = FileUtil.uriToFile(uri, AlarmClockAddActivity.this);
|
||||||
MultipartBody.Part body;
|
|
||||||
if (FileUtil.isLocalPath(mPictrueFilePath)) {
|
|
||||||
File picFile = new File(mPictrueFilePath);
|
|
||||||
MediaType mediaType = MediaType.Companion.parse("image/png");
|
|
||||||
RequestBody requestBody = RequestBody.Companion.create(picFile, mediaType);
|
|
||||||
body = MultipartBody.Part.createFormData("file", picFile.getName(), requestBody);
|
|
||||||
} else {
|
|
||||||
String fileName = Utils.getFileNamefromURL(mPictrueFilePath);
|
|
||||||
File picFile = new File(Utils.getDownLoadPath(this) + fileName);
|
|
||||||
MediaType mediaType = MediaType.Companion.parse("image/png");
|
|
||||||
RequestBody requestBody = RequestBody.Companion.create(picFile, mediaType);
|
|
||||||
body = MultipartBody.Part.createFormData("file", picFile.getName(), requestBody);
|
|
||||||
}
|
|
||||||
|
|
||||||
mAlarmClockData.setId(mAlarmClockData.getId());
|
mAlarmClockData.setId(mAlarmClockData.getId());
|
||||||
mAlarmClockData.setType(mDayType);
|
mAlarmClockData.setType(mDayType);
|
||||||
@@ -210,47 +198,71 @@ public class AlarmEditActivity extends BaseMvvmActivity<AlarmEditViewModel, Acti
|
|||||||
AlarmUtils.getInstance().updateAlarmClock(mAlarmClockData);
|
AlarmUtils.getInstance().updateAlarmClock(mAlarmClockData);
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
NetInterfaceManager.getInstance().getAlarmClockEditObservable(params, body)
|
if (!TextUtils.isEmpty(mPictrueFilePath)) {
|
||||||
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
MultipartBody.Part body;
|
||||||
.subscribe(new Observer<BaseResponse>() {
|
if (FileUtil.isLocalPath(mPictrueFilePath)) {
|
||||||
@Override
|
File picFile = new File(mPictrueFilePath);
|
||||||
public void onSubscribe(@NonNull Disposable d) {
|
MediaType mediaType = MediaType.Companion.parse("image/png");
|
||||||
Log.e("checkContent", "onSubscribe: ");
|
RequestBody requestBody = RequestBody.Companion.create(picFile, mediaType);
|
||||||
Toaster.show("正在上传");
|
body = MultipartBody.Part.createFormData("file", picFile.getName(), requestBody);
|
||||||
mViewDataBinding.tvAdd.setEnabled(false);
|
} else {
|
||||||
}
|
String fileName = Utils.getFileNamefromURL(mPictrueFilePath);
|
||||||
|
File picFile = new File(Utils.getDownLoadPath(this) + fileName);
|
||||||
@Override
|
MediaType mediaType = MediaType.Companion.parse("image/png");
|
||||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
RequestBody requestBody = RequestBody.Companion.create(picFile, mediaType);
|
||||||
Log.e("checkContent", "onNext: " + baseResponse);
|
body = MultipartBody.Part.createFormData("file", picFile.getName(), requestBody);
|
||||||
if (baseResponse.code == 200) {
|
}
|
||||||
Toaster.show("编辑成功");
|
NetInterfaceManager.getInstance().getAlarmClockEditObservable(params, body)
|
||||||
mAlarmClockData.setEdited(false);
|
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||||
AlarmUtils.getInstance().updateAlarmClock(mAlarmClockData);
|
.subscribe(getAlarmClockEditObserver());
|
||||||
finish();
|
} else {
|
||||||
} else {
|
NetInterfaceManager.getInstance().getAlarmClockEditObservable(params)
|
||||||
Toaster.show("编辑失败:" + baseResponse.msg);
|
.compose(RxLifecycle.bindUntilEvent(getLifecycleSubject(), ActivityEvent.DESTROY))
|
||||||
}
|
.subscribe(getAlarmClockEditObserver());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(@NonNull Throwable e) {
|
|
||||||
Log.e("checkContent", "onError: " + e.getMessage());
|
|
||||||
mAlarmClockData.setEdited(true);
|
|
||||||
AlarmUtils.getInstance().updateAlarmClock(mAlarmClockData);
|
|
||||||
onComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
Log.e("checkContent", "onComplete: ");
|
|
||||||
mViewDataBinding.tvAdd.setEnabled(true);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Observer<BaseResponse> getAlarmClockEditObserver() {
|
||||||
|
return new Observer<BaseResponse>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(@NonNull Disposable d) {
|
||||||
|
Log.e("checkContent", "onSubscribe: ");
|
||||||
|
Toaster.show("正在上传");
|
||||||
|
mViewDataBinding.tvAdd.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||||
|
Log.e("checkContent", "onNext: " + baseResponse);
|
||||||
|
if (baseResponse.code == 200) {
|
||||||
|
Toaster.show("编辑成功");
|
||||||
|
mAlarmClockData.setEdited(false);
|
||||||
|
AlarmUtils.getInstance().updateAlarmClock(mAlarmClockData);
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
Toaster.show("编辑失败:" + baseResponse.msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(@NonNull Throwable e) {
|
||||||
|
Log.e("checkContent", "onError: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
mAlarmClockData.setEdited(true);
|
||||||
|
AlarmUtils.getInstance().updateAlarmClock(mAlarmClockData);
|
||||||
|
onComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
Log.e("checkContent", "onComplete: ");
|
||||||
|
mViewDataBinding.tvAdd.setEnabled(true);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private void openSelector() {
|
private void openSelector() {
|
||||||
PictureSelector.create(AlarmEditActivity.this)
|
PictureSelector.create(AlarmEditActivity.this)
|
||||||
.openGallery(SelectMimeType.ofAll())
|
.openGallery(SelectMimeType.ofAll())
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.provider.Settings;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
@@ -79,9 +78,8 @@ public class AlarmListActivity extends BaseMvvmActivity<AlarmListViewModel, Acti
|
|||||||
mAlarmAdapter.setOnLongClickListener(new AlarmAdapter.OnLongClickListener() {
|
mAlarmAdapter.setOnLongClickListener(new AlarmAdapter.OnLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onLongClick(AlarmClockData alarmClockData) {
|
public void onLongClick(AlarmClockData alarmClockData) {
|
||||||
boolean clockModify = mMMKV.decodeBool(CommonConfig.DISABLE_CLOCK_MODIFY, false);
|
int clockModify = mMMKV.decodeInt(CommonConfig.ALARM_CLOCK_CTRL, 1);
|
||||||
int alarm_clock_ctrl = Settings.Global.getInt(getContentResolver(), CommonConfig.ALARM_CLOCK_CTRL, 1);
|
if (clockModify == 0) {
|
||||||
if (clockModify || alarm_clock_ctrl == 0) {
|
|
||||||
Toaster.showLong("已禁用闹钟修改");
|
Toaster.showLong("已禁用闹钟修改");
|
||||||
} else {
|
} else {
|
||||||
showDialog(alarmClockData);
|
showDialog(alarmClockData);
|
||||||
@@ -236,9 +234,8 @@ public class AlarmListActivity extends BaseMvvmActivity<AlarmListViewModel, Acti
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void add(View view) {
|
public void add(View view) {
|
||||||
boolean clockModify = mMMKV.decodeBool(CommonConfig.DISABLE_CLOCK_MODIFY, false);
|
int clockModify = mMMKV.decodeInt(CommonConfig.ALARM_CLOCK_CTRL, 1);
|
||||||
int alarm_clock_ctrl = Settings.Global.getInt(getContentResolver(), CommonConfig.ALARM_CLOCK_CTRL, 1);
|
if (clockModify == 0) {
|
||||||
if (clockModify || alarm_clock_ctrl == 0) {
|
|
||||||
Toaster.showLong("已禁用闹钟修改");
|
Toaster.showLong("已禁用闹钟修改");
|
||||||
} else {
|
} else {
|
||||||
startActivity(new Intent(AlarmListActivity.this, AlarmAddActivity.class));
|
startActivity(new Intent(AlarmListActivity.this, AlarmAddActivity.class));
|
||||||
|
|||||||
@@ -27,10 +27,12 @@ import com.vscool.os.bean.BaseResponse;
|
|||||||
import com.vscool.os.bean.Contact;
|
import com.vscool.os.bean.Contact;
|
||||||
import com.vscool.os.custom.GlideEngine;
|
import com.vscool.os.custom.GlideEngine;
|
||||||
import com.vscool.os.databinding.ActivityContactEditBinding;
|
import com.vscool.os.databinding.ActivityContactEditBinding;
|
||||||
|
import com.vscool.os.utils.ContactsUtils;
|
||||||
import com.vscool.os.utils.FileUtil;
|
import com.vscool.os.utils.FileUtil;
|
||||||
import com.vscool.os.utils.ScreenUtils;
|
import com.vscool.os.utils.ScreenUtils;
|
||||||
import com.vscool.os.utils.Utils;
|
import com.vscool.os.utils.Utils;
|
||||||
import com.xiasuhuei321.loadingdialog.view.LoadingDialog;
|
import com.xiasuhuei321.loadingdialog.view.LoadingDialog;
|
||||||
|
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -47,11 +49,7 @@ public class EditContactActivity extends BaseMvvmActivity<EditContactViewModel,
|
|||||||
private LoadingDialog mLoadingDialog;
|
private LoadingDialog mLoadingDialog;
|
||||||
private String mPictrueFilePath;
|
private String mPictrueFilePath;
|
||||||
private Contact mContact;
|
private Contact mContact;
|
||||||
|
private long mContactId = -1;
|
||||||
@Override
|
|
||||||
public boolean setfitWindow() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutId() {
|
protected int getLayoutId() {
|
||||||
@@ -68,6 +66,9 @@ public class EditContactActivity extends BaseMvvmActivity<EditContactViewModel,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initView() {
|
protected void initView() {
|
||||||
|
UltimateBarX.addStatusBarTopPadding(mViewDataBinding.clExit);
|
||||||
|
UltimateBarX.addNavigationBarBottomPadding(mViewDataBinding.clBottom);
|
||||||
|
|
||||||
mLoadingDialog = new LoadingDialog(this);
|
mLoadingDialog = new LoadingDialog(this);
|
||||||
mLoadingDialog.setLoadingText("正在上传")
|
mLoadingDialog.setLoadingText("正在上传")
|
||||||
.setSuccessText("添加成功")
|
.setSuccessText("添加成功")
|
||||||
@@ -107,6 +108,9 @@ public class EditContactActivity extends BaseMvvmActivity<EditContactViewModel,
|
|||||||
if (mContact == null) {
|
if (mContact == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!TextUtils.isEmpty(mContact.getMobile())) {
|
||||||
|
mContactId = ContactsUtils.findContactIdByPhoneNumber(EditContactActivity.this, mContact.getMobile());
|
||||||
|
}
|
||||||
if (mContact.getIs_urgent() == 1) {
|
if (mContact.getIs_urgent() == 1) {
|
||||||
mViewDataBinding.toggleButton.setToggleOn(false);
|
mViewDataBinding.toggleButton.setToggleOn(false);
|
||||||
} else {
|
} else {
|
||||||
@@ -182,6 +186,17 @@ public class EditContactActivity extends BaseMvvmActivity<EditContactViewModel,
|
|||||||
params.put("mobile", phone);
|
params.put("mobile", phone);
|
||||||
params.put("tag", groupTag);
|
params.put("tag", groupTag);
|
||||||
params.put("is_urgent", String.valueOf(mViewDataBinding.toggleButton.isToggleOn()));
|
params.put("is_urgent", String.valueOf(mViewDataBinding.toggleButton.isToggleOn()));
|
||||||
|
|
||||||
|
Contact contact = new Contact();
|
||||||
|
contact.setId(mContact.getId());
|
||||||
|
contact.setMobile(phone);
|
||||||
|
contact.setName(name);
|
||||||
|
contact.setTag(groupTag);
|
||||||
|
contact.setIs_urgent(mViewDataBinding.toggleButton.isToggleOn());
|
||||||
|
contact.setAvatar(avatarFile.getAbsolutePath());
|
||||||
|
|
||||||
|
ContactsUtils.editContactPhone(EditContactActivity.this, mContactId, mContact);
|
||||||
|
|
||||||
mViewModel.editContact(params, body);
|
mViewModel.editContact(params, body);
|
||||||
mLoadingDialog.show();
|
mLoadingDialog.show();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import com.vscool.os.R;
|
|||||||
import com.vscool.os.base.mvvm.BaseMvvmActivity;
|
import com.vscool.os.base.mvvm.BaseMvvmActivity;
|
||||||
import com.vscool.os.config.CommonConfig;
|
import com.vscool.os.config.CommonConfig;
|
||||||
import com.vscool.os.databinding.ActivityControlBinding;
|
import com.vscool.os.databinding.ActivityControlBinding;
|
||||||
import com.vscool.os.manager.AmapManager;
|
|
||||||
import com.vscool.os.utils.BrightnessUtils;
|
import com.vscool.os.utils.BrightnessUtils;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@@ -674,7 +673,7 @@ public class ControlActivity extends BaseMvvmActivity<ControlViewModel, Activity
|
|||||||
mViewDataBinding.clLocation.setOnClickListener(new View.OnClickListener() {
|
mViewDataBinding.clLocation.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
AmapManager.getInstance().startLocation();
|
// AmapManager.getInstance().startLocation();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import android.content.ContentResolver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.ServiceConnection;
|
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
@@ -16,6 +15,7 @@ import android.database.Cursor;
|
|||||||
import android.hardware.camera2.CameraAccessException;
|
import android.hardware.camera2.CameraAccessException;
|
||||||
import android.hardware.camera2.CameraCharacteristics;
|
import android.hardware.camera2.CameraCharacteristics;
|
||||||
import android.hardware.camera2.CameraManager;
|
import android.hardware.camera2.CameraManager;
|
||||||
|
import android.media.AudioAttributes;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -72,7 +72,6 @@ import com.vscool.os.fragment.app.AppListFragment;
|
|||||||
import com.vscool.os.fragment.contact.ContactFragment;
|
import com.vscool.os.fragment.contact.ContactFragment;
|
||||||
import com.vscool.os.fragment.home.HomeFragment;
|
import com.vscool.os.fragment.home.HomeFragment;
|
||||||
import com.vscool.os.fragment.settings.SettingsFragment;
|
import com.vscool.os.fragment.settings.SettingsFragment;
|
||||||
import com.vscool.os.manager.AmapManager;
|
|
||||||
import com.vscool.os.manager.DesktopIconManager;
|
import com.vscool.os.manager.DesktopIconManager;
|
||||||
import com.vscool.os.service.NotificationService;
|
import com.vscool.os.service.NotificationService;
|
||||||
import com.vscool.os.utils.ApkUtils;
|
import com.vscool.os.utils.ApkUtils;
|
||||||
@@ -106,7 +105,6 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
|||||||
private static final String TAG = "MainActivity";
|
private static final String TAG = "MainActivity";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||||
|
|
||||||
private FragmentManager mFragmentManager;
|
private FragmentManager mFragmentManager;
|
||||||
@@ -711,7 +709,6 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
|||||||
mViewModel.getTestApp();
|
mViewModel.getTestApp();
|
||||||
|
|
||||||
registerReceiver();
|
registerReceiver();
|
||||||
initAmap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initAmap() {
|
private void initAmap() {
|
||||||
@@ -719,9 +716,10 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
|||||||
String tude = mMMKV.decodeString(CommonConfig.MANUALLY_SELECT_LOCATION_TUDE, CommonConfig.DEFAULT_LOCATION_TUDE);
|
String tude = mMMKV.decodeString(CommonConfig.MANUALLY_SELECT_LOCATION_TUDE, CommonConfig.DEFAULT_LOCATION_TUDE);
|
||||||
if (!manual) {
|
if (!manual) {
|
||||||
LiveEventBus.get(CommonConfig.AMAP_LOCATION_MAP_BEAN, MapBean.class)
|
LiveEventBus.get(CommonConfig.AMAP_LOCATION_MAP_BEAN, MapBean.class)
|
||||||
.observe(this, new Observer<MapBean>() {
|
.observeSticky(this, new Observer<MapBean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable MapBean mapBean) {
|
public void onChanged(@Nullable MapBean mapBean) {
|
||||||
|
Log.e(TAG, "observeSticky onChanged: ");
|
||||||
mMMKV.encode(CommonConfig.MANUALLY_SELECT_LOCATION_DISTRICT, mapBean.getDistrict());
|
mMMKV.encode(CommonConfig.MANUALLY_SELECT_LOCATION_DISTRICT, mapBean.getDistrict());
|
||||||
mMMKV.encode(CommonConfig.MANUALLY_SELECT_LOCATION_TUDE, mapBean.getLongitude() + "," + mapBean.getLatitude());
|
mMMKV.encode(CommonConfig.MANUALLY_SELECT_LOCATION_TUDE, mapBean.getLongitude() + "," + mapBean.getLatitude());
|
||||||
// mViewDataBinding.tvLocation.setText(mapBean.getDistrict());
|
// mViewDataBinding.tvLocation.setText(mapBean.getDistrict());
|
||||||
@@ -735,9 +733,6 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceConnection mAlarmServiceConnection;
|
|
||||||
|
|
||||||
|
|
||||||
public static void toggleNotificationListenerService(Context context) {
|
public static void toggleNotificationListenerService(Context context) {
|
||||||
Log.e(TAG, "toggleNotificationListenerService");
|
Log.e(TAG, "toggleNotificationListenerService");
|
||||||
PackageManager pm = context.getPackageManager();
|
PackageManager pm = context.getPackageManager();
|
||||||
@@ -848,6 +843,7 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
|||||||
}
|
}
|
||||||
|
|
||||||
setDockApp();
|
setDockApp();
|
||||||
|
initAmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDockApp() {
|
private void setDockApp() {
|
||||||
@@ -1085,7 +1081,6 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
|||||||
registerNewAppReceiver();
|
registerNewAppReceiver();
|
||||||
registerSOSNumberReceiver();
|
registerSOSNumberReceiver();
|
||||||
registerUpdateDesktopReceiver();
|
registerUpdateDesktopReceiver();
|
||||||
registerUpdateAddressReceiver();
|
|
||||||
registerTimeReceiver();
|
registerTimeReceiver();
|
||||||
registerMissCallReceiver();
|
registerMissCallReceiver();
|
||||||
registerPhoneStateReceiver();
|
registerPhoneStateReceiver();
|
||||||
@@ -1101,9 +1096,6 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
|||||||
if (mUpdateDesktopReceiver != null) {
|
if (mUpdateDesktopReceiver != null) {
|
||||||
unregisterReceiver(mUpdateDesktopReceiver);
|
unregisterReceiver(mUpdateDesktopReceiver);
|
||||||
}
|
}
|
||||||
if (mUpdateAddressReceiver != null) {
|
|
||||||
unregisterReceiver(mUpdateAddressReceiver);
|
|
||||||
}
|
|
||||||
if (mTimeChangedReceiver != null) {
|
if (mTimeChangedReceiver != null) {
|
||||||
unregisterReceiver(mTimeChangedReceiver);
|
unregisterReceiver(mTimeChangedReceiver);
|
||||||
}
|
}
|
||||||
@@ -1188,25 +1180,6 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private UpdateAddressReceiver mUpdateAddressReceiver;
|
|
||||||
|
|
||||||
private void registerUpdateAddressReceiver() {
|
|
||||||
mUpdateAddressReceiver = new UpdateAddressReceiver();
|
|
||||||
IntentFilter filter = new IntentFilter();
|
|
||||||
filter.addAction(CommonConfig.UIUIAIOS_UPDATE_ADDRESS_ACTION);
|
|
||||||
registerReceiver(mUpdateAddressReceiver, filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
class UpdateAddressReceiver extends BroadcastReceiver {
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
String action = intent.getAction();
|
|
||||||
if (CommonConfig.UIUIAIOS_UPDATE_ADDRESS_ACTION.equals(action)) {
|
|
||||||
AmapManager.getInstance().startLocation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//监听时间和日期变化
|
//监听时间和日期变化
|
||||||
public void registerTimeReceiver() {
|
public void registerTimeReceiver() {
|
||||||
mTimeChangedReceiver = new TimeChangedReceiver();
|
mTimeChangedReceiver = new TimeChangedReceiver();
|
||||||
@@ -1286,12 +1259,17 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
|||||||
boolean voiceBroadcast = mMMKV.decodeBool(CommonConfig.VOICE_BROADCAST, false);
|
boolean voiceBroadcast = mMMKV.decodeBool(CommonConfig.VOICE_BROADCAST, false);
|
||||||
Log.e(TAG, "onReceive: voiceBroadcast = " + voiceBroadcast);
|
Log.e(TAG, "onReceive: voiceBroadcast = " + voiceBroadcast);
|
||||||
if (voiceBroadcast) {
|
if (voiceBroadcast) {
|
||||||
mTextToSpeech = new TextToSpeech(MainActivity.this, MainActivity.this);
|
|
||||||
if (TextUtils.isEmpty(number)) {
|
if (TextUtils.isEmpty(number)) {
|
||||||
mPhoneInfo = "未知号码来电";
|
mPhoneInfo = "未知号码来电";
|
||||||
} else {
|
} else {
|
||||||
mPhoneInfo = "来自" + getContactName(number) + number + "的电话";
|
mPhoneInfo = "来自" + getContactName(number) + number + "的电话";
|
||||||
}
|
}
|
||||||
|
mTextToSpeech = new TextToSpeech(MainActivity.this, MainActivity.this);
|
||||||
|
AudioAttributes.Builder audioAttributes = new AudioAttributes.Builder().
|
||||||
|
setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE).
|
||||||
|
setContentType(AudioAttributes.CONTENT_TYPE_SPEECH).
|
||||||
|
setFlags(AudioAttributes.FLAG_AUDIBILITY_ENFORCED);
|
||||||
|
mTextToSpeech.setAudioAttributes(audioAttributes.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import com.vscool.os.databinding.ActivityMainBinding;
|
|||||||
import com.vscool.os.db.ContactCacheUtils;
|
import com.vscool.os.db.ContactCacheUtils;
|
||||||
import com.vscool.os.gson.GsonUtils;
|
import com.vscool.os.gson.GsonUtils;
|
||||||
import com.vscool.os.manager.AppManager;
|
import com.vscool.os.manager.AppManager;
|
||||||
|
import com.vscool.os.manager.WeatherManager;
|
||||||
import com.vscool.os.network.NetInterfaceManager;
|
import com.vscool.os.network.NetInterfaceManager;
|
||||||
import com.vscool.os.service.main.MainService;
|
import com.vscool.os.service.main.MainService;
|
||||||
import com.vscool.os.utils.ActivationUtil;
|
import com.vscool.os.utils.ActivationUtil;
|
||||||
@@ -90,14 +91,43 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getWeatherNow(location);
|
WeatherManager weatherManager = new WeatherManager(getCtx());
|
||||||
getWeather24Hourly(location);
|
weatherManager.getWeatherNow(location, new WeatherManager.WeatherNowCallback() {
|
||||||
getWeather7D(location);
|
@Override
|
||||||
|
public void onWeatherNow(WeatherNowBean.NowBaseBean nowBaseBean) {
|
||||||
|
LiveEventBus
|
||||||
|
.get("getWeatherNowKey")
|
||||||
|
.post(nowBaseBean);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// weatherManager.getWeather24Hourly(location, new WeatherManager.WeatherHourlyCallback() {
|
||||||
|
// @Override
|
||||||
|
// public void onWeatherHourly(List<WeatherHourlyBean.HourlyBean> hourlyBeanList) {
|
||||||
|
// if (hourlyBeanList != null && !hourlyBeanList.isEmpty()) {
|
||||||
|
// LiveEventBus
|
||||||
|
// .get("getWeather24HourlyKey")
|
||||||
|
// .post(hourlyBeanList.get(0));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
weatherManager.getWeather7Day(false, location, new WeatherManager.WeatherDailyCallback() {
|
||||||
|
@Override
|
||||||
|
public void onWeatherDaily(List<WeatherDailyBean.DailyBean> dailyBeanList) {
|
||||||
|
if (dailyBeanList != null && !dailyBeanList.isEmpty()) {
|
||||||
|
LiveEventBus
|
||||||
|
.get("getWeather7DKey")
|
||||||
|
.post(dailyBeanList.get(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// getWeatherNow(location);
|
||||||
|
// getWeather24Hourly(location);
|
||||||
|
// getWeather7D(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
private MutableLiveData<WeatherNowBean.NowBaseBean> mNowBaseBeanData = new MutableLiveData<>();
|
private MutableLiveData<WeatherNowBean.NowBaseBean> mNowBaseBeanData = new MutableLiveData<>();
|
||||||
|
|
||||||
|
|
||||||
public void getWeatherNow(String location) {
|
public void getWeatherNow(String location) {
|
||||||
Log.e(TAG, "getWeatherNow: " + location);
|
Log.e(TAG, "getWeatherNow: " + location);
|
||||||
/**
|
/**
|
||||||
@@ -134,9 +164,9 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
private MutableLiveData<WeatherHourlyBean.HourlyBean> mHourlyBeanData = new MutableLiveData<>();
|
private MutableLiveData<WeatherHourlyBean.HourlyBean> mHourlyBeanData = new MutableLiveData<>();
|
||||||
|
|
||||||
|
|
||||||
public void getWeather24Hourly(String location) {
|
public void getWeather24Hourly(String location) {
|
||||||
QWeather.getWeather24Hourly(getCtx(), location, new QWeather.OnResultWeatherHourlyListener() {
|
QWeather.getWeather24Hourly(getCtx(), location, new QWeather.OnResultWeatherHourlyListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -165,9 +195,9 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
private MutableLiveData<WeatherDailyBean.DailyBean> DailyBeanData = new MutableLiveData<>();
|
private MutableLiveData<WeatherDailyBean.DailyBean> DailyBeanData = new MutableLiveData<>();
|
||||||
|
|
||||||
|
|
||||||
public void getWeather7D(String location) {
|
public void getWeather7D(String location) {
|
||||||
QWeather.getWeather7D(getCtx(), location, new QWeather.OnResultWeatherDailyListener() {
|
QWeather.getWeather7D(getCtx(), location, new QWeather.OnResultWeatherDailyListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -180,7 +210,6 @@ public class MainViewModel extends BaseViewModel<ActivityMainBinding, ActivityEv
|
|||||||
public void onSuccess(WeatherDailyBean weatherDailyBean) {
|
public void onSuccess(WeatherDailyBean weatherDailyBean) {
|
||||||
String jsonString = new Gson().toJson(weatherDailyBean);
|
String jsonString = new Gson().toJson(weatherDailyBean);
|
||||||
Log.d("getWeather7D", "onSuccess: " + jsonString);
|
Log.d("getWeather7D", "onSuccess: " + jsonString);
|
||||||
mMMKV.encode(CommonConfig.WEATHER_DAILY_KEY, jsonString);
|
|
||||||
List<WeatherDailyBean.DailyBean> dailyBeans = weatherDailyBean.getDaily();
|
List<WeatherDailyBean.DailyBean> dailyBeans = weatherDailyBean.getDaily();
|
||||||
if (dailyBeans != null && dailyBeans.size() != 0) {
|
if (dailyBeans != null && dailyBeans.size() != 0) {
|
||||||
WeatherDailyBean.DailyBean dailyBean = weatherDailyBean.getDaily().get(0);
|
WeatherDailyBean.DailyBean dailyBean = weatherDailyBean.getDaily().get(0);
|
||||||
|
|||||||
@@ -31,10 +31,12 @@ import com.vscool.os.bean.SystemSettings;
|
|||||||
import com.vscool.os.config.CommonConfig;
|
import com.vscool.os.config.CommonConfig;
|
||||||
import com.vscool.os.databinding.ActivitySettingBinding;
|
import com.vscool.os.databinding.ActivitySettingBinding;
|
||||||
import com.vscool.os.dialog.CustomDialog;
|
import com.vscool.os.dialog.CustomDialog;
|
||||||
|
import com.vscool.os.dialog.PermissionsDialog;
|
||||||
import com.vscool.os.service.WeAccessibilityService;
|
import com.vscool.os.service.WeAccessibilityService;
|
||||||
import com.vscool.os.service.main.MainService;
|
import com.vscool.os.service.main.MainService;
|
||||||
import com.vscool.os.utils.AccessibilityUtils;
|
import com.vscool.os.utils.AccessibilityUtils;
|
||||||
import com.vscool.os.utils.ApkUtils;
|
import com.vscool.os.utils.ApkUtils;
|
||||||
|
import com.vscool.os.utils.FloatingWindowUtils;
|
||||||
import com.vscool.os.view.ToggleButton;
|
import com.vscool.os.view.ToggleButton;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@@ -164,14 +166,18 @@ public class SettingActivity extends BaseMvvmActivity<SettingViewModel, Activity
|
|||||||
@Override
|
@Override
|
||||||
public void onToggle(boolean on) {
|
public void onToggle(boolean on) {
|
||||||
Log.e(TAG, "disableVolumeKey: contactModify = " + on);
|
Log.e(TAG, "disableVolumeKey: contactModify = " + on);
|
||||||
mMMKV.encode(CommonConfig.DISABLE_CONTACT_MODIFY, !on);
|
if (on) {
|
||||||
|
showContactDialog();
|
||||||
|
} else {
|
||||||
|
mMMKV.encode(CommonConfig.DISABLE_CONTACT_MODIFY, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mViewDataBinding.tbClock.setOnToggleChanged(new ToggleButton.OnToggleChanged() {
|
mViewDataBinding.tbClock.setOnToggleChanged(new ToggleButton.OnToggleChanged() {
|
||||||
@Override
|
@Override
|
||||||
public void onToggle(boolean on) {
|
public void onToggle(boolean on) {
|
||||||
Log.e(TAG, "disableVolumeKey: clockModify = " + on);
|
Log.e(TAG, "disableVolumeKey: clockModify = " + on);
|
||||||
mMMKV.encode(CommonConfig.DISABLE_CLOCK_MODIFY, !on);
|
mMMKV.encode(CommonConfig.ALARM_CLOCK_CTRL, on ? 1 : 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -224,6 +230,23 @@ public class SettingActivity extends BaseMvvmActivity<SettingViewModel, Activity
|
|||||||
boolean autoAccept = mMMKV.decodeBool(CommonConfig.WECHAT_CALL_AUTO_ACCEPT, false);
|
boolean autoAccept = mMMKV.decodeBool(CommonConfig.WECHAT_CALL_AUTO_ACCEPT, false);
|
||||||
Log.e(TAG, "initView: autoAccept = " + autoAccept);
|
Log.e(TAG, "initView: autoAccept = " + autoAccept);
|
||||||
mViewDataBinding.tbAuto.setToggleStatu(autoAccept);
|
mViewDataBinding.tbAuto.setToggleStatu(autoAccept);
|
||||||
|
if (autoAccept) {
|
||||||
|
boolean floatWindowEnable = Settings.Global.getInt(getContentResolver(), CommonConfig.HOVER_HOME, CommonConfig.HOVER_HOME_STATUS) == 1;
|
||||||
|
boolean permission = FloatingWindowUtils.checkFloatPermission(SettingActivity.this);
|
||||||
|
if (floatWindowEnable && permission) {
|
||||||
|
Toast.makeText(SettingActivity.this, "由于系统限制,请先关闭悬浮窗功能,开启自动接听后再打开悬浮窗", Toast.LENGTH_LONG).show();
|
||||||
|
showFloatWindowDialog();
|
||||||
|
} else {
|
||||||
|
if (AccessibilityUtils.isAccessibilitySettingsOn(SettingActivity.this)) {
|
||||||
|
mMMKV.encode(CommonConfig.WECHAT_CALL_AUTO_ACCEPT, 1);
|
||||||
|
Intent intent = new Intent(WeAccessibilityService.SETTING_AUTOMATIC_ANSWER_ACTION);
|
||||||
|
intent.putExtra("auto_answer", true);
|
||||||
|
sendBroadcast(intent);
|
||||||
|
} else {
|
||||||
|
showAutoAcceptDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean dialTone = mMMKV.decodeBool(CommonConfig.DISABLE_DIAL_TONE_MODIFY, true);
|
boolean dialTone = mMMKV.decodeBool(CommonConfig.DISABLE_DIAL_TONE_MODIFY, true);
|
||||||
Log.e(TAG, "initView: dialTone = " + dialTone);
|
Log.e(TAG, "initView: dialTone = " + dialTone);
|
||||||
@@ -246,9 +269,9 @@ public class SettingActivity extends BaseMvvmActivity<SettingViewModel, Activity
|
|||||||
Log.e(TAG, "initView: contactModify = " + contactModify);
|
Log.e(TAG, "initView: contactModify = " + contactModify);
|
||||||
mViewDataBinding.tbContact.setToggleStatu(!contactModify);
|
mViewDataBinding.tbContact.setToggleStatu(!contactModify);
|
||||||
|
|
||||||
boolean clockModify = mMMKV.decodeBool(CommonConfig.DISABLE_CLOCK_MODIFY, false);
|
int clockModify = mMMKV.decodeInt(CommonConfig.ALARM_CLOCK_CTRL, 1);
|
||||||
Log.e(TAG, "initView: clockModify = " + clockModify);
|
Log.e(TAG, "initView: clockModify = " + clockModify);
|
||||||
mViewDataBinding.tbClock.setToggleStatu(!clockModify);
|
mViewDataBinding.tbClock.setToggleStatu(clockModify == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int REQUEST_CODE_DRAW_OVER_OTHER_APPS_PERMISSION = 200;
|
private static final int REQUEST_CODE_DRAW_OVER_OTHER_APPS_PERMISSION = 200;
|
||||||
@@ -350,23 +373,132 @@ public class SettingActivity extends BaseMvvmActivity<SettingViewModel, Activity
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAutoAccept(boolean on) {
|
public void setAutoAccept(boolean on) {
|
||||||
if (AccessibilityUtils.isAccessibilitySettingsOn(SettingActivity.this)) {
|
if (on) {
|
||||||
mMMKV.encode(CommonConfig.WECHAT_CALL_AUTO_ACCEPT, on);
|
|
||||||
Intent intent = new Intent(WeAccessibilityService.SETTING_AUTOMATIC_ANSWER_ACTION);
|
|
||||||
intent.putExtra("auto_answer", on);
|
|
||||||
sendBroadcast(intent);
|
|
||||||
} else {
|
|
||||||
boolean floatWindowEnable = Settings.Global.getInt(getContentResolver(), CommonConfig.HOVER_HOME, CommonConfig.HOVER_HOME_STATUS) == 1;
|
boolean floatWindowEnable = Settings.Global.getInt(getContentResolver(), CommonConfig.HOVER_HOME, CommonConfig.HOVER_HOME_STATUS) == 1;
|
||||||
if (floatWindowEnable) {
|
boolean permission = FloatingWindowUtils.checkFloatPermission(SettingActivity.this);
|
||||||
Toaster.showLong("因为系统限制,请先关闭 主页按钮 功能,开启自动接听后再打开");
|
if (floatWindowEnable && permission) {
|
||||||
mViewDataBinding.tbAuto.setToggleOff();
|
Toast.makeText(SettingActivity.this, "由于系统限制,请先关闭悬浮窗功能,开启自动接听后再打开悬浮窗", Toast.LENGTH_LONG).show();
|
||||||
|
showFloatWindowDialog();
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(SettingActivity.this, "请在无障碍服务中打开 - 亲情桌面快捷服务", Toast.LENGTH_LONG).show();
|
showAutoAcceptDialog();
|
||||||
startActivity(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS));
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
mMMKV.encode(CommonConfig.WECHAT_CALL_AUTO_ACCEPT, 0);
|
||||||
|
mViewDataBinding.tbAuto.setToggleStatu(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (AccessibilityUtils.isAccessibilitySettingsOn(SettingActivity.this)) {
|
||||||
|
// mMMKV.encode(CommonConfig.WECHAT_CALL_AUTO_ACCEPT, on);
|
||||||
|
// Intent intent = new Intent(WeAccessibilityService.SETTING_AUTOMATIC_ANSWER_ACTION);
|
||||||
|
// intent.putExtra("auto_answer", on);
|
||||||
|
// sendBroadcast(intent);
|
||||||
|
// } else {
|
||||||
|
// boolean floatWindowEnable = Settings.Global.getInt(getContentResolver(), CommonConfig.HOVER_HOME, CommonConfig.HOVER_HOME_STATUS) == 1;
|
||||||
|
// if (floatWindowEnable) {
|
||||||
|
// Toaster.showLong("由于系统限制,请先关闭 主页按钮 功能,开启自动接听后再打开");
|
||||||
|
// mViewDataBinding.tbAuto.setToggleOff();
|
||||||
|
// } else {
|
||||||
|
// Toast.makeText(SettingActivity.this, "请在无障碍服务中打开 - 亲情桌面快捷服务", Toast.LENGTH_LONG).show();
|
||||||
|
// startActivity(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private PermissionsDialog mFloatWindowDialog;
|
||||||
|
|
||||||
|
private void showFloatWindowDialog() {
|
||||||
|
if (mFloatWindowDialog != null) {
|
||||||
|
mFloatWindowDialog.dismiss();
|
||||||
|
mFloatWindowDialog = null;
|
||||||
|
}
|
||||||
|
mFloatWindowDialog = new PermissionsDialog(SettingActivity.this);
|
||||||
|
mFloatWindowDialog.setTitle("功能说明");
|
||||||
|
mFloatWindowDialog.setContent("由于系统限制,请先关闭悬浮窗功能,开启自动接听后再打开悬浮窗");
|
||||||
|
mFloatWindowDialog.setDeniedtext("取消");
|
||||||
|
mFloatWindowDialog.setGrantedtext("确定");
|
||||||
|
mFloatWindowDialog.setPermissionsCallback(new PermissionsDialog.PermissionsCallback() {
|
||||||
|
@Override
|
||||||
|
public void onGranted() {
|
||||||
|
mFloatWindowDialog.dismiss();
|
||||||
|
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDenied() {
|
||||||
|
mFloatWindowDialog.dismiss();
|
||||||
|
mViewDataBinding.tbAuto.setToggleStatu(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mFloatWindowDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private PermissionsDialog mAutoAcceptDialog;
|
||||||
|
|
||||||
|
private void showAutoAcceptDialog() {
|
||||||
|
if (mAutoAcceptDialog != null) {
|
||||||
|
mAutoAcceptDialog.dismiss();
|
||||||
|
mAutoAcceptDialog = null;
|
||||||
|
}
|
||||||
|
mAutoAcceptDialog = new PermissionsDialog(SettingActivity.this);
|
||||||
|
mAutoAcceptDialog.setTitle("功能说明");
|
||||||
|
if (AccessibilityUtils.isAccessibilitySettingsOn(SettingActivity.this)) {
|
||||||
|
mAutoAcceptDialog.setContent("微信视频和语言通话全屏通知情况下,开启自动接听。");
|
||||||
|
} else {
|
||||||
|
mAutoAcceptDialog.setContent("微信视频和语言通话全屏通知情况下,开启自动接听。微信自动接听功能需要获取无障碍权限,点击确定将会跳转到系统设置页面");
|
||||||
|
}
|
||||||
|
mAutoAcceptDialog.setDeniedtext("取消");
|
||||||
|
mAutoAcceptDialog.setGrantedtext("确定");
|
||||||
|
mAutoAcceptDialog.setPermissionsCallback(new PermissionsDialog.PermissionsCallback() {
|
||||||
|
@Override
|
||||||
|
public void onGranted() {
|
||||||
|
mAutoAcceptDialog.dismiss();
|
||||||
|
if (AccessibilityUtils.isAccessibilitySettingsOn(SettingActivity.this)) {
|
||||||
|
mMMKV.encode(CommonConfig.WECHAT_CALL_AUTO_ACCEPT, 1);
|
||||||
|
Intent intent = new Intent(WeAccessibilityService.SETTING_AUTOMATIC_ANSWER_ACTION);
|
||||||
|
intent.putExtra("auto_answer", true);
|
||||||
|
sendBroadcast(intent);
|
||||||
|
} else {
|
||||||
|
Toast.makeText(SettingActivity.this, "请在无障碍服务中打开 - 亲情桌面快捷服务", Toast.LENGTH_LONG).show();
|
||||||
|
startActivity(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDenied() {
|
||||||
|
mAutoAcceptDialog.dismiss();
|
||||||
|
mMMKV.encode(CommonConfig.WECHAT_CALL_AUTO_ACCEPT, 0);
|
||||||
|
mViewDataBinding.tbAuto.setToggleStatu(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mAutoAcceptDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CustomDialog contactDialog;
|
||||||
|
|
||||||
|
private void showContactDialog() {
|
||||||
|
contactDialog = new CustomDialog(SettingActivity.this);
|
||||||
|
contactDialog.setTitle("温馨提示")
|
||||||
|
.setMessage("开启后,允许手机端修改联系人信息")
|
||||||
|
.setOnClickBottomListener(new CustomDialog.OnClickBottomListener() {
|
||||||
|
@Override
|
||||||
|
public void onPositiveClick() {
|
||||||
|
mMMKV.encode(CommonConfig.DISABLE_CONTACT_MODIFY, false);
|
||||||
|
contactDialog.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNegtiveClick() {
|
||||||
|
mViewDataBinding.tbContact.setToggleOff();
|
||||||
|
contactDialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
contactDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class BtnClick {
|
public class BtnClick {
|
||||||
public void exit(View view) {
|
public void exit(View view) {
|
||||||
finish();
|
finish();
|
||||||
@@ -412,6 +544,7 @@ public class SettingActivity extends BaseMvvmActivity<SettingViewModel, Activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void autoAccept(View view) {
|
public void autoAccept(View view) {
|
||||||
boolean autoAccept = mMMKV.decodeBool(CommonConfig.WECHAT_CALL_AUTO_ACCEPT, false);
|
boolean autoAccept = mMMKV.decodeBool(CommonConfig.WECHAT_CALL_AUTO_ACCEPT, false);
|
||||||
Log.e(TAG, "autoAccept: autoAccept = " + autoAccept);
|
Log.e(TAG, "autoAccept: autoAccept = " + autoAccept);
|
||||||
@@ -443,9 +576,9 @@ public class SettingActivity extends BaseMvvmActivity<SettingViewModel, Activity
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void disableClockModify(View view) {
|
public void disableClockModify(View view) {
|
||||||
boolean clockModify = mMMKV.decodeBool(CommonConfig.DISABLE_CLOCK_MODIFY, false);
|
int clockModify = mMMKV.decodeInt(CommonConfig.ALARM_CLOCK_CTRL, 1);
|
||||||
Log.e(TAG, "disableVolumeKey: clockModify = " + clockModify);
|
Log.e(TAG, "disableVolumeKey: clockModify = " + clockModify);
|
||||||
mMMKV.encode(CommonConfig.DISABLE_CLOCK_MODIFY, !clockModify);
|
mMMKV.encode(CommonConfig.ALARM_CLOCK_CTRL, clockModify == 1 ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ public class TouchActivity extends BaseMvvmActivity<TouchViewModel, ActivityTouc
|
|||||||
Log.e(TAG, "initView: contactModify = " + contactModify);
|
Log.e(TAG, "initView: contactModify = " + contactModify);
|
||||||
mViewDataBinding.setDisableContact(contactModify);
|
mViewDataBinding.setDisableContact(contactModify);
|
||||||
|
|
||||||
boolean clockModify = mMMKV.decodeBool(CommonConfig.DISABLE_CLOCK_MODIFY, false);
|
int clockModify = mMMKV.decodeInt(CommonConfig.ALARM_CLOCK_CTRL, 1);
|
||||||
Log.e(TAG, "disableVolumeKey: clockModify = " + clockModify);
|
Log.e(TAG, "disableVolumeKey: clockModify = " + clockModify);
|
||||||
mViewDataBinding.setDisableClock(clockModify);
|
mViewDataBinding.setDisableClock(clockModify == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -68,10 +68,10 @@ public class TouchActivity extends BaseMvvmActivity<TouchViewModel, ActivityTouc
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void disableClockModify(View view) {
|
public void disableClockModify(View view) {
|
||||||
boolean clockModify = mMMKV.decodeBool(CommonConfig.DISABLE_CLOCK_MODIFY, false);
|
int clockModify = mMMKV.decodeInt(CommonConfig.ALARM_CLOCK_CTRL, 1);
|
||||||
Log.e(TAG, "disableVolumeKey: clockModify = " + clockModify);
|
Log.e(TAG, "disableVolumeKey: clockModify = " + clockModify);
|
||||||
mViewDataBinding.setDisableClock(!clockModify);
|
mViewDataBinding.setDisableClock(clockModify == 0);
|
||||||
mMMKV.encode(CommonConfig.DISABLE_CLOCK_MODIFY, !clockModify);
|
mMMKV.encode(CommonConfig.ALARM_CLOCK_CTRL, clockModify == 1 ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import com.vscool.os.manager.AmapManager;
|
|||||||
import com.vscool.os.view.FadeInOutAnimator;
|
import com.vscool.os.view.FadeInOutAnimator;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class WeatherActivity extends BaseMvvmActivity<WeatherViewModel, ActivityWeatherBinding>
|
public class WeatherActivity extends BaseMvvmActivity<WeatherViewModel, ActivityWeatherBinding>
|
||||||
implements NetworkUtils.OnNetworkStatusChangedListener {
|
implements NetworkUtils.OnNetworkStatusChangedListener {
|
||||||
@@ -107,7 +108,7 @@ public class WeatherActivity extends BaseMvvmActivity<WeatherViewModel, Activity
|
|||||||
// linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
// linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
||||||
// mViewDataBinding.rvWeather.addItemDecoration(new HorizontalItemDecoration(30, this));//10表示10dp
|
// mViewDataBinding.rvWeather.addItemDecoration(new HorizontalItemDecoration(30, this));//10表示10dp
|
||||||
// } else {
|
// } else {
|
||||||
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
||||||
// }
|
// }
|
||||||
mViewDataBinding.rvWeather.setLayoutManager(linearLayoutManager);
|
mViewDataBinding.rvWeather.setLayoutManager(linearLayoutManager);
|
||||||
mViewDataBinding.rvWeather.setItemAnimator(new FadeInOutAnimator());
|
mViewDataBinding.rvWeather.setItemAnimator(new FadeInOutAnimator());
|
||||||
@@ -130,7 +131,7 @@ public class WeatherActivity extends BaseMvvmActivity<WeatherViewModel, Activity
|
|||||||
mViewDataBinding.swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
mViewDataBinding.swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onRefresh() {
|
public void onRefresh() {
|
||||||
getWeather();
|
getWeather(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -143,7 +144,7 @@ public class WeatherActivity extends BaseMvvmActivity<WeatherViewModel, Activity
|
|||||||
if (qweatherLocation != null) {
|
if (qweatherLocation != null) {
|
||||||
String tude = qweatherLocation.getLon() + "," + qweatherLocation.getLat();
|
String tude = qweatherLocation.getLon() + "," + qweatherLocation.getLat();
|
||||||
mMMKV.encode(CommonConfig.MANUALLY_SELECT_LOCATION_TUDE, tude);
|
mMMKV.encode(CommonConfig.MANUALLY_SELECT_LOCATION_TUDE, tude);
|
||||||
mViewModel.getWeather(tude);
|
mViewModel.getWeather(tude, true);
|
||||||
} else {
|
} else {
|
||||||
Toaster.show("获取位置信息失败");
|
Toaster.show("获取位置信息失败");
|
||||||
}
|
}
|
||||||
@@ -184,7 +185,6 @@ public class WeatherActivity extends BaseMvvmActivity<WeatherViewModel, Activity
|
|||||||
@Override
|
@Override
|
||||||
public void onChanged(WeatherDailyBean weatherDailyBean) {
|
public void onChanged(WeatherDailyBean weatherDailyBean) {
|
||||||
mViewDataBinding.swipeRefreshLayout.setRefreshing(false);
|
mViewDataBinding.swipeRefreshLayout.setRefreshing(false);
|
||||||
|
|
||||||
if (weatherDailyBean != null) {
|
if (weatherDailyBean != null) {
|
||||||
mWeatherDayApdapter.setDailyBeans(weatherDailyBean.getDaily());
|
mWeatherDayApdapter.setDailyBeans(weatherDailyBean.getDaily());
|
||||||
WeatherDailyBean.DailyBean dailyBean = weatherDailyBean.getDaily().get(0);
|
WeatherDailyBean.DailyBean dailyBean = weatherDailyBean.getDaily().get(0);
|
||||||
@@ -192,19 +192,27 @@ public class WeatherActivity extends BaseMvvmActivity<WeatherViewModel, Activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
mViewModel.mDailyBeanListMutableLiveData.observe(this, new Observer<List<WeatherDailyBean.DailyBean>>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(List<WeatherDailyBean.DailyBean> dailyBeanList) {
|
||||||
|
mViewDataBinding.swipeRefreshLayout.setRefreshing(false);
|
||||||
|
if (dailyBeanList != null) {
|
||||||
|
mWeatherDayApdapter.setDailyBeans(dailyBeanList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
getWeather(false);
|
||||||
getWeather();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getWeather() {
|
private void getWeather(boolean refresh) {
|
||||||
String district = mMMKV.decodeString(CommonConfig.MANUALLY_SELECT_LOCATION_DISTRICT, CommonConfig.DEFAULT_LOCATION_DISTRICT);
|
String district = mMMKV.decodeString(CommonConfig.MANUALLY_SELECT_LOCATION_DISTRICT, CommonConfig.DEFAULT_LOCATION_DISTRICT);
|
||||||
String tude = mMMKV.decodeString(CommonConfig.MANUALLY_SELECT_LOCATION_TUDE, CommonConfig.DEFAULT_LOCATION_TUDE);
|
String tude = mMMKV.decodeString(CommonConfig.MANUALLY_SELECT_LOCATION_TUDE, CommonConfig.DEFAULT_LOCATION_TUDE);
|
||||||
if (TextUtils.isEmpty(tude)) {
|
if (TextUtils.isEmpty(tude)) {
|
||||||
mViewModel.getLocation();
|
mViewModel.getLocation();
|
||||||
} else {
|
} else {
|
||||||
mViewDataBinding.tvLocation.setText(district);
|
mViewDataBinding.tvLocation.setText(district);
|
||||||
mViewModel.getWeather(tude);
|
mViewModel.getWeather(tude, refresh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +247,7 @@ public class WeatherActivity extends BaseMvvmActivity<WeatherViewModel, Activity
|
|||||||
mViewModel.getLocation();
|
mViewModel.getLocation();
|
||||||
} else {
|
} else {
|
||||||
mViewDataBinding.tvLocation.setText(district);
|
mViewDataBinding.tvLocation.setText(district);
|
||||||
mViewModel.getWeather(tude);
|
mViewModel.getWeather(tude, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.vscool.os.bean.QweatherLookup;
|
|||||||
import com.vscool.os.config.CommonConfig;
|
import com.vscool.os.config.CommonConfig;
|
||||||
import com.vscool.os.databinding.ActivityWeatherBinding;
|
import com.vscool.os.databinding.ActivityWeatherBinding;
|
||||||
import com.vscool.os.manager.AmapManager;
|
import com.vscool.os.manager.AmapManager;
|
||||||
|
import com.vscool.os.manager.WeatherManager;
|
||||||
import com.vscool.os.network.NetInterfaceManager;
|
import com.vscool.os.network.NetInterfaceManager;
|
||||||
import com.vscool.os.utils.ActivationUtil;
|
import com.vscool.os.utils.ActivationUtil;
|
||||||
import com.vscool.os.utils.JgyUtils;
|
import com.vscool.os.utils.JgyUtils;
|
||||||
@@ -90,7 +91,9 @@ public class WeatherViewModel extends BaseViewModel<ActivityWeatherBinding, Acti
|
|||||||
mLocationData.setValue(location);
|
mLocationData.setValue(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getWeather(String location) {
|
public void getWeather(String location, boolean refresh) {
|
||||||
|
Log.e(TAG, "getweather: refresh = " + refresh);
|
||||||
|
|
||||||
if (getCtx() == null) {
|
if (getCtx() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -102,10 +105,19 @@ public class WeatherViewModel extends BaseViewModel<ActivityWeatherBinding, Acti
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getWeatherNow(location);
|
WeatherManager weatherManager = new WeatherManager(getCtx());
|
||||||
getWeather7D(location);
|
weatherManager.getWeather7Day(refresh, location, new WeatherManager.WeatherDailyCallback() {
|
||||||
|
@Override
|
||||||
|
public void onWeatherDaily(List<WeatherDailyBean.DailyBean> dailyBeanList) {
|
||||||
|
mDailyBeanListMutableLiveData.setValue(dailyBeanList);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// getWeatherNow(location);
|
||||||
|
// getWeather7D(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<List<WeatherDailyBean.DailyBean>> mDailyBeanListMutableLiveData = new MutableLiveData<>();
|
||||||
|
|
||||||
public MutableLiveData<WeatherNowBean> mWeatherNowData = new MutableLiveData<>();
|
public MutableLiveData<WeatherNowBean> mWeatherNowData = new MutableLiveData<>();
|
||||||
|
|
||||||
public void getWeatherNow(String locationTude) {
|
public void getWeatherNow(String locationTude) {
|
||||||
@@ -162,4 +174,5 @@ public class WeatherViewModel extends BaseViewModel<ActivityWeatherBinding, Acti
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.qweather.sdk.bean.weather.WeatherDailyBean;
|
import com.qweather.sdk.bean.weather.WeatherDailyBean;
|
||||||
|
import com.vscool.os.BuildConfig;
|
||||||
import com.vscool.os.R;
|
import com.vscool.os.R;
|
||||||
import com.vscool.os.utils.DayUtils;
|
import com.vscool.os.utils.DayUtils;
|
||||||
|
|
||||||
@@ -62,7 +63,7 @@ public class WeatherDayApdapter extends RecyclerView.Adapter<WeatherDayApdapter.
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getWeatherDrawable(String iconName) {
|
private Drawable getWeatherDrawable(String iconName) {
|
||||||
int resID = mContext.getResources().getIdentifier("he" + iconName, "drawable", "com.uiui.aios");
|
int resID = mContext.getResources().getIdentifier("he" + iconName, "drawable", BuildConfig.APPLICATION_ID);
|
||||||
if (resID == 0) {
|
if (resID == 0) {
|
||||||
Log.e(TAG, "getView: not found src : " + iconName);
|
Log.e(TAG, "getView: not found src : " + iconName);
|
||||||
return mContext.getResources().getDrawable(R.drawable.he100);
|
return mContext.getResources().getDrawable(R.drawable.he100);
|
||||||
|
|||||||
@@ -845,7 +845,9 @@ public class AlarmUtils {
|
|||||||
|
|
||||||
public void ariaDownload(String url, String md5) {
|
public void ariaDownload(String url, String md5) {
|
||||||
String fileName = Utils.getFileNamefromURL(url);
|
String fileName = Utils.getFileNamefromURL(url);
|
||||||
|
Log.e(TAG, "ariaDownload: fileName = " + fileName);
|
||||||
File file = new File(Utils.getDownLoadPath(mContext) + fileName);
|
File file = new File(Utils.getDownLoadPath(mContext) + fileName);
|
||||||
|
Log.e(TAG, "ariaDownload: " + file.getAbsolutePath());
|
||||||
if (file.exists() && !file.isDirectory()) {
|
if (file.exists() && !file.isDirectory()) {
|
||||||
String fileMD5 = FileUtils.getFileMD5ToString(file);
|
String fileMD5 = FileUtils.getFileMD5ToString(file);
|
||||||
Log.e("ariaDownload", "fileOnlineMD5=" + md5);
|
Log.e("ariaDownload", "fileOnlineMD5=" + md5);
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public class CommonConfig {
|
|||||||
public static final String DEFAULT_PASSWORD = "6666";
|
public static final String DEFAULT_PASSWORD = "6666";
|
||||||
|
|
||||||
/*让桌面更新定位信息*/
|
/*让桌面更新定位信息*/
|
||||||
|
@Deprecated
|
||||||
public static final String UIUIAIOS_UPDATE_ADDRESS_ACTION = "UIUIAIOS_UPDATE_ADDRESS";
|
public static final String UIUIAIOS_UPDATE_ADDRESS_ACTION = "UIUIAIOS_UPDATE_ADDRESS";
|
||||||
/*桌面显示定位信息*/
|
/*桌面显示定位信息*/
|
||||||
public static final String UIUIAIOS_UPDATE_DESKTOP_LOCATION = "UIUIAIOS_UPDATE_DESKTOP_LOCATIO";
|
public static final String UIUIAIOS_UPDATE_DESKTOP_LOCATION = "UIUIAIOS_UPDATE_DESKTOP_LOCATIO";
|
||||||
@@ -82,7 +83,9 @@ public class CommonConfig {
|
|||||||
public static final String MAP_DEFAULT_ADDRESS_JSON_KEY = "amap_default_address_json_key";
|
public static final String MAP_DEFAULT_ADDRESS_JSON_KEY = "amap_default_address_json_key";
|
||||||
|
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static final String WEATHER_NOW_KEY = "WEATHER_NOW_JSON_STRING";
|
public static final String WEATHER_NOW_KEY = "WEATHER_NOW_JSON_STRING";
|
||||||
|
@Deprecated
|
||||||
public static final String WEATHER_DAILY_KEY = "WEATHER_DAILY_JSON_STRING";
|
public static final String WEATHER_DAILY_KEY = "WEATHER_DAILY_JSON_STRING";
|
||||||
|
|
||||||
|
|
||||||
@@ -110,6 +113,7 @@ public class CommonConfig {
|
|||||||
/*修改联系人禁用*/
|
/*修改联系人禁用*/
|
||||||
public static final String DISABLE_CONTACT_MODIFY = "disable_contact_modify_key";
|
public static final String DISABLE_CONTACT_MODIFY = "disable_contact_modify_key";
|
||||||
/*禁用闹钟修改*/
|
/*禁用闹钟修改*/
|
||||||
|
@Deprecated
|
||||||
public static final String DISABLE_CLOCK_MODIFY = "disable_clock_modify_key";
|
public static final String DISABLE_CLOCK_MODIFY = "disable_clock_modify_key";
|
||||||
/*联系人首屏*/
|
/*联系人首屏*/
|
||||||
public static final String CONTACT_HOME_KEY = "contact_home_control";
|
public static final String CONTACT_HOME_KEY = "contact_home_control";
|
||||||
|
|||||||
121
app/src/main/java/com/vscool/os/dialog/PermissionsDialog.java
Normal file
121
app/src/main/java/com/vscool/os/dialog/PermissionsDialog.java
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
package com.vscool.os.dialog;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
|
import com.vscool.os.R;
|
||||||
|
|
||||||
|
public class PermissionsDialog extends AlertDialog {
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
private TextView tv_title;
|
||||||
|
private TextView tv_content;
|
||||||
|
private TextView tv_cancel;
|
||||||
|
private TextView tv_confirm;
|
||||||
|
|
||||||
|
private String mTitle;
|
||||||
|
private String mContent;
|
||||||
|
private String mDeniedtext;
|
||||||
|
private String mGrantedtext;
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
mTitle = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
mContent = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeniedtext(String deniedtext) {
|
||||||
|
mDeniedtext = deniedtext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGrantedtext(String grantedtext) {
|
||||||
|
mGrantedtext = grantedtext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PermissionsDialog(@NonNull Context context) {
|
||||||
|
super(context, R.style.CustomDialog);
|
||||||
|
this.mContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PermissionsDialog(@NonNull Context context, int themeResId) {
|
||||||
|
super(context, themeResId);
|
||||||
|
this.mContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PermissionsDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
|
||||||
|
super(context, cancelable, cancelListener);
|
||||||
|
this.mContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPermissionsCallback(PermissionsCallback callback) {
|
||||||
|
this.mPermissionsCallback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PermissionsCallback mPermissionsCallback;
|
||||||
|
|
||||||
|
public interface PermissionsCallback {
|
||||||
|
void onGranted();
|
||||||
|
|
||||||
|
void onDenied();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.dialog_permissions);
|
||||||
|
setCanceledOnTouchOutside(false);
|
||||||
|
tv_title = findViewById(R.id.tv_title);
|
||||||
|
tv_content = findViewById(R.id.tv_content);
|
||||||
|
tv_cancel = findViewById(R.id.tv_cancel);
|
||||||
|
tv_confirm = findViewById(R.id.tv_confirm);
|
||||||
|
|
||||||
|
tv_cancel.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (mPermissionsCallback != null) {
|
||||||
|
mPermissionsCallback.onDenied();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tv_confirm.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (mPermissionsCallback != null) {
|
||||||
|
mPermissionsCallback.onGranted();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setText();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
super.show();
|
||||||
|
setText();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setText() {
|
||||||
|
if (!TextUtils.isEmpty(mTitle)) {
|
||||||
|
tv_title.setText(mTitle);
|
||||||
|
}
|
||||||
|
if (!TextUtils.isEmpty(mContent)) {
|
||||||
|
tv_content.setText(mContent);
|
||||||
|
}
|
||||||
|
if (!TextUtils.isEmpty(mDeniedtext)) {
|
||||||
|
tv_cancel.setText(mDeniedtext);
|
||||||
|
}
|
||||||
|
if (!TextUtils.isEmpty(mGrantedtext)) {
|
||||||
|
tv_confirm.setText(mGrantedtext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -40,7 +40,6 @@ import com.vscool.os.base.mvvm.fragment.BaseMvvmFragment;
|
|||||||
import com.vscool.os.bean.FamilyAddress;
|
import com.vscool.os.bean.FamilyAddress;
|
||||||
import com.vscool.os.config.CommonConfig;
|
import com.vscool.os.config.CommonConfig;
|
||||||
import com.vscool.os.databinding.PhoneFragmentControlBinding;
|
import com.vscool.os.databinding.PhoneFragmentControlBinding;
|
||||||
import com.vscool.os.manager.AmapManager;
|
|
||||||
import com.vscool.os.utils.BrightnessUtils;
|
import com.vscool.os.utils.BrightnessUtils;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@@ -830,7 +829,7 @@ public class ControlFragment extends BaseMvvmFragment<ControlViewModel, PhoneFra
|
|||||||
mViewDataBinding.clLocation.setOnClickListener(new View.OnClickListener() {
|
mViewDataBinding.clLocation.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
AmapManager.getInstance().startLocation();
|
// AmapManager.getInstance().startLocation();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import com.blankj.utilcode.util.NetworkUtils;
|
|||||||
import com.hjq.toast.Toaster;
|
import com.hjq.toast.Toaster;
|
||||||
import com.jeremyliao.liveeventbus.LiveEventBus;
|
import com.jeremyliao.liveeventbus.LiveEventBus;
|
||||||
import com.qweather.sdk.bean.weather.WeatherDailyBean;
|
import com.qweather.sdk.bean.weather.WeatherDailyBean;
|
||||||
import com.qweather.sdk.bean.weather.WeatherHourlyBean;
|
|
||||||
import com.qweather.sdk.bean.weather.WeatherNowBean;
|
import com.qweather.sdk.bean.weather.WeatherNowBean;
|
||||||
import com.tencent.mmkv.MMKV;
|
import com.tencent.mmkv.MMKV;
|
||||||
import com.vscool.os.BuildConfig;
|
import com.vscool.os.BuildConfig;
|
||||||
@@ -216,54 +215,57 @@ public class HomeFragment extends BaseMvvmFragment<HomeViewModel, FragmentHomeBi
|
|||||||
});
|
});
|
||||||
LiveEventBus
|
LiveEventBus
|
||||||
.get("getWeatherNowKey", WeatherNowBean.NowBaseBean.class)
|
.get("getWeatherNowKey", WeatherNowBean.NowBaseBean.class)
|
||||||
.observe(this, new Observer<WeatherNowBean.NowBaseBean>() {
|
.observeSticky(this, new Observer<WeatherNowBean.NowBaseBean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable WeatherNowBean.NowBaseBean nowBaseBean) {
|
public void onChanged(@Nullable WeatherNowBean.NowBaseBean nowBaseBean) {
|
||||||
mViewDataBinding.tvTemp.setText(nowBaseBean.getTemp() + "℃");
|
if (isAdded()) {
|
||||||
if (DayUtils.isNight()) {
|
mViewDataBinding.tvTemp.setText(nowBaseBean.getTemp() + "℃");
|
||||||
|
|
||||||
|
if (DayUtils.isNight()) {
|
||||||
// mViewDataBinding.clWeather.setBackground(mContext.getDrawable(R.drawable.custom_bg_weather_night));
|
// mViewDataBinding.clWeather.setBackground(mContext.getDrawable(R.drawable.custom_bg_weather_night));
|
||||||
} else {
|
} else {
|
||||||
switch (nowBaseBean.getIcon()) {
|
switch (nowBaseBean.getIcon()) {
|
||||||
default:
|
default:
|
||||||
case "100":
|
case "100":
|
||||||
case "150":
|
case "150":
|
||||||
//晴
|
//晴
|
||||||
// mViewDataBinding.clWeather.setBackground(mContext.getDrawable(R.drawable.custom_bg_weather));
|
// mViewDataBinding.clWeather.setBackground(mContext.getDrawable(R.drawable.custom_bg_weather));
|
||||||
break;
|
break;
|
||||||
case "102":
|
case "102":
|
||||||
case "152":
|
case "152":
|
||||||
//少云
|
//少云
|
||||||
// mViewDataBinding.clWeather.setBackground(mContext.getDrawable(R.drawable.custom_bg_weather_rain));
|
// mViewDataBinding.clWeather.setBackground(mContext.getDrawable(R.drawable.custom_bg_weather_rain));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// mViewDataBinding.tvWeather.setText(nowBaseBean.getText());
|
// mViewDataBinding.tvWeather.setText(nowBaseBean.getText());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
LiveEventBus
|
// LiveEventBus
|
||||||
.get("getWeather24HourlyKey", WeatherHourlyBean.HourlyBean.class)
|
// .get("getWeather24HourlyKey", WeatherHourlyBean.HourlyBean.class)
|
||||||
.observe(this, new Observer<WeatherHourlyBean.HourlyBean>() {
|
// .observeSticky(this, new Observer<WeatherHourlyBean.HourlyBean>() {
|
||||||
@Override
|
// @Override
|
||||||
public void onChanged(@Nullable WeatherHourlyBean.HourlyBean hourlyBean) {
|
// public void onChanged(@Nullable WeatherHourlyBean.HourlyBean hourlyBean) {
|
||||||
String imageName = "he" + hourlyBean.getIcon();
|
// String imageName = "he" + hourlyBean.getIcon();
|
||||||
Log.e(TAG, "onSuccess: " + imageName);
|
// Log.e(TAG, "onSuccess: " + imageName);
|
||||||
if (isAdded()) {
|
// if (isAdded()) {
|
||||||
// int resId = getResources().getIdentifier(imageName, "drawable", mContext.getPackageName());
|
//// int resId = getResources().getIdentifier(imageName, "drawable", mContext.getPackageName());
|
||||||
// Log.e(TAG, "onSuccess: " + resId);
|
//// Log.e(TAG, "onSuccess: " + resId);
|
||||||
// if (resId == 0) {
|
//// if (resId == 0) {
|
||||||
// mViewDataBinding.ivPic.setImageDrawable(mContext.getDrawable(R.drawable.he100));
|
//// mViewDataBinding.ivPic.setImageDrawable(mContext.getDrawable(R.drawable.he100));
|
||||||
// } else {
|
//// } else {
|
||||||
// mViewDataBinding.ivPic.setImageDrawable(mContext.getDrawable(resId));
|
//// mViewDataBinding.ivPic.setImageDrawable(mContext.getDrawable(resId));
|
||||||
// }
|
//// }
|
||||||
mViewDataBinding.tvTemp.setText(hourlyBean.getTemp() + "℃");
|
// mViewDataBinding.tvTemp.setText(hourlyBean.getTemp() + "℃");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
LiveEventBus
|
LiveEventBus
|
||||||
.get("getWeather7DKey", WeatherDailyBean.DailyBean.class)
|
.get("getWeather7DKey", WeatherDailyBean.DailyBean.class)
|
||||||
.observe(this, new Observer<WeatherDailyBean.DailyBean>() {
|
.observeSticky(this, new Observer<WeatherDailyBean.DailyBean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable WeatherDailyBean.DailyBean dailyBean) {
|
public void onChanged(@Nullable WeatherDailyBean.DailyBean dailyBean) {
|
||||||
mViewDataBinding.tvWeather.setText(dailyBean.getTempMin() + "℃ - " + dailyBean.getTempMax() + "℃");
|
mViewDataBinding.tvWeather.setText(dailyBean.getTempMin() + "℃ - " + dailyBean.getTempMax() + "℃");
|
||||||
@@ -443,7 +445,7 @@ public class HomeFragment extends BaseMvvmFragment<HomeViewModel, FragmentHomeBi
|
|||||||
boolean manual = mMMKV.decodeBool(CommonConfig.MANUALLY_SELECT_LOCATION_KEY, false);
|
boolean manual = mMMKV.decodeBool(CommonConfig.MANUALLY_SELECT_LOCATION_KEY, false);
|
||||||
if (!manual) {
|
if (!manual) {
|
||||||
LiveEventBus.get(CommonConfig.AMAP_LOCATION_MAP_BEAN, MapBean.class)
|
LiveEventBus.get(CommonConfig.AMAP_LOCATION_MAP_BEAN, MapBean.class)
|
||||||
.observe(this, new Observer<MapBean>() {
|
.observeSticky(this, new Observer<MapBean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable MapBean mapBean) {
|
public void onChanged(@Nullable MapBean mapBean) {
|
||||||
mViewDataBinding.tvLocation.setText(mapBean.getDistrict());
|
mViewDataBinding.tvLocation.setText(mapBean.getDistrict());
|
||||||
|
|||||||
215
app/src/main/java/com/vscool/os/manager/WeatherManager.java
Normal file
215
app/src/main/java/com/vscool/os/manager/WeatherManager.java
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
package com.vscool.os.manager;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.qweather.sdk.bean.base.Code;
|
||||||
|
import com.qweather.sdk.bean.base.Lang;
|
||||||
|
import com.qweather.sdk.bean.base.Unit;
|
||||||
|
import com.qweather.sdk.bean.weather.WeatherDailyBean;
|
||||||
|
import com.qweather.sdk.bean.weather.WeatherHourlyBean;
|
||||||
|
import com.qweather.sdk.bean.weather.WeatherNowBean;
|
||||||
|
import com.qweather.sdk.view.QWeather;
|
||||||
|
import com.tencent.mmkv.MMKV;
|
||||||
|
import com.vscool.os.config.CommonConfig;
|
||||||
|
import com.vscool.os.gson.GsonUtils;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class WeatherManager {
|
||||||
|
private static final String TAG = "WeatherManager";
|
||||||
|
|
||||||
|
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
private Gson mGson;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上次获取实时天气时间戳 3小时更新
|
||||||
|
*/
|
||||||
|
private static final String GET_WEATHER_NOW_LAST_TIME_KEY = "get_weather_now_last_time_key";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上次获取24小时天气时间戳 8小时更新
|
||||||
|
*/
|
||||||
|
private static final String GET_WEATHER_24_HOURLY_LAST_TIME_KEY = "get_weather_24_hourly_last_time_key";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上次获取7天天气时间戳 24小时更新
|
||||||
|
*/
|
||||||
|
private static final String GET_WEATHER_7_DAY_LAST_TIME_KEY = "get_weather_7_day_last_time_key";
|
||||||
|
|
||||||
|
/*实时天气缓存*/
|
||||||
|
private static final String CACHE_WEATHER_NOW_BEAN_KEY = "cache_weather_now_bean_key";
|
||||||
|
/*24小时天气缓存*/
|
||||||
|
private static final String CACHE_WEATHER_HOURLY_BEAN_KEY = "cache_weather_hourly_bean_key";
|
||||||
|
/*7天天气缓存*/
|
||||||
|
private static final String CACHE_WEATHER_DAILY_BEAN_KEY = "cache_weather_daily_bean_key";
|
||||||
|
|
||||||
|
private static final long MINUTE_1_INTERVAL_MS = 60 * 1000; // 1分钟毫秒数
|
||||||
|
private static final long HOURLY_3_INTERVAL_MS = 3 * 60 * 60 * 1000; // 3小时毫秒数
|
||||||
|
private static final long HOURLY_8_INTERVAL_MS = 8 * 60 * 60 * 1000; // 8小时毫秒数
|
||||||
|
private static final long HOURLY_24_INTERVAL_MS = 24 * 60 * 60 * 1000; // 24小时毫秒数
|
||||||
|
|
||||||
|
public WeatherManager(Context context) {
|
||||||
|
this.mContext = context;
|
||||||
|
mGson = new Gson();
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface WeatherNowCallback {
|
||||||
|
void onWeatherNow(WeatherNowBean.NowBaseBean nowBaseBean);
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void getWeatherNow(String location, WeatherNowCallback weatherNowCallback) {
|
||||||
|
long lastTime = mMMKV.decodeLong(GET_WEATHER_NOW_LAST_TIME_KEY, 0);
|
||||||
|
Log.e(TAG, "getWeatherNow: lastTime = " + lastTime);
|
||||||
|
String jsonString = mMMKV.decodeString(CACHE_WEATHER_NOW_BEAN_KEY, "");
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
|
||||||
|
if (lastTime == 0 || TextUtils.isEmpty(jsonString) || time - lastTime > HOURLY_3_INTERVAL_MS) {
|
||||||
|
Log.e(TAG, "getWeatherNow: get data");
|
||||||
|
QWeather.getWeatherNow(mContext, location, Lang.ZH_HANS, Unit.METRIC, new QWeather.OnResultWeatherNowListener() {
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
mMMKV.encode(GET_WEATHER_NOW_LAST_TIME_KEY, System.currentTimeMillis());
|
||||||
|
Log.e("getWeatherNow", "onError: " + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(WeatherNowBean weatherBean) {
|
||||||
|
mMMKV.encode(GET_WEATHER_NOW_LAST_TIME_KEY, System.currentTimeMillis());
|
||||||
|
Log.e("getWeatherNow", "onSuccess: ");
|
||||||
|
|
||||||
|
//先判断返回的status是否正确,当status正确时获取数据,若status不正确,可查看status对应的Code值找到原因
|
||||||
|
if (Code.OK == weatherBean.getCode()) {
|
||||||
|
WeatherNowBean.NowBaseBean now = weatherBean.getNow();
|
||||||
|
mMMKV.encode(CACHE_WEATHER_NOW_BEAN_KEY, GsonUtils.toJSONString(now));
|
||||||
|
if (weatherNowCallback != null) weatherNowCallback.onWeatherNow(now);
|
||||||
|
} else {
|
||||||
|
//在此查看返回数据失败的原因
|
||||||
|
Code code = weatherBean.getCode();
|
||||||
|
Log.d("getWeatherNow", "onSuccess: failed code: " + code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "getWeatherNow: get cache");
|
||||||
|
try {
|
||||||
|
WeatherNowBean.NowBaseBean now = GsonUtils.toJavaObject(jsonString, WeatherNowBean.NowBaseBean.class);
|
||||||
|
if (weatherNowCallback != null) weatherNowCallback.onWeatherNow(now);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "getWeatherNow: " + e.getMessage());
|
||||||
|
mMMKV.remove(CACHE_WEATHER_NOW_BEAN_KEY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface WeatherHourlyCallback {
|
||||||
|
void onWeatherHourly(List<WeatherHourlyBean.HourlyBean> hourlyBeanList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void getWeather24Hourly(String location, WeatherHourlyCallback weatherHourlyCallback) {
|
||||||
|
long lastTime = mMMKV.decodeLong(GET_WEATHER_24_HOURLY_LAST_TIME_KEY, 0);
|
||||||
|
Log.e(TAG, "getWeather24Hourly: lastTime = " + lastTime);
|
||||||
|
String jsonString = mMMKV.decodeString(CACHE_WEATHER_HOURLY_BEAN_KEY, "");
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
|
||||||
|
if (lastTime == 0 || TextUtils.isEmpty(jsonString) || time - lastTime > HOURLY_8_INTERVAL_MS) {
|
||||||
|
Log.e(TAG, "getWeather24Hourly: get data");
|
||||||
|
QWeather.getWeather24Hourly(mContext, location, new QWeather.OnResultWeatherHourlyListener() {
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable throwable) {
|
||||||
|
mMMKV.encode(GET_WEATHER_24_HOURLY_LAST_TIME_KEY, System.currentTimeMillis());
|
||||||
|
Log.e("getWeather24Hourly", "onError: " + throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(WeatherHourlyBean weatherHourlyBean) {
|
||||||
|
mMMKV.encode(GET_WEATHER_24_HOURLY_LAST_TIME_KEY, System.currentTimeMillis());
|
||||||
|
Log.e("getWeather24Hourly", "onSuccess: ");
|
||||||
|
|
||||||
|
if (Code.OK == weatherHourlyBean.getCode()) {
|
||||||
|
List<WeatherHourlyBean.HourlyBean> hourly = weatherHourlyBean.getHourly();
|
||||||
|
mMMKV.encode(CACHE_WEATHER_HOURLY_BEAN_KEY, GsonUtils.toJSONString(hourly));
|
||||||
|
if (weatherHourlyCallback != null)
|
||||||
|
weatherHourlyCallback.onWeatherHourly(hourly);
|
||||||
|
} else {
|
||||||
|
//在此查看返回数据失败的原因
|
||||||
|
Code code = weatherHourlyBean.getCode();
|
||||||
|
Log.e("getWeather24Hourly", "failed code: " + code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "getWeather24Hourly: get cache");
|
||||||
|
try {
|
||||||
|
Type type = new TypeToken<List<WeatherHourlyBean.HourlyBean>>() {
|
||||||
|
}.getType();
|
||||||
|
List<WeatherHourlyBean.HourlyBean> hourly = mGson.fromJson(jsonString, type);
|
||||||
|
if (weatherHourlyCallback != null) weatherHourlyCallback.onWeatherHourly(hourly);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "getWeather24Hourly: " + e.getMessage());
|
||||||
|
mMMKV.remove(CACHE_WEATHER_HOURLY_BEAN_KEY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface WeatherDailyCallback {
|
||||||
|
void onWeatherDaily(List<WeatherDailyBean.DailyBean> dailyBeanList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void getWeather7Day(boolean refresh, String location, WeatherDailyCallback weatherDailyCallback) {
|
||||||
|
Log.e(TAG, "getWeather7Day: refresh = " + refresh);
|
||||||
|
long lastTime = mMMKV.decodeLong(GET_WEATHER_7_DAY_LAST_TIME_KEY, 0);
|
||||||
|
Log.e(TAG, "getWeather7Day: lastTime = " + lastTime);
|
||||||
|
String jsonString = mMMKV.decodeString(CACHE_WEATHER_DAILY_BEAN_KEY, "");
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
|
||||||
|
if (lastTime == 0 || TextUtils.isEmpty(jsonString) || refresh ? time - lastTime > MINUTE_1_INTERVAL_MS : time - lastTime > HOURLY_24_INTERVAL_MS) {
|
||||||
|
Log.e(TAG, "getWeather7Day: get data");
|
||||||
|
QWeather.getWeather7D(mContext, location, new QWeather.OnResultWeatherDailyListener() {
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable throwable) {
|
||||||
|
mMMKV.encode(GET_WEATHER_7_DAY_LAST_TIME_KEY, System.currentTimeMillis());
|
||||||
|
Log.e("getWeather7Day", "onError: " + throwable.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(WeatherDailyBean weatherDailyBean) {
|
||||||
|
mMMKV.encode(GET_WEATHER_7_DAY_LAST_TIME_KEY, System.currentTimeMillis());
|
||||||
|
Log.e("getWeather7Day", "onSuccess: ");
|
||||||
|
|
||||||
|
if (Code.OK == weatherDailyBean.getCode()) {
|
||||||
|
List<WeatherDailyBean.DailyBean> dailyBeans = weatherDailyBean.getDaily();
|
||||||
|
mMMKV.encode(CACHE_WEATHER_DAILY_BEAN_KEY, GsonUtils.toJSONString(dailyBeans));
|
||||||
|
if (weatherDailyCallback != null)
|
||||||
|
weatherDailyCallback.onWeatherDaily(dailyBeans);
|
||||||
|
} else {
|
||||||
|
//在此查看返回数据失败的原因
|
||||||
|
Code code = weatherDailyBean.getCode();
|
||||||
|
Log.e("getWeather7Day", "failed code: " + code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "getWeather7Day: get cache");
|
||||||
|
try {
|
||||||
|
Type type = new TypeToken<List<WeatherDailyBean.DailyBean>>() {
|
||||||
|
}.getType();
|
||||||
|
List<WeatherDailyBean.DailyBean> dailyBeans = mGson.fromJson(jsonString, type);
|
||||||
|
if (weatherDailyCallback != null) weatherDailyCallback.onWeatherDaily(dailyBeans);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "getWeather7Day: " + e.getMessage());
|
||||||
|
mMMKV.remove(CACHE_WEATHER_DAILY_BEAN_KEY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -473,6 +473,13 @@ public class NetInterfaceManager {
|
|||||||
.observeOn(AndroidSchedulers.mainThread());
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Observable<BaseResponse> getAlarmClockEditObservable(Map<String, String> params) {
|
||||||
|
return mRetrofit.create(AlarmClockEditApi.class)
|
||||||
|
.editAlarmClock(params)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
public Observable<BaseResponse<AlarmClockData>> getAlarmClockByIdObservable(int id) {
|
public Observable<BaseResponse<AlarmClockData>> getAlarmClockByIdObservable(int id) {
|
||||||
return mRetrofit.create(AlarmClockQueryApi.class)
|
return mRetrofit.create(AlarmClockQueryApi.class)
|
||||||
.getAlarmClockById(Utils.getSerial(), id)
|
.getAlarmClockById(Utils.getSerial(), id)
|
||||||
|
|||||||
@@ -19,4 +19,9 @@ public interface AlarmClockEditApi {
|
|||||||
@QueryMap Map<String, String> params,
|
@QueryMap Map<String, String> params,
|
||||||
@Part MultipartBody.Part body
|
@Part MultipartBody.Part body
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@POST(UrlAddress.ALARM_CLOCK_EDIT)
|
||||||
|
Observable<BaseResponse> editAlarmClock(
|
||||||
|
@QueryMap Map<String, String> params
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,12 +230,7 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
|||||||
setAlarmTime();
|
setAlarmTime();
|
||||||
registerTimeChangedReceiver();
|
registerTimeChangedReceiver();
|
||||||
|
|
||||||
registerAlarmReceiver();
|
registerReceivers();
|
||||||
registFastCallReceive();
|
|
||||||
registerLockScreenReceiver();
|
|
||||||
registerOperateAlarmClockReceiver();
|
|
||||||
registerScreenLockReceiver();
|
|
||||||
registerSmsReceiver();
|
|
||||||
|
|
||||||
Observable.create(new ObservableOnSubscribe<Integer>() {
|
Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -338,6 +333,31 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
|||||||
Log.e(TAG, "onDestroy: ");
|
Log.e(TAG, "onDestroy: ");
|
||||||
mPresenter.detachView();
|
mPresenter.detachView();
|
||||||
NetworkUtils.unregisterNetworkStatusChangedListener(this);
|
NetworkUtils.unregisterNetworkStatusChangedListener(this);
|
||||||
|
unregisterReceivers();
|
||||||
|
|
||||||
|
if (mSoundPool != null) {
|
||||||
|
mSoundPool.release();
|
||||||
|
mSoundPool = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isScreenOn() {
|
||||||
|
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||||
|
// true为打开,false为关闭
|
||||||
|
return powerManager.isInteractive();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerReceivers() {
|
||||||
|
registerAlarmReceiver();
|
||||||
|
registFastCallReceive();
|
||||||
|
registerLockScreenReceiver();
|
||||||
|
registerOperateAlarmClockReceiver();
|
||||||
|
registerScreenLockReceiver();
|
||||||
|
registerSmsReceiver();
|
||||||
|
registerUpdateDesktopReceiver();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unregisterReceivers() {
|
||||||
if (alarmReceiver != null) {
|
if (alarmReceiver != null) {
|
||||||
unregisterReceiver(alarmReceiver);
|
unregisterReceiver(alarmReceiver);
|
||||||
}
|
}
|
||||||
@@ -359,19 +379,11 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
|||||||
if (mSmsReceiver != null) {
|
if (mSmsReceiver != null) {
|
||||||
unregisterReceiver(mSmsReceiver);
|
unregisterReceiver(mSmsReceiver);
|
||||||
}
|
}
|
||||||
|
if (mUpdateSettingsReceiver != null) {
|
||||||
if (mSoundPool != null) {
|
unregisterReceiver(mUpdateSettingsReceiver);
|
||||||
mSoundPool.release();
|
|
||||||
mSoundPool = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isScreenOn() {
|
|
||||||
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
|
||||||
// true为打开,false为关闭
|
|
||||||
return powerManager.isInteractive();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final String ALARMWAKEUP = "AIOS_ALARM_WAKEUP";
|
public static final String ALARMWAKEUP = "AIOS_ALARM_WAKEUP";
|
||||||
|
|
||||||
private void registerAlarmReceiver() {
|
private void registerAlarmReceiver() {
|
||||||
@@ -809,6 +821,48 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
|
|||||||
|
|
||||||
private SmsReceiver mSmsReceiver;
|
private SmsReceiver mSmsReceiver;
|
||||||
|
|
||||||
|
private static final String UPDATE_DESKTOP_SETTINGS_APP_KEY = "UPDATE_DESKTOP_SETTINGS_APP";
|
||||||
|
private static final String UPDATE_DESKTOP_SETTINGS_CLOCK_KEY = "UPDATE_DESKTOP_SETTINGS_CLCOK";
|
||||||
|
private static final String UPDATE_DESKTOP_SETTINGS_SOS_KEY = "UPDATE_DESKTOP_SETTINGS_SOS";
|
||||||
|
private static final String UPDATE_DESKTOP_SETTINGS_FLOAT_KEY = "UPDATE_DESKTOP_SETTINGS_FLOAT";
|
||||||
|
private static final String UPDATE_DESKTOP_SETTINGS_HOME_KEY = "UPDATE_DESKTOP_SETTINGS_HOME";
|
||||||
|
private static final String UPDATE_DESKTOP_SETTINGS_TIME_KEY = "UPDATE_DESKTOP_SETTINGS_TIME";
|
||||||
|
private static final String UPDATE_DESKTOP_SETTINGS_ANSWER_KEY = "UPDATE_DESKTOP_SETTINGS_ANSWER";
|
||||||
|
|
||||||
|
private UpdateSettingsReceiver mUpdateSettingsReceiver;
|
||||||
|
|
||||||
|
private void registerUpdateDesktopReceiver() {
|
||||||
|
if (mUpdateSettingsReceiver == null) {
|
||||||
|
mUpdateSettingsReceiver = new UpdateSettingsReceiver();
|
||||||
|
}
|
||||||
|
IntentFilter filter = new IntentFilter();
|
||||||
|
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||||
|
filter.addAction(UPDATE_DESKTOP_SETTINGS_APP_KEY);
|
||||||
|
filter.addAction(UPDATE_DESKTOP_SETTINGS_CLOCK_KEY);
|
||||||
|
filter.addAction(UPDATE_DESKTOP_SETTINGS_SOS_KEY);
|
||||||
|
filter.addAction(UPDATE_DESKTOP_SETTINGS_FLOAT_KEY);
|
||||||
|
filter.addAction(UPDATE_DESKTOP_SETTINGS_HOME_KEY);
|
||||||
|
filter.addAction(UPDATE_DESKTOP_SETTINGS_TIME_KEY);
|
||||||
|
filter.addAction(UPDATE_DESKTOP_SETTINGS_ANSWER_KEY);
|
||||||
|
registerReceiver(mUpdateSettingsReceiver, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
class UpdateSettingsReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
String action = intent.getAction();
|
||||||
|
Log.e(TAG, "onReceive: " + action);
|
||||||
|
if (TextUtils.isEmpty(action)) return;
|
||||||
|
switch (action) {
|
||||||
|
case UPDATE_DESKTOP_SETTINGS_CLOCK_KEY:
|
||||||
|
int alarm_clock_ctrl = intent.getIntExtra("alarm_clock_ctrl", 1);
|
||||||
|
mMMKV.encode(CommonConfig.ALARM_CLOCK_CTRL, alarm_clock_ctrl);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示弹出框
|
* 显示弹出框
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -15,17 +15,17 @@ 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.vscool.os.R;
|
import com.vscool.os.R;
|
||||||
import com.vscool.os.bean.Contact;
|
import com.vscool.os.bean.Contact;
|
||||||
import com.vscool.os.bean.ContactId;
|
import com.vscool.os.config.CommonConfig;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import io.reactivex.rxjava3.annotations.NonNull;
|
import io.reactivex.rxjava3.annotations.NonNull;
|
||||||
import io.reactivex.rxjava3.core.Observable;
|
import io.reactivex.rxjava3.core.Observable;
|
||||||
@@ -189,26 +189,31 @@ public class ContactsUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void updateContactPhone(Context context, Contact contact, Bitmap bitmap) {
|
public static void updateContactPhone(Context context, Contact contact, Bitmap bitmap) {
|
||||||
long rawContactId = ContactsUtils.getRawContactId(context, contact.getMobile());
|
String name = getContactNameFromNumber(context, contact.getMobile());
|
||||||
Log.e(TAG, "updateContactPhone: rawContactId = " + rawContactId);
|
Log.e(TAG, "updateContactPhone: " + name);
|
||||||
ContentResolver resolver = context.getContentResolver();
|
if (!Objects.equals(name, contact.getName())) {
|
||||||
|
long rawContactId = ContactsUtils.getRawContactId(context, contact.getMobile());
|
||||||
|
Log.e(TAG, "updateContactPhone: rawContactId = " + rawContactId);
|
||||||
|
updateContactNameByNumber(context, contact.getMobile(), contact.getName());
|
||||||
|
|
||||||
ContentValues values = new ContentValues();
|
ContentResolver resolver = context.getContentResolver();
|
||||||
values.put(ContactsContract.Data.RAW_CONTACT_ID, rawContactId);
|
|
||||||
values.put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE);
|
|
||||||
values.put(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, contact.getName());
|
|
||||||
resolver.insert(ContactsContract.Data.CONTENT_URI, values);
|
|
||||||
|
|
||||||
values.clear();
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(ContactsContract.Data.RAW_CONTACT_ID, rawContactId);
|
||||||
|
values.put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE);
|
||||||
|
values.put(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, contact.getName());
|
||||||
|
resolver.insert(ContactsContract.Data.CONTENT_URI, values);
|
||||||
|
|
||||||
values.put(ContactsContract.Data.RAW_CONTACT_ID, rawContactId);
|
values.clear();
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
|
|
||||||
values.put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE);
|
|
||||||
values.put(ContactsContract.CommonDataKinds.Photo.PHOTO, out.toByteArray());
|
|
||||||
resolver.insert(ContactsContract.Data.CONTENT_URI, values);
|
|
||||||
|
|
||||||
values.clear();
|
values.put(ContactsContract.Data.RAW_CONTACT_ID, rawContactId);
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
|
||||||
|
values.put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE);
|
||||||
|
values.put(ContactsContract.CommonDataKinds.Photo.PHOTO, out.toByteArray());
|
||||||
|
resolver.insert(ContactsContract.Data.CONTENT_URI, values);
|
||||||
|
|
||||||
|
values.clear();
|
||||||
|
|
||||||
// values.put(ContactsContract.Data.RAW_CONTACT_ID, rawContactId);
|
// values.put(ContactsContract.Data.RAW_CONTACT_ID, rawContactId);
|
||||||
// values.put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
|
// values.put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
|
||||||
@@ -228,7 +233,85 @@ public class ContactsUtils {
|
|||||||
// values.put(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, name);
|
// values.put(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, name);
|
||||||
// values.put(ContactsContract.CommonDataKinds.Phone.NUMBER, phone);
|
// values.put(ContactsContract.CommonDataKinds.Phone.NUMBER, phone);
|
||||||
// Log.d("updateContact", "values已经产生");
|
// Log.d("updateContact", "values已经产生");
|
||||||
// int result = resolver.update(ContactsContract.Data.CONTENT_URI, values, ContactsContract.Data.RAW_CONTACT_ID + "=?", new String[]{String.valueOf(bean.getId())});
|
|
||||||
|
// int result = resolver.update(ContactsContract.Data.CONTENT_URI, values, ContactsContract.Data.RAW_CONTACT_ID + "=?", new String[]{String.valueOf(rawContactId)});
|
||||||
|
// Log.e(TAG, "updateContactPhone: " + result);
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "updateContactPhone: same contact info");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getContactNameFromNumber(Context context, String phoneNumber) {
|
||||||
|
String contactName = null;
|
||||||
|
Uri lookupUri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
|
||||||
|
String[] projection = {ContactsContract.PhoneLookup.DISPLAY_NAME};
|
||||||
|
|
||||||
|
try (Cursor cursor = context.getContentResolver().query(lookupUri, projection, null, null, null)) {
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
contactName = cursor.getString(cursor.getColumnIndex(ContactsContract.PhoneLookup.DISPLAY_NAME));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("ContactQuery", "查询失败", e);
|
||||||
|
}
|
||||||
|
return contactName != null ? contactName : "未知号码";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void editContactPhone(Context context, long contactId, Contact contact) {
|
||||||
|
if (contactId == -1) {
|
||||||
|
saveContactPhone(context, contact);
|
||||||
|
} else {
|
||||||
|
// 2. 获取所有关联的RawContact ID
|
||||||
|
List<Long> rawContactIds = getRawContactIds(context, contactId);
|
||||||
|
if (rawContactIds.isEmpty()) {
|
||||||
|
Log.e("UpdateContact", "rawContactIds is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 构建批量操作
|
||||||
|
ArrayList<ContentProviderOperation> ops = new ArrayList<>();
|
||||||
|
for (Long rawId : rawContactIds) {
|
||||||
|
// 更新现有姓名(如果存在)
|
||||||
|
ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
|
||||||
|
.withSelection(
|
||||||
|
ContactsContract.Data.RAW_CONTACT_ID + "=? AND " +
|
||||||
|
ContactsContract.Data.MIMETYPE + "=?",
|
||||||
|
new String[]{String.valueOf(rawId), ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE}
|
||||||
|
)
|
||||||
|
.withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, contact.getName())
|
||||||
|
.build());
|
||||||
|
|
||||||
|
// 插入新姓名(如果原数据不存在)
|
||||||
|
// ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
|
||||||
|
// .withValue(ContactsContract.Data.RAW_CONTACT_ID, rawId)
|
||||||
|
// .withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)
|
||||||
|
// .withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, contact.getName())
|
||||||
|
// .withYieldAllowed(true)
|
||||||
|
// .build());
|
||||||
|
|
||||||
|
ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
|
||||||
|
.withSelection(
|
||||||
|
ContactsContract.Data.RAW_CONTACT_ID + "=? AND " +
|
||||||
|
ContactsContract.Data.MIMETYPE + "=? AND " +
|
||||||
|
ContactsContract.CommonDataKinds.Phone.TYPE + "=?",
|
||||||
|
new String[]{
|
||||||
|
String.valueOf(rawId),
|
||||||
|
ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE,
|
||||||
|
String.valueOf(ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.withValue(ContactsContract.CommonDataKinds.Phone.NUMBER, contact.getMobile())
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 执行修改
|
||||||
|
try {
|
||||||
|
context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
|
||||||
|
context.getContentResolver().notifyChange(ContactsContract.Data.CONTENT_URI, null); // 通知数据变更
|
||||||
|
Log.i("UpdateContact", "姓名已更新为: " + contact.getName());
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("UpdateContact", "修改失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateContactPhone(Context context, Contact contact) {
|
public static void updateContactPhone(Context context, Contact contact) {
|
||||||
@@ -243,6 +326,90 @@ public class ContactsUtils {
|
|||||||
resolver.insert(ContactsContract.Data.CONTENT_URI, values);
|
resolver.insert(ContactsContract.Data.CONTENT_URI, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void updateContactNameByNumber(Context context, String phoneNumber, String newName) {
|
||||||
|
// 1. 根据号码查找联系人ID
|
||||||
|
long contactId = findContactIdByPhoneNumber(context, phoneNumber);
|
||||||
|
if (contactId == -1) {
|
||||||
|
Log.e("UpdateContact", "未找到匹配的联系人");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 获取所有关联的RawContact ID
|
||||||
|
List<Long> rawContactIds = getRawContactIds(context, contactId);
|
||||||
|
if (rawContactIds.isEmpty()) {
|
||||||
|
Log.e("UpdateContact", "rawContactIds is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 构建批量操作
|
||||||
|
ArrayList<ContentProviderOperation> ops = new ArrayList<>();
|
||||||
|
for (Long rawId : rawContactIds) {
|
||||||
|
// 更新现有姓名(如果存在)
|
||||||
|
ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
|
||||||
|
.withSelection(
|
||||||
|
ContactsContract.Data.RAW_CONTACT_ID + "=? AND " +
|
||||||
|
ContactsContract.Data.MIMETYPE + "=?",
|
||||||
|
new String[]{String.valueOf(rawId), ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE}
|
||||||
|
)
|
||||||
|
.withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, newName)
|
||||||
|
.build());
|
||||||
|
|
||||||
|
// 插入新姓名(如果原数据不存在)
|
||||||
|
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
|
||||||
|
.withValue(ContactsContract.Data.RAW_CONTACT_ID, rawId)
|
||||||
|
.withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)
|
||||||
|
.withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, newName)
|
||||||
|
.withYieldAllowed(true)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 执行修改
|
||||||
|
try {
|
||||||
|
context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
|
||||||
|
context.getContentResolver().notifyChange(ContactsContract.Data.CONTENT_URI, null); // 通知数据变更
|
||||||
|
Log.i("UpdateContact", "姓名已更新为: " + newName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("UpdateContact", "修改失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据号码查询联系人ID
|
||||||
|
public static long findContactIdByPhoneNumber(Context context, String phoneNumber) {
|
||||||
|
Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
|
||||||
|
Cursor cursor = context.getContentResolver().query(
|
||||||
|
uri,
|
||||||
|
new String[]{ContactsContract.PhoneLookup._ID},
|
||||||
|
null, null, null
|
||||||
|
);
|
||||||
|
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
long contactId = cursor.getLong(0);
|
||||||
|
cursor.close();
|
||||||
|
return contactId;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取联系人所有RawContact ID
|
||||||
|
private static List<Long> getRawContactIds(Context context, long contactId) {
|
||||||
|
List<Long> rawIds = new ArrayList<>();
|
||||||
|
Cursor cursor = context.getContentResolver().query(
|
||||||
|
ContactsContract.RawContacts.CONTENT_URI,
|
||||||
|
new String[]{ContactsContract.RawContacts._ID},
|
||||||
|
ContactsContract.RawContacts.CONTACT_ID + "=?",
|
||||||
|
new String[]{String.valueOf(contactId)},
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
if (cursor != null) {
|
||||||
|
while (cursor.moveToNext()) {
|
||||||
|
rawIds.add(cursor.getLong(0));
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
return rawIds;
|
||||||
|
}
|
||||||
|
|
||||||
public static void update(Context context, Contact contact, Bitmap bitmap) {
|
public static void update(Context context, Contact contact, Bitmap bitmap) {
|
||||||
long rawContactId = ContactsUtils.getRawContactId(context, contact.getMobile());
|
long rawContactId = ContactsUtils.getRawContactId(context, contact.getMobile());
|
||||||
|
|
||||||
@@ -393,6 +560,32 @@ public class ContactsUtils {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getRawContactName(Context context, String phoneNum) {
|
||||||
|
ContentResolver resolver = context.getContentResolver();
|
||||||
|
Cursor cursor = null;
|
||||||
|
try {
|
||||||
|
cursor = resolver.query(ContactsContract.Data.CONTENT_URI,
|
||||||
|
new String[]{ContactsContract.Data.RAW_CONTACT_ID, ContactsContract.CommonDataKinds.Phone.NUMBER,
|
||||||
|
ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME},
|
||||||
|
ContactsContract.CommonDataKinds.Phone.NUMBER + "=?", new String[]{phoneNum}, null);
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
String displayName = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME));
|
||||||
|
Log.e(TAG, "getRawContactName: displayName = " + displayName);
|
||||||
|
String name = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME));
|
||||||
|
Log.e(TAG, "getRawContactName: rawName = " + name);
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Log.e(TAG, "getRawContactName: " + e.getMessage());
|
||||||
|
} finally {
|
||||||
|
if (cursor != null) {
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加联系人信息
|
* 添加联系人信息
|
||||||
*/
|
*/
|
||||||
@@ -557,32 +750,6 @@ public class ContactsUtils {
|
|||||||
// cursor.close();
|
// cursor.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ContactId> getLocalContacts(Context context) {
|
|
||||||
ContentResolver resolver = context.getContentResolver();
|
|
||||||
Uri uri = ContactsContract.Contacts.CONTENT_URI;
|
|
||||||
Cursor cursor = resolver.query(uri, null, null, null, null);
|
|
||||||
List<ContactId> contactIds = new ArrayList<>();
|
|
||||||
while (cursor.moveToNext()) {
|
|
||||||
long id = cursor.getLong(cursor.getColumnIndexOrThrow("name_raw_contact_id"));
|
|
||||||
int in_phone = cursor.getInt(cursor.getColumnIndexOrThrow("indicate_phone_or_sim_contact"));
|
|
||||||
String display_name = cursor.getString(cursor.getColumnIndexOrThrow("display_name"));
|
|
||||||
String photo_uri = cursor.getString(cursor.getColumnIndexOrThrow("photo_uri"));
|
|
||||||
|
|
||||||
ContactId contactId = new ContactId(id, in_phone, display_name, photo_uri);
|
|
||||||
contactIds.add(contactId);
|
|
||||||
}
|
|
||||||
cursor.close();
|
|
||||||
List<ContactId> filter = contactIds.stream().filter(new Predicate<ContactId>() {
|
|
||||||
@Override
|
|
||||||
public boolean test(ContactId contactId) {
|
|
||||||
return contactId.getInPhone() == -1;
|
|
||||||
}
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
Log.e(TAG, "getLocalContacts: " + filter);
|
|
||||||
return filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断某个手机号是否存在
|
* 判断某个手机号是否存在
|
||||||
*/
|
*/
|
||||||
@@ -639,5 +806,33 @@ 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package com.vscool.os.utils;
|
||||||
|
|
||||||
|
import android.app.AppOpsManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Binder;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
public class FloatingWindowUtils {
|
||||||
|
|
||||||
|
private static final String TAG = "FloatingWindowUtils";
|
||||||
|
|
||||||
|
public static boolean checkIsHuaweiRom() {
|
||||||
|
Log.e(TAG, "checkIsHuaweiRom: " + Build.MANUFACTURER);
|
||||||
|
return Build.MANUFACTURER.contains("HUAWEI") || Build.MANUFACTURER.contains("HONOR");
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 检查悬浮窗开启权限
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean checkFloatPermission(Context context) {
|
||||||
|
//华为和荣耀最后返回的数据有问题
|
||||||
|
if (checkIsHuaweiRom()) {
|
||||||
|
return Settings.canDrawOverlays(context);
|
||||||
|
}
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
|
||||||
|
return true;
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||||
|
try {
|
||||||
|
Class cls = Class.forName("android.content.Context");
|
||||||
|
Field declaredField = cls.getDeclaredField("APP_OPS_SERVICE");
|
||||||
|
declaredField.setAccessible(true);
|
||||||
|
Object obj = declaredField.get(cls);
|
||||||
|
if (!(obj instanceof String)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String str2 = (String) obj;
|
||||||
|
obj = cls.getMethod("getSystemService", String.class).invoke(context, str2);
|
||||||
|
cls = Class.forName("android.app.AppOpsManager");
|
||||||
|
Field declaredField2 = cls.getDeclaredField("MODE_ALLOWED");
|
||||||
|
declaredField2.setAccessible(true);
|
||||||
|
Method checkOp = cls.getMethod("checkOp", Integer.TYPE, Integer.TYPE, String.class);
|
||||||
|
int result = (Integer) checkOp.invoke(obj, 24, Binder.getCallingUid(), context.getPackageName());
|
||||||
|
return result == declaredField2.getInt(cls);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
AppOpsManager appOpsMgr = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
||||||
|
if (appOpsMgr == null)
|
||||||
|
return false;
|
||||||
|
int mode = appOpsMgr.checkOpNoThrow("android:system_alert_window", android.os.Process.myUid(), context
|
||||||
|
.getPackageName());
|
||||||
|
return Settings.canDrawOverlays(context) || mode == AppOpsManager.MODE_ALLOWED || mode == AppOpsManager.MODE_IGNORED;
|
||||||
|
} else {
|
||||||
|
return Settings.canDrawOverlays(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="设置闹钟"
|
android:text="编辑闹钟"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
@@ -411,7 +411,7 @@
|
|||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:onClick="@{click::submit}"
|
android:onClick="@{click::submit}"
|
||||||
android:text="添加闹钟"
|
android:text="编辑闹钟"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
android:background="#FAF8F8">
|
android:background="#FAF8F8">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/constraintLayout3"
|
android:id="@+id/cl_exit"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="64dp"
|
android:layout_height="64dp"
|
||||||
android:background="@drawable/general_setting_bg"
|
android:background="@drawable/general_setting_bg"
|
||||||
@@ -73,8 +73,8 @@
|
|||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toTopOf="@+id/cl_bottom"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/constraintLayout3">
|
app:layout_constraintTop_toBottomOf="@+id/cl_exit">
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -349,5 +349,11 @@
|
|||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/cl_bottom"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:text="主页按钮"
|
android:text="悬浮主页"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
@@ -144,7 +144,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:text="语音播报"
|
android:text="来电和短信播报"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
@@ -177,7 +177,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:text="自动接听"
|
android:text="微信自动接听"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
|||||||
87
app/src/main/res/layout/dialog_permissions.xml
Normal file
87
app/src/main/res/layout/dialog_permissions.xml
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/bg_dialog"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="权限申请说明"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="32dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:layout_marginBottom="32dp"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/linearLayout5"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/tv_title">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="18sp"
|
||||||
|
tools:text="内容文本" />
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/linearLayout5"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_cancel"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="拒绝"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="19sp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/tv_content" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_confirm"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="同意"
|
||||||
|
android:textColor="@color/default_blue"
|
||||||
|
android:textSize="19sp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="@+id/tv_content"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/tv_content" />
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
<color name="lightGray">#FFD3D3D3</color>
|
<color name="lightGray">#FFD3D3D3</color>
|
||||||
<color name="tv_add_color">#4880ff</color>
|
<color name="tv_add_color">#4880ff</color>
|
||||||
<color name="yellow">#F8B551</color>
|
<color name="yellow">#F8B551</color>
|
||||||
|
<color name="default_blue">#0166ff</color>
|
||||||
<color name="settings_color">#4D3AD8</color>
|
<color name="settings_color">#4D3AD8</color>
|
||||||
<color name="settings_color_bg">#221C27</color>
|
<color name="settings_color_bg">#221C27</color>
|
||||||
<color name="radio_botton_gray">#bbbbbb</color>
|
<color name="radio_botton_gray">#bbbbbb</color>
|
||||||
|
|||||||
Reference in New Issue
Block a user