Commit 3e8c02b0 authored by fallenstardust's avatar fallenstardust

如果卡组数量只有1则询问是否还原

parent 911d3b43
......@@ -12,9 +12,11 @@ import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import androidx.annotation.NonNull;
import java.io.File;
import java.io.IOException;
import cn.garymb.ygomobile.AppsSettings;
......@@ -145,6 +147,31 @@ public class MainActivity extends HomeActivity {
public void onDismiss(DialogInterface dialogInterface) {
if (AppsSettings.get().isServiceDuelAssistant() && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q)
YGOUtil.isServicePermission(MainActivity.this, true);
File oriDeckFiles = new File(ORI_DECK);
File deckFiles = new File(AppsSettings.get().getDeckDir());
if (oriDeckFiles.exists() && deckFiles.list().length <= 1) {
DialogPlus dlgpls = new DialogPlus(MainActivity.this);
dlgpls.setTitle(R.string.tip);
dlgpls.setMessage(R.string.restore_deck);
dlgpls.setLeftButtonText(R.string.Cancel);
dlgpls.setLeftButtonListener((dlg, i) -> {
dlgpls.dismiss();
});
dlgpls.setRightButtonText(R.string.deck_restore);
dlgpls.setRightButtonListener((dlg, i) -> {
try {
FileUtils.copyDir(ORI_DECK, AppsSettings.get().getDeckDir(), false);
} catch (Throwable e) {
Toast.makeText(MainActivity.this, e + "", Toast.LENGTH_SHORT).show();
}
Toast.makeText(MainActivity.this, R.string.done, Toast.LENGTH_SHORT).show();
dlgpls.dismiss();
});
dlgpls.show();
} else {
Toast.makeText(MainActivity.this, "不符合提示备份条件", Toast.LENGTH_SHORT).show();
}
}
});
dialog.show();
......
......@@ -285,7 +285,7 @@
<string name="deck_backup_n_restore">备份/还原</string>
<string name="deck_explain">备份:将当前所有卡组备份到内存根目录的ygocore文件夹
\n还原:将已在上述备份路径的所有卡组还原到此</string>
<string name="restore_deck">发现本机有卡组备份记录,是否导入</string>
<string name="restore_deck">发现本机有卡组备份记录,是否还原</string>
<string name="explain_permission">
将申请以下必要权限:
\n电话权限:不获得电话号码等个人信息,只获得机型信息用于BUG排查和适配
......
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