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 as published by
6 * the Free Software Foundation, either version 2 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/>.
19 package com
.owncloud
.android
.ui
.activity
;
21 import java
.util
.ArrayList
;
23 import android
.content
.Context
;
24 import android
.content
.Intent
;
25 import android
.os
.Bundle
;
26 import android
.text
.method
.ScrollingMovementMethod
;
27 import android
.view
.View
;
28 import android
.view
.ViewGroup
;
29 import android
.widget
.ArrayAdapter
;
30 import android
.widget
.ListAdapter
;
31 import android
.widget
.ListView
;
32 import android
.widget
.TextView
;
34 import com
.actionbarsherlock
.app
.SherlockFragmentActivity
;
35 import com
.owncloud
.android
.R
;
38 * Activity showing a text message and, optionally, a couple list of single or paired text strings.
40 * Added to show explanations for notifications when the user clicks on them, and there no place
41 * better to show them.
43 * @author David A. Velasco
45 public class GenericExplanationActivity
extends SherlockFragmentActivity
{
47 public static final String EXTRA_LIST
= GenericExplanationActivity
.class.getCanonicalName() + ".EXTRA_LIST";
48 public static final String EXTRA_LIST_2
= GenericExplanationActivity
.class.getCanonicalName() + ".EXTRA_LIST_2";
49 public static final String MESSAGE
= GenericExplanationActivity
.class.getCanonicalName() + ".MESSAGE";
53 protected void onCreate(Bundle savedInstanceState
) {
54 super.onCreate(savedInstanceState
);
56 Intent intent
= getIntent();
57 String message
= intent
.getStringExtra(MESSAGE
);
58 ArrayList
<String
> list
= intent
.getStringArrayListExtra(EXTRA_LIST
);
59 ArrayList
<String
> list2
= intent
.getStringArrayListExtra(EXTRA_LIST_2
);
61 setContentView(R
.layout
.generic_explanation
);
63 if (message
!= null
) {
64 TextView textView
= (TextView
) findViewById(R
.id
.message
);
65 textView
.setText(message
);
66 textView
.setMovementMethod(new ScrollingMovementMethod());
69 ListView listView
= (ListView
) findViewById(R
.id
.list
);
70 if (list
!= null
&& list
.size() > 0) {
71 //ListAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
72 ListAdapter adapter
= new ExplanationListAdapterView(this, list
, list2
);
73 listView
.setAdapter(adapter
);
75 listView
.setVisibility(View
.GONE
);
79 public class ExplanationListAdapterView
extends ArrayAdapter
<String
> {
81 ArrayList
<String
> mList
;
82 ArrayList
<String
> mList2
;
84 ExplanationListAdapterView(Context context
, ArrayList
<String
> list
, ArrayList
<String
> list2
) {
85 super(context
, android
.R
.layout
.two_line_list_item
, android
.R
.id
.text1
, list
);
91 public boolean isEnabled(int position
) {
99 public View
getView (int position
, View convertView
, ViewGroup parent
) {
100 View view
= super.getView(position
, convertView
, parent
);
102 if (mList2
!= null
&& mList2
.size() > 0 && position
>= 0 && position
< mList2
.size()) {
103 TextView text2
= (TextView
) view
.findViewById(android
.R
.id
.text2
);
105 text2
.setText(mList2
.get(position
));