Commit feb2b5b1 authored by fallenstardust's avatar fallenstardust

opt favourite cards

buildConfig调整
parent 53c30ec3
...@@ -7,6 +7,7 @@ android { ...@@ -7,6 +7,7 @@ android {
defaultConfig { defaultConfig {
applicationId "cn.garymb.ygomobile" applicationId "cn.garymb.ygomobile"
minSdkVersion 21 minSdkVersion 21
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 29 targetSdkVersion 29
versionCode 380800907 versionCode 380800907
versionName "3.8.8" versionName "3.8.8"
...@@ -22,21 +23,29 @@ android { ...@@ -22,21 +23,29 @@ android {
} }
productFlavors { productFlavors {
cn { cn {
buildConfigField 'String', 'URL_DONATE', '"https://afdian.net/@ygomobile"'
manifestPlaceholders = [APP_ID: "0b6f110306"] manifestPlaceholders = [APP_ID: "0b6f110306"]
} }
en { en {
applicationIdSuffix ".EN" applicationIdSuffix ".EN"
buildConfigField 'String', 'URL_DONATE', '"https://www.paypal.me/ygomobile1"'
manifestPlaceholders = [APP_ID: "9c66525dfa"] manifestPlaceholders = [APP_ID: "9c66525dfa"]
} }
ko { ko {
applicationIdSuffix ".KO" applicationIdSuffix ".KO"
buildConfigField 'String', 'URL_DONATE', '"https://www.paypal.me/ygomobile1"'
manifestPlaceholders = [APP_ID: "0488398d8a"] manifestPlaceholders = [APP_ID: "0488398d8a"]
} }
} }
buildTypes { buildTypes {
debug {
debuggable false
buildConfigField 'boolean', 'DEBUG_MODE', 'true'
}
release { release {
shrinkResources false shrinkResources false
minifyEnabled false minifyEnabled false
buildConfigField 'boolean', 'DEBUG_MODE', 'false'
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
} }
......
...@@ -124,10 +124,6 @@ ...@@ -124,10 +124,6 @@
android:theme="@style/AppTheme.Game" android:theme="@style/AppTheme.Game"
tools:replace="android:theme" /> tools:replace="android:theme" />
<receiver
android:name="cn.garymb.ygomobile.GameReceiver"
android:enabled="false" />
<activity <activity
android:name="cn.garymb.ygomobile.ui.preference.SettingsActivity" android:name="cn.garymb.ygomobile.ui.preference.SettingsActivity"
android:configChanges="orientation|keyboardHidden|navigation|screenSize" android:configChanges="orientation|keyboardHidden|navigation|screenSize"
...@@ -137,7 +133,7 @@ ...@@ -137,7 +133,7 @@
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize" /> android:windowSoftInputMode="stateAlwaysHidden|adjustResize" />
<activity <activity
android:name="cn.garymb.ygomobile.ui.cards.CardSearchAcitivity" android:name="cn.garymb.ygomobile.ui.cards.CardSearchActivity"
android:configChanges="orientation|keyboardHidden|navigation|screenSize" android:configChanges="orientation|keyboardHidden|navigation|screenSize"
android:label="@string/card_search" android:label="@string/card_search"
android:launchMode="singleTop" android:launchMode="singleTop"
...@@ -152,22 +148,6 @@ ...@@ -152,22 +148,6 @@
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" /> android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
<activity
android:name="cn.garymb.ygomobile.ui.cards.DeckManagerActivity2"
android:configChanges="orientation|keyboardHidden|navigation|screenSize"
android:label="@string/deck_manager"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/AppTheme"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
<activity
android:name="cn.garymb.ygomobile.ui.cards.DeckManagerActivity3"
android:configChanges="orientation|keyboardHidden|navigation|screenSize"
android:label="@string/deck_manager"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/AppTheme"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
<activity <activity
android:name="cn.garymb.ygomobile.ui.file.FileActivity" android:name="cn.garymb.ygomobile.ui.file.FileActivity"
android:configChanges="orientation|keyboardHidden|navigation|screenSize" android:configChanges="orientation|keyboardHidden|navigation|screenSize"
......
...@@ -7,6 +7,8 @@ import android.text.TextUtils; ...@@ -7,6 +7,8 @@ import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.WindowManager; import android.view.WindowManager;
import androidx.annotation.Nullable;
import org.json.JSONArray; import org.json.JSONArray;
import java.io.File; import java.io.File;
...@@ -46,6 +48,7 @@ import static cn.garymb.ygomobile.Constants.WINDBOT_PATH; ...@@ -46,6 +48,7 @@ import static cn.garymb.ygomobile.Constants.WINDBOT_PATH;
import static cn.garymb.ygomobile.Constants.YDK_FILE_EX; import static cn.garymb.ygomobile.Constants.YDK_FILE_EX;
public class AppsSettings { public class AppsSettings {
private static final String TAG = "AppsSettings";
private static final String PREF_VERSION = "app_version"; private static final String PREF_VERSION = "app_version";
private static AppsSettings sAppsSettings; private static AppsSettings sAppsSettings;
private final Point mScreenSize = new Point(); private final Point mScreenSize = new Point();
...@@ -130,10 +133,6 @@ public class AppsSettings { ...@@ -130,10 +133,6 @@ public class AppsSettings {
return mSharedPreferences.getBoolean(PREF_READ_EX, DEF_PREF_READ_EX); return mSharedPreferences.getBoolean(PREF_READ_EX, DEF_PREF_READ_EX);
} }
public boolean isUseDeckManagerV2() {
return false;//mSharedPreferences.getBoolean(PREF_DECK_MANAGER_V2, DEF_PREF_DECK_MANAGER_V2);
}
public float getXScale(int w, int h) { public float getXScale(int w, int h) {
if (isKeepScale()) { if (isKeepScale()) {
float sx = getScreenHeight() / w; float sx = getScreenHeight() / w;
...@@ -471,7 +470,9 @@ public class AppsSettings { ...@@ -471,7 +470,9 @@ public class AppsSettings {
mSharedPreferences.putString(Constants.PREF_GAME_PATH, path); mSharedPreferences.putString(Constants.PREF_GAME_PATH, path);
} }
//获取录像文件夹 /**
* @return 录像文件夹
*/
public String getReplayDir() { public String getReplayDir() {
return new File(getResourcePath(), CORE_REPLAY_PATH).getAbsolutePath(); return new File(getResourcePath(), CORE_REPLAY_PATH).getAbsolutePath();
} }
...@@ -517,7 +518,7 @@ public class AppsSettings { ...@@ -517,7 +518,7 @@ public class AppsSettings {
} }
//获得最后卡组绝对路径 //获得最后卡组绝对路径
public String getLastDeckPath() { public @Nullable String getLastDeckPath() {
String path; String path;
if (TextUtils.equals(context.getString(R.string.category_pack), getLastCategory())) { if (TextUtils.equals(context.getString(R.string.category_pack), getLastCategory())) {
path = getResourcePath() + "/" + CORE_PACK_PATH + "/" + getLastDeckName() + YDK_FILE_EX; path = getResourcePath() + "/" + CORE_PACK_PATH + "/" + getLastDeckName() + YDK_FILE_EX;
...@@ -528,13 +529,13 @@ public class AppsSettings { ...@@ -528,13 +529,13 @@ public class AppsSettings {
} else { } else {
path = getResourcePath() + "/" + CORE_DECK_PATH + "/" + getLastCategory() + "/" + getLastDeckName() + YDK_FILE_EX; path = getResourcePath() + "/" + CORE_DECK_PATH + "/" + getLastCategory() + "/" + getLastDeckName() + YDK_FILE_EX;
} }
Log.e("Appsettings", "拼接最后路径" + path); Log.e(TAG, "拼接最后路径" + path);
return path; return path;
} }
//保存最后卡组绝对路径、分类、卡组名 //保存最后卡组绝对路径、分类、卡组名
public void setLastDeckPath(String path) { public void setLastDeckPath(String path) {
Log.e("Appsettings", "设置最后路径" + path); Log.e(TAG, "设置最后路径" + path);
if (TextUtils.equals(path, getLastDeckPath())) { if (TextUtils.equals(path, getLastDeckPath())) {
//一样 //一样
return; return;
...@@ -623,10 +624,10 @@ public class AppsSettings { ...@@ -623,10 +624,10 @@ public class AppsSettings {
public void saveSettings(String key, String value) { public void saveSettings(String key, String value) {
if ("lastdeck".equals(key)) { if ("lastdeck".equals(key)) {
Log.e("AppSettings", value); Log.e(TAG, value);
mSharedPreferences.putString(Constants.PREF_LAST_YDK, value); mSharedPreferences.putString(Constants.PREF_LAST_YDK, value);
} else if ("lastcategory".equals(key)) { } else if ("lastcategory".equals(key)) {
Log.e("AppSettings", value); Log.e(TAG, value);
mSharedPreferences.putString(Constants.PREF_LAST_CATEGORY, value); mSharedPreferences.putString(Constants.PREF_LAST_CATEGORY, value);
} else { } else {
mSharedPreferences.putString(Constants.PREF_START + key, value); mSharedPreferences.putString(Constants.PREF_START + key, value);
...@@ -675,4 +676,9 @@ public class AppsSettings { ...@@ -675,4 +676,9 @@ public class AppsSettings {
// Log.i("kk", "saveTemp:" + array); // Log.i("kk", "saveTemp:" + array);
mSharedPreferences.putString(Constants.PREF_LAST_ROOM_LIST, array.toString()); mSharedPreferences.putString(Constants.PREF_LAST_ROOM_LIST, array.toString());
} }
//获取收藏文件
public String getFavoriteTxt() {
return new File(getResourcePath(), "/favorite.txt").getAbsolutePath();
}
} }
package cn.garymb.ygomobile.ui.cards;
import android.text.TextUtils;
import android.util.SparseArray;
import java.util.ArrayList;
import java.util.List;
import cn.garymb.ygomobile.AppsSettings;
import cn.garymb.ygomobile.Constants;
import cn.garymb.ygomobile.loader.ICardSearcher;
import cn.garymb.ygomobile.utils.FileUtils;
import ocgcore.data.Card;
public class CardFavorites {
private final List<Integer> mList = new ArrayList<>();
private static final CardFavorites sCardFavorites = new CardFavorites();
public static CardFavorites get() {
return sCardFavorites;
}
private CardFavorites() {
}
public boolean toggle(Integer id) {
if (!mList.contains(id)) {
//添加
mList.add(id);
return true;
} else {
//移除
mList.remove(id);
return false;
}
}
public boolean add(Integer id) {
if (!mList.contains(id)) {
mList.add(id);
return true;
}
return false;
}
public boolean hasCard(Integer id){
return mList.contains(id);
}
public List<Integer> getCardIds() {
return mList;
}
public List<Card> getCards(ICardSearcher cardLoader) {
SparseArray<Card> id = cardLoader.readCards(mList, false);
List<Card> list = new ArrayList<>();
if (id != null) {
for (int i = 0; i < id.size(); i++) {
list.add(id.valueAt(i));
}
}
return cardLoader.sort(list);
}
public void remove(Integer id) {
mList.remove(id);
}
public void load() {
List<String> lines = FileUtils.readLines(AppsSettings.get().getFavoriteTxt(), Constants.DEF_ENCODING);
mList.clear();
for (String line : lines) {
String tmp = line.trim();
if (TextUtils.isDigitsOnly(tmp)) {
mList.add(Integer.parseInt(tmp));
}
}
}
public void save() {
List<String> ret = new ArrayList<>();
for (Integer id : mList) {
ret.add(String.valueOf(id));
}
FileUtils.writeLines(AppsSettings.get().getFavoriteTxt(), ret, Constants.DEF_ENCODING, "\n");
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="@color/red">
<path
android:fillColor="@color/red"
android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="@color/red">
<path
android:fillColor="@color/red"
android:pathData="M16.5,3c-1.74,0 -3.41,0.81 -4.5,2.09C10.91,3.81 9.24,3 7.5,3 4.42,3 2,5.42 2,8.5c0,3.78 3.4,6.86 8.55,11.54L12,21.35l1.45,-1.32C18.6,15.36 22,12.28 22,8.5 22,5.42 19.58,3 16.5,3zM12.1,18.55l-0.1,0.1 -0.1,-0.1C7.14,14.24 4,11.39 4,8.5 4,6.5 5.5,5 7.5,5c1.54,0 3.04,0.99 3.57,2.36h1.87C13.46,5.99 14.96,5 16.5,5c2,0 3.5,1.5 3.5,3.5 0,2.89 -3.14,5.74 -7.9,10.05z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_baseline_favorite_24" android:state_selected="true" />
<item android:drawable="@drawable/ic_baseline_favorite_24" android:state_checked="true" />
<item android:drawable="@drawable/ic_baseline_favorite_border_24" />
</selector>
\ No newline at end of file
...@@ -145,9 +145,9 @@ ...@@ -145,9 +145,9 @@
android:layout_width="30dp" android:layout_width="30dp"
android:layout_height="30dp" android:layout_height="30dp"
android:layout_gravity="center" android:layout_gravity="center"
android:background="@drawable/ic_control_point" android:src="@drawable/selector_favorite"
android:paddingRight="5dp" android:paddingRight="5dp"
android:scaleType="center" /> android:scaleType="fitCenter" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
......
...@@ -12,8 +12,10 @@ ...@@ -12,8 +12,10 @@
<color name="mediumPurple">#673AB7</color> <color name="mediumPurple">#673AB7</color>
<color name="mediumPurpleDark">#572AA7</color> <color name="mediumPurpleDark">#572AA7</color>
<color name="colorPrimaryDark">#2f41a5</color> <color name="colorPrimaryDark">#2f41a5</color>
<color name="gold">#b8be35</color> <color name="gold">#C8BE35</color>
<color name="colorAccent">#EF3934</color> <color name="gold_light">#D8DE45</color>
<color name="red">#EF3934</color>
<color name="colorAccent">@color/red</color>
<color name="colorAccentDark">#CF3934</color> <color name="colorAccentDark">#CF3934</color>
<color name="item_title">@color/gold</color> <color name="item_title">@color/gold</color>
<color name="item_bg">#65ffffff</color> <color name="item_bg">#65ffffff</color>
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
<item name="android:windowIsTranslucent">true</item> <item name="android:windowIsTranslucent">true</item>
</style> </style>
<style name="AppTheme.Translucent" parent="AppTheme"> <style name="AppTheme.Translucent" parent="AppTheme">
<item name="android:windowIsTranslucent">true</item> <item name="android:windowIsTranslucent">true</item>
</style> </style>
......
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