aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/foundation/e/privacycentralapp/common
diff options
context:
space:
mode:
authorRomain Hunault <romain.hunault@e.email>2021-05-27 16:29:58 +0000
committerRomain Hunault <romain.hunault@e.email>2021-05-27 16:29:58 +0000
commit97b51f18dcc2f87a9cdd7f482033e30a6282d853 (patch)
treed951b14909c2dc4aab9908edea9da2122550c59d /app/src/main/java/foundation/e/privacycentralapp/common
parent7c02e9a048319c10d7396e7ec094c368f27273fd (diff)
parentfafd978342abb8332fcf3ed45cdc3b7d437576ba (diff)
downloadadvanced-privacy-97b51f18dcc2f87a9cdd7f482033e30a6282d853.tar.gz
Merge branch 'improvement/ui' into 'master'
Fix title and add back navigation support See merge request e/privacy-central/privacycentralapp!5
Diffstat (limited to 'app/src/main/java/foundation/e/privacycentralapp/common')
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/common/NavToolbarFragment.kt34
-rw-r--r--app/src/main/java/foundation/e/privacycentralapp/common/ToolbarFragment.kt43
2 files changed, 77 insertions, 0 deletions
diff --git a/app/src/main/java/foundation/e/privacycentralapp/common/NavToolbarFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/common/NavToolbarFragment.kt
new file mode 100644
index 0000000..52197cd
--- /dev/null
+++ b/app/src/main/java/foundation/e/privacycentralapp/common/NavToolbarFragment.kt
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2021 E FOUNDATION
+ *
+ * This program 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.
+ *
+ * This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package foundation.e.privacycentralapp.common
+
+import androidx.annotation.LayoutRes
+import com.google.android.material.appbar.MaterialToolbar
+
+abstract class NavToolbarFragment(@LayoutRes contentLayoutId: Int) : ToolbarFragment(contentLayoutId) {
+
+ override fun setupToolbar(toolbar: MaterialToolbar) {
+ super.setupToolbar(toolbar)
+ toolbar.apply {
+ setNavigationIcon(lineageos.platform.R.drawable.ic_back)
+ setNavigationOnClickListener {
+ requireActivity().onBackPressed()
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/foundation/e/privacycentralapp/common/ToolbarFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/common/ToolbarFragment.kt
new file mode 100644
index 0000000..f156e09
--- /dev/null
+++ b/app/src/main/java/foundation/e/privacycentralapp/common/ToolbarFragment.kt
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2021 E FOUNDATION
+ *
+ * This program 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.
+ *
+ * This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package foundation.e.privacycentralapp.common
+
+import android.os.Bundle
+import android.view.View
+import androidx.annotation.LayoutRes
+import androidx.fragment.app.Fragment
+import com.google.android.material.appbar.MaterialToolbar
+import foundation.e.privacycentralapp.R
+
+abstract class ToolbarFragment(@LayoutRes contentLayoutId: Int) : Fragment(contentLayoutId) {
+
+ /**
+ * @return title to be used in toolbar
+ */
+ abstract fun getTitle(): String
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+
+ setupToolbar(view.findViewById(R.id.toolbar))
+ }
+
+ open fun setupToolbar(toolbar: MaterialToolbar) {
+ toolbar.title = getTitle()
+ }
+}