1 /* ownCloud Android client application
2 * Copyright (C) 2011 Bartek Przybylski
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.
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.
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/>.
18 package com
.owncloud
.android
.ui
.adapter
;
20 import com
.owncloud
.android
.AccountUtils
;
21 import com
.owncloud
.android
.ui
.activity
.FileDisplayActivity
;
22 import com
.owncloud
.android
.ui
.activity
.Preferences
;
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
;
35 * Populates the landing screen icons.
37 * @author Lennart Rosam
40 public class LandingScreenAdapter
extends BaseAdapter
{
42 private Context mContext
;
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
};
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
};
53 public LandingScreenAdapter(Context context
) {
58 public int getCount() {
59 return mLandingScreenIcons
.length
;
64 * Returns the Intent associated with this object
65 * or null if the functionality is not yet implemented
67 public Object
getItem(int position
) {
68 Intent intent
= new Intent();
73 * The FileDisplayActivity requires the ownCloud account as an
74 * parcableExtra. We will put in the one that is selected in the
77 intent
.setClass(mContext
, FileDisplayActivity
.class);
78 intent
.putExtra("ACCOUNT",
79 AccountUtils
.getCurrentOwnCloudAccount(mContext
));
80 intent
.addFlags(Intent
.FLAG_ACTIVITY_NEW_TASK
);
83 intent
.setClass(mContext
, Preferences
.class);
92 public long getItemId(int position
) {
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
);
102 ImageView icon
= (ImageView
) convertView
103 .findViewById(R
.id
.gridImage
);
104 TextView iconText
= (TextView
) convertView
105 .findViewById(R
.id
.gridText
);
107 icon
.setImageResource(mLandingScreenIcons
[position
]);
108 iconText
.setText(mLandingScreenTexts
[position
]);