Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

New widget: capture template

Android 2.x now uses ActionBar
  • Loading branch information...
commit 202152e38450b942d0f6dc331ff261a23ab74b4d 1 parent 19f0370
Konstantin Vorobyev authored
Showing with 570 additions and 102 deletions.
  1. +1 −0  .classpath
  2. +21 −4 AndroidManifest.xml
  3. +12 −0 project.properties
  4. +16 −0 res/drawable/captute_widget_text_bg.xml
  5. BIN  res/drawable/widget_capture.png
  6. +1 −9 res/{layout-normal-land → layout-land-v11}/data_edit.xml
  7. +36 −0 res/layout-land/data_edit.xml
  8. 0  res/{layout-normal-land → layout-land}/data_options.xml
  9. +0 −8 res/{layout-large-land → layout-large-land-v11}/data_edit.xml
  10. 0  res/{layout-large-land → layout-large-land-v11}/f_outline_viewer.xml
  11. 0  res/{layout-large → layout-large-v11}/data_edit.xml
  12. +28 −0 res/layout-v11/data_edit.xml
  13. +12 −0 res/layout-v11/f_outline_viewer.xml
  14. +48 −0 res/layout/capture_template.xml
  15. +24 −0 res/layout/capture_widget.xml
  16. +7 −9 res/layout/data_edit.xml
  17. +12 −3 res/layout/f_outline_viewer.xml
  18. +1 −1  res/layout/outline_viewer_item.xml
  19. +1 −0  res/layout/outline_widget.xml
  20. +23 −0 res/menu/action_bar_menu.xml
  21. +6 −0 res/values/colors.xml
  22. +7 −0 res/xml/capture_widget.xml
  23. +17 −0 res/xml/capture_widget_preference.xml
  24. +1 −1  res/xml/outline_widget.xml
  25. BIN  src-img/widget_capture.pdn
  26. +2 −2 src-kvj/org/kvj/bravo7/SuperService.java
  27. +6 −2 src/com/matburt/mobileorg/service/DataService.java
  28. +1 −1  src/com/matburt/mobileorg/service/OrgNGParser.java
  29. +23 −5 src/com/matburt/mobileorg/settings/WidgetPreferences.java
  30. +71 −0 src/com/matburt/mobileorg/settings/widget/CaptureTemplatePreference.java
  31. +33 −0 src/com/matburt/mobileorg/settings/widget/CaptureWidgetConfig.java
  32. +36 −0 src/com/matburt/mobileorg/settings/widget/OutlineWidgetConfig.java
  33. +1 −3 src/com/matburt/mobileorg/settings/widget/WidgetList.java
  34. +19 −18 src/com/matburt/mobileorg/settings/widget/{WidgetConfigActivity.java → WidgetPreferenceActivity.java}
  35. +9 −12 src/com/matburt/mobileorg/ui/DataEditActivity.java
  36. +25 −18 src/com/matburt/mobileorg/ui/DataEditOptionsPanel.java
  37. +6 −4 src/com/matburt/mobileorg/ui/FOutlineViewer.java
  38. +56 −0 src/com/matburt/mobileorg/widgets/CaptureWidget.java
  39. +8 −2 src/com/matburt/mobileorg/widgets/OutlineWidget.java
