removed update toast when app first opens

This commit is contained in:
Denis Çerri 2022-09-18 14:25:30 +02:00
parent aa8a05d118
commit e3106936b8
No known key found for this signature in database
GPG key ID: 3F50F14A8E7F7A13
3 changed files with 11 additions and 6 deletions

View file

@ -48,7 +48,9 @@ public class MoreFragment extends PreferenceFragmentCompat {
}); });
updateApp.setOnPreferenceClickListener(preference -> { updateApp.setOnPreferenceClickListener(preference -> {
updateUtil.updateApp(); if(!updateUtil.updateApp()){
Toast.makeText(getContext(), R.string.you_are_in_latest_version, Toast.LENGTH_SHORT).show();
}
return true; return true;
}); });
} }

View file

@ -225,7 +225,9 @@ public class SettingsFragment extends PreferenceFragmentCompat {
}); });
version.setOnPreferenceClickListener(preference -> { version.setOnPreferenceClickListener(preference -> {
updateUtil.updateApp(); if(!updateUtil.updateApp()){
Toast.makeText(getContext(), R.string.you_are_in_latest_version, Toast.LENGTH_SHORT).show();
}
return true; return true;
}); });

View file

@ -45,10 +45,10 @@ public class UpdateUtil {
downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
} }
public void updateApp(){ public boolean updateApp(){
if (updatingApp) { if (updatingApp) {
Toast.makeText(context, context.getString(R.string.ytdl_already_updating), Toast.LENGTH_LONG).show(); Toast.makeText(context, context.getString(R.string.ytdl_already_updating), Toast.LENGTH_LONG).show();
return; return true;
} }
AtomicReference<JSONObject> res = new AtomicReference<>(new JSONObject()); AtomicReference<JSONObject> res = new AtomicReference<>(new JSONObject());
try{ try{
@ -71,8 +71,7 @@ public class UpdateUtil {
} catch (JSONException ignored) {} } catch (JSONException ignored) {}
if(version.equals("v"+BuildConfig.VERSION_NAME)){ if(version.equals("v"+BuildConfig.VERSION_NAME)){
Toast.makeText(context, R.string.you_are_in_latest_version, Toast.LENGTH_SHORT).show(); return false;
return;
} }
MaterialAlertDialogBuilder updateDialog = new MaterialAlertDialogBuilder(context) MaterialAlertDialogBuilder updateDialog = new MaterialAlertDialogBuilder(context)
@ -82,6 +81,8 @@ public class UpdateUtil {
.setNegativeButton("Cancel", (dialogInterface, i) -> {}) .setNegativeButton("Cancel", (dialogInterface, i) -> {})
.setPositiveButton("Update", (dialogInterface, i) -> startAppUpdate(res.get())); .setPositiveButton("Update", (dialogInterface, i) -> startAppUpdate(res.get()));
updateDialog.show(); updateDialog.show();
return true;
} }