Closes #403 Use Fragments for Navigation, Add Toolbar to HomeActivity
parent
cf260e4b8d
commit
77883c0f30
@ -1,36 +0,0 @@
|
|||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
package org.mozilla.fenix.settings
|
|
||||||
|
|
||||||
import android.R.id.content
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.MenuItem
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
|
|
||||||
class SettingsActivity : AppCompatActivity(), SettingsFragment.ActionBarUpdater {
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
|
||||||
with(supportFragmentManager.beginTransaction()) {
|
|
||||||
replace(content, SettingsFragment())
|
|
||||||
commit()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean = when (item.itemId) {
|
|
||||||
android.R.id.home -> {
|
|
||||||
onBackPressed()
|
|
||||||
true
|
|
||||||
}
|
|
||||||
else -> super.onOptionsItemSelected(item)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun updateTitle(titleResId: Int) {
|
|
||||||
setTitle(titleResId)
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||||
|
<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="@color/icons"
|
||||||
|
android:pathData="M13.326,12l4.337,-4.337a0.938,0.938 0,0 0,-1.326 -1.326L12,10.674 7.663,6.337A0.938,0.938 0,0 0,6.337 7.663L10.674,12 6.337,16.337a0.938,0.938 0,0 0,1.326 1.326L12,13.326l4.337,4.337a0.938,0.938 0,0 0,1.326 -1.326Z" />
|
||||||
|
</vector>
|
@ -1,20 +1,26 @@
|
|||||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context=".HomeActivity">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/navigationToolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="56dp"
|
||||||
tools:context=".HomeActivity">
|
android:background="@color/off_white"
|
||||||
|
android:elevation="8dp"/>
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
android:id="@+id/container"
|
||||||
android:layout_width="match_parent"
|
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="match_parent"
|
||||||
app:navGraph="@navigation/nav_graph"
|
android:layout_height="match_parent"
|
||||||
app:defaultNavHost="true"
|
app:defaultNavHost="true"
|
||||||
android:id="@+id/container"/>
|
app:navGraph="@navigation/nav_graph" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||||
|
<menu 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">
|
||||||
|
<item
|
||||||
|
android:id="@+id/librarySearch"
|
||||||
|
android:icon="@drawable/ic_search"
|
||||||
|
android:iconTint="@color/icons"
|
||||||
|
android:title="@string/library_search"
|
||||||
|
app:showAsAction="always"
|
||||||
|
tools:targetApi="o" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/libraryClose"
|
||||||
|
android:icon="@drawable/ic_close"
|
||||||
|
android:iconTint="@color/icons"
|
||||||
|
android:title="@string/mozac_close_button_description"
|
||||||
|
app:showAsAction="always"
|
||||||
|
tools:targetApi="o" />
|
||||||
|
</menu>
|
Loading…
Reference in New Issue