diff --git a/storage/demo/src/main/java/de/grobox/storagebackuptester/LogFragment.kt b/storage/demo/src/main/java/de/grobox/storagebackuptester/LogFragment.kt index 027ab534..38eb6f32 100644 --- a/storage/demo/src/main/java/de/grobox/storagebackuptester/LogFragment.kt +++ b/storage/demo/src/main/java/de/grobox/storagebackuptester/LogFragment.kt @@ -11,8 +11,6 @@ import android.os.Bundle import android.os.Environment import android.provider.Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION import android.view.LayoutInflater -import android.view.Menu -import android.view.MenuInflater import android.view.MenuItem import android.view.View import android.view.View.INVISIBLE @@ -22,6 +20,7 @@ import android.widget.Button import android.widget.ProgressBar import android.widget.Toast import android.widget.Toast.LENGTH_SHORT +import androidx.appcompat.widget.Toolbar import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.recyclerview.widget.RecyclerView @@ -48,7 +47,6 @@ open class LogFragment : Fragment() { container: ViewGroup?, savedInstanceState: Bundle?, ): View { - setHasOptionsMenu(true) val v = inflater.inflate(R.layout.fragment_log, container, false) list = v.findViewById(R.id.listView) list.adapter = adapter @@ -75,16 +73,16 @@ open class LogFragment : Fragment() { return v } - override fun onStart() { - super.onStart() - requireActivity().setTitle(R.string.app_name) + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + view.requireViewById(R.id.toolbar).apply { + title = getString(R.string.app_name) + setOnMenuItemClickListener(::onMenuItemSelected) + } } - override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { - inflater.inflate(R.menu.fragment_main, menu) - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { + private fun onMenuItemSelected(item: MenuItem): Boolean { return when (item.itemId) { R.id.settings -> { if (!checkPermission()) return false @@ -108,7 +106,7 @@ open class LogFragment : Fragment() { startActivity(shareIntent) true } - else -> super.onOptionsItemSelected(item) + else -> false } } diff --git a/storage/demo/src/main/java/de/grobox/storagebackuptester/restore/DemoSnapshotFragment.kt b/storage/demo/src/main/java/de/grobox/storagebackuptester/restore/DemoSnapshotFragment.kt index 13fcf328..dd5ab72b 100644 --- a/storage/demo/src/main/java/de/grobox/storagebackuptester/restore/DemoSnapshotFragment.kt +++ b/storage/demo/src/main/java/de/grobox/storagebackuptester/restore/DemoSnapshotFragment.kt @@ -31,7 +31,7 @@ class DemoSnapshotFragment : SnapshotFragment() { bottomStub.layoutResource = R.layout.footer_snapshot val footer = bottomStub.inflate() footer.findViewById