Upgrade gradle. Other minor changes

This commit is contained in:
inorichi 2016-02-06 00:37:11 +01:00
parent 34c5f0b7ba
commit c35184abdc
5 changed files with 36 additions and 34 deletions

View File

@ -1,6 +1,5 @@
import java.text.SimpleDateFormat
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
@ -29,6 +28,10 @@ ext {
}
}
def includeUpdater() {
return hasProperty("include_updater");
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
@ -45,6 +48,7 @@ android {
buildConfigField "String", "COMMIT_COUNT", "\"${getCommitCount()}\""
buildConfigField "String", "COMMIT_SHA", "\"${getGitSha()}\""
buildConfigField "String", "BUILD_TIME", "\"${getBuildTime()}\""
buildConfigField "boolean", "INCLUDE_UPDATER", "${includeUpdater()}"
}
compileOptions {

View File

@ -59,11 +59,11 @@ public class UpdateDownloader extends AsyncTask<String, Void, Void> {
@Override
protected Void doInBackground(String... arg0) {
protected Void doInBackground(String... args) {
try {
createCacheDir();
URL url = new URL(arg0[0]);
URL url = new URL(args[0]);
HttpURLConnection c = (HttpURLConnection) url.openConnection();
c.connect();

View File

@ -67,7 +67,7 @@ public class SettingsAboutFragment extends SettingsNestedFragment {
//Set onClickListener to check for new version
version.setOnPreferenceClickListener(preference -> {
if (!BuildConfig.DEBUG)
if (!BuildConfig.DEBUG && BuildConfig.INCLUDE_UPDATER)
checkVersion();
return true;
});
@ -101,33 +101,32 @@ public class SettingsAboutFragment extends SettingsNestedFragment {
releaseSubscription = updateChecker.checkForApplicationUpdate()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(next -> {
//Get version of latest releaseSubscription
String newVersion = next.getVersion();
newVersion = newVersion.replaceAll("[^\\d.]", "");
.subscribe(release -> {
//Get version of latest release
String newVersion = release.getVersion();
newVersion = newVersion.replaceAll("[^\\d.]", "");
//Check if latest version is different from current version
if (!newVersion.equals(BuildConfig.VERSION_NAME)) {
String downloadLink = next.getDownloadLink();
String body = next.getChangeLog();
//Check if latest version is different from current version
if (!newVersion.equals(BuildConfig.VERSION_NAME)) {
String downloadLink = release.getDownloadLink();
String body = release.getChangeLog();
//Create confirmation window
new MaterialDialog.Builder(getActivity())
.title(getString(R.string.update_check_title))
.content(body)
.positiveText(getString(R.string.update_check_confirm))
.negativeText(getString(R.string.update_check_ignore))
.onPositive((dialog, which) -> {
// User output that download has started
ToastUtil.showShort(getActivity(), getString(R.string.update_check_download_started));
// Start download
new UpdateDownloader(getActivity()).execute(downloadLink);
})
.show();
} else {
ToastUtil.showShort(getActivity(), getString(R.string.update_check_no_new_updates));
}
},
Throwable::printStackTrace);
//Create confirmation window
new MaterialDialog.Builder(getActivity())
.title(getString(R.string.update_check_title))
.content(body)
.positiveText(getString(R.string.update_check_confirm))
.negativeText(getString(R.string.update_check_ignore))
.onPositive((dialog, which) -> {
// User output that download has started
ToastUtil.showShort(getActivity(), getString(R.string.update_check_download_started));
// Start download
new UpdateDownloader(getActivity().getApplicationContext()).execute(downloadLink);
})
.show();
} else {
ToastUtil.showShort(getActivity(), getString(R.string.update_check_no_new_updates));
}
}, Throwable::printStackTrace);
}
}

View File

@ -6,8 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
classpath 'com.android.tools.build:gradle:2.0.0-beta2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'me.tatarka:gradle-retrolambda:3.2.4'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'

View File

@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Fri Feb 05 17:57:08 CET 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip