From: David A. Velasco Date: Wed, 30 Jan 2013 12:49:36 +0000 (+0100) Subject: Merge branch 'file_icons' into workaround_integration X-Git-Tag: oc-android-1.4.3~61 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/37f0586c47ab5c2b8f47a4b286b5c0df06b27c12?hp=d6f725bfebd0304b0b4f5d0daab8e311adf41aa7 Merge branch 'file_icons' into workaround_integration --- diff --git a/oc_jb_workaround/.classpath b/oc_jb_workaround/.classpath new file mode 100644 index 00000000..3f9691c5 --- /dev/null +++ b/oc_jb_workaround/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/oc_jb_workaround/.gitignore b/oc_jb_workaround/.gitignore new file mode 100644 index 00000000..0105cb34 --- /dev/null +++ b/oc_jb_workaround/.gitignore @@ -0,0 +1,19 @@ +# built application files +*.apk +*.ap_ + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files +bin/ +gen/ + +# Local configuration file (sdk path, etc) +local.properties + +# Mac .DS_Store files +.DS_Store diff --git a/oc_jb_workaround/.project b/oc_jb_workaround/.project new file mode 100644 index 00000000..54714bb1 --- /dev/null +++ b/oc_jb_workaround/.project @@ -0,0 +1,33 @@ + + + owncloud-android-workaround-accounts + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/oc_jb_workaround/.settings/org.eclipse.jdt.core.prefs b/oc_jb_workaround/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..b080d2dd --- /dev/null +++ b/oc_jb_workaround/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/oc_jb_workaround/AndroidManifest.xml b/oc_jb_workaround/AndroidManifest.xml new file mode 100644 index 00000000..af29747a --- /dev/null +++ b/oc_jb_workaround/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/oc_jb_workaround/README.md b/oc_jb_workaround/README.md new file mode 100644 index 00000000..cddf3bda --- /dev/null +++ b/oc_jb_workaround/README.md @@ -0,0 +1,10 @@ +ownCloud Jelly Bean Workaround +============================== + +Helper app to work around the problem of lost credentials at reboot time found +in devices with Android 4.1.x. + +Only needed for ownCloud apps installed from the Google Play Store. + +See more information about the bug here: +http://code.google.com/p/android/issues/detail?id=34880 \ No newline at end of file diff --git a/oc_jb_workaround/proguard-project.txt b/oc_jb_workaround/proguard-project.txt new file mode 100644 index 00000000..f2fe1559 --- /dev/null +++ b/oc_jb_workaround/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# 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 *; +#} diff --git a/oc_jb_workaround/project.properties b/oc_jb_workaround/project.properties new file mode 100644 index 00000000..9b84a6b4 --- /dev/null +++ b/oc_jb_workaround/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-16 diff --git a/oc_jb_workaround/res/drawable-hdpi/oc_icon.png b/oc_jb_workaround/res/drawable-hdpi/oc_icon.png new file mode 100644 index 00000000..e388c7be Binary files /dev/null and b/oc_jb_workaround/res/drawable-hdpi/oc_icon.png differ diff --git a/oc_jb_workaround/res/drawable-hdpi/oc_workaround_icon.png b/oc_jb_workaround/res/drawable-hdpi/oc_workaround_icon.png new file mode 100644 index 00000000..32985e36 Binary files /dev/null and b/oc_jb_workaround/res/drawable-hdpi/oc_workaround_icon.png differ diff --git a/oc_jb_workaround/res/drawable-ldpi/oc_icon.png b/oc_jb_workaround/res/drawable-ldpi/oc_icon.png new file mode 100644 index 00000000..11cf0ab1 Binary files /dev/null and b/oc_jb_workaround/res/drawable-ldpi/oc_icon.png differ diff --git a/oc_jb_workaround/res/drawable-ldpi/oc_workaround_icon.png b/oc_jb_workaround/res/drawable-ldpi/oc_workaround_icon.png new file mode 100644 index 00000000..03fa38be Binary files /dev/null and b/oc_jb_workaround/res/drawable-ldpi/oc_workaround_icon.png differ diff --git a/oc_jb_workaround/res/drawable-mdpi/oc_icon.png b/oc_jb_workaround/res/drawable-mdpi/oc_icon.png new file mode 100644 index 00000000..6997c7e4 Binary files /dev/null and b/oc_jb_workaround/res/drawable-mdpi/oc_icon.png differ diff --git a/oc_jb_workaround/res/drawable-mdpi/oc_workaround_icon.png b/oc_jb_workaround/res/drawable-mdpi/oc_workaround_icon.png new file mode 100644 index 00000000..78cd3ed4 Binary files /dev/null and b/oc_jb_workaround/res/drawable-mdpi/oc_workaround_icon.png differ diff --git a/oc_jb_workaround/res/drawable-xhdpi/oc_icon.png b/oc_jb_workaround/res/drawable-xhdpi/oc_icon.png new file mode 100644 index 00000000..e388c7be Binary files /dev/null and b/oc_jb_workaround/res/drawable-xhdpi/oc_icon.png differ diff --git a/oc_jb_workaround/res/drawable-xhdpi/oc_workaround_icon.png b/oc_jb_workaround/res/drawable-xhdpi/oc_workaround_icon.png new file mode 100644 index 00000000..d8a924c3 Binary files /dev/null and b/oc_jb_workaround/res/drawable-xhdpi/oc_workaround_icon.png differ diff --git a/oc_jb_workaround/res/values-v11/styles.xml b/oc_jb_workaround/res/values-v11/styles.xml new file mode 100644 index 00000000..541752f6 --- /dev/null +++ b/oc_jb_workaround/res/values-v11/styles.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/oc_jb_workaround/res/values-v14/styles.xml b/oc_jb_workaround/res/values-v14/styles.xml new file mode 100644 index 00000000..f20e0150 --- /dev/null +++ b/oc_jb_workaround/res/values-v14/styles.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/oc_jb_workaround/res/values/strings.xml b/oc_jb_workaround/res/values/strings.xml new file mode 100644 index 00000000..177c0536 --- /dev/null +++ b/oc_jb_workaround/res/values/strings.xml @@ -0,0 +1,6 @@ + + + + ownCloud Jelly Bean Workaround for lost credentials + + \ No newline at end of file diff --git a/oc_jb_workaround/res/values/styles.xml b/oc_jb_workaround/res/values/styles.xml new file mode 100644 index 00000000..4a10ca49 --- /dev/null +++ b/oc_jb_workaround/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/oc_jb_workaround/res/xml/authenticator.xml b/oc_jb_workaround/res/xml/authenticator.xml new file mode 100644 index 00000000..a62aa212 --- /dev/null +++ b/oc_jb_workaround/res/xml/authenticator.xml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/oc_jb_workaround/src/com/owncloud/android/workaround/accounts/AccountAuthenticatorService.java b/oc_jb_workaround/src/com/owncloud/android/workaround/accounts/AccountAuthenticatorService.java new file mode 100644 index 00000000..2d81f655 --- /dev/null +++ b/oc_jb_workaround/src/com/owncloud/android/workaround/accounts/AccountAuthenticatorService.java @@ -0,0 +1,103 @@ +/* ownCloud Jelly Bean Workaround for lost credentials + * + * Copyright (C) 2013 ownCloud Inc. + */ + +package com.owncloud.android.workaround.accounts; + +import android.accounts.AbstractAccountAuthenticator; +import android.accounts.Account; +import android.accounts.AccountAuthenticatorResponse; +import android.accounts.AccountManager; +import android.accounts.NetworkErrorException; +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.os.IBinder; + +public class AccountAuthenticatorService extends Service { + + private AccountAuthenticator mAuthenticator; + static final public String ACCOUNT_TYPE = "owncloud"; + + @Override + public void onCreate() { + super.onCreate(); + mAuthenticator = new AccountAuthenticator(this); + } + + @Override + public IBinder onBind(Intent intent) { + return mAuthenticator.getIBinder(); + } + + + public static class AccountAuthenticator extends AbstractAccountAuthenticator { + + public AccountAuthenticator(Context context) { + super(context); + } + + @Override + public Bundle addAccount(AccountAuthenticatorResponse response, + String accountType, String authTokenType, + String[] requiredFeatures, Bundle options) + throws NetworkErrorException { + return getCommonResultBundle(); + } + + + @Override + public Bundle confirmCredentials(AccountAuthenticatorResponse response, + Account account, Bundle options) throws NetworkErrorException { + return getCommonResultBundle(); + } + + @Override + public Bundle editProperties(AccountAuthenticatorResponse response, + String accountType) { + return getCommonResultBundle(); + } + + @Override + public Bundle getAuthToken(AccountAuthenticatorResponse response, + Account account, String authTokenType, Bundle options) + throws NetworkErrorException { + return getCommonResultBundle(); + } + + @Override + public String getAuthTokenLabel(String authTokenType) { + return ""; + } + + @Override + public Bundle hasFeatures(AccountAuthenticatorResponse response, + Account account, String[] features) throws NetworkErrorException { + return getCommonResultBundle(); + } + + @Override + public Bundle updateCredentials(AccountAuthenticatorResponse response, + Account account, String authTokenType, Bundle options) + throws NetworkErrorException { + return getCommonResultBundle(); + } + + @Override + public Bundle getAccountRemovalAllowed( + AccountAuthenticatorResponse response, Account account) + throws NetworkErrorException { + return getCommonResultBundle(); + } + + private Bundle getCommonResultBundle() { + Bundle resultBundle = new Bundle(); + resultBundle.putInt(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION); + resultBundle.putString(AccountManager.KEY_ERROR_MESSAGE, "This is just a workaround, not a real account authenticator"); + return resultBundle; + } + + } +} diff --git a/project.properties b/project.properties index d476196b..716944a4 100644 --- a/project.properties +++ b/project.properties @@ -8,5 +8,5 @@ # project structure. # Project target. -target=android-14 +target=android-17 android.library.reference.1=actionbarsherlock/library diff --git a/res/layout/fragment_changelog.xml b/res/layout/fragment_changelog.xml new file mode 100644 index 00000000..befaf086 --- /dev/null +++ b/res/layout/fragment_changelog.xml @@ -0,0 +1,60 @@ + + + + + + + + + \ No newline at end of file diff --git a/res/raw-de/changelog.html b/res/raw-de/changelog.html new file mode 100644 index 00000000..836ad765 --- /dev/null +++ b/res/raw-de/changelog.html @@ -0,0 +1,13 @@ + + +

