Skip to content
This repository
Browse code

Upgraded ActionBar.

  • Loading branch information...
commit 8ca172d76986d731f28724ee1efb8a6d776b1656 1 parent 7710454
Henning Weiss authored August 08, 2012
2  AndroidManifest.xml
@@ -17,6 +17,7 @@
17 17
         android:name=".Parsing.MobileOrgApplication"
18 18
         android:debuggable="true"
19 19
         android:icon="@drawable/icon"
  20
+        android:theme="@style/Theme.Sherlock"
20 21
         android:label="MobileOrg" >
21 22
         <meta-data
22 23
             android:name="android.app.default_searchable"
@@ -166,6 +167,7 @@
166 167
             android:name=".Services.TimeclockDialog"
167 168
             android:theme="@android:style/Theme.Dialog" >
168 169
         </activity>
  170
+        <activity android:name=".Gui.Capture.EditActivityMock"></activity>
169 171
     </application>
170 172
 
171 173
 </manifest>
2  libs/ActionBarSherlock
... ...
@@ -1 +1 @@
1  
-Subproject commit 989a0ffa90e1d7f665d9efc70e532d6c407ac5f2
  1
+Subproject commit 9598f2bb2ceed4a834cd5586a903f270ca4c0ccc
4  res/values/styles.xml
... ...
@@ -1,8 +1,8 @@
1 1
 <?xml version="1.0" encoding="utf-8"?>
2 2
 <resources>
3 3
     <style name="Theme.MobileOrgActionbar" parent="Theme.Sherlock">
4  
-        <item name="abBackground">@drawable/actionbar_background</item>
5  
-        <item name="abDivider">#3A5FCD</item>
  4
+        <item name="actionModeBackground">@drawable/actionbar_background</item>
  5
+        <item name="actionBarDivider">@color/actionbar_separator</item>
6 6
        <!-- <item name="abHeight">35dip</item>  -->
7 7
        <!--  <item name="abTitleTextStyle"></item> --> 
8 8
     </style>
