Commit 1277b418 authored by fallenstardust's avatar fallenstardust

将personalfragment改为settingfragment

parent dc278589
......@@ -24,6 +24,7 @@ android {
productFlavors {
cn {
resValue 'string', 'app_name', 'YGOMobile'
applicationIdSuffix ".CN"
buildConfigField 'String', 'URL_DONATE', '"https://afdian.net/@ygomobile"'
manifestPlaceholders = [APP_ID: "0b6f110306"]
}
......@@ -150,6 +151,4 @@ dependencies {
implementation 'com.ashokvarma.android:bottom-navigation-bar:2.2.0'
//圆形头像
implementation 'de.hdodenhof:circleimageview:2.2.0'
//litepal
implementation 'org.litepal.android:java:3.0.0'
}
......@@ -17,8 +17,6 @@ import com.tencent.smtt.sdk.QbSdk;
import com.yuyh.library.imgsel.ISNav;
import com.yuyh.library.imgsel.common.ImageLoader;
import org.litepal.LitePal;
import java.util.HashMap;
import cn.garymb.ygomobile.lite.BuildConfig;
......@@ -35,7 +33,6 @@ public class App extends GameApplication {
super.onCreate();
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
AppsSettings.init(this);
LitePal.initialize(getApplicationContext());
//初始化异常工具类
CrashHandler crashHandler = CrashHandler.getInstance();
crashHandler.init(getApplicationContext());
......
......@@ -39,6 +39,8 @@ public interface Constants {
boolean PREF_DEF_SENSOR_REFRESH = true;
String PREF_CHANGE_LOG = "pref_key_change_log";
String PREF_CHECK_UPDATE = "pref_key_about_check_update";
String PREF_RESET_GAME_RES = "pref_key_reset_game_res";
String PREF_JOIN_QQ = "pref_key_join_qq";
String PREF_DEL_EX = "pref_key_settings_delete_ex";
String PREF_LAST_ROOM_LIST = "pref_key_lastroom_list";
String PERF_TEST_REPLACE_KERNEL = "pref_key_test_replace_kernel";
......
......@@ -41,8 +41,7 @@ public class FileActivity extends BaseActivity implements AdapterView.OnItemClic
if (doIntent(getIntent())) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_filebrowser);
Toolbar toolbar = $(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().hide();
enableBackHome();
initViews();
mFileAdapter.setOnPathChangedListener(this);
......
......@@ -23,7 +23,7 @@ import cn.garymb.ygomobile.ui.activities.BaseActivity;
import cn.garymb.ygomobile.ui.cards.CardSearchFragment;
import cn.garymb.ygomobile.ui.cards.DeckManagerFragment;
import cn.garymb.ygomobile.ui.mycard.MycardFragment;
import cn.garymb.ygomobile.ui.settings.PersonalFragment;
import cn.garymb.ygomobile.ui.settings.fragments.SettingFragment;
import cn.garymb.ygomobile.utils.ScreenUtil;
public abstract class HomeActivity extends BaseActivity implements BottomNavigationBar.OnTabSelectedListener {
......@@ -38,7 +38,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
public CardSearchFragment fragment_search;
public DeckManagerFragment fragment_deck_cards;
public MycardFragment fragment_mycard;
public PersonalFragment fragment_personal;
public SettingFragment fragment_settings;
private Bundle mBundle;
......@@ -83,7 +83,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
super.onNewIntent(intent);
int mFlag = intent.getIntExtra("flag", 0);
if (mFlag == 4) { //判断获取到的flag值
switchFragment(fragment_personal, 4, false);
switchSettingFragment();
} else if (mFlag == 3) {
switchFragment(fragment_mycard, 3, false);
} else if (intent.hasExtra(Intent.EXTRA_TEXT)) {
......@@ -118,11 +118,10 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
fragment_search = new CardSearchFragment();
fragment_deck_cards = new DeckManagerFragment();
fragment_mycard = new MycardFragment();
fragment_personal = new PersonalFragment();
fragment_settings = new SettingFragment();
mFragment = fragment_home;
getSupportFragmentManager().beginTransaction()
.add(R.id.fragment_content, fragment_home)
.commit();
getSupportFragmentManager().beginTransaction().add(R.id.fragment_content, fragment_home).commit();
getFragmentManager().beginTransaction().add(R.id.fragment_content, fragment_settings).hide(fragment_settings).commit();
getSupportActionBar().hide();
}
......@@ -142,41 +141,49 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
switchFragment(fragment_mycard, position, false);
break;
case 4:
switchFragment(fragment_personal, position, false);
switchSettingFragment();
break;
}
}
public void switchSettingFragment() {
bottomNavigationBar.setFirstSelectedPosition(4).initialise();
getSupportFragmentManager().beginTransaction().hide(mFragment).commit();
getFragmentManager().beginTransaction().show(fragment_settings).commit();
}
public void switchFragment(Fragment fragment, int page, boolean replace) {
if (fragment_settings.isVisible())
getFragmentManager().beginTransaction().hide(fragment_settings).commit();
//用于intent到指定fragment时底部图标也跟着设置为选中状态
bottomNavigationBar.setFirstSelectedPosition(page).initialise();
//
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
//FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
if (mFragment.isHidden())
transaction.show(mFragment).commit();
getSupportFragmentManager().beginTransaction().show(mFragment).commit();
//判断当前显示的Fragment是不是切换的Fragment
if (mFragment != fragment) {
//判断切换的Fragment是否已经添加过
if (!fragment.isAdded()) {
//如果没有,则先把当前的Fragment隐藏,把切换的Fragment添加上
transaction.hide(mFragment)
getSupportFragmentManager().beginTransaction().hide(mFragment)
.add(R.id.fragment_content, fragment).commit();
} else {
//如果已经添加过,则先把当前的Fragment隐藏,把切换的Fragment显示出来
if (replace) {
//需要重新加载onCreateView需要detach再attach,而不是replace
transaction.hide(mFragment).detach(fragment).attach(fragment)
getSupportFragmentManager().beginTransaction().hide(mFragment).detach(fragment).attach(fragment)
.show(fragment)//重启该fragment后需要重新show
.commit();
} else {
transaction.hide(mFragment).show(fragment).commit();
getSupportFragmentManager().beginTransaction().hide(mFragment).show(fragment).commit();
}
}
mFragment = fragment;
} else {
if (replace) {
//需要重新加载onCreateView需要detach再attach,而不是replace
transaction.hide(mFragment).detach(fragment).attach(fragment)
getSupportFragmentManager().beginTransaction().hide(mFragment).detach(fragment).attach(fragment)
.show(fragment)//重启该fragment后需要重新show
.commit();
}
......
......@@ -129,10 +129,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View layoutView;
if (isHorizontal)
layoutView = inflater.inflate(R.layout.main_horizontal_fragment, container, false);
else
layoutView = inflater.inflate(R.layout.fragment_home, container, false);
layoutView = inflater.inflate(R.layout.fragment_home, container, false);
initBanner(layoutView, savedInstanceState);
initView(layoutView);
//初始化决斗助手
......@@ -207,7 +204,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
//轮播图
public void initBanner(View view, Bundle saveBundle) {
xb_banner = view.findViewById(R.id.xb_banner);
cv_banner = view.findViewById(R.id.cv_banner);
cv_banner = (CardView) view.findViewById(R.id.cv_banner);
cv_banner.post(() -> {
ViewGroup.LayoutParams layoutParams = cv_banner.getLayoutParams();
layoutParams.width = cv_banner.getWidth();
......@@ -571,75 +568,6 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
YGOStarter.startGame(getActivity(), null);
}
public void updateImages() {
Log.e("MainActivity", "重置资源");
DialogPlus dialog = DialogPlus.show(getContext(), null, getString(R.string.message));
dialog.show();
VUiKit.defer().when(() -> {
Log.e("MainActivity", "开始复制");
try {
IOUtils.createNoMedia(AppsSettings.get().getResourcePath());
FileUtils.delFile(AppsSettings.get().getResourcePath() + "/" + Constants.CORE_SCRIPT_PATH);
if (IOUtils.hasAssets(getContext(), getDatapath(Constants.CORE_PICS_ZIP))) {
IOUtils.copyFilesFromAssets(getContext(), getDatapath(Constants.CORE_PICS_ZIP),
AppsSettings.get().getResourcePath(), true);
}
if (IOUtils.hasAssets(getContext(), getDatapath(Constants.CORE_SCRIPTS_ZIP))) {
IOUtils.copyFilesFromAssets(getContext(), getDatapath(Constants.CORE_SCRIPTS_ZIP),
AppsSettings.get().getResourcePath(), true);
}
IOUtils.copyFilesFromAssets(getContext(), getDatapath(Constants.DATABASE_NAME),
AppsSettings.get().getResourcePath(), true);
IOUtils.copyFilesFromAssets(getContext(), getDatapath(Constants.CORE_STRING_PATH),
AppsSettings.get().getResourcePath(), true);
IOUtils.copyFilesFromAssets(getContext(), getDatapath(Constants.WINDBOT_PATH),
AppsSettings.get().getResourcePath(), true);
IOUtils.copyFilesFromAssets(getContext(), getDatapath(Constants.CORE_SKIN_PATH),
AppsSettings.get().getCoreSkinPath(), false);
String fonts = AppsSettings.get().getResourcePath() + "/" + Constants.FONT_DIRECTORY;
if (new File(fonts).list() != null)
FileUtils.delFile(fonts);
IOUtils.copyFilesFromAssets(getContext(), getDatapath(Constants.FONT_DIRECTORY),
AppsSettings.get().getFontDirPath(), true);
/*
IOUtils.copyFilesFromAssets(this, getDatapath(Constants.CORE_SOUND_PATH),
AppsSettings.get().getSoundPath(), false);*/
//复制原目录文件
if (new File(ORI_DECK).list() != null)
FileUtils.copyDir(ORI_DECK, AppsSettings.get().getDeckDir(), false);
if (new File(ORI_REPLAY).list() != null)
FileUtils.copyDir(ORI_REPLAY, AppsSettings.get().getResourcePath() + "/" + Constants.CORE_REPLAY_PATH, false);
if (new File(ORI_PICS).list() != null)
FileUtils.copyDir(ORI_PICS, AppsSettings.get().getCardImagePath(), false);
} catch (IOException e) {
e.printStackTrace();
Log.e("MainActivity", "错误" + e);
}
}).done((rs) -> {
Toast.makeText(getContext(), R.string.done, Toast.LENGTH_SHORT).show();
dialog.dismiss();
});
}
public boolean joinQQGroup(String key) {
Intent intent = new Intent();
intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + key));
// 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面 //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
try {
startActivity(intent);
return true;
} catch (Exception e) {
// 未安装手Q或安装的版本不支持
return false;
}
}
private void duelAssistantCheck() {
if (AppsSettings.get().isServiceDuelAssistant()) {
Handler handler = new Handler();
......
package cn.garymb.ygomobile.ui.mycard.base;
import cn.garymb.ygomobile.ui.mycard.bean.McUser;
/**
* Create By feihua On 2021/10/21
*/
public interface OnMcUserListener {
void onLogin(McUser user, String exception);
void onLogout();
//是否有效
boolean isListenerEffective();
}
package cn.garymb.ygomobile.ui.mycard.bean;
import org.litepal.crud.LitePalSupport;
/**
* Create By feihua On 2021/10/26
*/
public class McUser extends LitePalSupport {
private int id;
private int external_id;
private String username;
private String name;
private String email;
private String avatar_url;
private boolean admin;
private boolean moderator;
private boolean login;
public McUser() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getJID() {
return username + "@mycard.moe";
}
public String getPassword() {
return String.valueOf(external_id);
}
public String getConference() {
return "ygopro_china_north@conference.mycard.moe";
}
public int getExternal_id() {
return external_id;
}
public void setExternal_id(int external_id) {
this.external_id = external_id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAvatar_url() {
return avatar_url;
}
public void setAvatar_url(String avatar_url) {
this.avatar_url = avatar_url;
}
public boolean isAdmin() {
return admin;
}
public void setAdmin(boolean admin) {
this.admin = admin;
}
public boolean isModerator() {
return moderator;
}
public void setModerator(boolean moderator) {
this.moderator = moderator;
}
public boolean isLogin() {
return login;
}
public void setLogin(boolean login) {
this.login = login;
}
}
\ No newline at end of file
package cn.garymb.ygomobile.ui.settings;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import cn.garymb.ygomobile.base.BaseFragemnt;
import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.ui.home.HomeActivity;
import cn.garymb.ygomobile.ui.mycard.MycardFragment;
import cn.garymb.ygomobile.ui.mycard.base.OnMcUserListener;
import cn.garymb.ygomobile.ui.mycard.bean.McUser;
import cn.garymb.ygomobile.ui.mycard.mcchat.util.ImageUtil;
import cn.garymb.ygomobile.ui.plus.DialogPlus;
import cn.garymb.ygomobile.utils.McUserManagement;
public class PersonalFragment extends BaseFragemnt implements OnMcUserListener {
private RelativeLayout rl_user;
private TextView tv_name;
private ImageView iv_avatar;
private McUserManagement userManagement;
private RecyclerView rv_list;
private MycardFragment fragment_mycard;
private PersonalFragment fragment_personal;
//private SettingRecyclerViewAdapter settingAdpter;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View layoutView;
if (isHorizontal)
layoutView = inflater.inflate(R.layout.main_horizontal_fragment, container, false);
else
layoutView = inflater.inflate(R.layout.fragment_personal, container, false);
initView(layoutView);
//event
return layoutView;
}
public void initView(View layoutView) {
fragment_mycard = new MycardFragment();
fragment_personal = new PersonalFragment();
//登录萌卡
rl_user = layoutView.findViewById(R.id.rl_user);
tv_name = layoutView.findViewById(R.id.tv_name);
iv_avatar = layoutView.findViewById(R.id.iv_avatar);
userManagement = McUserManagement.getInstance();
rl_user.setOnClickListener(v1 -> {
if (userManagement.isLogin()) {
DialogPlus dialog = new DialogPlus(getContext());
dialog.setMessage(R.string.logout_mycard);
dialog.setLeftButtonText(R.string.cancel);
dialog.setLeftButtonListener((dlg, i) -> {
dialog.dismiss();
});
dialog.setRightButtonText(R.string.quit);
dialog.setRightButtonListener((dlg, i) -> {
userManagement.logout();
Toast.makeText(getContext(), R.string.done, Toast.LENGTH_SHORT).show();
dialog.dismiss();
});
} else {
getParentFragmentManager().beginTransaction().hide(fragment_personal).show(fragment_mycard).commit();
}
});
//设置列表
rv_list = layoutView.findViewById(R.id.rv_list);
rv_list.setLayoutManager(new LinearLayoutManager(getActivity()));
}
@Override
public void onLogin(McUser user, String exception) {
if (TextUtils.isEmpty(exception)) {
tv_name.setText(user.getUsername());
ImageUtil.setImage(getActivity(), user.getAvatar_url(), iv_avatar);
}
}
@Override
public void onLogout() {
tv_name.setText(R.string.login_mycard);
iv_avatar.setImageResource(R.drawable.avatar);
}
@Override
public boolean isListenerEffective() {
return false;
}
/**
* 第一次fragment可见(进行初始化工作)
*/
@Override
public void onFirstUserVisible() {
}
/**
* fragment可见(切换回来或者onResume)
*/
@Override
public void onUserVisible() {
}
/**
* 第一次fragment不可见(不建议在此处理事件)
*/
@Override
public void onFirstUserInvisible() {
}
/**
* fragment不可见(切换掉或者onPause)
*/
@Override
public void onUserInvisible() {
}
@Override
public void onBackHome() {
}
@Override
public void onBackPressed() {
}
}
......@@ -4,6 +4,9 @@ import static cn.garymb.ygomobile.Constants.ACTION_RELOAD;
import static cn.garymb.ygomobile.Constants.CORE_SKIN_AVATAR_SIZE;
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.ORI_DECK;
import static cn.garymb.ygomobile.Constants.ORI_PICS;
import static cn.garymb.ygomobile.Constants.ORI_REPLAY;
import static cn.garymb.ygomobile.Constants.PERF_TEST_REPLACE_KERNEL;
import static cn.garymb.ygomobile.Constants.PREF_CHANGE_LOG;
import static cn.garymb.ygomobile.Constants.PREF_CHECK_UPDATE;
......@@ -15,12 +18,14 @@ import static cn.garymb.ygomobile.Constants.PREF_GAME_FONT;
import static cn.garymb.ygomobile.Constants.PREF_GAME_PATH;
import static cn.garymb.ygomobile.Constants.PREF_IMAGE_QUALITY;
import static cn.garymb.ygomobile.Constants.PREF_IMMERSIVE_MODE;
import static cn.garymb.ygomobile.Constants.PREF_JOIN_QQ;
import static cn.garymb.ygomobile.Constants.PREF_KEEP_SCALE;
import static cn.garymb.ygomobile.Constants.PREF_LOCK_SCREEN;
import static cn.garymb.ygomobile.Constants.PREF_ONLY_GAME;
import static cn.garymb.ygomobile.Constants.PREF_OPENGL_VERSION;
import static cn.garymb.ygomobile.Constants.PREF_PENDULUM_SCALE;
import static cn.garymb.ygomobile.Constants.PREF_READ_EX;
import static cn.garymb.ygomobile.Constants.PREF_RESET_GAME_RES;
import static cn.garymb.ygomobile.Constants.PREF_SENSOR_REFRESH;
import static cn.garymb.ygomobile.Constants.PREF_START_SERVICEDUELASSISTANT;
import static cn.garymb.ygomobile.Constants.PREF_USE_EXTRA_CARD_CARDS;
......@@ -35,6 +40,7 @@ import android.app.Dialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
......@@ -84,24 +90,6 @@ public class SettingFragment extends PreferenceFragmentPlus {
private static final int COPY_SO_OK = 0;
private static final int COPY_SO_EXCEPTION = 1;
private static final int COPY_SO_NO_ROOT = 2;
@SuppressLint("HandlerLeak")
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case COPY_SO_OK:
Toast.makeText(getActivity(), "替换成功", Toast.LENGTH_SHORT).show();
break;
case COPY_SO_EXCEPTION:
Toast.makeText(getActivity(), "替换失败,原因为" + msg.obj, Toast.LENGTH_SHORT).show();
break;
case COPY_SO_NO_ROOT:
Toast.makeText(getActivity(), "没有root权限", Toast.LENGTH_SHORT).show();
break;
}
}
};
private AppsSettings mSettings;
private boolean isInit = true;
......@@ -123,9 +111,10 @@ public class SettingFragment extends PreferenceFragmentPlus {
addPreferencesFromResource(R.xml.preference_game);
bind(PREF_GAME_PATH, mSettings.getResourcePath());
// bind(PREF_GAME_VERSION, mSettings.getVersionString(mSettings.getGameVersion()));
bind(PREF_CHANGE_LOG, SystemUtils.getVersionName(getActivity())
+ "(" + SystemUtils.getVersion(getActivity()) + ")");
bind(PREF_CHANGE_LOG, SystemUtils.getVersionName(getActivity()) + "(" + SystemUtils.getVersion(getActivity()) + ")");
bind(PREF_CHECK_UPDATE, getString(R.string.settings_about_author_pref) + " : " + getString(R.string.settings_author));
bind(PREF_RESET_GAME_RES, getString(R.string.guide_reset));
bind(PREF_JOIN_QQ, getString(R.string.about_Join_QQ));
bind(PREF_START_SERVICEDUELASSISTANT, mSettings.isServiceDuelAssistant());
bind(PREF_LOCK_SCREEN, mSettings.isLockSreenOrientation());
bind(PREF_FONT_ANTIALIAS, mSettings.isFontAntiAlias());
......@@ -138,7 +127,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
bind(PREF_READ_EX, mSettings.isReadExpansions());
bind(PREF_DEL_EX, getString(R.string.about_delete_ex));
bind(PERF_TEST_REPLACE_KERNEL, "需root权限,请在开发者的指导下食用");
bind(PREF_WINDOW_TOP_BOTTOM, ""+mSettings.getScreenPadding());
bind(PREF_WINDOW_TOP_BOTTOM, "" + mSettings.getScreenPadding());
Preference preference = findPreference(PREF_READ_EX);
if (preference != null) {
preference.setSummary(mSettings.getExpansionsPath().getAbsolutePath());
......@@ -220,6 +209,13 @@ public class SettingFragment extends PreferenceFragmentPlus {
.loadUrl("file:///android_asset/changelog.html", Color.TRANSPARENT)
.show();
}
if (PREF_RESET_GAME_RES.equals(key)) {
updateImages();
}
if (PREF_JOIN_QQ.equals(key)) {
String groupkey = "anEjPCDdhLgxtfLre-nT52G1Coye3LkK";
joinQQGroup(groupkey);
}
if (PREF_CHECK_UPDATE.equals(key)) {
Beta.checkUpgrade();
}
......@@ -406,54 +402,6 @@ public class SettingFragment extends PreferenceFragmentPlus {
((CheckBoxPreference) preference).setChecked(true);
mSettings.setUseExtraCards(true);
copyDataBase(preference, file);
} else if (PERF_TEST_REPLACE_KERNEL.equals(key)) {
File path = App.get().getFilesDir().getParentFile();
String name = "libYGOMobile.so";
File soFile = new File(path.getAbsolutePath() + "/lib", name);
new Thread(new Runnable() {
@Override
public void run() {
Message me = new Message();
Process process = null;
DataOutputStream os = null;
try {
String cmd = "chmod -R 777 " + soFile.getAbsolutePath();
process = Runtime.getRuntime().exec("su"); //切换到root帐号
if (process == null) {
me.what = COPY_SO_NO_ROOT;
handler.sendMessage(me);
return;
}
os = new DataOutputStream(process.getOutputStream());
os.writeBytes(cmd + "\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
IOUtils.delete(soFile);
FileUtils.copyFile(file, soFile.getAbsolutePath());
me.what = COPY_SO_OK;
} catch (Exception e) {
e.printStackTrace();
me.what = COPY_SO_EXCEPTION;
me.obj = e;
} finally {
if (os != null) {
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (process != null)
process.destroy();
}
handler.sendMessage(me);
}
}).start();
} else {
super.onChooseFileOk(preference, file);
......@@ -478,6 +426,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
.into(imageView);
}
}
public void setImage(String outFile, int outWidth, int outHeight, ImageView imageView) {
File img = new File(outFile);
if (img.exists()) {
......@@ -547,5 +496,74 @@ public class SettingFragment extends PreferenceFragmentPlus {
}
}
public void updateImages() {
Log.e("MainActivity", "重置资源");
DialogPlus dialog = DialogPlus.show(getContext(), null, getString(R.string.message));
dialog.show();
VUiKit.defer().when(() -> {
Log.e("MainActivity", "开始复制");
try {
IOUtils.createNoMedia(AppsSettings.get().getResourcePath());
FileUtils.delFile(AppsSettings.get().getResourcePath() + "/" + Constants.CORE_SCRIPT_PATH);
if (IOUtils.hasAssets(getContext(), getDatapath(Constants.CORE_PICS_ZIP))) {
IOUtils.copyFilesFromAssets(getContext(), getDatapath(Constants.CORE_PICS_ZIP),
AppsSettings.get().getResourcePath(), true);
}
if (IOUtils.hasAssets(getContext(), getDatapath(Constants.CORE_SCRIPTS_ZIP))) {
IOUtils.copyFilesFromAssets(getContext(), getDatapath(Constants.CORE_SCRIPTS_ZIP),
AppsSettings.get().getResourcePath(), true);
}
IOUtils.copyFilesFromAssets(getContext(), getDatapath(Constants.DATABASE_NAME),
AppsSettings.get().getResourcePath(), true);
IOUtils.copyFilesFromAssets(getContext(), getDatapath(Constants.CORE_STRING_PATH),
AppsSettings.get().getResourcePath(), true);
IOUtils.copyFilesFromAssets(getContext(), getDatapath(Constants.WINDBOT_PATH),
AppsSettings.get().getResourcePath(), true);
IOUtils.copyFilesFromAssets(getContext(), getDatapath(Constants.CORE_SKIN_PATH),
AppsSettings.get().getCoreSkinPath(), false);
String fonts = AppsSettings.get().getResourcePath() + "/" + Constants.FONT_DIRECTORY;
if (new File(fonts).list() != null)
FileUtils.delFile(fonts);
IOUtils.copyFilesFromAssets(getContext(), getDatapath(Constants.FONT_DIRECTORY),
AppsSettings.get().getFontDirPath(), true);
/*
IOUtils.copyFilesFromAssets(this, getDatapath(Constants.CORE_SOUND_PATH),
AppsSettings.get().getSoundPath(), false);*/
//复制原目录文件
if (new File(ORI_DECK).list() != null)
FileUtils.copyDir(ORI_DECK, AppsSettings.get().getDeckDir(), false);
if (new File(ORI_REPLAY).list() != null)
FileUtils.copyDir(ORI_REPLAY, AppsSettings.get().getResourcePath() + "/" + Constants.CORE_REPLAY_PATH, false);
if (new File(ORI_PICS).list() != null)
FileUtils.copyDir(ORI_PICS, AppsSettings.get().getCardImagePath(), false);
} catch (IOException e) {
e.printStackTrace();
Log.e("MainActivity", "错误" + e);
}
}).done((rs) -> {
Toast.makeText(getContext(), R.string.done, Toast.LENGTH_SHORT).show();
dialog.dismiss();
});
}
public boolean joinQQGroup(String key) {
Intent intent = new Intent();
intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + key));
// 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面 //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
try {
startActivity(intent);
return true;
} catch (Exception e) {
// 未安装手Q或安装的版本不支持
return false;
}
}
}
package cn.garymb.ygomobile.utils;
import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import android.util.Log;
import org.litepal.LitePal;
import java.util.ArrayList;
import java.util.List;
import cn.garymb.ygomobile.App;
import cn.garymb.ygomobile.ui.mycard.base.OnMcUserListener;
import cn.garymb.ygomobile.ui.mycard.bean.McUser;
import cn.garymb.ygomobile.ui.mycard.mcchat.management.UserManagement;
/**
* Create By feihua On 2021/10/21
*/
public class McUserManagement {
private static final McUserManagement ourInstance = new McUserManagement();
private McUser user;
private List<OnMcUserListener> userListenerList;
private McUserManagement() {
userListenerList = new ArrayList<>();
user = LitePal.findFirst(McUser.class);
Log.e("McUserManagement", "初始化 " + (user!=null));
}
public static McUserManagement getInstance() {
return ourInstance;
}
public void addListener(OnMcUserListener onMcUserListener) {
userListenerList.add(onMcUserListener);
}
public void removeListener(OnMcUserListener onMcUserListener) {
userListenerList.remove(onMcUserListener);
}
public void login(McUser mUser, boolean isUpdate) {
if (this.user != null)
Log.e("McUserManagement", "登录1 " + this.user.getExternal_id());
Log.e("McUserManagement", isUpdate + "登录 " + mUser.getExternal_id());
if (isUpdate && this.user != null) {
if (!TextUtils.isEmpty(mUser.getName()))
this.user.setName(mUser.getName());
if (mUser.getExternal_id() > 0) {
Log.e("McUserManagement", "重设" + mUser.getExternal_id());
this.user.setExternal_id(mUser.getExternal_id());
}
if (!TextUtils.isEmpty(mUser.getUsername()))
this.user.setUsername(mUser.getUsername());
if (!TextUtils.isEmpty(mUser.getEmail()))
this.user.setEmail(mUser.getEmail());
if (!TextUtils.isEmpty(mUser.getAvatar_url()))
this.user.setAvatar_url(mUser.getAvatar_url());
Log.e("McUserManagement","1保存前"+user.getId());
boolean isSave=this.user.save();
Log.e("McUserManagement", (LitePal.findFirst(McUser.class)!=null)+"1保存情况 " + isSave);
Log.e("McUserManagement","1保存后"+user.getId());
} else {
this.user = mUser;
LitePal.deleteAll(McUser.class);
Log.e("McUserManagement","保存前"+user.getId());
boolean isSave=this.user.save();
Log.e("McUserManagement", (LitePal.findFirst(McUser.class)!=null)+"保存情况 " + isSave);
Log.e("McUserManagement","保存后"+user.getId());
}
SharedPreferenceUtil.setMyCardUserName(user.getUsername());
for (int i = 0; i < userListenerList.size(); i++) {
OnMcUserListener ul = userListenerList.get(i);
if (ul != null && ul.isListenerEffective()) {
ul.onLogin(user, null);
} else {
userListenerList.remove(i);
i--;
}
}
}
public McUser getUser() {
return user;
}
public boolean isLogin() {
return user != null;
}
public void logout() {
this.user = null;
LitePal.deleteAll(McUser.class);
Log.e("McUserManagement", "退出登录");
SharedPreferences lastModified = App.get().getSharedPreferences("lastModified", Context.MODE_PRIVATE);
lastModified.edit().putString("user_external_id", null).apply();
lastModified.edit().putString("user_name", null).apply();
UserManagement.setUserName(null);
UserManagement.setUserPassword(null);
for (int i = 0; i < userListenerList.size(); i++) {
OnMcUserListener ul = userListenerList.get(i);
if (ul != null && ul.isListenerEffective()) {
ul.onLogout();
} else {
userListenerList.remove(i);
i--;
}
}
}
}
......@@ -12,8 +12,6 @@
android:background="#80000000"
android:orientation="vertical">
<include layout="@layout/content_toolbar" />
<LinearLayout
android:id="@+id/head_view"
android:layout_width="match_parent"
......
......@@ -7,18 +7,20 @@
android:fitsSystemWindows="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#aa000000"/>
<FrameLayout
android:id="@+id/fragment_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#aa000000">
android:layout_marginBottom="70dp">
</FrameLayout>
<com.ashokvarma.bottomnavigation.BottomNavigationBar
android:id="@+id/bottom_navigation_bar"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_height="60dp"
android:layout_gravity="bottom" />
</FrameLayout>
\ No newline at end of file
......@@ -26,7 +26,6 @@
android:layout_height="70dp"
android:layout_gravity="bottom"
android:layout_marginLeft="10dp"
android:layout_marginBottom="60dp"
android:orientation="horizontal"
android:weightSum="1">
......@@ -153,8 +152,7 @@
android:orientation="vertical"
android:paddingLeft="4dp"
android:paddingTop="2dp"
android:paddingRight="5dp"
android:layout_marginBottom="60dp">
android:paddingRight="5dp">
<LinearLayout
android:layout_width="match_parent"
......
......@@ -68,7 +68,6 @@
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="60dp"
android:orientation="horizontal"
android:weightSum="3">
......
......@@ -7,7 +7,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:layout_marginBottom="60dp"
tools:openDrawer="left">
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="60dp"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/rl_user"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/dialogshort">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/iv_avatar"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:scaleType="centerCrop"
android:src="@drawable/avatar"
app:civ_border_color="@color/gray"
app:civ_border_width="1dp" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@id/iv_avatar"
android:text="@string/login_mycard"
android:textColor="@color/holo_blue_bright" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_guide_right"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp"
android:src="@drawable/p_right" />
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:background="@drawable/dialogshort"/>
</LinearLayout>
\ No newline at end of file
......@@ -23,7 +23,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@android:color/transparent"
android:layout_marginBottom="60dp"
android:dividerHeight="4dp"
android:padding="5dp"
android:scrollbars="vertical" />
......
......@@ -7,7 +7,6 @@
android:background="@drawable/nav_right"
android:orientation="vertical"
android:padding="10dp"
android:layout_marginBottom="60dp"
android:theme="@style/AppTheme.PopupOverlay.Dark"
tools:showIn="@layout/fragment_search">
......
......@@ -227,6 +227,7 @@
<string name="Open_Alert_Window">알림 관리</string>
<string name="Function_Menu">기능 메뉴</string>
<string name="Join_QQ">QQ 가입</string>
<string name="about_Join_QQ">join QQ group to report problems</string>
<string name="donatefor">기부를 통해 자동갱신 서버 비용을 지출하고 업데이트된 자료와 이미지를 정리하고 최신 디바이스에 대한 호환성있는 제작을 위해 디바이스들을 구입하는 것에 도움을 주실 수 있습니다.</string>
<string name="coverSelect">카드 커버로 사용할 이미지를 선택하세요</string>
<string name="bgSelect">배경으로 사용할 이미지를 선택하세요</string>
......@@ -299,7 +300,7 @@
<string name="guide_server_edit">편집 버튼:\n해당 서버 정보를 편집하려면 터치하십시오. \n게임 닉네임 등을 변경할 경우</string>
<string name="guide_help">튜토리얼:특정 앱 사용 방법 및 마스터 룰 학습 포함(필수)</string>
<string name="guide_settings">설정:듀얼 어시스턴트 시작, 확장 카드 팩 사용(있을 경우), 게임 아바타 , 배경, 카드 커버 변경 등</string>
<string name="guide_reset">리소스 초기화:누락 된 이미지 및 기타 파일이 실수로 삭제된 경우 리소스 초기화를 터치하십시오</string>
<string name="guide_reset">누락 된 이미지 및 기타 파일이 실수로 삭제된 경우 리소스 초기화를 터치하십시오</string>
<string name="guide_abt_room_list">입력한 비밀번호 기록;삭제하려면 기록을 길게 누르십시오</string>
<string name="guide_join_room">비밀번호를 입력하지 않고 무작위로 싱글 듀얼로 참여할 수 있습니다
\n비밀번호를 입력하여 친구와 사귈 수도 있습니다
......
......@@ -236,6 +236,7 @@
<string name="Open_Alert_Window">去打开悬浮窗</string>
<string name="Function_Menu">功能菜单</string>
<string name="Join_QQ">机型调试群</string>
<string name="about_Join_QQ">软件遇到使用问题可以加群</string>
<string name="donatefor">您的捐赠将用于维持自动更新费用,收集更新资料、修图后期以及购买适配机型等</string>
<string name="coverSelect">点击相应卡背选择文件</string>
<string name="bgSelect">点击相应背景选择文件</string>
......@@ -308,7 +309,7 @@
<string name="guide_server_edit">编辑按钮:\n点击编辑相应的服务器信息。\n如改游戏昵称等</string>
<string name="guide_help">教程:包含软件具体使用方法和大师规则学习(划重点)</string>
<string name="guide_settings">设置:启动决斗助手,使用先行卡(如果有),更改游戏头像,背景,卡背等</string>
<string name="guide_reset">重置资源:发现缺图等文件误删情况时点击重置</string>
<string name="guide_reset">发现缺图等文件误删情况时点击重置</string>
<string name="guide_abt_room_list">输入的密码会被记录;长按某个记录可以删除</string>
<string name="guide_join_room">不输入密码可加入随机默认模式决斗
\n也可以输入密码进行好友约战
......
......@@ -234,6 +234,7 @@
<string name="Open_Alert_Window">To Open Pop-ups</string>
<string name="Function_Menu">MENU</string>
<string name="Join_QQ">QQ Group</string>
<string name="about_Join_QQ">join QQ group to report problems</string>
<string name="donatefor">your donation will be used for keeping severs updating, buying card to get artworks and purchasing new phone to adapt</string>
<string name="coverSelect">click covers and select files</string>
<string name="bgSelect">click background and select files</string>
......@@ -309,7 +310,7 @@
<string name="guide_server_edit">Server edit\: edit server information. for example\: change nickname</string>
<string name="guide_help">Help\: specifically guide How to use YGOMobile and learn Master Rules</string>
<string name="guide_settings">Settings\: turn on Expansions and DuelAssistant.set game avatars, background, cardback. </string>
<string name="guide_reset">Reset Resources\: click to reset when pictures or any files are mistaken deleted</string>
<string name="guide_reset">click to reset when pictures or any files are mistaken deleted</string>
<string name="guide_abt_room_list">Inputted password will be recorded. Lone-Press to delete record(s)</string>
<string name="guide_join_room">you can join game without password to start random duel with default mode
\n use specified password and share other players to join same game
......
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/settings_about">
<Preference
android:key="pref_key_reset_game_res"
android:persistent="true"
android:title="@string/reset_game_res" />
<Preference
android:key="pref_key_about_check_update"
android:persistent="true"
android:title="@string/settings_about_check_update" />
<Preference
android:key="pref_key_change_log"
android:title="@string/settings_about_change_log" />
<Preference
android:key="pref_key_join_qq"
android:title="@string/Join_QQ" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/settings_game">
<!--Preference
......@@ -119,16 +135,11 @@
android:title="@string/settings_game_diy_card_db"/>-->
</PreferenceCategory>
<PreferenceCategory android:title="@string/settings_test_options">
<!--PreferenceCategory android:title="@string/settings_test_options">
<Preference
android:key="pref_key_test_replace_kernel"
android:persistent="true"
android:title="@string/settings_test_replace_kernel" />
<Preference
android:key=""
android:persistent="true"
android:title="" />
</PreferenceCategory>
</PreferenceCategory-->
</PreferenceScreen>
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