Quick patch to fix operations not ready for HTTPS
[pub/Android/ownCloud.git] / src / eu / alefzero / owncloud / ui / adapter / LandingScreenAdapter.java
index 694225d..7128886 100644 (file)
@@ -25,80 +25,87 @@ import android.view.ViewGroup;
 import android.widget.BaseAdapter;\r
 import android.widget.ImageView;\r
 import android.widget.TextView;\r
+import eu.alefzero.owncloud.AccountUtils;\r
 import eu.alefzero.owncloud.R;\r
 import eu.alefzero.owncloud.ui.activity.FileDisplayActivity;\r
 import eu.alefzero.owncloud.ui.activity.Preferences;\r
 \r
 /**\r
  * Populates the landing screen icons.\r
+ * \r
  * @author Lennart Rosam\r
- *\r
+ * \r
  */\r
 public class LandingScreenAdapter extends BaseAdapter {\r
-       \r
-       private Context mContext;\r
 \r
-       private final Integer[] mLandingScreenIcons = { R.drawable.home,\r
-                       R.drawable.music, R.drawable.contacts,\r
-                       R.drawable.calendar,\r
-                       android.R.drawable.ic_menu_agenda,\r
-                       R.drawable.settings };\r
+    private Context mContext;\r
+\r
+    private final Integer[] mLandingScreenIcons = { R.drawable.home,\r
+            R.drawable.music, R.drawable.contacts, R.drawable.calendar,\r
+            android.R.drawable.ic_menu_agenda, R.drawable.settings };\r
 \r
-       private final Integer[] mLandingScreenTexts = { R.string.main_files,\r
-                       R.string.main_music, R.string.main_contacts,\r
-                       R.string.main_calendar, R.string.main_bookmarks,\r
-                       R.string.main_settings };\r
+    private final Integer[] mLandingScreenTexts = { R.string.main_files,\r
+            R.string.main_music, R.string.main_contacts,\r
+            R.string.main_calendar, R.string.main_bookmarks,\r
+            R.string.main_settings };\r
 \r
-       public LandingScreenAdapter(Context context) {\r
-               mContext = context;\r
-       }\r
+    public LandingScreenAdapter(Context context) {\r
+        mContext = context;\r
+    }\r
 \r
-       @Override\r
-       public int getCount() {\r
-               return mLandingScreenIcons.length;\r
-       }\r
+    @Override\r
+    public int getCount() {\r
+        return mLandingScreenIcons.length;\r
+    }\r
 \r
-       @Override\r
-       /**\r
-        * Returns the Intent associated with this object\r
-        * or null if the functionality is not yet implemented\r
-        */\r
-       public Object getItem(int position) {\r
-               Intent intent = new Intent();\r
-               switch (position) {\r
-               case 0:\r
-                       intent.setClass(mContext, FileDisplayActivity.class);\r
-                       break;\r
-               case 5:\r
-                       intent.setClass(mContext, Preferences.class);\r
-                       break;\r
-               default:\r
-                       intent = null;\r
-               }\r
-               return intent;\r
-       }\r
+    @Override\r
+    /**\r
+     * Returns the Intent associated with this object\r
+     * or null if the functionality is not yet implemented\r
+     */\r
+    public Object getItem(int position) {\r
+        Intent intent = new Intent();\r
 \r
-       @Override\r
-       public long getItemId(int position) {\r
-               return position;\r
-       }\r
+        switch (position) {\r
+        case 0:\r
+            /*\r
+             * The FileDisplayActivity requires the ownCloud account as an\r
+             * parcableExtra. We will put in the one that is selected in the\r
+             * preferences\r
+             */\r
+            intent.setClass(mContext, FileDisplayActivity.class);\r
+            intent.putExtra("ACCOUNT",\r
+                    AccountUtils.getCurrentOwnCloudAccount(mContext));\r
+            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\r
+            break;\r
+        case 5:\r
+            intent.setClass(mContext, Preferences.class);\r
+            break;\r
+        default:\r
+            intent = null;\r
+        }\r
+        return intent;\r
+    }\r
 \r
-       @Override\r
-       public View getView(int position, View convertView, ViewGroup parent) {\r
-               if (convertView == null) {\r
-                       LayoutInflater inflator = LayoutInflater.from(mContext);\r
-                       convertView = inflator\r
-                                       .inflate(R.layout.landing_page_item, null);\r
+    @Override\r
+    public long getItemId(int position) {\r
+        return position;\r
+    }\r
 \r
-                       ImageView icon = (ImageView) convertView\r
-                                       .findViewById(R.id.gridImage);\r
-                       TextView iconText = (TextView) convertView\r
-                                       .findViewById(R.id.gridText);\r
+    @Override\r
+    public View getView(int position, View convertView, ViewGroup parent) {\r
+        if (convertView == null) {\r
+            LayoutInflater inflator = LayoutInflater.from(mContext);\r
+            convertView = inflator.inflate(R.layout.landing_page_item, null);\r
 \r
-                       icon.setImageResource(mLandingScreenIcons[position]);\r
-                       iconText.setText(mLandingScreenTexts[position]);\r
-               }\r
-               return convertView;\r
-       }\r
+            ImageView icon = (ImageView) convertView\r
+                    .findViewById(R.id.gridImage);\r
+            TextView iconText = (TextView) convertView\r
+                    .findViewById(R.id.gridText);\r
 \r
+            icon.setImageResource(mLandingScreenIcons[position]);\r
+            iconText.setText(mLandingScreenTexts[position]);\r
+        }\r
+        return convertView;\r
+    }\r
 }\r