/[projects]/android/Side9/src/dk/thoerup/side9/Side9Config.java
ViewVC logotype

Contents of /android/Side9/src/dk/thoerup/side9/Side9Config.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1217 - (show annotations) (download)
Mon Jan 24 22:21:23 2011 UTC (13 years, 3 months ago) by torben
File size: 3423 byte(s)
- Added flip animation of pictures in Picture View
- Marked OVerview activity as a launcher act. so it can be found in the phone's app launcher 
- Default values for "Show caption" and "save to sd" is now true.
- Bump version to 21
1 package dk.thoerup.side9;
2
3 import android.app.Activity;
4 import android.appwidget.AppWidgetManager;
5 import android.content.Context;
6 import android.content.Intent;
7 import android.content.SharedPreferences;
8 import android.content.SharedPreferences.Editor;
9 import android.os.Bundle;
10 import android.view.View;
11 import android.view.View.OnClickListener;
12 import android.widget.ArrayAdapter;
13 import android.widget.Button;
14 import android.widget.CheckBox;
15 import android.widget.Spinner;
16
17
18 public class Side9Config extends Activity {
19 int mAppWidgetId;
20
21 public final static String PREFS_SAVEIMAGE = "saveimage";
22 public final static String PREFS_SHOWCAPTION = "showcaption";
23 public final static String PREFS_ONTOUCH = "ontouch";
24
25
26
27 @Override
28 public void onCreate(Bundle savedInstanceState) {
29 super.onCreate(savedInstanceState);
30 setContentView(R.layout.config);
31
32 Intent intent = getIntent();
33 Bundle extras = intent.getExtras();
34 if (extras != null) {
35 mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
36 }
37
38 ////////////////////////////////////////////////////////////
39
40
41
42 SharedPreferences prefs = getSharedPreferences(Side9WidgetProvider.TAG, Context.MODE_PRIVATE);
43
44 Button okBtn = (Button) findViewById(R.id.ok);
45 okBtn.setOnClickListener( okListener );
46
47 CheckBox savetosd = (CheckBox) findViewById(R.id.savetosd);
48 boolean save = prefs.getBoolean(PREFS_SAVEIMAGE, true);
49 savetosd.setChecked(save);
50
51 CheckBox showcaption = (CheckBox) findViewById(R.id.showcaption);
52 boolean show = prefs.getBoolean(PREFS_SHOWCAPTION, true);
53 showcaption.setChecked(show);
54
55
56 Spinner ontouch = (Spinner) findViewById(R.id.ontouch);
57 ArrayAdapter<?> adapter = ArrayAdapter.createFromResource(this, R.array.ontouchtargets, android.R.layout.simple_spinner_item);
58 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
59
60 ontouch.setAdapter(adapter);
61
62 int ontouchsel = prefs.getInt(PREFS_ONTOUCH, 0);
63 ontouch.setSelection(ontouchsel);
64
65 }
66
67 private void updateWidget() {
68 AppWidgetManager mgr = AppWidgetManager.getInstance(Side9Config.this);
69
70 Side9WidgetProvider prov = new Side9WidgetProvider();
71 int widgets[] = new int[] { mAppWidgetId };
72
73 prov.resetStatics(); //force reload
74 prov.onUpdate(this, mgr, widgets );
75
76 }
77
78
79 OnClickListener okListener = new OnClickListener() {
80 @Override
81 public void onClick(View v) {
82
83 CheckBox savetosd = (CheckBox) findViewById(R.id.savetosd);
84 boolean save = savetosd.isChecked();
85
86 CheckBox showcaption = (CheckBox) findViewById(R.id.showcaption);
87 boolean show = showcaption.isChecked();
88
89 Spinner ontouch = (Spinner) findViewById(R.id.ontouch);
90 int ontouchsel = ontouch.getSelectedItemPosition();
91
92 SharedPreferences prefs = getSharedPreferences(Side9WidgetProvider.TAG, Context.MODE_PRIVATE);
93
94 Editor edit = prefs.edit();
95 edit.putBoolean(PREFS_SAVEIMAGE, save);
96 edit.putBoolean(PREFS_SHOWCAPTION, show);
97 edit.putInt(PREFS_ONTOUCH, ontouchsel);
98 edit.commit();
99
100 Intent resultValue = new Intent();
101 resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId); //you MUST return this intent
102 setResult(RESULT_OK, resultValue);
103 finish();
104
105 updateWidget();
106 }
107 };
108 }

  ViewVC Help
Powered by ViewVC 1.1.20