Commit 8041fa43 by YKai

feat: 友盟库升级优化,储存工具拓展

parent 14967758
...@@ -33,7 +33,7 @@ ext { ...@@ -33,7 +33,7 @@ ext {
//-------------- 功能组件 -------------- //-------------- 功能组件 --------------
//第一步 //第一步
"ydl-platform" : "0.0.41.56", "ydl-platform" : "0.0.41.57",
//第二步 若干 //第二步 若干
"ydl-webview" : "0.0.38.57", "ydl-webview" : "0.0.38.57",
...@@ -116,7 +116,7 @@ ext { ...@@ -116,7 +116,7 @@ ext {
//-------------- 功能组件 -------------- //-------------- 功能组件 --------------
//第一步 //第一步
"ydl-platform" : "0.0.41.56", "ydl-platform" : "0.0.41.57",
//第二步 若干 //第二步 若干
"ydl-webview" : "0.0.38.57", "ydl-webview" : "0.0.38.57",
...@@ -230,17 +230,17 @@ ext { ...@@ -230,17 +230,17 @@ ext {
"BaseRecyclerViewAdapterHelper": "com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.34", "BaseRecyclerViewAdapterHelper": "com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.34",
"flowlayout" : "cn.lankton:flowlayout:3.1.0", "flowlayout" : "cn.lankton:flowlayout:3.1.0",
"androidanimations" : "com.daimajia.androidanimations:library:2.3@aar", "androidanimations" : "com.daimajia.androidanimations:library:2.3@aar",
//友盟统计 // //友盟统计
"umeng-common" : "com.umeng.umsdk:common:9.3.8", "umeng-common" : "com.umeng.umsdk:common:9.4.7",
"umeng-asms" : "com.umeng.umsdk:asms:1.2.2", "umeng-asms" : "com.umeng.umsdk:asms:1.4.1",
//友盟社会化分享 // //友盟社会化分享
"umeng-share-core" : "com.umeng.umsdk:share-core:7.1.4", // "umeng-share-core" : "com.umeng.umsdk:share-core:7.1.4",
"umeng-share-qq" : "com.umeng.umsdk:share-qq:7.1.4", // "umeng-share-qq" : "com.umeng.umsdk:share-qq:7.1.4",
"umeng-share-wechat" : "com.umeng.umsdk:share-wx:7.1.4", // "umeng-share-wechat" : "com.umeng.umsdk:share-wx:7.1.4",
//分享面板 // //分享面板
"umeng-shareboard" : "com.umeng.umsdk:share-board:7.1.4", // "umeng-shareboard" : "com.umeng.umsdk:share-board:7.1.4",
"umeng-wx-guanfang" : "com.tencent.mm.opensdk:wechat-sdk-android-without-mta:6.6.5", // "umeng-wx-guanfang" : "com.tencent.mm.opensdk:wechat-sdk-android-without-mta:6.6.5",
"umeng-qq-guanfang" : "com.tencent.tauth:qqopensdk:3.51.2", // "umeng-qq-guanfang" : "com.tencent.tauth:qqopensdk:3.51.2",
//删除集成调试库,其功能合并到umeng基础组件库。 //删除集成调试库,其功能合并到umeng基础组件库。
//"umeng-debug" : "com.umeng.sdk:debug:1.0.0", //"umeng-debug" : "com.umeng.sdk:debug:1.0.0",
......
...@@ -143,12 +143,12 @@ dependencies { ...@@ -143,12 +143,12 @@ dependencies {
api rootProject.ext.dependencies["eventbus"] api rootProject.ext.dependencies["eventbus"]
api rootProject.ext.dependencies["umeng-common"] api rootProject.ext.dependencies["umeng-common"]
api rootProject.ext.dependencies["umeng-asms"] api rootProject.ext.dependencies["umeng-asms"]
api rootProject.ext.dependencies["umeng-share-core"] // api rootProject.ext.dependencies["umeng-share-core"]
api rootProject.ext.dependencies["umeng-share-qq"] // api rootProject.ext.dependencies["umeng-share-qq"]
api rootProject.ext.dependencies["umeng-share-wechat"] // api rootProject.ext.dependencies["umeng-share-wechat"]
api rootProject.ext.dependencies["umeng-shareboard"] // api rootProject.ext.dependencies["umeng-shareboard"]
api rootProject.ext.dependencies["umeng-wx-guanfang"] // api rootProject.ext.dependencies["umeng-wx-guanfang"]
api rootProject.ext.dependencies["umeng-qq-guanfang"] // api rootProject.ext.dependencies["umeng-qq-guanfang"]
api rootProject.ext.dependencies["stetho"] api rootProject.ext.dependencies["stetho"]
api rootProject.ext.dependencies["stetho-okhttp3"] api rootProject.ext.dependencies["stetho-okhttp3"]
api rootProject.ext.dependencies["bugly-crashreport"] api rootProject.ext.dependencies["bugly-crashreport"]
......
...@@ -37,71 +37,10 @@ import java.util.Collections; ...@@ -37,71 +37,10 @@ import java.util.Collections;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import static com.umeng.socialize.utils.ContextUtil.getPackageName;
public class DeviceTool { public class DeviceTool {
public static void openPersisonSetting(Activity activity) {
String brand = Build.BRAND;//手机厂商
if (TextUtils.equals(brand.toLowerCase(), "redmi") || TextUtils.equals(brand.toLowerCase(), "xiaomi")) {
gotoMiuiPermission(activity);//小米
} else if (TextUtils.equals(brand.toLowerCase(), "meizu")) {
gotoMeizuPermission(activity);
} else {
activity.startActivity(getAppDetailSettingIntent());
}
gotoMiuiPermission(activity);
}
/**
* 跳转到miui的权限管理页面
*/
private static void gotoMiuiPermission(Activity activity) {
Intent i = new Intent("miui.intent.action.APP_PERM_EDITOR");
ComponentName componentName = new ComponentName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
i.setComponent(componentName);
i.putExtra("extra_pkgname", getPackageName());
try {
activity.startActivity(i);
} catch (Exception e) {
e.printStackTrace();
gotoMeizuPermission(activity);
}
}
/**
* 获取应用详情页面intent
*
* @return
*/
private static Intent getAppDetailSettingIntent() {
Intent localIntent = new Intent();
localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (Build.VERSION.SDK_INT >= 9) {
localIntent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
localIntent.setData(Uri.fromParts("package", getPackageName(), null));
} else if (Build.VERSION.SDK_INT <= 8) {
localIntent.setAction(Intent.ACTION_VIEW);
localIntent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
localIntent.putExtra("com.android.settings.ApplicationPkgName", getPackageName());
}
return localIntent;
}
/**
* 跳转到魅族的权限管理系统
*/
private static void gotoMeizuPermission(Activity activity) {
Intent intent = new Intent("com.meizu.safe.security.SHOW_APPSEC");
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.putExtra("packageName", getPackageName());
try {
activity.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
activity.startActivity(getAppDetailSettingIntent());
}
}
//获取虚拟按键栏高度 //获取虚拟按键栏高度
public static int getNavigationBarHeight(Context context) { public static int getNavigationBarHeight(Context context) {
......
package com.ydl.ydlcommon.utils; package com.ydl.ydlcommon.utils;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import com.ydl.ydlcommon.base.BaseApp; import com.ydl.ydlcommon.base.BaseApp;
public class SharedPreferencesEditor { public class SharedPreferencesEditor {
private static final String app_sharedPreference_name = "yidianling_zj";
public static final String TEMP_TEST = "temp_test";//临时SP public static final String TEMP_TEST = "temp_test";//临时SP
/********************************************自定义文件存储***********************************************/ /********************************************自定义文件存储***********************************************/
...@@ -20,13 +22,34 @@ public class SharedPreferencesEditor { ...@@ -20,13 +22,34 @@ public class SharedPreferencesEditor {
editor.commit(); editor.commit();
} }
public static void putFileStringApply(String fileName,String key,String value) {
SharedPreferences mySharedPreferences = BaseApp.Companion.getApp().getSharedPreferences(
fileName, Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = mySharedPreferences.edit();
editor.putString(key, value);
editor.apply();
}
public static String getFileString(String fileName,String key) { public static String getFileString(String fileName,String key) {
SharedPreferences mySharedPreferences = BaseApp.Companion.getApp().getSharedPreferences( SharedPreferences mySharedPreferences = BaseApp.Companion.getApp().getSharedPreferences(
fileName, Activity.MODE_PRIVATE); fileName, Activity.MODE_PRIVATE);
return mySharedPreferences.getString(key, ""); return mySharedPreferences.getString(key, "");
} }
/***********************************************临时保存************************************************/ public static void writeSharedPreference(Context context, String key, String value) {
SharedPreferences mySharedPreferences = context.getSharedPreferences(
app_sharedPreference_name, Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = mySharedPreferences.edit();
editor.putString(key, value);
editor.commit();
}
public static String readSharedPreference(Context context, String key) {
SharedPreferences mySharedPreferences = context.getSharedPreferences(
app_sharedPreference_name, Activity.MODE_PRIVATE);
return mySharedPreferences.getString(key, "");
}
public static void putString(String key, String value) { public static void putString(String key, String value) {
SharedPreferences mySharedPreferences = BaseApp.Companion.getApp().getSharedPreferences( SharedPreferences mySharedPreferences = BaseApp.Companion.getApp().getSharedPreferences(
TEMP_TEST, Activity.MODE_PRIVATE); TEMP_TEST, Activity.MODE_PRIVATE);
...@@ -41,12 +64,62 @@ public class SharedPreferencesEditor { ...@@ -41,12 +64,62 @@ public class SharedPreferencesEditor {
return mySharedPreferences.getString(key, ""); return mySharedPreferences.getString(key, "");
} }
public static final void clear(){ public static void putBoolean(String key, boolean value) {
SharedPreferences mySharedPreferences = BaseApp.Companion.getApp().getSharedPreferences(
TEMP_TEST, Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = mySharedPreferences.edit();
editor.putBoolean(key, value);
editor.commit();
}
public static void putInt(String key, int value) {
SharedPreferences mySharedPreferences = BaseApp.Companion.getApp().getSharedPreferences(
TEMP_TEST, Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = mySharedPreferences.edit();
editor.putInt(key, value);
editor.commit();
}
SharedPreferences mySharedPreferencestemp = BaseApp.Companion.getApp().getSharedPreferences( public static boolean getBoolean(String key) {
SharedPreferences mySharedPreferences = BaseApp.Companion.getApp().getSharedPreferences(
TEMP_TEST, Activity.MODE_PRIVATE); TEMP_TEST, Activity.MODE_PRIVATE);
SharedPreferences.Editor editort = mySharedPreferencestemp.edit(); return mySharedPreferences.getBoolean(key, false);
editort.clear(); }
editort.commit();
public static int getInt(String key){
SharedPreferences mySharedPreferences = BaseApp.Companion.getApp().getSharedPreferences(
TEMP_TEST, Activity.MODE_PRIVATE);
return mySharedPreferences.getInt(key, 0);
}
public static void saveValue(Context context , String SPKey, String key, int val){
SharedPreferences sp = context.getSharedPreferences(SPKey, 0);
sp.edit().putInt(key, val).commit();
}
public static int getIntValueFromSP(Context context, String SPKey, String key){
SharedPreferences sp = context.getSharedPreferences(SPKey, 0);
return sp.getInt(key, 0);
}
public static void clearValues(Context context, String SPKey){
SharedPreferences sp = context.getSharedPreferences(SPKey, 0);
sp.edit().clear().commit();
}
public static final void clearByName(String name){
SharedPreferences mySharedPreferences = BaseApp.Companion.getApp().getSharedPreferences(
name, Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = mySharedPreferences.edit();
editor.clear();
editor.commit();
}
public static final void clear(){
SharedPreferences mySharedPreferences = BaseApp.Companion.getApp().getSharedPreferences(
app_sharedPreference_name, Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = mySharedPreferences.edit();
editor.clear();
editor.commit();
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment