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 eu
.alefzero
.owncloud
.ui
.adapter
; 
  20 import android
.content
.Context
; 
  21 import android
.content
.Intent
; 
  22 import android
.view
.LayoutInflater
; 
  23 import android
.view
.View
; 
  24 import android
.view
.ViewGroup
; 
  25 import android
.widget
.BaseAdapter
; 
  26 import android
.widget
.ImageView
; 
  27 import android
.widget
.TextView
; 
  28 import eu
.alefzero
.owncloud
.R
; 
  29 import eu
.alefzero
.owncloud
.authenticator
.AuthUtils
; 
  30 import eu
.alefzero
.owncloud
.ui
.activity
.FileDisplayActivity
; 
  31 import eu
.alefzero
.owncloud
.ui
.activity
.Preferences
; 
  34  * Populates the landing screen icons. 
  35  * @author Lennart Rosam 
  38 public class LandingScreenAdapter 
extends BaseAdapter 
{ 
  40         private Context mContext
; 
  42         private final Integer
[] mLandingScreenIcons 
= { R
.drawable
.home
, 
  43                         R
.drawable
.music
, R
.drawable
.contacts
, 
  45                         android
.R
.drawable
.ic_menu_agenda
, 
  46                         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 parcableExtra. 
  74                          * We will put in the one that is selected in the preferences 
  76                         intent
.setClass(mContext
, FileDisplayActivity
.class);    
  77                         intent
.putExtra("ACCOUNT", AuthUtils
.getCurrentOwnCloudAccount(mContext
)); 
  80                         intent
.setClass(mContext
, Preferences
.class); 
  89         public long getItemId(int position
) { 
  94         public View 
getView(int position
, View convertView
, ViewGroup parent
) { 
  95                 if (convertView 
== null
) { 
  96                         LayoutInflater inflator 
= LayoutInflater
.from(mContext
); 
  97                         convertView 
= inflator
 
  98                                         .inflate(R
.layout
.landing_page_item
, null
); 
 100                         ImageView icon 
= (ImageView
) convertView
 
 101                                         .findViewById(R
.id
.gridImage
); 
 102                         TextView iconText 
= (TextView
) convertView
 
 103                                         .findViewById(R
.id
.gridText
); 
 105                         icon
.setImageResource(mLandingScreenIcons
[position
]); 
 106                         iconText
.setText(mLandingScreenTexts
[position
]);