version:7.1
fix: update:更新圆角,修复修改字体大小报错
This commit is contained in:
@@ -22,7 +22,10 @@ import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class QuickAppActivity extends BaseActivity {
|
||||
public static final String QUICK_APP_KEY = "QuickAppKey";
|
||||
public static final String QUICK_APP_KEY = "QuickAppPackageKey";
|
||||
public static final String QUICK_APP_REFRESH_KEY = "QuickAppRefreshKey";
|
||||
public static final String QUICK_APP_ENABLED_KEY = "QuickAppEnabledKey";
|
||||
|
||||
private AppSelectedAdapter mAppSelectedAdapter;
|
||||
|
||||
@BindView(R.id.recyclerView)
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.view.WindowManager;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.alarmclock.uiui.IAlarmAidlInterface;
|
||||
@@ -68,14 +67,17 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
@BindView(R.id.magicIndicator)
|
||||
MagicIndicator mMagicIndicator;
|
||||
|
||||
private FragmentManager mFragmentManager;
|
||||
private FragmentTransaction mFragmentTransaction;
|
||||
private ScaleCircleNavigator scaleCircleNavigator;
|
||||
|
||||
private FragmentManager mFragmentManager;
|
||||
// private FragmentTransaction mFragmentTransaction;
|
||||
private BaseFragmentPagerAdapter mBaseFragmentPagerAdapter;
|
||||
|
||||
private List<Fragment> mFragments;
|
||||
private ControlFragment mControlFragment;
|
||||
private CustomFragment mCustomFragment;
|
||||
private SecondFragment mSecondFragment;
|
||||
|
||||
private boolean is_twoscreen = false;
|
||||
private int appListIndex = 2;
|
||||
private int defaultCurrent = 1;
|
||||
@@ -97,7 +99,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
mMainPresenter.attachView(this);
|
||||
mMainPresenter.setLifecycle(lifecycleSubject);
|
||||
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.e(TAG, "initView: " + this.getClass().getName());
|
||||
// SystemClock.setCurrentTimeMillis(1662123600000L);//09-02
|
||||
@@ -105,7 +106,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
}
|
||||
|
||||
mFragmentManager = getSupportFragmentManager();
|
||||
mFragmentTransaction = mFragmentManager.beginTransaction();
|
||||
// mFragmentTransaction = mFragmentManager.beginTransaction();
|
||||
mFragments = new ArrayList<>();
|
||||
mBaseFragmentPagerAdapter = new BaseFragmentPagerAdapter(mFragmentManager, mFragments);
|
||||
// fragmentTransaction.add(R.id.viewPager, appListFragment);
|
||||
@@ -123,6 +124,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
mFragments.add(mCustomFragment);
|
||||
mMainPresenter.getSystemSettings();
|
||||
ArrayList<DesktopIcon> desktopIcons = ApkUtils.queryFilterAppInfo(this);
|
||||
|
||||
int x = 0;
|
||||
for (int i = 0; i <= desktopIcons.size(); i++) {
|
||||
if (i != 0 && i % APP_LIST_SIZE == 0) {
|
||||
@@ -290,7 +292,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
mBaseFragmentPagerAdapter.notifyItemChanged();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
@@ -531,13 +532,15 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
registerReceiver(sosNumberReceiver, filter);
|
||||
}
|
||||
|
||||
class SOSNumberReceiver extends BroadcastReceiver {
|
||||
static class SOSNumberReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.e(TAG, "onReceive: " + intent.getAction());
|
||||
String setting_sos = intent.getStringExtra("setting_sos");
|
||||
if (TextUtils.isEmpty(setting_sos)) return;
|
||||
mCustomFragment.setSosNumber();
|
||||
if (TextUtils.isEmpty(setting_sos)) {
|
||||
return;
|
||||
}
|
||||
// mCustomFragment.setSosNumber();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.uiui.aios.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -24,7 +25,6 @@ public class AppSelectedAdapter extends RecyclerView.Adapter<AppSelectedAdapter.
|
||||
private List<AppSelectBean> mAppSelectBeans;
|
||||
private int unselectedStatus = -1;
|
||||
private int selecedPosition = unselectedStatus;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
|
||||
public void setAppSelectBeans(List<AppSelectBean> appSelectBeanList) {
|
||||
this.mAppSelectBeans = appSelectBeanList;
|
||||
@@ -54,13 +54,13 @@ public class AppSelectedAdapter extends RecyclerView.Adapter<AppSelectedAdapter.
|
||||
if (position != selecedPosition) {
|
||||
holder.iv_select.setImageDrawable(mContext.getDrawable(R.drawable.icon_selected));
|
||||
selecedPosition = position;
|
||||
mMMKV.encode(QuickAppActivity.QUICK_APP_KEY, appSelectBean.getPackageName());
|
||||
Settings.Global.putString(mContext.getContentResolver(), QuickAppActivity.QUICK_APP_KEY, appSelectBean.getPackageName());
|
||||
Log.e(TAG, "setQuickApp: " + appSelectBean.getPackageName());
|
||||
|
||||
} else {
|
||||
holder.iv_select.setImageDrawable(mContext.getDrawable(R.drawable.icon_unselected));
|
||||
selecedPosition = -1;
|
||||
mMMKV.encode(QuickAppActivity.QUICK_APP_KEY, "");
|
||||
Settings.Global.putString(mContext.getContentResolver(),QuickAppActivity.QUICK_APP_KEY, "");
|
||||
Log.e(TAG, "setQuickApp: empty");
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.uiui.aios.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
@@ -21,6 +22,7 @@ import com.google.gson.JsonObject;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.activity.code.HealthCodeActivity;
|
||||
import com.uiui.aios.base.BaseFragment;
|
||||
import com.uiui.aios.bean.BaseResponse;
|
||||
import com.uiui.aios.bean.DesktopIcon;
|
||||
@@ -113,7 +115,7 @@ public class AppListFragment extends BaseFragment {
|
||||
mDesktopIcons.addAll(new ArrayList<>(Arrays.asList(new DesktopIcon[12 - mDesktopIcons.size()])));
|
||||
}
|
||||
gridLayout = rootView.findViewById(R.id.list);
|
||||
if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (mContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
gridLayout.set(4, 3);
|
||||
} else {
|
||||
gridLayout.set(3, 4);
|
||||
@@ -123,8 +125,7 @@ public class AppListFragment extends BaseFragment {
|
||||
@Override
|
||||
public View getView(int index) {
|
||||
PackageManager pm = rootView.getContext().getPackageManager();
|
||||
View view = getLayoutInflater().inflate(R.layout.item_actions,
|
||||
null);
|
||||
View view = getLayoutInflater().inflate(R.layout.item_actions, null);
|
||||
ImageView iv = view.findViewById(R.id.iv);
|
||||
TextView tv = view.findViewById(R.id.tv);
|
||||
TextView bg = view.findViewById(R.id.bg);
|
||||
@@ -136,7 +137,7 @@ public class AppListFragment extends BaseFragment {
|
||||
int i = IconUtils.appClassNameList.indexOf(pkg);
|
||||
if (i != -1) {
|
||||
String val = IconUtils.appIconList.get(i);
|
||||
int resID = getActivity().getResources().getIdentifier(val, "drawable", "com.uiui.aios");
|
||||
int resID = mContext.getResources().getIdentifier(val, "drawable", "com.uiui.aios");
|
||||
int size = NotificationService.getNotificationLength(pkg);
|
||||
if (size == 0) {
|
||||
bg.setVisibility(View.GONE);
|
||||
@@ -151,7 +152,7 @@ public class AppListFragment extends BaseFragment {
|
||||
Log.e(TAG, "getView: not found src : " + pkg);
|
||||
iv.setImageDrawable(desktopIcon.getIcon());
|
||||
} else {
|
||||
iv.setImageDrawable(getActivity().getResources().getDrawable(resID));
|
||||
iv.setImageDrawable(mContext.getResources().getDrawable(resID));
|
||||
}
|
||||
} else {
|
||||
iv.setImageBitmap(BitmapUtils.getIconBitmap(rootView.getContext(), desktopIcon.getIcon()));
|
||||
@@ -187,6 +188,9 @@ public class AppListFragment extends BaseFragment {
|
||||
showPassword();
|
||||
}
|
||||
break;
|
||||
case "aios.family":
|
||||
startActivity(new Intent(mContext, HealthCodeActivity.class));
|
||||
break;
|
||||
case "com.android.dialer":
|
||||
int qch_call_forbid = Settings.System.getInt(mContext.getContentResolver(), "qch_call_forbid", 0);
|
||||
if (qch_call_forbid == 1) {
|
||||
@@ -196,14 +200,14 @@ public class AppListFragment extends BaseFragment {
|
||||
ApkUtils.openPackage(v.getContext(), desktopIcon.getPackageName(), desktopIcon.getClassName());
|
||||
AppUsedTimeUtils.getInstance().setAppPackageName(desktopIcon.getPackageName());
|
||||
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||
SendRunningApp(getActivity());
|
||||
SendRunningApp(mContext);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ApkUtils.openPackage(v.getContext(), desktopIcon.getPackageName(), desktopIcon.getClassName());
|
||||
AppUsedTimeUtils.getInstance().setAppPackageName(desktopIcon.getPackageName());
|
||||
AppUsedTimeUtils.getInstance().setStartTime(System.currentTimeMillis());
|
||||
SendRunningApp(getActivity());
|
||||
SendRunningApp(mContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.hardware.camera2.CameraAccessException;
|
||||
import android.hardware.camera2.CameraCharacteristics;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
@@ -28,6 +29,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
@@ -35,6 +37,7 @@ import com.baidu.location.BDAbstractLocationListener;
|
||||
import com.baidu.location.BDLocation;
|
||||
import com.baidu.location.LocationClient;
|
||||
import com.uiui.aios.R;
|
||||
import com.uiui.aios.disklrucache.CacheHelper;
|
||||
import com.uiui.aios.manager.AmapManager;
|
||||
import com.uiui.aios.utils.BrightnessUtils;
|
||||
import com.uiui.aios.view.RulerSeekBar;
|
||||
@@ -112,7 +115,7 @@ public class ControlFragment extends Fragment {
|
||||
private View rootView;
|
||||
private Context mContext;
|
||||
private ContentResolver mCRv;
|
||||
|
||||
private CacheHelper mCacheHelper;
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
@@ -154,6 +157,11 @@ public class ControlFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
@@ -161,6 +169,7 @@ public class ControlFragment extends Fragment {
|
||||
rootView = inflater.inflate(R.layout.fragment_control, container, false);
|
||||
mContext = rootView.getContext();
|
||||
mCRv = mContext.getContentResolver();
|
||||
mCacheHelper = new CacheHelper(mContext);
|
||||
ButterKnife.bind(this, rootView);
|
||||
initView();
|
||||
initData();
|
||||
@@ -171,7 +180,7 @@ public class ControlFragment extends Fragment {
|
||||
tv_wifi_ssid.requestFocus();
|
||||
|
||||
getWifi();
|
||||
registerReceivers();
|
||||
registerWiFiReceiver();
|
||||
getBluetooth();
|
||||
registerBluetoothReceiver();
|
||||
getBattery();
|
||||
@@ -217,10 +226,6 @@ public class ControlFragment extends Fragment {
|
||||
|
||||
private WifiReceiver mWifiReceiver;
|
||||
|
||||
private void registerReceivers() {
|
||||
registerWiFiReceiver();
|
||||
}
|
||||
|
||||
private void registerWiFiReceiver() {
|
||||
if (mWifiReceiver == null) {
|
||||
mWifiReceiver = new WifiReceiver();
|
||||
@@ -238,7 +243,7 @@ public class ControlFragment extends Fragment {
|
||||
mContext.registerReceiver(mWifiReceiver, filter);
|
||||
}
|
||||
|
||||
public class WifiReceiver extends BroadcastReceiver {
|
||||
class WifiReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "wifiReceiver";
|
||||
|
||||
@Override
|
||||
@@ -279,6 +284,12 @@ public class ControlFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
setBrightness();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前连接WIFI的SSID
|
||||
*/
|
||||
@@ -452,7 +463,7 @@ public class ControlFragment extends Fragment {
|
||||
mContext.registerReceiver(this.bleListenerReceiver, intentFilter);
|
||||
}
|
||||
|
||||
public class BluetoothMonitorReceiver extends BroadcastReceiver {
|
||||
class BluetoothMonitorReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
@@ -556,7 +567,7 @@ public class ControlFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
public class BatteryReceiver extends BroadcastReceiver {
|
||||
class BatteryReceiver extends BroadcastReceiver {
|
||||
public static final String TAG = "BatteryReceiver";
|
||||
|
||||
@Override
|
||||
@@ -564,7 +575,7 @@ public class ControlFragment extends Fragment {
|
||||
// 获取广播事件
|
||||
String action = intent.getAction();
|
||||
if (TextUtils.isEmpty(action)) return;
|
||||
Log.e(TAG, "onReceive: " + action);
|
||||
// Log.e(TAG, "onReceive: " + action);
|
||||
switch (action) {
|
||||
case Intent.ACTION_POWER_CONNECTED:
|
||||
cl_battery.setBackground(mContext.getDrawable(R.drawable.control_background_item));
|
||||
@@ -705,10 +716,10 @@ public class ControlFragment extends Fragment {
|
||||
String font_size;
|
||||
int index = Arrays.binarySearch(mValues, fontScale);
|
||||
Log.e(TAG, "getFontSize: index: " + index);
|
||||
if (index == -1) {
|
||||
font_size = "默认";
|
||||
} else {
|
||||
if (index >= 0) {
|
||||
font_size = mEntries.get(index);
|
||||
} else {
|
||||
font_size = "默认";
|
||||
}
|
||||
// tv_font_size.setText(font_size);
|
||||
seekBar.setProgress(index);
|
||||
@@ -740,17 +751,11 @@ public class ControlFragment extends Fragment {
|
||||
private LocationClient locationClient;
|
||||
|
||||
private void getLocation() {
|
||||
BDLocation bdLocation = AmapManager.getInstance().getNowMapLocation();
|
||||
if (bdLocation != null) {
|
||||
if (bdLocation.getLocType() == BDLocation.TypeGpsLocation // GPS定位结果
|
||||
|| bdLocation.getLocType() == BDLocation.TypeNetWorkLocation // 网络定位结果
|
||||
|| bdLocation.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果
|
||||
tv_location.setText(bdLocation.getAddrStr());
|
||||
} else {
|
||||
tv_location.setText("未知");
|
||||
}
|
||||
String addr = mCacheHelper.getAsString(AmapManager.ADDRESS_KEY);
|
||||
if (TextUtils.isEmpty(addr)) {
|
||||
tv_location.setText("未知");
|
||||
} else {
|
||||
tv_location.setText("定位失败");
|
||||
tv_location.setText(addr);
|
||||
}
|
||||
startLocation();
|
||||
cl_location.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -786,25 +791,19 @@ public class ControlFragment extends Fragment {
|
||||
|
||||
private void getBrightness() {
|
||||
seekbar_brightness.setMax(255);
|
||||
//亮度
|
||||
int brightness = Settings.System.getInt(mCRv, Settings.System.SCREEN_BRIGHTNESS, 1);
|
||||
seekbar_brightness.setProgress(brightness);
|
||||
Log.e(TAG, "getBrightness: brightness = " + brightness);
|
||||
int gamma = BrightnessUtils.convertLinearToGamma(brightness, 1, 255);
|
||||
Log.e(TAG, "getBrightness: gamma = " + gamma);
|
||||
long percentage = Math.round((((double) gamma / 65535) * 100f));
|
||||
tv_brightness.setText(percentage + "%");
|
||||
Log.e(TAG, "getBrightness: percentage = " + percentage);
|
||||
setBrightness();
|
||||
seekbar_brightness.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
|
||||
Log.e(TAG, "onProgressChanged: i = " + i);
|
||||
Settings.System.putInt(mCRv, Settings.System.SCREEN_BRIGHTNESS, i);
|
||||
int gamma = BrightnessUtils.convertLinearToGamma(i, 1, 255);
|
||||
int gamma = BrightnessUtils.convertLinearToGamma(i, 0, 255);
|
||||
Log.e(TAG, "onProgressChanged: gamma = " + gamma);
|
||||
int linear = BrightnessUtils.convertGammaToLinear(gamma, 0, 255);
|
||||
Log.e(TAG, "onProgressChanged: linear = " + linear);
|
||||
long percentage = Math.round((((double) gamma / 65535) * 100f));
|
||||
Log.e(TAG, "onProgressChanged: percentage = " + percentage);
|
||||
tv_brightness.setText(percentage + "%");
|
||||
// tv_brightness.setText(percentage + "%");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -819,6 +818,18 @@ public class ControlFragment extends Fragment {
|
||||
});
|
||||
}
|
||||
|
||||
private void setBrightness() {
|
||||
//亮度
|
||||
int brightness = Settings.System.getInt(mCRv, Settings.System.SCREEN_BRIGHTNESS, 0);
|
||||
seekbar_brightness.setProgress(brightness);
|
||||
Log.e(TAG, "getBrightness: brightness = " + brightness);
|
||||
int gamma = BrightnessUtils.convertLinearToGamma(brightness, 0, 255);
|
||||
Log.e(TAG, "getBrightness: gamma = " + gamma);
|
||||
long percentage = Math.round((((double) gamma / 65535) * 100f));
|
||||
// tv_brightness.setText(percentage + "%");
|
||||
Log.e(TAG, "getBrightness: percentage = " + percentage);
|
||||
}
|
||||
|
||||
private AudioManager mAudioManager;
|
||||
|
||||
private void getSound() {
|
||||
|
||||
@@ -1,227 +0,0 @@
|
||||
package com.uiui.aios.fragment;
|
||||
|
||||
import android.util.SparseArray;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 加载显示Fragment的ViewPagerAdapter基类
|
||||
* 提供可以刷新的方法
|
||||
*
|
||||
* @author Fly
|
||||
* @e-mail 1285760616@qq.com
|
||||
* @time 2018/3/22
|
||||
*/
|
||||
public class ViewPager2Adapter extends FragmentStateAdapter {
|
||||
private List<Fragment> mFragmentList;
|
||||
private FragmentManager mFragmentManager;
|
||||
/**
|
||||
* 下面两个值用来保存Fragment的位置信息,用以判断该位置是否需要更新
|
||||
*/
|
||||
private SparseArray<String> mFragmentPositionMap;
|
||||
private SparseArray<String> mFragmentPositionMapAfterUpdate;
|
||||
|
||||
public ViewPager2Adapter(FragmentManager fm, List<Fragment> fragments, Lifecycle lifecycle) {
|
||||
super(fm, lifecycle);
|
||||
mFragmentList = fragments;
|
||||
mFragmentManager = fm;
|
||||
mFragmentList = fragments;
|
||||
mFragmentPositionMap = new SparseArray<>();
|
||||
mFragmentPositionMapAfterUpdate = new SparseArray<>();
|
||||
setFragmentPositionMap();
|
||||
setFragmentPositionMapForUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新之前的位置信息,用<hashCode, position>的键值对结构来保存
|
||||
*/
|
||||
private void setFragmentPositionMap() {
|
||||
mFragmentPositionMap.clear();
|
||||
for (int i = 0; i < mFragmentList.size(); i++) {
|
||||
mFragmentPositionMap.put(Long.valueOf(getItemId(i)).intValue(), String.valueOf(i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新之后的位置信息,用<hashCode, position>的键值对结构来保存
|
||||
*/
|
||||
private void setFragmentPositionMapForUpdate() {
|
||||
mFragmentPositionMapAfterUpdate.clear();
|
||||
for (int i = 0; i < mFragmentList.size(); i++) {
|
||||
mFragmentPositionMapAfterUpdate.put(Long.valueOf(getItemId(i)).intValue(), String.valueOf(i));
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 在此方法中找到需要更新的位置返回POSITION_NONE,否则返回POSITION_UNCHANGED即可
|
||||
// */
|
||||
// @Override
|
||||
// public int getItemPosition(Object object) {
|
||||
// int hashCode = object.hashCode();
|
||||
// //查找object在更新后的列表中的位置
|
||||
// String position = mFragmentPositionMapAfterUpdate.get(hashCode);
|
||||
// //更新后的列表中不存在该object的位置了
|
||||
// if (position == null) {
|
||||
// return POSITION_NONE;
|
||||
// } else {
|
||||
// //如果更新后的列表中存在该object的位置, 查找该object之前的位置并判断位置是否发生了变化
|
||||
// int size = mFragmentPositionMap.size();
|
||||
// for (int i = 0; i < size ; i++) {
|
||||
// int key = mFragmentPositionMap.keyAt(i);
|
||||
// if (key == hashCode) {
|
||||
// String index = mFragmentPositionMap.get(key);
|
||||
// if (position.equals(index)) {
|
||||
// //位置没变依然返回POSITION_UNCHANGED
|
||||
// return POSITION_UNCHANGED;
|
||||
// } else {
|
||||
// //位置变了
|
||||
// return POSITION_NONE;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return POSITION_UNCHANGED;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 将指定的Fragment替换/更新为新的Fragment
|
||||
*
|
||||
* @param oldFragment 旧Fragment
|
||||
* @param newFragment 新Fragment
|
||||
*/
|
||||
public void replaceFragment(Fragment oldFragment, Fragment newFragment) {
|
||||
int position = mFragmentList.indexOf(oldFragment);
|
||||
if (position == -1) {
|
||||
return;
|
||||
}
|
||||
//从Transaction移除旧的Fragment
|
||||
removeFragmentInternal(oldFragment);
|
||||
//替换List中对应的Fragment
|
||||
mFragmentList.set(position, newFragment);
|
||||
//刷新Adapter
|
||||
notifyItemChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将指定位置的Fragment替换/更新为新的Fragment,同{@link #replaceFragment(Fragment oldFragment, Fragment newFragment)}
|
||||
*
|
||||
* @param position 旧Fragment的位置
|
||||
* @param newFragment 新Fragment
|
||||
*/
|
||||
public void replaceFragment(int position, Fragment newFragment) {
|
||||
Fragment oldFragment = mFragmentList.get(position);
|
||||
removeFragmentInternal(oldFragment);
|
||||
mFragmentList.set(position, newFragment);
|
||||
notifyItemChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除指定的Fragment
|
||||
*
|
||||
* @param fragment 目标Fragment
|
||||
*/
|
||||
public void removeFragment(Fragment fragment) {
|
||||
//先从List中移除
|
||||
mFragmentList.remove(fragment);
|
||||
//然后从Transaction移除
|
||||
removeFragmentInternal(fragment);
|
||||
//最后刷新Adapter
|
||||
notifyItemChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除指定位置的Fragment,同 {@link #removeFragment(Fragment fragment)}
|
||||
*
|
||||
* @param position
|
||||
*/
|
||||
public void removeFragment(int position) {
|
||||
Fragment fragment = mFragmentList.get(position);
|
||||
//然后从List中移除
|
||||
mFragmentList.remove(fragment);
|
||||
//先从Transaction移除
|
||||
removeFragmentInternal(fragment);
|
||||
//最后刷新Adapter
|
||||
notifyItemChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加Fragment
|
||||
*
|
||||
* @param fragment 目标Fragment
|
||||
*/
|
||||
public void addFragment(Fragment fragment) {
|
||||
mFragmentList.add(fragment);
|
||||
notifyItemChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* 在指定位置插入一个Fragment
|
||||
*
|
||||
* @param position 插入位置
|
||||
* @param fragment 目标Fragment
|
||||
*/
|
||||
public void insertFragment(int position, Fragment fragment) {
|
||||
mFragmentList.add(position, fragment);
|
||||
notifyItemChanged();
|
||||
}
|
||||
|
||||
private void notifyItemChanged() {
|
||||
//刷新之前重新收集位置信息
|
||||
setFragmentPositionMapForUpdate();
|
||||
notifyDataSetChanged();
|
||||
setFragmentPositionMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从Transaction移除Fragment
|
||||
*
|
||||
* @param fragment 目标Fragment
|
||||
*/
|
||||
private void removeFragmentInternal(Fragment fragment) {
|
||||
FragmentTransaction transaction = mFragmentManager.beginTransaction();
|
||||
transaction.remove(fragment);
|
||||
transaction.commitNow();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
return mFragmentList.get(position);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Fragment getItem(int position) {
|
||||
// return mFragmentList.get(position);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getCount() {
|
||||
// return mFragmentList.size();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 此方法不用position做返回值即可破解fragment tag异常的错误
|
||||
*/
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
// 获取当前数据的hashCode,其实这里不用hashCode用自定义的可以关联当前Item对象的唯一值也可以,只要不是直接返回position
|
||||
return mFragmentList.get(position).hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mFragmentList.size();
|
||||
}
|
||||
|
||||
public List<Fragment> getFragments() {
|
||||
return mFragmentList;
|
||||
}
|
||||
}
|
||||
@@ -250,6 +250,26 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
return mWifiInfo.isConnected();
|
||||
}
|
||||
|
||||
private RefreshBroadcastReceiver mRefreshBroadcastReceiver;
|
||||
|
||||
private void registerRefreshReceiver() {
|
||||
if (mRefreshBroadcastReceiver == null) {
|
||||
mRefreshBroadcastReceiver = new RefreshBroadcastReceiver();
|
||||
}
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(QuickAppActivity.QUICK_APP_REFRESH_KEY);
|
||||
mContext.registerReceiver(mRefreshBroadcastReceiver, filter);
|
||||
}
|
||||
|
||||
class RefreshBroadcastReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.e(TAG, "onReceive: " + intent.getAction());
|
||||
setQuickApp();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void registerAlarmClockReceiver() {
|
||||
if (null == mAlarmClockReceiver) {
|
||||
mAlarmClockReceiver = new AlarmClockReceiver();
|
||||
@@ -356,6 +376,7 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
|
||||
private void initView() {
|
||||
Log.e(TAG, "initView: " + Utils.getBatteryLevel(mContext));
|
||||
registerRefreshReceiver();
|
||||
registerBatteryReceiver();
|
||||
registerAlarmClockReceiver();
|
||||
registTimeReceiver();
|
||||
@@ -470,7 +491,10 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (TextUtils.isEmpty(quickAppPackagesName)) {
|
||||
startActivity(new Intent(mContext, QuickAppActivity.class));
|
||||
int is_quick = Settings.Global.getInt(mContext.getContentResolver(), QuickAppActivity.QUICK_APP_ENABLED_KEY, 0);
|
||||
if (is_quick == 0) {
|
||||
startActivity(new Intent(mContext, QuickAppActivity.class));
|
||||
}
|
||||
} else {
|
||||
ApkUtils.openPackage(mContext, quickAppPackagesName);
|
||||
}
|
||||
@@ -479,7 +503,12 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
cl_app.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
startActivity(new Intent(mContext, QuickAppActivity.class));
|
||||
int is_quick = Settings.Global.getInt(mContext.getContentResolver(), QuickAppActivity.QUICK_APP_ENABLED_KEY, 0);
|
||||
if (is_quick == 0) {
|
||||
startActivity(new Intent(mContext, QuickAppActivity.class));
|
||||
} else {
|
||||
ToastUtil.show("已在小程序设置");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@@ -629,7 +658,7 @@ public class CustomFragment extends BaseFragment implements CustomContact.Custom
|
||||
private String quickAppPackagesName;
|
||||
|
||||
private void setQuickApp() {
|
||||
quickAppPackagesName = mMMKV.decodeString(QuickAppActivity.QUICK_APP_KEY, "");
|
||||
quickAppPackagesName = Settings.Global.getString(mCRv, QuickAppActivity.QUICK_APP_KEY);
|
||||
Log.e(TAG, "setQuickApp: " + quickAppPackagesName);
|
||||
if (!TextUtils.isEmpty(quickAppPackagesName)) {
|
||||
ApplicationInfo applicationInfo = null;
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.baidu.location.BDAbstractLocationListener;
|
||||
import com.baidu.location.BDLocation;
|
||||
import com.baidu.location.LocationClient;
|
||||
import com.baidu.location.LocationClientOption;
|
||||
import com.blankj.utilcode.util.SPUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
@@ -28,7 +29,6 @@ public class AmapManager {
|
||||
private LocationClientOption mOption;
|
||||
private BDLocation mLocation;
|
||||
private CacheHelper mCacheHelper;
|
||||
private MMKV mmkv = MMKV.defaultMMKV();
|
||||
|
||||
private static final String AMAPLOCATION_JSON_KEY = "MAPLOCATION_JSON_STRING";
|
||||
public static final String LONGITUDE_KEY = "map_longitude_key";
|
||||
@@ -80,7 +80,7 @@ public class AmapManager {
|
||||
|
||||
public BDLocation getNowMapLocation() {
|
||||
if (mLocation == null) {
|
||||
String aMapLocationjson = mmkv.decodeString(AMAPLOCATION_JSON_KEY);
|
||||
String aMapLocationjson = SPUtils.getInstance().getString(AMAPLOCATION_JSON_KEY);
|
||||
if (TextUtils.isEmpty(aMapLocationjson)) {
|
||||
return null;
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public class AmapManager {
|
||||
case BDLocation.TypeGpsLocation:// GPS定位结果
|
||||
case BDLocation.TypeNetWorkLocation:// 网络定位结果
|
||||
case BDLocation.TypeOffLineLocation:// 离线定位结果
|
||||
mmkv.encode(AMAPLOCATION_JSON_KEY, GsonUtils.toJsonString(location));
|
||||
SPUtils.getInstance().put(AMAPLOCATION_JSON_KEY, GsonUtils.toJsonString(location));
|
||||
Log.e(TAG, "onLocationChanged: " + "定位成功");
|
||||
Log.e(TAG, "onLocationChanged: longitude = " + location.getLongitude());
|
||||
Log.e(TAG, "onLocationChanged: latitude = " + location.getLatitude());
|
||||
|
||||
@@ -57,6 +57,11 @@ public class ApkUtils {
|
||||
// this.add("com.tencent.android.qqdownloader");
|
||||
// this.add("com.alldocube.store");
|
||||
}};
|
||||
|
||||
private static HashSet<String> excludeClassName = new HashSet<String>() {{
|
||||
this.add("com.android.dialer.app.calllog.CallLogActivity");
|
||||
}};
|
||||
|
||||
private static HashSet<String> showPackageName = new HashSet<String>() {{
|
||||
this.add("com.uiui.sn");
|
||||
this.add("com.android.dialer");
|
||||
@@ -161,6 +166,7 @@ public class ApkUtils {
|
||||
Set<String> allowPackages = new HashSet();
|
||||
for (ResolveInfo resolveInfo : resolveinfoList) {
|
||||
Log.i(TAG, "queryFilterAppInfo: " + resolveInfo.activityInfo.packageName);
|
||||
Log.i(TAG, "queryFilterAppInfo: " + resolveInfo.activityInfo.name);
|
||||
allowPackages.add(resolveInfo.activityInfo.packageName);
|
||||
}
|
||||
String appListString = Settings.System.getString(context.getContentResolver(), "only_jgy_shortcut_list");
|
||||
@@ -220,8 +226,16 @@ public class ApkUtils {
|
||||
});
|
||||
ArrayList<DesktopIcon> desktopIcons = new ArrayList<>();
|
||||
for (ResolveInfo applicationInfo : resolveInfos) {
|
||||
desktopIcons.add(DesktopIcon.creatDesktopIcon(context, applicationInfo));
|
||||
if (!excludeClassName.contains(applicationInfo.activityInfo.name)) {
|
||||
desktopIcons.add(DesktopIcon.creatDesktopIcon(context, applicationInfo));
|
||||
}
|
||||
}
|
||||
DesktopIcon familyIcon = new DesktopIcon();
|
||||
familyIcon.setIcon(context.getDrawable(R.drawable.family_space));
|
||||
familyIcon.setLable("家庭空间");
|
||||
familyIcon.setPackageName("aios.family");
|
||||
desktopIcons.add(0, familyIcon);
|
||||
|
||||
DesktopIcon exitIcon = new DesktopIcon();
|
||||
exitIcon.setIcon(context.getDrawable(R.drawable.exit_icon));
|
||||
exitIcon.setLable("切换系统");
|
||||
|
||||
@@ -61,9 +61,9 @@ public class BitmapUtils {
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
drawable.draw(canvas);
|
||||
return bitmap;
|
||||
return Utils.getRoundedBitmap(bitmap, context);
|
||||
} else {
|
||||
return ((BitmapDrawable) drawable).getBitmap();
|
||||
return Utils.getRoundedBitmap(((BitmapDrawable) drawable).getBitmap(), context);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
|
||||
@@ -1,31 +1,28 @@
|
||||
package com.uiui.aios.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.role.RoleManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.uiui.aios.BuildConfig;
|
||||
import com.uiui.aios.R;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Utils {
|
||||
private static final String TAG = Utils.class.getSimpleName();
|
||||
@@ -95,5 +92,53 @@ public class Utils {
|
||||
return url.substring(position + 1);
|
||||
}
|
||||
|
||||
public static Bitmap getRoundedBitmap(Bitmap mBitmap, Context context) {
|
||||
Bitmap bgBitmap = Bitmap.createBitmap(mBitmap.getWidth(), mBitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
|
||||
Bitmap mask = BitmapFactory.decodeResource(context.getResources(), R.drawable.mask);
|
||||
int width = mask.getWidth();
|
||||
int height = mask.getHeight();
|
||||
Bitmap bitmapScale = Bitmap.createScaledBitmap(mBitmap, width, height, true);
|
||||
bitmapScale.setDensity(context.getResources().getDisplayMetrics().densityDpi);
|
||||
// Palette p = Palette.from(mBitmap).generate();
|
||||
// Palette.Swatch vibrant = p.getVibrantSwatch();//有活力的
|
||||
// int color = vibrant.getRgb(); //样本中的像素数量
|
||||
|
||||
Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas();
|
||||
Paint paint = new Paint();
|
||||
|
||||
canvas.setBitmap(result);
|
||||
// canvas.drawColor(color);
|
||||
canvas.drawBitmap(mask, 0, 0, paint);
|
||||
// paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
canvas.drawBitmap(bitmapScale, 0, 0, paint);
|
||||
// return result;
|
||||
|
||||
Bitmap result2 = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas2 = new Canvas();
|
||||
Paint paint2 = new Paint();
|
||||
canvas2.setBitmap(result2);
|
||||
canvas2.drawBitmap(mask, 0, 0, paint2);
|
||||
paint2.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
canvas2.drawBitmap(result, 0, 0, paint2);
|
||||
return result2;
|
||||
|
||||
|
||||
// Canvas mCanvas = new Canvas();
|
||||
// mCanvas.setBitmap(bgBitmap);
|
||||
// Paint mPaint = new Paint();
|
||||
// RectF mRectM = new RectF(scaleM, scaleM, mBitmap.getWidth() - scaleM, mBitmap.getHeight() - scaleM); //设置剪裁圆角的区域
|
||||
// Rect mRect = new Rect(0, 0, mBitmap.getWidth(), mBitmap.getHeight());
|
||||
// RectF mRectF = mRectM;
|
||||
//
|
||||
// float roundPx = 15; //圆角半径
|
||||
// mPaint.setAntiAlias(true);
|
||||
// //Log.d("wy"+TAG,"mBitmap.getWidth()="+mBitmap.getWidth()+", mBitmap.getHeight()="+mBitmap.getHeight());
|
||||
// mCanvas.drawRoundRect(mRectF, roundPx, roundPx, mPaint);
|
||||
// mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
// mCanvas.drawBitmap(mBitmap, mRect, mRect, mPaint);
|
||||
// return bgBitmap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.uiui.aios.viewpager2;
|
||||
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import net.lucode.hackware.magicindicator.MagicIndicator;
|
||||
|
||||
/**
|
||||
* 简化和ViewPager绑定
|
||||
* Created by hackware on 2016/8/17.
|
||||
*/
|
||||
|
||||
public class ViewPager2Helper {
|
||||
public static void bind(final MagicIndicator magicIndicator, ViewPager2 viewPager) {
|
||||
viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
magicIndicator.onPageScrolled(position, positionOffset, positionOffsetPixels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
magicIndicator.onPageSelected(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
magicIndicator.onPageScrollStateChanged(state);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.uiui.aios.viewpager2;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Viewpager2Adapter extends FragmentStateAdapter {
|
||||
|
||||
private FragmentManager mFragmentManager;
|
||||
private List<Fragment> fragmentList;
|
||||
|
||||
|
||||
public Viewpager2Adapter(@NonNull FragmentActivity fragmentActivity, FragmentManager fragmentManager, List<Fragment> fragmentList) {
|
||||
super(fragmentActivity);
|
||||
this.mFragmentManager = fragmentManager;
|
||||
this.fragmentList = fragmentList;
|
||||
}
|
||||
|
||||
public void replaceFragment(int position, Fragment fragment) {
|
||||
|
||||
}
|
||||
|
||||
public void addFragment(Fragment fragment) {
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
return fragmentList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return super.getItemId(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return fragmentList == null ? 0 : fragmentList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsItem(long itemId) {
|
||||
return super.containsItem(itemId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user