• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.fontlab;
18 
19 import java.util.ArrayList;
20 import java.util.List;
21 
22 import android.app.ListActivity;
23 import android.content.Intent;
24 import android.os.Bundle;
25 import android.view.View;
26 import android.widget.ListView;
27 import android.widget.SimpleAdapter;
28 
29 
30 public abstract class BackgroundPicker extends ListActivity
31 {
32 
onCreate(Bundle icicle)33     public void onCreate(Bundle icicle)
34     {
35         super.onCreate(icicle);
36 
37         setListAdapter(new SimpleAdapter(this,
38                 getData(),
39                 android.R.layout.simple_list_item_1,
40                 new String[] {"title"},
41                 new int[] {android.R.id.text1}));
42     }
43 
getData()44     protected List getData()
45     {
46         List myData = new ArrayList<Bundle>();
47         addItem(myData, "Solid White", 0, 0xFFFFFFFF, 0xFF000000);
48         addItem(myData, "Solid Light Gray", 0, 0xFFBFBFBF, 0xFF000000);
49         addItem(myData, "Solid Dark Gray", 0, 0xFF404040, 0xFFFFFFFF);
50         addItem(myData, "Solid Black", 0, 0xFF000000, 0xFFFFFFFF);
51         addItem(myData, "Solid Blue", 0, 0xFF1a387a, 0xFFFFFFFF);
52         addItem(myData, "Textured White", 0, 0, 0xFF000000);
53         // addItem(myData, "Textured Blue", android.R.drawable.screen_background_blue, 0, 0xFFFFFFFF);
54 
55         return myData;
56     }
57 
addItem(List<Bundle> data, String name, int textureRes, int bgColor, int textColor)58     protected void addItem(List<Bundle> data, String name, int textureRes, int bgColor, int textColor)
59     {
60         Bundle temp = new Bundle();
61         temp.putString("title", name);
62         if (textureRes != 0) {
63             temp.putInt("texture", textureRes);
64         }
65         temp.putInt("bgcolor", bgColor);
66         temp.putInt("text", textColor);
67         data.add(temp);
68     }
69 
onListItemClick(ListView l, View v, int position, long id)70     protected void onListItemClick(ListView l, View v, int position, long id)
71     {
72         Bundle map = (Bundle) l.getItemAtPosition(position);
73         setResult(RESULT_OK, (new Intent()).putExtras(map));
74         finish();
75     }
76 
77 }
78