diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-02-22 05:34:24 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-02-22 05:34:24 +0000 |
commit | 1293eac5c84340c4bdb4c9bef283de3e2710c7da (patch) | |
tree | fa2b8679c49066122436eb685971adf764057e98 /app/src/main/res | |
parent | 82d97cf73208f3f187b965fca4460f68af33f6b7 (diff) | |
download | infinity-for-reddit-1293eac5c84340c4bdb4c9bef283de3e2710c7da.tar infinity-for-reddit-1293eac5c84340c4bdb4c9bef283de3e2710c7da.tar.gz infinity-for-reddit-1293eac5c84340c4bdb4c9bef283de3e2710c7da.tar.bz2 infinity-for-reddit-1293eac5c84340c4bdb4c9bef283de3e2710c7da.tar.lz infinity-for-reddit-1293eac5c84340c4bdb4c9bef283de3e2710c7da.tar.xz infinity-for-reddit-1293eac5c84340c4bdb4c9bef283de3e2710c7da.tar.zst infinity-for-reddit-1293eac5c84340c4bdb4c9bef283de3e2710c7da.zip |
Add a search view in MainActivity and add a SearchActivity.
Diffstat (limited to 'app/src/main/res')
-rw-r--r-- | app/src/main/res/drawable/ic_search_white_24dp.xml | 5 | ||||
-rw-r--r-- | app/src/main/res/layout/activity_search.xml | 43 | ||||
-rw-r--r-- | app/src/main/res/layout/app_bar_main.xml | 32 | ||||
-rw-r--r-- | app/src/main/res/menu/main_activity.xml | 9 | ||||
-rw-r--r-- | app/src/main/res/menu/menu_search.xml | 10 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 10 | ||||
-rw-r--r-- | app/src/main/res/values/styles.xml | 12 | ||||
-rw-r--r-- | app/src/main/res/xml/searchable.xml | 6 |
8 files changed, 120 insertions, 7 deletions
diff --git a/app/src/main/res/drawable/ic_search_white_24dp.xml b/app/src/main/res/drawable/ic_search_white_24dp.xml new file mode 100644 index 00000000..be5ad99c --- /dev/null +++ b/app/src/main/res/drawable/ic_search_white_24dp.xml @@ -0,0 +1,5 @@ +<vector android:height="24dp" android:tint="#FFFFFF" + android:viewportHeight="24.0" android:viewportWidth="24.0" + android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="#FF000000" android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/> +</vector> diff --git a/app/src/main/res/layout/activity_search.xml b/app/src/main/res/layout/activity_search.xml new file mode 100644 index 00000000..bd440eac --- /dev/null +++ b/app/src/main/res/layout/activity_search.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<androidx.coordinatorlayout.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:layout_width="match_parent" + android:layout_height="match_parent"> + + <com.google.android.material.appbar.AppBarLayout + android:id="@+id/appbar_search_activity" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:theme="@style/AppTheme.AppBarOverlay"> + + <androidx.appcompat.widget.Toolbar + android:id="@+id/toolbar_search_activity" + android:layout_width="match_parent" + android:layout_height="?attr/actionBarSize" + android:background="?attr/colorPrimary" + app:popupTheme="@style/AppTheme.PopupOverlay" /> + + <com.google.android.material.tabs.TabLayout + android:id="@+id/tab_layout_search_activity" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@color/colorPrimary" + app:tabGravity="fill" + app:tabMode="fixed" + app:tabIndicatorColor="@android:color/white" + app:tabIndicatorHeight="3dp" + app:tabSelectedTextColor="@android:color/white" + app:tabTextColor="@android:color/white" + app:tabRippleColor="?attr/colorControlHighlight" + app:tabUnboundedRipple="false"/> + + </com.google.android.material.appbar.AppBarLayout> + + <androidx.viewpager.widget.ViewPager + android:id="@+id/view_pager_search_activity" + android:layout_width="match_parent" + android:layout_height="match_parent" + tools:context=".SearchActivity" /> + +</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml index f8894bda..9c1dfa84 100644 --- a/app/src/main/res/layout/app_bar_main.xml +++ b/app/src/main/res/layout/app_bar_main.xml @@ -11,15 +11,37 @@ android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> - <androidx.appcompat.widget.Toolbar - android:id="@+id/toolbar" + <FrameLayout + android:id="@+id/toolbar_frame_layout_main_activity" android:layout_width="match_parent" - android:layout_height="?attr/actionBarSize" - android:background="?attr/colorPrimary" - app:popupTheme="@style/AppTheme.PopupOverlay" /> + android:layout_height="wrap_content"> + + <androidx.appcompat.widget.Toolbar + android:id="@+id/toolbar" + android:layout_width="match_parent" + android:layout_height="?attr/actionBarSize" + android:background="?attr/colorPrimary" + app:popupTheme="@style/AppTheme.PopupOverlay" /> + + <com.ferfalk.simplesearchview.SimpleSearchView + android:id="@+id/search_view_main_activity" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:textColor="@android:color/white" + app:voiceSearch="true"/> + + </FrameLayout> </com.google.android.material.appbar.AppBarLayout> + <View + android:id="@+id/transparent_overlay_main_activity" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="#40000000" + android:elevation="1dp" + android:visibility="gone"/> + <include layout="@layout/content_main" /> </androidx.coordinatorlayout.widget.CoordinatorLayout> diff --git a/app/src/main/res/menu/main_activity.xml b/app/src/main/res/menu/main_activity.xml index 2be22f5f..2a4357aa 100644 --- a/app/src/main/res/menu/main_activity.xml +++ b/app/src/main/res/menu/main_activity.xml @@ -5,8 +5,15 @@ tools:context="ml.docilealligator.infinityforreddit.MainActivity"> <item android:id="@+id/action_refresh_main_activity" - android:orderInCategory="1" + android:orderInCategory="2" android:title="@string/action_refresh" android:icon="@drawable/ic_refresh_white_24dp" app:showAsAction="never" /> + + <item + android:id="@+id/action_search_main_activity" + android:orderInCategory="1" + android:title="@string/action_search" + android:icon="@drawable/ic_search_white_24dp" + app:showAsAction="always" /> </menu>
\ No newline at end of file diff --git a/app/src/main/res/menu/menu_search.xml b/app/src/main/res/menu/menu_search.xml new file mode 100644 index 00000000..afd34627 --- /dev/null +++ b/app/src/main/res/menu/menu_search.xml @@ -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="ml.docilealligator.infinityforreddit.SearchActivity"> + <item + android:id="@+id/action_search_search_activity" + android:orderInCategory="1" + android:title="@string/action_search" + app:showAsAction="always" /> +</menu> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 486fd853..a8058872 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,6 +1,7 @@ <resources> <string name="app_name">Infinity</string> <string name="login_activity_label">Login</string> + <string name="search_activity_label">Search</string> <string name="navigation_drawer_open">Open navigation drawer</string> <string name="navigation_drawer_close">Close navigation drawer</string> @@ -8,6 +9,7 @@ <string name="action_settings">Settings</string> <string name="action_download">Download</string> <string name="action_refresh">Refresh</string> + <string name="action_search">Search</string> <string name="tap_to_retry">Error loading image. Tap to retry.</string> <string name="load_posts_error">Error loading posts.\nTap to retry.</string> @@ -51,4 +53,12 @@ <string name="content_description_banner_imageview">Subreddit Banner Image</string> <string name="error_loading_posts">Error loading post</string> + + <string name="app_label">Infinity</string> + <string name="search_hint">Search anything</string> + <string name="title_activity_search">Search</string> + <string name="section_format">Hello World from section: %1$d</string> + <string name="tab_text_1">Tab 1</string> + <string name="tab_text_2">Tab 2</string> + <string name="tab_text_3">Tab 3</string> </resources> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 1ea7c276..1b770151 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -13,10 +13,13 @@ <style name="AppTheme.NoActionBar"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> + </style> + + <style name="AppTheme.NoActionBarWithTransparentStatusBar" parent="AppTheme.NoActionBar"> <item name="android:statusBarColor">@android:color/transparent</item> </style> - <style name="AppTheme.NoActionBarWithTranslucentStatusBar" parent="AppTheme.NoActionBar"> + <style name="AppTheme.NoActionBarWithTranslucentWindow" parent="AppTheme.NoActionBarWithTransparentStatusBar"> <item name="android:windowTranslucentStatus">true</item> </style> @@ -37,4 +40,11 @@ <item name="android:windowIsTranslucent">true</item> </style> + <style name="CustomTabLayout" parent="Widget.Design.TabLayout"> + <item name="tabIndicatorColor">@android:color/white</item> + <item name="tabIndicatorHeight">3dp</item> + <item name="tabBackground">?attr/selectableItemBackground</item> + <item name="tabSelectedTextColor">@android:color/white</item> + </style> + </resources> diff --git a/app/src/main/res/xml/searchable.xml b/app/src/main/res/xml/searchable.xml new file mode 100644 index 00000000..9b87146c --- /dev/null +++ b/app/src/main/res/xml/searchable.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<searchable xmlns:android="http://schemas.android.com/apk/res/android" + android:label="@string/app_label" + android:hint="@string/search_hint" + android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" > +</searchable>
\ No newline at end of file |