Basic version of toggling to people mode on tablet working

pull/14/head
Sam Bosley 12 years ago
parent 02f25f7e1f
commit 86ec3295b6

@ -3,6 +3,7 @@ package com.todoroo.astrid.people;
import android.app.Activity;
import com.timsu.astrid.R;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.astrid.activity.FilterListFragment;
import com.todoroo.astrid.adapter.FilterAdapter;
@ -15,6 +16,9 @@ public class PeopleListFragment extends FilterListFragment {
@Override
protected int getLayout(Activity activity) {
return R.layout.people_list_fragment;
if (AndroidUtilities.isTabletSized(activity))
return R.layout.people_list_fragment_3pane;
else
return R.layout.people_list_fragment;
}
}

@ -0,0 +1,20 @@
<?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:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?attr/asListPopoverBg"
android:orientation="vertical">
<!-- List -->
<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:scrollbars="vertical"
android:divider="@android:color/transparent"
android:cacheColorHint="#00000000"/>
</LinearLayout>

@ -302,10 +302,10 @@ public class AstridActivity extends FragmentActivity
}
}
protected Fragment setupFragment(String tag, int container, Class<? extends Fragment> cls, boolean createImmediate) {
protected Fragment setupFragment(String tag, int container, Class<? extends Fragment> cls, boolean createImmediate, boolean replace) {
final FragmentManager fm = getSupportFragmentManager();
Fragment fragment = fm.findFragmentByTag(tag);
if(fragment == null) {
if(fragment == null || replace) {
try {
fragment = cls.newInstance();
} catch (InstantiationException e) {

@ -44,6 +44,7 @@ import com.todoroo.astrid.api.FilterListItem;
import com.todoroo.astrid.core.CoreFilterExposer;
import com.todoroo.astrid.core.CustomFilterExposer;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.people.PeopleListFragment;
import com.todoroo.astrid.people.PeopleViewActivity;
import com.todoroo.astrid.service.StatisticsConstants;
import com.todoroo.astrid.service.StatisticsService;
@ -279,14 +280,14 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
}
setupFragment(FilterListFragment.TAG_FILTERLIST_FRAGMENT,
R.id.filterlist_fragment_container, FilterListFragment.class, false);
R.id.filterlist_fragment_container, FilterListFragment.class, false, false);
} else {
fragmentLayout = LAYOUT_SINGLE;
actionBar.setDisplayHomeAsUpEnabled(true);
listsNav.setOnClickListener(popupMenuClickListener);
createListsPopover();
setupPopoverWithFilterList((FilterListFragment) setupFragment(FilterListFragment.TAG_FILTERLIST_FRAGMENT, 0,
getFilterListClass(), true));
getFilterListClass(), true, false));
}
}
@ -294,17 +295,6 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
return FilterListFragment.class;
}
// private void togglePeopleView(boolean peopleMode) {
// if (fragmentLayout != LAYOUT_SINGLE) {
// if (peopleMode)
// setupFragment(FilterListFragment.TAG_FILTERLIST_FRAGMENT, R.id.filterlist_fragment_container,
// PeopleListFragment.class, false);
// else
// setupFragment(FilterListFragment.TAG_FILTERLIST_FRAGMENT,
// R.id.filterlist_fragment_container, FilterListFragment.class, false);
// }
// }
private void createListsPopover() {
listsPopover = new FragmentPopover(this, R.layout.list_dropdown_popover);
listsPopover.setOnDismissListener(new OnDismissListener() {
@ -685,8 +675,12 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
onSearchRequested();
return;
case MainMenuPopover.MAIN_MENU_ITEM_FRIENDS:
Intent peopleIntent = new Intent(this, PeopleViewActivity.class);
startActivity(peopleIntent);
if (fragmentLayout != LAYOUT_SINGLE) {
togglePeopleView();
} else {
Intent peopleIntent = new Intent(this, PeopleViewActivity.class);
startActivity(peopleIntent);
}
return;
case MainMenuPopover.MAIN_MENU_ITEM_SUGGESTIONS:
// Doesn't exist yet
@ -699,6 +693,17 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
tlf.handleOptionsMenuItemSelected(item, customIntent);
}
private void togglePeopleView() {
FilterListFragment flf = getFilterListFragment();
boolean peopleMode = !(flf instanceof PeopleListFragment);
if (peopleMode)
setupFragment(FilterListFragment.TAG_FILTERLIST_FRAGMENT, R.id.filterlist_fragment_container,
PeopleListFragment.class, false, true);
else
setupFragment(FilterListFragment.TAG_FILTERLIST_FRAGMENT,
R.id.filterlist_fragment_container, FilterListFragment.class, false, true);
}
public MainMenuPopover getMainMenuPopover() {
return mainMenuPopover;
}

Loading…
Cancel
Save