Commit 26a67b8f authored by kenan's avatar kenan

res check

parent 7cbd42c1
......@@ -51,6 +51,22 @@ bool Game::Initialize() {
LoadConfig(jni, options);
int windowWidth = gameUI->getWindowWidth(jni);
int windowHeight = gameUI->getWindowHeight(jni);
xScale = (float)windowWidth / GAME_WIDTH;
yScale = (float)windowHeight / GAME_HEIGHT;
LOGI("org xScale = %f, yScale = %f", xScale, yScale);
//int xs = (int) (xScale * 100) / 2 * 2;
//int sy = (int) (yScale * 100) / 2 * 2;
//xScale = xs/100.0f;
//yScale = sy/100.0f;
//windowWidth = (int)(xScale* (int)GAME_WIDTH);
//windowHeight = (int)(yScale* (int)GAME_HEIGHT);
//LOGI("wrapper xScale = %f, yScale = %f", xScale, yScale);
glversion = options->getOpenglVersion();
if (glversion == 0) {
params.DriverType = irr::video::EDT_OGLES1;
......@@ -87,10 +103,6 @@ bool Game::Initialize() {
isPSEnabled = options->isPendulumScaleEnabled();
dataManager.FileSystem = device->getFileSystem();
xScale = (float)windowWidth / GAME_WIDTH;
yScale = (float)windowHeight / GAME_HEIGHT;
LOGI("xScale = %f, yScale = %f", xScale, yScale);
//io::path databaseDir = options->getDBDir();
io::path workingDir = options->getWorkDir();
LOGI("workingDir= %s", workingDir.c_str());
......@@ -118,9 +130,9 @@ bool Game::Initialize() {
for(int i=0;i<len;i++){
io::path zip_path = zips[i];
if(dataManager.FileSystem->addFileArchive(zip_path.c_str(), false, false, EFAT_ZIP)) {
LOGD("add arrchive ok %s", zip_path.c_str());
LOGD("add arrchive ok [%s]", zip_path.c_str());
}else{
LOGD("add arrchive fail %s", zip_path.c_str());
LOGW("add arrchive fail [%s]", zip_path.c_str());
}
}
......@@ -187,7 +199,7 @@ bool Game::Initialize() {
if(dataManager.LoadDB(wpath)) {
LOGD("add cdb ok:%s", cdb_path.c_str());
}else{
LOGD("add cdb fail:%s", cdb_path.c_str());
LOGW("add cdb fail [%s]", cdb_path.c_str());
}
}
//if(!dataManager.LoadDB(workingDir.append("/cards.cdb").c_str()))
......@@ -199,10 +211,10 @@ bool Game::Initialize() {
return false;
env = device->getGUIEnvironment();
bool isAntialias = options->isFontAntiAliasEnabled();
numFont = irr::gui::CGUITTFont::createTTFont(driver, dataManager.FileSystem, gameConf.numfont, (int)16 * yScale, isAntialias, false);
adFont = irr::gui::CGUITTFont::createTTFont(driver, dataManager.FileSystem, gameConf.numfont, (int)12 * yScale, isAntialias, false);
lpcFont = irr::gui::CGUITTFont::createTTFont(driver, dataManager.FileSystem, gameConf.numfont, (int)48 * yScale, isAntialias, true);
guiFont = irr::gui::CGUITTFont::createTTFont(driver, dataManager.FileSystem, gameConf.textfont, (int)gameConf.textfontsize * yScale, isAntialias, true);
numFont = irr::gui::CGUITTFont::createTTFont(driver, dataManager.FileSystem, gameConf.numfont, ((int)16 * yScale)/2*2, isAntialias, false);
adFont = irr::gui::CGUITTFont::createTTFont(driver, dataManager.FileSystem, gameConf.numfont, ((int)12 * yScale)/2*2, isAntialias, false);
lpcFont = irr::gui::CGUITTFont::createTTFont(driver, dataManager.FileSystem, gameConf.numfont, ((int)48 * yScale)/2*2, isAntialias, true);
guiFont = irr::gui::CGUITTFont::createTTFont(driver, dataManager.FileSystem, gameConf.textfont, ((int)gameConf.textfontsize * yScale)/2*2, isAntialias, true);
textFont = guiFont;
if(!numFont || !textFont) {
LOGW("add font fail ");
......@@ -640,7 +652,7 @@ bool Game::Initialize() {
btnOperation = env->addButton(rect<s32>(1 * xScale, 409 * yScale, 105 * xScale, 459 * yScale), wCmdMenu, BUTTON_CMD_ACTIVATE, dataManager.GetSysString(1161));
btnReset = env->addButton(rect<s32>(1 * xScale, 460 * yScale , 105 * xScale, 510 * yScale), wCmdMenu, BUTTON_CMD_RESET, dataManager.GetSysString(1162));
//deck edit
wDeckEdit = env->addStaticText(L"", rect<s32>(309 * xScale, 8 * yScale, 605 * xScale, 130 * yScale), true, false, 0, -1, true);
wDeckEdit = env->addStaticText(L"", rect<s32>(309 * xScale, 1 * yScale, 605 * xScale, 130 * yScale), true, false, 0, -1, true);
wDeckEdit->setVisible(false);
btnManageDeck = env->addButton(rect<s32>(225 * xScale, 5 * yScale, 290 * xScale, 30 * yScale), wDeckEdit, BUTTON_MANAGE_DECK, dataManager.GetSysString(1460));
//deck manage
......@@ -725,7 +737,7 @@ bool Game::Initialize() {
wSort->setVisible(false);
//filters
#ifdef _IRR_ANDROID_PLATFORM_
wFilter = env->addStaticText(L"", rect<s32>(610 * xScale, 8 * yScale, 1020 * xScale, 130 * yScale), true, false, 0, -1, true);
wFilter = env->addStaticText(L"", rect<s32>(610 * xScale, 1 * yScale, 1020 * xScale, 130 * yScale), true, false, 0, -1, true);
wFilter->setVisible(false);
env->addStaticText(dataManager.GetSysString(1311), rect<s32>(10 * xScale, 5 * yScale, 70 * xScale, 25 * yScale), false, false, wFilter);
cbCardType = CAndroidGUIComboBox::addAndroidComboBox(env, rect<s32>(60 * xScale, 3 * yScale, 120 * xScale, 23 * yScale), wFilter, COMBOBOX_MAINTYPE);
......@@ -935,7 +947,7 @@ bool Game::Initialize() {
btnCancelOrFinish->setVisible(false);
#endif
//leave/surrender/exit
btnLeaveGame = env->addButton(rect<s32>(205 * xScale, 10 * yScale, 305 * xScale, 80 * yScale), 0, BUTTON_LEAVE_GAME, L"");
btnLeaveGame = env->addButton(rect<s32>(205 * xScale, 1 * yScale, 305 * xScale, 80 * yScale), 0, BUTTON_LEAVE_GAME, L"");
btnLeaveGame->setVisible(false);
//tip
stTip = env->addStaticText(L"", rect<s32>(0, 0, 150 * xScale, 150 * yScale), false, true, 0, -1, true);
......@@ -1759,14 +1771,8 @@ JNIEnv* Game::getJniEnv(){
#endif
void Game::refreshTexture(){
#ifdef _IRR_ANDROID_PLATFORM_
LOGD("refreshTexture before");
#endif
gMutex.lock();
textFont->setTransparency(true);
gMutex.unlock();
#ifdef _IRR_ANDROID_PLATFORM_
LOGD("refreshTexture after");
#endif
}
}
......@@ -33,7 +33,7 @@ namespace irr
{
CIrrDeviceAndroid::CIrrDeviceAndroid(const SIrrlichtCreationParameters& param)
: CIrrDeviceStub(param), Focused(true), Initialized(false), Paused(true), JNIEnvAttachedToVM(0)
: CIrrDeviceStub(param), Focused(false), Initialized(false), Paused(true), JNIEnvAttachedToVM(0)
{
#ifdef _DEBUG
setDebugName("CIrrDeviceAndroid");
......@@ -163,7 +163,7 @@ bool CIrrDeviceAndroid::isWindowFocused() const
bool CIrrDeviceAndroid::isWindowMinimized() const
{
return Paused;
return !Focused;
}
void CIrrDeviceAndroid::closeDevice()
......@@ -201,47 +201,44 @@ void CIrrDeviceAndroid::handleAndroidCommand(ANDROID_APP app, int32_t cmd)
{
CIrrDeviceAndroid* device = (CIrrDeviceAndroid*)app->userData;
switch (cmd) {
switch (cmd)
{
case APP_CMD_SAVE_STATE:
os::Printer::log("Android command APP_CMD_SAVE_STATE", ELL_DEBUG);
break;
case APP_CMD_INIT_WINDOW: {
break;
case APP_CMD_INIT_WINDOW:
char log_init_window[256];
os::Printer::log("Android command APP_CMD_INIT_WINDOW", ELL_DEBUG);
device->getExposedVideoData().OGLESAndroid.Window = app->window;
if (device->CreationParams.WindowSize.Width == 0 ||
device->CreationParams.WindowSize.Height == 0) {
if (device->CreationParams.WindowSize.Width == 0 || device->CreationParams.WindowSize.Height == 0)
{
device->CreationParams.WindowSize.Width = ANativeWindow_getWidth(app->window);
device->CreationParams.WindowSize.Height = ANativeWindow_getHeight(app->window);
}
sprintf(log_init_window, "init window: width = %d, height = %d",
ANativeWindow_getWidth(app->window), ANativeWindow_getHeight(app->window));
sprintf(log_init_window, "init window: width = %d, height = %d", ANativeWindow_getWidth(app->window), ANativeWindow_getHeight(app->window));
os::Printer::log(log_init_window);
device->getContextManager()->initialize(device->CreationParams,
device->ExposedVideoData);
device->getContextManager()->initialize(device->CreationParams, device->ExposedVideoData);
device->getContextManager()->generateSurface();
device->getContextManager()->generateContext();
device->getContextManager()->activateContext(
device->getContextManager()->getContext());
if (device->CreationParams.WindowSize.Width != 1 &&
device->CreationParams.WindowSize.Height != 1) {
if (!device->Initialized) {
io::CAndroidAssetFileArchive *assets = new io::CAndroidAssetFileArchive(
device->Android->activity->assetManager, false, false);
assets->addDirectoryToFileList("");
device->FileSystem->addFileArchive(assets);
assets->drop();
device->createDriver();
if (device->VideoDriver)
device->createGUIAndScene();
}
device->Initialized = true;
device->getContextManager()->activateContext(device->getContextManager()->getContext());
if (device->CreationParams.WindowSize.Width != 1 && device->CreationParams.WindowSize.Height != 1)
{
if (!device->Initialized)
{
io::CAndroidAssetFileArchive* assets = new io::CAndroidAssetFileArchive( device->Android->activity->assetManager, false, false);
assets->addDirectoryToFileList("");
device->FileSystem->addFileArchive(assets);
assets->drop();
device->createDriver();
if (device->VideoDriver)
device->createGUIAndScene();
}
device->Initialized = true;
}
}
break;
break;
case APP_CMD_TERM_WINDOW:
os::Printer::log("Android command APP_CMD_TERM_WINDOW", ELL_DEBUG);
device->getContextManager()->destroySurface();
......@@ -275,12 +272,13 @@ void CIrrDeviceAndroid::handleAndroidCommand(ANDROID_APP app, int32_t cmd)
}
device->Initialized = true;
}
}
// device->Focused = true;
device->Focused = true;
break;
case APP_CMD_LOST_FOCUS:
os::Printer::log("Android command APP_CMD_LOST_FOCUS", ELL_DEBUG);
// device->Focused = false;
device->Focused = false;
break;
case APP_CMD_DESTROY:
os::Printer::log("Android command APP_CMD_DESTROY", ELL_DEBUG);
......
......@@ -16,7 +16,7 @@ public class YGOCore{
private static final String TAG = "ygomobile";
public static int gPid;
private static YGOCore sYGOCore;
private static final boolean DISABLE_THREAD = false;
private static final boolean DISABLE_THREAD = true;
public static YGOCore getInstance(){
if(sYGOCore == null){
......@@ -95,7 +95,6 @@ public class YGOCore{
H.post(new Runnable() {
@Override
public void run() {
Log.i(TAG, "touch " + x + "x" + y);
sendTouchInner(action, x, y, id);
}
});
......
......@@ -25,6 +25,7 @@ android {
assets.srcDirs = ['../libcore/src/main/assets']
java.srcDirs = ['../libcore/src/main/java']
res.srcDirs = ['../libcore/src/main/res']
manifest.srcFile '../libcore/src/main/AndroidManifest.xml'
}
}
}
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="cn.garymb.ygomobile.lib">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application>
<receiver android:name="cn.garymb.ygomobile.GameReceiver"
android:process=":game" >
<intent-filter>
<action android:name="cn.garymb.ygomobile.game.start"/>
<action android:name="cn.garymb.ygomobile.game.stop"/>
</intent-filter>
</receiver>
</application>
</manifest>
......@@ -17,19 +17,19 @@
特别感谢: 菜菜,尸体,废话多,大毛,龙道香姐,晓L,幻兽L 的支持与努力.
</pre>
<ul>
<li style="color:#ffff00">3.5.1</li>
<li style="color:#ffff00">3.5.2</li>
</ul>
<pre>
更新:
1.更新ygo内核;
2.新卡SR09+VJ+SJ;
3.2019.10TCG禁卡表;
2.新卡1011;
修复:
1.部分全面屏手机点击和显示偏移的问题;
2.悬浮窗权限打开问题;
新增:
1.设置里可开启强制16:9比例画面;
2.增加对更多异形屏支持;
1.部分全面屏手机点击和显示不正常的问题;
3.横屏游戏时导航栏无法下拉和无法收起问题;
变更:
1.默认沉浸式ygopro画面,不再允许开关;
2.已开启ygopro的场合,点加入服务器不会
再重复建房(避免多窗口遮挡);
</pre>
</body>
</html>
\ No newline at end of file
......@@ -8,8 +8,8 @@ android {
applicationId "cn.garymb.ygomobile"
minSdkVersion 21
targetSdkVersion 28
versionCode 351001010
versionName "3.5.1"
versionCode 352001017
versionName "3.5.2"
flavorDimensions "versionCode"
vectorDrawables.useSupportLibrary = true
ndk {
......@@ -115,4 +115,6 @@ dependencies {
implementation 'com.yuyh.imgsel:library:2.0.6'
//跨进程SharedPreferencesPlus工具
implementation 'com.github.zhangliangming:PreferencesProvider:v1.3'
implementation 'com.jonathanfinerty.once:once:1.3.0'
}
......@@ -86,7 +86,7 @@
<activity
android:name="cn.garymb.ygomobile.YGOMobileActivity"
android:theme="@style/AppTheme.Game"
tools:replace="android:theme" >
tools:replace="android:theme">
<meta-data
android:name="android.notch_support"
android:value="true"/>
......
package cn.garymb.ygomobile;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.AssetManager;
import android.graphics.Point;
import android.os.Build;
import android.os.Process;
import android.util.Log;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatDelegate;
......@@ -14,11 +19,14 @@ import com.bumptech.glide.Glide;
import com.yuyh.library.imgsel.ISNav;
import com.yuyh.library.imgsel.common.ImageLoader;
import java.lang.reflect.Method;
import cn.garymb.ygomobile.interfaces.GameConfig;
import cn.garymb.ygomobile.interfaces.GameHost;
import cn.garymb.ygomobile.lite.BuildConfig;
import cn.garymb.ygomobile.utils.CrashHandler;
import cn.garymb.ygomobile.utils.ScreenUtil;
import jonathanfinerty.once.Once;
public class App extends GameApplication implements GameConfig {
private GameHost gameHost;
......@@ -26,16 +34,44 @@ public class App extends GameApplication implements GameConfig {
@Override
public void onCreate() {
super.onCreate();
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
boolean isGameProcess = getCurrentProcessName().endsWith(":game");
if (!isGameProcess) {
Once.initialise(this);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
//初始化图片选择器
initImgsel();
// QbSdk.initX5Environment(this, null);
// QbSdk.setCurrentID("");
}
AppsSettings.init(this);
//初始化异常工具类
CrashHandler crashHandler = CrashHandler.getInstance();
crashHandler.init(getApplicationContext());
gameHost = new LocalGameHost(this);
//初始化图片选择器
initImgsel();
// QbSdk.initX5Environment(this, null);
// QbSdk.setCurrentID("");
}
@SuppressLint({"PrivateApi", "DiscouragedPrivateApi"})
private String getCurrentProcessName() {
if (Build.VERSION.SDK_INT >= 28) {
return getProcessName();
}
try {
Class clazz = Class.forName("android.app.ActivityThread");
Method currentProcessName = clazz.getDeclaredMethod("currentProcessName");
return (String) currentProcessName.invoke(null);
} catch (Throwable e) {
Log.w("kk", "currentProcessName", e);
}
int pid = Process.myPid();
String processName = getPackageName();
ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningAppProcessInfo info : am.getRunningAppProcesses()) {
if (info.pid == pid) {
processName = info.processName;
break;
}
}
return processName;
}
private void initImgsel() {
......@@ -63,7 +99,7 @@ public class App extends GameApplication implements GameConfig {
return getAssets();
}
private class LocalGameHost extends GameHost{
private class LocalGameHost extends GameHost {
LocalGameHost(Context context) {
super(context);
}
......@@ -95,7 +131,9 @@ public class App extends GameApplication implements GameConfig {
intent.setAction("RUN_WINDBOT");
sendBroadcast(intent);
}
};
}
;
@Override
public boolean isKeepScale() {
......@@ -137,13 +175,13 @@ public class App extends GameApplication implements GameConfig {
// h = Math.min(size.x, size.y);
// h -= AppsSettings.get().getNotchHeight();
// } else {
int w1 = activity.getWindowManager().getDefaultDisplay().getWidth();
int h1 = activity.getWindowManager().getDefaultDisplay().getHeight();
w = Math.max(w1, h1);
h = Math.min(w1, h1);
if(isImmerSiveMode()){
h += ScreenUtil.getCurrentNavigationBarHeight(activity);
}
int w1 = activity.getWindowManager().getDefaultDisplay().getWidth();
int h1 = activity.getWindowManager().getDefaultDisplay().getHeight();
w = Math.max(w1, h1);
h = Math.min(w1, h1);
if (isImmerSiveMode()) {
h += ScreenUtil.getCurrentNavigationBarHeight(activity);
}
// }
return new int[]{w, h};
}
......
......@@ -53,13 +53,14 @@ public interface Constants {
String SETTINGS_AVATAR = "settings_game_avatar";
String SETTINGS_CARD_BG = "settings_game_diy_card_bg";
String ASSETS_PATH = "data/";
String ASSET_SERVER_LIST = "serverlist.xml";
String ASSET_LIMIT_PNG = ASSETS_PATH + "textures/lim.png";
String DEFAULT_FONT_NAME = "ygo.ttf";
String DATABASE_NAME = "cards.cdb";
String BOT_CONF = "bot.conf";
String WINDBOT_PATH = "windbot";
String WINDBOT_DECK_PATH = "Decks";
String LIB_WINDBOT_PATH = WINDBOT_PATH + "/";
String LIB_WINDBOT_DECK_PATH = "windbot/" + WINDBOT_DECK_PATH;
String LIB_WINDBOT_DIALOG_PATH = "windbot/Dialogs";
String FONT_DIRECTORY = "fonts";
String CORE_STRING_PATH = "strings.conf";
String CORE_LIMIT_PATH = "lflist.conf";
......@@ -73,8 +74,8 @@ public interface Constants {
String CORE_EXPANSIONS = "expansions";
String CORE_SINGLE_PATH = "single";
String CORE_IMAGE_PATH = "pics";
String MOBILE_LOG="log";
String MOBILE_DECK_SHARE="deckShare";
String MOBILE_LOG = "log";
String MOBILE_DECK_SHARE = "deckShare";
String CORE_EXPANSIONS_IMAGE_PATH = "expansions/pics";
String CORE_IMAGE_FIELD_PATH = "field";
String CORE_SCRIPT_PATH = "script";
......@@ -90,6 +91,25 @@ public interface Constants {
String CORE_SKIN_AVATAR_OPPONENT = "opponent.jpg";
String UNKNOWN_IMAGE = "unknown.jpg";
String YDK_FILE_EX = ".ydk";
String WINDBOT_ACTION = "RUN_WINDBOT";
String CORE_CONF_PATH = "conf";
String ASSET_SERVER_LIST = "serverlist.xml";
String ASSET_LIMIT_PNG = ASSETS_PATH + "textures/lim.png";
String ASSET_CARDS_CDB_FILE_PATH = ASSETS_PATH + DATABASE_NAME;
String ASSET_DECK_DIR_PATH = ASSETS_PATH + CORE_DECK_PATH;
String ASSET_PACK_DIR_PATH = ASSETS_PATH + CORE_PACK_PATH;
String ASSET_SINGLE_DIR_PATH = ASSETS_PATH + CORE_SINGLE_PATH;
String ASSET_SKIN_DIR_PATH = ASSETS_PATH + CORE_SKIN_PATH;
String ASSET_FONTS_DIR_PATH = ASSETS_PATH + FONT_DIRECTORY;
String ASSET_SCRIPTS_FILE_PATH = ASSETS_PATH + CORE_SCRIPTS_ZIP;
String ASSET_PICS_FILE_PATH = ASSETS_PATH + CORE_PICS_ZIP;
String ASSET_WINDBOT_DECK_DIR_PATH = ASSETS_PATH + LIB_WINDBOT_PATH + LIB_WINDBOT_DECK_PATH;
String ASSET_WINDBOT_DIALOG_DIR_PATH = ASSETS_PATH + LIB_WINDBOT_PATH + LIB_WINDBOT_DIALOG_PATH;
String ASSET_CONF_PATH = ASSETS_PATH + CORE_CONF_PATH;
String ASSET_STRING_CONF_FILE_PATH = ASSETS_PATH + CORE_CONF_PATH + "/" + CORE_STRING_PATH;
String ASSET_SKIN_PENDULUM_DIR_PATH = ASSETS_PATH + CORE_SKIN_PENDULUM_PATH;
int[] CORE_SKIN_BG_SIZE = new int[]{1280, 720};
int[] CORE_SKIN_CARD_COVER_SIZE = new int[]{177, 254};
int[] CORE_SKIN_AVATAR_SIZE = new int[]{128, 128};
......@@ -104,8 +124,8 @@ public interface Constants {
String PREF_FONT_SIZE = "pref_settings_font_size";
int DEF_PREF_FONT_SIZE = 14;
String PREF_NOTCH_HEIGHT="pref_notch_height";
int DEF_PREF_NOTCH_HEIGHT=0;
String PREF_NOTCH_HEIGHT = "pref_notch_height";
int DEF_PREF_NOTCH_HEIGHT = 0;
String PREF_ONLY_GAME = "pref_settings_only_game";
boolean DEF_PREF_ONLY_GAME = false;
......
......@@ -6,6 +6,7 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.text.TextUtils;
import android.view.View;
import android.widget.AdapterView;
......@@ -55,6 +56,12 @@ public class FileActivity extends BaseActivity implements AdapterView.OnItemClic
private void initViews() {
mFileAdapter = new FileAdapter(this);
try {
mFileAdapter.setRootPath(Environment.getExternalStorageDirectory().getAbsolutePath());
} catch (Exception e) {
mFileAdapter.setRootPath("/");
}
mListView = $(R.id.list_files);
mListView.setAdapter(mFileAdapter);
// footView = $(R.id.head_view);
......
......@@ -49,6 +49,11 @@ class FileAdapter extends BaseAdapterPlus<File> {
mOnPathChangedListener = onPathChangedListener;
}
public void setRootPath(String rootPath) {
this.rootPath = rootPath;
setPath(rootPath);
}
private String getRootPath() {
return "/";
}
......
......@@ -485,7 +485,11 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
AppsSettings.get().setLastRoomList(items);
simpleListAdapter.notifyDataSetChanged();
}
joinGame(serverInfo, name);
if (ComponentUtils.isActivityRunning(this, new ComponentName(this, YGOMobileActivity.class))){
openGame();
} else {
joinGame(serverInfo, name);
}
});
builder.setOnCloseLinster((dlg) -> {
dlg.dismiss();
......@@ -504,8 +508,6 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
YGOStarter.startGame(this, options);
}
protected abstract void checkResourceDownload(ResCheckTask.ResCheckListener listener);
protected abstract void openGame();
public abstract void updateImages();
......
......@@ -74,7 +74,6 @@ import static cn.garymb.ygomobile.Constants.PREF_USE_EXTRA_CARD_CARDS;
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;
import static cn.garymb.ygomobile.ui.home.ResCheckTask.getDatapath;
public class SettingFragment extends PreferenceFragmentPlus {
......@@ -517,12 +516,11 @@ public class SettingFragment extends PreferenceFragmentPlus {
//rename
Dialog dlg = DialogPlus.show(getActivity(), null, getString(R.string.coping_pendulum_image));
VUiKit.defer().when(() -> {
try {
IOUtils.createFolder(file);
IOUtils.copyFilesFromAssets(getActivity(), getDatapath(Constants.CORE_SKIN_PENDULUM_PATH),
file.getAbsolutePath(), false);
} catch (IOException e) {
}
IOUtils.createFolder(file);
IOUtils.copyFolder(getActivity().getAssets(), Constants.ASSET_SKIN_PENDULUM_DIR_PATH,
file.getAbsolutePath(), false);
}).fail((e)->{
dlg.dismiss();
}).done((re) -> {
dlg.dismiss();
});
......
......@@ -48,7 +48,7 @@ public class IOUtils {
if (file == null || !file.exists()) return;
if (file.isFile()) {
file.delete();
} else if(file.isDirectory()){
} else if (file.isDirectory()) {
File[] files = file.listFiles();
if (files != null) {
for (File f : files) {
......@@ -63,19 +63,6 @@ public class IOUtils {
return new File(src).renameTo(new File(to));
}
public static boolean isDirectory(Context context, String assets) {
String[] files = new String[0];
try {
files = context.getAssets().list(assets);
} catch (IOException e) {
}
if (files != null && files.length > 0) {
return true;
}
return false;
}
public static String tirmName(String name, String ex) {
if (name.toLowerCase(Locale.US).endsWith(ex)) {
int i = name.lastIndexOf(".");
......@@ -106,70 +93,80 @@ public class IOUtils {
return new File(path).getName();
}
public static int copyFilesFromAssets(Context context, String assets, String toPath, boolean update) throws IOException {
AssetManager am = context.getAssets();
String[] files = am.list(assets);
if (files == null) {
public static boolean copyFile(AssetManager mgr, String path, File file, boolean update) {
if (Constants.DEBUG)
Log.d(TAG, "copyFile:" + path + "-->" + file.getAbsolutePath());
InputStream inputStream = null;
boolean ret = false;
try {
inputStream = mgr.open(path);
if(update || !file.exists()) {
createFolderByFile(file);
ret = copyToFile(mgr.open(path), file.getAbsolutePath());
}else{
ret = true;
}
} catch (IOException e) {
e.printStackTrace();
} finally {
close(inputStream);
}
return ret;
}
public static int copyFolder(AssetManager mgr, String srcDir, String dstDir, boolean update) {
String[] files = null;
try {
files = mgr.list(srcDir);
} catch (IOException e) {
return 0;
}
if (files == null || files.length == 0) {
if (Constants.DEBUG)
Log.w(TAG, "copy dir:" + srcDir + "-->" + dstDir+", not files");
return 0;
}
if (files.length == 0) {
//is file
String file = getName(assets);
File tofile = new File(toPath, file);
if (update || !tofile.exists()) {
File dir = new File(dstDir);
createFolder(dir);
if (Constants.DEBUG)
Log.i(TAG, "copy dir:" + srcDir + "-->" + dstDir+", count="+files.length);
int count = 0;
for (String file : files) {
String assetPath = join(srcDir, file);
File toPath = new File(dstDir, file);
if (update || !toPath.exists()) {
if (Constants.DEBUG)
Log.i(TAG, "copy1:" + assets + "-->" + tofile);
createFolderByFile(tofile);
Log.d(TAG, "copy file:" + assetPath + "-->" + toPath.getAbsolutePath());
InputStream inputStream = null;
try {
inputStream = am.open(assets);
}catch (Exception e){
}
if(inputStream != null) {
copyToFile(inputStream, tofile.getAbsolutePath());
}else{
return 0;
}
}
return 1;
} else {
int count = 0;
File toDir = new File(toPath);
createFolder(toDir);
for (String file : files) {
String path = join(assets, file);
if (isDirectory(context, path)) {
if (Constants.DEBUG)
Log.i(TAG, "copy dir:" + path + "-->" + join(toPath, file));
createFolderByFile(new File(toPath, file));
count += copyFilesFromAssets(context, path, join(toPath, file), update);
} else {
File f = new File(join(toPath, file));
createFolderByFile(f);
if (update || !f.exists()) {
if (Constants.DEBUG)
Log.d(TAG, "copy2:" + path + "-->" + f.getAbsolutePath());
copyToFile(am.open(path), f.getAbsolutePath());
} else {
if (Constants.DEBUG)
Log.d(TAG, "copy ignore:" + path + "-->" + f.getAbsolutePath());
inputStream = mgr.open(assetPath);
if (copyToFile(inputStream, toPath.getAbsolutePath())) {
count++;
}
count++;
}catch (IOException e){
e.printStackTrace();
}finally {
close(inputStream);
}
} else {
count++;
if (Constants.DEBUG)
Log.d(TAG, "copy ignore:" + assetPath + "-->" + toPath.getAbsolutePath());
}
return count;
}
return count;
}
public static void createFolderByFile(File file) {
File dir = file.getParentFile();
if (dir != null && !dir.exists()) {
dir.mkdirs();
}
}
public static boolean createFolder(File file) {
if (!file.exists()) {
return file.mkdirs();
return file.mkdirs();
}
return false;
}
......@@ -182,30 +179,27 @@ public class IOUtils {
}
}
public static boolean hasAssets(Context context, String name) {
public static boolean hasAssets(AssetManager mgr, String name) {
try {
context.getAssets().open(name);
mgr.open(name);
} catch (IOException e) {
return false;
}
return true;
}
public static void copyToFile(InputStream in, String file) {
public static boolean copyToFile(InputStream in, String file) {
FileOutputStream outputStream = null;
try {
// File dir = new File(file).getParentFile();
// if (dir != null && !dir.exists()) {
// dir.mkdirs();
// }
outputStream = new FileOutputStream(file);
copy(in, outputStream);
} catch (Exception e) {
return false;
} finally {
close(outputStream);
close(in);
}
return true;
}
public static boolean createNoMedia(String path) {
......@@ -238,13 +232,12 @@ public class IOUtils {
os.write(buffer, 0, len);
}
} finally {
if (os!=null)
os.close();
if (os != null)
os.close();
is.close();
}
return new File(outPath);
}
}
......@@ -156,11 +156,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="@drawable/left"
android:background="@drawable/blue"
android:orientation="vertical"
android:paddingLeft="4dp"
android:paddingTop="2dp"
android:paddingRight="4dp">
android:paddingRight="5dp">
<LinearLayout
android:layout_width="match_parent"
......
......@@ -90,7 +90,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/left"
android:background="@drawable/blue"
android:orientation="vertical"
android:paddingLeft="4dp"
android:paddingTop="2dp"
......
......@@ -61,7 +61,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/left"
android:background="@drawable/blue"
android:orientation="vertical"
android:paddingLeft="4dp"
android:paddingTop="2dp"
......
......@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/right"
android:background="@drawable/red"
android:orientation="vertical"
android:padding="10dp"
......
......@@ -30,6 +30,5 @@
<item>초보유저든, 복귀유저든 배울 마음만 있다면 크게 어렵지 않습니다.</item>
<item>덱 관리자에서 카드를 제거하실려면 제거할 카드를 길게 눌러주세요.</item>
<item>방 번호가 너무 많이 기록되어 있을 경우 기록된 방 번호를 길게 누르시면 지워집니다.</item>
<item>이미지 변경에 실패한 경우 갤러리 또는 파일 관리 앱을 선택후 시도해보십시오.</item>
</string-array>
</resources>
\ No newline at end of file
......@@ -11,7 +11,7 @@
</string-array>
<string-array name="tips" tools:ignore="InconsistentArrays">
<item>游戏王圈子不大,珍惜一起玩的人</item>
<item>决斗界面点触不准?可以去手机设置→显示设置→隐藏刘海</item>
<item>决斗界面点触不准?可以去手机设置→更多显示设置→隐藏顶部区域</item>
<item>主页每个服务器按住左划就会出现「编辑」和「删除」哦</item>
<item>试试点击左下角浮动的「功能菜单」会有更多功能</item>
<item>想不联网也打人机?「功能菜单」→「单人游戏」→「人机模式」</item>
......@@ -19,7 +19,7 @@
<item>卡组自己组更能享受游戏乐趣,自己组也更容易神抽哦</item>
<item>看到每个服务器右下的宝石了吗?点点看吧</item>
<item>先行卡和正式卡密码不同,打了补丁要注意区分哦</item>
<item>觉得遇到BUG先确定是否真的是BUG再进行反馈哈</item>
<item>觉得遇到BUG先请准备好局面截图和录像再反馈</item>
<item>不懂怎么更新?去「功能菜单」→「设置」→「检查更新」看看</item>
<item>不知道怎么用,可以点开「功能菜单」→「教程」查看使用方法</item>
<item>维护开发不容易,欢迎前往「功能菜单」→「支持我们」留下您的心意</item>
......@@ -30,6 +30,5 @@
<item>不管是新手还是回归玩家,只要肯学习,不用多久就能成为大佬哦</item>
<item>竖屏卡组编辑中想删除某张卡只需要长按它就好啦</item>
<item>房间号记录太多遮住按钮了?长按某个记录就会自动删除哦</item>
<item>如果改头像等图片出现加载失败,请点击左上角选择“图库”或“文件”里的图片试试</item>
</string-array>
</resources>
\ No newline at end of file
......@@ -19,7 +19,7 @@
<item>Build your own Deck will gain More Lucky Drawing</item>
<item>Have you see the ball at bottom-right in every severlist? Try to click it</item>
<item>Released and Pre-released Cards are different,pls note after patch them</item>
<item>Pls Confirm that is a ture BUG before Report</item>
<item>Before BUG Reporting\,Pls prepare the screenshoot and replay</item>
<item>if you dont know how to use YGOMobile,Try to Click Everywhere</item>
<item>Keeping Developing isnot EZ,Welcome to Click and Leave your Donation</item>
<item>there is no so-called MR4, that is New Master Rule</item>
......@@ -29,6 +29,5 @@
<item>Keep playing and learning, you will be stronger soon.even you are beginner and returner</item>
<item>Long-pressing the card you wanna delete in vertical deck editor</item>
<item>Long-pressing the password record to delete it</item>
<item>If change avatars(cover or bg) failed, try to find artworks in gallery or file manager</item>
</string-array>
</resources>
\ No newline at end of file
......@@ -23,7 +23,7 @@
<color name="holo_blue_light">#ff33b5e5</color>
<color name="holo_green_bright">#95d389</color>
<color name="holo_orange_bright">#ff982a</color>
<color name="FallNavy">#11113d</color>
<color name="colorMain">#2196F3</color>
<color name="background">#ECEFF1</color>
</resources>
\ No newline at end of file
......@@ -40,7 +40,7 @@
<style name="AppTheme.Game" parent="android:Theme.Holo.NoActionBar.Fullscreen">
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowDisablePreview">true</item>
<item name="android:windowBackground">@drawable/game_bg_blue</item>
<item name="android:windowBackground">@color/FallNavy</item>
</style>
<style name="AppTheme.Logo" parent="AppTheme">
......
......@@ -17,7 +17,7 @@
<CheckBoxPreference
android:key="pref_settings_keep_scale"
android:persistent="false"
android:title="@string/about_pref_settings_keep_scale"/>
android:title="@string/about_pref_settings_keep_scale" />
<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