Skip to content

Commit

Permalink
Use Prebuilt Library for App Updates
Browse files Browse the repository at this point in the history
Signed-off-by: GauthamAsir <[email protected]>
  • Loading branch information
GauthamAsir committed Apr 28, 2020
1 parent 6111086 commit 9825ca5
Show file tree
Hide file tree
Showing 28 changed files with 1,050 additions and 17 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 21
targetSdkVersion 29
versionCode 2
versionName "2.7"
versionName "2.6"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -21,6 +21,11 @@ android {
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies {
Expand All @@ -39,7 +44,6 @@ dependencies {

implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
implementation 'de.hdodenhof:circleimageview:3.1.0'

implementation 'com.github.javiersantos:AppUpdater:2.7'
implementation project(path: ':library')

}
5 changes: 4 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="a.gautham.statusdownloader">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Expand Down Expand Up @@ -28,10 +29,12 @@
android:name="androidx.core.content.FileProvider"
android:authorities="a.gautham.statusdownloader.provider"
android:exported="false"
tools:replace="android:authorities"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
android:resource="@xml/provider_paths"
tools:replace="android:resource"/>
</provider>
</application>

Expand Down
15 changes: 5 additions & 10 deletions app/src/main/java/a/gautham/statusdownloader/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;

import com.github.javiersantos.appupdater.AppUpdater;
import com.github.javiersantos.appupdater.enums.Display;
import com.github.javiersantos.appupdater.enums.UpdateFrom;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout;

import java.io.File;
import java.util.Objects;

import a.gautham.library.AppUpdater;
import a.gautham.library.Display;
import a.gautham.statusdownloader.Adapter.PageAdapter;
import a.gautham.statusdownloader.Utils.Common;

Expand Down Expand Up @@ -170,13 +169,9 @@ private class GetLatestAppVersion extends AsyncTask{
@Override
protected Object doInBackground(Object[] objects) {

final AppUpdater appUpdater = new AppUpdater(MainActivity.this)
.setDisplay(Display.DIALOG)
.setUpdateFrom(UpdateFrom.XML)
.setUpdateXML("https://raw.githubusercontent.com/GauthamAsir/WhatsApp_Status_Saver/master/update.xml")
.setCancelable(false)
.setButtonDoNotShowAgain(null);

AppUpdater appUpdater = new AppUpdater(MainActivity.this);
appUpdater.setDisplay(Display.DIALOG);
appUpdater.setUpGithub("GauthamAsir","WhatsApp_Status_Saver");
appUpdater.start();

return null;
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
repositories {
google()
jcenter()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
Expand Down
1 change: 1 addition & 0 deletions library/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
52 changes: 52 additions & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"

defaultConfig {
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

//RetroFit
implementation 'com.squareup.retrofit2:retrofit:2.8.1'
implementation 'com.squareup.retrofit2:converter-gson:2.8.1'

//Recycler View
implementation 'androidx.recyclerview:recyclerview:1.1.0'

//Card View
implementation 'androidx.cardview:cardview:1.0.0'

//Material Themes
implementation 'com.google.android.material:material:1.1.0'

}
Empty file added library/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions library/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package a.gautham.library;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

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

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();

assertEquals("a.gautham.library.test", appContext.getPackageName());
}
}
21 changes: 21 additions & 0 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="a.gautham.library" >

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<application>

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths"/>
</provider>

</application>
</manifest>
Loading

0 comments on commit 9825ca5

Please sign in to comment.