Commit 2b42637d authored by fallenstardust's avatar fallenstardust

在卡组编辑下进行备份、还原卡组。

parent d4047e3f
...@@ -2,11 +2,13 @@ package cn.garymb.ygomobile.ui.cards; ...@@ -2,11 +2,13 @@ package cn.garymb.ygomobile.ui.cards;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment;
import android.os.Handler; import android.os.Handler;
import android.text.InputType; import android.text.InputType;
import android.text.TextUtils; import android.text.TextUtils;
...@@ -83,6 +85,7 @@ import ocgcore.data.Card; ...@@ -83,6 +85,7 @@ import ocgcore.data.Card;
import ocgcore.data.LimitList; import ocgcore.data.LimitList;
import ocgcore.enums.LimitType; import ocgcore.enums.LimitType;
import static cn.garymb.ygomobile.Constants.ORI_DECK;
import static cn.garymb.ygomobile.Constants.YDK_FILE_EX; import static cn.garymb.ygomobile.Constants.YDK_FILE_EX;
class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerViewItemListener.OnItemListener, OnItemDragListener, YGODialogUtil.OnDeckMenuListener { class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerViewItemListener.OnItemListener, OnItemDragListener, YGODialogUtil.OnDeckMenuListener {
...@@ -619,9 +622,29 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView ...@@ -619,9 +622,29 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
} }
public boolean doMenu(int menuId) { public boolean doMenu(int menuId) {
DialogPlus builder = new DialogPlus(this);
switch (menuId) { switch (menuId) {
case R.id.action_quit: case R.id.action_deck_backup_n_restore:
onBackHome(); builder.setTitle(R.string.question);
builder.setMessage(R.string.deck_explain);
builder.setMessageGravity(Gravity.CENTER_HORIZONTAL);
builder.setLeftButtonText(R.string.deck_restore);
builder.setRightButtonText(R.string.deck_back_up);
builder.setRightButtonListener(new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
doBackUpDeck();
}
});
builder.setLeftButtonListener(new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
doRestoreDeck();
}
});
builder.show();
break; break;
// case R.id.action_refresh: // case R.id.action_refresh:
// mDeckAdapater.notifyDataSetChanged(); // mDeckAdapater.notifyDataSetChanged();
...@@ -672,7 +695,6 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView ...@@ -672,7 +695,6 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
break; break;
case R.id.action_clear_deck: { case R.id.action_clear_deck: {
DialogPlus builder = new DialogPlus(this);
builder.setTitle(R.string.question); builder.setTitle(R.string.question);
builder.setMessage(R.string.question_clear_deck); builder.setMessage(R.string.question_clear_deck);
builder.setMessageGravity(Gravity.CENTER_HORIZONTAL); builder.setMessageGravity(Gravity.CENTER_HORIZONTAL);
...@@ -692,7 +714,6 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView ...@@ -692,7 +714,6 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
if (mDeckAdapater.getYdkFile().getParent().equals(mSettings.getAiDeckDir())) { if (mDeckAdapater.getYdkFile().getParent().equals(mSettings.getAiDeckDir())) {
Toast.makeText(this, R.string.donot_editor_bot_Deck, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.donot_editor_bot_Deck, Toast.LENGTH_SHORT).show();
} else { } else {
DialogPlus builder = new DialogPlus(this);
builder.setTitle(R.string.question); builder.setTitle(R.string.question);
builder.setMessage(R.string.question_delete_deck); builder.setMessage(R.string.question_delete_deck);
builder.setMessageGravity(Gravity.CENTER_HORIZONTAL); builder.setMessageGravity(Gravity.CENTER_HORIZONTAL);
...@@ -1090,7 +1111,7 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView ...@@ -1090,7 +1111,7 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
addMenuButton(mMenuIds, menu, R.id.action_unsort, R.string.unsort, R.drawable.unsort); addMenuButton(mMenuIds, menu, R.id.action_unsort, R.string.unsort, R.drawable.unsort);
addMenuButton(mMenuIds, menu, R.id.action_sort, R.string.sort, R.drawable.sort); addMenuButton(mMenuIds, menu, R.id.action_sort, R.string.sort, R.drawable.sort);
addMenuButton(mMenuIds, menu, R.id.action_quit, R.string.quit, R.drawable.quit); addMenuButton(mMenuIds, menu, R.id.action_deck_backup_n_restore, R.string.deck_backup_n_restore, R.drawable.downloadimages);
//设置展开或隐藏的延时。 默认值为 800ms。 //设置展开或隐藏的延时。 默认值为 800ms。
menu.setDuration(150); menu.setDuration(150);
...@@ -1119,6 +1140,22 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView ...@@ -1119,6 +1140,22 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
mMenuIds.put(mMenuIds.size(), menuId); mMenuIds.put(mMenuIds.size(), menuId);
} }
private void doBackUpDeck() {
try {
FileUtils.copyDir(mSettings.getDeckDir(), ORI_DECK, true);
} catch (Throwable e) {
Toast.makeText(getContext(), e + "", Toast.LENGTH_SHORT);
}
}
private void doRestoreDeck() {
try {
FileUtils.copyDir(ORI_DECK, mSettings.getDeckDir(), false);
} catch (Throwable e) {
Toast.makeText(getContext(), e + "", Toast.LENGTH_SHORT);
}
}
@Override @Override
public void onDeckSelect(DeckFile deckFile) { public void onDeckSelect(DeckFile deckFile) {
loadDeckFromFile(new File(deckFile.getPath())); loadDeckFromFile(new File(deckFile.getPath()));
......
...@@ -259,11 +259,6 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> { ...@@ -259,11 +259,6 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
//复制人机资源 //复制人机资源
IOUtils.copyFilesFromAssets(mContext, getDatapath(Constants.WINDBOT_PATH), IOUtils.copyFilesFromAssets(mContext, getDatapath(Constants.WINDBOT_PATH),
resPath, needsUpdate); resPath, needsUpdate);
//复制原目录文件
FileUtils.copyDir(ORI_DECK, mSettings.getDeckDir(), false);
FileUtils.copyDir(ORI_REPLAY, resPath + "/" + Constants.CORE_REPLAY_PATH, false);
//FileUtils.copyDir(ORI_TEXTURES, mSettings.getCoreSkinPath(), true);
//FileUtils.copyDir(ORI_PICS, mSettings.getCardImagePath(), false);
han.sendEmptyMessage(0); han.sendEmptyMessage(0);
......
...@@ -13,6 +13,12 @@ ...@@ -13,6 +13,12 @@
android:title="@string/share_deck" android:title="@string/share_deck"
app:showAsAction="always" /> app:showAsAction="always" />
<item
android:id="@+id/action_deck_backup_n_restore"
android:icon="@drawable/downloadimages"
android:title="@string/deck_backup_n_restore"
app:showAsAction="always" />
<!--<item--> <!--<item-->
<!--android:id="@+id/action_card_list"--> <!--android:id="@+id/action_card_list"-->
<!--android:icon="@drawable/listicon"--> <!--android:icon="@drawable/listicon"-->
......
...@@ -281,4 +281,9 @@ ...@@ -281,4 +281,9 @@
<string name="ypk_installed">확장팩 설치되어</string> <string name="ypk_installed">확장팩 설치되어</string>
<string name="ypk_go_setting">점검 \"확장팩 사용\" </string> <string name="ypk_go_setting">점검 \"확장팩 사용\" </string>
<string name="ypk_failed_bcos">확장팩 설치 실패, 왜냐하면\:</string> <string name="ypk_failed_bcos">확장팩 설치 실패, 왜냐하면\:</string>
<string name="deck_back_up">BackUp</string>
<string name="deck_restore">Restore</string>
<string name="deck_backup_n_restore">BackUp/Restore</string>
<string name="deck_explain">BackUp\: back up all decks to Sdcard/ygocore
\nRestore\: restore backed up decks</string>
</resources> </resources>
...@@ -280,4 +280,9 @@ ...@@ -280,4 +280,9 @@
<string name="ypk_installed">拓展卡包文件已安装</string> <string name="ypk_installed">拓展卡包文件已安装</string>
<string name="ypk_go_setting">这是拓展卡包文件,要使用须启用扩展卡包</string> <string name="ypk_go_setting">这是拓展卡包文件,要使用须启用扩展卡包</string>
<string name="ypk_failed_bcos">拓展卡包安装失败,原因:</string> <string name="ypk_failed_bcos">拓展卡包安装失败,原因:</string>
<string name="deck_back_up">备份</string>
<string name="deck_restore">还原</string>
<string name="deck_backup_n_restore">备份/还原</string>
<string name="deck_explain">备份:将当前所有卡组备份到内存根目录的ygocore文件夹
\n还原:将已在上述备份路径的所有卡组还原到此</string>
</resources> </resources>
...@@ -283,4 +283,9 @@ ...@@ -283,4 +283,9 @@
<string name="ypk_installed">expansion file installed</string> <string name="ypk_installed">expansion file installed</string>
<string name="ypk_go_setting">check \"Use Expansions\" to use it</string> <string name="ypk_go_setting">check \"Use Expansions\" to use it</string>
<string name="ypk_failed_bcos">expansion file install failed, because\:</string> <string name="ypk_failed_bcos">expansion file install failed, because\:</string>
<string name="deck_back_up">BackUp</string>
<string name="deck_restore">Restore</string>
<string name="deck_backup_n_restore">BackUp/Restore</string>
<string name="deck_explain">BackUp\: back up all decks to Sdcard/ygocore
\nRestore\: restore backed up decks</string>
</resources> </resources>
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