Initial commit.
[wl-mobile.git] / src / pl / org / nowoczesnapolska / CatalogueBook.java
1 package pl.org.nowoczesnapolska;
2
3 import android.app.Activity;
4 import android.content.Context;
5 import android.content.Intent;
6 import android.os.Bundle;
7 import android.view.Menu;
8 import android.view.MenuItem;
9 import android.view.View;
10 import android.view.View.OnClickListener;
11 import android.widget.Button;
12
13 public class CatalogueBook extends Activity {
14         static final private int MENU_SHARE = Menu.FIRST;
15         static final private int MENU_SHELF = Menu.FIRST+1;
16         static final private int MENU_SIGNIN = Menu.FIRST+2;
17         static final private int MENU_SETTINGS = Menu.FIRST+3;  
18         static final private int MENU_ABOUT = Menu.FIRST+4;
19         
20         Context ctx;
21         
22     @Override
23     public void onCreate(Bundle savedInstanceState) {
24         super.onCreate(savedInstanceState);
25         setContentView(R.layout.catalogue_book);
26         ctx = this;
27         Button read_online = (Button) findViewById(R.id.read_online);
28         
29         read_online.setOnClickListener(new OnClickListener() {
30                         
31                         public void onClick(View v) {
32                                 // TODO Auto-generated method stub
33                                 startActivity(new Intent(ctx, CatalogueReadOnline.class));
34                         }
35                 });    
36     }
37
38     @Override
39     public boolean onCreateOptionsMenu(Menu menu) {
40         super.onCreateOptionsMenu(menu);
41
42         int groupId;
43         int menuItemId;
44         int menuItemOrder;
45         int menuItemText;
46
47         // share
48         groupId = 1;
49         menuItemId = MENU_SHARE;
50         menuItemOrder = Menu.NONE;
51         menuItemText = R.string.menu_share;     
52         
53         menu.add(groupId, menuItemId,
54                         menuItemOrder, menuItemText);
55
56         // shelf
57         groupId = 1;
58         menuItemId = MENU_SHELF;
59         menuItemOrder = Menu.NONE;
60         menuItemText = R.string.menu_shelf;     
61         
62         menu.add(groupId, menuItemId,
63                         menuItemOrder, menuItemText);           
64         
65         
66         // sign in
67         groupId = 0;
68         menuItemId = MENU_SIGNIN;
69         menuItemOrder = Menu.NONE;
70         menuItemText = R.string.menu_signin;            
71         
72         menu.add(groupId, menuItemId,
73                         menuItemOrder, menuItemText);
74         
75         // settings
76         groupId = 0;
77         menuItemId = MENU_SETTINGS;
78         menuItemOrder = Menu.NONE;
79         menuItemText = R.string.menu_settings;          
80         
81         menu.add(groupId, menuItemId,
82                         menuItemOrder, menuItemText);           
83         
84         // about
85         groupId = 0;
86         menuItemId = MENU_ABOUT;
87         menuItemOrder = Menu.NONE;
88         menuItemText = R.string.menu_about;
89         
90         menu.add(groupId, menuItemId,
91                         menuItemOrder, menuItemText);
92                 
93         
94         
95         return true;
96     }    
97
98     public boolean onOptionsItemSelected(MenuItem item) {
99         
100         super.onOptionsItemSelected(item);
101         switch (item.getItemId()) {
102                 case (MENU_SHARE):
103                                 Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
104                                 shareIntent.setType("text/plain");
105                                 shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Wolne Lektury: Autor");
106                                 shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Miron Miron");                         
107                                 startActivity(Intent.createChooser(shareIntent, "Share this author"));  
108                         return true;
109                 case (MENU_SHELF):                              
110                                 startActivity(new Intent(ctx, Shelves.class));  
111                         return true;                            
112                 case (MENU_SIGNIN):
113                         startActivity(new Intent(ctx, SignIn.class));
114                         return true;
115                 case (MENU_SETTINGS):
116                         startActivity(new Intent(ctx, Settings.class));
117                         return true;
118                 case (MENU_ABOUT):
119                         startActivity(new Intent(ctx, About.class));
120                         return true;                    
121         }                       
122
123         return false;           
124     }    
125     
126         
127 }