Skip to content

Commit

Permalink
Add automatic APK open after download option
Browse files Browse the repository at this point in the history
Refactor and clean up code a bit
  • Loading branch information
revanmj committed Jun 30, 2018
1 parent 9a252a6 commit c5a1e74
Show file tree
Hide file tree
Showing 9 changed files with 335 additions and 323 deletions.
14 changes: 9 additions & 5 deletions library/wversionmanager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'

ext {

bintrayRepo = "Android-WVersionManager"
bintrayName = "com.winsontan520.wversionmanager"
libraryDescription = ''
Expand All @@ -15,7 +14,7 @@ ext {
siteUrl = 'https://github.com/revanmj/Android-WVersionManager'
gitUrl = 'https://github.com/revanmj/Android-WVersionManager.git'

libraryVersion = '1.5'
libraryVersion = "1.6"

developerId = 'revanmj'
developerName = 'Michal Jakubowski'
Expand All @@ -33,8 +32,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
versionCode 5
versionName "1.5"
versionCode 6
versionName "$libraryVersion"
}

buildTypes {
Expand All @@ -43,10 +42,15 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.android.support:support-v4:27.1.1'
}

task deleteJar(type: Delete) {
Expand Down
10 changes: 9 additions & 1 deletion library/wversionmanager/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<provider
android:name="com.winsontan520.wversionmanager.UpdateFileProvider"
android:authorities="${applicationId}.UpdateFileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.winsontan520.wversionmanager.library;
package com.winsontan520.wversionmanager;

import org.xml.sax.XMLReader;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,60 +1,53 @@
package com.winsontan520.wversionmanager.library;
package com.winsontan520.wversionmanager;

import android.Manifest;
import android.graphics.drawable.Drawable;
import android.support.annotation.RequiresPermission;

public interface IWVersionManager {

/**
* @return Label of update now button
*/
public String getUpdateNowLabel();


/**
* @param updateNowLabel Set the label for update now button
*/
public void setUpdateNowLabel(String updateNowLabel);

/**
* @return label of remind me later button
*/
public String getRemindMeLaterLabel();

/**
* @param remindMeLaterLabel Set label of remind me later button
* Displays a dialog asking user to rate your app
*/
public void setRemindMeLaterLabel(String remindMeLaterLabel);

/**
* @return label of ignore this version button
*/
public String getIgnoreThisVersionLabel();

public void askForRate();
/**
* @param ignoreThisVersionLabel Set label of ignore this version button
* Initiates check for updates that may result in displaying a dialog with release notes
* and options to update now, remind user about it later or ignore that version
*/
public void setIgnoreThisVersionLabel(String ignoreThisVersionLabel);

public void checkVersion();
/**
* @param icon Set drawable of icon in dialog
* @param icon Drawable of icon in dialog
*/
public void setIcon(Drawable icon);

/**
* @param title Set title of dialog
* @param title Title of dialog
*/
public void setTitle(String title);

/**
* @param message Set message of dialog
* @param message Message of dialog
*/
public void setMessage(String message);

/**
* @param value Set if Android's Download Manager should be used (off by default) instead of opening a link in a browser
* Used to choose if Android's Download Manager should be used to download file at URL
* from JSON file to Downloads folder (off by default) instead of opening a link in a browser
* @param value <code>true</code> to use Download Manager, <code>false</code> otherwise
*/
@RequiresPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
public void useDownloadManager(boolean value);

/**
* Setting this to <code>true</code> when {@link #useDownloadManager(boolean)}
* is also <code>true</code> will automatically fire APK installation dialog after download completes.
* This requires Unknown Sources to be enabled (globally on Nougat and lower,
* for your app specifically in Oreo or higher). If permission is not granted,
* system's Download app will be launched.
* @param value <code>true</code> to enable auto install, <code>false</code> otherwise
*/
@RequiresPermission(anyOf = {Manifest.permission.REQUEST_INSTALL_PACKAGES, Manifest.permission.INSTALL_PACKAGES})
public void installAfterDownload(boolean value);

/**
* @return message of dialog
*/
Expand Down Expand Up @@ -124,5 +117,4 @@ public interface IWVersionManager {
* @param listener Set your own callback listener when receiving response from server
*/
public void setOnReceiveListener(OnReceiveListener listener);

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.winsontan520.wversionmanager.library;
package com.winsontan520.wversionmanager;

public interface OnReceiveListener {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.winsontan520.wversionmanager;

import android.support.v4.content.FileProvider;

public class UpdateFileProvider extends FileProvider { }
Loading

0 comments on commit c5a1e74

Please sign in to comment.