Layout adjust, list update logic fix
This commit is contained in:
parent
ff41704101
commit
d48159dddd
|
@ -5,7 +5,7 @@
|
|||
"type": "COMPAT",
|
||||
"name": "SMAPI for 1.4.5.137",
|
||||
"assetPath": "compat/137/",
|
||||
"description": "SMAPI compat package for game 1.4.4.128 - 1.4.5.137",
|
||||
"description": "SMAPI compat package for game 1.4.4.128 - 1.4.5.137, SMAPI 3.3.2.0",
|
||||
"url": "http://zaneyork.cn/download/compat/smapi_137.zip",
|
||||
"hash": "bd16e8e4cb52d636e24c6a2d2309b66a60e492d2b97c1b8f6a519c04ac42ebdc"
|
||||
},
|
||||
|
|
|
@ -27,6 +27,11 @@ The default values are mirrored in StardewModdingAPI.Framework.Models.SConfig to
|
|||
*/
|
||||
"DeveloperMode": false,
|
||||
|
||||
/**
|
||||
* Whether to enable load mods with multithreading supports.
|
||||
*/
|
||||
"MultithreadingLoading": false,
|
||||
|
||||
/**
|
||||
* Whether to add a section to the 'mod issues' list for mods which directly use potentially
|
||||
* sensitive .NET APIs like file or shell access. Note that many mods do this legitimately as
|
||||
|
|
|
@ -4,12 +4,15 @@ import android.Manifest;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import com.microsoft.appcenter.AppCenter;
|
||||
import com.microsoft.appcenter.analytics.Analytics;
|
||||
import com.microsoft.appcenter.crashes.Crashes;
|
||||
import com.zane.smapiinstaller.constant.Constants;
|
||||
import com.zane.smapiinstaller.entity.FrameworkConfig;
|
||||
import com.zane.smapiinstaller.logic.ConfigManager;
|
||||
import com.zane.smapiinstaller.logic.GameLauncher;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -40,25 +43,20 @@ public class MainActivity extends AppCompatActivity {
|
|||
@BindView(R.id.nav_view)
|
||||
NavigationView navigationView;
|
||||
|
||||
private void requestPermissions()
|
||||
{
|
||||
private void requestPermissions() {
|
||||
if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(MainActivity.this,
|
||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
initView();
|
||||
}
|
||||
}
|
||||
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED)
|
||||
{
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
initView();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
requestPermissions();
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +83,8 @@ public class MainActivity extends AppCompatActivity {
|
|||
NavigationUI.setupWithNavController(navigationView, navController);
|
||||
}
|
||||
|
||||
@OnClick(R.id.launch) void launchButtonClick() {
|
||||
@OnClick(R.id.launch)
|
||||
void launchButtonClick() {
|
||||
new GameLauncher(navigationView).launch();
|
||||
}
|
||||
|
||||
|
@ -96,6 +95,43 @@ public class MainActivity extends AppCompatActivity {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
ConfigManager manager = new ConfigManager();
|
||||
FrameworkConfig config = manager.getConfig();
|
||||
menu.findItem(R.id.settings_verbose_logging).setChecked(config.isVerboseLogging());
|
||||
menu.findItem(R.id.settings_check_for_updates).setChecked(config.isCheckForUpdates());
|
||||
menu.findItem(R.id.settings_developer_mode).setChecked(config.isDeveloperMode());
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if(item.isCheckable()) {
|
||||
if (item.isChecked())
|
||||
item.setChecked(false);
|
||||
else
|
||||
item.setChecked(true);
|
||||
}
|
||||
ConfigManager manager = new ConfigManager();
|
||||
FrameworkConfig config = manager.getConfig();
|
||||
switch (item.getItemId()) {
|
||||
case R.id.settings_verbose_logging:
|
||||
config.setVerboseLogging(item.isChecked());
|
||||
break;
|
||||
case R.id.settings_check_for_updates:
|
||||
config.setCheckForUpdates(item.isChecked());
|
||||
break;
|
||||
case R.id.settings_developer_mode:
|
||||
config.setDeveloperMode(item.isChecked());
|
||||
break;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
manager.flushConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSupportNavigateUp() {
|
||||
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
|
||||
|
|
|
@ -12,6 +12,11 @@ public class Constants {
|
|||
* 日志路径
|
||||
*/
|
||||
public static final String LOG_PATH = "StardewValley/ErrorLogs/SMAPI-latest.txt";
|
||||
|
||||
/**
|
||||
* 配置文件路径
|
||||
*/
|
||||
public static final String CONFIG_PATH = "StardewValley/smapi-internal/config.user.json";
|
||||
/**
|
||||
* 安装包目标包名
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package com.zane.smapiinstaller.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* SMAPI的配置
|
||||
*/
|
||||
@Data
|
||||
@JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY, getterVisibility= JsonAutoDetect.Visibility.NONE)
|
||||
public class FrameworkConfig {
|
||||
/**
|
||||
* 详细日志
|
||||
*/
|
||||
@JsonProperty("VerboseLogging")
|
||||
private boolean VerboseLogging = false;
|
||||
/**
|
||||
* 检查更新
|
||||
*/
|
||||
@JsonProperty("CheckForUpdates")
|
||||
private boolean CheckForUpdates = true;
|
||||
/**
|
||||
* 开发者模式
|
||||
*/
|
||||
@JsonProperty("DeveloperMode")
|
||||
private boolean DeveloperMode = false;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.zane.smapiinstaller.logic;
|
||||
|
||||
import android.os.Environment;
|
||||
|
||||
import com.zane.smapiinstaller.constant.Constants;
|
||||
import com.zane.smapiinstaller.entity.FrameworkConfig;
|
||||
import com.zane.smapiinstaller.utils.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* 配置管理器
|
||||
*/
|
||||
public class ConfigManager {
|
||||
private FrameworkConfig config;
|
||||
|
||||
public ConfigManager() {
|
||||
File configFile = new File(Environment.getExternalStorageDirectory(), Constants.CONFIG_PATH);
|
||||
if(configFile.exists()) {
|
||||
config = FileUtils.getFileJson(configFile, FrameworkConfig.class);
|
||||
}
|
||||
if(config == null) {
|
||||
config = new FrameworkConfig();
|
||||
}
|
||||
}
|
||||
|
||||
public FrameworkConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void flushConfig() {
|
||||
File configFile = new File(Environment.getExternalStorageDirectory(), Constants.CONFIG_PATH);
|
||||
FileUtils.writeFileJson(configFile, config);
|
||||
}
|
||||
}
|
|
@ -107,7 +107,37 @@ public class FileUtils {
|
|||
try (OutputStreamWriter writer = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8)) {
|
||||
writer.write(JSONUtil.toJson(content));
|
||||
} finally {
|
||||
org.zeroturnaround.zip.commons.FileUtils.moveFile(file, new File(context.getFilesDir(), filename));
|
||||
File distFile = new File(context.getFilesDir(), filename);
|
||||
if(file.exists()) {
|
||||
org.zeroturnaround.zip.commons.FileUtils.forceDelete(distFile);
|
||||
}
|
||||
org.zeroturnaround.zip.commons.FileUtils.moveFile(file, distFile);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入JSON文件到本地
|
||||
* @param file 文件
|
||||
* @param content 内容
|
||||
*/
|
||||
public static void writeFileJson(File file, Object content) {
|
||||
try {
|
||||
if(!file.getParentFile().exists()) {
|
||||
org.zeroturnaround.zip.commons.FileUtils.forceMkdir(file.getParentFile());
|
||||
}
|
||||
String filename = file.getName();
|
||||
String tmpFilename = filename + ".tmp";
|
||||
File fileTmp = new File(file.getParent(), tmpFilename);
|
||||
FileOutputStream outputStream = new FileOutputStream(fileTmp);
|
||||
try (OutputStreamWriter writer = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8)) {
|
||||
writer.write(JSONUtil.toJson(content));
|
||||
} finally {
|
||||
if(file.exists()) {
|
||||
org.zeroturnaround.zip.commons.FileUtils.forceDelete(file);
|
||||
}
|
||||
org.zeroturnaround.zip.commons.FileUtils.moveFile(fileTmp, file);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
|
|
@ -32,17 +32,32 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/guideline_h3"
|
||||
android:text="@string/smapi_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/guideline_h1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintGuide_percent="0.2" />
|
||||
app:layout_constraintGuide_percent="0.1" />
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/guideline_h2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintGuide_percent="0.2" />
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/guideline_h3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintGuide_percent="0.3" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -1,9 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/action_settings"
|
||||
app:showAsAction="never" />
|
||||
<group
|
||||
android:checkableBehavior="all">
|
||||
<item
|
||||
android:id="@+id/settings_verbose_logging"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/settings_verbose_logging"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/settings_check_for_updates"
|
||||
android:orderInCategory="101"
|
||||
android:title="@string/settings_check_for_updates"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/settings_developer_mode"
|
||||
android:orderInCategory="102"
|
||||
android:title="@string/settings_developer_mode"
|
||||
app:showAsAction="never" />
|
||||
</group>
|
||||
</menu>
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
<string name="button_compat">兼容性</string>
|
||||
<string name="button_nexus">N網</string>
|
||||
<string name="button_release">官網</string>
|
||||
<string name="test_message">暫處於內測階段, Q群:860453392</string>
|
||||
<string name="button_logs">日誌</string>
|
||||
<string name="smapi_game_name">SMAPI星露穀物語</string>
|
||||
<string name="error_failed_to_create_file">無法創建以下文件: %s</string>
|
||||
|
@ -55,4 +54,8 @@
|
|||
<string name="button_donation_text">捐贈</string>
|
||||
<string name="button_qq_group_2_text">QQ群②: 1078428449</string>
|
||||
<string name="button_gplay" >谷歌商店详情</string>
|
||||
<string name="smapi_version">SMAPI版本: 3.3.2.2</string>
|
||||
<string name="settings_verbose_logging">詳細日誌</string>
|
||||
<string name="settings_check_for_updates">檢查更新</string>
|
||||
<string name="settings_developer_mode">開發者模式</string>
|
||||
</resources>
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
<string name="button_compat">兼容性</string>
|
||||
<string name="button_nexus">N網</string>
|
||||
<string name="button_release">官網</string>
|
||||
<string name="test_message">暫處於內測階段, Q群:860453392</string>
|
||||
<string name="button_logs">日誌</string>
|
||||
<string name="smapi_game_name">SMAPI星露穀物語</string>
|
||||
<string name="error_failed_to_create_file">無法創建以下文件: %s</string>
|
||||
|
@ -55,4 +54,8 @@
|
|||
<string name="button_donation_text">捐贈</string>
|
||||
<string name="button_qq_group_2_text">QQ群②: 1078428449</string>
|
||||
<string name="button_gplay" >谷歌商店详情</string>
|
||||
<string name="smapi_version">SMAPI版本: 3.3.2.2</string>
|
||||
<string name="settings_verbose_logging">詳細日誌</string>
|
||||
<string name="settings_developer_mode">開發者模式</string>
|
||||
<string name="settings_check_for_updates">檢查更新</string>
|
||||
</resources>
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
<string name="button_compat">兼容性</string>
|
||||
<string name="button_nexus">N网</string>
|
||||
<string name="button_release">官网</string>
|
||||
<string name="test_message">暂处于内测阶段, Q群:860453392</string>
|
||||
<string name="button_logs">日志</string>
|
||||
<string name="smapi_game_name">SMAPI星露谷物语</string>
|
||||
<string name="error_failed_to_create_file">无法创建以下文件: %s</string>
|
||||
|
@ -55,4 +54,8 @@
|
|||
<string name="button_qq_group_2_text">QQ群②: 1078428449</string>
|
||||
<string name="error_depends_on_mod_version">%1$s依赖%2$s %3$s版本,请先更新它</string>
|
||||
<string name="button_gplay">谷歌商店详情</string>
|
||||
<string name="smapi_version">SMAPI版本: 3.3.2.2</string>
|
||||
<string name="settings_verbose_logging">详细日志</string>
|
||||
<string name="settings_developer_mode">开发者模式</string>
|
||||
<string name="settings_check_for_updates">检查更新</string>
|
||||
</resources>
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
<string name="button_compat">Compat</string>
|
||||
<string name="button_nexus">Nexus</string>
|
||||
<string name="button_release">Release</string>
|
||||
<string name="test_message">Still at test stage now.</string>
|
||||
<string name="button_logs">Logs</string>
|
||||
<string name="smapi_game_name">SMAPI Stardew Valley</string>
|
||||
<string name="error_failed_to_create_file">Failed to create target file : %s</string>
|
||||
|
@ -59,4 +58,8 @@
|
|||
<string name="button_donation_text">Donation</string>
|
||||
<string name="toast_redpacket_message" translatable="false">红包码已复制\n支付宝首页搜索“9188262” 立即领红包</string>
|
||||
<string name="button_gplay">View in Play Store</string>
|
||||
<string name="smapi_version">SMAPI Version: 3.3.2.2</string>
|
||||
<string name="settings_verbose_logging">Verbose Logging</string>
|
||||
<string name="settings_check_for_updates">Check For Updates</string>
|
||||
<string name="settings_developer_mode">Developer Mode</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue