forked from upstream-mirrors/quik
Revert "Use ActionView for main search view"
This reverts commit 25580e88e8.
This commit is contained in:
@@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of QKSMS.
|
|
||||||
*
|
|
||||||
* QKSMS is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* QKSMS is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package com.moez.QKSMS.common.widget
|
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.Context
|
|
||||||
import android.util.AttributeSet
|
|
||||||
import android.view.View
|
|
||||||
import android.view.inputmethod.InputMethodManager
|
|
||||||
import android.widget.LinearLayout
|
|
||||||
import androidx.appcompat.view.CollapsibleActionView
|
|
||||||
import androidx.appcompat.widget.Toolbar
|
|
||||||
import com.jakewharton.rxbinding2.widget.textChanges
|
|
||||||
import com.moez.QKSMS.R
|
|
||||||
import com.moez.QKSMS.common.util.extensions.dismissKeyboard
|
|
||||||
import io.reactivex.Observable
|
|
||||||
import kotlinx.android.synthetic.main.search_view.view.*
|
|
||||||
|
|
||||||
|
|
||||||
class SearchView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : LinearLayout(context, attrs), CollapsibleActionView {
|
|
||||||
|
|
||||||
val queryChanged: Observable<CharSequence>
|
|
||||||
|
|
||||||
init {
|
|
||||||
View.inflate(context, R.layout.search_view, this)
|
|
||||||
orientation = LinearLayout.HORIZONTAL
|
|
||||||
layoutParams = Toolbar.LayoutParams(Toolbar.LayoutParams.MATCH_PARENT, Toolbar.LayoutParams.MATCH_PARENT)
|
|
||||||
|
|
||||||
queryChanged = query.textChanges()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActionViewExpanded() {
|
|
||||||
|
|
||||||
// Focus on the query field and display the keyboard
|
|
||||||
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
|
|
||||||
query.requestFocus()
|
|
||||||
imm?.showSoftInput(query, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActionViewCollapsed() {
|
|
||||||
// Reset the query
|
|
||||||
query.setText("")
|
|
||||||
|
|
||||||
// Dismiss the keyboard
|
|
||||||
(context as? Activity)?.dismissKeyboard()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -26,6 +26,7 @@ import android.os.Bundle
|
|||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
import androidx.appcompat.app.ActionBarDrawerToggle
|
import androidx.appcompat.app.ActionBarDrawerToggle
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
@@ -35,6 +36,7 @@ import androidx.recyclerview.widget.ItemTouchHelper
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import com.jakewharton.rxbinding2.view.clicks
|
import com.jakewharton.rxbinding2.view.clicks
|
||||||
|
import com.jakewharton.rxbinding2.widget.textChanges
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.Navigator
|
import com.moez.QKSMS.common.Navigator
|
||||||
import com.moez.QKSMS.common.androidxcompat.drawerOpen
|
import com.moez.QKSMS.common.androidxcompat.drawerOpen
|
||||||
@@ -47,7 +49,6 @@ import com.moez.QKSMS.common.util.extensions.scrapViews
|
|||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import com.moez.QKSMS.common.widget.SearchView
|
|
||||||
import com.moez.QKSMS.feature.conversations.ConversationItemTouchCallback
|
import com.moez.QKSMS.feature.conversations.ConversationItemTouchCallback
|
||||||
import com.moez.QKSMS.feature.conversations.ConversationsAdapter
|
import com.moez.QKSMS.feature.conversations.ConversationsAdapter
|
||||||
import com.moez.QKSMS.repository.SyncRepository
|
import com.moez.QKSMS.repository.SyncRepository
|
||||||
@@ -70,7 +71,7 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
@Inject lateinit var viewModelFactory: ViewModelProvider.Factory
|
@Inject lateinit var viewModelFactory: ViewModelProvider.Factory
|
||||||
|
|
||||||
override val activityResumedIntent: Subject<Unit> = PublishSubject.create()
|
override val activityResumedIntent: Subject<Unit> = PublishSubject.create()
|
||||||
override val queryChangedIntent: Subject<CharSequence> = PublishSubject.create()
|
override val queryChangedIntent by lazy { toolbarSearch.textChanges() }
|
||||||
override val composeIntent by lazy { compose.clicks() }
|
override val composeIntent by lazy { compose.clicks() }
|
||||||
override val drawerOpenIntent: Observable<Boolean> by lazy {
|
override val drawerOpenIntent: Observable<Boolean> by lazy {
|
||||||
drawerLayout
|
drawerLayout
|
||||||
@@ -188,7 +189,9 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
else -> 0
|
else -> 0
|
||||||
}
|
}
|
||||||
|
|
||||||
toolbar.menu.findItem(R.id.search)?.isVisible = state.page is Inbox && state.page.selected == 0 || state.page is Searching
|
toolbarSearch.setVisible(state.page is Inbox && state.page.selected == 0 || state.page is Searching)
|
||||||
|
toolbarTitle.setVisible(toolbarSearch.visibility != View.VISIBLE)
|
||||||
|
|
||||||
toolbar.menu.findItem(R.id.archive)?.isVisible = state.page is Inbox && selectedConversations != 0
|
toolbar.menu.findItem(R.id.archive)?.isVisible = state.page is Inbox && selectedConversations != 0
|
||||||
toolbar.menu.findItem(R.id.unarchive)?.isVisible = state.page is Archived && selectedConversations != 0
|
toolbar.menu.findItem(R.id.unarchive)?.isVisible = state.page is Archived && selectedConversations != 0
|
||||||
toolbar.menu.findItem(R.id.delete)?.isVisible = selectedConversations != 0
|
toolbar.menu.findItem(R.id.delete)?.isVisible = selectedConversations != 0
|
||||||
@@ -211,10 +214,7 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
when (state.page) {
|
when (state.page) {
|
||||||
is Inbox -> {
|
is Inbox -> {
|
||||||
showBackButton(state.page.selected > 0)
|
showBackButton(state.page.selected > 0)
|
||||||
title = when (state.page.selected != 0) {
|
title = getString(R.string.main_title_selected, state.page.selected)
|
||||||
true -> getString(R.string.main_title_selected, state.page.selected)
|
|
||||||
false -> getString(R.string.main_title)
|
|
||||||
}
|
|
||||||
if (recyclerView.adapter !== conversationsAdapter) recyclerView.adapter = conversationsAdapter
|
if (recyclerView.adapter !== conversationsAdapter) recyclerView.adapter = conversationsAdapter
|
||||||
conversationsAdapter.updateData(state.page.data)
|
conversationsAdapter.updateData(state.page.data)
|
||||||
itemTouchHelper.attachToRecyclerView(recyclerView)
|
itemTouchHelper.attachToRecyclerView(recyclerView)
|
||||||
@@ -301,7 +301,8 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun clearSearch() {
|
override fun clearSearch() {
|
||||||
toolbar.menu.findItem(R.id.search)?.collapseActionView()
|
dismissKeyboard()
|
||||||
|
toolbarSearch.text = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearSelection() {
|
override fun clearSelection() {
|
||||||
@@ -324,13 +325,6 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
menuInflater.inflate(R.menu.main, menu)
|
menuInflater.inflate(R.menu.main, menu)
|
||||||
|
|
||||||
// Query changes
|
|
||||||
menu?.findItem(R.id.search)
|
|
||||||
?.let { search -> search.actionView as? SearchView }
|
|
||||||
?.queryChanged
|
|
||||||
?.subscribe(queryChangedIntent)
|
|
||||||
|
|
||||||
return super.onCreateOptionsMenu(menu)
|
return super.onCreateOptionsMenu(menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
<!--
|
|
||||||
~ Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
|
||||||
~
|
|
||||||
~ This file is part of QKSMS.
|
|
||||||
~
|
|
||||||
~ QKSMS is free software: you can redistribute it and/or modify
|
|
||||||
~ it under the terms of the GNU General Public License as published by
|
|
||||||
~ the Free Software Foundation, either version 3 of the License, or
|
|
||||||
~ (at your option) any later version.
|
|
||||||
~
|
|
||||||
~ QKSMS is distributed in the hope that it will be useful,
|
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
~ GNU General Public License for more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License
|
|
||||||
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
<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.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>
|
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
<androidx.appcompat.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
style="@style/Toolbar"
|
style="@style/Toolbar"
|
||||||
android:elevation="8dp"
|
android:animateLayoutChanges="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
@@ -41,8 +41,16 @@
|
|||||||
|
|
||||||
<com.moez.QKSMS.common.widget.QkTextView
|
<com.moez.QKSMS.common.widget.QkTextView
|
||||||
android:id="@+id/toolbarTitle"
|
android:id="@+id/toolbarTitle"
|
||||||
|
style="@style/ToolbarText" />
|
||||||
|
|
||||||
|
<com.moez.QKSMS.common.widget.QkEditText
|
||||||
|
android:id="@+id/toolbarSearch"
|
||||||
style="@style/ToolbarText"
|
style="@style/ToolbarText"
|
||||||
tools:text="Conversations" />
|
android:layout_marginEnd="16dp"
|
||||||
|
android:hint="@string/title_conversations"
|
||||||
|
android:textColorHint="?android:attr/textColorTertiary"
|
||||||
|
app:textSize="primary"
|
||||||
|
tools:textSize="16sp" />
|
||||||
|
|
||||||
</androidx.appcompat.widget.Toolbar>
|
</androidx.appcompat.widget.Toolbar>
|
||||||
|
|
||||||
@@ -85,6 +93,14 @@
|
|||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
tools:backgroundTint="@color/tools_theme" />
|
tools:backgroundTint="@color/tools_theme" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="8dp"
|
||||||
|
android:background="@drawable/ab_shadow"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/bottom"
|
android:id="@+id/bottom"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
~ Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
|
||||||
~
|
|
||||||
~ This file is part of QKSMS.
|
|
||||||
~
|
|
||||||
~ QKSMS is free software: you can redistribute it and/or modify
|
|
||||||
~ it under the terms of the GNU General Public License as published by
|
|
||||||
~ the Free Software Foundation, either version 3 of the License, or
|
|
||||||
~ (at your option) any later version.
|
|
||||||
~
|
|
||||||
~ QKSMS is distributed in the hope that it will be useful,
|
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
~ GNU General Public License for more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License
|
|
||||||
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
<merge 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"
|
|
||||||
tools:parentTag="com.moez.QKSMS.common.widget.SearchView">
|
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.QkEditText
|
|
||||||
android:id="@+id/query"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="@null"
|
|
||||||
android:hint="@string/title_conversations"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
|
||||||
android:textColorHint="?android:attr/textColorTertiary"
|
|
||||||
app:textSize="primary" />
|
|
||||||
|
|
||||||
</merge>
|
|
||||||
@@ -19,13 +19,6 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/search"
|
|
||||||
android:icon="@drawable/ic_search_black_24dp"
|
|
||||||
android:title="@string/main_menu_search"
|
|
||||||
app:actionViewClass="com.moez.QKSMS.common.widget.SearchView"
|
|
||||||
app:showAsAction="always|collapseActionView" />
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/archive"
|
android:id="@+id/archive"
|
||||||
android:icon="@drawable/ic_archive_black_24dp"
|
android:icon="@drawable/ic_archive_black_24dp"
|
||||||
|
|||||||
@@ -39,10 +39,8 @@
|
|||||||
<string name="menu_info">Details</string>
|
<string name="menu_info">Details</string>
|
||||||
<string name="menu_save">Save to gallery</string>
|
<string name="menu_save">Save to gallery</string>
|
||||||
|
|
||||||
<string name="main_title">Inbox</string>
|
|
||||||
<string name="main_drawer_open_cd">Open navigation drawer</string>
|
<string name="main_drawer_open_cd">Open navigation drawer</string>
|
||||||
<string name="main_title_selected">%d selected</string>
|
<string name="main_title_selected">%d selected</string>
|
||||||
<string name="main_menu_search">Search</string>
|
|
||||||
<string name="main_menu_clear">Clear</string>
|
<string name="main_menu_clear">Clear</string>
|
||||||
<string name="main_menu_archive">Archive</string>
|
<string name="main_menu_archive">Archive</string>
|
||||||
<string name="main_menu_unarchive">Unarchive</string>
|
<string name="main_menu_unarchive">Unarchive</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user