Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added HTML changelog support #177

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ea1af28
added Webview option to update dialog's options
Gabboxl Jan 11, 2020
48a5b19
use first the specified Url in setWebviewChangelog() for the webview
Gabboxl Jan 27, 2020
be56dab
do not open browser when using webview
Gabboxl Jan 27, 2020
0591c4a
update methods description
Gabboxl Jan 30, 2020
749db67
updated junit for demo app tests
Gabboxl Jan 30, 2020
50792d7
prevent parsing "urlChangelog" if not using webview
Gabboxl Jan 31, 2020
ddb8f16
added html changelog example to demo app
Gabboxl Jan 31, 2020
0fca791
using only one instance of Update in the whole library
Gabboxl Feb 2, 2020
3941bca
fix for library tests
Gabboxl Feb 2, 2020
ca1c0eb
using Update's setChangelogUrl() for manual webview changelog
Gabboxl Feb 2, 2020
3c71222
do not parse changelogurl if manually set
Gabboxl Feb 2, 2020
dc67afd
parserJSON fixes, create a new instance if there isn't one, using a n…
Gabboxl Feb 3, 2020
14c5a37
revert https://github.com/Gabboxl/AppUpdater/commit/0fca791ca9096a621…
Gabboxl Feb 5, 2020
76cefde
Target API 33
Gabboxl Jan 15, 2023
0eca987
Migrate to AndroidX libraries
Gabboxl Jan 15, 2023
74d52df
Update dependencies
Gabboxl Jan 15, 2023
42b0df4
Replace jcenter repository with mavenCentral
Gabboxl Jan 15, 2023
1f880ec
Update library dependencies
Gabboxl Jan 15, 2023
7c45d81
Target API level 33 for the library
Gabboxl Jan 15, 2023
98743f6
Updated AGP & wrapper again
Gabboxl Jan 15, 2023
58e6347
Import fixes
Gabboxl Jan 15, 2023
dbff008
Update AGP and Gradle wrapper again part 2
Gabboxl Jan 15, 2023
0d37aaa
Migrated other components and imports to androidx
Gabboxl Jan 15, 2023
da6012d
Add "exported" tag to manifest
Gabboxl Jan 15, 2023
fbf940e
Disable jetifier
Gabboxl Jan 15, 2023
a1dc6c6
Use MaterialAlertDialogBuilder
Gabboxl Jan 15, 2023
eda0102
Update tests with the UiThreadStatement class
Gabboxl Jan 15, 2023
a979e96
Fix android test dependencies
Gabboxl Jan 15, 2023
19d29ea
Use permission POST_NOTIFICATIONS
Gabboxl Jan 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
compileSdkVersion 33

