diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 5cd135a..f05a1d5 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -11,6 +11,7 @@
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 37a7509..7bfef59 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/app/build.gradle b/app/build.gradle
index 977145c..a9033d1 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -9,7 +9,7 @@ android {
minSdkVersion 21
targetSdkVersion 29
versionCode 2
- versionName "2.7"
+ versionName "2.6"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@@ -21,6 +21,11 @@ android {
}
}
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
}
dependencies {
@@ -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')
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index a167fd4..45eda2a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,5 +1,6 @@
@@ -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">
+ android:resource="@xml/provider_paths"
+ tools:replace="android:resource"/>
diff --git a/app/src/main/java/a/gautham/statusdownloader/MainActivity.java b/app/src/main/java/a/gautham/statusdownloader/MainActivity.java
index 7ce1f3c..91e6b5a 100644
--- a/app/src/main/java/a/gautham/statusdownloader/MainActivity.java
+++ b/app/src/main/java/a/gautham/statusdownloader/MainActivity.java
@@ -20,9 +20,6 @@
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;
@@ -30,6 +27,8 @@
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;
@@ -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;
diff --git a/build.gradle b/build.gradle
index b99ecae..bb6000c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
repositories {
google()
jcenter()
-
+
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
diff --git a/library/.gitignore b/library/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/library/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/library/build.gradle b/library/build.gradle
new file mode 100644
index 0000000..c47842b
--- /dev/null
+++ b/library/build.gradle
@@ -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'
+
+}
diff --git a/library/consumer-rules.pro b/library/consumer-rules.pro
new file mode 100644
index 0000000..e69de29
diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro
new file mode 100644
index 0000000..f1b4245
--- /dev/null
+++ b/library/proguard-rules.pro
@@ -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
diff --git a/library/src/androidTest/java/a/gautham/library/ExampleInstrumentedTest.java b/library/src/androidTest/java/a/gautham/library/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..2dcfc45
--- /dev/null
+++ b/library/src/androidTest/java/a/gautham/library/ExampleInstrumentedTest.java
@@ -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 Testing documentation
+ */
+@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());
+ }
+}
diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..8d8989a
--- /dev/null
+++ b/library/src/main/AndroidManifest.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/library/src/main/java/a/gautham/library/AppUpdater.java b/library/src/main/java/a/gautham/library/AppUpdater.java
new file mode 100644
index 0000000..e2599da
--- /dev/null
+++ b/library/src/main/java/a/gautham/library/AppUpdater.java
@@ -0,0 +1,445 @@
+package a.gautham.library;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.os.PowerManager;
+import android.util.Log;
+import android.widget.Toast;
+
+import androidx.core.content.FileProvider;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.ref.WeakReference;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import a.gautham.library.helper.ServiceGenerator;
+import a.gautham.library.models.AssestsModel;
+import a.gautham.library.models.GitRelease;
+import a.gautham.library.models.Update;
+import a.gautham.library.service.GithubService;
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+
+public class AppUpdater {
+
+ private Context context;
+ private String dialogTitle, dialogMessage, dialogBtnPositiveText, dialogBtnNegativeText, gitUsername, gitRepoName;
+ private boolean dialogCancelable;
+ private int dialogAlertStyle, dialog_icon;
+ private UpdateListener updateListener;
+ private UtilsAsync utilsAsync;
+ private static final String TAG = "AppUpdater: ";
+ private static DownloadTask downloadTask;
+ private Display display;
+
+ public AppUpdater(Context context) {
+ this.context = context;
+
+ // DIALOG
+ this.dialogTitle = context.getString(R.string.app_updater_new_update_available);
+ this.dialogBtnPositiveText = context.getString(R.string.app_updater_update);
+ this.dialogBtnNegativeText = context.getString(R.string.app_updater_cancel);
+ this.dialogMessage = "";
+ this.dialogCancelable = false;
+ this.dialog_icon = R.drawable.ic_system_update;
+ this.dialogAlertStyle = R.style.dialogAlertStyle;
+
+ this.updateListener = new UpdateListener() {
+ @Override
+ public void onSuccess(Update update, boolean isUpdateAvailable) {
+ if (isUpdateAvailable){
+
+ if (display == Display.DIALOG)
+ showDialog(update);
+
+ }
+ }
+
+ @Override
+ public void onFailed(String error) {
+
+ }
+ };
+
+ }
+
+ public interface UpdateListener{
+
+ void onSuccess(Update update, boolean isUpdateAvailable);
+
+ void onFailed(String error);
+ }
+
+ public AppUpdater withListener(UpdateListener updateListener){
+ this.updateListener = updateListener;
+ return this;
+ }
+
+ public AppUpdater setDialogTitle(String dialogTitle) {
+ this.dialogTitle = dialogTitle;
+ return this;
+ }
+
+ public AppUpdater setDialogMessage(String dialogMessage) {
+ this.dialogMessage = dialogMessage;
+ return this;
+ }
+
+ public AppUpdater setDialogBtnPositive(String dialogBtnPositive) {
+ this.dialogBtnPositiveText = dialogBtnPositive;
+ return this;
+ }
+
+ public AppUpdater setDialogBtnNegative(String dialogBtnNegative) {
+ this.dialogBtnNegativeText = dialogBtnNegative;
+ return this;
+ }
+
+ public AppUpdater setDialogCancelable(boolean dialogCancelable) {
+ this.dialogCancelable = dialogCancelable;
+ return this;
+ }
+
+ public AppUpdater setDialogAlertStyle(int dialogAlertStyle) {
+ this.dialogAlertStyle = dialogAlertStyle;
+ return this;
+ }
+
+ public AppUpdater setDialog_icon(int dialog_icon) {
+ this.dialog_icon = dialog_icon;
+ return this;
+ }
+
+ public AppUpdater setUpGithub(String gitUsername, String gitRepoName){
+ this.gitUsername = gitUsername;
+ this.gitRepoName = gitRepoName;
+ return this;
+ }
+
+ public void setDisplay(Display display) {
+ this.display = display;
+ }
+
+ public void start(){
+
+ utilsAsync = new UtilsAsync(context, gitUsername, gitRepoName, updateListener);
+ utilsAsync.execute();
+
+ }
+
+ static class UtilsAsync extends AsyncTask{
+
+ private WeakReference contextRef;
+ private String gitUsername, gitRepoName;
+ private UpdateListener updateListener;
+ private Update update1;
+
+ UtilsAsync(Context context, String gitUsername, String gitRepoName, UpdateListener updateListener) {
+ this.contextRef = new WeakReference<>(context);
+ this.gitUsername = gitUsername;
+ this.gitRepoName = gitRepoName;
+ this.updateListener = updateListener;
+ }
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+
+ Context context = contextRef.get();
+ if (context == null || updateListener == null){
+ cancel(true);
+ }else if (isNetworkAvailable(context)){
+ if (!isGitHubValid(gitUsername, gitRepoName)){
+ updateListener.onFailed(context.getString(R.string.app_updater_git_empty));
+ cancel(true);
+ }
+ }else {
+ updateListener.onFailed(context.getString(R.string.app_updater_no_internet));
+ cancel(true);
+ }
+
+ }
+
+ @Override
+ protected Object doInBackground(Object[] objects) {
+
+ try {
+ Call callAsync;
+ GithubService githubService = ServiceGenerator.build().create(GithubService.class);
+ callAsync = githubService.getReleases(gitUsername, gitRepoName);
+
+ callAsync.enqueue(new Callback() {
+ @Override
+ public void onResponse(Call call, Response response) {
+
+ if (response.code() == 200){
+
+ GitRelease releases = response.body();
+ AssestsModel assestsModel = releases.getAssestsModels().get(0);
+
+ double size = assestsModel.getSize();
+ double fileSizeInKB = size / 1024;
+ double fileSizeInMB = fileSizeInKB / 1024;
+ double fileSizeInGb = fileSizeInMB / 1024;
+
+ Update update = new Update(assestsModel.getDownload_url(),
+ assestsModel.getAssest_name(),
+ releases.getRelease_title(),
+ releases.getRelease_description(),
+ releases.getRelease_tag_name(),
+ assestsModel.getDownload_count(),
+ assestsModel.getSize(), fileSizeInKB, fileSizeInMB, fileSizeInGb);
+ update1 = update;
+
+ double currentAppversion = Double.parseDouble(getAppVersion(contextRef.get()));
+ double latestAppversion = Double.parseDouble(releases.getRelease_tag_name());
+
+ updateListener.onSuccess(update,isUpdateAvailable(currentAppversion, latestAppversion));
+
+ }else {
+ updateListener.onFailed("Failed: " + response.message());
+ cancel(true);
+ }
+
+ }
+
+ @Override
+ public void onFailure(Call call, Throwable t) {
+ Log.e(TAG + "Error: ",t.getMessage());
+ updateListener.onFailed("Error: "+ t.getMessage());
+ cancel(true);
+ }
+ });
+
+ }catch (Exception e){
+ Log.e(TAG + "Failed: ",e.getMessage());
+ updateListener.onFailed("Failed: "+ e.getMessage());
+ cancel(true);
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Object o) {
+ super.onPostExecute(o);
+
+
+ }
+ }
+
+ private void showDialog(Update update1) {
+
+ AlertDialog.Builder builder =
+ new AlertDialog.Builder(context, dialogAlertStyle)
+ .setTitle(dialogTitle)
+ .setCancelable(dialogCancelable)
+ .setIcon(dialog_icon);
+
+ if (dialogMessage.isEmpty()){
+ builder.setMessage(String.format("New Update %s is Available. By Downloading the latest " +
+ "update, you will get the latest features, " +
+ "improvements and bug fixes. Do you want to Update App?",update1.getLatest_version()));
+ }else {
+ builder.setMessage(dialogMessage);
+ }
+
+ builder.setPositiveButton(dialogBtnPositiveText, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ downloadTask = new DownloadTask(context, update1);
+ downloadTask.execute(update1.getDownloadUrl());
+ }
+ });
+ builder.setNegativeButton(dialogBtnNegativeText, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ }
+ });
+
+ builder.show();
+ }
+
+ public void stop(){
+ if (utilsAsync != null && utilsAsync.isCancelled()){
+ utilsAsync.cancel(true);
+ }
+ }
+
+ private static boolean isGitHubValid(String gitUsername, String gitRepoName) {
+
+ if (gitUsername == null || gitRepoName == null){
+ return false;
+ }else
+ return !gitUsername.isEmpty() && !gitRepoName.isEmpty() && gitUsername.length() != 0 && gitRepoName.length() != 0;
+ }
+
+ private static boolean isUpdateAvailable(double currentAppversion, double latestAppversion){
+
+ return currentAppversion < latestAppversion;
+ }
+
+ static Boolean isNetworkAvailable(Context context) {
+ Boolean res = false;
+ ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (cm != null) {
+ NetworkInfo networkInfo = cm.getActiveNetworkInfo();
+ if (networkInfo != null) {
+ res = networkInfo.isConnected();
+ }
+ }
+
+ return res;
+ }
+
+ private static String getAppVersion(Context context){
+
+ String result = "";
+ try {
+ result = context.getPackageManager().getPackageInfo(context.getPackageName(),0)
+ .versionName;
+ result = result.replaceAll("[a-zA-Z]|-","");
+ }catch (PackageManager.NameNotFoundException e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ private static class DownloadTask extends AsyncTask {
+
+ private WeakReference contextRef;
+ private String app_name;
+ private PowerManager.WakeLock mWakeLock;
+ private DownloadDialog downloadDialog;
+
+ DownloadTask(Context context, Update update) {
+ this.contextRef = new WeakReference<>(context);
+ this.app_name = update.getAsset_name();
+ downloadDialog = new DownloadDialog(contextRef.get());
+ downloadDialog.setDownloadName(update.getAsset_name());
+ downloadDialog.setDownloadSize(update.getAsses_sizeMb()+"MB");
+ downloadDialog.setNegativeBtnListener(new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ cancel(true);
+ }
+ });
+ }
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ PowerManager pm = (PowerManager) contextRef.get().getSystemService(Context.POWER_SERVICE);
+ mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
+ getClass().getName());
+ mWakeLock.acquire();
+ downloadDialog.show();
+ }
+
+ @Override
+ protected String doInBackground(String... sUrl) {
+ InputStream input = null;
+ OutputStream output = null;
+ HttpURLConnection connection = null;
+
+ try {
+ URL url = new URL(sUrl[0]);
+ connection = (HttpURLConnection) url.openConnection();
+ connection.connect();
+
+ // expect HTTP 200 OK, so we don't mistakenly save error report
+ // instead of the file
+ if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
+ return "Server returned HTTP " + connection.getResponseCode()
+ + " " + connection.getResponseMessage();
+ }
+
+ // this will be useful to display download percentage
+ // might be -1: server did not report the length
+ int fileLength = connection.getContentLength();
+
+ // download the file
+ input = connection.getInputStream();
+ output = new FileOutputStream(contextRef.get().getExternalFilesDir(null).getAbsolutePath() + "/"+app_name);
+
+ byte[] data = new byte[4096];
+ long total = 0;
+ int count;
+ while ((count = input.read(data)) != -1) {
+ // allow canceling with back button
+ if (isCancelled()) {
+ input.close();
+ return null;
+ }
+ total += count;
+ // publishing the progress....
+ if (fileLength > 0) // only if total length is known
+ publishProgress((int) (total * 100 / fileLength));
+ output.write(data, 0, count);
+
+ }
+ } catch (Exception e) {
+ return e.toString();
+ } finally {
+ try {
+ if (output != null)
+ output.close();
+ if (input != null)
+ input.close();
+ } catch (IOException ignored) {
+ }
+
+ if (connection != null)
+ connection.disconnect();
+ }
+ return null;
+ }
+
+ @Override
+ protected void onProgressUpdate(Integer... progress) {
+ super.onProgressUpdate(progress);
+
+ downloadDialog.setProgressPercent(progress[0] + "%");
+ downloadDialog.setProgressBaPercent(progress[0]);
+ }
+
+ @Override
+ protected void onPostExecute(String result) {
+
+ mWakeLock.release();
+ downloadDialog.hide();
+ if (result != null){
+ Toast.makeText(contextRef.get(),R.string.app_updater_download_error+result, Toast.LENGTH_LONG).show();
+ }
+ else{
+
+ Toast.makeText(contextRef.get(),R.string.app_updater_update_downloaded, Toast.LENGTH_SHORT).show();
+
+ File file = new File(contextRef.get().getExternalFilesDir(null).getAbsolutePath()
+ + "/" + app_name);
+ Uri data = FileProvider.getUriForFile(contextRef.get(), contextRef.get().getPackageName() +".provider",file);
+
+ Intent installAPK = new Intent(Intent.ACTION_INSTALL_PACKAGE);
+ installAPK.setDataAndType(data,"application/vnd.android.package-archive");
+ installAPK.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+ contextRef.get().startActivity(installAPK);
+ }
+ }
+ }
+
+}
diff --git a/library/src/main/java/a/gautham/library/Display.java b/library/src/main/java/a/gautham/library/Display.java
new file mode 100644
index 0000000..a209cca
--- /dev/null
+++ b/library/src/main/java/a/gautham/library/Display.java
@@ -0,0 +1,7 @@
+package a.gautham.library;
+
+public enum Display {
+ DIALOG,
+ SNACKBAR,
+ NOTIFICATION
+}
\ No newline at end of file
diff --git a/library/src/main/java/a/gautham/library/DownloadDialog.java b/library/src/main/java/a/gautham/library/DownloadDialog.java
new file mode 100644
index 0000000..36a3266
--- /dev/null
+++ b/library/src/main/java/a/gautham/library/DownloadDialog.java
@@ -0,0 +1,74 @@
+package a.gautham.library;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+
+public class DownloadDialog extends AlertDialog {
+
+ private int progressBaPercent;
+ private DialogInterface.OnClickListener negativeBtnListener;
+ private AlertDialog alertDialog;
+ private TextView percent_pg, download_name, download_size;
+ private ProgressBar progressBar;
+
+ DownloadDialog(@NonNull Context context) {
+ super(context);
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.dialogAlertStyle);
+ builder.setCancelable(false);
+
+ View view = LayoutInflater.from(context).inflate(R.layout.download_layout, null);
+ builder.setView(view);
+
+ progressBar = view.findViewById(R.id.progressBar);
+ download_name = view.findViewById(R.id.download_name);
+ download_size = view.findViewById(R.id.download_size);
+ percent_pg = view.findViewById(R.id.percent_pg);
+ builder.setTitle(R.string.app_updater_downloading);
+ builder.setIcon(R.drawable.ic_system_update);
+
+ progressBar.setMax(100);
+ progressBar.setIndeterminate(false);
+ progressBar.setProgress(progressBaPercent);
+
+ builder.setNegativeButton("Cancel",negativeBtnListener);
+
+ alertDialog = builder.create();
+
+ }
+
+ void setDownloadName(String downloadName) {
+ download_name.setText(downloadName);
+ }
+
+ void setDownloadSize(String downloadSize) {
+ download_size.setText(downloadSize);
+ }
+
+ void setProgressPercent(String progressPercent) {
+ percent_pg.setText(progressPercent);
+ }
+
+ void setProgressBaPercent(int progressBaPercent) {
+ progressBar.setProgress(progressBaPercent);
+ }
+
+ void setNegativeBtnListener(OnClickListener negativeBtn) {
+ this.negativeBtnListener = negativeBtn;
+ }
+
+ public void show(){
+ alertDialog.show();
+ }
+
+ public void hide(){
+ alertDialog.dismiss();
+ }
+}
diff --git a/library/src/main/java/a/gautham/library/helper/ServiceGenerator.java b/library/src/main/java/a/gautham/library/helper/ServiceGenerator.java
new file mode 100644
index 0000000..6f1fa95
--- /dev/null
+++ b/library/src/main/java/a/gautham/library/helper/ServiceGenerator.java
@@ -0,0 +1,19 @@
+package a.gautham.library.helper;
+
+import retrofit2.Retrofit;
+import retrofit2.converter.gson.GsonConverterFactory;
+
+public class ServiceGenerator {
+
+ private static final String GITHUB_BASE_URL = "https://api.github.com/";
+
+ public static Retrofit build(){
+ Retrofit.Builder builder = new Retrofit.Builder();
+ builder.baseUrl(GITHUB_BASE_URL);
+ builder.addConverterFactory(GsonConverterFactory.create());
+
+ Retrofit retrofit = builder.build();
+ return retrofit;
+ }
+
+}
diff --git a/library/src/main/java/a/gautham/library/models/AssestsModel.java b/library/src/main/java/a/gautham/library/models/AssestsModel.java
new file mode 100644
index 0000000..4cfdcb1
--- /dev/null
+++ b/library/src/main/java/a/gautham/library/models/AssestsModel.java
@@ -0,0 +1,50 @@
+package a.gautham.library.models;
+
+import com.google.gson.annotations.SerializedName;
+
+public class AssestsModel {
+
+ @SerializedName("browser_download_url")
+ private String download_url;
+
+ @SerializedName("download_count")
+ private long download_count;
+
+ @SerializedName("size")
+ private long size;
+
+ @SerializedName("name")
+ private String assest_name;
+
+ public String getDownload_url() {
+ return download_url;
+ }
+
+ public void setDownload_url(String download_url) {
+ this.download_url = download_url;
+ }
+
+ public long getDownload_count() {
+ return download_count;
+ }
+
+ public void setDownload_count(long download_count) {
+ this.download_count = download_count;
+ }
+
+ public long getSize() {
+ return size;
+ }
+
+ public void setSize(long size) {
+ this.size = size;
+ }
+
+ public String getAssest_name() {
+ return assest_name;
+ }
+
+ public void setAssest_name(String assest_name) {
+ this.assest_name = assest_name;
+ }
+}
diff --git a/library/src/main/java/a/gautham/library/models/GitRelease.java b/library/src/main/java/a/gautham/library/models/GitRelease.java
new file mode 100644
index 0000000..9913c32
--- /dev/null
+++ b/library/src/main/java/a/gautham/library/models/GitRelease.java
@@ -0,0 +1,85 @@
+package a.gautham.library.models;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.util.List;
+
+public class GitRelease {
+
+ @SerializedName("name")
+ private String release_title;
+
+ @SerializedName("body")
+ private String release_description;
+
+ @SerializedName("draft")
+ private boolean draft;
+
+ @SerializedName("prerelease")
+ private boolean prerelease;
+
+ @SerializedName("tag_name")
+ private String release_tag_name;
+
+ @SerializedName("assets_url")
+ private String assets_url;
+
+ @SerializedName("assets")
+ private List assestsModels;
+
+ public List getAssestsModels() {
+ return assestsModels;
+ }
+
+ public void setAssestsModels(List assestsModels) {
+ this.assestsModels = assestsModels;
+ }
+
+ public String getRelease_title() {
+ return release_title;
+ }
+
+ public void setRelease_title(String release_title) {
+ this.release_title = release_title;
+ }
+
+ public String getRelease_description() {
+ return release_description;
+ }
+
+ public void setRelease_description(String release_description) {
+ this.release_description = release_description;
+ }
+
+ public boolean isDraft() {
+ return draft;
+ }
+
+ public void setDraft(boolean draft) {
+ this.draft = draft;
+ }
+
+ public boolean isPrerelease() {
+ return prerelease;
+ }
+
+ public void setPrerelease(boolean prerelease) {
+ this.prerelease = prerelease;
+ }
+
+ public String getRelease_tag_name() {
+ return release_tag_name;
+ }
+
+ public void setRelease_tag_name(String release_tag_name) {
+ this.release_tag_name = release_tag_name;
+ }
+
+ public String getAssets_url() {
+ return assets_url;
+ }
+
+ public void setAssets_url(String assets_url) {
+ this.assets_url = assets_url;
+ }
+}
diff --git a/library/src/main/java/a/gautham/library/models/Update.java b/library/src/main/java/a/gautham/library/models/Update.java
new file mode 100644
index 0000000..845511e
--- /dev/null
+++ b/library/src/main/java/a/gautham/library/models/Update.java
@@ -0,0 +1,101 @@
+package a.gautham.library.models;
+
+public class Update {
+
+ private String downloadUrl, asset_name, release_title, release_description, latest_version;
+ private long download_count, asset_size;
+ private double asset_sizeKb, asses_sizeMb, asset_Gb;
+
+ public Update(String downloadUrl, String asset_name, String release_title, String release_description, String latest_version, long download_count, long asset_size, double asset_sizeKb, double asses_sizeMb, double asset_Gb) {
+ this.downloadUrl = downloadUrl;
+ this.asset_name = asset_name;
+ this.release_title = release_title;
+ this.release_description = release_description;
+ this.latest_version = latest_version;
+ this.download_count = download_count;
+ this.asset_size = asset_size;
+ this.asset_sizeKb = asset_sizeKb;
+ this.asses_sizeMb = asses_sizeMb;
+ this.asset_Gb = asset_Gb;
+ }
+
+ public String getDownloadUrl() {
+ return downloadUrl;
+ }
+
+ public void setDownloadUrl(String downloadUrl) {
+ this.downloadUrl = downloadUrl;
+ }
+
+ public String getAsset_name() {
+ return asset_name;
+ }
+
+ public void setAsset_name(String asset_name) {
+ this.asset_name = asset_name;
+ }
+
+ public String getRelease_title() {
+ return release_title;
+ }
+
+ public void setRelease_title(String release_title) {
+ this.release_title = release_title;
+ }
+
+ public String getRelease_description() {
+ return release_description;
+ }
+
+ public void setRelease_description(String release_description) {
+ this.release_description = release_description;
+ }
+
+ public String getLatest_version() {
+ return latest_version;
+ }
+
+ public void setLatest_version(String latest_version) {
+ this.latest_version = latest_version;
+ }
+
+ public long getDownload_count() {
+ return download_count;
+ }
+
+ public void setDownload_count(long download_count) {
+ this.download_count = download_count;
+ }
+
+ public long getAsset_size() {
+ return asset_size;
+ }
+
+ public void setAsset_size(long asset_size) {
+ this.asset_size = asset_size;
+ }
+
+ public double getAsset_sizeKb() {
+ return asset_sizeKb;
+ }
+
+ public void setAsset_sizeKb(double asset_sizeKb) {
+ this.asset_sizeKb = asset_sizeKb;
+ }
+
+ public double getAsses_sizeMb() {
+ return asses_sizeMb;
+ }
+
+ public void setAsses_sizeMb(double asses_sizeMb) {
+ this.asses_sizeMb = asses_sizeMb;
+ }
+
+ public double getAsset_Gb() {
+ return asset_Gb;
+ }
+
+ public void setAsset_Gb(double asset_Gb) {
+ this.asset_Gb = asset_Gb;
+ }
+}
diff --git a/library/src/main/java/a/gautham/library/service/GithubService.java b/library/src/main/java/a/gautham/library/service/GithubService.java
new file mode 100644
index 0000000..dbd729b
--- /dev/null
+++ b/library/src/main/java/a/gautham/library/service/GithubService.java
@@ -0,0 +1,12 @@
+package a.gautham.library.service;
+
+import a.gautham.library.models.GitRelease;
+import retrofit2.Call;
+import retrofit2.http.GET;
+import retrofit2.http.Path;
+
+public interface GithubService {
+ @GET("/repos/{username}/{repo}/releases/latest")
+ public Call getReleases(@Path("username") String username, @Path("repo") String repo);
+
+}
diff --git a/library/src/main/res/drawable/ic_system_update.xml b/library/src/main/res/drawable/ic_system_update.xml
new file mode 100644
index 0000000..c654ff8
--- /dev/null
+++ b/library/src/main/res/drawable/ic_system_update.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/library/src/main/res/layout/download_layout.xml b/library/src/main/res/layout/download_layout.xml
new file mode 100644
index 0000000..07e6139
--- /dev/null
+++ b/library/src/main/res/layout/download_layout.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/values/app_updater.xml b/library/src/main/res/values/app_updater.xml
new file mode 100644
index 0000000..0bb1b47
--- /dev/null
+++ b/library/src/main/res/values/app_updater.xml
@@ -0,0 +1,14 @@
+
+
+ New Update Available!
+ You are Up-To date. No new updates available
+ Update
+ Cancel
+ Git User Name or Repo Name can\'t be Empty
+ No Internet Available
+ App Updater
+ 0%
+ Error Downloading
+ Update Downloaded
+ Downloading
+
\ No newline at end of file
diff --git a/library/src/main/res/values/colors.xml b/library/src/main/res/values/colors.xml
new file mode 100644
index 0000000..4faecfa
--- /dev/null
+++ b/library/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #6200EE
+ #3700B3
+ #03DAC5
+
\ No newline at end of file
diff --git a/library/src/main/res/values/styles.xml b/library/src/main/res/values/styles.xml
new file mode 100644
index 0000000..ca33314
--- /dev/null
+++ b/library/src/main/res/values/styles.xml
@@ -0,0 +1,7 @@
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/xml/filepaths.xml b/library/src/main/res/xml/filepaths.xml
new file mode 100644
index 0000000..ffa74ab
--- /dev/null
+++ b/library/src/main/res/xml/filepaths.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/library/src/test/java/a/gautham/library/ExampleUnitTest.java b/library/src/test/java/a/gautham/library/ExampleUnitTest.java
new file mode 100644
index 0000000..bd2e6c9
--- /dev/null
+++ b/library/src/test/java/a/gautham/library/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package a.gautham.library;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index 4feee4a..6f2259a 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,2 +1,2 @@
rootProject.name='Status Downloader'
-include ':app'
+include ':app', ':library'