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

62 lines
2.6 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;
import android.text.SpannableStringBuilder;
import android.text.method.LinkMovementMethod;
import android.text.style.RelativeSizeSpan;
import android.text.style.URLSpan;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
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;
2020-07-25 21:10:26 +00:00
import androidx.fragment.app.FragmentManager;
2020-07-01 17:08:28 +00:00
import awais.instagrabber.BuildConfig;
import awais.instagrabber.R;
import awais.instagrabber.interfaces.FetchListener;
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 -> {
new AlertDialog.Builder(context)
2020-07-26 22:23:24 +00:00
.setTitle(res.getString(R.string.update_available, version))
2020-07-25 21:10:26 +00:00
.setMessage(R.string.update_notice)
.setNeutralButton(R.string.cancel, null)
.setNegativeButton(R.string.action_github, (dialog, which) -> {
2020-07-01 17:08:28 +00:00
try {
2020-07-25 21:10:26 +00:00
context.startActivity(new Intent(Intent.ACTION_VIEW).setData(
Uri.parse("https://github.com/austinhuang0131/instagrabber/releases/latest")));
2020-07-01 17:08:28 +00:00
} catch (final ActivityNotFoundException e) {
// do nothing
}
2020-07-25 21:10:26 +00:00
})
.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
}
}
}