Skip to content

Commit

Permalink
Move starred repositories to bookmarks screen
Browse files Browse the repository at this point in the history
Related to #578, #624 and #725
  • Loading branch information
Tunous committed Mar 23, 2018
1 parent 74c9b80 commit b56fdd4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
16 changes: 12 additions & 4 deletions app/src/main/java/com/gh4a/activities/home/BookmarkFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@

import com.gh4a.R;
import com.gh4a.fragment.BookmarkListFragment;
import com.gh4a.fragment.StarredRepositoryListFragment;

public class BookmarkFactory extends FragmentFactory {
private static final int[] TAB_TITLES = new int[] {
R.string.bookmarks
R.string.bookmarks, R.string.starred
};

public BookmarkFactory(HomeActivity activity) {
private final String mUserLogin;

public BookmarkFactory(HomeActivity activity, String userLogin) {
super(activity);
mUserLogin = userLogin;
}

@Override
protected @StringRes int getTitleResId() {
return R.string.bookmarks;
@StringRes
protected int getTitleResId() {
return R.string.stars_and_bookmarks;
}

@Override
Expand All @@ -27,6 +32,9 @@ protected int[] getTabTitleResIds() {

@Override
protected Fragment makeFragment(int position) {
if (position == 1) {
return StarredRepositoryListFragment.newInstance(mUserLogin, "", ""); // TODO
}
return BookmarkListFragment.newInstance();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ private FragmentFactory getFactoryForItem(int id) {
case R.id.search:
return new SearchFactory(this);
case R.id.bookmarks:
return new BookmarkFactory(this);
return new BookmarkFactory(this, mUserLogin);
case R.id.pub_timeline:
return new TimelineFactory(this);
case R.id.blog:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,6 @@ private void applyFilterTypeAndSortOrder() {
}

switch (mFilterType) {
case "starred":
mMainFragment = StarredRepositoryListFragment.newInstance(mUserLogin,
mSortOrder, mSortDirection);
break;
case "watched":
mMainFragment = WatchedRepositoryListFragment.newInstance(mUserLogin);
break;
Expand Down Expand Up @@ -364,7 +360,6 @@ public static class FilterDrawerHelper {
FILTER_LOOKUP.put(R.id.filter_type_sources, "sources");
FILTER_LOOKUP.put(R.id.filter_type_forks, "forks");
FILTER_LOOKUP.put(R.id.filter_type_watched, "watched");
FILTER_LOOKUP.put(R.id.filter_type_starred, "starred");
}

public static FilterDrawerHelper create(String userLogin, boolean isOrg) {
Expand Down Expand Up @@ -427,9 +422,7 @@ public void setFilterType(String type) {
}

public int getMenuResId() {
return TextUtils.equals(mFilterType, "starred") ? R.menu.repo_starred_sort
: TextUtils.equals(mFilterType, "watched") ? 0
: R.menu.repo_sort;
return TextUtils.equals(mFilterType, "watched") ? 0 : R.menu.repo_sort;
}

public void selectSortType(Menu menu, String order, String direction) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/menu/home_nav_drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
android:icon="@drawable/icon_search"/>
<item
android:id="@+id/bookmarks"
android:title="@string/bookmarks"
android:title="@string/stars_and_bookmarks"
android:icon="@drawable/icon_bookmark" />
</group>
<group
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/res/menu/repo_filter_logged_in.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
<item
android:id="@+id/filter_type_watched"
android:title="@string/repo_type_watched" />
<item
android:id="@+id/filter_type_starred"
android:title="@string/repo_type_starred" />
</group>
</menu>
</item>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<string name="feedback_by_email">By Email</string>
<string name="feedback_by_gh4a">By OctoDroid</string>
<string name="bookmarks">Bookmarks</string>
<string name="stars_and_bookmarks">Stars and Bookmarks</string>
<string name="other_info">Other Information</string>
<string name="view">View</string>
<string name="readme">Readme</string>
Expand Down

0 comments on commit b56fdd4

Please sign in to comment.