Added dialog in the main app to advise users about the workaround app
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / activity / FileDisplayActivity.java
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