From 5469505cc6fb26bed8eeb08ce3ac78e817eb9007 Mon Sep 17 00:00:00 2001 From: tongtongstudio Date: Fri, 6 Nov 2026 18:48:43 +0800 Subject: [PATCH] =?UTF-8?q?refactor(base):=20=E6=B8=85=E7=90=86=E5=BA=9F?= =?UTF-8?q?=E5=BC=83=E4=BB=A3=E7=A0=81=E5=B9=B6=E6=A0=87=E8=AE=B0=E9=81=97?= =?UTF-8?q?=E7=95=99=E7=B1=BB=E4=B8=BA=E5=B7=B2=E5=BA=9F=E5=BC=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除已废弃的MVP架构基类(BaseActivity、BasePresenter、BaseView) - 删除未使用的对话框类(ActivationDialog、InfoDialog) - 删除未使用的工具类(CheckPermissionsActivity、DiskLruCacheHelper、BaseRxService) - 删除未使用的数据类(SNUidBean、BaseMvvmDialogFragment) - 为MainActivity、MainViewModel添加@Deprecated注解 - 为BaseRxActivity、BaseRxFragment、BaseRxDialogFragment添加@Deprecated注解 - 修正RunningAppManager中Statistics包名大小写为statistics --- app/src/main/AndroidManifest.xml | 2 +- .../fuying/sn/activity/main/MainActivity.java | 1 + .../sn/activity/main/MainViewModel.java | 1 + .../sn/amap/CheckPermissionsActivity.java | 227 ---------- .../com/fuying/sn/base/mvp/BaseActivity.java | 134 ------ .../com/fuying/sn/base/mvp/BasePresenter.java | 8 - .../java/com/fuying/sn/base/mvp/BaseView.java | 5 - .../mvvm/fragment/BaseMvvmDialogFragment.java | 184 -------- .../com/fuying/sn/base/rx/BaseRxActivity.java | 1 + .../sn/base/rx/BaseRxDialogFragment.java | 1 + .../com/fuying/sn/base/rx/BaseRxFragment.java | 1 + .../com/fuying/sn/base/rx/BaseRxService.java | 58 --- .../java/com/fuying/sn/bean/SNUidBean.java | 53 --- .../fuying/sn/desktop/RunningAppManager.java | 4 +- .../fuying/sn/dialog/ActivationDialog.java | 251 ---------- .../java/com/fuying/sn/dialog/InfoDialog.java | 109 ----- .../sn/disklrucache/DiskLruCacheHelper.java | 427 ------------------ .../com/fuying/sn/manager/MyGlideModule.java | 3 +- .../sn/network/NetInterfaceManager.java | 65 --- .../com/fuying/sn/network/UrlAddress.java | 4 +- .../fuying/sn/network/api/PublicIPApi.java | 20 - .../sn/network/cache/RxCacheRequest.java | 38 -- .../sn/network/cache/RxTimeCacheManager.java | 66 --- ...lReceiver.java => ApkInstallReceiver.java} | 2 +- .../com/fuying/sn/service/ManagerService.java | 7 +- .../AppInformation.java | 2 +- .../StatisticsInfo.java | 2 +- .../com/fuying/sn/utils/AudioMngHelper.java | 168 ------- .../main/java/com/fuying/sn/utils/Hash.java | 31 -- .../com/fuying/sn/utils/ReceiverCompat.java | 122 +++++ .../main/java/com/fuying/sn/utils/Utils.java | 21 +- .../com/fuying/sn/view/FlowRadioGroup.java | 72 --- 32 files changed, 142 insertions(+), 1948 deletions(-) delete mode 100644 app/src/main/java/com/fuying/sn/amap/CheckPermissionsActivity.java delete mode 100644 app/src/main/java/com/fuying/sn/base/mvp/BaseActivity.java delete mode 100644 app/src/main/java/com/fuying/sn/base/mvp/BasePresenter.java delete mode 100644 app/src/main/java/com/fuying/sn/base/mvp/BaseView.java delete mode 100644 app/src/main/java/com/fuying/sn/base/mvvm/fragment/BaseMvvmDialogFragment.java delete mode 100644 app/src/main/java/com/fuying/sn/base/rx/BaseRxService.java delete mode 100644 app/src/main/java/com/fuying/sn/bean/SNUidBean.java delete mode 100644 app/src/main/java/com/fuying/sn/dialog/ActivationDialog.java delete mode 100644 app/src/main/java/com/fuying/sn/dialog/InfoDialog.java delete mode 100644 app/src/main/java/com/fuying/sn/disklrucache/DiskLruCacheHelper.java delete mode 100644 app/src/main/java/com/fuying/sn/network/api/PublicIPApi.java delete mode 100644 app/src/main/java/com/fuying/sn/network/cache/RxCacheRequest.java delete mode 100644 app/src/main/java/com/fuying/sn/network/cache/RxTimeCacheManager.java rename app/src/main/java/com/fuying/sn/receiver/{APKinstallReceiver.java => ApkInstallReceiver.java} (98%) rename app/src/main/java/com/fuying/sn/{Statistics => statistics}/AppInformation.java (99%) rename app/src/main/java/com/fuying/sn/{Statistics => statistics}/StatisticsInfo.java (99%) delete mode 100644 app/src/main/java/com/fuying/sn/utils/AudioMngHelper.java delete mode 100644 app/src/main/java/com/fuying/sn/utils/Hash.java create mode 100644 app/src/main/java/com/fuying/sn/utils/ReceiverCompat.java delete mode 100644 app/src/main/java/com/fuying/sn/view/FlowRadioGroup.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 74d345e..3655a73 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -198,7 +198,7 @@ diff --git a/app/src/main/java/com/fuying/sn/activity/main/MainActivity.java b/app/src/main/java/com/fuying/sn/activity/main/MainActivity.java index d1fb33d..2239a37 100644 --- a/app/src/main/java/com/fuying/sn/activity/main/MainActivity.java +++ b/app/src/main/java/com/fuying/sn/activity/main/MainActivity.java @@ -61,6 +61,7 @@ import io.reactivex.rxjava3.annotations.NonNull; import io.reactivex.rxjava3.core.Observer; import io.reactivex.rxjava3.disposables.Disposable; +@Deprecated public class MainActivity extends BaseMvvmActivity implements NetworkUtils.OnNetworkStatusChangedListener { private static final String TAG = "MainActivity"; diff --git a/app/src/main/java/com/fuying/sn/activity/main/MainViewModel.java b/app/src/main/java/com/fuying/sn/activity/main/MainViewModel.java index 80d98f3..d47ca69 100644 --- a/app/src/main/java/com/fuying/sn/activity/main/MainViewModel.java +++ b/app/src/main/java/com/fuying/sn/activity/main/MainViewModel.java @@ -23,6 +23,7 @@ import java.lang.reflect.Type; import io.reactivex.rxjava3.disposables.Disposable; +@Deprecated public class MainViewModel extends BaseViewModel { private CacheHelper mCacheHelper = new CacheHelper(getCtx()); diff --git a/app/src/main/java/com/fuying/sn/amap/CheckPermissionsActivity.java b/app/src/main/java/com/fuying/sn/amap/CheckPermissionsActivity.java deleted file mode 100644 index 2e58eb5..0000000 --- a/app/src/main/java/com/fuying/sn/amap/CheckPermissionsActivity.java +++ /dev/null @@ -1,227 +0,0 @@ -/** - * - */ -package com.fuying.sn.amap; - -import android.Manifest; -import android.annotation.TargetApi; -import android.app.Activity; -import android.app.AlertDialog; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.provider.Settings; -import android.view.KeyEvent; - - -import com.fuying.sn.R; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -/** - * 继承了Activity,实现Android6.0的运行时权限检测 - * 需要进行运行时权限检测的Activity可以继承这个类 - * - * @创建时间:2016年5月27日 下午3:01:31 - * @项目名称: AMapLocationDemo - * @author hongming.wang - * @文件名称:PermissionsChecker.java - * @类型名称:PermissionsChecker - * @since 2.5.0 - */ -public class CheckPermissionsActivity extends Activity { - //是否需要检测后台定位权限,设置为true时,如果用户没有给予后台定位权限会弹窗提示 - private boolean needCheckBackLocation = false; - //如果设置了target > 28,需要增加这个权限,否则不会弹出"始终允许"这个选择框 - private static String BACKGROUND_LOCATION_PERMISSION = "android.permission.ACCESS_BACKGROUND_LOCATION"; - /** - * 需要进行检测的权限数组 - */ - protected String[] needPermissions = { - Manifest.permission.ACCESS_COARSE_LOCATION, - Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.READ_PHONE_STATE - }; - - private static final int PERMISSON_REQUESTCODE = 0; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if(Build.VERSION.SDK_INT > 28 - && getApplicationContext().getApplicationInfo().targetSdkVersion > 28) { - needPermissions = new String[] { - Manifest.permission.ACCESS_COARSE_LOCATION, - Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.READ_PHONE_STATE, - BACKGROUND_LOCATION_PERMISSION - }; - } - } - - /** - * 判断是否需要检测,防止不停的弹框 - */ - private boolean isNeedCheck = true; - - @Override - protected void onResume() { - super.onResume(); - if (Build.VERSION.SDK_INT >= 23 - && getApplicationInfo().targetSdkVersion >= 23) { - if (isNeedCheck) { - checkPermissions(needPermissions); - } - } - } - - /** - * - * @param permissions - * @since 2.5.0 - * - */ - private void checkPermissions(String... permissions) { - try { - if (Build.VERSION.SDK_INT >= 23 - && getApplicationInfo().targetSdkVersion >= 23) { - List needRequestPermissonList = findDeniedPermissions(permissions); - if (null != needRequestPermissonList - && needRequestPermissonList.size() > 0) { - String[] array = needRequestPermissonList.toArray(new String[needRequestPermissonList.size()]); - Method method = getClass().getMethod("requestPermissions", new Class[]{String[].class, - int.class}); - - method.invoke(this, array, PERMISSON_REQUESTCODE); - } - } - } catch (Throwable e) { - } - } - - /** - * 获取权限集中需要申请权限的列表 - * - * @param permissions - * @return - * @since 2.5.0 - * - */ - private List findDeniedPermissions(String[] permissions) { - List needRequestPermissonList = new ArrayList(); - if (Build.VERSION.SDK_INT >= 23 - && getApplicationInfo().targetSdkVersion >= 23){ - try { - for (String perm : permissions) { - Method checkSelfMethod = getClass().getMethod("checkSelfPermission", String.class); - Method shouldShowRequestPermissionRationaleMethod = getClass().getMethod("shouldShowRequestPermissionRationale", - String.class); - if ((Integer)checkSelfMethod.invoke(this, perm) != PackageManager.PERMISSION_GRANTED - || (Boolean)shouldShowRequestPermissionRationaleMethod.invoke(this, perm)) { - if(!needCheckBackLocation - && BACKGROUND_LOCATION_PERMISSION.equals(perm)) { - continue; - } - needRequestPermissonList.add(perm); - } - } - } catch (Throwable e) { - - } - } - return needRequestPermissonList; - } - - /** - * 检测是否所有的权限都已经授权 - * @param grantResults - * @return - * @since 2.5.0 - * - */ - private boolean verifyPermissions(int[] grantResults) { - for (int result : grantResults) { - if (result != PackageManager.PERMISSION_GRANTED) { - return false; - } - } - return true; - } - - @Override - @TargetApi(23) - public void onRequestPermissionsResult(int requestCode, - String[] permissions, int[] paramArrayOfInt) { - if (requestCode == PERMISSON_REQUESTCODE) { - if (!verifyPermissions(paramArrayOfInt)) { - showMissingPermissionDialog(); - isNeedCheck = false; - } - } - } - - /** - * 显示提示信息 - * - * @since 2.5.0 - * - */ - private void showMissingPermissionDialog() { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(R.string.notifyTitle); - builder.setMessage(R.string.notifyMsg); - - // 拒绝, 退出应用 - builder.setNegativeButton(R.string.cancel, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - finish(); - } - }); - - builder.setPositiveButton(R.string.setting, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - startAppSettings(); - } - }); - - builder.setCancelable(false); - - builder.show(); - } - - /** - * 启动应用的设置 - * - * @since 2.5.0 - * - */ - private void startAppSettings() { - Intent intent = new Intent( - Settings.ACTION_APPLICATION_DETAILS_SETTINGS); - intent.setData(Uri.parse("package:" + getPackageName())); - startActivity(intent); - } - - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { - if(keyCode == KeyEvent.KEYCODE_BACK){ - this.finish(); - return true; - } - return super.onKeyDown(keyCode, event); - } - -} diff --git a/app/src/main/java/com/fuying/sn/base/mvp/BaseActivity.java b/app/src/main/java/com/fuying/sn/base/mvp/BaseActivity.java deleted file mode 100644 index 8e6a7d8..0000000 --- a/app/src/main/java/com/fuying/sn/base/mvp/BaseActivity.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.fuying.sn.base.mvp; - -import android.app.ActivityManager; -import android.os.Build; -import android.os.Bundle; - -import androidx.annotation.CallSuper; -import androidx.annotation.CheckResult; -import androidx.annotation.ContentView; -import androidx.annotation.LayoutRes; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; - -import com.fuying.sn.R; -import com.trello.rxlifecycle4.LifecycleProvider; -import com.trello.rxlifecycle4.LifecycleTransformer; -import com.trello.rxlifecycle4.RxLifecycle; -import com.trello.rxlifecycle4.android.ActivityEvent; -import com.trello.rxlifecycle4.android.RxLifecycleAndroid; -import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX; - -import io.reactivex.rxjava3.core.Observable; -import io.reactivex.rxjava3.subjects.BehaviorSubject; - -@Deprecated -public abstract class BaseActivity extends AppCompatActivity implements LifecycleProvider { - public final BehaviorSubject lifecycleSubject = BehaviorSubject.create(); - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); -// StatusBarUtil.init(this); - UltimateBarX.statusBar(this) - .transparent() - .colorRes(R.color.colorPrimaryDark) - .light(true) - .apply(); - UltimateBarX.navigationBar(this) - .transparent() - .colorRes(R.color.colorPrimaryDark) - .light(true) - .apply(); - setContentView(this.getLayoutId()); - initView(); - initData(); - //最近任务和应用图标不一样 - if (Build.VERSION.SDK_INT > 27) { - ActivityManager.TaskDescription description = new ActivityManager.TaskDescription(getString(R.string.app_name), R.mipmap.ic_launcher, getColor(R.color.colorPrimary)); - this.setTaskDescription(description); - } - } - - /** - * 设置布局 - */ - public abstract int getLayoutId(); - - /** - * 初始化视图 - */ - public abstract void initView(); - - - /** - * 初始化数据 - */ - public abstract void initData(); - - public BaseActivity() { - super(); - } - - @ContentView - public BaseActivity(@LayoutRes int contentLayoutId) { - super(contentLayoutId); - } - - @Override - @NonNull - @CheckResult - public final Observable lifecycle() { - return lifecycleSubject.hide(); - } - - @Override - @NonNull - @CheckResult - public final LifecycleTransformer bindUntilEvent(@NonNull ActivityEvent event) { - return RxLifecycle.bindUntilEvent(lifecycleSubject, event); - } - - @Override - @NonNull - @CheckResult - public final LifecycleTransformer bindToLifecycle() { - return RxLifecycleAndroid.bindActivity(lifecycleSubject); - } - - @Override - @CallSuper - protected void onStart() { - super.onStart(); - lifecycleSubject.onNext(ActivityEvent.START); - } - - @Override - @CallSuper - protected void onResume() { - super.onResume(); - lifecycleSubject.onNext(ActivityEvent.RESUME); - } - - @Override - @CallSuper - protected void onPause() { - lifecycleSubject.onNext(ActivityEvent.PAUSE); - super.onPause(); - } - - @Override - @CallSuper - protected void onStop() { - lifecycleSubject.onNext(ActivityEvent.STOP); - super.onStop(); - } - - @Override - @CallSuper - protected void onDestroy() { - lifecycleSubject.onNext(ActivityEvent.DESTROY); - super.onDestroy(); - } -} diff --git a/app/src/main/java/com/fuying/sn/base/mvp/BasePresenter.java b/app/src/main/java/com/fuying/sn/base/mvp/BasePresenter.java deleted file mode 100644 index e5a7378..0000000 --- a/app/src/main/java/com/fuying/sn/base/mvp/BasePresenter.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.fuying.sn.base.mvp; - -@Deprecated -public interface BasePresenter { - void attachView(V view); - - void detachView(); -} diff --git a/app/src/main/java/com/fuying/sn/base/mvp/BaseView.java b/app/src/main/java/com/fuying/sn/base/mvp/BaseView.java deleted file mode 100644 index bf83a1a..0000000 --- a/app/src/main/java/com/fuying/sn/base/mvp/BaseView.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.fuying.sn.base.mvp; - -@Deprecated -public interface BaseView { -} diff --git a/app/src/main/java/com/fuying/sn/base/mvvm/fragment/BaseMvvmDialogFragment.java b/app/src/main/java/com/fuying/sn/base/mvvm/fragment/BaseMvvmDialogFragment.java deleted file mode 100644 index 0c2efb0..0000000 --- a/app/src/main/java/com/fuying/sn/base/mvvm/fragment/BaseMvvmDialogFragment.java +++ /dev/null @@ -1,184 +0,0 @@ -package com.fuying.sn.base.mvvm.fragment; - -import android.app.Activity; -import android.content.Context; -import android.content.res.Configuration; -import android.os.Bundle; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; - -import androidx.annotation.LayoutRes; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.databinding.DataBindingUtil; -import androidx.databinding.ViewDataBinding; -import androidx.lifecycle.ViewModel; -import androidx.lifecycle.ViewModelProvider; - -import com.fuying.sn.base.BaseDialogFragment; - -import java.lang.ref.WeakReference; -import java.lang.reflect.ParameterizedType; - -/** - * @author: lml - * @date: 2021/12/15 - */ -public abstract class BaseMvvmDialogFragment extends BaseDialogFragment { - protected String mTag = this.getClass().getSimpleName(); - /** - * 是否顯示了 - */ - protected boolean mIsVisible; - /** - * 是否準備好了-Created - */ - protected boolean mHasPrepare; - - - protected VM mViewModel; - protected VDB mViewDataBinding; - protected Class vmClass; - // -// protected Toolbar toolbar; -// protected View statusBarView; - // - protected Bundle bundle;//来自getArguments() - protected Bundle savedInstanceState; - -// protected Context context; - - /** - * 上下文 - */ - private WeakReference ctx; - - public Context getCtx() { - return ctx == null ? null : ctx.get(); - } - - @Override - public void onAttach(@NonNull Context context) { - super.onAttach(context); -// this.context = context; - ctx = new WeakReference<>(context); - } - - /** - * onCreate、onResume里不能调用 - * - * @return - */ - public boolean isAttached() { - boolean flag = getCtx() != null && isAdded(); - Log.e(" >> isAttached >>", "flag = " + flag); - return flag; - } - - @Nullable - @Override - public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - //ViewDataBinding - mViewDataBinding = DataBindingUtil.inflate(inflater, getLayoutId(), container, false); - mViewDataBinding.setLifecycleOwner(this); - - //ViewModel - vmClass = (Class) ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[0]; - mViewModel = new ViewModelProvider(this).get(vmClass); - - return mViewDataBinding.getRoot(); - } - - - @Override - public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - initDataBinding(); - initView(bundle = getArguments()); - - initData(this.savedInstanceState = savedInstanceState); - - if (mIsVisible) { - onEnter(); - } - mHasPrepare = true; - - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - mHasPrepare = false; - mViewDataBinding = null; - } - - @Override - public void setUserVisibleHint(boolean isVisibleToUser) { - super.setUserVisibleHint(isVisibleToUser); - if (mIsVisible == getUserVisibleHint()) - return; - mIsVisible = getUserVisibleHint(); - if (mIsVisible) { - if (!mHasPrepare) - return; - onEnter(); - } else { - onExit(); - } - } - - @LayoutRes - protected abstract int getLayoutId(); - - protected abstract void initDataBinding(); - - protected abstract void initView(Bundle bundle); - - protected abstract void initData(Bundle savedInstanceState); - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - } - - protected void hideInputMethod(Activity activity) { - InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); - View view = activity.getCurrentFocus(); - if (view != null) { - imm.hideSoftInputFromWindow(view.getWindowToken(), 0); - } - } - - protected void hideInputMethod(Activity activity, EditText editText) { - InputMethodManager imm = (InputMethodManager) editText.getContext().getSystemService(Activity.INPUT_METHOD_SERVICE); - View view = activity.getCurrentFocus(); - if (view != null) { - imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); - } - } - - protected void showInputMethod(EditText editText) { - InputMethodManager imm = (InputMethodManager) editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(editText, InputMethodManager.SHOW_FORCED); - } - - /** - * 進入界面 - */ - protected void onEnter() { - - } - - /** - * 離開界面 - */ - protected void onExit() { - - } - -} diff --git a/app/src/main/java/com/fuying/sn/base/rx/BaseRxActivity.java b/app/src/main/java/com/fuying/sn/base/rx/BaseRxActivity.java index 177d655..5aa316c 100644 --- a/app/src/main/java/com/fuying/sn/base/rx/BaseRxActivity.java +++ b/app/src/main/java/com/fuying/sn/base/rx/BaseRxActivity.java @@ -21,6 +21,7 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject; * {@link com.trello.rxlifecycle4.components.RxActivity} * copied form RxActivity} */ +@Deprecated public abstract class BaseRxActivity extends AppCompatActivity implements LifecycleProvider { private final BehaviorSubject lifecycleSubject = BehaviorSubject.create(); diff --git a/app/src/main/java/com/fuying/sn/base/rx/BaseRxDialogFragment.java b/app/src/main/java/com/fuying/sn/base/rx/BaseRxDialogFragment.java index c03121e..c960260 100644 --- a/app/src/main/java/com/fuying/sn/base/rx/BaseRxDialogFragment.java +++ b/app/src/main/java/com/fuying/sn/base/rx/BaseRxDialogFragment.java @@ -22,6 +22,7 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject; * {@link com.trello.rxlifecycle4.components.RxFragment} * copied form RxFragment} */ +@Deprecated public class BaseRxDialogFragment extends DialogFragment implements LifecycleProvider { private final BehaviorSubject lifecycleSubject = BehaviorSubject.create(); diff --git a/app/src/main/java/com/fuying/sn/base/rx/BaseRxFragment.java b/app/src/main/java/com/fuying/sn/base/rx/BaseRxFragment.java index 8c330c6..d34339d 100644 --- a/app/src/main/java/com/fuying/sn/base/rx/BaseRxFragment.java +++ b/app/src/main/java/com/fuying/sn/base/rx/BaseRxFragment.java @@ -22,6 +22,7 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject; * {@link com.trello.rxlifecycle4.components.RxFragment} * copied form RxFragment} */ +@Deprecated public class BaseRxFragment extends Fragment implements LifecycleProvider { private final BehaviorSubject lifecycleSubject = BehaviorSubject.create(); diff --git a/app/src/main/java/com/fuying/sn/base/rx/BaseRxService.java b/app/src/main/java/com/fuying/sn/base/rx/BaseRxService.java deleted file mode 100644 index f7abe92..0000000 --- a/app/src/main/java/com/fuying/sn/base/rx/BaseRxService.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.fuying.sn.base.rx; - -import android.app.Service; -import android.content.Intent; - -import androidx.annotation.CheckResult; -import androidx.annotation.NonNull; - -import com.trello.rxlifecycle4.LifecycleProvider; -import com.trello.rxlifecycle4.LifecycleTransformer; -import com.trello.rxlifecycle4.RxLifecycle; -import com.trello.rxlifecycle4.android.ActivityEvent; -import com.trello.rxlifecycle4.android.RxLifecycleAndroid; - -import io.reactivex.rxjava3.core.Observable; -import io.reactivex.rxjava3.subjects.BehaviorSubject; - -public abstract class BaseRxService extends Service implements LifecycleProvider { - private final BehaviorSubject lifecycleSubject = BehaviorSubject.create(); - - public BehaviorSubject getLifecycleSubject() { - return lifecycleSubject; - } - - - @Override - @NonNull - @CheckResult - public final Observable lifecycle() { - return lifecycleSubject.hide(); - } - - @Override - @NonNull - @CheckResult - public final LifecycleTransformer bindUntilEvent(@NonNull ActivityEvent event) { - return RxLifecycle.bindUntilEvent(lifecycleSubject, event); - } - - @Override - @NonNull - @CheckResult - public final LifecycleTransformer bindToLifecycle() { - return RxLifecycleAndroid.bindActivity(lifecycleSubject); - } - - @Override - public void onCreate() { - super.onCreate(); - lifecycleSubject.onNext(ActivityEvent.CREATE); - } - - @Override - public void onDestroy() { - super.onDestroy(); - lifecycleSubject.onNext(ActivityEvent.DESTROY); - } -} diff --git a/app/src/main/java/com/fuying/sn/bean/SNUidBean.java b/app/src/main/java/com/fuying/sn/bean/SNUidBean.java deleted file mode 100644 index cd994ae..0000000 --- a/app/src/main/java/com/fuying/sn/bean/SNUidBean.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.fuying.sn.bean; - -import java.io.Serializable; - -public class SNUidBean implements Serializable { - private static final long serialVersionUID = 8415979808461790756L; - - String specification_id; - String user_power_id; - int grade; - String activate_time; - String card_info; - - public String getSpecification_id() { - return specification_id; - } - - public void setSpecification_id(String specification_id) { - this.specification_id = specification_id; - } - - public String getUser_power_id() { - return user_power_id; - } - - public void setUser_power_id(String user_power_id) { - this.user_power_id = user_power_id; - } - - public int getGrade() { - return grade; - } - - public void setGrade(int grade) { - this.grade = grade; - } - - public String getActivate_time() { - return activate_time; - } - - public void setActivate_time(String activate_time) { - this.activate_time = activate_time; - } - - public String getCard_info() { - return card_info; - } - - public void setCard_info(String card_info) { - this.card_info = card_info; - } -} diff --git a/app/src/main/java/com/fuying/sn/desktop/RunningAppManager.java b/app/src/main/java/com/fuying/sn/desktop/RunningAppManager.java index a702ba4..237de48 100644 --- a/app/src/main/java/com/fuying/sn/desktop/RunningAppManager.java +++ b/app/src/main/java/com/fuying/sn/desktop/RunningAppManager.java @@ -26,8 +26,8 @@ import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import com.fuying.sn.BuildConfig; -import com.fuying.sn.Statistics.AppInformation; -import com.fuying.sn.Statistics.StatisticsInfo; +import com.fuying.sn.statistics.AppInformation; +import com.fuying.sn.statistics.StatisticsInfo; import com.fuying.sn.bean.AppInfo; import com.fuying.sn.bean.AppUsageTime; import com.fuying.sn.bean.MyAppUsageBean; diff --git a/app/src/main/java/com/fuying/sn/dialog/ActivationDialog.java b/app/src/main/java/com/fuying/sn/dialog/ActivationDialog.java deleted file mode 100644 index 42391d3..0000000 --- a/app/src/main/java/com/fuying/sn/dialog/ActivationDialog.java +++ /dev/null @@ -1,251 +0,0 @@ -package com.fuying.sn.dialog; - - -import android.content.Context; -import android.os.Bundle; -import android.text.TextUtils; -import android.view.View; -import android.widget.Button; -import android.widget.ImageView; -import android.widget.TextView; - -import androidx.appcompat.app.AlertDialog; - -import com.fuying.sn.R; - - -/** - * description:自定义dialog - */ - -public class ActivationDialog extends AlertDialog { - /** - * 显示的图片 - */ - private ImageView imageIv; - - /** - * 显示的标题 - */ - private TextView titleTv; - - /** - * 显示的消息 - */ - private TextView messageTv; - - /** - * 确认和取消按钮 - */ - private Button negtiveBn, positiveBn; - - /** - * 按钮之间的分割线 - */ - private View columnLineView; - - private Context mContext; - - public ActivationDialog(Context context) { - super(context, R.style.CustomDialog); - this.mContext = context; - } - - /** - * 都是内容数据 - */ - private String message; - private String title; - private String positive, negtive; - private int imageResId = -1; - - /** - * 底部是否只有一个按钮 - */ - private boolean isSingle = false; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.custom_dialog); - //按空白处不能取消动画 - setCanceledOnTouchOutside(false); - //初始化界面控件 - initView(); - //初始化界面数据 - refreshView(); - //初始化界面控件的事件 - initEvent(); - } - - /** - * 初始化界面的确定和取消监听器 - */ - private void initEvent() { - //设置确定按钮被点击后,向外界提供监听 - positiveBn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (onClickBottomListener != null) { - onClickBottomListener.onPositiveClick(); - } - } - }); - //设置取消按钮被点击后,向外界提供监听 - negtiveBn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (onClickBottomListener != null) { - onClickBottomListener.onNegtiveClick(); - } - } - }); - } - - /** - * 初始化界面控件的显示数据 - */ - private void refreshView() { - //如果用户自定了title和message - if (!TextUtils.isEmpty(title)) { - titleTv.setText(title); - titleTv.setVisibility(View.VISIBLE); - } else { - titleTv.setVisibility(View.GONE); - } - if (!TextUtils.isEmpty(message)) { - messageTv.setText(message); - } - //如果设置按钮的文字 - if (!TextUtils.isEmpty(positive)) { - positiveBn.setText(positive); - } else { - positiveBn.setText("确定"); - } - if (!TextUtils.isEmpty(negtive)) { - negtiveBn.setText(negtive); - } else { - negtiveBn.setText("取消"); - } - - if (imageResId != -1) { - imageIv.setImageResource(imageResId); - imageIv.setVisibility(View.VISIBLE); - } else { - imageIv.setVisibility(View.GONE); - } - /** - * 只显示一个按钮的时候隐藏取消按钮,回掉只执行确定的事件 - */ - if (isSingle) { - columnLineView.setVisibility(View.GONE); - negtiveBn.setVisibility(View.GONE); - } else { - negtiveBn.setVisibility(View.VISIBLE); - columnLineView.setVisibility(View.VISIBLE); - } - } - - @Override - public void show() { - super.show(); - refreshView(); - } - - /** - * 初始化界面控件 - */ - private void initView() { - negtiveBn = findViewById(R.id.negtive); - positiveBn = findViewById(R.id.positive); - titleTv = findViewById(R.id.title); - messageTv = findViewById(R.id.message); - imageIv = findViewById(R.id.image); - columnLineView = findViewById(R.id.column_line); - } - - /** - * 设置确定取消按钮的回调 - */ - private OnClickBottomListener onClickBottomListener; - - public void setOnClickBottomListener(OnClickBottomListener onClickBottomListener) { - this.onClickBottomListener = onClickBottomListener; - } - - public interface OnClickBottomListener { - /** - * 点击确定按钮事件 - */ - void onPositiveClick(); - - /** - * 点击取消按钮事件 - */ - void onNegtiveClick(); - } - - public String getMessage() { - return message; - } - - public ActivationDialog setMessage(String message) { - this.message = message; - return this; - } - - public String getTitle() { - return title; - } - - public ActivationDialog setTitle(String title) { - this.title = title; - return this; - } - - public String getPositive() { - return positive; - } - - public ActivationDialog setPositive(String positive) { - this.positive = positive; - return this; - } - - public String getNegtive() { - return negtive; - } - - public ActivationDialog setNegtive(String negtive) { - this.negtive = negtive; - return this; - } - - public ActivationDialog setNegtiveText(String negtive) { - negtiveBn.setText(negtive); - return this; - } - - public int getImageResId() { - return imageResId; - } - - public boolean isSingle() { - return isSingle; - } - - public ActivationDialog setSingle(boolean single) { - isSingle = single; - return this; - } - - public ActivationDialog setImageResId(int imageResId) { - this.imageResId = imageResId; - return this; - } - - @Override - public void dismiss() { - super.dismiss(); - } -} diff --git a/app/src/main/java/com/fuying/sn/dialog/InfoDialog.java b/app/src/main/java/com/fuying/sn/dialog/InfoDialog.java deleted file mode 100644 index e11253c..0000000 --- a/app/src/main/java/com/fuying/sn/dialog/InfoDialog.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.fuying.sn.dialog; - -import android.app.Dialog; -import android.content.Context; -import android.graphics.Bitmap; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; -import android.widget.ImageView; -import android.widget.TextView; - -import androidx.annotation.NonNull; - -import com.fuying.sn.R; - - -public class InfoDialog extends Dialog { - - private InfoDialog(Context context, int themeResId) { - super(context, themeResId); - } - - public static class Builder { - - private View mLayout; - - private ImageView mIcon; - private TextView mTitle; - private TextView mMessage; - private Button mButton; - - private View.OnClickListener mButtonClickListener; - - private InfoDialog mDialog; - - public Builder(Context context) { - mDialog = new InfoDialog(context, R.style.CustomDialog); - LayoutInflater inflater = - (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - //加载布局文件 - mLayout = inflater.inflate(R.layout.dialog, null, false); - //添加布局文件到 Dialog - mDialog.addContentView(mLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT)); - - mIcon = mLayout.findViewById(R.id.dialog_icon); - mTitle = mLayout.findViewById(R.id.dialog_title); - mMessage = mLayout.findViewById(R.id.dialog_message); - mButton = mLayout.findViewById(R.id.dialog_button); - } - - /** - * 通过 ID 设置 Dialog 图标 - */ - public Builder setIcon(int resId) { - mIcon.setImageResource(resId); - return this; - } - - /** - * 用 Bitmap 作为 Dialog 图标 - */ - public Builder setIcon(Bitmap bitmap) { - mIcon.setImageBitmap(bitmap); - return this; - } - - /** - * 设置 Dialog 标题 - */ - public Builder setTitle(@NonNull String title) { - mTitle.setText(title); - mTitle.setVisibility(View.VISIBLE); - return this; - } - - /** - * 设置 Message - */ - public Builder setMessage(@NonNull String message) { - mMessage.setText(message); - return this; - } - - /** - * 设置按钮文字和监听 - */ - public Builder setButton(@NonNull String text, View.OnClickListener listener) { - mButton.setText(text); - mButtonClickListener = listener; - return this; - } - - public InfoDialog create() { - mButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - mDialog.dismiss(); - mButtonClickListener.onClick(view); - } - }); - mDialog.setContentView(mLayout); - mDialog.setCancelable(true); //用户可以点击后退键关闭 Dialog - mDialog.setCanceledOnTouchOutside(false); //用户不可以点击外部来关闭 Dialog - return mDialog; - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/fuying/sn/disklrucache/DiskLruCacheHelper.java b/app/src/main/java/com/fuying/sn/disklrucache/DiskLruCacheHelper.java deleted file mode 100644 index 1f90ecb..0000000 --- a/app/src/main/java/com/fuying/sn/disklrucache/DiskLruCacheHelper.java +++ /dev/null @@ -1,427 +0,0 @@ -package com.fuying.sn.disklrucache; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.drawable.Drawable; -import android.os.Environment; -import android.util.Log; - -import com.jakewharton.disklrucache.DiskLruCache; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.BufferedWriter; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Serializable; - -/** - * 磁盘缓存帮助类 - */ -public class DiskLruCacheHelper { - private static final String DIR_NAME = "diskCache"; - private static final int MAX_COUNT = 5 * 1024 * 1024; - private static final int DEFAULT_APP_VERSION = 1; - - private static final String TAG = "DiskLruCacheHelper"; - - private DiskLruCache mDiskLruCache; - - public DiskLruCacheHelper(Context context) throws IOException { - mDiskLruCache = generateCache(context, DIR_NAME, MAX_COUNT); - } - - public DiskLruCacheHelper(Context context, String dirName) throws IOException { - mDiskLruCache = generateCache(context, dirName, MAX_COUNT); - } - - public DiskLruCacheHelper(Context context, String dirName, int maxCount) throws IOException { - mDiskLruCache = generateCache(context, dirName, maxCount); - } - - //custom cache dir - public DiskLruCacheHelper(File dir) throws IOException { - mDiskLruCache = generateCache(null, dir, MAX_COUNT); - } - - public DiskLruCacheHelper(Context context, File dir) throws IOException { - mDiskLruCache = generateCache(context, dir, MAX_COUNT); - } - - public DiskLruCacheHelper(Context context, File dir, int maxCount) throws IOException { - mDiskLruCache = generateCache(context, dir, maxCount); - } - - private DiskLruCache generateCache(Context context, File dir, int maxCount) throws IOException { - if (!dir.exists() || !dir.isDirectory()) { - throw new IllegalArgumentException( - dir + " is not a directory or does not exists. "); - } - - int appVersion = context == null ? DEFAULT_APP_VERSION : Utils.getAppVersion(context); - - DiskLruCache diskLruCache = DiskLruCache.open( - dir, - appVersion, - DEFAULT_APP_VERSION, - maxCount); - - return diskLruCache; - } - - private DiskLruCache generateCache(Context context, String dirName, int maxCount) throws IOException { - DiskLruCache diskLruCache = DiskLruCache.open( - getDiskCacheDir(context, dirName), - Utils.getAppVersion(context), - DEFAULT_APP_VERSION, - maxCount); - return diskLruCache; - } - // ======================================= - // ============== String 数据 读写 ============= - // ======================================= - - public void put(String key, String value) { - DiskLruCache.Editor edit = null; - BufferedWriter bw = null; - try { - edit = editor(key); - if (edit == null) return; - OutputStream os = edit.newOutputStream(0); - bw = new BufferedWriter(new OutputStreamWriter(os)); - bw.write(value); - edit.commit();//write CLEAN - } catch (IOException e) { - e.printStackTrace(); - try { - //s - edit.abort();//write REMOVE - } catch (IOException e1) { - e1.printStackTrace(); - } - } finally { - try { - if (bw != null) - bw.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - public String getAsString(String key) { - InputStream inputStream = null; - try { - //write READ - inputStream = get(key); - if (inputStream == null) return null; - StringBuilder sb = new StringBuilder(); - int len = 0; - byte[] buf = new byte[128]; - while ((len = inputStream.read(buf)) != -1) { - sb.append(new String(buf, 0, len)); - } - return sb.toString(); - - - } catch (IOException e) { - e.printStackTrace(); - if (inputStream != null) - try { - inputStream.close(); - } catch (IOException e1) { - e1.printStackTrace(); - } - } - return null; - } - - - public void put(String key, JSONObject jsonObject) { - put(key, jsonObject.toString()); - } - - public JSONObject getAsJson(String key) { - String val = getAsString(key); - try { - if (val != null) - return new JSONObject(val); - } catch (JSONException e) { - e.printStackTrace(); - } - return null; - } - - // ======================================= - // ============ JSONArray 数据 读写 ============= - // ======================================= - - public void put(String key, JSONArray jsonArray) { - put(key, jsonArray.toString()); - } - - public JSONArray getAsJSONArray(String key) { - String JSONString = getAsString(key); - try { - JSONArray obj = new JSONArray(JSONString); - return obj; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - // ======================================= - // ============== byte 数据 读写 ============= - // ======================================= - - /** - * 保存 byte数据 到 缓存中 - * - * @param key 保存的key - * @param value 保存的数据 - */ - public void put(String key, byte[] value) { - OutputStream out = null; - DiskLruCache.Editor editor = null; - try { - editor = editor(key); - if (editor == null) { - return; - } - out = editor.newOutputStream(0); - out.write(value); - out.flush(); - editor.commit();//write CLEAN - } catch (Exception e) { - e.printStackTrace(); - try { - editor.abort();//write REMOVE - } catch (IOException e1) { - e1.printStackTrace(); - } - - } finally { - if (out != null) { - try { - out.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - - public byte[] getAsBytes(String key) { - byte[] res = null; - InputStream is = get(key); - if (is == null) return null; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try { - byte[] buf = new byte[256]; - int len = 0; - while ((len = is.read(buf)) != -1) { - baos.write(buf, 0, len); - } - res = baos.toByteArray(); - } catch (IOException e) { - e.printStackTrace(); - } - return res; - } - - - // ======================================= - // ============== 序列化 数据 读写 ============= - // ======================================= - public void put(String key, Serializable value) { - DiskLruCache.Editor editor = editor(key); - ObjectOutputStream oos = null; - if (editor == null) return; - try { - OutputStream os = editor.newOutputStream(0); - oos = new ObjectOutputStream(os); - oos.writeObject(value); - oos.flush(); - editor.commit(); - } catch (IOException e) { - e.printStackTrace(); - try { - editor.abort(); - } catch (IOException e1) { - e1.printStackTrace(); - } - } finally { - try { - if (oos != null) - oos.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - public T getAsSerializable(String key) { - T t = null; - InputStream is = get(key); - ObjectInputStream ois = null; - if (is == null) return null; - try { - ois = new ObjectInputStream(is); - t = (T) ois.readObject(); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - try { - if (ois != null) - ois.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - return t; - } - - // ======================================= - // ============== bitmap 数据 读写 ============= - // ======================================= - public void put(String key, Bitmap bitmap) { - put(key, Utils.bitmap2Bytes(bitmap)); - } - - public Bitmap getAsBitmap(String key) { - byte[] bytes = getAsBytes(key); - if (bytes == null) return null; - return Utils.bytes2Bitmap(bytes); - } - - // ======================================= - // ============= drawable 数据 读写 ============= - // ======================================= - public void put(String key, Drawable value) { - put(key, Utils.drawable2Bitmap(value)); - } - - public Drawable getAsDrawable(String key) { - byte[] bytes = getAsBytes(key); - if (bytes == null) { - return null; - } - return Utils.bitmap2Drawable(Utils.bytes2Bitmap(bytes)); - } - - // ======================================= - // ============= other methods ============= - // ======================================= - public boolean remove(String key) { - try { - key = Utils.hashKeyForDisk(key); - return mDiskLruCache.remove(key); - } catch (IOException e) { - e.printStackTrace(); - } - return false; - } - - public void close() throws IOException { - mDiskLruCache.close(); - } - - public void delete() throws IOException { - mDiskLruCache.delete(); - } - - public void flush() throws IOException { - mDiskLruCache.flush(); - } - - public boolean isClosed() { - return mDiskLruCache.isClosed(); - } - - public long size() { - return mDiskLruCache.size(); - } - - public void setMaxSize(long maxSize) { - mDiskLruCache.setMaxSize(maxSize); - } - - public File getDirectory() { - return mDiskLruCache.getDirectory(); - } - - public long getMaxSize() { - return mDiskLruCache.getMaxSize(); - } - - - // ======================================= - // ===遇到文件比较大的,可以直接通过流读写 ===== - // ======================================= - //basic editor - public DiskLruCache.Editor editor(String key) { - try { - key = Utils.hashKeyForDisk(key); - //wirte DIRTY - DiskLruCache.Editor edit = mDiskLruCache.edit(key); - //edit maybe null :the entry is editing - if (edit == null) { - Log.w(TAG, "the entry spcified key:" + key + " is editing by other . "); - } - return edit; - } catch (IOException e) { - e.printStackTrace(); - } - - return null; - } - - - //basic get - public InputStream get(String key) { - try { - DiskLruCache.Snapshot snapshot = mDiskLruCache.get(Utils.hashKeyForDisk(key)); - if (snapshot == null) //not find entry , or entry.readable = false - { - Log.e(TAG, "not find entry , or entry.readable = false"); - return null; - } - //write READ - return snapshot.getInputStream(0); - - } catch (IOException e) { - e.printStackTrace(); - return null; - } - - } - - - // ======================================= - // ============== 序列化 数据 读写 ============= - // ======================================= - - private File getDiskCacheDir(Context context, String uniqueName) { - String cachePath; - if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) - || !Environment.isExternalStorageRemovable()) { - cachePath = context.getExternalCacheDir().getPath(); - } else { - cachePath = context.getCacheDir().getPath(); - } - return new File(cachePath + File.separator + uniqueName); - } - -} diff --git a/app/src/main/java/com/fuying/sn/manager/MyGlideModule.java b/app/src/main/java/com/fuying/sn/manager/MyGlideModule.java index 0113d3f..b8219d0 100644 --- a/app/src/main/java/com/fuying/sn/manager/MyGlideModule.java +++ b/app/src/main/java/com/fuying/sn/manager/MyGlideModule.java @@ -3,6 +3,7 @@ package com.fuying.sn.manager; import android.content.Context; import com.bumptech.glide.GlideBuilder; +import com.bumptech.glide.annotation.GlideModule; import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory; import com.bumptech.glide.module.AppGlideModule; import com.fuying.sn.utils.StorageUtils; @@ -10,7 +11,7 @@ import com.fuying.sn.utils.StorageUtils; /** * Created by Administrator on 2017/2/9. */ -@com.bumptech.glide.annotation.GlideModule +@GlideModule public class MyGlideModule extends AppGlideModule { @Override public void applyOptions(final Context context, GlideBuilder builder) { diff --git a/app/src/main/java/com/fuying/sn/network/NetInterfaceManager.java b/app/src/main/java/com/fuying/sn/network/NetInterfaceManager.java index 1951879..3b5a111 100644 --- a/app/src/main/java/com/fuying/sn/network/NetInterfaceManager.java +++ b/app/src/main/java/com/fuying/sn/network/NetInterfaceManager.java @@ -61,7 +61,6 @@ import com.fuying.sn.manager.time.db.AppUsageRecordEntity; import com.fuying.sn.network.api.AppApi; import com.fuying.sn.network.api.CommonApi; import com.fuying.sn.network.api.FileApi; -import com.fuying.sn.network.api.PublicIPApi; import com.fuying.sn.network.api.ScreenStateApi; import com.fuying.sn.network.api.SettingsApi; import com.fuying.sn.network.api.SnApi; @@ -662,70 +661,6 @@ public class NetInterfaceManager { * */ - public interface PublicIP { - void set(String ip); - } - - /** - * 获取设备公网IP - * - * @param publicIP - */ - private static String IpAddr = ""; - - public void getPublicIP(PublicIP publicIP) { - Retrofit retrofit = new Retrofit.Builder() - .client(getOkHttpClient()) - .baseUrl(UrlAddress.SHOUHU_CITYJSON) - .addConverterFactory(GsonConverterFactory.create()) - .addCallAdapterFactory(RxJava3CallAdapterFactory.create()) - .build(); - retrofit.create(PublicIPApi.class) - .getPublicIP() - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Observer() { - @Override - public void onSubscribe(Disposable d) { - Log.e("getPublicIP", "onSubscribe: "); - } - - @Override - public void onNext(ResponseBody responseBody) { - try { - String s = responseBody.string(); - Log.e("getPublicIP", "onNext: " + s); - if (!TextUtils.isEmpty(s)) { - //var returnCitySN = {"cip": "183.11.74.141", "cid": "440300", "cname": "广东省深圳市"}; - if (s.contains("{")) { - String jsonString = s.substring(s.indexOf("{"), s.lastIndexOf("}") + 1); - JsonObject jsonObject = JsonParser.parseString(jsonString).getAsJsonObject(); - String ip = jsonObject.get("cip").getAsString(); - if (!TextUtils.isEmpty(ip)) { - IpAddr = ip; - } - } - } - } catch (IOException e) { - e.printStackTrace(); - Log.e("getPublicIP", "IOException: " + e.getMessage()); - } - } - - @Override - public void onError(Throwable e) { - Log.e("getPublicIP", "onError: " + e.getMessage()); - } - - @Override - public void onComplete() { - Log.e("getPublicIP", "onComplete: "); - publicIP.set(IpAddr); - } - }); - - } - public interface ObserverCallback { void onSubscribe(Disposable d); diff --git a/app/src/main/java/com/fuying/sn/network/UrlAddress.java b/app/src/main/java/com/fuying/sn/network/UrlAddress.java index 80bb530..f16f801 100644 --- a/app/src/main/java/com/fuying/sn/network/UrlAddress.java +++ b/app/src/main/java/com/fuying/sn/network/UrlAddress.java @@ -75,6 +75,7 @@ public class UrlAddress { public final static String QUERY_APP_INSIDE = "control/queryAppInside"; /*获取是否为网课模式*/ public static final String GET_CLOUD_LESSON_SETTING = "Control/getCloudLessonSetting"; + /*获取app桌面管控配置*/ @Deprecated public final static String GET_APP_TIME_CONTROL = "Control/getAppTimeControl"; @@ -119,6 +120,5 @@ public class UrlAddress { /*应用使用记录*/ public static final String APP_USAGE_RECORD = "appUsageRecord"; - /*获取公网IP*/ - public static final String SHOUHU_CITYJSON = "http://pv.sohu.com/cityjson/"; + } diff --git a/app/src/main/java/com/fuying/sn/network/api/PublicIPApi.java b/app/src/main/java/com/fuying/sn/network/api/PublicIPApi.java deleted file mode 100644 index 37e9120..0000000 --- a/app/src/main/java/com/fuying/sn/network/api/PublicIPApi.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.fuying.sn.network.api; - - -import com.fuying.sn.network.UrlAddress; - -import io.reactivex.rxjava3.core.Observable; -import okhttp3.ResponseBody; -import retrofit2.http.GET; - -/** - * @author : fanhuitong - * e-mail : - * @date : 2021/10/1814:39 - * desc : - * version: 1.0 - */ -public interface PublicIPApi { - @GET(UrlAddress.SHOUHU_CITYJSON) - Observable getPublicIP(); -} diff --git a/app/src/main/java/com/fuying/sn/network/cache/RxCacheRequest.java b/app/src/main/java/com/fuying/sn/network/cache/RxCacheRequest.java deleted file mode 100644 index 10e0a06..0000000 --- a/app/src/main/java/com/fuying/sn/network/cache/RxCacheRequest.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.fuying.sn.network.cache; - -import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; -import io.reactivex.rxjava3.core.Observable; -import io.reactivex.rxjava3.schedulers.Schedulers; - -/** - * 优化后:无需手动传CacheKey,自动从请求获取 - */ -public class RxCacheRequest { - private static final RxCacheManager CACHE_MANAGER = RxCacheManager.getInstance(); - - /** - * 极简调用:仅需 网络请求Observable + 缓存过期时间 - * - * @param networkObservable 原始网络请求 - * @param expireTimeMillis 缓存有效期(毫秒) - * @return 带自动缓存的Observable - */ - public static Observable withCache(Observable networkObservable, String cacheKey, long expireTimeMillis) { - return Observable.defer(() -> { - - // 2. 读取缓存 - T cacheData = CACHE_MANAGER.getCache(cacheKey); - if (cacheData != null) { - return Observable.just(cacheData); - } - - // 3. 无缓存则发起网络请求,成功后缓存 - return networkObservable - .subscribeOn(Schedulers.io()) - .doOnNext(data -> CACHE_MANAGER.saveCache(cacheKey, data, expireTimeMillis)); - }) - .subscribeOn(Schedulers.io()) // 缓存IO切到子线程 - .observeOn(AndroidSchedulers.mainThread()); - } - -} diff --git a/app/src/main/java/com/fuying/sn/network/cache/RxTimeCacheManager.java b/app/src/main/java/com/fuying/sn/network/cache/RxTimeCacheManager.java deleted file mode 100644 index d81414e..0000000 --- a/app/src/main/java/com/fuying/sn/network/cache/RxTimeCacheManager.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.fuying.sn.network.cache; - -import java.util.concurrent.ConcurrentHashMap; - -import io.reactivex.rxjava3.core.Observable; -import io.reactivex.rxjava3.core.ObservableSource; -import io.reactivex.rxjava3.core.ObservableTransformer; - -public class RxTimeCacheManager { - - // Thread-safe memory cache to hold our data and its timestamp - private static final ConcurrentHashMap> cacheMap = new ConcurrentHashMap<>(); - - /** - * Industry Standard RxJava Cache Transformer. - * * @param cacheKey Unique key for this specific request (e.g., URL or Method Name) - * - * @param validTimeMillis How long the data is valid before a new network request is allowed - */ - public static ObservableTransformer applyCache(final String cacheKey, final long validTimeMillis) { - return new ObservableTransformer() { - @Override - public ObservableSource apply(Observable upstream) { - // defer() ensures this logic runs EVERY time someone subscribes, not at initialization - return Observable.defer(() -> { - CacheEntry entry = cacheMap.get(cacheKey); - long currentTime = System.currentTimeMillis(); - - // 1. Check if cache exists and is within the time limit - if (entry != null && (currentTime - entry.timestamp) < validTimeMillis) { - // Cache HIT -> Return cached data immediately, do not trigger network - @SuppressWarnings("unchecked") - T cachedData = (T) entry.data; - return Observable.just(cachedData); - } - - // 2. Cache MISS or EXPIRED -> Trigger upstream (network) and save result - return upstream.doOnNext(data -> { - // Save the fresh data and current timestamp back to the cache - cacheMap.put(cacheKey, new CacheEntry<>(data, System.currentTimeMillis())); - }); - }); - } - }; - } - - /** - * Clears a specific cache key if you need to force a refresh manually. - */ - public static void clearCache(String cacheKey) { - cacheMap.remove(cacheKey); - } - - /** - * Internal wrapper to hold the payload and the time it was fetched. - */ - private static class CacheEntry { - final T data; - final long timestamp; - - CacheEntry(T data, long timestamp) { - this.data = data; - this.timestamp = timestamp; - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/fuying/sn/receiver/APKinstallReceiver.java b/app/src/main/java/com/fuying/sn/receiver/ApkInstallReceiver.java similarity index 98% rename from app/src/main/java/com/fuying/sn/receiver/APKinstallReceiver.java rename to app/src/main/java/com/fuying/sn/receiver/ApkInstallReceiver.java index 99bb127..5c3c407 100644 --- a/app/src/main/java/com/fuying/sn/receiver/APKinstallReceiver.java +++ b/app/src/main/java/com/fuying/sn/receiver/ApkInstallReceiver.java @@ -21,7 +21,7 @@ import io.reactivex.rxjava3.core.ObservableEmitter; import io.reactivex.rxjava3.core.Observer; import io.reactivex.rxjava3.disposables.Disposable; -public class APKinstallReceiver extends BroadcastReceiver { +public class ApkInstallReceiver extends BroadcastReceiver { private static final String TAG = "APKinstallReceiver"; @SuppressLint("StaticFieldLeak") diff --git a/app/src/main/java/com/fuying/sn/service/ManagerService.java b/app/src/main/java/com/fuying/sn/service/ManagerService.java index b817d88..f0da19f 100644 --- a/app/src/main/java/com/fuying/sn/service/ManagerService.java +++ b/app/src/main/java/com/fuying/sn/service/ManagerService.java @@ -21,7 +21,6 @@ import android.widget.LinearLayout; import android.widget.TextView; import com.blankj.utilcode.util.NetworkUtils; -import com.fuying.sn.BuildConfig; import com.fuying.sn.R; import com.fuying.sn.bean.BaseResponse; import com.fuying.sn.config.CommonConfig; @@ -29,7 +28,7 @@ import com.fuying.sn.gson.GsonUtils; import com.fuying.sn.network.NetInterfaceManager; import com.fuying.sn.network.UrlAddress; import com.fuying.sn.push.PushManager; -import com.fuying.sn.receiver.APKinstallReceiver; +import com.fuying.sn.receiver.ApkInstallReceiver; import com.fuying.sn.receiver.BootReceiver; import com.fuying.sn.utils.SPUtils; import com.fuying.sn.utils.Utils; @@ -598,11 +597,11 @@ public class ManagerService extends Service implements NetworkUtils.OnNetworkSta }); } - private APKinstallReceiver apKinstallReceiver; + private ApkInstallReceiver apKinstallReceiver; private void registAppReceive() { if (null == apKinstallReceiver) { - apKinstallReceiver = new APKinstallReceiver(); + apKinstallReceiver = new ApkInstallReceiver(); } IntentFilter filter = new IntentFilter(); filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); diff --git a/app/src/main/java/com/fuying/sn/Statistics/AppInformation.java b/app/src/main/java/com/fuying/sn/statistics/AppInformation.java similarity index 99% rename from app/src/main/java/com/fuying/sn/Statistics/AppInformation.java rename to app/src/main/java/com/fuying/sn/statistics/AppInformation.java index 7740f2b..9b76d37 100644 --- a/app/src/main/java/com/fuying/sn/Statistics/AppInformation.java +++ b/app/src/main/java/com/fuying/sn/statistics/AppInformation.java @@ -1,4 +1,4 @@ -package com.fuying.sn.Statistics; +package com.fuying.sn.statistics; import android.annotation.TargetApi; import android.app.usage.UsageStats; diff --git a/app/src/main/java/com/fuying/sn/Statistics/StatisticsInfo.java b/app/src/main/java/com/fuying/sn/statistics/StatisticsInfo.java similarity index 99% rename from app/src/main/java/com/fuying/sn/Statistics/StatisticsInfo.java rename to app/src/main/java/com/fuying/sn/statistics/StatisticsInfo.java index b0c2d4a..3352898 100644 --- a/app/src/main/java/com/fuying/sn/Statistics/StatisticsInfo.java +++ b/app/src/main/java/com/fuying/sn/statistics/StatisticsInfo.java @@ -1,4 +1,4 @@ -package com.fuying.sn.Statistics; +package com.fuying.sn.statistics; import android.annotation.TargetApi; import android.app.usage.UsageEvents; diff --git a/app/src/main/java/com/fuying/sn/utils/AudioMngHelper.java b/app/src/main/java/com/fuying/sn/utils/AudioMngHelper.java deleted file mode 100644 index ae8a164..0000000 --- a/app/src/main/java/com/fuying/sn/utils/AudioMngHelper.java +++ /dev/null @@ -1,168 +0,0 @@ -package com.fuying.sn.utils; - - -import android.content.Context; -import android.media.AudioManager; - -import androidx.annotation.IntDef; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - *
- *     author: Chestnut
- *     blog  : http://www.jianshu.com/u/a0206b5f4526
- *     time  : 2017/6/17 16:11
- *     desc  :  集成音量控制
- *     thanks To:   http://blog.csdn.net/hufeng882412/article/details/7310131
- *     dependent on:
- *     update log:
- * 
- */ - -public class AudioMngHelper { - - private static final String TAG = "AudioMngHelper"; - private final boolean OpenLog = true; - - private AudioManager audioManager; - private int NOW_AUDIO_TYPE = TYPE_MUSIC; - private int NOW_FLAG = FLAG_NOTHING; - private int VOICE_STEP_100 = 2; //0-100的步进。 - - /** - * 封装:STREAM_类型 - */ - public final static int TYPE_MUSIC = AudioManager.STREAM_MUSIC; - public final static int TYPE_ALARM = AudioManager.STREAM_ALARM; - public final static int TYPE_RING = AudioManager.STREAM_RING; - - @IntDef({TYPE_MUSIC, TYPE_ALARM, TYPE_RING}) - @Retention(RetentionPolicy.SOURCE) - public @interface TYPE { - } - - /** - * 封装:FLAG - */ - public final static int FLAG_SHOW_UI = AudioManager.FLAG_SHOW_UI; - public final static int FLAG_PLAY_SOUND = AudioManager.FLAG_PLAY_SOUND; - public final static int FLAG_NOTHING = 0; - - @IntDef({FLAG_SHOW_UI, FLAG_PLAY_SOUND, FLAG_NOTHING}) - @Retention(RetentionPolicy.SOURCE) - public @interface FLAG { - } - - /** - * 初始化,获取音量管理者 - * - * @param context 上下文 - */ - public AudioMngHelper(Context context) { - audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); - } - - public int getSystemMaxVolume() { - return audioManager.getStreamMaxVolume(NOW_AUDIO_TYPE); - } - - public int getSystemCurrentVolume() { - return audioManager.getStreamVolume(NOW_AUDIO_TYPE); - } - - /** - * 以0-100为范围,获取当前的音量值 - * - * @return 获取当前的音量值 - */ - public int get100CurrentVolume() { - return 100 * getSystemCurrentVolume() / getSystemMaxVolume(); - } - - /** - * 修改步进值 - * - * @param step step - * @return this - */ - public AudioMngHelper setVoiceStep100(int step) { - VOICE_STEP_100 = step; - return this; - } - - /** - * 改变当前的模式,对全局API生效 - * - * @param type - * @return - */ - public AudioMngHelper setAudioType(@TYPE int type) { - NOW_AUDIO_TYPE = type; - return this; - } - - /** - * 改变当前FLAG,对全局API生效 - * - * @param flag - * @return - */ - public AudioMngHelper setFlag(@FLAG int flag) { - NOW_FLAG = flag; - return this; - } - - public AudioMngHelper addVoiceSystem() { - audioManager.adjustStreamVolume(NOW_AUDIO_TYPE, AudioManager.ADJUST_RAISE, NOW_FLAG); - return this; - } - - public AudioMngHelper subVoiceSystem() { - audioManager.adjustStreamVolume(NOW_AUDIO_TYPE, AudioManager.ADJUST_LOWER, NOW_FLAG); - return this; - } - - /** - * 调整音量,自定义 - * - * @param num 0-100 - * @return 改完后的音量值 - */ - public int setVoice100(int num) { - int a = (int) Math.ceil((num) * getSystemMaxVolume() * 0.01); - a = a <= 0 ? 0 : a; - a = a >= 100 ? 100 : a; - audioManager.setStreamVolume(NOW_AUDIO_TYPE, a, 0); - return get100CurrentVolume(); - } - - /** - * 步进加,步进值可修改 - * 0——100 - * - * @return 改完后的音量值 - */ - public int addVoice100() { - int a = (int) Math.ceil((VOICE_STEP_100 + get100CurrentVolume()) * getSystemMaxVolume() * 0.01); - a = a <= 0 ? 0 : a; - a = a >= 100 ? 100 : a; - audioManager.setStreamVolume(NOW_AUDIO_TYPE, a, NOW_FLAG); - return get100CurrentVolume(); - } - - /** - * 步进减,步进值可修改 - * 0——100 - * - * @return 改完后的音量值 - */ - public int subVoice100() { - int a = (int) Math.floor((get100CurrentVolume() - VOICE_STEP_100) * getSystemMaxVolume() * 0.01); - a = a <= 0 ? 0 : a; - a = a >= 100 ? 100 : a; - audioManager.setStreamVolume(NOW_AUDIO_TYPE, a, NOW_FLAG); - return get100CurrentVolume(); - } -} diff --git a/app/src/main/java/com/fuying/sn/utils/Hash.java b/app/src/main/java/com/fuying/sn/utils/Hash.java deleted file mode 100644 index ba4611c..0000000 --- a/app/src/main/java/com/fuying/sn/utils/Hash.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.fuying.sn.utils; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -public class Hash { - - private static final char[] hexCode = "0123456789ABCDEF".toCharArray(); - - public static String md5(String input) { - byte[] bytes = new byte[0]; - try { - bytes = MessageDigest.getInstance("MD5").digest(input.getBytes()); - return printHexBinary(bytes); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - return ""; - } - } - - public static String printHexBinary(byte[] data) { - StringBuilder r = new StringBuilder(data.length * 2); - for (byte b : data) { - r.append(hexCode[(b >> 4) & 0xF]); - r.append(hexCode[(b & 0xF)]); - } - return r.toString(); - } -} - - diff --git a/app/src/main/java/com/fuying/sn/utils/ReceiverCompat.java b/app/src/main/java/com/fuying/sn/utils/ReceiverCompat.java new file mode 100644 index 0000000..51fb129 --- /dev/null +++ b/app/src/main/java/com/fuying/sn/utils/ReceiverCompat.java @@ -0,0 +1,122 @@ +package com.fuying.sn.utils; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.os.Build; +import android.util.Log; + +/** + * 动态注册广播兼容工具。 + * + *

Android 13(API 33)起,动态注册的接收器若包含非系统保护广播,必须显式声明导出标志; + * Android 14+ 的系统(含各厂商定制 ROM,例如本机 Android 16)会强制校验,缺失时直接抛出: + *

+ * java.lang.SecurityException: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED
+ * should be specified when a receiver isn't being registered exclusively for system broadcasts
+ * 
+ * 该异常会导致 Activity / Service 创建失败(启动闪退),并进一步造成前台服务 + * {@code startForegroundService()} 超时 ANR。 + * + *

说明:本工程通过 {@code app/libs/framework.jar} 提供系统隐藏 API(该 jar 为 + * Android 10 / API 29 的 framework),其中已包含 + * {@code registerReceiver(BroadcastReceiver, IntentFilter, int)} 等带 flags 的重载, + * 因此这里直接调用即可,无需反射;在低版本系统中未知标志位会被忽略, + * 行为与改造前的两参注册保持一致。 + * + *

标志选择建议: + *

    + *
  • {@link #RECEIVER_NOT_EXPORTED}:只接收系统广播,或本应用 + * (含共享 {@code android.uid.system} 的兄弟应用)发送的广播;
  • + *
  • {@link #RECEIVER_EXPORTED}:需要接收其它(不同 UID 的)应用发送的广播, + * 与改造前两参 {@code registerReceiver} 的默认行为一致。
  • + *
+ * + * @author LiGuangMin + */ +public final class ReceiverCompat { + + private static final String TAG = "ReceiverCompat"; + + /** + * 对应 Context.RECEIVER_EXPORTED(API 33)。 + */ + public static final int RECEIVER_EXPORTED = 0x00000002; + + /** + * 对应 Context.RECEIVER_NOT_EXPORTED(API 33)。 + */ + public static final int RECEIVER_NOT_EXPORTED = 0x00000004; + + /** + * 带导出标志的注册重载从 API 33 开始对应用生效。 + * 此处不使用 {@code Build.VERSION_CODES.TIRAMISU},因为 framework.jar 只到 API 29。 + */ + private static final int FLAGS_API = 33; + + private ReceiverCompat() { + } + + /** + * 兼容注册,等价于 {@code registerReceiver(receiver, filter)}, + * 但在 API 33+ 上显式带上导出标志。 + */ + public static Intent registerReceiver(Context context, BroadcastReceiver receiver, + IntentFilter filter, int flags) { + return registerReceiver(context, receiver, filter, flags, null); + } + + /** + * 安全注销广播接收器。 + * + *

系统自带的 {@code unregisterReceiver()} 在"接收器未注册过"或"重复注销"时会抛出 + * {@code IllegalArgumentException: Receiver not registered},直接导致进程崩溃; + * 而业务代码通常只能用字段是否为 null 来判断,字段非 null 并不代表注册成功 + * (例如注册过程中抛异常、Service 被销毁等场景)。这里统一做容错处理。 + * + * @param receiver 允许为 null + */ + public static void unregisterReceiver(Context context, BroadcastReceiver receiver) { + if (context == null || receiver == null) { + return; + } + try { + context.unregisterReceiver(receiver); + } catch (Exception e) { + Log.e(TAG, "unregisterReceiver failed: " + e); + } + } + + /** + * 兼容注册,等价于 + * {@code registerReceiver(receiver, filter, broadcastPermission, scheduler)}。 + * + * @param receiver 可以为 null,此时用于查询粘性广播 + * @param flags {@link #RECEIVER_EXPORTED} 或 {@link #RECEIVER_NOT_EXPORTED} + * @param broadcastPermission 发送方必须持有的权限,可为 null + */ + public static Intent registerReceiver(Context context, BroadcastReceiver receiver, + IntentFilter filter, int flags, + String broadcastPermission) { + if (context == null || filter == null) { + return null; + } + try { + if (Build.VERSION.SDK_INT >= FLAGS_API) { + return context.registerReceiver(receiver, filter, broadcastPermission, null, flags); + } + //Android 13 以下不支持导出标志,保持原有注册方式 + return context.registerReceiver(receiver, filter, broadcastPermission, null); + } catch (Exception e) { + //兜底:极端情况下(例如厂商裁剪了重载)退回到传统注册,避免直接崩溃 + Log.e(TAG, "registerReceiver failed, fallback to legacy: " + e); + try { + return context.registerReceiver(receiver, filter); + } catch (Exception inner) { + Log.e(TAG, "registerReceiver legacy failed: " + inner); + return null; + } + } + } +} diff --git a/app/src/main/java/com/fuying/sn/utils/Utils.java b/app/src/main/java/com/fuying/sn/utils/Utils.java index 3efae32..1c83be1 100644 --- a/app/src/main/java/com/fuying/sn/utils/Utils.java +++ b/app/src/main/java/com/fuying/sn/utils/Utils.java @@ -17,7 +17,6 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; -import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; @@ -49,12 +48,11 @@ import androidx.annotation.VisibleForTesting; import com.fuying.sn.BuildConfig; import com.fuying.sn.R; -import com.fuying.sn.Statistics.AppInformation; -import com.fuying.sn.Statistics.StatisticsInfo; +import com.fuying.sn.statistics.AppInformation; +import com.fuying.sn.statistics.StatisticsInfo; import com.fuying.sn.bean.AppUsed; import com.fuying.sn.config.CommonConfig; import com.fuying.sn.gson.GsonUtils; -import com.fuying.sn.network.NetInterfaceManager; import com.google.gson.JsonObject; import com.google.zxing.BarcodeFormat; import com.google.zxing.EncodeHintType; @@ -1339,21 +1337,6 @@ public class Utils { } } - /** - * 获取公网IP并保存 - * - * @param context - */ - public static void getPublicIP(Context context) { - NetInterfaceManager.getInstance().getPublicIP(new NetInterfaceManager.PublicIP() { - @Override - public void set(String ip) { - SPUtils.put(context, "PublicIP", ip); - Log.e("getPublicIP", "set: " + ip); - } - }); - } - /*重启自身*/ public static void triggerRebirth(Context context) { PackageManager packageManager = context.getPackageManager(); diff --git a/app/src/main/java/com/fuying/sn/view/FlowRadioGroup.java b/app/src/main/java/com/fuying/sn/view/FlowRadioGroup.java deleted file mode 100644 index d8466be..0000000 --- a/app/src/main/java/com/fuying/sn/view/FlowRadioGroup.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.fuying.sn.view; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.View; -import android.widget.RadioGroup; - -/** - * 流式布局的RadioGroup - */ -public class FlowRadioGroup extends RadioGroup { - - public FlowRadioGroup(Context context) { - super(context); - } - - public FlowRadioGroup(Context context, AttributeSet attrs) { - super(context, attrs); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int maxWidth = MeasureSpec.getSize(widthMeasureSpec); - int childCount = getChildCount(); - int x = 0; - int y = 0; - int row = 0; - - for (int index = 0; index < childCount; index++) { - final View child = getChildAt(index); - if (child.getVisibility() != View.GONE) { - child.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); - // 此处增加onlayout中的换行判断,用于计算所需的高度 - int width = child.getMeasuredWidth(); - int height = child.getMeasuredHeight(); - x += width; - y = row * height + height; - if (x > maxWidth) { - x = width; - row++; - y = row * height + height; - } - } - } - // 设置容器所需的宽度和高度 - setMeasuredDimension(maxWidth, y); - } - - @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - final int childCount = getChildCount(); - int maxWidth = r - l; - int x = 0; - int y = 0; - int row = 0; - for (int i = 0; i < childCount; i++) { - final View child = this.getChildAt(i); - if (child.getVisibility() != View.GONE) { - int width = child.getMeasuredWidth(); - int height = child.getMeasuredHeight(); - x += width; - y = row * height + height; - if (x > maxWidth) { - x = width; - row++; - y = row * height + height; - } - child.layout(x - width, y - height, x, y); - } - } - } -}