diff options
| author | Amit Kumar <amitkma@e.email> | 2021-05-14 21:20:57 +0530 |
|---|---|---|
| committer | Amit Kumar <amitkma@e.email> | 2021-05-14 21:20:57 +0530 |
| commit | da842396556248654acacfdebbc01f5e20132eb6 (patch) | |
| tree | f2953fe0c56fea020869d0dfed77f3a4e851d434 /app/src/main/java/foundation/e/privacycentralapp/common | |
| parent | 7c02e9a048319c10d7396e7ec094c368f27273fd (diff) | |
| download | advanced-privacy-da842396556248654acacfdebbc01f5e20132eb6.tar.gz | |
Extract toolbar implementation and add back navigation support
Diffstat (limited to 'app/src/main/java/foundation/e/privacycentralapp/common')
| -rw-r--r-- | app/src/main/java/foundation/e/privacycentralapp/common/NavToolbarFragment.kt | 34 | ||||
| -rw-r--r-- | app/src/main/java/foundation/e/privacycentralapp/common/ToolbarFragment.kt | 42 |
2 files changed, 76 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..0a9d102 --- /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 android.widget.Toolbar +import androidx.annotation.LayoutRes + +abstract class NavToolbarFragment(@LayoutRes contentLayoutId: Int) : ToolbarFragment(contentLayoutId) { + + override fun setupToolbar(toolbar: Toolbar) { + 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..c316340 --- /dev/null +++ b/app/src/main/java/foundation/e/privacycentralapp/common/ToolbarFragment.kt @@ -0,0 +1,42 @@ +/* + * 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 android.widget.Toolbar +import androidx.annotation.LayoutRes +import androidx.fragment.app.Fragment +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: Toolbar) { + toolbar.title = getTitle() + } +} |
