version:1.3
fix: update:sos界面拨打所有电话
This commit is contained in:
@@ -2,6 +2,7 @@ package com.uiui.os.fragment;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
@@ -41,10 +42,14 @@ import com.qweather.sdk.view.QWeather;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiui.os.BuildConfig;
|
||||
import com.uiui.os.R;
|
||||
import com.uiui.os.activity.EmergencyActivity;
|
||||
import com.uiui.os.adapter.AlarmClockAdapter;
|
||||
import com.uiui.os.adapter.NotificationAdapter;
|
||||
import com.uiui.os.adapter.SOSNnmberAdapter;
|
||||
import com.uiui.os.bean.AlarmClockData;
|
||||
import com.uiui.os.bean.AlarmItem;
|
||||
import com.uiui.os.bean.BaseResponse;
|
||||
import com.uiui.os.network.NetInterfaceManager;
|
||||
import com.uiui.os.utils.AmapManager;
|
||||
import com.uiui.os.utils.APKUtils;
|
||||
import com.uiui.os.utils.AppUtil;
|
||||
@@ -52,10 +57,15 @@ import com.uiui.os.utils.Utils;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
|
||||
/**
|
||||
@@ -88,6 +98,15 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
TextView wifi_ssid;
|
||||
@BindView(R.id.cl_wifi)
|
||||
ConstraintLayout cl_wifi;
|
||||
@BindView(R.id.iv_sos)
|
||||
ImageView iv_sos;
|
||||
@BindView(R.id.rv_sos)
|
||||
RecyclerView rv_sos;
|
||||
@BindView(R.id.cl_sos)
|
||||
ConstraintLayout cl_soso;
|
||||
@BindView(R.id.iv_note_nodata)
|
||||
ImageView iv_note_nodata;
|
||||
|
||||
|
||||
private String TAG = CustomFragment.class.getSimpleName();
|
||||
private int[] mShaderColors = new int[]{0xFFfa3db5, 0xFFF8867E, 0xFFF79F6B, 0xFFF79F6B, 0xFFF79F6B, 0xFFF8867E, 0xFFfa3db5};
|
||||
@@ -95,7 +114,10 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
private List<AlarmItem> alarmItemList;
|
||||
private NotificationAdapter notificationAdapter;
|
||||
private AlarmClockAdapter alarmClockAdapter;
|
||||
private SOSNnmberAdapter sosNnmberAdapter;
|
||||
private MMKV mmkv;
|
||||
private Context context;
|
||||
private ContentResolver mCRv;
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
@@ -227,11 +249,11 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
int status = intent.getIntExtra("status", BatteryManager.BATTERY_STATUS_UNKNOWN);
|
||||
if (status == BatteryManager.BATTERY_STATUS_CHARGING) {
|
||||
if (rootView != null) {
|
||||
iv_charging.setVisibility(View.VISIBLE);
|
||||
// iv_charging.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
if (rootView != null) {
|
||||
iv_charging.setVisibility(View.GONE);
|
||||
// iv_charging.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,6 +265,8 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
rootView = inflater.inflate(R.layout.fragment_custom, container, false);
|
||||
context = rootView.getContext();
|
||||
mCRv = context.getContentResolver();
|
||||
ButterKnife.bind(this, rootView);
|
||||
initView();
|
||||
initData();
|
||||
@@ -281,10 +305,42 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
alarmClockAdapter = new AlarmClockAdapter();
|
||||
rv_clock.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
rv_clock.setAdapter(alarmClockAdapter);
|
||||
sosNnmberAdapter = new SOSNnmberAdapter();
|
||||
rv_sos.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
rv_sos.setAdapter(sosNnmberAdapter);
|
||||
cl_soso.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), EmergencyActivity.class);
|
||||
// intent.putExtra("setting_sos", phone);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getActivity().startActivity(intent);
|
||||
}
|
||||
});
|
||||
setAlarm();
|
||||
refreshMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
setAlarm();
|
||||
setSosNumber();
|
||||
}
|
||||
|
||||
public void setSosNumber() {
|
||||
String setting_sos = Settings.System.getString(mCRv, "setting_sos");
|
||||
if (TextUtils.isEmpty(setting_sos)) {
|
||||
// rv_sos.setVisibility(View.GONE);
|
||||
// iv_sos.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
// rv_sos.setVisibility(View.VISIBLE);
|
||||
// iv_sos.setVisibility(View.GONE);
|
||||
List<String> phoneList = new ArrayList<>(Arrays.asList(setting_sos.split(",")));
|
||||
sosNnmberAdapter.setPhoneNumberList(phoneList);
|
||||
}
|
||||
}
|
||||
|
||||
private void setAlarm() {
|
||||
if (rootView == null) return;
|
||||
if (alarmItemList == null) {
|
||||
@@ -328,7 +384,13 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
}.getType();
|
||||
Gson gson = new Gson();
|
||||
List<AlarmClockData> data = gson.fromJson(jsonString, type);
|
||||
List<AlarmClockData> showData = data.subList(0, 1);
|
||||
notificationAdapter.setDataList(data);
|
||||
recyclerView.setVisibility(View.VISIBLE);
|
||||
iv_note_nodata.setVisibility(View.GONE);
|
||||
} else {
|
||||
recyclerView.setVisibility(View.GONE);
|
||||
iv_note_nodata.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,7 +431,7 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
|
||||
|
||||
private void killBackgroundApp() {
|
||||
List<String> pkgList = APKUtils.queryFilterAppList(getActivity());
|
||||
List<String> pkgList = APKUtils.queryFilterAppList(context);
|
||||
for (String pkg : pkgList) {
|
||||
if (pkg.equalsIgnoreCase(BuildConfig.APPLICATION_ID)) continue;
|
||||
killBackgroundProcesses(pkg);
|
||||
@@ -380,7 +442,7 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
ActivityManager activityManager;
|
||||
try {
|
||||
activityManager = (ActivityManager)
|
||||
getActivity().getSystemService(Context.ACTIVITY_SERVICE);
|
||||
context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
activityManager.killBackgroundProcesses(packageName);
|
||||
Method forceStopPackage = activityManager.getClass()
|
||||
.getDeclaredMethod("forceStopPackage", String.class);
|
||||
@@ -395,8 +457,8 @@ public class CustomFragment extends Fragment implements NetworkUtils.OnNetworkSt
|
||||
}
|
||||
|
||||
private void refreshMemory() {
|
||||
long avail = AppUtil.getAvailMemory(getActivity());
|
||||
long total = AppUtil.getTotalMemory(getActivity());
|
||||
long avail = AppUtil.getAvailMemory(context);
|
||||
long total = AppUtil.getTotalMemory(context);
|
||||
int x = (int) (((total - avail) / (double) total) * 100);
|
||||
cpv.setProgressColor(mShaderColors);
|
||||
cpv.showAnimation(0, x, 1000);
|
||||
|
||||
Reference in New Issue
Block a user