Added dialog in the main app to advise users about the workaround app
authorDavid A. Velasco <dvelasco@solidgear.es>
Wed, 30 Jan 2013 12:46:15 +0000 (13:46 +0100)
committerDavid A. Velasco <dvelasco@solidgear.es>
Wed, 30 Jan 2013 12:46:15 +0000 (13:46 +0100)
project.properties
res/layout/fragment_changelog.xml [new file with mode: 0644]
res/raw-de/changelog.html [new file with mode: 0644]
res/raw-es/changelog.html [new file with mode: 0644]
res/raw/changelog.html [new file with mode: 0644]
res/values/strings.xml
src/com/owncloud/android/ui/activity/FileDisplayActivity.java
src/com/owncloud/android/ui/dialog/ChangelogDialog.java [new file with mode: 0644]

index d476196..716944a 100644 (file)
@@ -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 (file)
index 0000000..befaf08
--- /dev/null
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 
+  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 2 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 <http://www.gnu.org/licenses/>.
+ -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/owncloud_white" 
+    android:id="@+id/explanation"
+    android:orientation="vertical">
+
+       <TextView
+               android:id="@+id/message"
+               android:layout_width="match_parent"
+               android:layout_height="0dp"
+               android:layout_weight="2"
+           android:padding="10dip"
+           android:scrollbarAlwaysDrawVerticalTrack="true"
+               android:text="@string/text_placeholder"
+               android:autoLink="all"
+               />
+    
+    <!-- LinearLayout
+        android:id="@+id/buttons"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center"
+        android:orientation="horizontal" >
+
+               <Button
+                   android:id="@+id/ok"
+                   android:layout_width="wrap_content"
+                   android:layout_height="wrap_content"
+                   android:layout_weight="1"
+                   android:text="@string/common_ok" />
+               
+        <Button
+            android:id="@+id/cancel"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:text="@string/common_cancel" />
+
+       </LinearLayout -->
+       
+</LinearLayout>
\ No newline at end of file
diff --git a/res/raw-de/changelog.html b/res/raw-de/changelog.html
new file mode 100644 (file)
index 0000000..836ad76
--- /dev/null
@@ -0,0 +1,13 @@
+<html>
+       <body>
+       <p>
+               Dieses Gerät läuft mit Android 4.1.x.
+       </p>
+       <p>
+               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: 
+       </p>
+       <p style="text-align:center">
+               <a href="http://play.google.com/store/apps/details?id=com.owncloud.android.workaround.accounts">ownCloud Jelly Bean Workaround</a> 
+       </p>
+       </body>
+</html>
diff --git a/res/raw-es/changelog.html b/res/raw-es/changelog.html
new file mode 100644 (file)
index 0000000..693224a
--- /dev/null
@@ -0,0 +1,13 @@
+<html>
+       <body>
+       <p>
+               Su dispositivo ejecuta Android 4.1.x. 
+       </p>
+       <p>
+               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:        
+       </p>
+       <p style="text-align:center">
+               <a href="http://play.google.com/store/apps/details?id=com.owncloud.android.workaround.accounts">ownCloud Jelly Bean Workaround</a>
+       </p>
+       </body>
+</html>
diff --git a/res/raw/changelog.html b/res/raw/changelog.html
new file mode 100644 (file)
index 0000000..fccf0f7
--- /dev/null
@@ -0,0 +1,13 @@
+<html>
+       <body>
+       <p>
+               Your device runs Android 4.1.x. 
+       </p>
+       <p>
+               To prevent losing your ownCloud account credentials on every reboot, please, install this free helper app to work around the bug in Jelly Bean:
+       </p>
+       <p style="text-align:center">
+               <a href="http://play.google.com/store/apps/details?id=com.owncloud.android.workaround.accounts">ownCloud Jelly Bean Workaround</a> 
+       </p>
+       </body>
+</html>
index 0041d1b..8676e46 100644 (file)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
     <string name="app_name">ownCloud</string>
+    <string name="whats_new">What\'s new</string>
     <string name="main_password">Password:</string>
     <string name="main_login">Username:</string>
     <string name="main_button_login">Login</string>
index cfee79d..cfd9ae5 100644 (file)
@@ -35,6 +35,7 @@ import android.content.Intent;
 import android.content.IntentFilter;\r
 import android.content.ServiceConnection;\r
 import android.content.SharedPreferences;\r
+import android.content.SharedPreferences.Editor;\r
 import android.content.pm.PackageInfo;\r
 import android.content.pm.PackageManager.NameNotFoundException;\r
 import android.content.res.Resources.NotFoundException;\r
@@ -82,6 +83,7 @@ import com.owncloud.android.operations.RenameFileOperation;
 import com.owncloud.android.operations.SynchronizeFileOperation;\r
 import com.owncloud.android.operations.RemoteOperationResult.ResultCode;\r
 import com.owncloud.android.syncadapter.FileSyncService;\r
+import com.owncloud.android.ui.dialog.ChangelogDialog;\r
 import com.owncloud.android.ui.dialog.SslValidatorDialog;\r
 import com.owncloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener;\r
 import com.owncloud.android.ui.fragment.FileDetailFragment;\r
@@ -124,6 +126,7 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
     private static final int DIALOG_CHOOSE_UPLOAD_SOURCE = 4;\r
     private static final int DIALOG_SSL_VALIDATOR = 5;\r
     private static final int DIALOG_CERT_NOT_SAVED = 6;\r
+    private static final String DIALOG_CHANGELOG_TAG = "DIALOG_CHANGELOG";\r
 \r
     \r
     private static final int ACTION_SELECT_CONTENT_FROM_APPS = 1;\r
@@ -206,11 +209,41 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
         actionBar.setListNavigationCallbacks(mDirectories, this);\r
         setSupportProgressBarIndeterminateVisibility(false);        // always AFTER setContentView(...) ; to workaround bug in its implementation\r
         \r
+        \r
+        // show changelog, if needed\r
+        showChangeLog();\r
+        \r
         Log.d(getClass().toString(), "onCreate() end");\r
     }\r
 \r
     \r
     /**\r
+     * Shows a dialog with the change log of the current version after each app update\r
+     * \r
+     *  TODO make it permanent; by now, only to advice the workaround app for 4.1.x\r
+     */\r
+    private void showChangeLog() {\r
+        if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.JELLY_BEAN) {\r
+            final String KEY_VERSION = "version";\r
+            SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());\r
+            int currentVersionNumber = 0;\r
+            int savedVersionNumber = sharedPref.getInt(KEY_VERSION, 0);\r
+            try {\r
+                PackageInfo pi          = getPackageManager().getPackageInfo(getPackageName(), 0);\r
+                currentVersionNumber    = pi.versionCode;\r
+            } catch (Exception e) {}\r
+     \r
+            if (currentVersionNumber > savedVersionNumber) {\r
+                ChangelogDialog.newInstance(true).show(getSupportFragmentManager(), DIALOG_CHANGELOG_TAG);\r
+                Editor editor   = sharedPref.edit();\r
+                editor.putInt(KEY_VERSION, currentVersionNumber);\r
+                editor.commit();\r
+            }\r
+        }\r
+    }\r
+    \r
+\r
+    /**\r
      * Launches the account creation activity. To use when no ownCloud account is available\r
      */\r
     private void createFirstAccount() {\r
diff --git a/src/com/owncloud/android/ui/dialog/ChangelogDialog.java b/src/com/owncloud/android/ui/dialog/ChangelogDialog.java
new file mode 100644 (file)
index 0000000..6330da7
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ *
+ */
+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;
+    }
+    */
+}
+
+