Customization of task edit activity layout

pull/14/head
Sam Bosley 14 years ago
parent 36621ab281
commit 1741dd34ee

@ -247,6 +247,14 @@
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="com.todoroo.astrid.activity.BeastModePreferenceActivity"
android:theme="@android:style/Theme">
<intent-filter>
<action android:name="com.todoroo.astrid.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.todoroo.astrid.core.OldTaskPreferences" <activity android:name="com.todoroo.astrid.core.OldTaskPreferences"
android:theme="@android:style/Theme" android:theme="@android:style/Theme"
android:label="@string/EPr_manage_header"> android:label="@string/EPr_manage_header">

@ -0,0 +1,29 @@
<?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.commonsware.cwac.tlv.TouchListView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tlv="http://schemas.android.com/apk/res/com.timsu.astrid"
android:id="@android:id/list"
android:scrollbars="vertical"
android:cacheColorHint="#00000000"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:drawSelectorOnTop="false"
tlv:normal_height="52dip"
tlv:grabber="@+id/grabber" />
<Button
android:id="@+id/reset"
android:layout_width="fill_parent"
android:layout_height="100dip"
android:text="@string/EPr_beastMode_reset"
android:layout_weight="1"/>
</LinearLayout>

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- See the file "LICENSE" for the full license governing this code. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:astrid="http://schemas.android.com/apk/res/com.timsu.astrid"
android:layout_width="fill_parent"
android:layout_height="52dip"
android:paddingTop="2dip"
android:paddingBottom="2dip"
android:paddingLeft="4dip"
android:paddingRight="4dip"
android:gravity="center"
android:orientation="horizontal">
<!-- grabber -->
<ImageView android:id="@+id/grabber"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:scaleType="center"
android:src="@drawable/grabber"/>
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:paddingRight="5dip"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</LinearLayout>

@ -346,6 +346,32 @@
<item>Specific Day/Time</item> <item>Specific Day/Time</item>
</string-array> </string-array>
<!-- Task edit control set descriptors -->
<string name="TEA_control_title">Task Title</string>
<string name="TEA_control_who">Who</string>
<string name="TEA_control_when">When</string>
<string name="TEA_control_more_section">More Section</string>
<string name="TEA_control_importance">Importance</string>
<string name="TEA_control_lists">Lists</string>
<string name="TEA_control_notes">Notes</string>
<string name="TEA_control_reminders">Reminders</string>
<string name="TEA_control_timer">Timer Controls</string>
<string name="TEA_control_share">Share With Friends</string>
<string-array name="TEA_control_sets">
<item>@string/TEA_control_title</item>
<item>@string/TEA_control_who</item>
<item>@string/TEA_control_when</item>
<item>@string/TEA_control_more_section</item>
<item>@string/TEA_control_importance</item>
<item>@string/TEA_control_lists</item>
<item>@string/TEA_control_notes</item>
<item>@string/TEA_control_reminders</item>
<item>@string/TEA_control_timer</item>
<item>@string/TEA_control_share</item>
</string-array>
<string name="hide_until_prompt">Show in my list</string> <string name="hide_until_prompt">Show in my list</string>
<!-- Add Ons tab when no add-ons found --> <!-- Add Ons tab when no add-ons found -->
@ -402,8 +428,8 @@
<string name="EPr_showNotes_title">Show Notes In Task</string> <string name="EPr_showNotes_title">Show Notes In Task</string>
<!-- Preference: Beast mode (auto-expand edit page) --> <!-- Preference: Beast mode (auto-expand edit page) -->
<string name="EPr_beastMode_title">Beast Mode</string> <string name="EPr_beastMode_title">Beast Mode</string>
<string name="EPr_beastMode_desc_disabled">Advanced task edit settings will start hidden</string> <string name="EPr_beastMode_desc">Customize the layout of the Task Edit Page</string>
<string name="EPr_beastMode_desc_enabled">Advanced task edit settings will show automatically</string> <string name="EPr_beastMode_reset">Reset to defaults</string>
<!-- Preference: Task List Show Notes Description (disabled) --> <!-- Preference: Task List Show Notes Description (disabled) -->
<string name="EPr_showNotes_desc_disabled">Notes will be displayed in quick action bar</string> <string name="EPr_showNotes_desc_disabled">Notes will be displayed in quick action bar</string>

@ -14,10 +14,7 @@
android:title="@string/EPr_fontSize_title" android:title="@string/EPr_fontSize_title"
android:summary="@string/EPr_fontSize_desc" /> android:summary="@string/EPr_fontSize_desc" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference <PreferenceScreen android:title="" android:key="@string/p_beastMode" android:summary="@string/EPr_beastMode_desc"/>
android:key="@string/p_beastMode"
android:title="@string/EPr_beastMode_title"
android:defaultValue="false"/>
<com.todoroo.astrid.ui.MultilineCheckboxPreference <com.todoroo.astrid.ui.MultilineCheckboxPreference
android:key="@string/p_showNotes" android:key="@string/p_showNotes"

