From bf85ecb81433f98be38b9b50d92b6405e8dbdfdf Mon Sep 17 00:00:00 2001 From: Akash-Ramjyothi Date: Sun, 3 Apr 2022 00:42:35 +0530 Subject: [PATCH] Added Update App feature --- build.gradle | 2 ++ .../hostage/ui/activity/MainActivity.java | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/build.gradle b/build.gradle index ec3c02ff..367b968d 100644 --- a/build.gradle +++ b/build.gradle @@ -110,6 +110,8 @@ dependencies { implementation files('libs/VirusTotalAPI.jar') implementation 'com.google.firebase:firebase-analytics:19.0.0' + implementation 'com.github.javiersantos:AppUpdater:2.7' + // https://mvnrepository.com/artifact/com.hierynomus/smbj testImplementation group: 'com.hierynomus', name: 'smbj', version: '0.11.1' diff --git a/src/main/java/dk/aau/netsec/hostage/ui/activity/MainActivity.java b/src/main/java/dk/aau/netsec/hostage/ui/activity/MainActivity.java index ac657437..7aafc915 100644 --- a/src/main/java/dk/aau/netsec/hostage/ui/activity/MainActivity.java +++ b/src/main/java/dk/aau/netsec/hostage/ui/activity/MainActivity.java @@ -43,6 +43,10 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; +import com.github.javiersantos.appupdater.AppUpdater; +import com.github.javiersantos.appupdater.enums.Display; +import com.github.javiersantos.appupdater.enums.UpdateFrom; + import dk.aau.netsec.hostage.Hostage; import dk.aau.netsec.hostage.R; import dk.aau.netsec.hostage.location.MyLocationManager; @@ -274,6 +278,8 @@ protected void onCreate(Bundle savedInstanceState) { context = new WeakReference<>(getApplicationContext()); setContentView(R.layout.activity_drawer_main); + setUpUpdatePrompt(); + addAnimation(); // configures the action bar configureActionBar(); @@ -303,6 +309,21 @@ protected void onCreate(Bundle savedInstanceState) { } } + public void setUpUpdatePrompt() { + AppUpdater appUpdater = new AppUpdater(this); + + new AppUpdater(this) + .setUpdateFrom(UpdateFrom.GOOGLE_PLAY) + .setDisplay(Display.DIALOG) + .setTitleOnUpdateAvailable("Update available")//Title of the Dialog Prompt + .setContentOnUpdateAvailable("Check out the latest version available of Amahi Android App!")//Description of the Dialog Prompt + .setButtonUpdate("Update")//Updates the App + .setButtonDoNotShowAgain("Don't show again");//Never shows the prompt again until next release + + appUpdater.start(); + } + + private void executeRoot() { CheckRoot checkRoot = new CheckRoot(); checkRoot.execute();