BarInsta/app/src/main/java/awais/instagrabber/utils/FlavorTown.java

55 lines
2.5 KiB
Java
Raw Normal View History

2020-07-01 17:08:28 +00:00
package awais.instagrabber.utils;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.AsyncTask;
2020-07-23 16:00:09 +00:00
import android.widget.Toast;
2020-07-01 17:08:28 +00:00
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import awais.instagrabber.BuildConfig;
import awais.instagrabber.R;
import static awais.instagrabber.utils.Utils.settingsHelper;
public final class FlavorTown {
public static void updateCheck(@NonNull final Context context) {
2020-07-25 21:10:26 +00:00
Resources res = context.getResources();
new UpdateChecker(version -> {
2020-08-22 07:22:53 +00:00
if (!version.equals(BuildConfig.VERSION_NAME) && !BuildConfig.DEBUG) {
2020-08-22 01:12:26 +00:00
new AlertDialog.Builder(context)
.setTitle(res.getString(R.string.update_available, version))
.setMessage(R.string.update_notice)
.setNeutralButton(R.string.cancel, null)
.setNegativeButton(R.string.action_github, (dialog, which) -> {
try {
context.startActivity(new Intent(Intent.ACTION_VIEW).setData(
Uri.parse("https://github.com/austinhuang0131/instagrabber/releases/latest")));
} catch (final ActivityNotFoundException e) {
// do nothing
}
})
.setPositiveButton(R.string.action_fdroid, (dialog, which) -> {
try {
context.startActivity(new Intent(Intent.ACTION_VIEW).setData(
Uri.parse("https://f-droid.org/packages/me.austinhuang.instagrabber/")));
} catch (final ActivityNotFoundException e) {
// do nothing
}
})
.show();
}
2020-07-01 17:08:28 +00:00
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
public static void changelogCheck(@NonNull final Context context) {
if (settingsHelper.getInteger(Constants.PREV_INSTALL_VERSION) < BuildConfig.VERSION_CODE) {
2020-07-23 16:00:09 +00:00
Toast.makeText(context, R.string.updated, Toast.LENGTH_SHORT).show();
settingsHelper.putInteger(Constants.PREV_INSTALL_VERSION, BuildConfig.VERSION_CODE);
2020-07-01 17:08:28 +00:00
}
}
}