1 /* ownCloud Android client application 
   2  *   Copyright (C) 2012-2013 ownCloud Inc. 
   4  *   This program is free software: you can redistribute it and/or modify 
   5  *   it under the terms of the GNU General Public License version 2, 
   6  *   as published by the Free Software Foundation. 
   8  *   This program is distributed in the hope that it will be useful, 
   9  *   but WITHOUT ANY WARRANTY; without even the implied warranty of 
  10  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  11  *   GNU General Public License for more details. 
  13  *   You should have received a copy of the GNU General Public License 
  14  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. 
  18 package com
.owncloud
.android
.ui
.activity
; 
  20 import java
.util
.ArrayList
; 
  22 import android
.content
.Context
; 
  23 import android
.content
.Intent
; 
  24 import android
.os
.Bundle
; 
  25 import android
.text
.method
.ScrollingMovementMethod
; 
  26 import android
.view
.View
; 
  27 import android
.view
.ViewGroup
; 
  28 import android
.widget
.ArrayAdapter
; 
  29 import android
.widget
.ListAdapter
; 
  30 import android
.widget
.ListView
; 
  31 import android
.widget
.TextView
; 
  33 import com
.actionbarsherlock
.app
.ActionBar
; 
  34 import com
.actionbarsherlock
.app
.SherlockFragmentActivity
; 
  35 import com
.owncloud
.android
.R
; 
  36 import com
.owncloud
.android
.utils
.DisplayUtils
; 
  40  * Activity showing a text message and, optionally, a couple list of single or paired text strings. 
  42  * Added to show explanations for notifications when the user clicks on them, and there no place 
  43  * better to show them. 
  45  * @author David A. Velasco 
  47 public class GenericExplanationActivity  
extends SherlockFragmentActivity 
{ 
  49     public static final String EXTRA_LIST 
= GenericExplanationActivity
.class.getCanonicalName() + ".EXTRA_LIST"; 
  50     public static final String EXTRA_LIST_2 
= GenericExplanationActivity
.class.getCanonicalName() + ".EXTRA_LIST_2"; 
  51     public static final String MESSAGE 
= GenericExplanationActivity
.class.getCanonicalName() + ".MESSAGE"; 
  55     protected void onCreate(Bundle savedInstanceState
) { 
  56         super.onCreate(savedInstanceState
); 
  58         Intent intent 
= getIntent(); 
  59         String message 
= intent
.getStringExtra(MESSAGE
);  
  60         ArrayList
<String
> list 
= intent
.getStringArrayListExtra(EXTRA_LIST
); 
  61         ArrayList
<String
> list2 
= intent
.getStringArrayListExtra(EXTRA_LIST_2
); 
  63         setContentView(R
.layout
.generic_explanation
); 
  65         if (message 
!= null
) { 
  66             TextView textView 
= (TextView
) findViewById(R
.id
.message
); 
  67             textView
.setText(message
); 
  68             textView
.setMovementMethod(new ScrollingMovementMethod()); 
  71         ListView listView 
= (ListView
) findViewById(R
.id
.list
); 
  72         if (list 
!= null 
&& list
.size() > 0) { 
  73             //ListAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list); 
  74             ListAdapter adapter 
= new ExplanationListAdapterView(this, list
, list2
); 
  75             listView
.setAdapter(adapter
); 
  77             listView
.setVisibility(View
.GONE
); 
  80         ActionBar actionBar 
= getSupportActionBar(); 
  81         actionBar
.setIcon(DisplayUtils
.getSeasonalIconId()); 
  84     public class ExplanationListAdapterView 
extends ArrayAdapter
<String
> { 
  86         ArrayList
<String
> mList
; 
  87         ArrayList
<String
> mList2
; 
  89         ExplanationListAdapterView(Context context
, ArrayList
<String
> list
, ArrayList
<String
> list2
) { 
  90             super(context
, android
.R
.layout
.two_line_list_item
, android
.R
.id
.text1
, list
); 
  96         public boolean isEnabled(int position
) { 
 104         public View 
getView (int position
, View convertView
, ViewGroup parent
) { 
 105             View view 
= super.getView(position
, convertView
, parent
); 
 107                 if (mList2 
!= null 
&& mList2
.size() > 0 && position 
>= 0 && position 
< mList2
.size()) { 
 108                     TextView text2 
= (TextView
) view
.findViewById(android
.R
.id
.text2
); 
 110                         text2
.setText(mList2
.get(position
));