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 -> {
updateUtil.updateApp();
if(!updateUtil.updateApp()){
Toast.makeText(getContext(), R.string.you_are_in_latest_version, Toast.LENGTH_SHORT).show();
}
return true;
});
}

View file

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

View file

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