-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from SanojPunchihewa/dev
Add method to get Available version code
- Loading branch information
Showing
13 changed files
with
228 additions
and
51 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
language: android | ||
sudo: required | ||
jdk: oraclejdk8 | ||
dist: trusty | ||
|
||
env: | ||
global: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 34 additions & 4 deletions
38
app/src/main/java/com/zanojmobiapps/inappupdatedemoapp/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,97 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/layout_main" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".MainActivity" | ||
android:id="@+id/layout_main"> | ||
tools:context=".MainActivity"> | ||
|
||
<LinearLayout | ||
android:layout_centerInParent="true" | ||
android:id="@+id/linearLayout" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="8dp" | ||
android:layout_marginTop="120dp" | ||
android:gravity="center_horizontal" | ||
android:orientation="vertical" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintHorizontal_bias="0.5" | ||
app:layout_constraintStart_toEndOf="@+id/linearLayout2" | ||
app:layout_constraintTop_toTopOf="parent"> | ||
|
||
<TextView | ||
android:id="@+id/txt_available_version" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textSize="40sp" | ||
tools:text="25" /> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="Available Version" | ||
android:textSize="15sp" /> | ||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:id="@+id/linearLayout2" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content"> | ||
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"> | ||
|
||
<TextView | ||
android:id="@+id/textView" | ||
android:id="@+id/txt_current_version" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="In App Update Demo App" | ||
android:textSize="25sp" /> | ||
android:textSize="40sp" | ||
tools:text="2" /> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="Current Version" | ||
android:textSize="15sp" /> | ||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_centerInParent="true" | ||
android:layout_marginEnd="8dp" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="100dp" | ||
android:gravity="center_horizontal" | ||
android:orientation="vertical" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/linearLayout"> | ||
|
||
<com.google.android.material.button.MaterialButton | ||
style="@style/Widget.MaterialComponents.Button.OutlinedButton" | ||
android:textColor="@color/colorAccent" | ||
app:strokeColor="@color/colorAccent" | ||
android:layout_width="200dp" | ||
android:layout_height="wrap_content" | ||
android:text="Flexible Update" | ||
android:layout_margin="10dp" | ||
android:onClick="callFlexibleUpdate" /> | ||
|
||
<com.google.android.material.button.MaterialButton | ||
android:backgroundTint="@color/colorAccent" | ||
android:layout_width="200dp" | ||
android:layout_height="wrap_content" | ||
android:text="Immediate Update" | ||
android:layout_margin="10dp" | ||
android:onClick="callImmediateUpdate" /> | ||
|
||
</LinearLayout> | ||
|
||
</RelativeLayout> | ||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.