1 /* ownCloud Android client application
2 * Copyright (C) 2011 Bartek Przybylski
3 * Copyright (C) 2012-2013 ownCloud Inc.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 package com
.owncloud
.android
.ui
.adapter
;
21 import com
.owncloud
.android
.AccountUtils
;
22 import com
.owncloud
.android
.ui
.activity
.FileDisplayActivity
;
23 import com
.owncloud
.android
.ui
.activity
.Preferences
;
25 import android
.content
.Context
;
26 import android
.content
.Intent
;
27 import android
.view
.LayoutInflater
;
28 import android
.view
.View
;
29 import android
.view
.ViewGroup
;
30 import android
.widget
.BaseAdapter
;
31 import android
.widget
.ImageView
;
32 import android
.widget
.TextView
;
33 import com
.owncloud
.android
.R
;
36 * Populates the landing screen icons.
38 * @author Lennart Rosam
41 public class LandingScreenAdapter
extends BaseAdapter
{
43 private Context mContext
;
45 private final Integer
[] mLandingScreenIcons
= { R
.drawable
.home
,
46 R
.drawable
.music
, R
.drawable
.contacts
, R
.drawable
.calendar
,
47 android
.R
.drawable
.ic_menu_agenda
, R
.drawable
.settings
};
49 private final Integer
[] mLandingScreenTexts
= { R
.string
.main_files
,
50 R
.string
.main_music
, R
.string
.main_contacts
,
51 R
.string
.main_calendar
, R
.string
.main_bookmarks
,
52 R
.string
.main_settings
};
54 public LandingScreenAdapter(Context context
) {
59 public int getCount() {
60 return mLandingScreenIcons
.length
;
65 * Returns the Intent associated with this object
66 * or null if the functionality is not yet implemented
68 public Object
getItem(int position
) {
69 Intent intent
= new Intent();
74 * The FileDisplayActivity requires the ownCloud account as an
75 * parcableExtra. We will put in the one that is selected in the
78 intent
.setClass(mContext
, FileDisplayActivity
.class);
79 intent
.putExtra("ACCOUNT",
80 AccountUtils
.getCurrentOwnCloudAccount(mContext
));
81 intent
.addFlags(Intent
.FLAG_ACTIVITY_NEW_TASK
);
84 intent
.setClass(mContext
, Preferences
.class);
93 public long getItemId(int position
) {
98 public View
getView(int position
, View convertView
, ViewGroup parent
) {
99 if (convertView
== null
) {
100 LayoutInflater inflator
= LayoutInflater
.from(mContext
);
101 convertView
= inflator
.inflate(R
.layout
.landing_page_item
, null
);
103 ImageView icon
= (ImageView
) convertView
104 .findViewById(R
.id
.gridImage
);
105 TextView iconText
= (TextView
) convertView
106 .findViewById(R
.id
.gridText
);
108 icon
.setImageResource(mLandingScreenIcons
[position
]);
109 iconText
.setText(mLandingScreenTexts
[position
]);