Add some localizability & implement simple account deletion

This commit is contained in:
artdeell 2022-11-11 10:31:57 +03:00 committed by ArtDev
parent bae23f770e
commit ac71ffbdef
3 changed files with 10 additions and 5 deletions

View File

@ -34,6 +34,7 @@ import net.kdt.pojavlaunch.authenticator.microsoft.MicrosoftBackgroundLogin;
import net.kdt.pojavlaunch.extra.ExtraConstants; import net.kdt.pojavlaunch.extra.ExtraConstants;
import net.kdt.pojavlaunch.extra.ExtraCore; import net.kdt.pojavlaunch.extra.ExtraCore;
import net.kdt.pojavlaunch.extra.ExtraListener; import net.kdt.pojavlaunch.extra.ExtraListener;
import net.kdt.pojavlaunch.services.ProgressService;
import net.kdt.pojavlaunch.value.MinecraftAccount; import net.kdt.pojavlaunch.value.MinecraftAccount;
import java.io.File; import java.io.File;
@ -165,8 +166,10 @@ public class mcAccountSpinner extends AppCompatSpinner implements AdapterView.On
public void removeCurrentAccount(){ public void removeCurrentAccount(){
int position = getSelectedItemPosition(); int position = getSelectedItemPosition();
if(position == 0) return; if(position == 0) return;
File accountFile = new File(Tools.DIR_ACCOUNT_NEW, mAccountList.get(position)+".json");
if(accountFile.exists()) accountFile.delete();
mAccountList.remove(position); mAccountList.remove(position);
reloadAccounts(false, 0); reloadAccounts(false, 0);
} }

View File

@ -108,24 +108,24 @@ public class LauncherActivity extends BaseActivity {
private final ExtraListener<Boolean> mLaunchGameListener = (key, value) -> { private final ExtraListener<Boolean> mLaunchGameListener = (key, value) -> {
if(mProgressLayout.hasProcesses()){ if(mProgressLayout.hasProcesses()){
Toast.makeText(this, "Tasks are in progress, please wait", Toast.LENGTH_LONG).show(); Toast.makeText(this, R.string.tasks_ongoing, Toast.LENGTH_LONG).show();
return false; return false;
} }
String selectedProfile = LauncherPreferences.DEFAULT_PREF.getString(LauncherPreferences.PREF_KEY_CURRENT_PROFILE,""); String selectedProfile = LauncherPreferences.DEFAULT_PREF.getString(LauncherPreferences.PREF_KEY_CURRENT_PROFILE,"");
if (LauncherProfiles.mainProfileJson == null || LauncherProfiles.mainProfileJson.profiles == null if (LauncherProfiles.mainProfileJson == null || LauncherProfiles.mainProfileJson.profiles == null
|| !LauncherProfiles.mainProfileJson.profiles.containsKey(selectedProfile)){ || !LauncherProfiles.mainProfileJson.profiles.containsKey(selectedProfile)){
Toast.makeText(this, "No selected version", Toast.LENGTH_LONG).show(); Toast.makeText(this, R.string.error_no_version, Toast.LENGTH_LONG).show();
return false; return false;
} }
MinecraftProfile prof = LauncherProfiles.mainProfileJson.profiles.get(selectedProfile); MinecraftProfile prof = LauncherProfiles.mainProfileJson.profiles.get(selectedProfile);
if (prof == null || prof.lastVersionId == null){ if (prof == null || prof.lastVersionId == null){
Toast.makeText(this, "No selected version", Toast.LENGTH_LONG).show(); Toast.makeText(this, R.string.error_no_version, Toast.LENGTH_LONG).show();
return false; return false;
} }
if(mAccountSpinner.getSelectedAccount() == null){ if(mAccountSpinner.getSelectedAccount() == null){
Toast.makeText(this, "No selected minecraft account", Toast.LENGTH_LONG).show(); Toast.makeText(this, R.string.no_saved_accounts, Toast.LENGTH_LONG).show();
return false; return false;
} }

View File

@ -316,4 +316,6 @@
<string name="folder_dialog_insert_name">Insert folder name</string> <string name="folder_dialog_insert_name">Insert folder name</string>
<string name="main_login_done">Login done</string> <string name="main_login_done">Login done</string>
<string name="main_add_account">Add account</string> <string name="main_add_account">Add account</string>
<string name="tasks_ongoing">Tasks are in progress, please wait</string>
<string name="no_saved_accounts">No saved accounts</string>
</resources> </resources>