+ Dieses Gerät läuft mit Android 4.1.x. +

+

+ In dieser Version von Android existiert ein Bug, der nach jedem Neustart eine erneute Eingabe der ownCloud Login-Informationen nötig macht. Um das zu umgehen installieren Sie bitte diese kostenlose Hilfs-App: +

+

+ ownCloud Jelly Bean Workaround +

+ + diff --git a/res/raw-es/changelog.html b/res/raw-es/changelog.html new file mode 100644 index 00000000..693224a3 --- /dev/null +++ b/res/raw-es/changelog.html @@ -0,0 +1,13 @@ + + +

+ Su dispositivo ejecuta Android 4.1.x. +

+

+ Para prevenir la pérdida de las credenciales de sus cuentas ownCloud en cada reinicio, por favor, instale esta app gratuita que evita el problema en Jelly Bean: +

+

+ ownCloud Jelly Bean Workaround +

+ + diff --git a/res/raw/changelog.html b/res/raw/changelog.html new file mode 100644 index 00000000..fccf0f7e --- /dev/null +++ b/res/raw/changelog.html @@ -0,0 +1,13 @@ + + +

+ Your device runs Android 4.1.x. +

+

+ To prevent losing your ownCloud account credentials on every reboot, please, install this free helper app to work around the bug in Jelly Bean: +

