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

View file

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

View file

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

View file

@ -6,8 +6,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:1.5.0' classpath 'com.android.tools.build:gradle:2.0.0-beta2'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'me.tatarka:gradle-retrolambda:3.2.4' classpath 'me.tatarka:gradle-retrolambda:3.2.4'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0' 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 distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists 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