Sorting in SearchResultActivity is available. Switch DataSource instead of replacing fragments when changing sorting types. Minor bugs fixed.

This commit is contained in:
Alex Ning
2019-07-29 00:52:08 +08:00
parent 40fc423b33
commit 111ba8e5fc
32 changed files with 524 additions and 138 deletions

View File

@@ -1,18 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="8dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="24dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:text="@string/bottom_sheet_post_type"
android:textSize="18sp" />
android:paddingBottom="8dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/text_type_linear_layout_post_type_bottom_sheet_fragment"
@@ -30,7 +21,7 @@
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="32dp"
android:layout_marginEnd="48dp"
android:src="@drawable/ic_outline_text_24px"
android:tint="@color/primaryTextColor" />
@@ -38,7 +29,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/bottom_sheet_post_text" />
android:text="@string/bottom_sheet_post_text"
android:textColor="@color/primaryTextColor" />
</LinearLayout>
@@ -58,7 +50,7 @@
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="32dp"
android:layout_marginEnd="48dp"
android:src="@drawable/ic_link"
android:tint="@color/primaryTextColor" />
@@ -66,7 +58,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/bottom_sheet_post_link" />
android:text="@string/bottom_sheet_post_link"
android:textColor="@color/primaryTextColor" />
</LinearLayout>
@@ -86,7 +79,7 @@
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="32dp"
android:layout_marginEnd="48dp"
android:src="@drawable/ic_menu_gallery"
android:tint="@color/primaryTextColor" />
@@ -94,7 +87,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/bottom_sheet_post_image" />
android:text="@string/bottom_sheet_post_image"
android:textColor="@color/primaryTextColor" />
</LinearLayout>
@@ -114,7 +108,7 @@
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_marginEnd="32dp"
android:layout_marginEnd="48dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_outline_video_label_24px"
android:tint="@color/primaryTextColor" />
@@ -123,7 +117,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/bottom_sheet_post_video" />
android:text="@string/bottom_sheet_post_video"
android:textColor="@color/primaryTextColor" />
</LinearLayout>

View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="8dp">
<TextView
android:id="@+id/relevance_type_text_view_search_sort_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_relevance"
android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" />
<TextView
android:id="@+id/hot_type_text_view_search_sort_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_hot"
android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" />
<TextView
android:id="@+id/top_type_text_view_search_sort_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_top"
android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" />
<TextView
android:id="@+id/new_type_text_view_search_sort_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_new"
android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" />
<TextView
android:id="@+id/comments_type_text_view_search_sort_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_comments"
android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" />
</LinearLayout>

View File

@@ -0,0 +1,36 @@
<?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:paddingBottom="8dp"
android:orientation="vertical">
<TextView
android:id="@+id/relevance_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_relevance"
android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" />
<TextView
android:id="@+id/activity_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_activity"
android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground" />
</LinearLayout>

View File

@@ -4,22 +4,12 @@
android:layout_height="match_parent"
android:paddingBottom="8dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="24dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:text="@string/sort"
android:textColor="@color/primaryTextColor"
android:textSize="18sp" />
<TextView
android:id="@+id/best_type_text_view_sort_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_best"
android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
@@ -33,6 +23,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_hot"
android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
@@ -46,6 +37,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_new"
android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
@@ -59,6 +51,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_random"
android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
@@ -72,6 +65,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_rising"
android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
@@ -85,6 +79,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_top"
android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
@@ -98,6 +93,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_controversial"
android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"

View File

@@ -2,15 +2,22 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_search_search_result_activity"
android:id="@+id/action_sort_search_result_activity"
android:orderInCategory="1"
android:title="@string/action_search"
android:icon="@drawable/ic_outline_sort_24px"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_search_search_result_activity"
android:orderInCategory="2"
android:title="@string/action_search"
android:icon="@drawable/ic_search_white_24dp"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_refresh_search_result_activity"
android:orderInCategory="2"
android:orderInCategory="3"
android:title="@string/action_refresh"
app:showAsAction="never" />
</menu>

View File

@@ -23,4 +23,8 @@
<color name="backgroundColor">#121212</color>
<color name="backgroundColorPrimaryDark">#1565C0</color>
<color name="roundedBottomSheetPrimaryBackground">#242424</color>
<color name="roundedBottomSheetPrimaryNavigationBarColor">#000000</color>
</resources>

View File

@@ -24,5 +24,7 @@
<color name="backgroundColorPrimaryDark">@color/colorPrimaryDark</color>
<color name="roundedBottomSheetPrimaryBackground">#FFFFFF</color>
<color name="roundedBottomSheetPrimaryNavigationBarColor">#000000</color>
</resources>

View File

@@ -7,7 +7,6 @@
<dimen name="fab_margin">16dp</dimen>
<dimen name="app_bar_height">180dp</dimen>
<dimen name="text_margin">16dp</dimen>
<dimen name="roundedBottomSheetCornerRadiusTopPadding">0dp</dimen>
<dimen name="roundedBottomSheetCornerRadiusLeftPadding">0dp</dimen>
<dimen name="roundedBottomSheetCornerRadiusRightPadding">0dp</dimen>
</resources>

View File

@@ -142,7 +142,7 @@
<string name="sort_rising">Rising</string>
<string name="sort_top">Top</string>
<string name="sort_controversial">Controversial</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="sort_relevance">Relevance</string>
<string name="sort_comments">Comments</string>
<string name="sort_activity">Activity</string>
</resources>