6  src/com/matburt/mobileorg/Gui/Capture/DateTableRow.java
@@ -99,7 +99,7 @@ private void init(Context context,
99 99
 		dateButton = (Button) findViewById(R.id.dateButton);
100 100
 		dateButton.setOnClickListener(new View.OnClickListener() {
101 101
 			public void onClick(View v) {
102  
-				FragmentTransaction ft = parentFragment.getSupportFragmentManager()
  102
+				FragmentTransaction ft = parentFragment.getSherlockActivity().getSupportFragmentManager()
103 103
 						.beginTransaction();
104 104
 				DialogFragment newFragment = new DatePickerDialogFragment(
105 105
 						dateChangeListener);
@@ -110,7 +110,7 @@ public void onClick(View v) {
110 110
 		startTimeButton = (Button) findViewById(R.id.dateTimeStartButton);
111 111
 		startTimeButton.setOnClickListener(new View.OnClickListener() {
112 112
 			public void onClick(View v) {
113  
-				FragmentTransaction ft = parentFragment.getSupportFragmentManager()
  113
+				FragmentTransaction ft = parentFragment.getSherlockActivity().getSupportFragmentManager()
114 114
 						.beginTransaction();
115 115
 				DialogFragment newFragment = new StartTimePickerDialogFragment(
116 116
 						startTimeChangeListener);
@@ -121,7 +121,7 @@ public void onClick(View v) {
121 121
 		endTimeButton = (Button) findViewById(R.id.dateTimeEndButton);
122 122
 		endTimeButton.setOnClickListener(new View.OnClickListener() {
123 123
 			public void onClick(View v) {
124  
-				FragmentTransaction ft = parentFragment.getSupportFragmentManager()
  124
+				FragmentTransaction ft = parentFragment.getSherlockActivity().getSupportFragmentManager()
125 125
 						.beginTransaction();
126 126
 				DialogFragment newFragment = new EndTimePickerDialogFragment(
127 127
 						endTimeChangeListener);
226  src/com/matburt/mobileorg/Gui/Capture/EditActivity.java
@@ -7,17 +7,16 @@
7 7
 import android.content.SharedPreferences;
8 8
 import android.os.Bundle;
9 9
 import android.preference.PreferenceManager;
10  
-import android.support.v4.app.ActionBar;
11  
-import android.support.v4.app.ActionBar.Tab;
12  
-import android.support.v4.app.Fragment;
13  
-import android.support.v4.app.FragmentActivity;
14 10
 import android.support.v4.app.FragmentTransaction;
15  
-import android.support.v4.view.MenuItem;
16  
-import android.support.v4.view.SubMenu;
17  
-import android.support.v4.view.Window;
18  
-import android.view.MenuInflater;
19 11
 import android.view.WindowManager;
20 12
 
  13
+import com.actionbarsherlock.app.ActionBar;
  14
+import com.actionbarsherlock.app.SherlockFragmentActivity;
  15
+import com.actionbarsherlock.view.Menu;
  16
+import com.actionbarsherlock.view.MenuInflater;
  17
+import com.actionbarsherlock.view.MenuItem;
  18
+import com.actionbarsherlock.view.SubMenu;
  19
+import com.actionbarsherlock.view.Window;
21 20
 import com.matburt.mobileorg.R;
22 21
 import com.matburt.mobileorg.Services.TimeclockService;
23 22
 import com.matburt.mobileorg.Synchronizers.Synchronizer;
@@ -25,48 +24,34 @@
25 24
 import com.matburt.mobileorg.provider.OrgProviderUtil;
26 25
 import com.matburt.mobileorg.util.OrgUtils;
27 26
 
28  
-public class EditActivity extends FragmentActivity {
  27
+public class EditActivity extends SherlockFragmentActivity {
  28
+	public final static String NODE_ID = "node_id";
  29
+	public final static String ACTIONMODE = "actionMode";
29 30
 	public final static String ACTIONMODE_CREATE = "create";
30 31
 	public final static String ACTIONMODE_EDIT = "edit";
31 32
 	public final static String ACTIONMODE_ADDCHILD = "add_child";
32 33
 
33 34
 	private OrgNode node;
34 35
 	private String actionMode;
35  
-		
  36
+	
  37
+	public final static String FRAGMENT_DETAILS_TAG = "details";
  38
+	public final static String FRAGMENT_PAYLOAD_TAG = "payload";
  39
+	
36 40
 	private EditDetailsFragment detailsFragment;
37 41
 	private EditPayloadFragment payloadFragment;
38 42
 	private EditPayloadFragment rawPayloadFragment;
39 43
 	private ContentResolver resolver;
  44
+	private EditTabListener editTabListener;
40 45
 
41 46
 	@Override
42 47
 	public void onCreate(Bundle savedInstanceState) {
43 48
 		super.onCreate(savedInstanceState);
44  
-		this.resolver = getContentResolver();
45  
-
46  
-		SharedPreferences appSettings = PreferenceManager
47  
-				.getDefaultSharedPreferences(getBaseContext());
48  
-		if (appSettings.getBoolean("fullscreen", true)) {
49  
-			requestWindowFeature(Window.FEATURE_NO_TITLE);
50  
-			getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
51  
-					WindowManager.LayoutParams.FLAG_FULLSCREEN);
52  
-		}
53  
-		
54  
-		if (savedInstanceState != null) {
55  
-			this.detailsFragment = (EditDetailsFragment) getSupportFragmentManager()
56  
-					.getFragment(savedInstanceState,
57  
-							EditDetailsFragment.class.getName());
58  
-			this.payloadFragment = (EditPayloadFragment) getSupportFragmentManager()
59  
-					.getFragment(savedInstanceState,
60  
-							EditPayloadFragment.class.getName());
61  
-			this.rawPayloadFragment = (EditPayloadFragment) getSupportFragmentManager()
62  
-					.getFragment(savedInstanceState,
63  
-							EditPayloadFragment.class.getName() + "raw");
64  
-		}
65 49
 		
66 50
 		setContentView(R.layout.edit);
  51
+		this.resolver = getContentResolver();
67 52
 		
68  
-		init();
69  
-		
  53
+		restoreInstanceState(savedInstanceState);
  54
+		initState();
70 55
 		setupActionbarTabs(savedInstanceState);
71 56
 	}
72 57
 	
@@ -82,10 +67,18 @@ protected void onSaveInstanceState(Bundle outState) {
82 67
         outState.putInt("tab", getSupportActionBar().getSelectedNavigationIndex());
83 68
 	}
84 69
 	
85  
-	private void init() {
86  
-		Intent intent = getIntent();
87  
-		this.actionMode = intent.getStringExtra("actionMode");
88  
-		long node_id = intent.getLongExtra("node_id", -1);	
  70
+	private void restoreInstanceState(Bundle savedInstanceState) {
  71
+		if (savedInstanceState != null) {
  72
+			this.detailsFragment = (EditDetailsFragment) getSupportFragmentManager()
  73
+					.getFragment(savedInstanceState,
  74
+							EditDetailsFragment.class.getName());
  75
+			this.payloadFragment = (EditPayloadFragment) getSupportFragmentManager()
  76
+					.getFragment(savedInstanceState,
  77
+							EditPayloadFragment.class.getName());
  78
+			this.rawPayloadFragment = (EditPayloadFragment) getSupportFragmentManager()
  79
+					.getFragment(savedInstanceState,
  80
+							EditPayloadFragment.class.getName() + "raw");
  81
+		}		
89 82
 		
90 83
 		if (this.detailsFragment == null)
91 84
 			this.detailsFragment = new EditDetailsFragment();
@@ -93,62 +86,24 @@ private void init() {
93 86
 			this.payloadFragment = new EditPayloadFragment();
94 87
 		if (this.rawPayloadFragment == null)
95 88
 			this.rawPayloadFragment = new EditPayloadFragment();
96  
-		
97  
-		String defaultTodo = PreferenceManager
98  
-				.getDefaultSharedPreferences(this).getString("defaultTodo", "");
99  
-		
100  
-		if (this.actionMode == null) {
101  
-			String subject = intent
102  
-					.getStringExtra("android.intent.extra.SUBJECT");
103  
-			String text = intent.getStringExtra("android.intent.extra.TEXT");
104  
-
105  
-			if(text != null && subject != null) {
106  
-				subject = "[[" + text + "][" + subject + "]]";
107  
-				text = "";
108  
-			}
109  
-			
110  
-			if(subject == null)
111  
-				subject = "";
112  
-			if(text == null)
113  
-				text = "";
114  
-
115  
-			this.node = new OrgNode();
116  
-			this.detailsFragment.init(this.node, this.actionMode, defaultTodo, subject, resolver);
117  
-			this.payloadFragment.init(text, true);
118  
-			this.actionMode = ACTIONMODE_CREATE;
119  
-		} else if (this.actionMode.equals(ACTIONMODE_CREATE)) {
120  
-			this.node = new OrgNode();
121  
-			this.detailsFragment.init(this.node, this.actionMode, defaultTodo, resolver);
122  
-			this.payloadFragment.init("", true);
123  
-		} else if (this.actionMode.equals(ACTIONMODE_EDIT)) {
124  
-			this.node = new OrgNode(node_id, getContentResolver());
125  
-			this.detailsFragment.init(this.node, this.actionMode, defaultTodo, resolver);
126  
-			this.payloadFragment.init(this.node.getCleanedPayload(), true);
127  
-		} else if (this.actionMode.equals(ACTIONMODE_ADDCHILD)) {
128  
-			this.node = new OrgNode(node_id, getContentResolver());
129  
-			this.detailsFragment.init(this.node, this.actionMode, defaultTodo, resolver);
130  
-			this.payloadFragment.init("", true);
131  
-		}
132  
-
133  
-		this.rawPayloadFragment.init(node.getRawPayload(), false);
134 89
 	}
135  
-
136  
-
137  
-	private void setupActionbarTabs(Bundle savedInstanceState) {
  90
+	
  91
+	public void setupActionbarTabs(Bundle savedInstanceState) {
138 92
 		ActionBar actionbar = getSupportActionBar();
139  
-
140 93
 		actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  94
+		actionbar.removeAllTabs();
141 95
 
142 96
 		ActionBar.Tab detailsTab = actionbar.newTab().setText("Details");
143  
-		detailsTab.setTabListener(new TabListener(detailsFragment, "details"));
  97
+		//editTabListener = new EditTabListener(detailsFragment, "details", getSupportFragmentManager());
  98
+		detailsTab.setTabListener(new EditTabListener(detailsFragment, "details", getSupportFragmentManager()));
144 99
 		actionbar.addTab(detailsTab);
145 100
 	    
146 101
 		ActionBar.Tab payloadTab = actionbar.newTab().setText("Payload");
147  
-		payloadTab.setTabListener(new TabListener(payloadFragment, "payload"));
  102
+		payloadTab.setTabListener(new EditTabListener(payloadFragment, "payload", getSupportFragmentManager()));
148 103
 		actionbar.addTab(payloadTab);
149 104
 
150 105
 	    ActionBar.Tab rawPayloadTab = actionbar.newTab().setText("Raw Payload");
151  
-	    rawPayloadTab.setTabListener(new TabListener(rawPayloadFragment, "raw_payload"));
  106
+	    rawPayloadTab.setTabListener(new EditTabListener(rawPayloadFragment, "raw_payload", getSupportFragmentManager()));
152 107
 	    actionbar.addTab(rawPayloadTab);
153 108
 	    
154 109
 		if (savedInstanceState != null) {
@@ -156,49 +111,75 @@ private void setupActionbarTabs(Bundle savedInstanceState) {
156 111
         }
157 112
 	}
158 113
 	
  114
+	private void initState() {
  115
+		Intent intent = getIntent();
  116
+		this.actionMode = intent.getStringExtra("actionMode");
  117
+		long node_id = intent.getLongExtra("node_id", -1);	
159 118
 
160  
-	private class TabListener implements ActionBar.TabListener {
161  
-		Fragment fragment;
162  
-
163  
-		public TabListener(Fragment fragment, String tag) {
164  
-			this.fragment = fragment;
  119
+		String defaultTodo = PreferenceManager
  120
+				.getDefaultSharedPreferences(this).getString("defaultTodo", "");
  121
+		
  122
+		if (this.actionMode == null) {
  123
+			this.node = getCaptureIntentContents(intent);
  124
+			this.actionMode = ACTIONMODE_CREATE;
  125
+		} else if (this.actionMode.equals(ACTIONMODE_CREATE)) {
  126
+			this.node = new OrgNode();
  127
+		} else if (this.actionMode.equals(ACTIONMODE_EDIT)) {
  128
+			this.node = new OrgNode(node_id, getContentResolver());
  129
+		} else if (this.actionMode.equals(ACTIONMODE_ADDCHILD)) {
  130
+			this.node = new OrgNode(node_id, getContentResolver());
  131
+		}
165 132
 
166  
-			FragmentTransaction fragmentTransaction = getSupportFragmentManager()
167  
-					.beginTransaction();
  133
+		setOrgNode(this.node, defaultTodo);
  134
+	}
  135
+	
  136
+	public void setOrgNode(OrgNode node, String defaultTodo) {
  137
+		
  138
+		EditDetailsFragment detailsFragment = new EditDetailsFragment();
  139
+		detailsFragment.init(node, defaultTodo, resolver);
  140
+		
  141
+		FragmentTransaction beginTransaction = getSupportFragmentManager().beginTransaction();
  142
+		beginTransaction.replace(R.id.editnode_fragment_container, detailsFragment);
  143
+		beginTransaction.commit();
  144
+		this.detailsFragment = detailsFragment;
  145
+		
  146
+		this.payloadFragment.init(node.getCleanedPayload(), true);
  147
+		this.rawPayloadFragment.init(node.getRawPayload(), false);
  148
+	}
  149
+	
  150
+	public OrgNode getOrgNode() {
  151
+		return this.detailsFragment.getEditedOrgNode();
  152
+	}
168 153
 
169  
-			if (fragment != null && fragment.isAdded() == false) {
170  
-				fragmentTransaction.add(R.id.editnode_fragment_container,
171  
-						fragment, tag);
172  
-			}
173 154
 
174  
-			fragmentTransaction.hide(fragment).commit();
175  
-		}
  155
+	private static OrgNode getCaptureIntentContents(Intent intent) {
  156
+		String subject = intent
  157
+				.getStringExtra("android.intent.extra.SUBJECT");
  158
+		String text = intent.getStringExtra("android.intent.extra.TEXT");
176 159
 
177  
-		@Override
178  
-		public void onTabSelected(Tab tab, FragmentTransaction ft) {			
179  
-			FragmentTransaction fragmentTransaction = getSupportFragmentManager()
180  
-					.beginTransaction();
181  
-		    fragmentTransaction.show(fragment).commit();
  160
+		if(text != null && subject != null) {
  161
+			subject = "[[" + text + "][" + subject + "]]";
  162
+			text = "";
182 163
 		}
  164
+		
  165
+		if(subject == null)
  166
+			subject = "";
  167
+		if(text == null)
  168
+			text = "";
183 169
 
184  
-		@Override
185  
-		public void onTabUnselected(Tab tab, FragmentTransaction ft) {
186  
-			if (fragment != null) {
187  
-				FragmentTransaction fragmentTransaction = getSupportFragmentManager()
188  
-						.beginTransaction();
189  
-				fragmentTransaction.hide(fragment).commit();
190  
-			}
191  
-		}
  170
+		OrgNode node = new OrgNode();
  171
+		node.name = subject;
  172
+		node.payload = text;
  173
+		return node;
  174
+	}
192 175
 
193  
-		@Override
194  
-		public void onTabReselected(Tab tab, FragmentTransaction ft) {
195  
-		}
196  
-	};
  176
+	
  177
+	
197 178
 	
198 179
     @Override
199  
-	public boolean onCreateOptionsMenu(android.support.v4.view.Menu menu) {
  180
+	public boolean onPrepareOptionsMenu(Menu menu) {
200 181
     	super.onCreateOptionsMenu(menu);
201  
-		MenuInflater inflater = getMenuInflater();
  182
+		MenuInflater inflater = getSupportMenuInflater();
202 183
 	    inflater.inflate(R.menu.edit, menu);
203 184
 	    
204 185
 		if (this.node.id > -1) {
@@ -221,11 +202,11 @@ public boolean onCreateOptionsMenu(android.support.v4.view.Menu menu) {
221 202
 			subMenuItem.setIcon(R.drawable.ic_menu_moreoverflow);
222 203
 			subMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
223 204
 		}
224  
-		return true;
  205
+		return true;	
225 206
 	}
226  
-	
  207
+
227 208
 	@Override
228  
-	public boolean onOptionsItemSelected(android.support.v4.view.MenuItem item) {
  209
+	public boolean onOptionsItemSelected(MenuItem item) {
229 210
 		switch (item.getItemId()) {
230 211
 		case android.R.id.home:
231 212
 			doCancel();
@@ -344,17 +325,8 @@ private void insertChangesIntoPayloadResidue() {
344 325
 		node.getPayload().insertOrReplace("DEADLINE:", detailsFragment.getDeadline());
345 326
 	}
346 327
 	
347  
-	private OrgNode getNodeFromFragments() {
348  
-		OrgNode orgNode = new OrgNode();
349  
-		orgNode.name = this.detailsFragment.getTitle();
350  
-		orgNode.todo = this.detailsFragment.getTodo();
351  
-		orgNode.priority = this.detailsFragment.getPriority();
352  
-		orgNode.tags = this.detailsFragment.getTags();
353  
-		return orgNode;
354  
-	}
355  
-	
356 328
 	private void save() {
357  
-		OrgNode newNode = getNodeFromFragments();
  329
+		OrgNode newNode = this.detailsFragment.getEditedOrgNode();
358 330
 
359 331
 		if (this.actionMode.equals(ACTIONMODE_CREATE) || this.actionMode.equals(ACTIONMODE_ADDCHILD))
360 332
 			createNewNode(newNode);
111  src/com/matburt/mobileorg/Gui/Capture/EditDetailsFragment.java
@@ -7,11 +7,8 @@
7 7
 import android.content.ContentResolver;
8 8
 import android.content.Context;
9 9
 import android.os.Bundle;
10  
-import android.support.v4.app.Fragment;
11  
-import android.support.v4.view.Menu;
12 10
 import android.text.TextUtils;
13 11
 import android.view.LayoutInflater;
14  
-import android.view.MenuInflater;
15 12
 import android.view.View;
16 13
 import android.view.ViewGroup;
17 14
 import android.widget.ArrayAdapter;
@@ -20,12 +17,14 @@
20 17
 import android.widget.Spinner;
21 18
 import android.widget.TableLayout;
22 19
 
  20
+import com.actionbarsherlock.app.SherlockFragment;
  21
+import com.actionbarsherlock.view.MenuItem;
23 22
 import com.matburt.mobileorg.R;
24 23
 import com.matburt.mobileorg.Gui.Capture.DateTableRow.OrgTimeDate;
25 24
 import com.matburt.mobileorg.provider.OrgNode;
26 25
 import com.matburt.mobileorg.provider.OrgProviderUtil;
27 26
 
28  
-public class EditDetailsFragment extends Fragment {
  27
+public class EditDetailsFragment extends SherlockFragment {
29 28
 	private EditText titleView;
30 29
 	private Spinner priorityView;
31 30
 	private Spinner todoStateView;
@@ -35,9 +34,7 @@
35 34
 	private LocationTableRow locationTableRow;
36 35
 
37 36
 	private OrgNode node;
38  
-	private String actionMode;
39 37
 	
40  
-	private String title;
41 38
 	ArrayList<TagTableRow> tagEntries = new ArrayList<TagTableRow>();
42 39
 	private String defaultTodo;
43 40
 	private DateTableRow scheduledEntry = null;
@@ -45,19 +42,13 @@
45 42
 	
46 43
 	private ArrayList<String> tagsToRestore = null;
47 44
 	private ContentResolver resolver;
48  
-
49  
-	public void init(OrgNode node, String actionMode, String defaultTodo, String title, ContentResolver resolver) {
50  
-		init(node, actionMode, defaultTodo, resolver);
51  
-		this.title = title;
52  
-	}
53 45
 	
54  
-	public void init(OrgNode node, String actionMode, String defaultTodo, ContentResolver resolver) {
55  
-		this.actionMode = actionMode;
  46
+	public void init(OrgNode node, String defaultTodo, ContentResolver resolver) {
56 47
 		this.defaultTodo = defaultTodo;
57 48
 		this.resolver = resolver;
58 49
 		this.node = node;
59 50
 	}
60  
-	
  51
+
61 52
 	@Override
62 53
 	public View onCreateView(LayoutInflater inflater, ViewGroup container,
63 54
 			Bundle savedInstanceState) {
@@ -73,7 +64,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
73 64
 		this.locationView = (LinearLayout) view.findViewById(R.id.location);
74 65
 		
75 66
         setHasOptionsMenu(true);
76  
-        initDisplay();
  67
+        //updateDisplay();
77 68
         
78 69
 		if (savedInstanceState != null) {
79 70
 			setupScheduled(savedInstanceState.getString("scheduled"));
@@ -94,8 +85,11 @@ public void onStart() {
94 85
 			setupTags(tagsToRestore);
95 86
 			tagsToRestore = null;
96 87
 		}
  88
+		updateDisplay();
97 89
 	}
98 90
 	
  91
+	
  92
+	
99 93
 	@Override
100 94
 	public void onSaveInstanceState(Bundle outState) {
101 95
 		super.onSaveInstanceState(outState);
@@ -109,34 +103,23 @@ public void onSaveInstanceState(Bundle outState) {
109 103
         outState.putStringArrayList("tags", tags);
110 104
 	}
111 105
 
112  
-	private void initDisplay() {		
113  
-		if(this.actionMode == null) {
114  
-			this.actionMode = EditActivity.ACTIONMODE_CREATE;
115  
-			titleView.setText(title);
116  
-			titleView.setSelection(title.length());
  106
+	public void updateDisplay() {
  107
+		assert(node != null);
  108
+		assert(node.name != null);
  109
+		assert(titleView != null);
  110
+		titleView.setText(node.name);
  111
+		titleView.setSelection(node.name.length());
117 112
 
118  
-			setupSpinner(getActivity(), todoStateView, OrgProviderUtil.getTodos(resolver), defaultTodo);
119  
-			setupSpinner(getActivity(), priorityView, OrgProviderUtil.getPriorities(resolver), "");
120  
-			this.locationTableRow = new LocationTableRow(getActivity(), locationView, resolver);
121  
-		}
122  
-		else if (this.actionMode.equals(EditActivity.ACTIONMODE_EDIT)) {
123  
-			titleView.setText(node.name);
124  
-			titleView.setSelection(node.name.length());
125  
-			
126  
-			// TODO Fix taglist
127  
-			//setupTags(node.getTagList());
128  
-			setupDates();
129  
-			setupSpinner(getActivity(), todoStateView, OrgProviderUtil.getTodos(resolver), node.todo);
130  
-			setupSpinner(getActivity(), priorityView,OrgProviderUtil.getPriorities(resolver), node.priority);
131  
-			if(node.getParent(resolver) != null)
132  
-				this.locationTableRow = new LocationTableRow(node.getParent(resolver), getActivity(), locationView, resolver);
133  
-		} else { //if (this.actionMode.equals(EditActivity.ACTIONMODE_CREATE)) { // or ACTIONMODE_ADDPARENT
134  
-			titleView.setText("");
135  
-
136  
-			setupSpinner(getActivity(), todoStateView, OrgProviderUtil.getTodos(resolver), defaultTodo);
137  
-			setupSpinner(getActivity(), priorityView, OrgProviderUtil.getPriorities(resolver), "");
138  
-			this.locationTableRow = new LocationTableRow(node, getActivity(), locationView, resolver);
139  
-		}
  113
+		// TODO Fix taglist
  114
+		// setupTags(node.getTagList());
  115
+		setupDates();
  116
+		setupSpinner(getActivity(), todoStateView,
  117
+				OrgProviderUtil.getTodos(resolver), node.todo);
  118
+		setupSpinner(getActivity(), priorityView,
  119
+				OrgProviderUtil.getPriorities(resolver), node.priority);
  120
+		if (node.getParent(resolver) != null)
  121
+			this.locationTableRow = new LocationTableRow(
  122
+					node.getParent(resolver), getActivity(), locationView, resolver);
140 123
 	}
141 124
 	
142 125
 	private void setupTags(ArrayList<String> tagList) {		
@@ -212,14 +195,18 @@ public void onClick(View v) {
212 195
 	};
213 196
 	
214 197
     
  198
+	
  199
+	
215 200
 	@Override
216  
-	public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  201
+	public void onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu,
  202
+			com.actionbarsherlock.view.MenuInflater inflater) {
  203
+		// TODO Auto-generated method stub
217 204
 		super.onCreateOptionsMenu(menu, inflater);
218 205
 		inflater.inflate(R.menu.edit_details, menu);
219 206
 	}
220 207
 	
221 208
 	@Override
222  
-	public void onPrepareOptionsMenu(Menu menu) {
  209
+	public void onPrepareOptionsMenu(com.actionbarsherlock.view.Menu menu) {
223 210
 		super.onPrepareOptionsMenu(menu);
224 211
 		
225 212
 		if(this.scheduledEntry != null)
@@ -234,7 +221,7 @@ public void onPrepareOptionsMenu(Menu menu) {
234 221
 	}
235 222
 
236 223
 	@Override
237  
-	public boolean onOptionsItemSelected(android.support.v4.view.MenuItem item) {
  224
+	public boolean onOptionsItemSelected(MenuItem item) {
238 225
 		switch (item.getItemId()) {
239 226
 
240 227
 		case R.id.menu_nodeedit_tag:
@@ -276,22 +263,24 @@ public boolean hasEdits() {
276 263
 		String newTodo = todoStateView.getSelectedItem().toString();
277 264
 		String newPriority = priorityView.getSelectedItem().toString();
278 265
 		String newTags = getTags();
279  
-		if (this.actionMode.equals(EditActivity.ACTIONMODE_CREATE)) {
280  
-			if (newTitle.length() == 0)
281  
-				return false;
282  
-		} else if (this.actionMode.equals(EditActivity.ACTIONMODE_EDIT)) {
283  
-			
284  
-			if (newTitle.equals(node.name)
285  
-					&& newTodo.equals(node.todo)
286  
-					&& newTags.equals(node.tags)
287  
-					&& newPriority.equals(node.priority))
288  
-				return false;
289  
-		}	
  266
+
  267
+		if (newTitle.equals(node.name) && newTodo.equals(node.todo)
  268
+				&& newTags.equals(node.tags)
  269
+				&& newPriority.equals(node.priority))
  270
+			return false;
290 271
 		return true;
291 272
 	}
292 273
 	
  274
+	public OrgNode getEditedOrgNode() {
  275
+		OrgNode orgNode = new OrgNode();
  276
+		orgNode.name = getTitle();
  277
+		orgNode.todo = getTodo();
  278
+		orgNode.priority = getPriority();
  279
+		orgNode.tags = getTags();
  280
+		return orgNode;
  281
+	}
293 282
 	
294  
-	public String getTags() {
  283
+	private String getTags() {
295 284
 		StringBuilder result = new StringBuilder();
296 285
 		for(TagTableRow entry: tagEntries) {
297 286
 			String selection = entry.getSelection();
@@ -321,15 +310,15 @@ public String getDeadline() {
321 310
 			return "DEADLINE: <" + this.deadlineEntry.getDate() + ">";
322 311
 	}
323 312
 	
324  
-	public String getTitle() {
325  
-		return this.titleView.getText().toString();
  313
+	private String getTitle() {
  314
+		return titleView.getText().toString();
326 315
 	}
327 316
 	
328  
-	public String getTodo() {
  317
+	private String getTodo() {
329 318
 		return todoStateView.getSelectedItem().toString();
330 319
 	}
331 320
 	
332  
-	public String getPriority() {
  321
+	private String getPriority() {
333 322
 		return priorityView.getSelectedItem().toString();
334 323
 	}
335 324
 	
22  src/com/matburt/mobileorg/Gui/Capture/EditPayloadFragment.java
... ...
@@ -1,24 +1,24 @@
1 1
 package com.matburt.mobileorg.Gui.Capture;
2 2
 
3 3
 import android.os.Bundle;
4  
-import android.support.v4.app.Fragment;
5  
-import android.support.v4.view.Menu;
  4
+import android.text.InputFilter;
6 5
 import android.view.LayoutInflater;
7  
-import android.view.MenuInflater;
8 6
 import android.view.View;
9 7
 import android.view.ViewGroup;
10 8
 import android.widget.EditText;
11  
-import android.text.InputFilter;
12 9
 
  10
+import com.actionbarsherlock.app.SherlockFragment;
  11
+import com.actionbarsherlock.view.Menu;
  12
+import com.actionbarsherlock.view.MenuInflater;
  13
+import com.actionbarsherlock.view.MenuItem;
13 14
 import com.matburt.mobileorg.R;
14 15
 import com.matburt.mobileorg.util.OrgUtils;
15 16
 
16  
-public class EditPayloadFragment extends Fragment {
  17
+public class EditPayloadFragment extends SherlockFragment {
17 18
 	public static final String DISPLAY_STRING = "text";
18 19
 	public static final String RESULT_STRING = "text";
19 20
     private EditText editDisplay;
20 21
 
21  
-    private String orig_content;
22 22
     private String content;
23 23
 	private boolean enabled;
24 24
     
@@ -54,8 +54,9 @@ public String getText() {
54 54
 
55 55
 	public boolean hasEdits() {
56 56
             return (!getText().equals(content));
57  
-        }
58  
-        
  57
+    }
  58
+	
  59
+	
59 60
 	@Override
60 61
 	public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
61 62
 		super.onCreateOptionsMenu(menu, inflater);
@@ -63,13 +64,14 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
63 64
 	}
64 65
 
65 66
 	@Override
66  
-	public boolean onOptionsItemSelected(android.support.v4.view.MenuItem item) {
  67
+	public boolean onOptionsItemSelected(MenuItem item) {
  68
+		// TODO Auto-generated method stub
67 69
 		switch (item.getItemId()) {
68 70
 		case R.id.nodeeditbody_timestamp:
69 71
 			insertTimestamp();
70 72
 			return true;
71 73
 		}
72  
-		return false;
  74
+		return false;	
73 75
 	}
74 76
 	
75 77
 	public void insertTimestamp() {
53  src/com/matburt/mobileorg/Gui/Capture/EditTabListener.java
... ...
@@ -0,0 +1,53 @@
  1
+package com.matburt.mobileorg.Gui.Capture;
  2
+
  3
+import android.support.v4.app.Fragment;
  4
+import android.support.v4.app.FragmentManager;
  5
+import android.support.v4.app.FragmentTransaction;
  6
+
  7
+import com.actionbarsherlock.app.ActionBar.Tab;
  8
+import com.actionbarsherlock.app.ActionBar.TabListener;
  9
+import com.matburt.mobileorg.R;
  10
+
  11
+class EditTabListener implements TabListener {
  12
+	Fragment fragment;
  13
+	FragmentManager manager;
  14
+
  15
+	public EditTabListener(Fragment fragment, String tag, FragmentManager manager) {
  16
+		this.fragment = fragment;
  17
+		this.manager = manager;
  18
+
  19
+		FragmentTransaction fragmentTransaction = manager.beginTransaction();
  20
+
  21
+		if (fragment != null && fragment.isAdded() == false) {
  22
+			fragmentTransaction.add(R.id.editnode_fragment_container,
  23
+					fragment, tag);
  24
+		}
  25
+
  26
+		fragmentTransaction.hide(fragment).commit();
  27
+	}
  28
+
  29
+	@Override
  30
+	public void onTabSelected(Tab tab, FragmentTransaction ft) {			
  31
+		FragmentTransaction fragmentTransaction = manager.beginTransaction();
  32
+	    fragmentTransaction.show(fragment).commit();
  33
+	}
  34
+
  35
+	@Override
  36
+	public void onTabUnselected(Tab tab, FragmentTransaction ft) {
  37
+		if (fragment != null) {
  38
+			FragmentTransaction fragmentTransaction = manager.beginTransaction();
  39
+			fragmentTransaction.hide(fragment).commit();
  40
+		}
  41
+	}
  42
+	
  43
+	public void replaceFragment(Fragment fragment, String tag) {
  44
+		FragmentTransaction fragmentTransaction = manager.beginTransaction();
  45
+		fragmentTransaction.remove(this.fragment);
  46
+		fragmentTransaction.add(R.id.editnode_fragment_container, fragment, tag);
  47
+		fragmentTransaction.commit();
  48
+	}
  49
+
  50
+	@Override
  51
+	public void onTabReselected(Tab tab, FragmentTransaction ft) {
  52
+	}
  53
+};
17  src/com/matburt/mobileorg/Gui/NodeViewActivity.java
@@ -14,21 +14,22 @@
14 14
 import android.net.Uri;
15 15
 import android.os.Bundle;
16 16
 import android.preference.PreferenceManager;
17  
-import android.support.v4.app.FragmentActivity;
18  
-import android.support.v4.view.Window;
19 17
 import android.util.Log;
20  
-import android.view.MenuInflater;
21 18
 import android.view.WindowManager;
22 19
 import android.webkit.WebView;
23 20
 import android.webkit.WebViewClient;
24 21
 
  22
+import com.actionbarsherlock.app.SherlockFragmentActivity;
  23
+import com.actionbarsherlock.view.Menu;
  24
+import com.actionbarsherlock.view.MenuItem;
  25
+import com.actionbarsherlock.view.Window;
25 26
 import com.matburt.mobileorg.R;
26 27
 import com.matburt.mobileorg.Gui.Capture.EditActivity;
27 28
 import com.matburt.mobileorg.Parsing.MobileOrgApplication;
28 29
 import com.matburt.mobileorg.Parsing.NodeWrapper;
29 30
 import com.matburt.mobileorg.Synchronizers.Synchronizer;
30 31
 
31  
-public class NodeViewActivity extends FragmentActivity {
  32
+public class NodeViewActivity extends SherlockFragmentActivity {
32 33
 	private WebView display;
33 34
 	private MobileOrgApplication appInst;
34 35
 	private SynchServiceReceiver syncReceiver;
@@ -81,9 +82,11 @@ private void refreshDisplay() {
81 82
 		this.display.loadDataWithBaseURL(null, data, "text/html", "UTF-8", null);
82 83
 	}
83 84
 	
  85
+	
  86
+	
84 87
 	@Override
85  
-	public boolean onCreateOptionsMenu(android.support.v4.view.Menu menu) {
86  
-		MenuInflater inflater = getMenuInflater();
  88
+	public boolean onCreateOptionsMenu(Menu menu) {
  89
+		com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater();
87 90
 	    inflater.inflate(R.menu.nodeview, menu);
88 91
 	    
89 92
 	    if(this.appInst.getDB().isNodeEditable(node_id) == false)
@@ -93,7 +96,7 @@ public boolean onCreateOptionsMenu(android.support.v4.view.Menu menu) {
93 96
 	}
94 97
 
95 98
 	@Override
96  
-	public boolean onOptionsItemSelected(android.support.v4.view.MenuItem item) {
  99
+	public boolean onOptionsItemSelected(MenuItem item) {
97 100
 		switch (item.getItemId()) {
98 101
 		case android.R.id.home:
99 102
 			finish();
32  src/com/matburt/mobileorg/Gui/OutlineActivity.java
@@ -18,14 +18,10 @@
18 18
 import android.net.Uri;
19 19
 import android.os.Bundle;
20 20
 import android.preference.PreferenceManager;
21  
-import android.support.v4.app.FragmentActivity;
22  
-import android.support.v4.view.Window;
23 21
 import android.util.Log;
24 22
 import android.view.LayoutInflater;
25  
-import android.view.MenuInflater;
26 23
 import android.view.View;
27 24
 import android.view.ViewGroup;
28  
-import android.view.WindowManager;
29 25
 import android.widget.AdapterView;
30 26
 import android.widget.AdapterView.OnItemClickListener;
31 27
 import android.widget.AdapterView.OnItemLongClickListener;
@@ -34,6 +30,10 @@
34 30
 import android.widget.TextView;
35 31
 import android.widget.Toast;
36 32
 
  33
+import com.actionbarsherlock.app.SherlockActivity;
  34
+import com.actionbarsherlock.view.Menu;
  35
+import com.actionbarsherlock.view.MenuInflater;
  36
+import com.actionbarsherlock.view.MenuItem;
37 37
 import com.matburt.mobileorg.R;
38 38
 import com.matburt.mobileorg.Gui.Capture.EditActivity;
39 39
 import com.matburt.mobileorg.Parsing.MobileOrgApplication;
@@ -44,7 +44,7 @@
44 44
 import com.matburt.mobileorg.Synchronizers.Synchronizer;
45 45
 import com.matburt.mobileorg.provider.OrgContract.OrgData;
46 46
 
47  
-public class OutlineActivity extends FragmentActivity
  47
+public class OutlineActivity extends SherlockActivity
48 48
 {
49 49
     private MobileOrgApplication appInst;
50 50
 
@@ -66,14 +66,7 @@
66 66
 	@Override
67 67
 	protected void onCreate(Bundle savedInstanceState) {
68 68
 		super.onCreate(savedInstanceState);
69  
-		
70  
-		SharedPreferences appSettings = PreferenceManager
71  
-				.getDefaultSharedPreferences(getBaseContext());
72  
-		if (appSettings.getBoolean("fullscreen", true)) {
73  
-			requestWindowFeature(Window.FEATURE_NO_TITLE);
74  
-			getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
75  
-					WindowManager.LayoutParams.FLAG_FULLSCREEN);
76  
-		}
  69
+
77 70
 		setContentView(R.layout.outline);		
78 71
 		
79 72
 		this.appInst = (MobileOrgApplication) this.getApplication();
@@ -125,9 +118,12 @@ protected void onDestroy() {
125 118
 	 * data has been updated.
126 119
 	 */
127 120
 	private void refreshDisplay() {
  121
+		final String outlineSort = node_id > 0 ? OrgData.DEFAULT_SORT 
  122
+											   : OrgData.NAME_SORT;
  123
+		
128 124
 		Cursor cursor = getContentResolver().query(
129 125
 				OrgData.buildChildrenUri(node_id.toString()),
130  
-				OrgData.DEFAULT_COLUMNS, null, null, OrgData.DEFAULT_SORT);
  126
+				OrgData.DEFAULT_COLUMNS, null, null, outlineSort);
131 127
 
132 128
 		if (node_id >= 0) {
133 129
 			if(cursor.getCount() == 0)
@@ -160,13 +156,13 @@ private void setTitle() {
160 156
 		if(this.node_id > -1) {
161 157
 			NodeWrapper node = new NodeWrapper(this.node_id, appInst.getDB());
162 158
 			final String subTitle = node.constructOlpId().substring("olp:".length());
163  
-			this.getSupportActionBar().setSubtitle(subTitle);
  159
+			//this.getSherlock().setSubtitle(subTitle);
164 160
 		}
165 161
 	}
166 162
 
167 163
 	@Override
168  
-	public boolean onCreateOptionsMenu(android.support.v4.view.Menu menu) {
169  
-		MenuInflater inflater = getMenuInflater();
  164
+	public boolean onCreateOptionsMenu(Menu menu) {
  165
+		MenuInflater inflater = getSupportMenuInflater();
170 166
 	    inflater.inflate(R.menu.outline_menu, menu);
171 167
 	    
172 168
 	    if(this.node_id == -1 || isNodeInFile(this.node_id, "agendas.org"))
@@ -176,7 +172,7 @@ public boolean onCreateOptionsMenu(android.support.v4.view.Menu menu) {
176 172
 	}
177 173
 
178 174
 	@Override
179  
-	public boolean onOptionsItemSelected(android.support.v4.view.MenuItem item) {
  175
+	public boolean onOptionsItemSelected(MenuItem item) {
180 176
 		switch (item.getItemId()) {
181 177
 		case android.R.id.home:
182 178
 			if(this.node_id != -1)
2  src/com/matburt/mobileorg/provider/OrgContract.java
@@ -87,6 +87,8 @@ public static Uri buildChildrenUri(long node_id) {
87 87
 			return buildChildrenUri(Long.toString(node_id));
88 88
 		}
89 89
 		public static final String DEFAULT_SORT = ID + " ASC";
  90
+		public static final String NAME_SORT = NAME + " ASC";
  91
+
90 92
 		
91 93
 		public static final String[] DEFAULT_COLUMNS = { ID, NAME, TODO, TAGS,
92 94
 				PARENT_ID, PAYLOAD, LEVEL, PRIORITY, FILE_ID };
8  src/com/matburt/mobileorg/util/OrgUtils.java
@@ -3,10 +3,18 @@
3 3
 import java.text.SimpleDateFormat;
4 4
 import java.util.Date;
5 5
 
  6
+import android.content.Context;
  7
+import android.preference.PreferenceManager;
  8
+
6 9
 public class OrgUtils {
7 10
 	
8 11
 	public static String getTimestamp() {
9 12
 		SimpleDateFormat sdf = new SimpleDateFormat("[yyyy-MM-dd EEE HH:mm]");		
10 13
 		return sdf.format(new Date());
11 14
 	}
  15
+	
  16
+	public static String getDefaultTodo(Context context) {
  17
+		return PreferenceManager.getDefaultSharedPreferences(context)
  18
+				.getString("defaultTodo", "");
  19
+	}
12 20
 }

0 notes on commit 8ca172d

Please sign in to comment.
Something went wrong with that request. Please try again.