@ -0,0 +1,96 @@
package com.todoroo.astrid.activity;
import java.util.ArrayList;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import com.commonsware.cwac.tlv.TouchListView;
import com.commonsware.cwac.tlv.TouchListView.DropListener;
import com.timsu.astrid.R;
import com.todoroo.andlib.utility.Preferences;
public class BeastModePreferenceActivity extends ListActivity {
private TouchListView touchList;
private ArrayAdapter<String> adapter;
private ArrayList<String> items;
public static final String BEAST_MODE_ORDER_PREF = "beast_mode_order"; //$NON-NLS-1$
public static final String BEAST_MODE_PREF_ITEM_SEPARATOR = ";"; //$NON-NLS-1$
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.beast_mode_pref_activity);
setTitle(R.string.EPr_beastMode_desc);
touchList = (TouchListView) getListView();
String order = Preferences.getStringValue(BEAST_MODE_ORDER_PREF);
String[] itemsArray;
if (order == null) {
itemsArray = getResources().getStringArray(R.array.TEA_control_sets);
} else {
itemsArray = order.split(BEAST_MODE_PREF_ITEM_SEPARATOR);
}
items = new ArrayList<String>();
for (String s : itemsArray) {
items.add(s);
}
adapter = new ArrayAdapter<String>(this, R.layout.preference_draggable_row, R.id.text, items);
touchList.setAdapter(adapter);
touchList.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
});
touchList.setDropListener(new DropListener() {
@Override
public void drop(int from, int to) {
String s = items.remove(from);
items.add(to, s);
adapter.notifyDataSetChanged();
}
});
Button resetButton = (Button) findViewById(R.id.reset);
resetButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resetToDefault();
}
});
}
private void resetToDefault() {
String[] itemsArray = getResources().getStringArray(R.array.TEA_control_sets);
while (items.size() > 0)
items.remove(0);
for (String s : itemsArray)
items.add(s);
adapter.notifyDataSetChanged();
}
@Override
public void finish() {
StringBuilder newSetting = new StringBuilder(30);
for (int i = 0; i < adapter.getCount(); i++) {
newSetting.append(adapter.getItem(i));
newSetting.append(BEAST_MODE_PREF_ITEM_SEPARATOR);
}
Preferences.setString(BEAST_MODE_ORDER_PREF, newSetting.toString());
super.finish();
}
}