+

+ ownCloud Jelly Bean Workaround +

+ + diff --git a/res/values/strings.xml b/res/values/strings.xml index 0041d1b8..8676e46e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,6 +1,7 @@ ownCloud + What\'s new Password: Username: Login diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index cfee79d4..cfd9ae5e 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -35,6 +35,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources.NotFoundException; @@ -82,6 +83,7 @@ import com.owncloud.android.operations.RenameFileOperation; import com.owncloud.android.operations.SynchronizeFileOperation; import com.owncloud.android.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.syncadapter.FileSyncService; +import com.owncloud.android.ui.dialog.ChangelogDialog; import com.owncloud.android.ui.dialog.SslValidatorDialog; import com.owncloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener; import com.owncloud.android.ui.fragment.FileDetailFragment; @@ -124,6 +126,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements private static final int DIALOG_CHOOSE_UPLOAD_SOURCE = 4; private static final int DIALOG_SSL_VALIDATOR = 5; private static final int DIALOG_CERT_NOT_SAVED = 6; + private static final String DIALOG_CHANGELOG_TAG = "DIALOG_CHANGELOG"; private static final int ACTION_SELECT_CONTENT_FROM_APPS = 1; @@ -206,11 +209,41 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements actionBar.setListNavigationCallbacks(mDirectories, this); setSupportProgressBarIndeterminateVisibility(false); // always AFTER setContentView(...) ; to workaround bug in its implementation + + // show changelog, if needed + showChangeLog(); + Log.d(getClass().toString(), "onCreate() end"); } /** + * Shows a dialog with the change log of the current version after each app update + * + * TODO make it permanent; by now, only to advice the workaround app for 4.1.x + */ + private void showChangeLog() { + if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.JELLY_BEAN) { + final String KEY_VERSION = "version"; + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + int currentVersionNumber = 0; + int savedVersionNumber = sharedPref.getInt(KEY_VERSION, 0); + try { + PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0); + currentVersionNumber = pi.versionCode; + } catch (Exception e) {} + + if (currentVersionNumber > savedVersionNumber) { + ChangelogDialog.newInstance(true).show(getSupportFragmentManager(), DIALOG_CHANGELOG_TAG); + Editor editor = sharedPref.edit(); + editor.putInt(KEY_VERSION, currentVersionNumber); + editor.commit(); + } + } + } + + + /** * Launches the account creation activity. To use when no ownCloud account is available */ private void createFirstAccount() { diff --git a/src/com/owncloud/android/ui/dialog/ChangelogDialog.java b/src/com/owncloud/android/ui/dialog/ChangelogDialog.java new file mode 100644 index 00000000..6330da74 --- /dev/null +++ b/src/com/owncloud/android/ui/dialog/ChangelogDialog.java @@ -0,0 +1,109 @@ +/* ownCloud Android client application + * Copyright (C) 2013 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +package com.owncloud.android.ui.dialog; + +import java.io.InputStream; +import java.util.Scanner; + +import android.app.AlertDialog; +import android.app.Dialog; +import android.content.DialogInterface; +import android.net.Uri; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.webkit.WebView; +import android.widget.TextView; + +import com.actionbarsherlock.app.SherlockDialogFragment; +import com.owncloud.android.R; + +/** + * Dialog to show the contents of res/raw/CHANGELOG.txt + */ +public class ChangelogDialog extends SherlockDialogFragment { + + private static final String ARG_CANCELABLE = ChangelogDialog.class.getCanonicalName() + ".ARG_CANCELABLE"; + + + /** + * Public factory method to get dialog instances. + * + * @param cancelable If 'true', the dialog can be cancelled by the user input (BACK button, touch outside...) + * @return New dialog instance, ready to show. + */ + public static ChangelogDialog newInstance(boolean cancelable) { + ChangelogDialog fragment = new ChangelogDialog(); + Bundle args = new Bundle(); + args.putBoolean(ARG_CANCELABLE, cancelable); + fragment.setArguments(args); + return fragment; + } + + + /** + * {@inheritDoc} + */ + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + /// load the custom view to insert in the dialog, between title and + WebView webview = new WebView(getActivity()); + webview.loadUrl("file:///android_res/raw/" + getResources().getResourceEntryName(R.raw.changelog) + ".html"); + + /// build the dialog + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + Dialog dialog = builder.setView(webview) + .setIcon(R.drawable.icon) + .setTitle(R.string.whats_new) + .setPositiveButton(R.string.common_ok, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }).create(); + + dialog.setCancelable(getArguments().getBoolean(ARG_CANCELABLE)); + return dialog; + } + + /** + * {@inheritDoc} + *-/ + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + /// load the custom layout + View view = inflater.inflate(R.layout.fragment_changelog, container); + mEditText = (EditText) view.findViewById(R.id.txt_your_name); + getDialog().setTitle(R.string.whats_new); + + /// read full contents of the change log file (don't make it too big) + InputStream changeLogStream = getResources().openRawResource(R.raw.changelog); + Scanner scanner = new java.util.Scanner(changeLogStream).useDelimiter("\\A"); + String text = scanner.hasNext() ? scanner.next() : ""; + + /// make clickable the links in the change log file + SpannableString sText = new SpannableString(text); + Linkify.addLinks(sText, Linkify.ALL); + + return view; + } + */ +} + +