1 package com
.owncloud
.android
.ui
.activity
; 
   3 import java
.util
.ArrayList
; 
   5 import android
.content
.Context
; 
   6 import android
.content
.Intent
; 
   7 import android
.os
.Bundle
; 
   8 import android
.text
.method
.ScrollingMovementMethod
; 
   9 import android
.view
.View
; 
  10 import android
.view
.ViewGroup
; 
  11 import android
.widget
.ArrayAdapter
; 
  12 import android
.widget
.ListAdapter
; 
  13 import android
.widget
.ListView
; 
  14 import android
.widget
.TextView
; 
  16 import com
.actionbarsherlock
.app
.SherlockFragmentActivity
; 
  17 import com
.owncloud
.android
.R
; 
  20  * Activity showing a text message and, optionally, a couple list of single or paired text strings. 
  22  * Added to show explanations for notifications when the user clicks on them, and there no place 
  23  * better to show them. 
  25  * @author David A. Velasco 
  27 public class GenericExplanationActivity  
extends SherlockFragmentActivity 
{ 
  29     public static final String EXTRA_LIST 
= GenericExplanationActivity
.class.getCanonicalName() + ".EXTRA_LIST"; 
  30     public static final String EXTRA_LIST_2 
= GenericExplanationActivity
.class.getCanonicalName() + ".EXTRA_LIST_2"; 
  31     public static final String MESSAGE 
= GenericExplanationActivity
.class.getCanonicalName() + ".MESSAGE"; 
  35     protected void onCreate(Bundle savedInstanceState
) { 
  36         super.onCreate(savedInstanceState
); 
  38         Intent intent 
= getIntent(); 
  39         String message 
= intent
.getStringExtra(MESSAGE
);  
  40         ArrayList
<String
> list 
= intent
.getStringArrayListExtra(EXTRA_LIST
); 
  41         ArrayList
<String
> list2 
= intent
.getStringArrayListExtra(EXTRA_LIST_2
); 
  43         setContentView(R
.layout
.generic_explanation
); 
  45         if (message 
!= null
) { 
  46             TextView textView 
= (TextView
) findViewById(R
.id
.message
); 
  47             textView
.setText(message
); 
  48             textView
.setMovementMethod(new ScrollingMovementMethod()); 
  51         ListView listView 
= (ListView
) findViewById(R
.id
.list
); 
  52         if (list 
!= null 
&& list
.size() > 0) { 
  53             //ListAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list); 
  54             ListAdapter adapter 
= new ExplanationListAdapterView(this, list
, list2
); 
  55             listView
.setAdapter(adapter
); 
  57             listView
.setVisibility(View
.GONE
); 
  61     public class ExplanationListAdapterView 
extends ArrayAdapter
<String
> { 
  63         ArrayList
<String
> mList
; 
  64         ArrayList
<String
> mList2
; 
  66         ExplanationListAdapterView(Context context
, ArrayList
<String
> list
, ArrayList
<String
> list2
) { 
  67             super(context
, android
.R
.layout
.two_line_list_item
, android
.R
.id
.text1
, list
); 
  73         public boolean isEnabled(int position
) { 
  81         public View 
getView (int position
, View convertView
, ViewGroup parent
) { 
  82             View view 
= super.getView(position
, convertView
, parent
); 
  84                 if (mList2 
!= null 
&& mList2
.size() > 0 && position 
>= 0 && position 
< mList2
.size()) { 
  85                     TextView text2 
= (TextView
) view
.findViewById(android
.R
.id
.text2
); 
  87                         text2
.setText(mList2
.get(position
));