From a130253b9a71726a80ca1a1d695406bf736d666a Mon Sep 17 00:00:00 2001 From: nominalista Date: Fri, 2 Aug 2019 18:56:31 +0200 Subject: [PATCH] Add privacy policy to settings --- .../presentation/SettingsFragmentModel.kt | 40 ++++++++++++++++++- app/src/main/res/layout/fragment_settings.xml | 2 + app/src/main/res/layout/header_settings.xml | 2 +- app/src/main/res/values-pl-rPL/strings.xml | 5 ++- app/src/main/res/values/strings.xml | 5 ++- 5 files changed, 50 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nominalista/expenses/settings/presentation/SettingsFragmentModel.kt b/app/src/main/java/com/nominalista/expenses/settings/presentation/SettingsFragmentModel.kt index f5a0eb5..3e893b5 100644 --- a/app/src/main/java/com/nominalista/expenses/settings/presentation/SettingsFragmentModel.kt +++ b/app/src/main/java/com/nominalista/expenses/settings/presentation/SettingsFragmentModel.kt @@ -2,11 +2,13 @@ package com.nominalista.expenses.settings.presentation import android.content.Context import android.net.Uri +import android.os.Build import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider import androidx.work.WorkInfo import com.nominalista.expenses.Application +import com.nominalista.expenses.BuildConfig import com.nominalista.expenses.R import com.nominalista.expenses.data.Currency import com.nominalista.expenses.data.preference.PreferenceDataSource @@ -50,7 +52,8 @@ class SettingsFragmentModel( } private fun loadItemModels() { - itemModels.value = createExpenseSection() + createGeneralSection() + itemModels.value = + createExpenseSection() + createGeneralSection() + createInformationSection() } // Expense section @@ -158,6 +161,38 @@ class SettingsFragmentModel( } } + // Information section + + private fun createInformationSection(): List { + val context = getApplication() + + val itemModels = mutableListOf() + + itemModels += createInformationHeader(context) + itemModels += createPrivacyPolicy(context) + itemModels += createVersion(context) + + return itemModels + } + + private fun createInformationHeader(context: Context): SettingItemModel = + SettingsHeaderModel(context.getString(R.string.information)) + + private fun createPrivacyPolicy(context: Context): SettingItemModel { + val title = context.getString(R.string.privacy_policy) + + return ActionSettingItemModel(title).apply { + click = { showActivity.next(PRIVACY_POLICY_URI) } + } + } + + private fun createVersion(context: Context): SettingItemModel { + val title = context.getString(R.string.version) + val summary = BuildConfig.VERSION_NAME + + return SummaryActionSettingItemModel(title, summary) + } + // Lifecycle end override fun onCleared() { @@ -250,5 +285,8 @@ class SettingsFragmentModel( private val EMAIL_URI = Uri.parse("mailto:the.nominalista@gmail.com") + + private val PRIVACY_POLICY_URI = + Uri.parse("https://github.com/nominalista/expenses/blob/master/privacy_policy.md") } } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_settings.xml b/app/src/main/res/layout/fragment_settings.xml index 12cf519..24a7862 100644 --- a/app/src/main/res/layout/fragment_settings.xml +++ b/app/src/main/res/layout/fragment_settings.xml @@ -10,6 +10,8 @@ android:id="@+id/recycler_view" android:layout_width="match_parent" android:layout_height="match_parent" + android:clipToPadding="false" + android:paddingBottom="@dimen/spacing_large" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" diff --git a/app/src/main/res/layout/header_settings.xml b/app/src/main/res/layout/header_settings.xml index 338d288..3bb9e18 100644 --- a/app/src/main/res/layout/header_settings.xml +++ b/app/src/main/res/layout/header_settings.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="48dp" + android:layout_height="56dp" android:orientation="vertical"> Filtruj Filtruj tagi Ogólne + Informacje Nazwa Nie Brak dodanych tagów. Możesz zarządzać swoimi tagami w ekranie dodawania nowego wydatku. @@ -43,7 +44,8 @@ Brak tagów Notatki Notatki (opcjonalnie) - Oceń aplikację (4.8 🌟) + Polityka Prywatności + Oceń aplikację (4.9 🌟) Zapisz Wybierz walutę Wybierz tagi @@ -57,5 +59,6 @@ Tytuł Dzisiaj Wyświetl kod źródłowy + Wersja Tak \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5c97b19..1136050 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -36,6 +36,7 @@ Filter Filter tags General + Information Name No No added tags. You can manage your tags on adding new expense screen. @@ -44,7 +45,8 @@ No tags Notes Notes (optional) - Rate the app (4.8 🌟) + Privacy Policy + Rate the app (4.9 🌟) Save Select currency Select tags @@ -58,6 +60,7 @@ Title Today View source code + Version Yes