import android.app.ActionBar;
import android.app.Activity;
-import android.app.Fragment;
import android.appwidget.AppWidgetManager;
import android.content.Intent;
import android.os.Bundle;
public class WidgetConfigure extends Activity {
private int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
- private WidgetPreferences mPreferences;
private View.OnClickListener mOnClickListener;
@Override
// Set the view layout resource to use.
this.setContentView(R.layout.appwidget_configure);
-
- final Bundle args = new Bundle();
- args.putInt(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
- mPreferences = new WidgetPreferences();
- // Do not retain this fragment across configuration changes because I am tired for following
- // the fragment lifecycle (I am going to loose the instance field values but I DON'T CARE!!!)
- mPreferences.setRetainInstance(false);
- mPreferences.setArguments(args);
- this.getFragmentManager()
- .beginTransaction()
- .replace(R.id.weather_appwidget_configure_preferences, mPreferences)
- .commit();
+
mOnClickListener = new View.OnClickListener() {
public void onClick(View v) {
// Save to permanent storage
- mPreferences.onSavePreferences();
// Push widget update to surface with newly set prefix
final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="fill_vertical|fill_horizontal" >
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
- <LinearLayout android:id="@+id/weather_appwidget_configure_preferences"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_gravity="center"
- android:orientation="horizontal" >
-
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/weather_appwidget_configure_preferences"
- android:layout_centerHorizontal="true"
- android:layout_gravity="center"
- android:gravity="center"
- android:baselineAligned="false"
- android:orientation="horizontal" >
-
- <Button
- android:id="@+id/weather_appwidget_configure_refresh_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:textAlignment="center"
- android:text="@string/widget_preferences_button_refresh" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="wrap_content"
+ <LinearLayout android:id="@+id/weather_appwidget_configure_button_layout"
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
- android:layout_centerHorizontal="true"
- android:layout_gravity="center"
- android:gravity="center"
- android:baselineAligned="false"
- android:orientation="horizontal" >
-
+ android:orientation="horizontal"
+ android:gravity="center">
<Button
android:id="@+id/weather_appwidget_configure_save_button"
android:layout_width="wrap_content"
android:text="@android:string/ok" />
</LinearLayout>
-</RelativeLayout>
+ <ScrollView
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_above="@id/weather_appwidget_configure_button_layout">
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="Country"
+ android:padding="5dp"
+ android:layout_gravity="start" />
+
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1dp"
+ android:background="#ffffffff" />
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:padding="30dp">
+
+ <Switch android:id="@+id/weather_appwidget_configure_country"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Country field"
+ android:textOff="HIDE"
+ android:textOn="SHOW" />
+ </LinearLayout>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="Temperature units"
+ android:padding="5dp"
+ android:layout_gravity="start" />
+
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1dp"
+ android:background="#ffffffff" />
+
+ <Spinner android:id="@+id/weather_appwidget_configure_temperature_units"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:padding="30dp"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:textAlignment="center"
+ android:entries="@array/weather_preferences_temperature_human_value"
+ android:spinnerMode="dialog" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="Refresh"
+ android:padding="5dp"
+ android:layout_gravity="start" />
+
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1dp"
+ android:background="#ffffffff" />
+
+ <GridLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="horizontal"
+ android:padding="30dp">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="Refresh data"
+ android:padding="5dp"
+ android:layout_gravity="start" />
+
+ <Button android:id="@+id/weather_appwidget_configure_refresh_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="end"
+ android:textAlignment="center"
+ android:text="Refresh"/>
+
+ </GridLayout>
+
+ </LinearLayout>
+ </ScrollView>
+
+
+</RelativeLayout>
\ No newline at end of file