/
Configure.java
107 lines (97 loc) · 3.19 KB
/
Configure.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package com.kroah.clock;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.app.AlertDialog;
import android.appwidget.AppWidgetManager;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
public class Configure extends Activity {
public static final String MODULE = "GREGKHConfigureScreen";
public static int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
private Button okButton;
// Display a simple "About" dialog
final void about() {
AlertDialog.Builder ad = new AlertDialog.Builder(Configure.this);
ad.setTitle(getString(R.string.about_title));
ad.setMessage(getString(R.string.about));
ad.setPositiveButton(getString(R.string.ok),
new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// nothing
}
});
ad.setCancelable(true);
ad.setOnCancelListener(new OnCancelListener() {
public void onCancel(DialogInterface Dialog) {
// nothing
}
});
ad.show();
}
static final private int MENU_SETTINGS = 1;
static final private int MENU_ABOUT = 2;
static final private int MENU_EXIT = 3;
/* Creates the menu items */
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, MENU_SETTINGS, 0, "Settings").setIcon(R.drawable.menu_preferences);
menu.add(0, MENU_ABOUT, 0, "About").setIcon(R.drawable.menu_about);
menu.add(0, MENU_EXIT, 0, "Exit").setIcon(R.drawable.menu_close);
return true;
}
/* Handles item selections */
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_SETTINGS:
//settings();
return true;
case MENU_ABOUT:
about();
return true;
case MENU_EXIT:
Intent result = new Intent();
result.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
setResult(RESULT_OK, result);
finish();
return true;
}
return false;
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
Log.d(MODULE, "onCreate:enter");
super.onCreate(savedInstanceState);
setContentView(R.layout.config);
// Find the widget id from the intent.
Intent intent = getIntent();
Bundle extras = intent.getExtras();
if (extras != null) {
Log.d(MODULE, "onCreate:extras != null");
mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
}
// If they gave us an intent without the widget id, get out
if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
Log.d(MODULE, "onCreatea:mAppWidgetId == INVALID");
finish();
}
okButton = (Button)findViewById(R.id.myButton);
okButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Log.d(MODULE, "ok button clicked");
Intent result = new Intent();
result.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
setResult(RESULT_OK, result);
Log.d(MODULE, "ok button finishing");
finish();
}
});
Log.d(MODULE, "onCreate:exit");
}
}