Skip to content

Commit

Permalink
Add privacy policy to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
nominalista committed Aug 2, 2019
1 parent c21ad57 commit a130253
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,7 +52,8 @@ class SettingsFragmentModel(
}

private fun loadItemModels() {
itemModels.value = createExpenseSection() + createGeneralSection()
itemModels.value =
createExpenseSection() + createGeneralSection() + createInformationSection()
}

// Expense section
Expand Down Expand Up @@ -158,6 +161,38 @@ class SettingsFragmentModel(
}
}

// Information section

private fun createInformationSection(): List<SettingItemModel> {
val context = getApplication<Application>()

val itemModels = mutableListOf<SettingItemModel>()

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() {
Expand Down Expand Up @@ -250,5 +285,8 @@ class SettingsFragmentModel(

private val EMAIL_URI =
Uri.parse("mailto:[email protected]")

private val PRIVACY_POLICY_URI =
Uri.parse("https://github.com/nominalista/expenses/blob/master/privacy_policy.md")
}
}
2 changes: 2 additions & 0 deletions app/src/main/res/layout/fragment_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/header_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<View
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/res/values-pl-rPL/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<string name="filter">Filtruj</string>
<string name="filter_tags">Filtruj tagi</string>
<string name="general">Ogólne</string>
<string name="information">Informacje</string>
<string name="name">Nazwa</string>
<string name="no">Nie</string>
<string name="no_added_tags_message">Brak dodanych tagów. Możesz zarządzać swoimi tagami w ekranie dodawania nowego wydatku.</string>
Expand All @@ -43,7 +44,8 @@
<string name="no_tags">Brak tagów</string>
<string name="notes_title">Notatki</string>
<string name="notes_hint">Notatki (opcjonalnie)</string>
<string name="rate_app">Oceń aplikację (4.8 &#x1F31F;)</string>
<string name="privacy_policy">Polityka Prywatności</string>
<string name="rate_app">Oceń aplikację (4.9 &#x1F31F;)</string>
<string name="save">Zapisz</string>
<string name="select_currency">Wybierz walutę</string>
<string name="select_tags">Wybierz tagi</string>
Expand All @@ -57,5 +59,6 @@
<string name="title_hint">Tytuł</string>
<string name="today">Dzisiaj</string>
<string name="view_source_code">Wyświetl kod źródłowy</string>
<string name="version">Wersja</string>
<string name="yes">Tak</string>
</resources>
5 changes: 4 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<string name="filter">Filter</string>
<string name="filter_tags">Filter tags</string>
<string name="general">General</string>
<string name="information">Information</string>
<string name="name">Name</string>
<string name="no">No</string>
<string name="no_added_tags_message">No added tags. You can manage your tags on adding new expense screen.</string>
Expand All @@ -44,7 +45,8 @@
<string name="no_tags">No tags</string>
<string name="notes_title">Notes</string>
<string name="notes_hint">Notes (optional)</string>
<string name="rate_app">Rate the app (4.8 &#x1F31F;)</string>
<string name="privacy_policy">Privacy Policy</string>
<string name="rate_app">Rate the app (4.9 &#x1F31F;)</string>
<string name="save">Save</string>
<string name="select_currency">Select currency</string>
<string name="select_tags">Select tags</string>
Expand All @@ -58,6 +60,7 @@
<string name="title_hint">Title</string>
<string name="today">Today</string>
<string name="view_source_code">View source code</string>
<string name="version">Version</string>
<string name="yes">Yes</string>

<!-- Shared Preferences -->
Expand Down

0 comments on commit a130253

Please sign in to comment.