diff --git a/.idea/markdown-exported-files.xml b/.idea/markdown-exported-files.xml
new file mode 100644
index 0000000..5d1f129
--- /dev/null
+++ b/.idea/markdown-exported-files.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 016e06d..acb5fc2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,6 @@
language: android
sudo: required
-jdk: oraclejdk8
+dist: trusty
env:
global:
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..2081288
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,25 @@
+# Changelog
+All notable changes to InAppUpdater will be documented in this file.
+
+## [Unreleased]
+### Added
+- Method to get the Version code of the Available Update
+
+### Changed
+- Pass the Activity to the `Builder()` instead of `start()`
+```java
+mUpdateManager = UpdateManager.Builder(this);
+```
+- No need to pass Activity to `continueUpdate()`
+## [1.0.3-alpha.1] - 2019-07-25
+### Added
+- Debug Logs to the UpdateManager
+
+## [1.0.2] - 2019-07-16
+
+## [1.0.1] - 2019-07-16
+### Changed
+- Package name
+
+## [v1.0] - 2019-07-16
+:tada: Initial Release
\ No newline at end of file
diff --git a/README.md b/README.md
index 0246fd3..4fee505 100644
--- a/README.md
+++ b/README.md
@@ -24,37 +24,48 @@ allprojects {
### Step 2: Add the dependency
```Gradle
dependencies {
- implementation 'com.github.SanojPunchihewa:InAppUpdater:1.0.2'
+ implementation 'com.github.SanojPunchihewa:InAppUpdater:1.0.3'
}
```
### Step 3: Initialize the UpdateManager
Initialize the UpdateManager in your `onCreate` method of the Activity
```java
- UpdateManager.Builder().mode(UpdateManagerConstant.IMMEDIATE).start(this);
+ UpdateManager.Builder(this).mode(UpdateManagerConstant.FLEXIBLE).start();
```
-#### Update Mode
+**Update Mode**
+
There are two modes
-* Flexible *(default)* - User can use the app during update download, installation and restart needs to be triggered by user
+* Flexible(`UpdateManagerConstant.FLEXIBLE`) *(default)* - User can use the app during update download, installation and restart needs to be triggered by user
-* Immediate - User will be blocked until download and installation is finished, restart is triggered automatically
+* Immediate(`UpdateManagerConstant.IMMEDIATE`) - User will be blocked until download and installation is finished, restart is triggered automatically
-#### Set the update mode
-```java
- UpdateManager.Builder().mode(UpdateManagerConstant.IMMEDIATE)
-```
-
### Step 4: Resume the updates
Call `continueUpdate` method in your `onResume` method to install waiting updates
```java
@Override
protected void onResume() {
super.onResume();
- UpdateManager.continueUpdate(this);
+ UpdateManager.continueUpdate();
}
```
+**Additionally** you can get the Available Version Code of the update. You can find these codes in the [demo app](/app/src/main/java/com/zanojmobiapps/inappupdatedemoapp/MainActivity.java)
+
+```java
+mUpdateManager.getAvailableVersionCode(new onVersionCheckListener() {
+ @Override
+ public void onReceiveVersionCode(final int code) {
+ // Do something here
+ }
+});
+```
+## :movie_camera: Demo
+Flexible Update | Immediate Update
+:-------------------------:|:-------------------------:
+![](/images/gif/flexible_update.gif) | ![](/images/gif/immediate_update.gif)
+
## :exclamation: Troubleshoot
- In-app updates works only with devices running **Android 5.0 (API level 21) or higher**
- In-app updates are available only to user accounts that own the app. So, **make sure the account you’re using has downloaded your app from Google Play at least once before using the account to test in-app updates.**
diff --git a/app/src/main/java/com/zanojmobiapps/inappupdatedemoapp/MainActivity.java b/app/src/main/java/com/zanojmobiapps/inappupdatedemoapp/MainActivity.java
index 64f1ea2..ad62045 100644
--- a/app/src/main/java/com/zanojmobiapps/inappupdatedemoapp/MainActivity.java
+++ b/app/src/main/java/com/zanojmobiapps/inappupdatedemoapp/MainActivity.java
@@ -1,25 +1,55 @@
package com.zanojmobiapps.inappupdatedemoapp;
-import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
-
+import android.view.View;
+import android.widget.TextView;
+import androidx.appcompat.app.AppCompatActivity;
import com.sanojpunchihewa.updatemanager.UpdateManager;
+import com.sanojpunchihewa.updatemanager.UpdateManager.onVersionCheckListener;
import com.sanojpunchihewa.updatemanager.UpdateManagerConstant;
public class MainActivity extends AppCompatActivity {
+ // Declare the UpdateManager
+ UpdateManager mUpdateManager;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
- UpdateManager.Builder().mode(UpdateManagerConstant.IMMEDIATE).start(this);
+ TextView txtCurrentVersion = findViewById(R.id.txt_current_version);
+ TextView txtAvailableVersion = findViewById(R.id.txt_available_version);
+
+ txtCurrentVersion.setText(String.valueOf(BuildConfig.VERSION_CODE));
+
+ // Initialize the Update Manager with the Activity and the Update Mode
+ mUpdateManager = UpdateManager.Builder(this);
+
+ // Callback from Available version code
+ mUpdateManager.getAvailableVersionCode(new onVersionCheckListener() {
+ @Override
+ public void onReceiveVersionCode(final int code) {
+ txtAvailableVersion.setText(String.valueOf(code));
+ }
+ });
}
@Override
protected void onResume() {
super.onResume();
- UpdateManager.continueUpdate(this);
+ // Continue updates when resumed
+ mUpdateManager.continueUpdate();
+ }
+
+ public void callFlexibleUpdate(View view) {
+ // Start a Flexible Update
+ mUpdateManager.mode(UpdateManagerConstant.FLEXIBLE).start();
+ }
+
+ public void callImmediateUpdate(View view) {
+ // Start a Immediate Update
+ mUpdateManager.mode(UpdateManagerConstant.IMMEDIATE).start();
}
}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 849515d..78a51ec 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -1,24 +1,97 @@
-
+ tools:context=".MainActivity">
+
+
+
+
+
+
+
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:layout_marginTop="120dp"
+ android:gravity="center_horizontal"
+ android:orientation="vertical"
+ app:layout_constraintEnd_toStartOf="@+id/linearLayout"
+ app:layout_constraintHorizontal_bias="0.5"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
+ android:textSize="40sp"
+ tools:text="2" />
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 9513160..e18f895 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -1,7 +1,7 @@
-