@ -62,6 +62,7 @@ public class EditPreferences extends TodorooPreferenceActivity {
private static final int ABOUT_PREFERENCE = 0; // see preferences.xml for order of prefs private static final int ABOUT_PREFERENCE = 0; // see preferences.xml for order of prefs
private static final int HELP_PREFERENCE = 1; private static final int HELP_PREFERENCE = 1;
private static final int APPEARANCE_PREFERENCE = 2;
private static final int POWER_PACK_PREFERENCE = 3; private static final int POWER_PACK_PREFERENCE = 3;
public static final int RESULT_CODE_THEME_CHANGED = 1; public static final int RESULT_CODE_THEME_CHANGED = 1;
@ -119,6 +120,17 @@ public class EditPreferences extends TodorooPreferenceActivity {
} }
}); });
PreferenceCategory appearance = (PreferenceCategory) screen.getPreference(APPEARANCE_PREFERENCE);
Preference beastMode = appearance.getPreference(1);
beastMode.setTitle(r.getString(R.string.EPr_beastMode_title));
beastMode.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference p) {
showBeastMode();
return true;
}
});
addDebugPreferences(); addDebugPreferences();
addPreferenceListeners(); addPreferenceListeners();
@ -142,6 +154,12 @@ public class EditPreferences extends TodorooPreferenceActivity {
startActivity(intent); startActivity(intent);
} }
private void showBeastMode() {
Intent intent = new Intent(this, BeastModePreferenceActivity.class);
intent.setAction(AstridApiConstants.ACTION_SETTINGS);
startActivity(intent);
}
private void addPluginPreferences(PreferenceScreen screen) { private void addPluginPreferences(PreferenceScreen screen) {
Intent queryIntent = new Intent(AstridApiConstants.ACTION_SETTINGS); Intent queryIntent = new Intent(AstridApiConstants.ACTION_SETTINGS);
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
@ -272,11 +290,6 @@ public class EditPreferences extends TodorooPreferenceActivity {
preference.setSummary(getString(R.string.EPr_theme_desc, preference.setSummary(getString(R.string.EPr_theme_desc,
r.getStringArray(R.array.EPr_themes)[index])); r.getStringArray(R.array.EPr_themes)[index]));
} }
} else if (r.getString(R.string.p_beastMode).equals(preference.getKey())) {
if (value != null && !(Boolean)value)
preference.setSummary(R.string.EPr_beastMode_desc_disabled);
else
preference.setSummary(R.string.EPr_beastMode_desc_enabled);
} }
// statistics service // statistics service
else if (r.getString(R.string.p_statistics).equals(preference.getKey())) { else if (r.getString(R.string.p_statistics).equals(preference.getKey())) {

@ -21,6 +21,7 @@ package com.todoroo.astrid.activity;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import android.app.Activity; import android.app.Activity;
@ -258,21 +259,25 @@ public final class TaskEditActivity extends Activity {
constructWhenDialog(whenDialogView); constructWhenDialog(whenDialogView);
HashMap<String, TaskEditControlSet> controlSetMap = new HashMap<String, TaskEditControlSet>();
// populate control set // populate control set
EditTitleControlSet editTitle = new EditTitleControlSet(this, R.layout.control_set_title, Task.TITLE, R.id.title); EditTitleControlSet editTitle = new EditTitleControlSet(this, R.layout.control_set_title, Task.TITLE, R.id.title);
title = (EditText) editTitle.getView().findViewById(R.id.title); title = (EditText) editTitle.getView().findViewById(R.id.title);
controls.add(editTitle); controls.add(editTitle);
basicControls.addView(editTitle.getView()); //basicControls.addView(editTitle.getDisplayView());
controlSetMap.put(getString(R.string.TEA_control_title), editTitle);
TimerActionControlSet timerAction = new TimerActionControlSet(this, editTitle.getView()); TimerActionControlSet timerAction = new TimerActionControlSet(this, editTitle.getView());
controls.add(timerAction); controls.add(timerAction);
controls.add(peopleControlSet = new EditPeopleControlSet(TaskEditActivity.this, R.layout.control_set_assigned, R.layout.control_set_assigned_display, R.string.actfm_EPA_assign_label, REQUEST_LOG_IN)); controls.add(peopleControlSet = new EditPeopleControlSet(TaskEditActivity.this, R.layout.control_set_assigned, R.layout.control_set_assigned_display, R.string.actfm_EPA_assign_label, REQUEST_LOG_IN));
basicControls.addView(peopleControlSet.getDisplayView()); //basicControls.addView(peopleControlSet.getDisplayView());
controlSetMap.put(getString(R.string.TEA_control_who), peopleControlSet);
UrgencyControlSet urgencyControl = new UrgencyControlSet(TaskEditActivity.this, R.layout.control_set_urgency, R.id.when_header, R.id.aux_date, R.id.when_label, R.id.when_image); UrgencyControlSet urgencyControl = new UrgencyControlSet(TaskEditActivity.this, R.layout.control_set_urgency, R.id.when_header, R.id.aux_date, R.id.when_label, R.id.when_image);
controls.add(urgencyControl); controls.add(urgencyControl);
whenControls.addView(urgencyControl.getView()); whenControls.addView(urgencyControl.getDisplayView());
RepeatControlSet repeatControls = new RepeatControlSet(TaskEditActivity.this, R.layout.control_set_repeat, R.layout.control_set_repeat_display, R.string.repeat_enabled); RepeatControlSet repeatControls = new RepeatControlSet(TaskEditActivity.this, R.layout.control_set_repeat, R.layout.control_set_repeat_display, R.string.repeat_enabled);
@ -290,27 +295,32 @@ public final class TaskEditActivity extends Activity {
ImportanceControlSet importanceControl = new ImportanceControlSet(TaskEditActivity.this, R.layout.control_set_importance); ImportanceControlSet importanceControl = new ImportanceControlSet(TaskEditActivity.this, R.layout.control_set_importance);
controls.add(importanceControl); controls.add(importanceControl);
importanceControl.addListener(editTitle); importanceControl.addListener(editTitle);
moreControls.addView(importanceControl.getView()); //moreControls.addView(importanceControl.getDisplayView());
controlSetMap.put(getString(R.string.TEA_control_importance), importanceControl);
TagsControlSet tagsControl = new TagsControlSet(TaskEditActivity.this, R.layout.control_set_tags, R.layout.control_set_tags_display, R.string.TEA_tags_label); TagsControlSet tagsControl = new TagsControlSet(TaskEditActivity.this, R.layout.control_set_tags, R.layout.control_set_tags_display, R.string.TEA_tags_label);
controls.add(tagsControl); controls.add(tagsControl);
moreControls.addView(tagsControl.getDisplayView()); //moreControls.addView(tagsControl.getDisplayView());
controlSetMap.put(getString(R.string.TEA_control_lists), tagsControl);
notesControlSet = new EditNotesControlSet(TaskEditActivity.this, R.layout.control_set_notes, R.layout.control_set_notes_display); notesControlSet = new EditNotesControlSet(TaskEditActivity.this, R.layout.control_set_notes, R.layout.control_set_notes_display);
notesEditText = (EditText) notesControlSet.getView().findViewById(R.id.notes); notesEditText = (EditText) notesControlSet.getView().findViewById(R.id.notes);
controls.add(notesControlSet); controls.add(notesControlSet);
moreControls.addView(notesControlSet.getDisplayView()); //moreControls.addView(notesControlSet.getDisplayView());
controlSetMap.put(getString(R.string.TEA_control_notes), notesControlSet);
ReminderControlSet reminderControl = new ReminderControlSet(TaskEditActivity.this, R.layout.control_set_reminders, R.layout.control_set_reminders_display); ReminderControlSet reminderControl = new ReminderControlSet(TaskEditActivity.this, R.layout.control_set_reminders, R.layout.control_set_reminders_display);
controls.add(reminderControl); controls.add(reminderControl);
moreControls.addView(reminderControl.getDisplayView()); //moreControls.addView(reminderControl.getDisplayView());
controlSetMap.put(getString(R.string.TEA_control_reminders), reminderControl);
TimerControlSet timerControl = new TimerControlSet(TaskEditActivity.this, R.layout.control_set_timers, R.layout.control_set_timers_extras_display, R.string.TEA_timer_controls); TimerControlSet timerControl = new TimerControlSet(TaskEditActivity.this, R.layout.control_set_timers, R.layout.control_set_timers_extras_display, R.string.TEA_timer_controls);
timerAction.setListener(timerControl); timerAction.setListener(timerControl);
controls.add(timerControl); controls.add(timerControl);
moreControls.addView(timerControl.getDisplayView()); //moreControls.addView(timerControl.getDisplayView());
controlSetMap.put(getString(R.string.TEA_control_timer), timerControl);
moreControls.addView(peopleControlSet.getSharedWithRow()); //moreControls.addView(peopleControlSet.getSharedWithRow());
try { try {
if(ProducteevUtilities.INSTANCE.isLoggedIn()) { if(ProducteevUtilities.INSTANCE.isLoggedIn()) {
@ -336,14 +346,38 @@ public final class TaskEditActivity extends Activity {
Log.e("astrid-error", "loading-control-set", e); //$NON-NLS-1$ //$NON-NLS-2$ Log.e("astrid-error", "loading-control-set", e); //$NON-NLS-1$ //$NON-NLS-2$
} }
boolean beastMode = Preferences.getBoolean(R.string.p_beastMode, false);
if (beastMode) {
LinearLayout moreHeader = (LinearLayout) findViewById(R.id.more_header);
moreHeader.setVisibility(View.GONE);
whenControls.setVisibility(View.VISIBLE); String[] itemOrder;
moreControls.setVisibility(View.VISIBLE); String orderPreference = Preferences.getStringValue(BeastModePreferenceActivity.BEAST_MODE_ORDER_PREF);
if (orderPreference != null)
itemOrder = orderPreference.split(BeastModePreferenceActivity.BEAST_MODE_PREF_ITEM_SEPARATOR);
else
itemOrder = getResources().getStringArray(R.array.TEA_control_sets);
String moreSectionTrigger = getString(R.string.TEA_control_more_section);
String whenViewDescriptor = getString(R.string.TEA_control_when);
View whenView = findViewById(R.id.when_container);
String shareViewDescriptor = getString(R.string.TEA_control_share);
LinearLayout section = basicControls;
for (int i = 0; i < itemOrder.length; i++) {
String item = itemOrder[i];
if (item.equals(moreSectionTrigger)) {
section = moreControls;
} else {
TaskEditControlSet curr = controlSetMap.get(item);
if (item.equals(shareViewDescriptor))
section.addView(peopleControlSet.getSharedWithRow());
else if (item.equals(whenViewDescriptor)) {
LinearLayout parent = (LinearLayout) whenView.getParent();
parent.removeView(whenView);
section.addView(whenView);
} else if (curr != null)
section.addView(curr.getDisplayView());
}
} }
if (moreControls.getChildCount() == 0)
findViewById(R.id.more_header).setVisibility(View.GONE);
// Load task data in background // Load task data in background
new TaskEditBackgroundLoader().start(); new TaskEditBackgroundLoader().start();

@ -26,6 +26,10 @@ public abstract class TaskEditControlSet {
return view; return view;
} }
public View getDisplayView() {
return getView();
}
/** /**
* Read data from model to update the control set * Read data from model to update the control set
*/ */

Loading…
Cancel
Save