Restore download manager icon to toolbar
This commit is contained in:
@@ -28,6 +28,8 @@ import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.provider.Settings
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
@@ -101,7 +103,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
this.lifecycleScope.launch {
|
||||
NetworkProvider(applicationContext).networkStatus.collect {
|
||||
when(it) {
|
||||
when (it) {
|
||||
NetworkStatus.AVAILABLE -> {
|
||||
if (!supportFragmentManager.isDestroyed && isIntroDone()) {
|
||||
val fragment = supportFragmentManager
|
||||
@@ -113,6 +115,7 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NetworkStatus.LOST -> {
|
||||
if (!supportFragmentManager.isDestroyed && isIntroDone()) {
|
||||
supportFragmentManager.beginTransaction()
|
||||
@@ -199,6 +202,7 @@ class MainActivity : AppCompatActivity() {
|
||||
B.toolbar.visibility = View.VISIBLE
|
||||
B.drawerLayout.setDrawerLockMode(LOCK_MODE_UNLOCKED)
|
||||
}
|
||||
|
||||
else -> {
|
||||
hideTopLevelOnlyViews()
|
||||
}
|
||||
@@ -207,6 +211,21 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_main, menu)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.menu_download_manager -> {
|
||||
navController.navigate(R.id.downloadFragment)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun hideTopLevelOnlyViews() {
|
||||
B.searchFab.visibility = View.GONE
|
||||
B.navView.visibility = View.GONE
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:navigationIcon="@drawable/ic_menu_unfold"
|
||||
app:menu="@menu/menu_main"
|
||||
app:title="@string/app_name" />
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
|
||||
27
app/src/main/res/menu/menu_main.xml
Normal file
27
app/src/main/res/menu/menu_main.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Aurora Store
|
||||
~ Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
~
|
||||
~ Aurora Store 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 2 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ Aurora Store 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 Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
~
|
||||
-->
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/menu_download_manager"
|
||||
android:icon="@drawable/ic_download_manager"
|
||||
android:title="@string/title_download_manager"
|
||||
app:showAsAction="always" />
|
||||
</menu>
|
||||
Reference in New Issue
Block a user