<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<application android:icon="@drawable/icon" android:label="@string/app_name">
- <activity android:name=".ui.FileDisplayActivity"
- android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
+ <activity android:name=".ui.FileDisplayActivity"></activity>
<activity android:name=".Uploader">
<intent-filter>
<action android:name="android.intent.action.SEND"></action>
<service android:name=".FileDownloader">
</service>
<activity android:name=".ui.FileDetailActivity"></activity>
+ <activity android:name=".ui.LandingActivity"
+ android:theme="@android:style/Theme.NoTitleBar"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
</application>
</manifest>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="fill_parent"\r
+ android:background="#F7F7F7"\r
+ android:orientation="vertical" >
+\r
+ <fragment\r
+ android:id="@+id/actionBar"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="wrap_content"\r
+ class="eu.alefzero.owncloud.ui.fragment.ActionBar" >
+ <!-- Preview: layout=@layout/action_bar -->
+ </fragment>\r
+ \r
+ <fragment\r
+ android:id="@+id/landingPage"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="wrap_content"\r
+ class="eu.alefzero.owncloud.ui.fragment.LandingPageFragment" >\r
+ <!-- Preview: layout=@layout/landing_page_fragment -->\r
+ </fragment>\r
+\r
+ \r
+\r
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+ android:id="@+id/linearLayout1"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="wrap_content"\r
+ android:orientation="vertical" >\r
+\r
+ <ImageView\r
+ android:id="@+id/ocLogo"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_gravity="center_horizontal"\r
+ android:paddingTop="10dip"\r
+ android:src="@drawable/owncloud_logo" />\r
+\r
+ <TextView\r
+ android:id="@+id/textView0"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_gravity="center_horizontal"\r
+ android:layout_marginBottom="15dip"\r
+ android:layout_marginTop="15dip"\r
+ android:text="@string/main_welcome"\r
+ android:textColor="@android:color/black"\r
+ android:textSize="7pt"\r
+ android:textStyle="bold" />\r
+\r
+ <GridView\r
+ android:id="@+id/gridview"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="fill_parent"\r
+ android:layout_gravity="center_horizontal"\r
+ android:columnWidth="90dp"\r
+ android:gravity="center"\r
+ android:horizontalSpacing="10dp"\r
+ android:numColumns="2"\r
+ android:stretchMode="columnWidth"\r
+ android:verticalSpacing="10dp" >\r
+ </GridView>\r
+\r
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+ android:background="#F7F7F7"\r
+ android:layout_width="fill_parent"\r
+ android:layout_height="fill_parent" >\r
+\r
+ <ImageView\r
+ android:id="@+id/gridImage"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_alignParentTop="true"\r
+ android:layout_centerHorizontal="true"\r
+ android:src="@drawable/action_item_btn" />
+\r\r\r
+ <TextView\r
+ android:id="@+id/gridText"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_below="@+id/gridImage"\r
+ android:layout_centerHorizontal="true"\r
+ android:text="Medium Text"\r
+ android:textAppearance="?android:attr/textAppearanceMedium"\r
+ android:textColor="@color/setup_text_hint" />\r
+\r
+</RelativeLayout>
\ No newline at end of file
--- /dev/null
+/* ownCloud Android client application\r
+ * Copyright (C) 2012 Lennart Rosam\r
+ *\r
+ * This program is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+ *\r
+ */\r
+package eu.alefzero.owncloud.ui;\r
+\r
+import android.os.Bundle;\r
+import android.support.v4.app.FragmentActivity;\r
+import eu.alefzero.owncloud.R;\r
+\r
+/**\r
+ * This activity is used as a landing page when the user first opens this app.\r
+ * \r
+ * @author Lennart Rosam\r
+ */\r
+public class LandingActivity extends FragmentActivity {\r
+\r
+ @Override\r
+ protected void onCreate(Bundle savedInstanceState) {\r
+ super.onCreate(savedInstanceState);\r
+ setContentView(R.layout.landing_page);\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+package eu.alefzero.owncloud.ui.fragment;\r
+\r
+import android.accounts.Account;\r
+import android.accounts.AccountManager;\r
+import android.content.Context;\r
+import android.content.Intent;\r
+import android.os.Bundle;\r
+import android.support.v4.app.Fragment;\r
+import android.util.Log;\r
+import android.view.LayoutInflater;\r
+import android.view.View;\r
+import android.view.ViewGroup;\r
+import android.widget.AdapterView;\r
+import android.widget.AdapterView.OnItemClickListener;\r
+import android.widget.BaseAdapter;\r
+import android.widget.GridView;\r
+import android.widget.ImageView;\r
+import android.widget.TextView;\r
+import android.widget.Toast;\r
+import eu.alefzero.owncloud.R;\r
+import eu.alefzero.owncloud.authenticator.AccountAuthenticator;\r
+import eu.alefzero.owncloud.ui.FileDisplayActivity;\r
+import eu.alefzero.owncloud.ui.Preferences;\r
+\r
+public class LandingPageFragment extends Fragment implements OnItemClickListener {\r
+\r
+ @Override\r
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,\r
+ Bundle savedInstanceState) {\r
+ View root = inflater.inflate(R.layout.landing_page_fragment, container);\r
+ return root;\r
+ }\r
+\r
+\r
+ @Override\r
+ public void onActivityCreated(Bundle savedInstanceState) {\r
+ super.onActivityCreated(savedInstanceState);\r
+ GridView grid = (GridView) getView().findViewById(R.id.gridview);\r
+ grid.setAdapter(new LandingScreenAdapter(getActivity()));\r
+ grid.setOnItemClickListener(this);\r
+ }\r
+ \r
+ @Override\r
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {\r
+ Intent intent;\r
+ \r
+ /**\r
+ * If the user selects something and acounts are setup,\r
+ * we can use our LandingScreenAdapter to get the matching\r
+ * intent for the selected item.\r
+ * \r
+ * Otherwise, the accounsAreSetuo() method will trigger the \r
+ * creation of one.\r
+ */\r
+ if(accountsAreSetup()){\r
+ intent = (Intent) parent.getAdapter().getItem(position);\r
+ if(intent != null ){\r
+ startActivity(intent);\r
+ } else {\r
+ Toast toast = Toast.makeText(getActivity(), "Not yet implemented!", Toast.LENGTH_SHORT);\r
+ toast.show();\r
+ }\r
+ \r
+ } \r
+ }\r
+\r
+ /**\r
+ * Checks, whether or not there are any ownCloud accounts \r
+ * setup. If there is none, it will create one.\r
+ * \r
+ * If there are more then one, it will trigger a selection\r
+ * unless the selection has not been made yet.\r
+ * \r
+ * @return true, if there is at least one account.\r
+ */\r
+ private boolean accountsAreSetup() {\r
+ AccountManager accMan = AccountManager.get(getActivity());\r
+ Account[] accounts = accMan\r
+ .getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);\r
+\r
+ if (accounts.length == 0) {\r
+ Intent intent = new Intent("android.settings.ADD_ACCOUNT_SETTINGS");\r
+ intent.putExtra("authorities",\r
+ new String[] { AccountAuthenticator.AUTH_TOKEN_TYPE });\r
+ startActivity(intent);\r
+ return false;\r
+ } else if (accounts.length > 1) {\r
+ // TODO: Figure out what to do.\r
+ } \r
+\r
+ return true;\r
+ }\r
+\r
+ /**\r
+ * Used to populate the landing page grid.\r
+ * Defined this one right in here as private class\r
+ * as it is unlikely that this Adapter can be useful\r
+ * anywhere else.\r
+ * \r
+ * @author Lennart Rosam\r
+ *\r
+ */\r
+ private 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
+ android.R.drawable.ic_menu_today,\r
+ android.R.drawable.ic_menu_agenda,\r
+ android.R.drawable.ic_menu_preferences };\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
+\r
+ public LandingScreenAdapter(Context context) {\r
+ mContext = context;\r
+ }\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
+\r
+ @Override\r
+ public long getItemId(int position) {\r
+ return position;\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
+\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
+ }\r
+}\r