Commit 14fdeb99 authored by kenan's avatar kenan

曲面屏

parent 32845fb4
......@@ -3,6 +3,7 @@ package cn.garymb.ygomobile;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Point;
import android.os.ParcelFileDescriptor;
import android.text.TextUtils;
import android.util.Log;
import android.view.WindowManager;
......@@ -22,6 +23,7 @@ import cn.garymb.ygomobile.core.IrrlichtBridge;
import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.ui.preference.PreferenceFragmentPlus;
import cn.garymb.ygomobile.utils.DeckUtil;
import cn.garymb.ygomobile.utils.DensityUtils;
import cn.garymb.ygomobile.utils.IOUtils;
import static cn.garymb.ygomobile.Constants.CORE_DECK_PATH;
......@@ -56,8 +58,8 @@ public class AppsSettings {
private static AppsSettings sAppsSettings;
private final Point mScreenSize = new Point();
private final Point mRealScreenSize = new Point();
private Context context;
private PreferenceFragmentPlus.SharedPreferencesPlus mSharedPreferences;
private final Context context;
private final PreferenceFragmentPlus.SharedPreferencesPlus mSharedPreferences;
private float mDensity;
private AppsSettings(Context context) {
......@@ -160,6 +162,15 @@ public class AppsSettings {
return mSharedPreferences.getBoolean(PREF_KEEP_SCALE, DEF_PREF_KEEP_SCALE);
}
public int getScreenPadding() {
//ListPreference都是string
String str = mSharedPreferences.getString(PREF_WINDOW_TOP_BOTTOM, null);
if (!TextUtils.isEmpty(str) && TextUtils.isDigitsOnly(str)) {
return Integer.parseInt(str);
}
return 0;
}
public float getScreenWidth() {
int w, h;
if (isImmerSiveMode()) {
......@@ -171,7 +182,8 @@ public class AppsSettings {
}
int ret = Math.min(w, h);
//测试代码,曲面屏左右2变需要留空白,但是游戏画面比例不对,需要修改c那边代码
int fix_h = mSharedPreferences.getInt(PREF_WINDOW_TOP_BOTTOM, DEF_PREF_WINDOW_TOP_BOTTOM);
int fix_h = DensityUtils.dp2px(context, getScreenPadding());
Log.d(IrrlichtBridge.TAG, "screen padding=" + fix_h);
return ret - fix_h * 2;
}
......@@ -525,7 +537,8 @@ public class AppsSettings {
}
//获得最后卡组绝对路径
public @Nullable String getLastDeckPath() {
public @Nullable
String getLastDeckPath() {
String path;
if (TextUtils.equals(context.getString(R.string.category_pack), getLastCategory())) {
path = getResourcePath() + "/" + CORE_PACK_PATH + "/" + getLastDeckName() + YDK_FILE_EX;
......
......@@ -74,6 +74,7 @@ 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_START_SERVICEDUELASSISTANT;
import static cn.garymb.ygomobile.Constants.PREF_USE_EXTRA_CARD_CARDS;
import static cn.garymb.ygomobile.Constants.PREF_WINDOW_TOP_BOTTOM;
import static cn.garymb.ygomobile.Constants.SETTINGS_AVATAR;
import static cn.garymb.ygomobile.Constants.SETTINGS_CARD_BG;
import static cn.garymb.ygomobile.Constants.SETTINGS_COVER;
......@@ -138,6 +139,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
bind(PREF_READ_EX, mSettings.isReadExpansions());
bind(PREF_DEL_EX, getString(R.string.about_delete_ex));
bind(PERF_TEST_REPLACE_KERNEL, "需root权限,请在开发者的指导下食用");
bind(PREF_WINDOW_TOP_BOTTOM, ""+mSettings.getScreenPadding());
Preference preference = findPreference(PREF_READ_EX);
if (preference != null) {
preference.setSummary(mSettings.getExpansionsPath().getAbsolutePath());
......
......@@ -7,6 +7,9 @@ public class DensityUtils {
* dp转px
*/
public static int dp2px(Context ctx, float dp) {
if(dp == 0){
return 0;
}
float density = ctx.getResources().getDisplayMetrics().density;
int px = (int) (dp * density + 0.5f);// 4.9->5 4.4->4
return px;
......
......@@ -318,4 +318,5 @@
<string name="label_ot_All">모든 카드</string>
<string name="label_ot_No_Exclusive">ID 없는 카드</string>
<string name="label_ot_CUSTOM">커스텀 카드</string>
<string name="settings_screen_padding">曲面屏预留高度</string>
</resources>
......@@ -318,4 +318,5 @@
<string name="ask_delete_ex">点击确认以清空</string>
<string name="about_delete_ex">如果遇到拓展卡包问题时删除是个不错的办法</string>
<string name="file_installed">文件已导入</string>
<string name="settings_screen_padding">曲面屏预留高度</string>
</resources>
......@@ -9,6 +9,12 @@
<item>0</item>
<item>1</item>
</string-array>
<string-array name="screen_top_bottom_value" translatable="false">
<item>0</item>
<item>5</item>
<item>10</item>
<item>15</item>
</string-array>
<string-array name="tips" tools:ignore="InconsistentArrays">
<item>Duel is One Thing, Kind is Everything</item>
<item>Touching Inaccurately in Duelling? to Ephone「Settings」→「Display」→「NotchDisplay」→「Hide the notch area」</item>
......
......@@ -83,6 +83,12 @@
<item>Speed</item>
<item>Quality</item>
</string-array>
<string-array name="screen_top_bottom_desc" translatable="false">
<item>Disable</item>
<item>5</item>
<item>10</item>
<item>15</item>
</string-array>
<!-- settings -->
<string name="server_name">Name:</string>
......@@ -321,4 +327,5 @@
<string name="label_ot_CUSTOM">Custom</string>
<string name="label_ot_No_Exclusive">No exclusive</string>
<string name="label_ot_SC_OCG">SChinese OCG</string>
<string name="settings_screen_padding">Reserved height of curved screen</string>
</resources>
......@@ -37,6 +37,12 @@
android:key="pref_settings_keep_scale"
android:persistent="false"
android:title="@string/about_pref_settings_keep_scale" />
<ListPreference
android:entries="@array/screen_top_bottom_desc"
android:entryValues="@array/screen_top_bottom_value"
android:key="pref_settings_window_top_bottom"
android:persistent="true"
android:title="@string/settings_screen_padding" />
<ListPreference
android:entries="@array/opengl_version"
......
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