From: tobiasKaminsky Date: Thu, 5 Nov 2015 20:37:08 +0000 (+0100) Subject: check available beta version X-Git-Tag: beta-20151122~43 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/21cacceea00a4181566b4c41ee50cdf2ed1cd55f?ds=inline;hp=-c check available beta version --- 21cacceea00a4181566b4c41ee50cdf2ed1cd55f diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 77f8a0db..240d73be 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -17,8 +17,7 @@ along with this program. If not, see . --> + android:versionName="ownCloud beta" xmlns:android="http://schemas.android.com/apk/res/android"> diff --git a/apks/latest b/apks/latest new file mode 100644 index 00000000..57d5957c --- /dev/null +++ b/apks/latest @@ -0,0 +1 @@ +20151105 diff --git a/apks/owncloud-beta-2015-11-02.apk b/apks/owncloud-beta-2015-11-02.apk new file mode 100644 index 00000000..924f6260 Binary files /dev/null and b/apks/owncloud-beta-2015-11-02.apk differ diff --git a/apks/owncloud-beta-20151105.apk b/apks/owncloud-beta-20151105.apk new file mode 100644 index 00000000..0206ed55 Binary files /dev/null and b/apks/owncloud-beta-20151105.apk differ diff --git a/build.gradle b/build.gradle index be674c9f..d707b027 100644 --- a/build.gradle +++ b/build.gradle @@ -3,13 +3,12 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:1.3.0' } } apply plugin: 'com.android.application' - repositories { mavenCentral() @@ -33,6 +32,7 @@ android { defaultConfig { applicationId "com.owncloud.android.beta" + versionCode computeVersionCode() } sourceSets { @@ -73,4 +73,8 @@ android { } } - +def computeVersionCode() { + def date = new Date() + def formattedDate = date.format('yyyyMMdd').toInteger() + return formattedDate +} \ No newline at end of file diff --git a/oc_jb_workaround/build.gradle b/oc_jb_workaround/build.gradle index 2fcc9f6c..4a48a297 100644 --- a/oc_jb_workaround/build.gradle +++ b/oc_jb_workaround/build.gradle @@ -3,7 +3,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'com.android.tools.build:gradle:1.3.0' } } apply plugin: 'com.android.library' diff --git a/res/values/setup.xml b/res/values/setup.xml index c1c6e7ac..0d156b2c 100644 --- a/res/values/setup.xml +++ b/res/values/setup.xml @@ -47,7 +47,7 @@ true true http://owncloud.com/mobile/help - https://github.com/owncloud/android/raw/beta/apks/latest.apk + https://github.com/owncloud/android/raw/beta/apks/owncloud-beta- "mailto:" "mailto:apps@owncloud.com" diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 06e9142b..29e8fe26 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -112,7 +112,7 @@ android:key="about_app" /> diff --git a/src/com/owncloud/android/ui/activity/Preferences.java b/src/com/owncloud/android/ui/activity/Preferences.java index 8ba64280..6bdc1e16 100644 --- a/src/com/owncloud/android/ui/activity/Preferences.java +++ b/src/com/owncloud/android/ui/activity/Preferences.java @@ -34,6 +34,7 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; import android.net.Uri; +import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; @@ -62,6 +63,7 @@ import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ArrayAdapter; import android.widget.ListAdapter; import android.widget.ListView; +import android.widget.Toast; import com.owncloud.android.BuildConfig; import com.owncloud.android.MainApp; @@ -80,6 +82,13 @@ import com.owncloud.android.services.OperationsService; import com.owncloud.android.ui.RadioButtonPreference; import com.owncloud.android.utils.DisplayUtils; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.concurrent.ExecutionException; + /** * An Activity that allows the user to change the application's settings. @@ -478,12 +487,30 @@ public class Preferences extends PreferenceActivity pBetaLink.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { - String betaLinkWeb = (String) getText(R.string.beta_link); - if (betaLinkWeb != null && betaLinkWeb.length() > 0) { - Uri uriUrl = Uri.parse(betaLinkWeb); - Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl); - startActivity(intent); + Integer currentVersion = BuildConfig.VERSION_CODE; + LoadingVersionNumberTask loadTask = new LoadingVersionNumberTask(); + loadTask.execute(); + Integer latestVersion = -1; + try { + latestVersion = loadTask.get(); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); } + if (latestVersion == -1){ + Toast.makeText(getApplicationContext(), "No information available!", Toast.LENGTH_SHORT).show(); + } + if (latestVersion > currentVersion){ + String betaLinkWeb = (String) getText(R.string.beta_link) + latestVersion + ".apk"; + if (betaLinkWeb != null && betaLinkWeb.length() > 0) { + Uri uriUrl = Uri.parse(betaLinkWeb); + Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl); + startActivity(intent); + return true; + } + } else { + Toast.makeText(getApplicationContext(), "No new version available!", Toast.LENGTH_SHORT).show(); + return true; + } return true; } }); @@ -641,6 +668,7 @@ public class Preferences extends PreferenceActivity public void setContentView(View view) { getDelegate().setContentView(view); } + @Override public void setContentView(View view, ViewGroup.LayoutParams params) { getDelegate().setContentView(view, params); @@ -917,4 +945,29 @@ public class Preferences extends PreferenceActivity } } }; + + /** + * + * Class for loading the version number + * + */ + private class LoadingVersionNumberTask extends AsyncTask { + protected Integer doInBackground(Void... args) { + try { + URL url = new URL("https://www.tobiaskaminsky.de/ocVersion"); + BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); + + Integer latestVersion = Integer.parseInt(in.readLine()); + in.close(); + + return latestVersion; + + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return -1; + } + } }