Commit fc625291 authored by fallenstardust's avatar fallenstardust

test log

parent 250ff94b
...@@ -3,13 +3,10 @@ package cn.garymb.ygomobile; ...@@ -3,13 +3,10 @@ package cn.garymb.ygomobile;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Build;
import android.os.Environment; import android.os.Environment;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
import org.json.JSONArray; import org.json.JSONArray;
...@@ -39,11 +36,18 @@ import static cn.garymb.ygomobile.Constants.PREF_READ_EX; ...@@ -39,11 +36,18 @@ import static cn.garymb.ygomobile.Constants.PREF_READ_EX;
import static cn.garymb.ygomobile.Constants.PREF_SENSOR_REFRESH; import static cn.garymb.ygomobile.Constants.PREF_SENSOR_REFRESH;
public class AppsSettings { public class AppsSettings {
private static final String PREF_VERSION = "app_version";
private static AppsSettings sAppsSettings; private static AppsSettings sAppsSettings;
private Context context; private Context context;
private PreferenceFragmentPlus.SharedPreferencesPlus mSharedPreferences; private PreferenceFragmentPlus.SharedPreferencesPlus mSharedPreferences;
private float mScreenHeight, mScreenWidth, mDensity; private float mScreenHeight, mScreenWidth, mDensity;
private static final String PREF_VERSION = "app_version";
private AppsSettings(Context context) {
this.context = context;
mSharedPreferences = PreferenceFragmentPlus.SharedPreferencesPlus.create(context, context.getPackageName() + ".settings");
mSharedPreferences.setAutoSave(true);
update(context);
}
public static void init(Context context) { public static void init(Context context) {
if (sAppsSettings == null) { if (sAppsSettings == null) {
...@@ -55,15 +59,23 @@ public class AppsSettings { ...@@ -55,15 +59,23 @@ public class AppsSettings {
return sAppsSettings; return sAppsSettings;
} }
public File getSystemConfig() { //获取刘海屏的参数
return new File(getResourcePath(), CORE_SYSTEM_PATH); public static int[] getNotchSize(Context context) {
int[] notchSize = new int[]{0, 0};
try {
ClassLoader cl = context.getClassLoader();
Class HwNotchSizeUtil = cl.loadClass("com.huawei.android.util.HwNotchSizeUtil");
Method get = HwNotchSizeUtil.getMethod("getNotchSize");
notchSize = (int[]) get.invoke(HwNotchSizeUtil);
} catch (ClassNotFoundException e) {
Log.e("test", "getNotchSize ClassNotFoundException");
} catch (NoSuchMethodException e) {
Log.e("test", "getNotchSize NoSuchMethodException");
} catch (Exception e) {
Log.e("test", "getNotchSize Exception");
} finally {
return notchSize;
} }
private AppsSettings(Context context) {
this.context = context;
mSharedPreferences = PreferenceFragmentPlus.SharedPreferencesPlus.create(context, context.getPackageName() + ".settings");
mSharedPreferences.setAutoSave(true);
update(context);
} }
//检测是否存在刘海屏 //检测是否存在刘海屏
...@@ -85,25 +97,6 @@ public class AppsSettings { ...@@ -85,25 +97,6 @@ public class AppsSettings {
} }
} }
//获取刘海屏的参数
public static int[] getNotchSize(Context context) {
int[] notchSize = new int[]{0, 0};
try {
ClassLoader cl = context.getClassLoader();
Class HwNotchSizeUtil = cl.loadClass("com.huawei.android.util.HwNotchSizeUtil");
Method get = HwNotchSizeUtil.getMethod("getNotchSize");
notchSize = (int[]) get.invoke(HwNotchSizeUtil);
} catch (ClassNotFoundException e) {
Log.e("test", "getNotchSize ClassNotFoundException");
} catch (NoSuchMethodException e) {
Log.e("test", "getNotchSize NoSuchMethodException");
} catch (Exception e) {
Log.e("test", "getNotchSize Exception");
} finally {
return notchSize;
}
}
//获取系统状态栏高度 //获取系统状态栏高度
public static int getStatusBarHeight(Context context) { public static int getStatusBarHeight(Context context) {
int StatusBarHeight = 0; int StatusBarHeight = 0;
...@@ -114,6 +107,10 @@ public class AppsSettings { ...@@ -114,6 +107,10 @@ public class AppsSettings {
return StatusBarHeight; return StatusBarHeight;
} }
public File getSystemConfig() {
return new File(getResourcePath(), CORE_SYSTEM_PATH);
}
public void update(Context context) { public void update(Context context) {
mDensity = context.getResources().getDisplayMetrics().density; mDensity = context.getResources().getDisplayMetrics().density;
mScreenHeight = context.getResources().getDisplayMetrics().heightPixels; mScreenHeight = context.getResources().getDisplayMetrics().heightPixels;
...@@ -122,6 +119,10 @@ public class AppsSettings { ...@@ -122,6 +119,10 @@ public class AppsSettings {
DisplayMetrics dm = SystemUtils.getHasVirtualDisplayMetrics((Activity) context); DisplayMetrics dm = SystemUtils.getHasVirtualDisplayMetrics((Activity) context);
if (dm != null) { if (dm != null) {
int height = Math.max(dm.widthPixels, dm.heightPixels); int height = Math.max(dm.widthPixels, dm.heightPixels);
Log.i("机横屏height", "" + height);
if(dm.widthPixels / dm.heightPixels > 16/9 ) {
height = height - getStatusBarHeight(context);
}
if (mScreenHeight == Math.max(mScreenHeight, mScreenWidth)) { if (mScreenHeight == Math.max(mScreenHeight, mScreenWidth)) {
mScreenHeight = height; mScreenHeight = height;
} else { } else {
...@@ -129,10 +130,11 @@ public class AppsSettings { ...@@ -129,10 +130,11 @@ public class AppsSettings {
} }
} }
} }
if (!hasNotchInScreen(context)) { Log.i("机屏幕高度", "" + mScreenHeight);
Log.i("机屏幕宽度", "" + mScreenWidth);
} Log.i("机刘海高度", "" + getNotchSize(context));
Log.i("屏幕不算虚拟键", "" + mScreenHeight); Log.i("机状态栏高度", "" + getStatusBarHeight(context));
Log.i("机是否存在刘海",""+ hasNotchInScreen(context));
} }
public int getAppVersion() { public int getAppVersion() {
...@@ -386,10 +388,6 @@ public class AppsSettings { ...@@ -386,10 +388,6 @@ public class AppsSettings {
return mSharedPreferences.getBoolean(Constants.PREF_USE_EXTRA_CARD_CARDS, Constants.PREF_DEF_USE_EXTRA_CARD_CARDS); return mSharedPreferences.getBoolean(Constants.PREF_USE_EXTRA_CARD_CARDS, Constants.PREF_DEF_USE_EXTRA_CARD_CARDS);
} }
public String getCoreSkinPath() {
return new File(getResourcePath(), Constants.CORE_SKIN_PATH).getAbsolutePath();
}
/*** /***
* 设置是否使用额外卡库 * 设置是否使用额外卡库
*/ */
...@@ -397,18 +395,22 @@ public class AppsSettings { ...@@ -397,18 +395,22 @@ public class AppsSettings {
mSharedPreferences.putBoolean(Constants.PREF_USE_EXTRA_CARD_CARDS, useExtraCards); mSharedPreferences.putBoolean(Constants.PREF_USE_EXTRA_CARD_CARDS, useExtraCards);
} }
public String getCoreSkinPath() {
return new File(getResourcePath(), Constants.CORE_SKIN_PATH).getAbsolutePath();
}
/*** /***
* 字体路径 * 字体路径
*/ */
public void setFontPath(String font) { public String getFontPath() {
mSharedPreferences.putString(Constants.PREF_GAME_FONT, font); return mSharedPreferences.getString(Constants.PREF_GAME_FONT, getFontDefault());
} }
/*** /***
* 字体路径 * 字体路径
*/ */
public String getFontPath() { public void setFontPath(String font) {
return mSharedPreferences.getString(Constants.PREF_GAME_FONT, getFontDefault()); mSharedPreferences.putString(Constants.PREF_GAME_FONT, font);
} }
/** /**
...@@ -458,6 +460,13 @@ public class AppsSettings { ...@@ -458,6 +460,13 @@ public class AppsSettings {
return mSharedPreferences.getBoolean(PREF_SENSOR_REFRESH, PREF_DEF_SENSOR_REFRESH); return mSharedPreferences.getBoolean(PREF_SENSOR_REFRESH, PREF_DEF_SENSOR_REFRESH);
} }
/***
* 最后卡组名
*/
public String getLastDeck() {
return mSharedPreferences.getString(Constants.PREF_LAST_YDK, Constants.PREF_DEF_LAST_YDK);
}
/*** /***
* 最后卡组名 * 最后卡组名
*/ */
...@@ -469,13 +478,6 @@ public class AppsSettings { ...@@ -469,13 +478,6 @@ public class AppsSettings {
mSharedPreferences.putString(Constants.PREF_LAST_YDK, name); mSharedPreferences.putString(Constants.PREF_LAST_YDK, name);
} }
/***
* 最后卡组名
*/
public String getLastDeck() {
return mSharedPreferences.getString(Constants.PREF_LAST_YDK, Constants.PREF_DEF_LAST_YDK);
}
public String getCurLastDeck() { public String getCurLastDeck() {
return mSharedPreferences.getString(Constants.PREF_LAST_YDK, null); return mSharedPreferences.getString(Constants.PREF_LAST_YDK, null);
} }
......
...@@ -63,7 +63,7 @@ public class ServiceDuelAssistant extends Service { ...@@ -63,7 +63,7 @@ public class ServiceDuelAssistant extends Service {
//加房关键字 //加房关键字
public static final String[] passwordPrefix = { public static final String[] passwordPrefix = {
"M,", "m,", "M,", "m,",
"T,", "t,", "T,",
"PR,", "pr,", "PR,", "pr,",
"AI,", "ai,", "AI,", "ai,",
"LF2,", "lf2,", "LF2,", "lf2,",
......
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