Merge pull request #117 from sbosley/120110_sb_dynamically_generated_fragments

Bug fixes to fragment lifecycles, especially when rotating
pull/14/head
sbosley 13 years ago
commit bbde5fb531

@ -17,6 +17,7 @@ public class FilterWithCustomIntent extends Filter {
* Custom activity name
*/
public ComponentName customTaskList = null;
public ComponentName customWrapperActivity = null;
/**
* Bundle with extras set. Can be null
@ -40,7 +41,7 @@ public class FilterWithCustomIntent extends Filter {
public Intent getCustomIntent() {
Intent intent = new Intent();
intent.putExtra("filter", this); //$NON-NLS-1$
intent.setComponent(customTaskList);
intent.setComponent(customWrapperActivity);
if(customExtras != null)
intent.putExtras(customExtras);
@ -68,6 +69,7 @@ public class FilterWithCustomIntent extends Filter {
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeParcelable(customTaskList, 0);
dest.writeParcelable(customWrapperActivity, 0);
dest.writeParcelable(customExtras, 0);
}
@ -75,6 +77,7 @@ public class FilterWithCustomIntent extends Filter {
public void readFromParcel(Parcel source) {
super.readFromParcel(source);
customTaskList = source.readParcelable(ComponentName.class.getClassLoader());
customWrapperActivity = source.readParcelable(ComponentName.class.getClassLoader());
customExtras = source.readParcelable(Bundle.class.getClassLoader());
}

@ -95,8 +95,8 @@ public class TagViewActivity extends TaskListActivity {
// --- UI initialization
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
public void onActivityCreated(final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getListView().setOnKeyListener(null);
@ -271,14 +271,17 @@ public class TagViewActivity extends TaskListActivity {
String oldName = tagData.getValue(TagData.NAME);
actFmSyncService.fetchTag(tagData);
DialogUtilities.dismissDialog(getActivity(), progressDialog);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if(noRemoteId && tagData.getValue(TagData.REMOTE_ID) > 0)
refreshData(manual, true);
}
});
Activity activity = getActivity();
if (activity != null) {
DialogUtilities.dismissDialog(activity, progressDialog);
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if(noRemoteId && tagData.getValue(TagData.REMOTE_ID) > 0)
refreshData(manual, true);
}
});
}
if(!oldName.equals(tagData.getValue(TagData.NAME))) {
TagService.getInstance().rename(oldName,
@ -304,27 +307,33 @@ public class TagViewActivity extends TaskListActivity {
actFmSyncService.fetchTasksForTag(tagData, manual, new Runnable() {
@Override
public void run() {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
loadTaskListContent(true);
((TextView)taskListView.findViewById(android.R.id.empty)).setText(R.string.TLA_no_items);
DialogUtilities.dismissDialog(getActivity(), progressDialog);
}
});
final Activity activity = getActivity();
if (activity != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
loadTaskListContent(true);
((TextView)taskListView.findViewById(android.R.id.empty)).setText(R.string.TLA_no_items);
DialogUtilities.dismissDialog(activity, progressDialog);
}
});
}
}
});
actFmSyncService.fetchUpdatesForTag(tagData, manual, new Runnable() {
@Override
public void run() {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
//refreshUpdatesList();
DialogUtilities.dismissDialog(getActivity(), progressDialog);
}
});
final Activity activity = getActivity();
if (activity != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
//refreshUpdatesList();
DialogUtilities.dismissDialog(activity, progressDialog);
}
});
}
}
});
@ -352,7 +361,7 @@ public class TagViewActivity extends TaskListActivity {
} catch (JSONException e) {
e.printStackTrace();
}
getActivity().findViewById(R.id.filter_assigned).setOnClickListener(new OnClickListener() {
getView().findViewById(R.id.filter_assigned).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
resetAssignedFilter();

@ -23,6 +23,7 @@ import com.todoroo.andlib.sql.Join;
import com.todoroo.andlib.sql.Order;
import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.activity.TaskListWrapperActivity;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.AstridFilterExposer;
import com.todoroo.astrid.api.Filter;
@ -71,6 +72,7 @@ public class GtasksFilterExposer extends BroadcastReceiver implements AstridFilt
values);
filter.listingIcon = ((BitmapDrawable)context.getResources().getDrawable(R.drawable.gtasks_icon)).getBitmap();
filter.customTaskList = new ComponentName(ContextManager.getContext(), GtasksListActivity.class);
filter.customWrapperActivity = new ComponentName(ContextManager.getContext(), TaskListWrapperActivity.class);
Bundle extras = new Bundle();
extras.putBoolean(TaskListActivity.TOKEN_OVERRIDE_ANIM, true);
filter.customExtras = extras;

@ -101,7 +101,6 @@ public class RepeatControlSet extends PopupControlSet {
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
checkBox.setPadding(0, 0, 0, 0);
checkBox.setLayoutParams(lp);
checkBox.setBackgroundResource(0);
checkBox.setTag(Weekday.values()[dayOfWeek - 1]);
checkBox.setButtonDrawable(R.drawable.btn_check_small);

@ -28,8 +28,8 @@ import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.actfm.TagViewActivity;
import com.todoroo.astrid.actfm.TagViewWrapperActivity;
import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.activity.TaskListWrapperActivity;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.AstridFilterExposer;
import com.todoroo.astrid.api.Filter;
@ -85,7 +85,8 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
newTagIntent(context, RenameTagActivity.class, tag),
newTagIntent(context, DeleteTagActivity.class, tag)
};
filter.customTaskList = new ComponentName(ContextManager.getContext(), TagViewWrapperActivity.class);
filter.customTaskList = new ComponentName(ContextManager.getContext(), TagViewActivity.class);
filter.customWrapperActivity = new ComponentName(ContextManager.getContext(), TaskListWrapperActivity.class);
if(tag.image != null)
filter.imageUrl = tag.image;
if(tag.updateText != null)

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- See the file "LICENSE" for the full license governing this code. -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
style="@style/Content"
android:orientation="vertical">
<!-- Header -->
<LinearLayout
android:id="@+id/lists_header"
android:layout_width="fill_parent"
android:layout_height="43dip"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_alignParentTop="true"
style="@style/Header">
<!-- List Label -->
<TextView android:id="@+id/listLabel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_weight="100"
android:singleLine="true"
android:ellipsize="end"
android:gravity="center"
android:text="@string/FLA_title"
style="@style/TextAppearance.TLA_Header"/>
<ImageView android:id="@+id/back"
android:layout_width="43dip"
android:layout_height="fill_parent"
android:background="?attr/asHeaderButtonBackground"
android:padding="7dip"
android:src="@drawable/icn_tasks"
android:scaleType="fitCenter"
android:visibility="gone" />
</LinearLayout>
<!-- Footer -->
<LinearLayout
android:id="@+id/lists_footer"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_weight="1"
android:padding="5dip"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<Button
android:id="@+id/new_list_button"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/footer_editbutton"
android:gravity="center"
android:text="@string/FLA_new_list"
android:textStyle="bold"
style="@style/TextAppearance.TEA_action"/>
</LinearLayout>
<!-- List -->
<ExpandableListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="100"
android:layout_below="@id/lists_header"
android:layout_above="@id/lists_footer"
android:scrollbars="vertical"
android:cacheColorHint="#00000000"/>
</RelativeLayout>

@ -4,22 +4,27 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.todoroo.astrid.activity.FilterListActivity"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/filterlist_fragment"
android:layout_weight="67">
<!-- Preview: layout=@layout/filter_list_activity -->
</fragment>
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.todoroo.astrid.activity.TaskListActivity"
android:id="@+id/filterlist_fragment_container"
android:layout_weight="67">
<fragment
android:name="com.todoroo.astrid.activity.FilterListActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="filterlist_fragment">
<!-- Preview: layout=@layout/filter_list_activity -->
</fragment>
</FrameLayout>
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="#000000"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tasklist_fragment"
android:layout_weight="33">
<!-- Preview: layout=@layout/task_list_activity -->
</fragment>
android:id="@+id/tasklist_fragment_container"
android:layout_weight="33">
</FrameLayout>
</LinearLayout>

@ -4,22 +4,34 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.todoroo.astrid.activity.TaskListActivity"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tasklist_fragment"
android:layout_weight="67">
<!-- Preview: layout=@layout/task_list_activity -->
</fragment>
android:layout_weight="67"
android:id="@+id/tasklist_fragment_container">
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.todoroo.astrid.activity.TaskEditActivity"
android:name="com.todoroo.astrid.activity.TaskListActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="tasklist_fragment">
<!-- Preview: layout=@layout/task_list_activity -->
</fragment>
</FrameLayout>
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="#000000"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/taskedit_fragment"
android:layout_weight="33">
<!-- Preview: layout=@layout/task_edit_activity -->
</fragment>
android:layout_weight="33"
android:id="@+id/taskedit_fragment_container">
<fragment
android:name="com.todoroo.astrid.activity.TaskEditActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="taskedit_fragment">
<!-- Preview: layout=@layout/task_edit_activity -->
</fragment>
</FrameLayout>
</LinearLayout>

@ -0,0 +1,136 @@
<?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"
android:id="@+id/taskListParent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
style="@style/Content"
android:orientation="vertical">
<!-- Header -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="43dip"
android:layout_weight="1"
android:orientation="horizontal">
<!-- Filters Button -->
<ImageView android:id="@+id/back"
android:layout_width="43dip"
android:layout_height="fill_parent"
android:background="?attr/asHeaderButtonBackground"
android:padding="7dip"
android:src="@drawable/icn_lists"
android:scaleType="fitCenter"
android:visibility="gone" />
<LinearLayout
style="@style/Header"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal">
<!-- List Label -->
<TextView android:id="@+id/listLabel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_weight="100"
android:singleLine="true"
android:ellipsize="end"
android:gravity="center"
style="@style/TextAppearance.TLA_Header"/>
</LinearLayout>
<LinearLayout android:id="@+id/activityContainer"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:visibility="gone">
<View
android:layout_width="0.5dip"
android:layout_height="fill_parent"
android:background="#ff222222"/>
<ImageView android:id="@+id/activity"
android:layout_height="fill_parent"
android:layout_width="43dip"
android:background="?attr/asHeaderButtonBackground"
android:padding="7dip"
android:src="@drawable/icn_cmmt_off"
android:scaleType="fitCenter" />
</LinearLayout>
<LinearLayout android:id="@+id/sortContainer"
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<View
android:layout_width="0.5dip"
android:layout_height="fill_parent"
android:background="#ff222222"/>
<ImageView android:id="@+id/sort_settings"
android:layout_height="fill_parent"
android:layout_width="43dip"
android:background="?attr/asHeaderButtonBackground"
android:padding="7dip"
android:src="@drawable/ic_sort"
android:scaleType="fitCenter" />
</LinearLayout>
</LinearLayout>
<!-- Body goes here -->
<!-- Footer -->
<LinearLayout
android:id="@+id/taskListFooter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="47dip"
android:layout_weight="1"
android:background="@drawable/footer_background"
android:padding="3dip"
android:orientation="horizontal">
<!-- Voice Add Button -->
<ImageButton android:id="@+id/voiceAddButton"
android:layout_width="wrap_content"
android:layout_height="39dip"
android:layout_gravity="top"
android:layout_marginRight="3dip"
android:layout_weight="1"
android:visibility="gone"
android:background="@drawable/footer_button"
android:src="@drawable/ic_footer_mic"
android:scaleType="center"/>
<!-- Quick Add Task -->
<EditText android:id="@+id/quickAddText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="3dip"
android:layout_weight="100"
android:background="@drawable/footer_edittext"
android:hint="@string/TLA_quick_add_hint"
android:textSize="16sp"
android:autoText="true"
android:capitalize="sentences"/>
<!-- Extended Add Button -->
<ImageButton android:id="@+id/quickAddButton"
android:layout_width="wrap_content"
android:layout_height="39dip"
android:layout_gravity="top"
android:layout_marginRight="3dip"
android:layout_weight="1"
android:background="@drawable/footer_button"
android:src="@drawable/ic_footer_add"
android:scaleType="center"/>
</LinearLayout>
</LinearLayout>

@ -4,22 +4,27 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.todoroo.astrid.activity.FilterListActivity"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/filterlist_fragment"
android:layout_weight="67">
<!-- Preview: layout=@layout/filter_list_activity -->
</fragment>
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.todoroo.astrid.activity.TaskListActivity"
android:layout_weight="67"
android:id="@+id/filterlist_fragment_container">
<fragment
android:name="com.todoroo.astrid.activity.FilterListActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/filterlist_fragment">
<!-- Preview: layout=@layout/filter_list_activity -->
</fragment>
</FrameLayout>
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="#000000"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tasklist_fragment"
android:layout_weight="33">
<!-- Preview: layout=@layout/task_list_activity -->
</fragment>
android:layout_weight="33"
android:id="@+id/tasklist_fragment_container">
</FrameLayout>
</LinearLayout>

@ -42,7 +42,8 @@
<LinearLayout android:id="@+id/repeatDayOfWeekContainer"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:gravity="center"/>
</LinearLayout>
<LinearLayout

@ -1,8 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<fragment
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.todoroo.astrid.activity.FilterListActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/filterlist_fragment">
</fragment>
<fragment
android:name="com.todoroo.astrid.activity.FilterListActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="filterlist_fragment">
</fragment>
</FrameLayout>

@ -1,8 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<fragment
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.todoroo.astrid.activity.TaskEditActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/taskedit_fragment">
</fragment>
android:id="@+id/taskedit_fragment_container">
<fragment
android:name="com.todoroo.astrid.activity.TaskEditActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="taskedit_fragment">
</fragment>
</FrameLayout>

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<fragment
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.todoroo.astrid.activity.TaskListActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tasklist_fragment">
</fragment>
android:id="@+id/tasklist_fragment_container">
</FrameLayout>

@ -4,6 +4,8 @@ import android.app.PendingIntent.CanceledException;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import com.timsu.astrid.R;
import com.todoroo.andlib.utility.AndroidUtilities;
@ -37,20 +39,23 @@ public class AstridWrapperActivity extends FragmentActivity
*/
protected boolean mMultipleFragments = false;
protected FilterListActivity getFilterListFragment() {
public FilterListActivity getFilterListFragment() {
FilterListActivity frag = (FilterListActivity) getSupportFragmentManager()
.findFragmentById(R.id.filterlist_fragment);
if (frag == null || !frag.isInLayout())
return null;
return frag;
}
protected TaskListActivity getTaskListFragment() {
public TaskListActivity getTaskListFragment() {
TaskListActivity frag = (TaskListActivity) getSupportFragmentManager()
.findFragmentById(R.id.tasklist_fragment);
if (frag == null || !frag.isInLayout())
return null;
.findFragmentByTag(TaskListActivity.TAG_TASKLIST_FRAGMENT);
return frag;
}
public TaskEditActivity getTaskEditFragment() {
TaskEditActivity frag = (TaskEditActivity) getSupportFragmentManager()
.findFragmentByTag(TaskEditActivity.TAG_TASKEDIT_FRAGMENT);
return frag;
}
@ -108,20 +113,19 @@ public class AstridWrapperActivity extends FragmentActivity
return false;
} else {
// If showing both fragments, directly update the tasklist-fragment
TaskListActivity tasklist = (TaskListActivity) getSupportFragmentManager()
.findFragmentById(R.id.tasklist_fragment);
Intent intent = getIntent();
if(item instanceof Filter) {
Filter filter = (Filter)item;
if(filter instanceof FilterWithCustomIntent) {
FilterWithCustomIntent customFilter = ((FilterWithCustomIntent)filter);
tasklist.onNewIntent(customFilter.getCustomIntent());
intent = ((FilterWithCustomIntent)filter).getCustomIntent();
} else {
Intent intent = new Intent(this, TaskListWrapperActivity.class);
intent.putExtra(TaskListActivity.TOKEN_FILTER, filter);
tasklist.onNewIntent(intent);
}
setIntent(intent);
setupTasklistFragmentWithFilter(filter);
// no animation for dualpane-layout
AndroidUtilities.callOverridePendingTransition(this, 0, 0);
StatisticsService.reportEvent(StatisticsConstants.FILTER_LIST);
@ -137,8 +141,30 @@ public class AstridWrapperActivity extends FragmentActivity
}
}
protected void setupTasklistFragmentWithFilter(Filter filter) {
Class<?> component = TaskListActivity.class;
if (filter instanceof FilterWithCustomIntent) {
try {
component = Class.forName(((FilterWithCustomIntent) filter).customTaskList.getClassName());
} catch (Exception e) {
// Invalid
}
}
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
try {
TaskListActivity newFragment = (TaskListActivity) component.newInstance();
transaction.replace(R.id.tasklist_fragment_container, newFragment, TaskListActivity.TAG_TASKLIST_FRAGMENT);
transaction.commit();
} catch (Exception e) {
e.printStackTrace(); //Uh ohs
}
}
@Override
public void onTaskListItemClicked(int category, int position) {
}
@Override

@ -6,7 +6,6 @@ import java.util.concurrent.atomic.AtomicReference;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
@ -19,7 +18,6 @@ import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.Property.IntegerProperty;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.astrid.adapter.TaskAdapter;
import com.todoroo.astrid.adapter.TaskAdapter.OnCompletedTaskListener;
import com.todoroo.astrid.core.SortHelper;
import com.todoroo.astrid.data.Task;
@ -107,7 +105,7 @@ public class DraggableTaskListActivity extends TaskListActivity {
private final class DraggableTaskAdapter extends TaskAdapter {
private DraggableTaskAdapter(ListFragment activity, int resource,
private DraggableTaskAdapter(TaskListActivity activity, int resource,
Cursor c, AtomicReference<String> query, boolean autoRequery,
OnCompletedTaskListener onCompletedTaskListener) {
super(activity, resource, c, query, autoRequery,

@ -95,6 +95,8 @@ import com.todoroo.astrid.utility.Constants;
*/
public class FilterListActivity extends ExpandableListFragment {
public static final String TAG_FILTERLIST_FRAGMENT = "filterlist_fragment";
// -- extra codes
//public static final String SHOW_BACK_BUTTON = "show_back"; //$NON-NLS-1$
@ -199,9 +201,7 @@ public class FilterListActivity extends ExpandableListFragment {
public void onClick(View v) {
Intent intent = TagsPlugin.newTagDialog(getActivity());
startActivity(intent);
AndroidUtilities.callApiMethod(5, getActivity(), "overridePendingTransition",
new Class<?>[] { Integer.TYPE, Integer.TYPE },
R.anim.slide_left_in, R.anim.slide_left_out);
AndroidUtilities.callOverridePendingTransition(getActivity(), R.anim.slide_left_in, R.anim.slide_left_out);
}
});
@ -209,7 +209,7 @@ public class FilterListActivity extends ExpandableListFragment {
onNewIntent(getActivity().getIntent());
Fragment tasklistFrame = getFragmentManager().findFragmentById(R.id.tasklist_fragment);
Fragment tasklistFrame = getFragmentManager().findFragmentByTag(TaskListActivity.TAG_TASKLIST_FRAGMENT);
mDualFragments = (tasklistFrame != null) && tasklistFrame.isInLayout();
if (mDualFragments) {
@ -475,7 +475,7 @@ public class FilterListActivity extends ExpandableListFragment {
return true;
}
default: {
Fragment tasklist = getSupportFragmentManager().findFragmentById(R.id.tasklist_fragment);
Fragment tasklist = getSupportFragmentManager().findFragmentByTag(TaskListActivity.TAG_TASKLIST_FRAGMENT);
if (tasklist != null && tasklist.isInLayout())
return tasklist.onOptionsItemSelected(item);
}
@ -515,13 +515,16 @@ public class FilterListActivity extends ExpandableListFragment {
Preferences.setLong(LAST_TAG_REFRESH_KEY, DateUtilities.now());
actFmSyncService.fetchTags(0);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
adapter.clear();
adapter.getLists();
}
});
Activity activity = getActivity();
if (activity != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
adapter.clear();
adapter.getLists();
}
});
}
} catch (IOException e) {
if (manual)

@ -2,9 +2,13 @@ package com.todoroo.astrid.activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.widget.TextView;
import com.timsu.astrid.R;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.service.ThemeService;
public class FilterListWrapperActivity extends AstridWrapperActivity {
@ -17,6 +21,17 @@ public class FilterListWrapperActivity extends AstridWrapperActivity {
ThemeService.applyTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.filter_list_wrapper_activity);
if (findViewById(R.id.tasklist_fragment_container) != null)
setupTasklistFragmentWithFilter((Filter)getIntent().getParcelableExtra(TaskListActivity.TOKEN_FILTER));
else {
Fragment tla = getTaskListFragment();
if (tla != null) {
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.remove(tla);
transaction.commit();
}
}
}
/* (non-Javadoc)
@ -42,4 +57,10 @@ public class FilterListWrapperActivity extends AstridWrapperActivity {
// update the actionbar-title
getSupportActionBar().setTitle(title);
}
@Override
public void finish() {
super.finish();
AndroidUtilities.callOverridePendingTransition(this, R.anim.slide_left_in, R.anim.slide_left_out);
}
}

@ -32,6 +32,7 @@ public final class ShareLinkActivity extends TaskListActivity {
taskService.save(task);
Intent intent = new Intent(getActivity(), TaskEditWrapperActivity.class);
intent.putExtra(TaskEditActivity.TOKEN_ID, task.getId());
intent.putExtra(TOKEN_FILTER, filter);
startActivityForResult(intent, ACTIVITY_EDIT_TASK);
}
}

@ -107,6 +107,8 @@ import com.todoroo.astrid.voice.VoiceInputAssistant;
*/
public final class TaskEditActivity extends Fragment {
public static final String TAG_TASKEDIT_FRAGMENT = "taskedit_fragment";
// --- bundle tokens
/**
@ -290,7 +292,7 @@ public final class TaskEditActivity extends Fragment {
setHasOptionsMenu(true);
getSupportActivity().getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Fragment tasklistFrame = getFragmentManager().findFragmentById(R.id.tasklist_fragment);
Fragment tasklistFrame = getFragmentManager().findFragmentByTag(TaskListActivity.TAG_TASKLIST_FRAGMENT);
mDualFragments = (tasklistFrame != null) && tasklistFrame.isInLayout();
setUpUIComponents();
@ -652,6 +654,12 @@ public final class TaskEditActivity extends Fragment {
Notifications.cancelNotifications(model.getId());
}
/** Convenience method to populate fields after setting model to null */
public void repopulateFromScratch(Intent intent) {
model = null;
populateFields(intent);
}
/** Populate UI component values from the model */
public void populateFields(Intent intent) {
loadItem(intent);
@ -674,7 +682,7 @@ public final class TaskEditActivity extends Fragment {
}
/** Save task model from values in UI components */
private void save(boolean onPause) {
public void save(boolean onPause) {
if(title.getText().length() > 0)
model.setValue(Task.DELETION_DATE, 0L);

@ -3,8 +3,10 @@ package com.todoroo.astrid.activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.KeyEvent;
import android.widget.TextView;
import com.timsu.astrid.R;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.astrid.service.ThemeService;
public class TaskEditWrapperActivity extends AstridWrapperActivity {
@ -26,7 +28,7 @@ public class TaskEditWrapperActivity extends AstridWrapperActivity {
super.onResume();
Fragment frag = (Fragment) getSupportFragmentManager()
.findFragmentById(R.id.tasklist_fragment);
.findFragmentByTag(TaskListActivity.TAG_TASKLIST_FRAGMENT);
if (frag != null) {
mMultipleFragments = true;
} else {
@ -37,9 +39,25 @@ public class TaskEditWrapperActivity extends AstridWrapperActivity {
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
TaskEditActivity frag = (TaskEditActivity) getSupportFragmentManager()
.findFragmentById(R.id.taskedit_fragment);
.findFragmentByTag(TaskEditActivity.TAG_TASKEDIT_FRAGMENT);
if (frag != null && frag.isInLayout())
return frag.onKeyDown(keyCode, event);
return super.onKeyDown(keyCode, event);
}
@Override
public void setTitle(CharSequence title) {
Fragment frag = (Fragment) getSupportFragmentManager()
.findFragmentByTag(TaskListActivity.TAG_TASKLIST_FRAGMENT);
if (frag != null && frag.isInLayout())
((TextView)frag.getView().findViewById(R.id.listLabel)).setText(title);
// update the actionbar-title
getSupportActionBar().setTitle(title);
}
@Override
public void finish() {
super.finish();
AndroidUtilities.callOverridePendingTransition(this, R.anim.slide_right_in, R.anim.slide_right_out);
}
}

@ -16,6 +16,7 @@ import android.app.AlertDialog;
import android.app.PendingIntent.CanceledException;
import android.app.SearchManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
@ -128,6 +129,8 @@ import com.todoroo.astrid.widget.TasksWidget;
public class TaskListActivity extends ListFragment implements OnScrollListener,
GestureInterface, OnSortSelectedListener {
public static final String TAG_TASKLIST_FRAGMENT = "tasklist_fragment";
// --- activities
private static final long BACKGROUND_REFRESH_INTERVAL = 120000L;
@ -372,6 +375,10 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
contextMenuExtensionLoader.loadInNewThread(getActivity());
}
public Filter getFilter() {
return filter;
}
protected void addSyncRefreshMenuItem(Menu menu) {
MenuItem item = menu.add(Menu.NONE, MENU_SYNC_ID, Menu.NONE,
R.string.TLA_menu_sync);
@ -576,12 +583,14 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
protected Intent getOnClickQuickAddIntent(Task t) {
Intent intent = new Intent(getActivity(), TaskEditWrapperActivity.class);
intent.putExtra(TaskEditActivity.TOKEN_ID, t.getId());
intent.putExtra(TOKEN_FILTER, filter);
return intent;
}
protected Intent getOnLongClickQuickAddIntent(Task t) {
Intent intent = new Intent(getActivity(), TaskEditWrapperActivity.class);
intent.putExtra(TaskEditActivity.TOKEN_ID, t.getId());
intent.putExtra(TOKEN_FILTER, filter);
return intent;
}
@ -921,7 +930,7 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
getListView().setOnScrollListener(this);
registerForContextMenu(getListView());
loadTaskListContent(false);
loadTaskListContent(true);
}
/**
@ -1334,6 +1343,7 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
itemId = item.getGroupId();
intent = new Intent(getActivity(), TaskEditWrapperActivity.class);
intent.putExtra(TaskEditActivity.TOKEN_ID, itemId);
intent.putExtra(TOKEN_FILTER, filter);
startActivityForResult(intent, ACTIVITY_EDIT_TASK);
transitionForTaskEdit();
return true;
@ -1357,6 +1367,7 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
intent = new Intent(getActivity(), TaskEditWrapperActivity.class);
intent.putExtra(TaskEditActivity.TOKEN_ID, clone.getId());
intent.putExtra(TOKEN_FILTER, filter);
startActivityForResult(intent, ACTIVITY_EDIT_TASK);
transitionForTaskEdit();
@ -1414,8 +1425,9 @@ public class TaskListActivity extends ListFragment implements OnScrollListener,
@SuppressWarnings("nls")
private void showFilterListActivity() {
Intent intent = new Intent(getActivity(),
FilterListWrapperActivity.class);
Intent intent = (Intent) getActivity().getIntent().clone();
intent.setComponent(new ComponentName(getActivity(), FilterListWrapperActivity.class));
intent.setFlags(0);
startActivity(intent);
AndroidUtilities.callOverridePendingTransition(getActivity(), R.anim.slide_right_in, R.anim.slide_right_out);
}

@ -5,6 +5,8 @@ import android.support.v4.app.Fragment;
import android.widget.TextView;
import com.timsu.astrid.R;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.service.ThemeService;
public class TaskListWrapperActivity extends AstridWrapperActivity {
@ -13,9 +15,12 @@ public class TaskListWrapperActivity extends AstridWrapperActivity {
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
ThemeService.applyTheme(this);
ThemeService.applyTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.task_list_wrapper_activity);
Filter savedFilter = getIntent().getParcelableExtra(TaskListActivity.TOKEN_FILTER);
setupTasklistFragmentWithFilter(savedFilter);
}
/* (non-Javadoc)
@ -41,4 +46,10 @@ public class TaskListWrapperActivity extends AstridWrapperActivity {
// update the actionbar-title
getSupportActionBar().setTitle(title);
}
@Override
public void finish() {
super.finish();
AndroidUtilities.callOverridePendingTransition(this, R.anim.slide_right_in, R.anim.slide_right_out);
}
}

@ -17,7 +17,9 @@ import java.util.concurrent.atomic.AtomicReference;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@ -28,7 +30,6 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.support.v4.app.ListFragment;
import android.text.Html;
import android.text.Html.ImageGetter;
import android.text.Html.TagHandler;
@ -139,7 +140,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
@Autowired
private TaskService taskService;
protected final ListFragment fragment;
protected final TaskListActivity fragment;
protected final HashMap<Long, Boolean> completedItems = new HashMap<Long, Boolean>(0);
protected OnCompletedTaskListener onCompletedTaskListener = null;
public boolean isFling = false;
@ -179,7 +180,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
* @param onCompletedTaskListener
* task listener. can be null
*/
public TaskAdapter(ListFragment fragment, int resource,
public TaskAdapter(TaskListActivity fragment, int resource,
Cursor c, AtomicReference<String> query, boolean autoRequery,
OnCompletedTaskListener onCompletedTaskListener) {
super(ContextManager.getContext(), c, autoRequery);
@ -928,10 +929,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
mBar = null;
if(position == 0) {
Intent intent = new Intent(fragment.getActivity(), TaskEditWrapperActivity.class);
intent.putExtra(TaskEditActivity.TOKEN_ID, taskId);
fragment.startActivityForResult(intent, TaskListActivity.ACTIVITY_EDIT_TASK);
AndroidUtilities.callOverridePendingTransition(fragment.getActivity(), R.anim.slide_left_in, R.anim.slide_left_out);
editTask(taskId);
} else {
flushSpecific(taskId);
try {
@ -988,10 +986,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
if (actions.size() > 0)
mBar.show(v);
else {
Intent intent = new Intent(fragment.getActivity(), TaskEditWrapperActivity.class);
intent.putExtra(TaskEditActivity.TOKEN_ID, taskId);
fragment.getActivity().startActivityForResult(intent, TaskListActivity.ACTIVITY_EDIT_TASK);
AndroidUtilities.callOverridePendingTransition(fragment.getActivity(), R.anim.slide_left_in, R.anim.slide_left_out);
editTask(taskId);
}
} else if (!viewHolder.task.getFlag(Task.FLAGS, Task.FLAG_IS_READONLY)) {
// Register a temporary receiver in case we clicked a task with no actions forthcoming and should start
@ -1015,10 +1010,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
if (taskId != -1) {
Collection<TaskAction> actions = taskActionManager.get(taskId);
if (actions != null && actions.size() == 0) {
Intent editIntent = new Intent(fragment.getActivity(), TaskEditWrapperActivity.class);
editIntent.putExtra(TaskEditActivity.TOKEN_ID, taskId);
fragment.getActivity().startActivityForResult(editIntent, TaskListActivity.ACTIVITY_EDIT_TASK);
AndroidUtilities.callOverridePendingTransition(fragment.getActivity(), R.anim.slide_left_in, R.anim.slide_left_out);
editTask(taskId);
}
}
fragment.getActivity().unregisterReceiver(this);
@ -1026,6 +1018,22 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
}
private void editTask(long taskId) {
Activity activity = fragment.getActivity();
Intent intent = (Intent) activity.getIntent().clone();
intent.setComponent(new ComponentName(activity, TaskEditWrapperActivity.class));
intent.putExtra(TaskEditActivity.TOKEN_ID, taskId);
intent.putExtra(TaskListActivity.TOKEN_FILTER, fragment.getFilter());
if (activity instanceof TaskEditWrapperActivity) {
TaskEditActivity editActivity = ((TaskEditWrapperActivity) activity).getTaskEditFragment();
editActivity.save(true);
editActivity.repopulateFromScratch(intent);
} else {
fragment.startActivityForResult(intent, TaskListActivity.ACTIVITY_EDIT_TASK);
AndroidUtilities.callOverridePendingTransition(fragment.getActivity(), R.anim.slide_left_in, R.anim.slide_left_out);
}
}
/**
* Call me when the parent presses trackpad
*/

Loading…
Cancel
Save