View
1  .classpath
@@ -11,5 +11,6 @@
<classpathentry kind="lib" path="libs/dropbox-android-sdk-1.2.2.jar"/>
<classpathentry kind="lib" path="libs/httpmime-4.0.3.jar"/>
<classpathentry kind="lib" path="libs/android-support-v4.jar"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
View
25 AndroidManifest.xml
@@ -16,7 +16,8 @@
android:debuggable="true"
android:icon="@drawable/logo_72"
android:label="MobileOrg"
- android:name=".App" >
+ android:name=".App"
+ android:theme="@style/Theme.ActionBar">
<service android:name=".service.DataService" />
<receiver android:name=".service.DataAlarmReceiver"/>
@@ -75,7 +76,15 @@
<activity
android:configChanges="orientation|keyboard"
android:label="Widget Preference"
- android:name=".settings.widget.WidgetConfigActivity" >
+ android:name=".settings.widget.OutlineWidgetConfig" >
+ <intent-filter >
+ <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:configChanges="keyboard"
+ android:label="Widget Preference"
+ android:name=".settings.widget.CaptureWidgetConfig" >
<intent-filter >
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
@@ -99,7 +108,7 @@
</intent-filter>
</activity>
- <receiver android:name=".widgets.OutlineWidget" >
+ <receiver android:name=".widgets.OutlineWidget" android:label="MobileOrg outline">
<intent-filter >
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
@@ -108,6 +117,14 @@
android:name="android.appwidget.provider"
android:resource="@xml/outline_widget" />
</receiver>
- </application>
+ <receiver android:name=".widgets.CaptureWidget" android:label="MobileOrg capture">
+ <intent-filter >
+ <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
+ </intent-filter>
+ <meta-data
+ android:name="android.appwidget.provider"
+ android:resource="@xml/capture_widget" />
+ </receiver>
+ </application>
</manifest>
View
12 project.properties
@@ -0,0 +1,12 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-14
+android.library.reference.1=../android-actionbar/actionbar
View
16 res/drawable/captute_widget_text_bg.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+ <solid android:color="@android:color/background_dark"/>
+
+ <padding
+ android:left="5dp"
+ android:top="1dp"
+ android:right="5dp"
+ android:bottom="1dp"/>
+
+ <corners
+ android:bottomRightRadius="10dp"
+ android:bottomLeftRadius="10dp"
+ android:topLeftRadius="10dp"
+ android:topRightRadius="10dp"/>
+</shape>
View
BIN  res/drawable/widget_capture.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
10 res/layout-normal-land/data_edit.xml → res/layout-land-v11/data_edit.xml
@@ -3,7 +3,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
- <TableLayout
+ <TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
@@ -27,12 +27,4 @@
android:layout_weight="1"/>
</TableRow>
</TableLayout>
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <Button android:text="Save"
- android:id="@+id/data_edit_save"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- </FrameLayout>
</LinearLayout>
View
36 res/layout-land/data_edit.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+ <com.markupartist.android.widget.ActionBar
+ android:id="@+id/actionbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/ActionBar"
+ title="Capture" />
+ <TableLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:stretchColumns="0">
+ <TableRow>
+ <EditText
+ android:id="@+id/data_edit_text"
+ android:typeface="monospace"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minLines="1"/>
+ <ImageButton
+ android:id="@+id/data_edit_button"
+ android:layout_width="50dp"
+ android:layout_height="50dp"
+ android:src="@drawable/more"/>
+ <fragment class="com.matburt.mobileorg.ui.DataEditOptionsPanel"
+ android:id="@+id/data_edit_panel"
+ android:layout_width="200dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"/>
+ </TableRow>
+ </TableLayout>
+</LinearLayout>
View
0  res/layout-normal-land/data_options.xml → res/layout-land/data_options.xml
File renamed without changes
View
8 res/layout-large-land/data_edit.xml → res/layout-large-land-v11/data_edit.xml
@@ -30,12 +30,4 @@
android:layout_weight="1"/>
</TableRow>
</TableLayout>
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <Button android:text="Save"
- android:id="@+id/data_edit_save"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- </FrameLayout>
</LinearLayout>
View
0  res/layout-large-land/f_outline_viewer.xml → res/layout-large-land-v11/f_outline_viewer.xml
File renamed without changes
View
0  res/layout-large/data_edit.xml → res/layout-large-v11/data_edit.xml
File renamed without changes
View
28 res/layout-v11/data_edit.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+ <fragment class="com.matburt.mobileorg.ui.DataEditOptionsPanel"
+ android:id="@+id/data_edit_panel"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="horizontal"
+ android:layout_weight="1">
+ <EditText
+ android:id="@+id/data_edit_text"
+ android:typeface="monospace"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:minLines="1"/>
+ <ImageButton
+ android:id="@+id/data_edit_button"
+ android:layout_width="50dp"
+ android:layout_height="50dp"
+ android:src="@drawable/more"/>
+ </LinearLayout>
+</LinearLayout>
View
12 res/layout-v11/f_outline_viewer.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+ <fragment
+ android:id="@+id/viewer_left_pane"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ class="com.matburt.mobileorg.ui.OutlineViewerFragment" />
+
+</LinearLayout>
View
48 res/layout/capture_template.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <TableLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:stretchColumns="0">
+ <TableRow
+ android:gravity="center_vertical">
+ <TextView android:text="TODO:"/>
+ <Spinner
+ android:id="@+id/data_panel_todo"
+ android:layout_width="match_parent"/>
+ </TableRow>
+ <TableRow
+ android:gravity="center_vertical">
+ <TextView android:text="Priority:"/>
+ <Spinner
+ android:id="@+id/data_panel_priority"
+ android:layout_width="match_parent"/>
+ </TableRow>
+ </TableLayout>
+ <TextView android:text="Tags:"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+ <EditText
+ android:id="@+id/data_panel_tags"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:layout_gravity="fill_vertical"/>
+
+ <TextView android:text="Outline:"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+
+
+ <EditText
+ android:id="@+id/data_panel_title"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="fill_vertical"
+ android:inputType="text|textCapSentences"
+ android:singleLine="true" />
+
View
24 res/layout/capture_widget.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/capture_widget_root"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:layout_margin="@dimen/widget_margin">
+
+ <ImageView
+ android:id="@+id/capture_widget_icon"
+ android:src="@drawable/widget_capture"
+ android:layout_width="50dp"
+ android:layout_height="50dp"
+ android:layout_gravity="center"/>
+ <TextView
+ android:id="@+id/capture_widget_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="Widget"
+ android:textColor="@android:color/primary_text_dark"
+ android:background="@drawable/captute_widget_text_bg"/>
+
+</LinearLayout>
View
16 res/layout/data_edit.xml
@@ -3,7 +3,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
- <fragment class="com.matburt.mobileorg.ui.DataEditOptionsPanel"
+ <com.markupartist.android.widget.ActionBar
+ android:id="@+id/actionbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/ActionBar"
+ title="Capture" />
+ <fragment class="com.matburt.mobileorg.ui.DataEditOptionsPanel"
android:id="@+id/data_edit_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
@@ -25,12 +31,4 @@
android:layout_height="50dp"
android:src="@drawable/more"/>
</LinearLayout>
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <Button android:text="Save"
- android:id="@+id/data_edit_save"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
- </FrameLayout>
</LinearLayout>
View
15 res/layout/f_outline_viewer.xml
@@ -3,9 +3,18 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
- <fragment
+
+ <com.markupartist.android.widget.ActionBar
+ android:id="@+id/actionbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/ActionBar"
+ title="MobileOrg" />
+
+ <fragment
android:id="@+id/viewer_left_pane"
- class="com.matburt.mobileorg.ui.OutlineViewerFragment"
android:layout_width="match_parent"
- android:layout_height="match_parent"/>
+ android:layout_height="match_parent"
+ class="com.matburt.mobileorg.ui.OutlineViewerFragment" />
+
</LinearLayout>
View
2  res/layout/outline_viewer_item.xml
@@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingBottom="4dp">
+ android:paddingBottom="8dp">
<TextView
android:id="@+id/outline_viewer_item_text"
android:layout_width="wrap_content"
View
1  res/layout/outline_widget.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/outline_widget_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/panel_border"
View
23 res/menu/action_bar_menu.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <item
+ android:id="@+id/menu_sync"
+ android:icon="@drawable/sync"
+ android:showAsAction="ifRoom"
+ android:title="Sync"/>
+
+ <item
+ android:id="@+id/menu_capture"
+ android:icon="@drawable/capture"
+ android:showAsAction="ifRoom"
+ android:title="Capture"/>
+
+ <item
+ android:id="@+id/menu_edit"
+ android:enabled="false"
+ android:showAsAction="ifRoom"
+ android:title="Edit"
+ android:icon="@drawable/edit"/>
+
+</menu>
View
6 res/values/colors.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <color name="actionbar_divider">#222222</color>
+ <color name="actionbar_background_start">#333333</color>
+ <color name="actionbar_background_end">#111111</color>
+</resources>
View
7 res/xml/capture_widget.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
+ android:minWidth="72dp"
+ android:minHeight="72dp"
+ android:updatePeriodMillis="0"
+ android:configure="com.matburt.mobileorg.settings.widget.CaptureWidgetConfig"
+ android:initialLayout="@layout/capture_widget"/>
View
17 res/xml/capture_widget_preference.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <PreferenceCategory android:key="common" >
+
+ <EditTextPreference
+ android:dialogTitle="Enter widget name"
+ android:key="name"
+ android:title="Widget name" />
+ </PreferenceCategory>
+
+ <PreferenceCategory android:title="Template" >
+
+ <com.matburt.mobileorg.settings.widget.CaptureTemplatePreference android:key="template" />
+ </PreferenceCategory>
+
+</PreferenceScreen>
View
2  res/xml/outline_widget.xml
@@ -3,6 +3,6 @@
android:minWidth="220dp"
android:minHeight="220dp"
android:updatePeriodMillis="0"
- android:configure="com.matburt.mobileorg.settings.widget.WidgetConfigActivity"
+ android:configure="com.matburt.mobileorg.settings.widget.OutlineWidgetConfig"
android:initialLayout="@layout/outline_widget"
android:resizeMode="horizontal|vertical"/>
View
BIN  src-img/widget_capture.pdn
Binary file not shown
View
4 src-kvj/org/kvj/bravo7/SuperService.java
@@ -24,7 +24,6 @@
protected String title = "Application";
private static final int SERVICE_NOTIFY = 100;
private static final String TAG = "SuperService";
- private static final int ALARM_ID = 103;
private static final String LOCK_NAME = "SuperService";
protected int notificationID = SERVICE_NOTIFY;
private Class<? extends AlarmReceiver> alarmBroadcastReceiverClass = null;
@@ -54,9 +53,10 @@ public static synchronized void powerUnlock(Context context) {
getLock(context).release();
}
- public SuperService(Class<T> controllerClass) {
+ public SuperService(Class<T> controllerClass, String title) {
this();
this.controllerClass = controllerClass;
+ this.title = title;
}
public class LocalBinder extends Binder {
View
8 src/com/matburt/mobileorg/service/DataService.java
@@ -24,7 +24,7 @@
PendingIntent syncIntent = null;
public DataService() {
- super(DataController.class);
+ super(DataController.class, "MobileOrg");
}
@Override
@@ -74,7 +74,11 @@ public void syncFinished(boolean success) {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i(TAG, "onStartCommand: " + flags);
- String message = intent.getStringExtra("message");
+ String message = null;
+ try {
+ message = intent.getStringExtra("message");
+ } catch (Exception e) {
+ }
Log.i(TAG, "Handle intent: " + message);
if (null == message) {
return Service.START_STICKY;
View
2  src/com/matburt/mobileorg/service/OrgNGParser.java
@@ -24,7 +24,7 @@
};
private static Pattern outlinePattern = Pattern.compile("^(\\*+\\s+)"
- + "([A-Z0-9]+\\s+)?" + "(\\[\\#([A-Z])\\]\\s+)?" + "(.+)$");
+ + "([A-Z][A-Z0-9]*\\s+)?" + "(\\[\\#([A-Z])\\]\\s+)?" + "(.+)$");
private static Pattern outlineTailPattern = Pattern
.compile("((((\\:[a-z]+)+\\:)|\\:)+)?" + "(<before>(.*)</before>)?"
+ "(<after>(.*)</after>)?" + "$");
View
28 src/com/matburt/mobileorg/settings/WidgetPreferences.java
@@ -6,31 +6,49 @@
import android.support.v4.app.FragmentActivity;
import com.matburt.mobileorg.R;
-import com.matburt.mobileorg.settings.widget.WidgetConfigActivity;
+import com.matburt.mobileorg.settings.widget.CaptureWidgetConfig;
+import com.matburt.mobileorg.settings.widget.OutlineWidgetConfig;
import com.matburt.mobileorg.settings.widget.WidgetList;
import com.matburt.mobileorg.settings.widget.WidgetList.ClickListener;
import com.matburt.mobileorg.settings.widget.WidgetList.WidgetInfo;
+import com.matburt.mobileorg.settings.widget.WidgetPreferenceActivity;
-public class WidgetPreferences extends FragmentActivity implements ClickListener {
+public class WidgetPreferences extends FragmentActivity implements
+ ClickListener {
WidgetList widgetList = null;
Fragment editorFragment = null;
-
+
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
setContentView(R.layout.widgets_config);
- widgetList = (WidgetList) getSupportFragmentManager().findFragmentById(R.id.widget_list);
+ widgetList = (WidgetList) getSupportFragmentManager().findFragmentById(
+ R.id.widget_list);
widgetList.setClickListener(this);
}
@Override
public void click(WidgetInfo info) {
if (null == editorFragment) {
- Intent intent = new Intent(this, WidgetConfigActivity.class);
+ Class<? extends WidgetPreferenceActivity> configActivity = getConfigActivity(info);
+ if (null == configActivity) {
+ return;
+ }
+ Intent intent = new Intent(this, configActivity);
intent.putExtra("id", info.id);
startActivity(intent);
}
}
+ protected Class<? extends WidgetPreferenceActivity> getConfigActivity(
+ WidgetInfo info) {
+ if ("outline".equals(info.type)) {
+ return OutlineWidgetConfig.class;
+ }
+ if ("capture".equals(info.type)) {
+ return CaptureWidgetConfig.class;
+ }
+ return null;
+ }
}
View
71 src/com/matburt/mobileorg/settings/widget/CaptureTemplatePreference.java
@@ -0,0 +1,71 @@
+package com.matburt.mobileorg.settings.widget;
+
+import org.kvj.bravo7.ControllerConnector.ControllerReceiver;
+
+import android.content.Context;
+import android.content.SharedPreferences.Editor;
+import android.os.Parcelable;
+import android.preference.Preference;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.Spinner;
+
+import com.matburt.mobileorg.R;
+import com.matburt.mobileorg.service.DataController;
+import com.matburt.mobileorg.ui.DataEditOptionsPanel;
+
+public class CaptureTemplatePreference extends Preference implements
+ ControllerReceiver<DataController> {
+
+ private static final String TAG = "CaptureTemplate";
+ private Spinner todoSpinner;
+ private Spinner prioritySpinner;
+ private EditText tagsText;
+ private EditText titleText;
+ private DataController controller;
+
+ public CaptureTemplatePreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setLayoutResource(R.layout.capture_template);
+ }
+
+ @Override
+ protected void onBindView(View view) {
+ super.onBindView(view);
+ todoSpinner = (Spinner) view.findViewById(R.id.data_panel_todo);
+ prioritySpinner = (Spinner) view.findViewById(R.id.data_panel_priority);
+ tagsText = (EditText) view.findViewById(R.id.data_panel_tags);
+ titleText = (EditText) view.findViewById(R.id.data_panel_title);
+ DataEditOptionsPanel.loadPanel(getContext(), controller, todoSpinner,
+ getSharedPreferences().getString("template_todo", null),
+ prioritySpinner,
+ getSharedPreferences().getString("template_priority", null),
+ tagsText,
+ getSharedPreferences().getString("template_tags", null));
+ titleText.setText(getSharedPreferences().getString("template", null));
+ }
+
+ @Override
+ public void onController(DataController controller) {
+ this.controller = controller;
+ }
+
+ @Override
+ protected Parcelable onSaveInstanceState() {
+ saveData();
+ return super.onSaveInstanceState();
+ }
+
+ public void saveData() {
+ Editor editor = getSharedPreferences().edit();
+ editor.putString("template_todo",
+ DataEditOptionsPanel.getSpinnerValue(todoSpinner));
+ editor.putString("template_priority",
+ DataEditOptionsPanel.getSpinnerValue(prioritySpinner));
+ editor.putString("template_tags", tagsText.getText().toString());
+ editor.putString("template", titleText.getText().toString());
+ editor.commit();
+ }
+
+}
View
33 src/com/matburt/mobileorg/settings/widget/CaptureWidgetConfig.java
@@ -0,0 +1,33 @@
+package com.matburt.mobileorg.settings.widget;
+
+import android.os.Bundle;
+
+import com.matburt.mobileorg.R;
+import com.matburt.mobileorg.service.DataController;
+
+public class CaptureWidgetConfig extends WidgetPreferenceActivity {
+
+ CaptureTemplatePreference captureTemplatePreference = null;
+
+ public CaptureWidgetConfig() {
+ super("capture", R.xml.capture_widget_preference);
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ captureTemplatePreference = (CaptureTemplatePreference) findPreference("template");
+ }
+
+ @Override
+ public void onController(DataController controller) {
+ super.onController(controller);
+ captureTemplatePreference.onController(controller);
+ }
+
+ @Override
+ protected void onDestroy() {
+ captureTemplatePreference.saveData();
+ super.onDestroy();
+ }
+}
View
36 src/com/matburt/mobileorg/settings/widget/OutlineWidgetConfig.java
@@ -0,0 +1,36 @@
+package com.matburt.mobileorg.settings.widget;
+
+import android.content.Intent;
+import android.os.Bundle;
+
+import com.matburt.mobileorg.R;
+import com.matburt.mobileorg.service.DataController;
+
+public class OutlineWidgetConfig extends WidgetPreferenceActivity {
+
+ public OutlineWidgetConfig() {
+ super("outline", R.xml.widget_preference);
+ }
+
+ OutlineListPreference itemsPreference = null;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ itemsPreference = (OutlineListPreference) findPreference("items");
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (RESULT_OK == resultCode
+ && OutlineListPreference.SELECT_OUTLINE == requestCode) {
+ itemsPreference.itemModified(data.getStringExtra("data"));
+ }
+ }
+
+ @Override
+ public void onController(DataController controller) {
+ itemsPreference.onController(controller);
+ }
+}
View
4 src/com/matburt/mobileorg/settings/widget/WidgetList.java
@@ -21,7 +21,7 @@
public class WidgetInfo {
public int id;
- String type;
+ public String type;
@Override
public String toString() {
@@ -36,8 +36,6 @@ public String toString() {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- App.getInstance().setWidgetConfig(0, "outline");
- App.getInstance().setWidgetConfig(1, "outline");
reloadData();
}
View
37 ...bileorg/settings/widget/WidgetConfigActivity.java → ...org/settings/widget/WidgetPreferenceActivity.java
@@ -1,22 +1,27 @@
package com.matburt.mobileorg.settings.widget;
import org.kvj.bravo7.ControllerConnector;
+import org.kvj.bravo7.ControllerConnector.ControllerReceiver;
-import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import com.matburt.mobileorg.App;
-import com.matburt.mobileorg.R;
import com.matburt.mobileorg.service.DataController;
import com.matburt.mobileorg.service.DataService;
-public class WidgetConfigActivity extends PreferenceActivity {
-
- OutlineListPreference itemsPreference = null;
+public class WidgetPreferenceActivity extends PreferenceActivity implements
+ ControllerReceiver<DataController> {
ControllerConnector<App, DataController, DataService> connector = null;
Integer widgetID = null;
+ private String widgetType;
+ private int prefID;
+
+ public WidgetPreferenceActivity(String widgetType, int prefID) {
+ this.widgetType = widgetType;
+ this.prefID = prefID;
+ }
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -29,33 +34,23 @@ protected void onCreate(Bundle savedInstanceState) {
widgetID = getIntent().getExtras().getInt("id");
}
getPreferenceManager().setSharedPreferencesName("widget_" + widgetID);
- addPreferencesFromResource(R.xml.widget_preference);
- itemsPreference = (OutlineListPreference) findPreference("items");
+ addPreferencesFromResource(prefID);
}
@Override
protected void onDestroy() {
super.onDestroy();
if (null != widgetID) {
- App.getInstance().setWidgetConfig(widgetID, "outline");
+ App.getInstance().setWidgetConfig(widgetID, widgetType);
App.getInstance().updateWidgets(widgetID);
}
}
@Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (RESULT_OK == resultCode
- && OutlineListPreference.SELECT_OUTLINE == requestCode) {
- itemsPreference.itemModified(data.getStringExtra("data"));
- }
- }
-
- @Override
protected void onStart() {
super.onStart();
connector = new ControllerConnector<App, DataController, DataService>(
- this, itemsPreference);
+ this, this);
connector.connectController(DataService.class);
}
@@ -64,4 +59,10 @@ protected void onStop() {
super.onStop();
connector.disconnectController();
}
+
+ @Override
+ public void onController(DataController controller) {
+ // TODO Auto-generated method stub
+
+ }
}
View
21 src/com/matburt/mobileorg/ui/DataEditActivity.java
@@ -21,6 +21,7 @@
import android.widget.EditText;
import android.widget.ImageButton;
+import com.markupartist.android.widget.ActionBar;
import com.matburt.mobileorg.App;
import com.matburt.mobileorg.R;
import com.matburt.mobileorg.service.DataController;
@@ -50,21 +51,16 @@ protected void onCreate(Bundle savedInstanceState) {
// Log.i(TAG,
// "onCreate: "+getResources().getConfiguration().screenLayout+", "+getResources().getDisplayMetrics().densityDpi);
setContentView(R.layout.data_edit);
+ if (null != findViewById(R.id.actionbar)) {
+ ActionBar bar = (ActionBar) findViewById(R.id.actionbar);
+ bar.setHomeLogo(R.drawable.logo_72);
+ getMenuInflater().inflate(R.menu.editor_menu, bar.asMenu());
+ }
edit = (EditText) findViewById(R.id.data_edit_text);
edit.setInputType(InputType.TYPE_CLASS_TEXT
| InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE
| InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
togglePanel = (ImageButton) findViewById(R.id.data_edit_button);
- save = (Button) findViewById(R.id.data_edit_save);
- if (null != save) {
- save.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- onSave();
- }
- });
- }
panel = (DataEditOptionsPanel) getSupportFragmentManager()
.findFragmentById(R.id.data_edit_panel);
if (null == savedInstanceState) {
@@ -73,7 +69,6 @@ public void onClick(View v) {
data = new Bundle();
data.putString("type", "title");
}
- data.putBoolean("panel", false);
} else {
data = savedInstanceState;
}
@@ -96,6 +91,7 @@ protected void onStart() {
conn = new ControllerConnector<App, DataController, DataService>(this,
this);
conn.connectController(DataService.class);
+ edit.requestFocusFromTouch();
}
@Override
@@ -111,7 +107,7 @@ public void onController(DataController controller) {
}
controller.setInEdit(true);
this.controller = controller;
- Log.i(TAG, "Restoring editor state here " + data.getString("text"));
+ // Log.i(TAG, "Restoring editor state here " + data.getString("text"));
if (!"title".equals(data.getString("type"))) {
togglePanel.setVisibility(View.GONE);
edit.setSingleLine(false);
@@ -119,6 +115,7 @@ public void onController(DataController controller) {
edit.setSingleLine(true);
}
edit.setText(data.getString("text"));
+ edit.setSelection(edit.getText().length());
panel.getView().setVisibility(
data.getBoolean("panel", false) ? View.VISIBLE : View.GONE);
panel.loadData(controller, data);
View
43 src/com/matburt/mobileorg/ui/DataEditOptionsPanel.java
@@ -3,7 +3,7 @@
import java.util.ArrayList;
import java.util.List;
-import android.app.Activity;
+import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.InputType;
@@ -22,7 +22,7 @@
public static class StringListAdapter extends ArrayAdapter<String> {
- public StringListAdapter(Activity activity, List<String> data) {
+ public StringListAdapter(Context activity, List<String> data) {
super(activity, android.R.layout.simple_spinner_item,
new ArrayList<String>(data));
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
@@ -51,18 +51,20 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
- public void loadData(DataController controller, Bundle data) {
+ public static void loadPanel(Context activity, DataController controller,
+ Spinner todoSpinner, String todo, Spinner prioritySpinner,
+ String priority, EditText tagsText, String tags) {
List<String> items = new ArrayList<String>();
items.add("Empty");
int selectedTODO = 0;
List<TodoState> todoStates = controller.getTodoTypes();
for (int i = 0; i < todoStates.size(); i++) {
items.add(todoStates.get(i).name);
- if (todoStates.get(i).name.equals(data.getString("todo"))) {
+ if (todoStates.get(i).name.equals(todo)) {
selectedTODO = i + 1;
}
}
- todoSpinner.setAdapter(new StringListAdapter(getActivity(), items));
+ todoSpinner.setAdapter(new StringListAdapter(activity, items));
todoSpinner.setSelection(selectedTODO);
items.clear();
items.add("Empty");
@@ -70,31 +72,36 @@ public void loadData(DataController controller, Bundle data) {
List<String> prStates = controller.getPrioritiesNG();
for (int i = 0; i < prStates.size(); i++) {
items.add(prStates.get(i));
- if (prStates.get(i).equals(data.getString("priority"))) {
+ if (prStates.get(i).equals(priority)) {
selectedPriority = i + 1;
}
}
- prioritySpinner.setAdapter(new StringListAdapter(getActivity(), items));
+ prioritySpinner.setAdapter(new StringListAdapter(activity, items));
prioritySpinner.setSelection(selectedPriority);
- String tags = data.getString("tags");
if (null == tags) {
tags = ":";
}
tagsText.setText(tags);
+
}
- public void saveData(Bundle data) {
- if (0 == todoSpinner.getSelectedItemPosition()) {
- data.putString("todo", null);
- } else {
- data.putString("todo", todoSpinner.getSelectedItem().toString());
- }
- if (0 == prioritySpinner.getSelectedItemPosition()) {
- data.putString("priority", null);
+ public void loadData(DataController controller, Bundle data) {
+ loadPanel(this.getActivity(), controller, todoSpinner,
+ data.getString("todo"), prioritySpinner,
+ data.getString("priority"), tagsText, data.getString("tags"));
+ }
+
+ public static String getSpinnerValue(Spinner spinner) {
+ if (0 == spinner.getSelectedItemPosition()) {
+ return null;
} else {
- data.putString("priority", prioritySpinner.getSelectedItem()
- .toString());
+ return spinner.getSelectedItem().toString();
}
+ }
+
+ public void saveData(Bundle data) {
+ data.putString("todo", getSpinnerValue(todoSpinner));
+ data.putString("priority", getSpinnerValue(prioritySpinner));
String tagsString = tagsText.getText().toString().trim();
if (!tagsString.startsWith(":")) {
tagsString = ":" + tagsString;
View
10 src/com/matburt/mobileorg/ui/FOutlineViewer.java
@@ -17,8 +17,8 @@
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
-import android.view.Window;
+import com.markupartist.android.widget.ActionBar;
import com.matburt.mobileorg.App;
import com.matburt.mobileorg.R;
import com.matburt.mobileorg.service.DataController;
@@ -57,10 +57,12 @@ protected void onCreate(Bundle savedState) {
}
}
Log.i(TAG, "We are on: " + android.os.Build.VERSION.SDK_INT);
- if (android.os.Build.VERSION.SDK_INT < 11) {// <3.0
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- }
setContentView(R.layout.f_outline_viewer);
+ if (null != findViewById(R.id.actionbar)) {
+ ActionBar bar = (ActionBar) findViewById(R.id.actionbar);
+ bar.setHomeLogo(R.drawable.logo_72);
+ getMenuInflater().inflate(R.menu.action_bar_menu, bar.asMenu());
+ }
left = (OutlineViewerFragment) getSupportFragmentManager()
.findFragmentById(R.id.viewer_left_pane);
right = (OutlineViewerFragment) getSupportFragmentManager()
View
56 src/com/matburt/mobileorg/widgets/CaptureWidget.java
@@ -0,0 +1,56 @@
+package com.matburt.mobileorg.widgets;
+
+import android.app.PendingIntent;
+import android.appwidget.AppWidgetManager;
+import android.appwidget.AppWidgetProvider;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.util.Log;
+import android.widget.RemoteViews;
+
+import com.matburt.mobileorg.App;
+import com.matburt.mobileorg.R;
+import com.matburt.mobileorg.ui.DataEditActivity;
+
+public class CaptureWidget extends AppWidgetProvider {
+
+ private static final String TAG = "CaptureWidget";
+
+ @Override
+ public void onUpdate(Context context, AppWidgetManager appWidgetManager,
+ int[] appWidgetIds) {
+ super.onUpdate(context, appWidgetManager, appWidgetIds);
+ try {
+ for (int i = 0; i < appWidgetIds.length; i++) {
+ int id = appWidgetIds[i];
+ SharedPreferences prefs = App.getInstance().getWidgetConfig(id);
+ if (null == prefs) {
+ Log.w(TAG, "No config for " + id);
+ continue;
+ }
+ RemoteViews views = new RemoteViews(context.getPackageName(),
+ R.layout.capture_widget);
+ views.setTextViewText(R.id.capture_widget_text,
+ prefs.getString("name", "???"));
+ Intent intent = new Intent(context, DataEditActivity.class);
+ intent.putExtra("type", "title");
+ intent.putExtra("panel", true);
+ intent.putExtra("text", prefs.getString("template", ""));
+ intent.putExtra("todo", prefs.getString("template_todo", ""));
+ intent.putExtra("priority",
+ prefs.getString("template_priority", ""));
+ intent.putExtra("tags", prefs.getString("template_tags", ""));
+ PendingIntent pendingIntent = PendingIntent.getActivity(
+ context, id, intent, PendingIntent.FLAG_CANCEL_CURRENT);
+ views.setOnClickPendingIntent(R.id.capture_widget_root,
+ pendingIntent);
+ appWidgetManager.updateAppWidget(id, views);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
View
10 src/com/matburt/mobileorg/widgets/OutlineWidget.java
@@ -2,9 +2,11 @@
import java.util.ArrayList;
+import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
+import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
import android.widget.RemoteViews;
@@ -13,6 +15,7 @@
import com.matburt.mobileorg.R;
import com.matburt.mobileorg.service.DataController;
import com.matburt.mobileorg.service.NoteNG;
+import com.matburt.mobileorg.ui.FOutlineViewer;
import com.matburt.mobileorg.ui.OutlineViewerAdapter;
import com.matburt.mobileorg.ui.OutlineViewerAdapter.TextViewParts;
@@ -28,7 +31,6 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager,
DataController.class);
for (int i = 0; i < appWidgetIds.length; i++) {
int id = appWidgetIds[i];
- Log.i(TAG, "Update widget: " + id);
SharedPreferences prefs = App.getInstance().getWidgetConfig(id);
if (null == prefs) {
Log.w(TAG, "No config for " + id);
@@ -36,6 +38,11 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager,
}
RemoteViews views = new RemoteViews(context.getPackageName(),
R.layout.outline_widget);
+ Intent intent = new Intent(context, FOutlineViewer.class);
+ PendingIntent pendingIntent = PendingIntent.getActivity(
+ context, id, intent, PendingIntent.FLAG_CANCEL_CURRENT);
+ views.setOnClickPendingIntent(R.id.outline_widget_root,
+ pendingIntent);
views.removeAllViews(R.id.outline_widget_list);
int bg = Integer.parseInt(prefs.getString("background", "4"));
Log.i(TAG,
@@ -63,7 +70,6 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager,
prefs.getBoolean("long", false));
}
appWidgetManager.updateAppWidget(id, views);
- Log.i(TAG, "Update widget done");
}
} catch (Exception e) {
e.printStackTrace();
Please sign in to comment.
Something went wrong with that request. Please try again.