Add search and watch history (#626)
Add search and watch history * Make MainActicity a single task * Remove some casting * SearchFragment: start searching when created with query * Handle settings change in onResume * History: Log pop up and background playback * History: Add swipe to remove functionallity * Enable history by default * Use stream item * Store more information about the stream * Integrate history database into AppDatabase * Remove redundant casts * Re-enable date converters * History: Use Rx Java and run DB in background * Also make HistoryDAO extend BasicDAO * History: RX-ify swipe to remove * Sort history entries by creation date * History: Set toolbar title * Don't repeat history entries * Introduced setters so we can update entries in the database * If the latest entry has the same (main) values, just update it
This commit is contained in:
parent
09159ec245
commit
c0515de6b7
37 changed files with 1470 additions and 33 deletions
9
app/src/main/res/drawable/ic_delete_sweep_black_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_delete_sweep_black_24dp.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M15,16h4v2h-4zM15,8h7v2h-7zM15,12h6v2h-6zM3,18c0,1.1 0.9,2 2,2h6c1.1,0 2,-0.9 2,-2L13,8L3,8v10zM14,5h-3l-1,-1L6,4L5,5L2,5v2h12z"/>
|
||||
</vector>
|
||||
9
app/src/main/res/drawable/ic_delete_sweep_white_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_delete_sweep_white_24dp.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M15,16h4v2h-4zM15,8h7v2h-7zM15,12h6v2h-6zM3,18c0,1.1 0.9,2 2,2h6c1.1,0 2,-0.9 2,-2L13,8L3,8v10zM14,5h-3l-1,-1L6,4L5,5L2,5v2h12z"/>
|
||||
</vector>
|
||||
52
app/src/main/res/layout/activity_history.xml
Normal file
52
app/src/main/res/layout/activity_history.xml
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context="org.schabi.newpipe.history.HistoryActivity">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/appbar_padding_top"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||
app:title="@string/app_name">
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
</android.support.design.widget.TabLayout>
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
app:srcCompat="?attr/clear_history" />
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
33
app/src/main/res/layout/fragment_history.xml
Normal file
33
app/src/main/res/layout/fragment_history.xml
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/constraintLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context="org.schabi.newpipe.history.HistoryFragment">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/history_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:listitem="@layout/item_search_history" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/history_empty"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/history_empty"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<include
|
||||
android:id="@+id/history_disabled_view"
|
||||
layout="@layout/history_disabled_view"
|
||||
android:visibility="gone" />
|
||||
|
||||
</FrameLayout>
|
||||
17
app/src/main/res/layout/history_disabled_view.xml
Normal file
17
app/src/main/res/layout/history_disabled_view.xml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?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:orientation="vertical"
|
||||
android:gravity="center">
|
||||
<TextView
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="¯\\_(ツ)_/¯"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:text="@string/history_disabled"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
24
app/src/main/res/layout/item_search_history.xml
Normal file
24
app/src/main/res/layout/item_search_history.xml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="10/11/2017 11:32" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/search"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
tools:text="Search query" />
|
||||
</LinearLayout>
|
||||
24
app/src/main/res/layout/item_watch_history.xml
Normal file
24
app/src/main/res/layout/item_watch_history.xml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/history_date"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="11/10/2017 at 10:12" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/stream_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
tools:text="How to Watch Youtube Videos? [5h loop]" />
|
||||
</LinearLayout>
|
||||
|
|
@ -7,12 +7,19 @@
|
|||
android:title="@string/downloads"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
<item android:id="@+id/action_history"
|
||||
android:orderInCategory="981"
|
||||
android:title="@string/action_history"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
<item android:id="@+id/action_settings"
|
||||
android:orderInCategory="990"
|
||||
android:title="@string/settings"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
|
||||
<item android:id="@+id/action_about"
|
||||
android:orderInCategory="1000"
|
||||
android:title="@string/action_about" />
|
||||
|
||||
</menu>
|
||||
10
app/src/main/res/menu/menu_history.xml
Normal file
10
app/src/main/res/menu/menu_history.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="org.schabi.newpipe.history.HistoryActivity">
|
||||
|
||||
<item android:id="@+id/action_settings"
|
||||
android:orderInCategory="990"
|
||||
android:title="@string/settings"
|
||||
app:showAsAction="never"/>
|
||||
</menu>
|
||||
|
|
@ -15,4 +15,5 @@
|
|||
<attr name="collapse" format="reference"/>
|
||||
<attr name="volume_off" format="reference"/>
|
||||
<attr name="separatorColor" format="color"/>
|
||||
<attr name="clear_history" format="reference" />
|
||||
</resources>
|
||||
|
|
@ -50,4 +50,7 @@
|
|||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
<dimen name="appbar_padding_top">8dp</dimen>
|
||||
|
||||
<dimen name="app_bar_height">180dp</dimen>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
<dimen name="text_margin">16dp</dimen>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -232,6 +232,8 @@
|
|||
</string-array>
|
||||
<string name="show_age_restricted_content" translatable="false">show_age_restricted_content</string>
|
||||
<string name="use_tor_key" translatable="false">use_tor</string>
|
||||
<string name="enable_search_history_key" translatable="false">enable_search_history</string>
|
||||
<string name="enable_watch_history_key" translatable="false">enable_watch_history</string>
|
||||
|
||||
<string name="settings_file_charset_key" translatable="false">file_rename</string>
|
||||
<string name="settings_file_replacement_character_key" translatable="false">file_replacement_character</string>
|
||||
|
|
|
|||
|
|
@ -71,9 +71,14 @@
|
|||
<string name="player_gesture_controls_summary">Use gestures to control the brightness and volume of the player</string>
|
||||
<string name="show_search_suggestions_title">Search suggestions</string>
|
||||
<string name="show_search_suggestions_summary">Show suggestions when searching</string>
|
||||
<string name="enable_search_history_title">Search history</string>
|
||||
<string name="enable_search_history_summary">Store search queries locally</string>
|
||||
<string name="enable_watch_history_title">Watch history</string>
|
||||
<string name="enable_watch_history_summary">Store watch history</string>
|
||||
<string name="resume_on_audio_focus_gain_title">Resume on focus gain</string>
|
||||
<string name="resume_on_audio_focus_gain_summary">Continue playing after interruptions (e.g. phone calls)</string>
|
||||
|
||||
|
||||
<string name="download_dialog_title">Download</string>
|
||||
|
||||
<string-array name="theme_description_list">
|
||||
|
|
@ -233,4 +238,14 @@
|
|||
<string name="contribution_encouragement">Whether you have ideas, translation, design changes, code cleaning, or real heavy code changes, help is always welcome. The more is done the better it gets!</string>
|
||||
<string name="read_full_license">Read license</string>
|
||||
<string name="contribution_title">Contribution</string>
|
||||
|
||||
<!-- History -->
|
||||
<string name="title_activity_history">History</string>
|
||||
<string name="title_history_search">Searched</string>
|
||||
<string name="title_history_view">Watched</string>
|
||||
<string name="history_disabled">History is disabled</string>
|
||||
<string name="action_history">History</string>
|
||||
<string name="history_empty">The History is empty.</string>
|
||||
<string name="history_cleared">History cleared</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<resources>
|
||||
|
||||
<style name="RootTheme" parent="android:Theme.Holo"/>
|
||||
<style name="RootTheme" parent="android:Theme.Holo" />
|
||||
|
||||
<style name="PlayerTheme" parent="Theme.AppCompat.NoActionBar">
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
|
|
@ -16,6 +16,7 @@
|
|||
<item name="thumbs_up">@drawable/ic_thumb_up_black_24dp</item>
|
||||
<item name="thumbs_down">@drawable/ic_thumb_down_black_24dp</item>
|
||||
<item name="audio">@drawable/ic_headset_black_24dp</item>
|
||||
<item name="clear_history">@drawable/ic_delete_sweep_white_24dp</item>
|
||||
<item name="download">@drawable/ic_file_download_black_24dp</item>
|
||||
<item name="share">@drawable/ic_share_black_24dp</item>
|
||||
<item name="cast">@drawable/ic_cast_black_24dp</item>
|
||||
|
|
@ -41,6 +42,7 @@
|
|||
<item name="thumbs_up">@drawable/ic_thumb_up_white_24dp</item>
|
||||
<item name="thumbs_down">@drawable/ic_thumb_down_white_24dp</item>
|
||||
<item name="audio">@drawable/ic_headset_white_24dp</item>
|
||||
<item name="clear_history">@drawable/ic_delete_sweep_black_24dp</item>
|
||||
<item name="download">@drawable/ic_file_download_white_24dp</item>
|
||||
<item name="share">@drawable/ic_share_white_24dp</item>
|
||||
<item name="cast">@drawable/ic_cast_white_24dp</item>
|
||||
|
|
@ -107,8 +109,8 @@
|
|||
<item name="colorAccent">@color/light_youtube_accent_color</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -188,6 +188,17 @@
|
|||
android:summary="@string/show_search_suggestions_summary"
|
||||
android:title="@string/show_search_suggestions_title"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/enable_search_history_key"
|
||||
android:title="@string/enable_search_history_title"
|
||||
android:summary="@string/enable_search_history_summary"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/enable_watch_history_key"
|
||||
android:title="@string/enable_watch_history_title"
|
||||
android:summary="@string/enable_watch_history_summary"/>
|
||||
<!--
|
||||
<CheckBoxPreference
|
||||
android:key="@string/use_tor_key"
|
||||
|
|
@ -195,6 +206,5 @@
|
|||
android:summary="@string/use_tor_summary"
|
||||
android:defaultValue="false"/>
|
||||
-->
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue