forked from GitHub-Mirror/riotX-android
74 lines
2.3 KiB
Kotlin
74 lines
2.3 KiB
Kotlin
|
/*
|
||
|
* Copyright 2019 New Vector Ltd
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*/
|
||
|
package im.vector.reactions
|
||
|
|
||
|
import android.os.Bundle
|
||
|
import android.view.Menu
|
||
|
import android.view.MenuInflater
|
||
|
import android.view.MenuItem
|
||
|
import android.widget.SearchView
|
||
|
import androidx.appcompat.app.AppCompatActivity
|
||
|
import com.google.android.material.tabs.TabLayout
|
||
|
|
||
|
class EmojiReactionPickerActivity : AppCompatActivity() {
|
||
|
|
||
|
lateinit var tabLayout: TabLayout
|
||
|
|
||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||
|
super.onCreate(savedInstanceState)
|
||
|
setContentView(R.layout.activity_emoji_reaction_picker)
|
||
|
setSupportActionBar(findViewById(R.id.toolbar))
|
||
|
|
||
|
tabLayout = findViewById(R.id.tabs)
|
||
|
|
||
|
|
||
|
tabLayout.addTab(tabLayout.newTab().setText("Tab 1"));
|
||
|
tabLayout.addTab(tabLayout.newTab().setText("Tab 2"));
|
||
|
tabLayout.addTab(tabLayout.newTab().setText("Tab 3"));
|
||
|
|
||
|
|
||
|
supportActionBar?.title = getString(R.string.title_activity_emoji_reaction_picker)
|
||
|
}
|
||
|
|
||
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||
|
val inflater: MenuInflater = menuInflater
|
||
|
inflater.inflate(R.menu.menu_emoji_reaction_picker, menu)
|
||
|
|
||
|
val searchItem = menu.findItem(R.id.search)
|
||
|
(searchItem.actionView as? SearchView)?.let {
|
||
|
|
||
|
searchItem.setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
|
||
|
override fun onMenuItemActionExpand(p0: MenuItem?): Boolean {
|
||
|
it.isIconified = false
|
||
|
it.requestFocusFromTouch()
|
||
|
return true
|
||
|
}
|
||
|
|
||
|
override fun onMenuItemActionCollapse(p0: MenuItem?): Boolean {
|
||
|
// when back, clear all search
|
||
|
it.setQuery("", true)
|
||
|
return true
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
|
||
|
return true
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|