Code clean up
This commit is contained in:
parent
36a64e4ad3
commit
362cb4f1bc
|
@ -162,81 +162,10 @@ public class MainActivity extends AppCompatActivity {
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
case R.id.settings_language:
|
case R.id.settings_language:
|
||||||
DialogUtils.setCurrentDialog(new MaterialDialog.Builder(this).title(R.string.settings_set_language).items(R.array.languages).itemsCallback((dialog, itemView, position, text) -> {
|
selectLanguageLogic();
|
||||||
boolean restart;
|
|
||||||
switch (position) {
|
|
||||||
case 0:
|
|
||||||
restart = LanguagesManager.setSystemLanguage(this);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
restart = LanguagesManager.setAppLanguage(this, Locale.ENGLISH);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
restart = LanguagesManager.setAppLanguage(this, Locale.SIMPLIFIED_CHINESE);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
restart = LanguagesManager.setAppLanguage(this, Locale.TRADITIONAL_CHINESE);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
restart = LanguagesManager.setAppLanguage(this, Locale.KOREA);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
restart = LanguagesManager.setAppLanguage(this, new Locale("th", ""));
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
restart = LanguagesManager.setAppLanguage(this, new Locale("es", ""));
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
restart = LanguagesManager.setAppLanguage(this, Locale.FRENCH);
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
restart = LanguagesManager.setAppLanguage(this, new Locale("pt", ""));
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
restart = LanguagesManager.setAppLanguage(this, new Locale("in", ""));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (restart) {
|
|
||||||
// 我们可以充分运用 Activity 跳转动画,在跳转的时候设置一个渐变的效果
|
|
||||||
startActivity(new Intent(this, MainActivity.class));
|
|
||||||
overridePendingTransition(R.anim.fragment_fade_enter, R.anim.fragment_fade_exit);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}).show());
|
|
||||||
return true;
|
return true;
|
||||||
case R.id.settings_translation_service:
|
case R.id.settings_translation_service:
|
||||||
DialogUtils.setCurrentDialog(new MaterialDialog.Builder(this).title(R.string.settings_translation_service).items(R.array.translators).itemsCallback((dialog, itemView, position, text) -> {
|
selectTranslateServiceLogic();
|
||||||
DaoSession daoSession = ((MainApplication)this.getApplication()).getDaoSession();
|
|
||||||
AppConfigDao appConfigDao = daoSession.getAppConfigDao();
|
|
||||||
AppConfig activeTranslator = appConfigDao.queryBuilder().where(AppConfigDao.Properties.Name.eq(AppConfigKey.ACTIVE_TRANSLATOR)).build().unique();
|
|
||||||
switch (position) {
|
|
||||||
case 0:
|
|
||||||
if(activeTranslator != null) {
|
|
||||||
appConfigDao.delete(activeTranslator);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
if(activeTranslator == null) {
|
|
||||||
activeTranslator = new AppConfig(null, AppConfigKey.ACTIVE_TRANSLATOR, TranslateUtil.GOOGLE);
|
|
||||||
} else {
|
|
||||||
activeTranslator.setValue(TranslateUtil.GOOGLE);
|
|
||||||
}
|
|
||||||
appConfigDao.insertOrReplace(activeTranslator);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if(activeTranslator == null) {
|
|
||||||
activeTranslator = new AppConfig(null, AppConfigKey.ACTIVE_TRANSLATOR, TranslateUtil.YOU_DAO);
|
|
||||||
} else {
|
|
||||||
activeTranslator.setValue(TranslateUtil.YOU_DAO);
|
|
||||||
}
|
|
||||||
appConfigDao.insertOrReplace(activeTranslator);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}).show());
|
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
|
@ -245,6 +174,85 @@ public class MainActivity extends AppCompatActivity {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void selectTranslateServiceLogic() {
|
||||||
|
DialogUtils.setCurrentDialog(new MaterialDialog.Builder(this).title(R.string.settings_translation_service).items(R.array.translators).itemsCallback((dialog, itemView, position, text) -> {
|
||||||
|
DaoSession daoSession = ((MainApplication)this.getApplication()).getDaoSession();
|
||||||
|
AppConfigDao appConfigDao = daoSession.getAppConfigDao();
|
||||||
|
AppConfig activeTranslator = appConfigDao.queryBuilder().where(AppConfigDao.Properties.Name.eq(AppConfigKey.ACTIVE_TRANSLATOR)).build().unique();
|
||||||
|
switch (position) {
|
||||||
|
case 0:
|
||||||
|
if(activeTranslator != null) {
|
||||||
|
appConfigDao.delete(activeTranslator);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if(activeTranslator == null) {
|
||||||
|
activeTranslator = new AppConfig(null, AppConfigKey.ACTIVE_TRANSLATOR, TranslateUtil.GOOGLE);
|
||||||
|
} else {
|
||||||
|
activeTranslator.setValue(TranslateUtil.GOOGLE);
|
||||||
|
}
|
||||||
|
appConfigDao.insertOrReplace(activeTranslator);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if(activeTranslator == null) {
|
||||||
|
activeTranslator = new AppConfig(null, AppConfigKey.ACTIVE_TRANSLATOR, TranslateUtil.YOU_DAO);
|
||||||
|
} else {
|
||||||
|
activeTranslator.setValue(TranslateUtil.YOU_DAO);
|
||||||
|
}
|
||||||
|
appConfigDao.insertOrReplace(activeTranslator);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}).show());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void selectLanguageLogic() {
|
||||||
|
DialogUtils.setCurrentDialog(new MaterialDialog.Builder(this).title(R.string.settings_set_language).items(R.array.languages).itemsCallback((dialog, itemView, position, text) -> {
|
||||||
|
boolean restart;
|
||||||
|
switch (position) {
|
||||||
|
case 0:
|
||||||
|
restart = LanguagesManager.setSystemLanguage(this);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
restart = LanguagesManager.setAppLanguage(this, Locale.ENGLISH);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
restart = LanguagesManager.setAppLanguage(this, Locale.SIMPLIFIED_CHINESE);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
restart = LanguagesManager.setAppLanguage(this, Locale.TRADITIONAL_CHINESE);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
restart = LanguagesManager.setAppLanguage(this, Locale.KOREA);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
restart = LanguagesManager.setAppLanguage(this, new Locale("th", ""));
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
restart = LanguagesManager.setAppLanguage(this, new Locale("es", ""));
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
restart = LanguagesManager.setAppLanguage(this, Locale.FRENCH);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
restart = LanguagesManager.setAppLanguage(this, new Locale("pt", ""));
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
restart = LanguagesManager.setAppLanguage(this, new Locale("in", ""));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (restart) {
|
||||||
|
// 我们可以充分运用 Activity 跳转动画,在跳转的时候设置一个渐变的效果
|
||||||
|
startActivity(new Intent(this, MainActivity.class));
|
||||||
|
overridePendingTransition(R.anim.fragment_fade_enter, R.anim.fragment_fade_exit);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}).show());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onSupportNavigateUp() {
|
public boolean onSupportNavigateUp() {
|
||||||
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
|
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
|
||||||
|
|
|
@ -9,7 +9,6 @@ import lombok.Data;
|
||||||
/**
|
/**
|
||||||
* SMAPI的配置
|
* SMAPI的配置
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
|
|
||||||
@Data
|
@Data
|
||||||
@JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY, getterVisibility= JsonAutoDetect.Visibility.NONE)
|
@JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY, getterVisibility= JsonAutoDetect.Visibility.NONE)
|
||||||
public class FrameworkConfig {
|
public class FrameworkConfig {
|
||||||
|
|
|
@ -7,7 +7,6 @@ import lombok.Data;
|
||||||
/**
|
/**
|
||||||
* Mod信息
|
* Mod信息
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("ALL")
|
|
||||||
@Data
|
@Data
|
||||||
public class ModManifestEntry {
|
public class ModManifestEntry {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -63,7 +63,11 @@ public class HelpItemAdapter extends RecyclerView.Adapter<HelpItemAdapter.ViewHo
|
||||||
void setHelpItem(HelpItem item) {
|
void setHelpItem(HelpItem item) {
|
||||||
textTitle.setText(item.getTitle());
|
textTitle.setText(item.getTitle());
|
||||||
textAuthor.setText(item.getAuthor());
|
textAuthor.setText(item.getAuthor());
|
||||||
textContent.setText(Html.fromHtml(item.getContent()));
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||||
|
textContent.setText(Html.fromHtml(item.getContent(), Html.FROM_HTML_MODE_COMPACT));
|
||||||
|
} else {
|
||||||
|
textContent.setText(Html.fromHtml(item.getContent()));
|
||||||
|
}
|
||||||
textContent.setMovementMethod(LinkMovementMethod.getInstance());
|
textContent.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue