From: David A. Velasco Date: Wed, 30 Jan 2013 12:46:15 +0000 (+0100) Subject: Added dialog in the main app to advise users about the workaround app X-Git-Tag: oc-android-1.4.3~62 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/5da9c095a462e59ed3d0dd997b5adc33f2788dc8 Added dialog in the main app to advise users about the workaround app --- 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; + } + */ +} + +