Commit 2c25cc48 authored by fallenstardust's avatar fallenstardust

完善背景图片三张自定义

parent 03f7c622
...@@ -73,6 +73,8 @@ public interface Constants { ...@@ -73,6 +73,8 @@ public interface Constants {
String CORE_SKIN_COVER = "cover.jpg"; String CORE_SKIN_COVER = "cover.jpg";
String CORE_SKIN_COVER2 = "cover2.jpg"; String CORE_SKIN_COVER2 = "cover2.jpg";
String CORE_SKIN_BG = "bg.jpg"; String CORE_SKIN_BG = "bg.jpg";
String CORE_SKIN_BG_MENU = "bg_menu.jpg";
String CORE_SKIN_BG_DECK = "bg_deck.jpg";
String CORE_SKIN_AVATAR_ME = "me.jpg"; String CORE_SKIN_AVATAR_ME = "me.jpg";
String CORE_SKIN_AVATAR_OPPONENT = "opponent.jpg"; String CORE_SKIN_AVATAR_OPPONENT = "opponent.jpg";
String UNKNOWN_IMAGE = "unknown.jpg"; String UNKNOWN_IMAGE = "unknown.jpg";
......
...@@ -45,6 +45,8 @@ import ocgcore.ConfigManager; ...@@ -45,6 +45,8 @@ import ocgcore.ConfigManager;
import static android.R.attr.key; import static android.R.attr.key;
import static android.R.attr.packageNames; import static android.R.attr.packageNames;
import static cn.garymb.ygomobile.Constants.ACTION_RELOAD; import static cn.garymb.ygomobile.Constants.ACTION_RELOAD;
import static cn.garymb.ygomobile.Constants.CORE_SKIN_BG_SIZE;
import static cn.garymb.ygomobile.Constants.CORE_SKIN_CARD_COVER_SIZE;
import static cn.garymb.ygomobile.Constants.PREF_CHANGE_LOG; import static cn.garymb.ygomobile.Constants.PREF_CHANGE_LOG;
import static cn.garymb.ygomobile.Constants.PREF_CHECK_UPDATE; import static cn.garymb.ygomobile.Constants.PREF_CHECK_UPDATE;
import static cn.garymb.ygomobile.Constants.PREF_DECK_DELETE_DILAOG; import static cn.garymb.ygomobile.Constants.PREF_DECK_DELETE_DILAOG;
...@@ -185,6 +187,7 @@ public class SettingFragment extends PreferenceFragmentPlus { ...@@ -185,6 +187,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
//选择ttf字体文件,保存 //选择ttf字体文件,保存
showFileChooser(preference, "*.ttf", mSettings.getFontDirPath(), getString(R.string.dialog_select_font)); showFileChooser(preference, "*.ttf", mSettings.getFontDirPath(), getString(R.string.dialog_select_font));
} else if (SETTINGS_COVER.equals(key)) { } else if (SETTINGS_COVER.equals(key)) {
//显示卡背图片对话框
final DialogPlus dialog = new DialogPlus(getContext()); final DialogPlus dialog = new DialogPlus(getContext());
dialog.setContentView(R.layout.dialog_cover_select); dialog.setContentView(R.layout.dialog_cover_select);
dialog.setTitle(R.string.card_cover); dialog.setTitle(R.string.card_cover);
...@@ -192,26 +195,60 @@ public class SettingFragment extends PreferenceFragmentPlus { ...@@ -192,26 +195,60 @@ public class SettingFragment extends PreferenceFragmentPlus {
View viewDialog = dialog.getContentView(); View viewDialog = dialog.getContentView();
ImageView cover1 = viewDialog.findViewById(R.id.cover1); ImageView cover1 = viewDialog.findViewById(R.id.cover1);
ImageView cover2 = viewDialog.findViewById(R.id.cover2); ImageView cover2 = viewDialog.findViewById(R.id.cover2);
setImage(getDatapath(mSettings.getCoreSkinPath()+Constants.CORE_SKIN_COVER),cover1); setImage(mSettings.getCoreSkinPath()+ "/" + Constants.CORE_SKIN_COVER, CORE_SKIN_CARD_COVER_SIZE[0],CORE_SKIN_CARD_COVER_SIZE[1],cover1);
setImage(getDatapath(mSettings.getCoreSkinPath()+Constants.CORE_SKIN_COVER2),cover2); setImage(mSettings.getCoreSkinPath()+ "/" + Constants.CORE_SKIN_COVER2, CORE_SKIN_CARD_COVER_SIZE[0],CORE_SKIN_CARD_COVER_SIZE[1],cover2);
cover1.setOnClickListener((v) -> { cover1.setOnClickListener((v) -> {
//显示图片对话框? //打开系统文件相册
String outFile = new File(mSettings.getCoreSkinPath(), Constants.CORE_SKIN_COVER).getAbsolutePath(); String outFile = new File(mSettings.getCoreSkinPath(), Constants.CORE_SKIN_COVER).getAbsolutePath();
showImageDialog(preference, getString(R.string.card_cover), showImageDialog(preference, getString(R.string.card_cover),
outFile, outFile,
true, Constants.CORE_SKIN_CARD_COVER_SIZE[0], Constants.CORE_SKIN_CARD_COVER_SIZE[1]); true, CORE_SKIN_CARD_COVER_SIZE[0], CORE_SKIN_CARD_COVER_SIZE[1]);
dialog.dismiss();
}); });
cover2.setOnClickListener((v) -> { cover2.setOnClickListener((v) -> {
//显示图片对话框? //打开系统文件相册
String outFile = new File(mSettings.getCoreSkinPath(), Constants.CORE_SKIN_COVER2).getAbsolutePath(); String outFile = new File(mSettings.getCoreSkinPath(), Constants.CORE_SKIN_COVER2).getAbsolutePath();
showImageDialog(preference, getString(R.string.card_cover), showImageDialog(preference, getString(R.string.card_cover),
outFile, outFile,
true, Constants.CORE_SKIN_CARD_COVER_SIZE[0], Constants.CORE_SKIN_CARD_COVER_SIZE[1]); true, CORE_SKIN_CARD_COVER_SIZE[0], CORE_SKIN_CARD_COVER_SIZE[1]);
dialog.dismiss();
}); });
} else if (SETTINGS_CARD_BG.equals(key)) { } else if (SETTINGS_CARD_BG.equals(key)) {
//显示图片对话框? final DialogPlus dialog = new DialogPlus(getContext());
String outFile = new File(mSettings.getCoreSkinPath(), Constants.CORE_SKIN_BG).getAbsolutePath(); dialog.setContentView(R.layout.dialog_bg_select);
showImageDialog(preference, getString(R.string.game_bg), outFile, true, Constants.CORE_SKIN_BG_SIZE[0], Constants.CORE_SKIN_BG_SIZE[1]); dialog.setTitle(R.string.game_bg);
dialog.show();
View viewDialog = dialog.getContentView();
ImageView bg = viewDialog.findViewById(R.id.bg);
ImageView bg_menu = viewDialog.findViewById(R.id.bg_menu);
ImageView bg_deck = viewDialog.findViewById(R.id.bg_deck);
setImage(mSettings.getCoreSkinPath()+ "/" + Constants.CORE_SKIN_BG, CORE_SKIN_BG_SIZE[0], CORE_SKIN_BG_SIZE[1],bg);
setImage(mSettings.getCoreSkinPath()+ "/" + Constants.CORE_SKIN_BG_MENU, CORE_SKIN_BG_SIZE[0], CORE_SKIN_BG_SIZE[1],bg_menu);
setImage(mSettings.getCoreSkinPath()+ "/" + Constants.CORE_SKIN_BG_DECK, CORE_SKIN_BG_SIZE[0], CORE_SKIN_BG_SIZE[1],bg_deck);
bg.setOnClickListener((v) -> {
//打开系统文件相册
String outFile = new File(mSettings.getCoreSkinPath(), Constants.CORE_SKIN_BG).getAbsolutePath();
showImageDialog(preference, getString(R.string.bg),
outFile,
true, CORE_SKIN_BG_SIZE[0], CORE_SKIN_BG_SIZE[1]);
dialog.dismiss();
});
bg_menu.setOnClickListener((v) -> {
//打开系统文件相册
String outFile = new File(mSettings.getCoreSkinPath(), Constants.CORE_SKIN_BG_MENU).getAbsolutePath();
showImageDialog(preference, getString(R.string.bg_menu),
outFile,
true, CORE_SKIN_BG_SIZE[0], CORE_SKIN_BG_SIZE[1]);
dialog.dismiss();
});
bg_deck.setOnClickListener((v) -> {
//打开系统文件相册
String outFile = new File(mSettings.getCoreSkinPath(), Constants.CORE_SKIN_BG_DECK).getAbsolutePath();
showImageDialog(preference, getString(R.string.bg_deck),
outFile,
true, CORE_SKIN_BG_SIZE[0], CORE_SKIN_BG_SIZE[1]);
dialog.dismiss();
});
} else if (PREF_USE_EXTRA_CARD_CARDS.equals(key)) { } else if (PREF_USE_EXTRA_CARD_CARDS.equals(key)) {
CheckBoxPreference checkBoxPreference = (CheckBoxPreference) preference; CheckBoxPreference checkBoxPreference = (CheckBoxPreference) preference;
if (checkBoxPreference.isChecked()) { if (checkBoxPreference.isChecked()) {
...@@ -296,12 +333,14 @@ public class SettingFragment extends PreferenceFragmentPlus { ...@@ -296,12 +333,14 @@ public class SettingFragment extends PreferenceFragmentPlus {
} }
} }
public void setImage(String path,ImageView imageView){ public void setImage(String outFile,int outWidth,int outHeight,ImageView imageView){
//图片显示代码 File img = new File(outFile);
Glide.with(this).load(path) if (img.exists()) {
.diskCacheStrategy(DiskCacheStrategy.NONE) Glide.with(this).load(img).signature(new StringSignature(img.getName() + img.lastModified()))
.override(Constants.CORE_SKIN_CARD_COVER_SIZE[0], Constants.CORE_SKIN_CARD_COVER_SIZE[1]) .diskCacheStrategy(DiskCacheStrategy.NONE)
.into(imageView); .override(outWidth, outHeight)
.into(imageView);
}
} }
private void copyDataBase(Preference preference, String file) { private void copyDataBase(Preference preference, String file) {
......
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center">
<TextView
android:layout_width="@dimen/label_width_middle"
android:layout_height="wrap_content"
android:text="@string/bg"/>
<ImageView
android:id="@+id/bg"
android:layout_width="320dp"
android:layout_height="180dp" />
<TextView
android:layout_width="@dimen/label_width_middle"
android:layout_height="wrap_content"
android:text="@string/bg_menu"/>
<ImageView
android:id="@+id/bg_menu"
android:layout_width="320dp"
android:layout_height="180dp" />
<TextView
android:layout_width="@dimen/label_width_middle"
android:layout_height="wrap_content"
android:text="@string/bg_deck"/>
<ImageView
android:id="@+id/bg_deck"
android:layout_width="320dp"
android:layout_height="180dp" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
<ImageView <ImageView
android:id="@+id/cover1" android:id="@+id/cover1"
android:layout_width="44dp" android:layout_width="88dp"
android:layout_height="64dp" /> android:layout_height="128dp" />
<TextView <TextView
android:layout_width="@dimen/label_width_middle" android:layout_width="@dimen/label_width_middle"
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
<ImageView <ImageView
android:id="@+id/cover2" android:id="@+id/cover2"
android:layout_width="44dp" android:layout_width="88dp"
android:layout_height="64dp" /> android:layout_height="128dp" />
</LinearLayout> </LinearLayout>
......
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
<string name="copy_databse">复制数据库中</string> <string name="copy_databse">复制数据库中</string>
<string name="card_cover">卡片背面</string> <string name="card_cover">卡片背面</string>
<string name="game_bg">游戏背景</string> <string name="game_bg">游戏背景</string>
<string name="bg">决斗背景</string>
<string name="bg_menu">菜单背景</string>
<string name="bg_deck">卡组背景</string>
<string name="action_add_server">添加服务器</string> <string name="action_add_server">添加服务器</string>
<string name="no_find_file_selectotr">没有找到文件选择器</string> <string name="no_find_file_selectotr">没有找到文件选择器</string>
<string name="no_find_image_selector">没有找到图片选择器</string> <string name="no_find_image_selector">没有找到图片选择器</string>
......
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