提交 39b266d8 编写于 作者: J jackjintai

Merge branch 'feature/platform'

# Conflicts:
#	Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/aop/urlconnection/HttpUrlConnectionProxyUtil.java
......@@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.novoda:bintray-release:0.9.2'
classpath "com.didichuxing.doraemonkit:doraemonkit-plugin:${rootProject.ext.android["pluginVersionName"]}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.ext.android["kotlin_version"]}"
......
......@@ -119,7 +119,7 @@ class DoraemonKitReal {
*/
static void install(final Application app, List<AbstractKit> selfKits, String productId) {
DokitConstant.PRODUCT_ID = productId;
DokitConstant.APP_HEALTH_RUNNING = GlobalConfig.getAppHealth(DoraemonKit.APPLICATION);
DokitConstant.APP_HEALTH_RUNNING = GlobalConfig.getAppHealth();
//添加常用工具
if (sHasInit) {
//已经初始化添加自定义kits
......@@ -149,7 +149,7 @@ class DoraemonKitReal {
Log.i(TAG, "======isMainProcess===");
String strDokitMode = SharedPrefsUtil.getString(app, SharedPrefsKey.FLOAT_START_MODE, "normal");
String strDokitMode = SharedPrefsUtil.getString(SharedPrefsKey.FLOAT_START_MODE, "normal");
if (strDokitMode.equals("normal")) {
DokitConstant.IS_NORMAL_FLOAT_MODE = true;
} else {
......@@ -307,10 +307,10 @@ class DoraemonKitReal {
private static void checkGPSMock() {
if (GpsMockConfig.isGPSMockOpen(APPLICATION)) {
if (GpsMockConfig.isGPSMockOpen()) {
GpsMockManager.getInstance().startMock();
}
LatLng latLng = GpsMockConfig.getMockLocation(APPLICATION);
LatLng latLng = GpsMockConfig.getMockLocation();
if (latLng == null) {
return;
}
......
......@@ -4,11 +4,9 @@ import com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.DoraemonInterc
import com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.DoraemonWeakNetworkInterceptor;
import com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.LargePictureInterceptor;
import com.didichuxing.doraemonkit.kit.network.okhttp.interceptor.MockInterceptor;
import com.didichuxing.doraemonkit.okgo.DokitOkGo;
import java.net.URL;
import java.net.URLConnection;
import java.util.concurrent.TimeUnit;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
......@@ -44,13 +42,14 @@ public class HttpUrlConnectionProxyUtil {
private static URLConnection createOkHttpURLConnection(URLConnection urlConnection) throws Exception {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
addInterceptor(builder);
OkHttpClient mClient = builder
.retryOnConnectionFailure(true)
//不需要再重复添加拦截器 因为已经通过字节码主如果拦截器了
//addInterceptor(builder);
OkHttpClient mClient = builder.
.retryOnConnectionFailure(true)
.readTimeout(DokitOkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS)
.writeTimeout(DokitOkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS)
.connectTimeout(DokitOkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS)
.build();
build();
String strUrl = urlConnection.getURL().toString();
URL url = new URL(strUrl);
......@@ -70,19 +69,20 @@ public class HttpUrlConnectionProxyUtil {
private static void addInterceptor(OkHttpClient.Builder builder) {
// 判断当前是否已经添加了拦截器,如果已添加则返回
for (Interceptor interceptor : builder.interceptors()) {
if (interceptor instanceof DoraemonInterceptor) {
if (interceptor instanceof MockInterceptor) {
return;
}
}
builder
//添加mock拦截器
.addInterceptor(new MockInterceptor())
//添加大图检测拦截器
.addInterceptor(new LargePictureInterceptor())
//添加弱网 拦截器
.addNetworkInterceptor(new DoraemonWeakNetworkInterceptor())
//添加dokit拦截器
.addInterceptor(new DoraemonInterceptor());
.addInterceptor(new DoraemonInterceptor())
//添加弱网 拦截器
.addNetworkInterceptor(new DoraemonWeakNetworkInterceptor());
}
/**
......
package com.didichuxing.doraemonkit.config;
import android.content.Context;
import com.didichuxing.doraemonkit.constant.SharedPrefsKey;
import com.didichuxing.doraemonkit.util.SharedPrefsUtil;
......@@ -9,11 +7,11 @@ import com.didichuxing.doraemonkit.util.SharedPrefsUtil;
* @author wanglikun
*/
public class AlignRulerConfig {
public static boolean isAlignRulerOpen(Context context) {
return SharedPrefsUtil.getBoolean(context, SharedPrefsKey.ALIGN_RULER_OPEN, false);
public static boolean isAlignRulerOpen() {
return SharedPrefsUtil.getBoolean(SharedPrefsKey.ALIGN_RULER_OPEN, false);
}
public static void setAlignRulerOpen(Context context, boolean open) {
SharedPrefsUtil.putBoolean(context, SharedPrefsKey.ALIGN_RULER_OPEN, open);
public static void setAlignRulerOpen(boolean open) {
SharedPrefsUtil.putBoolean(SharedPrefsKey.ALIGN_RULER_OPEN, open);
}
}
\ No newline at end of file
package com.didichuxing.doraemonkit.config;
import android.content.Context;
import com.didichuxing.doraemonkit.constant.SharedPrefsKey;
import com.didichuxing.doraemonkit.util.SharedPrefsUtil;
......@@ -9,11 +7,11 @@ import com.didichuxing.doraemonkit.util.SharedPrefsUtil;
* @author wanglikun
*/
public class ColorPickConfig {
public static boolean isColorPickOpen(Context context) {
return SharedPrefsUtil.getBoolean(context, SharedPrefsKey.COLOR_PICK_OPEN, false);
public static boolean isColorPickOpen() {
return SharedPrefsUtil.getBoolean(SharedPrefsKey.COLOR_PICK_OPEN, false);
}
public static void setColorPickOpen(Context context, boolean open) {
SharedPrefsUtil.putBoolean(context, SharedPrefsKey.COLOR_PICK_OPEN, open);
public static void setColorPickOpen(boolean open) {
SharedPrefsUtil.putBoolean(SharedPrefsKey.COLOR_PICK_OPEN, open);
}
}
\ No newline at end of file
package com.didichuxing.doraemonkit.config;
import android.content.Context;
import android.os.Environment;
import com.didichuxing.doraemonkit.constant.SharedPrefsKey;
import com.didichuxing.doraemonkit.util.SharedPrefsUtil;
public class CrashCaptureConfig {
public static boolean isCrashCaptureOpen(Context context) {
return SharedPrefsUtil.getBoolean(context, SharedPrefsKey.CRASH_CAPTURE_OPEN, false);
public static boolean isCrashCaptureOpen() {
return SharedPrefsUtil.getBoolean(SharedPrefsKey.CRASH_CAPTURE_OPEN, false);
}
public static void setCrashCaptureOpen(Context context, boolean open) {
SharedPrefsUtil.putBoolean(context, SharedPrefsKey.CRASH_CAPTURE_OPEN, open);
public static void setCrashCaptureOpen(boolean open) {
SharedPrefsUtil.putBoolean(SharedPrefsKey.CRASH_CAPTURE_OPEN, open);
}
}
package com.didichuxing.doraemonkit.config;
import android.content.Context;
import com.didichuxing.doraemonkit.constant.SharedPrefsKey;
import com.didichuxing.doraemonkit.util.SharedPrefsUtil;
......@@ -11,19 +9,19 @@ import com.didichuxing.doraemonkit.util.SharedPrefsUtil;
public class FloatIconConfig {
public static int getLastPosX(Context context) {
return SharedPrefsUtil.getInt(context, SharedPrefsKey.FLOAT_ICON_POS_X, 0);
public static int getLastPosX() {
return SharedPrefsUtil.getInt(SharedPrefsKey.FLOAT_ICON_POS_X, 0);
}
public static int getLastPosY(Context context) {
return SharedPrefsUtil.getInt(context, SharedPrefsKey.FLOAT_ICON_POS_Y, 0);
public static int getLastPosY() {
return SharedPrefsUtil.getInt(SharedPrefsKey.FLOAT_ICON_POS_Y, 0);
}
public static void saveLastPosY(Context context, int val) {
SharedPrefsUtil.putInt(context, SharedPrefsKey.FLOAT_ICON_POS_Y, val);
public static void saveLastPosY(int val) {
SharedPrefsUtil.putInt(SharedPrefsKey.FLOAT_ICON_POS_Y, val);
}
public static void saveLastPosX(Context context, int val) {
SharedPrefsUtil.putInt(context, SharedPrefsKey.FLOAT_ICON_POS_X, val);
public static void saveLastPosX(int val) {
SharedPrefsUtil.putInt(SharedPrefsKey.FLOAT_ICON_POS_X, val);
}
}
......@@ -18,19 +18,16 @@ public class GlobalConfig {
/**
* 设置健康体检
*
* @param context
* @param isRunning
*/
public static void setAppHealth(Context context, boolean isRunning) {
SharedPrefsUtil.putBoolean(context, SharedPrefsKey.APP_HEALTH, isRunning);
public static void setAppHealth(boolean isRunning) {
SharedPrefsUtil.putBoolean(SharedPrefsKey.APP_HEALTH, isRunning);
}
/**
* 获得app 健康体检功能的本地状态
*
* @param context
*/
public static boolean getAppHealth(Context context) {
return SharedPrefsUtil.getBoolean(context, SharedPrefsKey.APP_HEALTH, false);
public static boolean getAppHealth() {
return SharedPrefsUtil.getBoolean(SharedPrefsKey.APP_HEALTH, false);
}
}
package com.didichuxing.doraemonkit.config;
import android.content.Context;
import com.didichuxing.doraemonkit.constant.CachesKey;
import com.didichuxing.doraemonkit.constant.SharedPrefsKey;
import com.didichuxing.doraemonkit.model.LatLng;
......@@ -13,19 +11,25 @@ import com.didichuxing.doraemonkit.util.SharedPrefsUtil;
*/
public class GpsMockConfig {
public static boolean isGPSMockOpen(Context context) {
return SharedPrefsUtil.getBoolean(context, SharedPrefsKey.GPS_MOCK_OPEN, false);
/**
* @return
*/
public static boolean isGPSMockOpen() {
return SharedPrefsUtil.getBoolean(SharedPrefsKey.GPS_MOCK_OPEN, false);
}
public static void setGPSMockOpen(Context context, boolean open) {
SharedPrefsUtil.putBoolean(context, SharedPrefsKey.GPS_MOCK_OPEN, open);
/**
* @param open
*/
public static void setGPSMockOpen(boolean open) {
SharedPrefsUtil.putBoolean(SharedPrefsKey.GPS_MOCK_OPEN, open);
}
public static LatLng getMockLocation(Context context) {
return (LatLng) CacheUtils.readObject(context, CachesKey.MOCK_LOCATION);
public static LatLng getMockLocation() {
return (LatLng) CacheUtils.readObject(CachesKey.MOCK_LOCATION);
}
public static void saveMockLocation(Context context, LatLng latLng) {
CacheUtils.saveObject(context, CachesKey.MOCK_LOCATION, latLng);
public static void saveMockLocation(LatLng latLng) {
CacheUtils.saveObject(CachesKey.MOCK_LOCATION, latLng);
}
}
\ No newline at end of file
package com.didichuxing.doraemonkit.config;
import android.content.Context;
import com.didichuxing.doraemonkit.constant.SharedPrefsKey;
import com.didichuxing.doraemonkit.util.SharedPrefsUtil;
......@@ -9,11 +7,11 @@ import com.didichuxing.doraemonkit.util.SharedPrefsUtil;
* @author wanglikun
*/
public class LogInfoConfig {
public static boolean isLogInfoOpen(Context context) {
return SharedPrefsUtil.getBoolean(context, SharedPrefsKey.LOG_INFO_OPEN, false);
public static boolean isLogInfoOpen() {
return SharedPrefsUtil.getBoolean(SharedPrefsKey.LOG_INFO_OPEN, false);
}
public static void setLogInfoOpen(Context context, boolean open) {
SharedPrefsUtil.putBoolean(context, SharedPrefsKey.LOG_INFO_OPEN, open);
public static void setLogInfoOpen(boolean open) {
SharedPrefsUtil.putBoolean(SharedPrefsKey.LOG_INFO_OPEN, open);
}
}
\ No newline at end of file
......@@ -13,59 +13,57 @@ import com.didichuxing.doraemonkit.util.SharedPrefsUtil;
*/
public class PerformanceSpInfoConfig {
public static boolean isFPSOpen(Context context) {
public static boolean isFPSOpen() {
// return false;
return SharedPrefsUtil.getBoolean(context, SharedPrefsKey.FRAME_INFO_FPS_OPEN, false);
return SharedPrefsUtil.getBoolean(SharedPrefsKey.FRAME_INFO_FPS_OPEN, false);
}
public static void setFPSOpen(Context context, boolean open) {
SharedPrefsUtil.putBoolean(context, SharedPrefsKey.FRAME_INFO_FPS_OPEN, open);
public static void setFPSOpen(boolean open) {
SharedPrefsUtil.putBoolean(SharedPrefsKey.FRAME_INFO_FPS_OPEN, open);
}
public static boolean isCPUOpen(Context context) {
public static boolean isCPUOpen() {
// return false;
return SharedPrefsUtil.getBoolean(context, SharedPrefsKey.FRAME_INFO_CPU_OPEN, false);
return SharedPrefsUtil.getBoolean(SharedPrefsKey.FRAME_INFO_CPU_OPEN, false);
}
public static void setCPUOpen(Context context, boolean open) {
SharedPrefsUtil.putBoolean(context, SharedPrefsKey.FRAME_INFO_CPU_OPEN, open);
public static void setCPUOpen(boolean open) {
SharedPrefsUtil.putBoolean(SharedPrefsKey.FRAME_INFO_CPU_OPEN, open);
}
public static boolean isMemoryOpen(Context context) {
public static boolean isMemoryOpen() {
// return false;
return SharedPrefsUtil.getBoolean(context, SharedPrefsKey.FRAME_INFO_MEMORY_OPEN, false);
return SharedPrefsUtil.getBoolean(SharedPrefsKey.FRAME_INFO_MEMORY_OPEN, false);
}
public static void setMemoryOpen(Context context, boolean open) {
SharedPrefsUtil.putBoolean(context, SharedPrefsKey.FRAME_INFO_MEMORY_OPEN, open);
public static void setMemoryOpen(boolean open) {
SharedPrefsUtil.putBoolean(SharedPrefsKey.FRAME_INFO_MEMORY_OPEN, open);
}
public static boolean isTrafficOpen(Context context) {
return SharedPrefsUtil.getBoolean(context, SharedPrefsKey.FRAME_INFO_TRAFFIC_OPEN, false);
public static boolean isTrafficOpen() {
return SharedPrefsUtil.getBoolean(SharedPrefsKey.FRAME_INFO_TRAFFIC_OPEN, false);
}
public static void setTrafficOpen(Context context, boolean open) {
SharedPrefsUtil.putBoolean(context, SharedPrefsKey.FRAME_INFO_TRAFFIC_OPEN, open);
public static void setTrafficOpen(boolean open) {
SharedPrefsUtil.putBoolean(SharedPrefsKey.FRAME_INFO_TRAFFIC_OPEN, open);
}
/**
* 是否显示性能检测UI开关
*
* @param context
* @return
*/
public static boolean isFrameUiOpen(Context context) {
return SharedPrefsUtil.getBoolean(context, SharedPrefsKey.FRAME_INFO_UI_OPEN, false);
public static boolean isFrameUiOpen() {
return SharedPrefsUtil.getBoolean(SharedPrefsKey.FRAME_INFO_UI_OPEN, false);
}
/**
* 设置显示性能检测UI开关
*
* @param context
* @return
*/
public static void setFrameUiOpen(Context context, boolean open) {
SharedPrefsUtil.putBoolean(context, SharedPrefsKey.FRAME_INFO_UI_OPEN, open);
public static void setFrameUiOpen(boolean open) {
SharedPrefsUtil.putBoolean(SharedPrefsKey.FRAME_INFO_UI_OPEN, open);
}
/**
......@@ -74,7 +72,7 @@ public class PerformanceSpInfoConfig {
* @return
*/
public static boolean isLargeImgOpen() {
return SharedPrefsUtil.getBoolean(DoraemonKit.APPLICATION, SharedPrefsKey.LARGE_IMG_OPEN, false);
return SharedPrefsUtil.getBoolean(SharedPrefsKey.LARGE_IMG_OPEN, false);
}
/**
......@@ -83,18 +81,17 @@ public class PerformanceSpInfoConfig {
* @param open
*/
public static void setLargeImgOpen(boolean open) {
SharedPrefsUtil.putBoolean(DoraemonKit.APPLICATION, SharedPrefsKey.LARGE_IMG_OPEN, open);
SharedPrefsUtil.putBoolean(SharedPrefsKey.LARGE_IMG_OPEN, open);
}
/**
* 设置大图内存阈值
*
* @param context
* @param threshold
*/
public static void setLargeImgMemoryThreshold(Context context, float threshold) {
SharedPrefsUtil.putFloat(context, SharedPrefsKey.LARGE_IMG_MEMORY_THRESHOLD, threshold);
public static void setLargeImgMemoryThreshold(float threshold) {
SharedPrefsUtil.putFloat(SharedPrefsKey.LARGE_IMG_MEMORY_THRESHOLD, threshold);
LargePictureManager.getInstance().setMemoryThreshold(threshold);
}
......@@ -102,32 +99,29 @@ public class PerformanceSpInfoConfig {
/**
* 获得大图内存阈值
*
* @param context
* @param threshold
*/
public static double getLargeImgMemoryThreshold(Context context, float threshold) {
return SharedPrefsUtil.getFloat(context, SharedPrefsKey.LARGE_IMG_MEMORY_THRESHOLD, threshold);
public static double getLargeImgMemoryThreshold(float threshold) {
return SharedPrefsUtil.getFloat(SharedPrefsKey.LARGE_IMG_MEMORY_THRESHOLD, threshold);
}
/**
* 设置大图文件阈值
*
* @param context
* @param threshold
*/
public static void setLargeImgFileThreshold(Context context, float threshold) {
SharedPrefsUtil.putFloat(context, SharedPrefsKey.LARGE_IMG_FILE_THRESHOLD, threshold);
public static void setLargeImgFileThreshold(float threshold) {
SharedPrefsUtil.putFloat(SharedPrefsKey.LARGE_IMG_FILE_THRESHOLD, threshold);
LargePictureManager.getInstance().setFileThreshold(threshold);
}
/**
* 获得大图文件阈值
*
* @param context
* @param threshold
*/
public static double getLargeImgFileThreshold(Context context, float threshold) {
return SharedPrefsUtil.getFloat(context, SharedPrefsKey.LARGE_IMG_FILE_THRESHOLD, threshold);
public static double getLargeImgFileThreshold(float threshold) {
return SharedPrefsUtil.getFloat(SharedPrefsKey.LARGE_IMG_FILE_THRESHOLD, threshold);
}
}
......@@ -9,11 +9,11 @@ import com.didichuxing.doraemonkit.util.SharedPrefsUtil;
* Created by wanglikun on 2018/12/28
*/
public class ViewCheckConfig {
public static boolean isViewCheckOpen(Context context) {
return SharedPrefsUtil.getBoolean(context, SharedPrefsKey.VIEW_CHECK_OPEN, false);
public static boolean isViewCheckOpen() {
return SharedPrefsUtil.getBoolean(SharedPrefsKey.VIEW_CHECK_OPEN, false);
}
public static void setViewCheckOpen(Context context, boolean open) {
SharedPrefsUtil.putBoolean(context, SharedPrefsKey.VIEW_CHECK_OPEN, open);
public static void setViewCheckOpen(boolean open) {
SharedPrefsUtil.putBoolean(SharedPrefsKey.VIEW_CHECK_OPEN, open);
}
}
......@@ -37,7 +37,7 @@ public class DokitConstant {
/**
* 是否处于健康体检中
*/
public static boolean APP_HEALTH_RUNNING = GlobalConfig.getAppHealth(DoraemonKit.APPLICATION);
public static boolean APP_HEALTH_RUNNING = GlobalConfig.getAppHealth();
/**
* 是否是普通的浮标模式
......
......@@ -81,7 +81,7 @@ public class AlignRulerInfoDokitView extends AbsDokitView implements AlignRulerM
mClose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlignRulerConfig.setAlignRulerOpen(getContext(), false);
AlignRulerConfig.setAlignRulerOpen(false);
DokitViewManager.getInstance().detach(AlignRulerMarkerDokitView.class.getSimpleName());
DokitViewManager.getInstance().detach(AlignRulerLineDokitView.class.getSimpleName());
DokitViewManager.getInstance().detach(AlignRulerInfoDokitView.class.getSimpleName());
......
......@@ -46,12 +46,12 @@ public class AlignRulerKit extends AbstractKit {
DokitViewManager.getInstance().attach(pageIntent);
AlignRulerConfig.setAlignRulerOpen(context, true);
AlignRulerConfig.setAlignRulerOpen(true);
}
@Override
public void onAppInit(Context context) {
AlignRulerConfig.setAlignRulerOpen(context, false);
AlignRulerConfig.setAlignRulerOpen(false);
}
@Override
......
......@@ -43,7 +43,7 @@ public class AlignRulerSettingFragment extends BaseFragment {
mSettingList = findViewById(R.id.setting_list);
mSettingList.setLayoutManager(new LinearLayoutManager(getContext()));
mSettingItemAdapter = new SettingItemAdapter(getContext());
mSettingItemAdapter.append(new SettingItem(R.string.dk_kit_align_ruler, AlignRulerConfig.isAlignRulerOpen(getContext())));
mSettingItemAdapter.append(new SettingItem(R.string.dk_kit_align_ruler, AlignRulerConfig.isAlignRulerOpen()));
mSettingList.setAdapter(mSettingItemAdapter);
mSettingItemAdapter.setOnSettingItemSwitchListener(new SettingItemAdapter.OnSettingItemSwitchListener() {
@Override
......@@ -57,7 +57,7 @@ public class AlignRulerSettingFragment extends BaseFragment {
DokitViewManager.getInstance().detach(AlignRulerMarkerDokitView.class);
DokitViewManager.getInstance().detach(AlignRulerLineDokitView.class);
}
AlignRulerConfig.setAlignRulerOpen(getContext(), on);
AlignRulerConfig.setAlignRulerOpen(on);
}
}
});
......
......@@ -2,7 +2,9 @@ package com.didichuxing.doraemonkit.kit.colorpick;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import androidx.annotation.ColorInt;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
......@@ -59,7 +61,7 @@ public class ColorPickerInfoDokitView extends AbsDokitView {
@Override
public void onClick(View v) {
ColorPickManager.getInstance().setColorPickerDokitView(null);
ColorPickConfig.setColorPickOpen(getContext(), false);
ColorPickConfig.setColorPickOpen(false);
DokitViewManager.getInstance().detach(ColorPickerDokitView.class.getSimpleName());
DokitViewManager.getInstance().detach(ColorPickerInfoDokitView.class.getSimpleName());
//取色器kit是依赖在当前透明的Activity上的 所以关闭控件时需要finish
......
......@@ -44,7 +44,7 @@ public class ColorPickerKit extends AbstractKit {
@Override
public void onAppInit(Context context) {
ColorPickConfig.setColorPickOpen(context, false);
ColorPickConfig.setColorPickOpen(false);
}
@Override
......
......@@ -5,8 +5,10 @@ import android.content.Context;
import android.content.Intent;
import android.media.projection.MediaProjectionManager;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.View;
import com.didichuxing.doraemonkit.R;
......@@ -30,7 +32,7 @@ public class ColorPickerSettingFragment extends BaseFragment {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (requestCaptureScreen()) {
ColorPickConfig.setColorPickOpen(getContext(), true);
ColorPickConfig.setColorPickOpen(true);
}
}
......
......@@ -13,8 +13,10 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.IdRes;
import androidx.annotation.StringRes;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
......@@ -429,11 +431,11 @@ public abstract class AbsDokitView implements DokitView, TouchProxy.OnTouchEvent
if (mTag.equals(MainIconDokitView.class.getSimpleName())) {
if (isNormalMode()) {
FloatIconConfig.saveLastPosX(getContext(), mFrameLayoutParams.leftMargin);
FloatIconConfig.saveLastPosY(getContext(), mFrameLayoutParams.topMargin);
FloatIconConfig.saveLastPosX(mFrameLayoutParams.leftMargin);
FloatIconConfig.saveLastPosY(mFrameLayoutParams.topMargin);
} else {
FloatIconConfig.saveLastPosX(getContext(), mWindowLayoutParams.x);
FloatIconConfig.saveLastPosY(getContext(), mWindowLayoutParams.y);
FloatIconConfig.saveLastPosX(mWindowLayoutParams.x);
FloatIconConfig.saveLastPosY(mWindowLayoutParams.y);
}
} else {
......@@ -606,8 +608,8 @@ public abstract class AbsDokitView implements DokitView, TouchProxy.OnTouchEvent
}
if (isActivityResume) {
if (tag.equals(MainIconDokitView.class.getSimpleName())) {
mFrameLayoutParams.leftMargin = FloatIconConfig.getLastPosX(getContext());
mFrameLayoutParams.topMargin = FloatIconConfig.getLastPosY(getContext());
mFrameLayoutParams.leftMargin = FloatIconConfig.getLastPosX();
mFrameLayoutParams.topMargin = FloatIconConfig.getLastPosY();
} else {
Point point = DokitViewManager.getInstance().getDokitViewPos(tag);
if (point != null) {
......
......@@ -35,7 +35,7 @@ public class CrashCaptureKit extends AbstractKit {
@Override
public void onAppInit(Context context) {
CrashCaptureManager.getInstance().init(context);
if (CrashCaptureConfig.isCrashCaptureOpen(context)) {
if (CrashCaptureConfig.isCrashCaptureOpen()) {
CrashCaptureManager.getInstance().start();
} else {
CrashCaptureManager.getInstance().stop();
......
package com.didichuxing.doraemonkit.kit.crash;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
......@@ -42,7 +43,7 @@ public class CrashCaptureMainFragment extends BaseFragment {
RecyclerView settingList = findViewById(R.id.setting_list);
settingList.setLayoutManager(new LinearLayoutManager(getContext()));
final SettingItemAdapter mSettingItemAdapter = new SettingItemAdapter(getContext());
mSettingItemAdapter.append(new SettingItem(R.string.dk_crash_capture_switch, CrashCaptureConfig.isCrashCaptureOpen(getContext())));
mSettingItemAdapter.append(new SettingItem(R.string.dk_crash_capture_switch, CrashCaptureConfig.isCrashCaptureOpen()));
mSettingItemAdapter.append(new SettingItem(R.string.dk_crash_capture_look, R.drawable.dk_more_icon));
SettingItem item = new SettingItem(R.string.dk_crash_capture_clean_data);
item.rightDesc = Formatter.formatFileSize(getContext(), FileUtil.getDirectorySize(CrashCaptureManager.getInstance().getCrashCacheDir()));
......@@ -51,7 +52,7 @@ public class CrashCaptureMainFragment extends BaseFragment {
@Override
public void onSettingItemSwitch(View view, SettingItem data, boolean on) {
if (data.desc == R.string.dk_crash_capture_switch) {
CrashCaptureConfig.setCrashCaptureOpen(getContext(), on);
CrashCaptureConfig.setCrashCaptureOpen(on);
if (on) {
CrashCaptureManager.getInstance().start();
} else {
......
......@@ -13,6 +13,7 @@ import com.didichuxing.doraemonkit.util.CacheUtils;
import com.didichuxing.doraemonkit.util.FileUtil;
import java.io.File;
import java.io.Serializable;
import java.util.Date;
/**
......@@ -56,7 +57,7 @@ public class CrashCaptureManager implements Thread.UncaughtExceptionHandler {
@Override
public void uncaughtException(final Thread t, final Throwable e) {
//保存崩溃信息
CacheUtils.saveObject(Log.getStackTraceString(e), getCrashCacheFile());
CacheUtils.saveObject((Serializable) Log.getStackTraceString(e), getCrashCacheFile());
//保存埋点数据
DataPickManager.getInstance().saveData2Local();
post(new Runnable() {
......
......@@ -2,6 +2,7 @@ package com.didichuxing.doraemonkit.kit.fileexplorer;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.DividerItemDecoration;
......@@ -42,7 +43,7 @@ public class SpFragment extends BaseFragment {
return spBeans;
}
spTableName = mFile.getName().replace(XML, "");
SharedPreferences sp = SharedPrefsUtil.getSharedPrefs(getActivity(), spTableName);
SharedPreferences sp = SharedPrefsUtil.getSharedPrefs(spTableName);
edit = sp.edit();
Map<String, ?> all = sp.getAll();
if (all.isEmpty()) {
......@@ -98,19 +99,19 @@ public class SpFragment extends BaseFragment {
String key = bean.key;
switch (bean.value.getClass().getSimpleName()) {
case SpInputType.STRING:
SharedPrefsUtil.putString(getActivity(), key, bean.value.toString());
SharedPrefsUtil.putString(key, bean.value.toString());
break;
case SpInputType.BOOLEAN:
SharedPrefsUtil.putBoolean(getActivity(), spTableName, key, (Boolean) bean.value);
SharedPrefsUtil.putBoolean(spTableName, key, (Boolean) bean.value);
break;
case SpInputType.INTEGER:
SharedPrefsUtil.putInt(getActivity(), spTableName, key, (Integer) bean.value);
SharedPrefsUtil.putInt(spTableName, key, (Integer) bean.value);
break;
case SpInputType.FLOAT:
SharedPrefsUtil.putFloat(getActivity(), spTableName, key, (Float) bean.value);
SharedPrefsUtil.putFloat(spTableName, key, (Float) bean.value);
break;
case SpInputType.LONG:
SharedPrefsUtil.putLong(getActivity(), spTableName, key, (Long) bean.value);
SharedPrefsUtil.putLong(spTableName, key, (Long) bean.value);
break;
default:
break;
......
......@@ -96,7 +96,7 @@ public class GpsMockFragment extends BaseFragment implements SettingItemAdapter.
}
GpsMockManager.getInstance().mockLocation(latitude, longitude);
GpsMockConfig.saveMockLocation(getContext(), new LatLng(latitude, longitude));
GpsMockConfig.saveMockLocation(new LatLng(latitude, longitude));
//刷新地图
String url = String.format("javascript:updateLocation(%s,%s)", latitude, longitude);
mWebView.loadUrl(url);
......@@ -157,7 +157,7 @@ public class GpsMockFragment extends BaseFragment implements SettingItemAdapter.
mSettingList.setLayoutManager(layoutManager);
List<SettingItem> settingItems = new ArrayList<>();
settingItems.add(new SettingItem(R.string.dk_gpsmock_open,
GpsMockConfig.isGPSMockOpen(getContext())));
GpsMockConfig.isGPSMockOpen()));
mSettingItemAdapter = new SettingItemAdapter(getContext());
mSettingItemAdapter.setData(settingItems);
mSettingItemAdapter.setOnSettingItemSwitchListener(this);
......@@ -175,7 +175,7 @@ public class GpsMockFragment extends BaseFragment implements SettingItemAdapter.
} else {
GpsMockManager.getInstance().stopMock();
}
GpsMockConfig.setGPSMockOpen(getContext(), on);
GpsMockConfig.setGPSMockOpen(on);
}
}
......@@ -212,7 +212,7 @@ public class GpsMockFragment extends BaseFragment implements SettingItemAdapter.
}
GpsMockManager.getInstance().mockLocation(latitude, longitude);
GpsMockConfig.saveMockLocation(getContext(), new LatLng(latitude, longitude));
GpsMockConfig.saveMockLocation(new LatLng(latitude, longitude));
ToastUtils.showShort(getString(R.string.dk_gps_location_change_toast, "" + longitude, "" + latitude));
}
......
......@@ -363,7 +363,7 @@ public class AppHealthInfoUtil {
//卡顿
BlockMonitorManager.getInstance().start();
//crash 开关
CrashCaptureConfig.setCrashCaptureOpen(DoraemonKit.APPLICATION, true);
CrashCaptureConfig.setCrashCaptureOpen(true);
CrashCaptureManager.getInstance().start();
}
......@@ -382,7 +382,7 @@ public class AppHealthInfoUtil {
//卡顿
BlockMonitorManager.getInstance().stop();
//crash 开关
CrashCaptureConfig.setCrashCaptureOpen(DoraemonKit.APPLICATION, false);
CrashCaptureConfig.setCrashCaptureOpen(false);
CrashCaptureManager.getInstance().stop();
}
......
......@@ -65,7 +65,7 @@ public class HealthFragmentChild0 extends BaseFragment {
LogHelper.i(TAG, "上传成功===>" + response.body());
ToastUtils.showShort(DokitUtil.getString(R.string.dk_health_upload_successed));
//重置状态
GlobalConfig.setAppHealth(DoraemonKit.APPLICATION, false);
GlobalConfig.setAppHealth(false);
DokitConstant.APP_HEALTH_RUNNING = false;
mTitle.setVisibility(View.INVISIBLE);
mController.setImageResource(R.drawable.dk_health_start);
......@@ -98,7 +98,7 @@ public class HealthFragmentChild0 extends BaseFragment {
public void onCancel() {
ToastUtils.showShort(DokitUtil.getString(R.string.dk_health_upload_droped));
//重置状态
GlobalConfig.setAppHealth(DoraemonKit.APPLICATION, false);
GlobalConfig.setAppHealth(false);
DokitConstant.APP_HEALTH_RUNNING = false;
mTitle.setVisibility(View.INVISIBLE);
mController.setImageResource(R.drawable.dk_health_start);
......@@ -128,7 +128,7 @@ public class HealthFragmentChild0 extends BaseFragment {
dialog.dismiss();
if (mController != null) {
ToastUtils.showShort(DokitUtil.getString(R.string.dk_health_funcation_start));
GlobalConfig.setAppHealth(DoraemonKit.APPLICATION, true);
GlobalConfig.setAppHealth(true);
DokitConstant.APP_HEALTH_RUNNING = true;
//重启app
mController.postDelayed(new Runnable() {
......
package com.didichuxing.doraemonkit.kit.largepicture;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
......@@ -67,8 +68,8 @@ public class LargeImageListFragment extends BaseFragment {
});
}
private double fileThreshold = PerformanceSpInfoConfig.getLargeImgFileThreshold(DoraemonKit.APPLICATION, LargePictureManager.FILE_DEFAULT_THRESHOLD);
private double memoryThreshold = PerformanceSpInfoConfig.getLargeImgMemoryThreshold(DoraemonKit.APPLICATION, LargePictureManager.MEMORY_DEFAULT_THRESHOLD);
private double fileThreshold = PerformanceSpInfoConfig.getLargeImgFileThreshold(LargePictureManager.FILE_DEFAULT_THRESHOLD);
private double memoryThreshold = PerformanceSpInfoConfig.getLargeImgMemoryThreshold(LargePictureManager.MEMORY_DEFAULT_THRESHOLD);
private void load() {
......
......@@ -80,7 +80,7 @@ public class LargePictureFragment extends BaseFragment {
float value = Float.parseFloat(s.toString());
float formateValue = Float.parseFloat(mDecimalFormat.format(value));
//设置文件大小
PerformanceSpInfoConfig.setLargeImgFileThreshold(getActivity(), formateValue);
PerformanceSpInfoConfig.setLargeImgFileThreshold(formateValue);
} catch (Exception e) {
e.printStackTrace();
}
......@@ -115,17 +115,17 @@ public class LargePictureFragment extends BaseFragment {
float value = Float.parseFloat(s.toString());
float formateValue = Float.parseFloat(mDecimalFormat.format(value));
//设置内存大小
PerformanceSpInfoConfig.setLargeImgMemoryThreshold(getActivity(), formateValue);
PerformanceSpInfoConfig.setLargeImgMemoryThreshold(formateValue);
} catch (Exception e) {
e.printStackTrace();
}
}
});
double fileThreshold = PerformanceSpInfoConfig.getLargeImgFileThreshold(getActivity(), LargePictureManager.FILE_DEFAULT_THRESHOLD);
double fileThreshold = PerformanceSpInfoConfig.getLargeImgFileThreshold(LargePictureManager.FILE_DEFAULT_THRESHOLD);
fileEditText.setText(mDecimalFormat.format(fileThreshold));
double memoryThreshold = PerformanceSpInfoConfig.getLargeImgMemoryThreshold(getActivity(), LargePictureManager.MEMORY_DEFAULT_THRESHOLD);
double memoryThreshold = PerformanceSpInfoConfig.getLargeImgMemoryThreshold(LargePictureManager.MEMORY_DEFAULT_THRESHOLD);
memoryEditText.setText(mDecimalFormat.format(memoryThreshold));
......
......@@ -17,8 +17,8 @@ import java.util.Map;
public class LargePictureManager {
public static float MEMORY_DEFAULT_THRESHOLD = 1.0f;
public static float FILE_DEFAULT_THRESHOLD = 150.0f;
private double fileThreshold = PerformanceSpInfoConfig.getLargeImgFileThreshold(DoraemonKit.APPLICATION, FILE_DEFAULT_THRESHOLD);
private double memoryThreshold = PerformanceSpInfoConfig.getLargeImgMemoryThreshold(DoraemonKit.APPLICATION, MEMORY_DEFAULT_THRESHOLD);
private double fileThreshold = PerformanceSpInfoConfig.getLargeImgFileThreshold(FILE_DEFAULT_THRESHOLD);
private double memoryThreshold = PerformanceSpInfoConfig.getLargeImgMemoryThreshold(MEMORY_DEFAULT_THRESHOLD);
private static final String TAG = "LargePictureManager";
private DecimalFormat mDecimalFormat = new DecimalFormat("0.00");
......
......@@ -21,23 +21,23 @@ public class LogInfoKit extends AbstractKit {
@Override
public int getName() {
return R.string.dk_kit_log_info;
return R.string.dk_kit_log_info;
}
@Override
public int getIcon() {
return R.drawable.dk_log_info;
return R.drawable.dk_log_info;
}
@Override
public void onClick(Context context) {
startUniversalActivity(context,FragmentIndex.FRAGMENT_LOG_INFO_SETTING);
startUniversalActivity(context, FragmentIndex.FRAGMENT_LOG_INFO_SETTING);
}
@Override
public void onAppInit(Context context) {
LogInfoConfig.setLogInfoOpen(context, false);
LogInfoConfig.setLogInfoOpen(false);
}
@Override
......
......@@ -43,7 +43,7 @@ public class LogInfoSettingFragment extends BaseFragment {
mSettingList = findViewById(R.id.setting_list);
mSettingList.setLayoutManager(new LinearLayoutManager(getContext()));
mSettingItemAdapter = new SettingItemAdapter(getContext());
mSettingItemAdapter.append(new SettingItem(R.string.dk_kit_log_info, LogInfoConfig.isLogInfoOpen(getContext())));
mSettingItemAdapter.append(new SettingItem(R.string.dk_kit_log_info, LogInfoConfig.isLogInfoOpen()));
mSettingItemAdapter.setOnSettingItemSwitchListener(new SettingItemAdapter.OnSettingItemSwitchListener() {
@Override
public void onSettingItemSwitch(View view, SettingItem data, boolean on) {
......@@ -61,7 +61,7 @@ public class LogInfoSettingFragment extends BaseFragment {
//清空回调
LogInfoManager.getInstance().removeListener();
}
LogInfoConfig.setLogInfoOpen(getContext(), on);
LogInfoConfig.setLogInfoOpen(on);
}
}
});
......
......@@ -147,10 +147,10 @@ public class GroupKitAdapter extends AbsRecyclerAdapter<AbsViewBinder<List<KitIt
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId == R.id.rb_normal) {
//选中normal
SharedPrefsUtil.putString(mContext, SharedPrefsKey.FLOAT_START_MODE, "normal");
SharedPrefsUtil.putString(SharedPrefsKey.FLOAT_START_MODE, "normal");
} else {
//选中系统
SharedPrefsUtil.putString(mContext, SharedPrefsKey.FLOAT_START_MODE, "system");
SharedPrefsUtil.putString(SharedPrefsKey.FLOAT_START_MODE, "system");
}
}
});
......@@ -183,7 +183,7 @@ public class GroupKitAdapter extends AbsRecyclerAdapter<AbsViewBinder<List<KitIt
}
});
String floatMode = SharedPrefsUtil.getString(mContext, SharedPrefsKey.FLOAT_START_MODE, "normal");
String floatMode = SharedPrefsUtil.getString(SharedPrefsKey.FLOAT_START_MODE, "normal");
if (floatMode.equals("normal")) {
rbNormal.setChecked(true);
} else {
......
......@@ -53,8 +53,8 @@ public class MainIconDokitView extends AbsDokitView {
@Override
public void initDokitViewLayoutParams(DokitViewLayoutParams params) {
params.x = FloatIconConfig.getLastPosX(getContext());
params.y = FloatIconConfig.getLastPosY(getContext());
params.x = FloatIconConfig.getLastPosX();
params.y = FloatIconConfig.getLastPosY();
params.width = FLOAT_SIZE;
params.height = FLOAT_SIZE;
}
......
......@@ -111,7 +111,7 @@ public class ViewCheckInfoDokitView extends AbsDokitView implements
@Override
public void onClick(View v) {
if (v == mClose) {
ViewCheckConfig.setViewCheckOpen(getContext(), false);
ViewCheckConfig.setViewCheckOpen( false);
DokitViewManager.getInstance().detach(ViewCheckDrawDokitView.class.getSimpleName());
DokitViewManager.getInstance().detach(ViewCheckInfoDokitView.class.getSimpleName());
DokitViewManager.getInstance().detach(ViewCheckDokitView.class.getSimpleName());
......
......@@ -46,12 +46,12 @@ public class ViewCheckerKit extends AbstractKit {
DokitViewManager.getInstance().attach(intent);
ViewCheckConfig.setViewCheckOpen(context, true);
ViewCheckConfig.setViewCheckOpen(true);
}
@Override
public void onAppInit(Context context) {
ViewCheckConfig.setViewCheckOpen(context, false);
ViewCheckConfig.setViewCheckOpen(false);
}
@Override
......
......@@ -4,6 +4,7 @@ import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
......@@ -83,7 +84,7 @@ public class WebDoorFragment extends BaseFragment {
findViewById(R.id.clear).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
WebDoorManager.getInstance().clearHistory(getContext());
WebDoorManager.getInstance().clearHistory();
mWebDoorHistoryAdapter.clear();
}
});
......@@ -103,7 +104,7 @@ public class WebDoorFragment extends BaseFragment {
mHistoryList.setNestedScrollingEnabled(false);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
mHistoryList.setLayoutManager(layoutManager);
List<String> historyItems = WebDoorManager.getInstance().getHistory(getContext());
List<String> historyItems = WebDoorManager.getInstance().getHistory();
mWebDoorHistoryAdapter = new WebDoorHistoryAdapter(getContext());
mWebDoorHistoryAdapter.setData(historyItems);
......@@ -120,9 +121,9 @@ public class WebDoorFragment extends BaseFragment {
}
private void doSearch(String url) {
WebDoorManager.getInstance().saveHistory(getContext(), url);
WebDoorManager.getInstance().saveHistory(url);
WebDoorManager.getInstance().getWebDoorCallback().overrideUrlLoading(getContext(), url);
mWebDoorHistoryAdapter.setData(WebDoorManager.getInstance().getHistory(getContext()));
mWebDoorHistoryAdapter.setData(WebDoorManager.getInstance().getHistory());
}
private boolean checkInput() {
......
......@@ -32,9 +32,9 @@ public class WebDoorManager {
mWebDoorCallback = null;
}
public void saveHistory(Context context, String text) {
public void saveHistory(String text) {
if (mHistory == null) {
mHistory = (ArrayList<String>) CacheUtils.readObject(context, CachesKey.WEB_DOOR_HISTORY);
mHistory = (ArrayList<String>) CacheUtils.readObject(CachesKey.WEB_DOOR_HISTORY);
}
if (mHistory == null) {
mHistory = new ArrayList<>();
......@@ -46,12 +46,12 @@ public class WebDoorManager {
mHistory.remove(0);
}
mHistory.add(text);
CacheUtils.saveObject(context, CachesKey.WEB_DOOR_HISTORY, mHistory);
CacheUtils.saveObject(CachesKey.WEB_DOOR_HISTORY, mHistory);
}
public ArrayList<String> getHistory(Context context) {
public ArrayList<String> getHistory() {
if (mHistory == null) {
mHistory = (ArrayList<String>) CacheUtils.readObject(context, CachesKey.WEB_DOOR_HISTORY);
mHistory = (ArrayList<String>) CacheUtils.readObject(CachesKey.WEB_DOOR_HISTORY);
}
if (mHistory == null) {
mHistory = new ArrayList<>();
......@@ -59,9 +59,9 @@ public class WebDoorManager {
return mHistory;
}
public void clearHistory(Context context) {
public void clearHistory() {
mHistory.clear();
CacheUtils.saveObject(context, CachesKey.WEB_DOOR_HISTORY, mHistory);
CacheUtils.saveObject(CachesKey.WEB_DOOR_HISTORY, mHistory);
}
private static class Holder {
......
package com.didichuxing.doraemonkit.util;
import android.content.Context;
import com.blankj.utilcode.util.Utils;
import java.io.File;
import java.io.FileInputStream;
......@@ -17,11 +17,9 @@ import java.io.Serializable;
public class CacheUtils {
private static final String TAG = "CacheUtils";
private CacheUtils() {
}
public static boolean saveObject(Context context, String key, Serializable ser) {
File file = new File(context.getCacheDir() + "/" + key);
public static boolean saveObject(String key, Serializable ser) {
File file = new File(Utils.getApp().getCacheDir() + "/" + key);
if (!file.exists()) {
try {
file.createNewFile();
......@@ -32,8 +30,8 @@ public class CacheUtils {
return saveObject(ser, file);
}
public static Serializable readObject(Context context, String key) {
File file = new File(context.getCacheDir() + "/" + key);
public static Serializable readObject(String key) {
File file = new File(Utils.getApp().getCacheDir() + "/" + key);
return readObject(file);
}
......
......@@ -2,8 +2,11 @@ package com.didichuxing.doraemonkit.util;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.Nullable;
import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.Utils;
import com.didichuxing.doraemonkit.constant.SharedPrefsKey;
import static com.didichuxing.doraemonkit.constant.SharedPrefsKey.APP_HEALTH;
......@@ -18,76 +21,103 @@ public class SharedPrefsUtil {
*/
private static final String SHARED_PREFS_DORAEMON = "shared_prefs_doraemon";
private static SharedPreferences getSharedPrefs(Context context) {
return getSharedPrefs(context, SHARED_PREFS_DORAEMON);
private static SharedPreferences getSharedPrefs() {
return getSharedPrefs(SHARED_PREFS_DORAEMON);
}
@Nullable
public static SharedPreferences getSharedPrefs(Context context, String name) {
return context.getSharedPreferences(name, Context.MODE_PRIVATE);
public static SharedPreferences getSharedPrefs(String name) {
return Utils.getApp().getSharedPreferences(name, Context.MODE_PRIVATE);
}
public static String getString(Context context, String key, String defVal) {
return getSharedPrefs(context).getString(key, defVal);
public static String getString(String key, String defVal) {
return getSharedPrefs().getString(key, defVal);
}
public static void putString(Context context, String key, String value) {
putString(context, SHARED_PREFS_DORAEMON, key, value);
public static void putString(String key, String value) {
putString(SHARED_PREFS_DORAEMON, key, value);
}
public static void putString(Context context, String table, String key, String value) {
if (key.equals(SHARED_PREFS_DORAEMON)) {
getSharedPrefs(context, table).edit().putString(key, value).commit();
} else {
getSharedPrefs(context, table).edit().putString(key, value).apply();
public static void putString(String table, String key, String value) {
try {
if (getSharedPrefs(table) != null) {
if (key.equals(SHARED_PREFS_DORAEMON)) {
getSharedPrefs(table).edit().putString(key, value).commit();
} else {
getSharedPrefs(table).edit().putString(key, value).apply();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void putBoolean(Context context, String key, boolean value) {
if (context == null) {
return;
}
putBoolean(context, SHARED_PREFS_DORAEMON, key, value);
public static void putBoolean(String key, boolean value) {
putBoolean(SHARED_PREFS_DORAEMON, key, value);
}
public static void putBoolean(Context context, String table, String key, boolean value) {
if (key.equals(SharedPrefsKey.APP_HEALTH)) {
getSharedPrefs(context, table).edit().putBoolean(key, value).commit();
} else {
getSharedPrefs(context, table).edit().putBoolean(key, value).apply();
public static void putBoolean(String table, String key, boolean value) {
try {
if (getSharedPrefs(table) != null) {
if (key.equals(SharedPrefsKey.APP_HEALTH)) {
getSharedPrefs(table).edit().putBoolean(key, value).commit();
} else {
getSharedPrefs(table).edit().putBoolean(key, value).apply();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static boolean getBoolean(Context context, String key, boolean defVal) {
return context != null && getSharedPrefs(context).getBoolean(key, defVal);
public static boolean getBoolean(String key, boolean defVal) {
return getSharedPrefs().getBoolean(key, defVal);
}
public static void putInt(Context context, String key, int value) {
putInt(context, SHARED_PREFS_DORAEMON, key, value);
public static void putInt(String key, int value) {
putInt(SHARED_PREFS_DORAEMON, key, value);
}
public static void putInt(Context context, String table, String key, Integer value) {
getSharedPrefs(context, table).edit().putInt(key, value).apply();
public static void putInt(String table, String key, Integer value) {
try {
getSharedPrefs(table).edit().putInt(key, value).apply();
} catch (Exception e) {
e.printStackTrace();
}
}
public static int getInt(Context context, String key, int defVal) {
return getSharedPrefs(context).getInt(key, defVal);
public static int getInt(String key, int defVal) {
return getSharedPrefs().getInt(key, defVal);
}
public static void putFloat(Context context, String table, String key, Float value) {
getSharedPrefs(context, table).edit().putFloat(key, value).apply();
public static void putFloat(String table, String key, Float value) {
try {
getSharedPrefs(table).edit().putFloat(key, value).apply();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void putFloat(Context context, String key, Float value) {
getSharedPrefs(context, SHARED_PREFS_DORAEMON).edit().putFloat(key, value).apply();
public static void putFloat(String key, Float value) {
try {
getSharedPrefs(SHARED_PREFS_DORAEMON).edit().putFloat(key, value).apply();
} catch (Exception e) {
e.printStackTrace();
}
}
public static float getFloat(Context context, String key, Float value) {
return getSharedPrefs(context).getFloat(key, value);
public static float getFloat(String key, Float value) {
return getSharedPrefs().getFloat(key, value);
}
public static void putLong(Context context, String table, String key, Long value) {
getSharedPrefs(context, table).edit().putLong(key, value).apply();
public static void putLong(String table, String key, Long value) {
try {
getSharedPrefs(table).edit().putLong(key, value).apply();
} catch (Exception e) {
e.printStackTrace();
}
}
......
......@@ -22,7 +22,7 @@ public class WebUtil {
view.postDelayed(new Runnable() {
@Override
public void run() {
LatLng latLng = GpsMockConfig.getMockLocation(view.getContext());
LatLng latLng = GpsMockConfig.getMockLocation();
if (latLng == null) {
latLng = new LatLng(0, 0);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册