Workaround to show hidden accents in options menu
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / adapter / LandingScreenAdapter.java
1 /* ownCloud Android client application
2 * Copyright (C) 2011 Bartek Przybylski
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 */
18 package com.owncloud.android.ui.adapter;
19
20 import com.owncloud.android.AccountUtils;
21 import com.owncloud.android.ui.activity.FileDisplayActivity;
22 import com.owncloud.android.ui.activity.Preferences;
23
24 import android.content.Context;
25 import android.content.Intent;
26 import android.view.LayoutInflater;
27 import android.view.View;
28 import android.view.ViewGroup;
29 import android.widget.BaseAdapter;
30 import android.widget.ImageView;
31 import android.widget.TextView;
32 import com.owncloud.android.R;
33
34 /**
35 * Populates the landing screen icons.
36 *
37 * @author Lennart Rosam
38 *
39 */
40 public class LandingScreenAdapter extends BaseAdapter {
41
42 private Context mContext;
43
44 private final Integer[] mLandingScreenIcons = { R.drawable.home,
45 R.drawable.music, R.drawable.contacts, R.drawable.calendar,
46 android.R.drawable.ic_menu_agenda, R.drawable.settings };
47
48 private final Integer[] mLandingScreenTexts = { R.string.main_files,
49 R.string.main_music, R.string.main_contacts,
50 R.string.main_calendar, R.string.main_bookmarks,
51 R.string.main_settings };
52
53 public LandingScreenAdapter(Context context) {
54 mContext = context;
55 }
56
57 @Override
58 public int getCount() {
59 return mLandingScreenIcons.length;
60 }
61
62 @Override
63 /**
64 * Returns the Intent associated with this object
65 * or null if the functionality is not yet implemented
66 */
67 public Object getItem(int position) {
68 Intent intent = new Intent();
69
70 switch (position) {
71 case 0:
72 /*
73 * The FileDisplayActivity requires the ownCloud account as an
74 * parcableExtra. We will put in the one that is selected in the
75 * preferences
76 */
77 intent.setClass(mContext, FileDisplayActivity.class);
78 intent.putExtra("ACCOUNT",
79 AccountUtils.getCurrentOwnCloudAccount(mContext));
80 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
81 break;
82 case 5:
83 intent.setClass(mContext, Preferences.class);
84 break;
85 default:
86 intent = null;
87 }
88 return intent;
89 }
90
91 @Override
92 public long getItemId(int position) {
93 return position;
94 }
95
96 @Override
97 public View getView(int position, View convertView, ViewGroup parent) {
98 if (convertView == null) {
99 LayoutInflater inflator = LayoutInflater.from(mContext);
100 convertView = inflator.inflate(R.layout.landing_page_item, null);
101
102 ImageView icon = (ImageView) convertView
103 .findViewById(R.id.gridImage);
104 TextView iconText = (TextView) convertView
105 .findViewById(R.id.gridText);
106
107 icon.setImageResource(mLandingScreenIcons[position]);
108 iconText.setText(mLandingScreenTexts[position]);
109 }
110 return convertView;
111 }
112 }