Display search history in SearchActivity. Save suggested sort type and nsfw info in database for SubredditData. Fix an issue in parsing posts.

This commit is contained in:
Alex Ning
2020-09-29 22:19:54 +08:00
parent 8dd4759035
commit 6e4519ef93
21 changed files with 512 additions and 71 deletions

View File

@@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:pathData="M35.4182,18.3369c-0.2456,-0.3018 -0.6104,-0.4678 -1.0273,-0.4678H31.0766l0.9194,-4.4711c0.0864,-0.4199 -0.0063,-0.8359 -0.2549,-1.1406c-0.2461,-0.3008 -0.6108,-0.4668 -1.0278,-0.4668c-0.8237,0 -1.6011,0.6435 -1.77,1.4668l-0.2498,1.2147c-0.0082,0.0305 -0.0214,0.0594 -0.0277,0.0903l-0.6794,3.3066h-5.5789l0.9194,-4.4711c0.0864,-0.4199 -0.0063,-0.8359 -0.2549,-1.1406c-0.2461,-0.3008 -0.6108,-0.4668 -1.0278,-0.4668c-0.8237,0 -1.6011,0.6435 -1.77,1.4668l-0.2601,1.2647c-0.0032,0.0137 -0.0095,0.0266 -0.0124,0.0403l-0.6799,3.3066h-3.6087c-0.8237,0 -1.6016,0.6435 -1.7705,1.4658c-0.0864,0.4209 0.0068,0.8359 0.2554,1.1406c0.2461,0.3018 0.6108,0.4668 1.0273,0.4668h3.4649l-0.9841,4.7861h-3.6087c-0.8237,0 -1.6016,0.6435 -1.7705,1.4668c-0.0864,0.4189 0.0063,0.835 0.2544,1.1387c0.2461,0.3018 0.6113,0.4678 1.0283,0.4678h3.4649l-0.9244,4.4951c-0.0864,0.4199 0.0063,0.8359 0.2549,1.1406c0.2456,0.3008 0.6108,0.4668 1.0273,0.4668c0.8237,0 1.6016,-0.6435 1.7705,-1.4668l0.9533,-4.6357h5.5824l-0.9244,4.4951c-0.0864,0.4199 0.0063,0.8359 0.2549,1.1406c0.2461,0.3008 0.6108,0.4668 1.0278,0.4668c0.8237,0 1.6011,-0.6435 1.77,-1.4668l0.9533,-4.6357h3.4666c0.8237,0 1.6016,-0.6435 1.7705,-1.4658c0.0884,-0.4287 -0.001,-0.834 -0.2515,-1.1416c-0.2451,-0.3008 -0.6113,-0.4658 -1.0308,-0.4658h-3.3229l0.9837,-4.7861h3.4666c0.8237,0 1.6016,-0.6435 1.7705,-1.4668C35.7595,19.0566 35.6667,18.6406 35.4182,18.3369zM20.7882,25.7285l0.9837,-4.7861h5.5824l-0.9841,4.7861H20.7882z"
android:fillColor="#303030"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M13,3c-4.97,0 -9,4.03 -9,9L1,12l3.89,3.89 0.07,0.14L9,12L6,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42C8.27,19.99 10.51,21 13,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,8v5l4.28,2.54 0.72,-1.21 -3.5,-2.08L13.5,8L12,8z"
android:fillColor="#000000"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M5,5.5C5,6.33 5.67,7 6.5,7h4v10.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5V7h4c0.83,0 1.5,-0.67 1.5,-1.5S18.33,4 17.5,4h-11C5.67,4 5,4.67 5,5.5z"
android:fillColor="#000000"/>
</vector>

View File

@@ -48,38 +48,64 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout
android:id="@+id/subreddit_name_relative_layout_search_activity"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:padding="16dp">
android:orientation="vertical">
<RelativeLayout
android:id="@+id/subreddit_name_relative_layout_search_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:padding="16dp">
<TextView
android:id="@+id/search_in_text_view_search_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/search_in"
android:textColor="?attr/colorAccent"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
<TextView
android:id="@+id/subreddit_name_text_view_search_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="32dp"
android:layout_marginEnd="16dp"
android:layout_toEndOf="@id/search_in_text_view_search_activity"
android:text="@string/all_subreddits"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
</RelativeLayout>
<View
android:id="@+id/divider_search_activity"
android:layout_width="match_parent"
android:layout_height="1dp" />
<TextView
android:id="@+id/search_in_text_view_search_activity"
android:id="@+id/recent_summary_text_view_search_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/search_in"
android:textColor="?attr/colorAccent"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
android:padding="16dp"
android:text="@string/recent_searches"
android:fontFamily="?attr/font_family"
android:visibility="gone" />
<TextView
android:id="@+id/subreddit_name_text_view_search_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="32dp"
android:layout_marginEnd="16dp"
android:layout_toEndOf="@id/search_in_text_view_search_activity"
android:text="@string/all_subreddits"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view_search_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View File

@@ -0,0 +1,19 @@
<?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="wrap_content"
android:padding="16dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground">
<TextView
android:id="@+id/recent_search_query_text_view_item_recent_search_query"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
android:drawablePadding="16dp" />
</LinearLayout>

View File

@@ -912,4 +912,6 @@
<string name="give_award_success">Award given</string>
<string name="give_award_failed">Failed</string>
<string name="recent_searches">Recent searches</string>
</resources>