mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
show search result placeholder when no results are shown
This commit is contained in:
@ -43,7 +43,7 @@ ext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:3.7.7'
|
implementation 'com.simplemobiletools:commons:3.7.9'
|
||||||
implementation 'joda-time:joda-time:2.9.9'
|
implementation 'joda-time:joda-time:2.9.9'
|
||||||
implementation 'com.facebook.stetho:stetho:1.5.0'
|
implementation 'com.facebook.stetho:stetho:1.5.0'
|
||||||
implementation 'com.android.support:multidex:1.0.2'
|
implementation 'com.android.support:multidex:1.0.2'
|
||||||
|
@ -6,6 +6,7 @@ import android.content.Intent
|
|||||||
import android.content.pm.ActivityInfo
|
import android.content.pm.ActivityInfo
|
||||||
import android.database.ContentObserver
|
import android.database.ContentObserver
|
||||||
import android.database.Cursor
|
import android.database.Cursor
|
||||||
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
@ -147,6 +148,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||||||
|
|
||||||
updateWidgets()
|
updateWidgets()
|
||||||
updateTextColors(calendar_coordinator)
|
updateTextColors(calendar_coordinator)
|
||||||
|
search_holder.background = ColorDrawable(config.backgroundColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
@ -221,7 +223,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||||||
override fun onQueryTextSubmit(query: String) = false
|
override fun onQueryTextSubmit(query: String) = false
|
||||||
|
|
||||||
override fun onQueryTextChange(newText: String): Boolean {
|
override fun onQueryTextChange(newText: String): Boolean {
|
||||||
if (mIsSearchOpen && newText.length >= 3) {
|
if (mIsSearchOpen) {
|
||||||
searchQueryChanged(newText)
|
searchQueryChanged(newText)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@ -232,11 +234,16 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||||||
MenuItemCompat.setOnActionExpandListener(mSearchMenuItem, object : MenuItemCompat.OnActionExpandListener {
|
MenuItemCompat.setOnActionExpandListener(mSearchMenuItem, object : MenuItemCompat.OnActionExpandListener {
|
||||||
override fun onMenuItemActionExpand(item: MenuItem?): Boolean {
|
override fun onMenuItemActionExpand(item: MenuItem?): Boolean {
|
||||||
mIsSearchOpen = true
|
mIsSearchOpen = true
|
||||||
|
search_holder.beVisible()
|
||||||
|
calendar_fab.beGone()
|
||||||
|
searchQueryChanged("")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMenuItemActionCollapse(item: MenuItem?): Boolean {
|
override fun onMenuItemActionCollapse(item: MenuItem?): Boolean {
|
||||||
mIsSearchOpen = false
|
mIsSearchOpen = false
|
||||||
|
search_holder.beGone()
|
||||||
|
calendar_fab.beVisible()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -772,12 +779,15 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||||||
|
|
||||||
private fun searchQueryChanged(text: String) {
|
private fun searchQueryChanged(text: String) {
|
||||||
mLatestSearchQuery = text
|
mLatestSearchQuery = text
|
||||||
|
search_placeholder_2.beGoneIf(text.length >= 2)
|
||||||
|
if (text.length >= 2) {
|
||||||
dbHelper.getEventsWithSearchQuery(text) { searchedText, events ->
|
dbHelper.getEventsWithSearchQuery(text) { searchedText, events ->
|
||||||
if (searchedText == mLatestSearchQuery) {
|
if (searchedText == mLatestSearchQuery) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun goLeft() {
|
override fun goLeft() {
|
||||||
main_view_pager.currentItem = main_view_pager.currentItem - 1
|
main_view_pager.currentItem = main_view_pager.currentItem - 1
|
||||||
|
@ -23,9 +23,9 @@
|
|||||||
android:id="@+id/week_view_hours_divider"
|
android:id="@+id/week_view_hours_divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:importantForAccessibility="no"
|
|
||||||
android:layout_alignRight="@+id/week_view_hours_scrollview"
|
android:layout_alignRight="@+id/week_view_hours_scrollview"
|
||||||
android:background="@drawable/stroke_bottom_right"/>
|
android:background="@drawable/stroke_bottom_right"
|
||||||
|
android:importantForAccessibility="no"/>
|
||||||
|
|
||||||
<com.simplemobiletools.calendar.views.MyScrollView
|
<com.simplemobiletools.calendar.views.MyScrollView
|
||||||
android:id="@+id/week_view_hours_scrollview"
|
android:id="@+id/week_view_hours_scrollview"
|
||||||
@ -76,4 +76,44 @@
|
|||||||
app:backgroundTint="@color/color_primary"
|
app:backgroundTint="@color/color_primary"
|
||||||
app:rippleColor="@color/pressed_item_foreground"/>
|
app:rippleColor="@color/pressed_item_foreground"/>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/search_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:clickable="true"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
android:id="@+id/search_placeholder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginTop="@dimen/activity_margin"
|
||||||
|
android:gravity="center"
|
||||||
|
android:paddingLeft="@dimen/activity_margin"
|
||||||
|
android:paddingRight="@dimen/activity_margin"
|
||||||
|
android:text="@string/no_items_found"
|
||||||
|
android:textSize="@dimen/bigger_text_size"/>
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
android:id="@+id/search_placeholder_2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/search_placeholder"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:gravity="center"
|
||||||
|
android:paddingBottom="@dimen/medium_margin"
|
||||||
|
android:paddingLeft="@dimen/activity_margin"
|
||||||
|
android:paddingRight="@dimen/activity_margin"
|
||||||
|
android:paddingTop="@dimen/medium_margin"
|
||||||
|
android:text="@string/type_2_characters"
|
||||||
|
android:textSize="@dimen/bigger_text_size"/>
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
|
android:id="@+id/search_results"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
|
Reference in New Issue
Block a user