defaultConfig {
applicationId "com.github.javiersantos.appupdater.demo"
minSdkVersion 14
targetSdkVersion 27
targetSdkVersion 33
versionCode 4
versionName "0.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

buildTypes {
Expand All @@ -24,24 +23,23 @@ android {
enabled = true
}

lintOptions {
namespace 'com.github.javiersantos.appupdater.demo'
lint {
disable 'MissingTranslation'
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation project(':library')

// Testing-only dependencies
testImplementation 'junit:junit:4.12'
androidTestImplementation('com.android.support.test:runner:1.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation 'junit:junit:4.13.2'
androidTestImplementation('androidx.test.ext:junit:1.1.5')

androidTestImplementation('androidx.test:core:1.5.0')
androidTestImplementation('androidx.test.espresso:espresso-core:3.5.1')
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.github.javiersantos.appupdater;

import android.support.test.runner.AndroidJUnit4;

import com.github.javiersantos.appupdater.objects.Update;

Expand All @@ -9,6 +8,8 @@

import static org.junit.Assert.assertTrue;

import androidx.test.ext.junit.runners.AndroidJUnit4;

@RunWith(AndroidJUnit4.class)
public class LibraryTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
package com.github.javiersantos.appupdater;

import android.support.test.InstrumentationRegistry;
import android.support.test.rule.UiThreadTestRule;
import android.support.test.runner.AndroidJUnit4;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import androidx.test.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.statement.UiThreadStatement;

import com.github.javiersantos.appupdater.enums.AppUpdaterError;
import com.github.javiersantos.appupdater.enums.UpdateFrom;
import com.github.javiersantos.appupdater.objects.Update;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

@RunWith(AndroidJUnit4.class)
public class NoUpdateAvailableTest {

@Rule
public UiThreadTestRule uiThreadTestRule = new UiThreadTestRule();

@Test
public void UpdateAvailable_Basic_JSON() throws Throwable {
final CountDownLatch signal = new CountDownLatch(1);

uiThreadTestRule.runOnUiThread(new Runnable() {
UiThreadStatement.runOnUiThread(new Runnable() {
@Override
public void run() {
new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
Expand Down Expand Up @@ -59,7 +56,7 @@ public void onFailed(AppUpdaterError error) {
public void UpdateAvailable_VersionCode_JSON() throws Throwable {
final CountDownLatch signal = new CountDownLatch(1);

uiThreadTestRule.runOnUiThread(new Runnable() {
UiThreadStatement.runOnUiThread(new Runnable() {
@Override
public void run() {
new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
Expand Down Expand Up @@ -89,7 +86,7 @@ public void onFailed(AppUpdaterError error) {
public void UpdateAvailable_Basic_XML() throws Throwable {
final CountDownLatch signal = new CountDownLatch(1);

uiThreadTestRule.runOnUiThread(new Runnable() {
UiThreadStatement.runOnUiThread(new Runnable() {
@Override
public void run() {
new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
Expand Down Expand Up @@ -119,7 +116,7 @@ public void onFailed(AppUpdaterError error) {
public void UpdateAvailable_VersionCode_XML() throws Throwable {
final CountDownLatch signal = new CountDownLatch(1);

uiThreadTestRule.runOnUiThread(new Runnable() {
UiThreadStatement.runOnUiThread(new Runnable() {
@Override
public void run() {
new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
import com.github.javiersantos.appupdater.enums.UpdateFrom;
import com.github.javiersantos.appupdater.objects.Update;

import android.support.test.InstrumentationRegistry;
import android.support.test.rule.UiThreadTestRule;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -17,17 +13,19 @@

import static org.junit.Assert.*;

import androidx.test.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.internal.runner.junit4.statement.UiThreadStatement;

@RunWith(AndroidJUnit4.class)
public class UpdateAvailableTest {

@Rule
public UiThreadTestRule uiThreadTestRule = new UiThreadTestRule();

@Test
public void UpdateAvailable_Basic_JSON() throws Throwable {
final CountDownLatch signal = new CountDownLatch(1);

uiThreadTestRule.runOnUiThread(new Runnable() {
UiThreadStatement.runOnUiThread(new Runnable() {
@Override
public void run() {
new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
Expand Down Expand Up @@ -57,7 +55,7 @@ public void onFailed(AppUpdaterError error) {
public void UpdateAvailable_VersionCode_JSON() throws Throwable {
final CountDownLatch signal = new CountDownLatch(1);

uiThreadTestRule.runOnUiThread(new Runnable() {
UiThreadStatement.runOnUiThread(new Runnable() {
@Override
public void run() {
new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
Expand Down Expand Up @@ -87,7 +85,7 @@ public void onFailed(AppUpdaterError error) {
public void UpdateAvailable_Basic_XML() throws Throwable {
final CountDownLatch signal = new CountDownLatch(1);

uiThreadTestRule.runOnUiThread(new Runnable() {
UiThreadStatement.runOnUiThread(new Runnable() {
@Override
public void run() {
new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
Expand Down Expand Up @@ -117,7 +115,7 @@ public void onFailed(AppUpdaterError error) {
public void UpdateAvailable_VersionCode_XML() throws Throwable {
final CountDownLatch signal = new CountDownLatch(1);

uiThreadTestRule.runOnUiThread(new Runnable() {
UiThreadStatement.runOnUiThread(new Runnable() {
@Override
public void run() {
new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
Expand Down Expand Up @@ -147,7 +145,7 @@ public void onFailed(AppUpdaterError error) {
public void UpdateAvailable_GOOGLEPLAY() throws Throwable {
final CountDownLatch signal = new CountDownLatch(1);

uiThreadTestRule.runOnUiThread(new Runnable() {
UiThreadStatement.runOnUiThread(new Runnable() {
@Override
public void run() {
new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
Expand Down Expand Up @@ -176,7 +174,7 @@ public void onFailed(AppUpdaterError error) {
public void UpdateAvailable_JSON() throws Throwable {
final CountDownLatch signal = new CountDownLatch(1);

uiThreadTestRule.runOnUiThread(new Runnable() {
UiThreadStatement.runOnUiThread(new Runnable() {
@Override
public void run() {
new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.javiersantos.appupdater.demo">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand All @@ -13,7 +12,8 @@
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:theme="@style/AppTheme.NoActionBar">
android:theme="@style/AppTheme.NoActionBar"
android:exported="true">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import com.github.javiersantos.appupdater.AppUpdater;
import com.github.javiersantos.appupdater.demo.databinding.ActivityMainBinding;
import com.github.javiersantos.appupdater.enums.Display;
Expand All @@ -33,14 +34,30 @@ public void onClick(View view) {
}
});

binding.included.dialogUpdateChangelogWebview.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new AppUpdater(mContext)
//.setUpdateFrom(UpdateFrom.GITHUB)
//.setGitHubUserAndRepo("javiersantos", "AppUpdater")
.setUpdateFrom(UpdateFrom.JSON)
.setUpdateJSON("https://pastebin.com/raw/eHrKfPMn")
.setDisplay(Display.DIALOG)
.showAppUpdated(true)
.setWebviewChangelog(true)
//.setWebviewChangelog(true, "http://urltochangelog.com/changelog.html")
.start();
}
});

binding.included.dialogUpdateChangelog.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new AppUpdater(mContext)
//.setUpdateFrom(UpdateFrom.GITHUB)
//.setGitHubUserAndRepo("javiersantos", "AppUpdater")
.setUpdateFrom(UpdateFrom.JSON)
.setUpdateJSON("https://raw.githubusercontent.com/javiersantos/AppUpdater/master/app/update-changelog.json")
.setUpdateJSON("https://pastebin.com/raw/eHrKfPMn")
.setDisplay(Display.DIALOG)
.showAppUpdated(true)
.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.Toolbar;
import androidx.core.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.Toolbar;

import com.github.javiersantos.appupdater.AppUpdater;
import com.github.javiersantos.appupdater.enums.Display;
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
<layout 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.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.github.javiersantos.appupdater.demo.MainActivity"
tools:ignore="PrivateResource">

<android.support.design.widget.AppBarLayout
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.design.widget.CollapsingToolbarLayout
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down Expand Up @@ -51,20 +51,20 @@
android:textSize="@dimen/abc_text_size_subhead_material"
app:layout_collapseMode="parallax" />

<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>

<include layout="@layout/content_main"
android:id="@+id/included"/>

<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -73,5 +73,5 @@
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end" />

</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
Loading