Skip to content

Commit

Permalink
Add GitHub section on settings screen (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
AfigAliyev committed Nov 3, 2022
1 parent fb45092 commit 59336d5
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import javax.inject.Inject
class SettingsRepositoryImpl @Inject constructor(
databaseDataSource: SettingsDatabaseDataSource
) : SettingsRepository {
override val repoUrl = databaseDataSource.repoUrl
override val privacyPolicyUrl = databaseDataSource.privacyPolicyUrl
override val version = databaseDataSource.version
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.maximillianleonov.cinemax.core.database.util.Constants
import javax.inject.Inject

class SettingsDatabaseDataSource @Inject constructor(versionProvider: CinemaxVersionProvider) {
val repoUrl = Constants.Urls.CINEMAX_REPO_URL
val privacyPolicyUrl = Constants.Urls.PRIVACY_POLICY_URL
val version = versionProvider.version
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ internal object Constants {

internal object Urls {
private const val CINEMAX_PAGE_URL = "https://maximillianleonov.github.io/Cinemax"
internal const val CINEMAX_REPO_URL = "https://github.com/MaximillianLeonov/Cinemax"
internal const val PRIVACY_POLICY_URL = "$CINEMAX_PAGE_URL/privacy-policy.html"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.maximillianleonov.cinemax.core.domain.repository

interface SettingsRepository {
val repoUrl: String
val privacyPolicyUrl: String
val version: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2022 Maximillian Leonov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.maximillianleonov.cinemax.core.domain.usecase

import com.maximillianleonov.cinemax.core.domain.repository.SettingsRepository
import javax.inject.Inject

class GetSettingsRepoUrlUseCase @Inject constructor(private val repository: SettingsRepository) {
operator fun invoke() = repository.repoUrl
}
25 changes: 25 additions & 0 deletions core/core-ui/src/main/res/drawable/ic_github.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2022 Maximillian Leonov
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#ffffff"
android:pathData="M10.9,2.1c-4.6,0.5 -8.3,4.2 -8.8,8.7c-0.5,4.7 2.2,8.9 6.3,10.5C8.7,21.4 9,21.2 9,20.8v-1.6c0,0 -0.4,0.1 -0.9,0.1c-1.4,0 -2,-1.2 -2.1,-1.9c-0.1,-0.4 -0.3,-0.7 -0.6,-1C5.1,16.3 5,16.3 5,16.2C5,16 5.3,16 5.4,16c0.6,0 1.1,0.7 1.3,1c0.5,0.8 1.1,1 1.4,1c0.4,0 0.7,-0.1 0.9,-0.2c0.1,-0.7 0.4,-1.4 1,-1.8c-2.3,-0.5 -4,-1.8 -4,-4c0,-1.1 0.5,-2.2 1.2,-3C7.1,8.8 7,8.3 7,7.6C7,7.2 7,6.6 7.3,6c0,0 1.4,0 2.8,1.3C10.6,7.1 11.3,7 12,7s1.4,0.1 2,0.3C15.3,6 16.8,6 16.8,6C17,6.6 17,7.2 17,7.6c0,0.8 -0.1,1.2 -0.2,1.4c0.7,0.8 1.2,1.8 1.2,3c0,2.2 -1.7,3.5 -4,4c0.6,0.5 1,1.4 1,2.3v2.6c0,0.3 0.3,0.6 0.7,0.5c3.7,-1.5 6.3,-5.1 6.3,-9.3C22,6.1 16.9,1.4 10.9,2.1z" />
</vector>
1 change: 1 addition & 0 deletions core/core-ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<string name="settings">Settings</string>

<string name="about">About</string>
<string name="source_code_github">Source code on GitHub</string>
<string name="privacy_policy">Privacy Policy</string>
<string name="version">Version</string>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import android.content.Intent
import androidx.core.net.toUri
import androidx.lifecycle.ViewModel
import com.maximillianleonov.cinemax.core.domain.usecase.GetSettingsPrivacyPolicyUrlUseCase
import com.maximillianleonov.cinemax.core.domain.usecase.GetSettingsRepoUrlUseCase
import com.maximillianleonov.cinemax.core.domain.usecase.GetSettingsVersionUseCase
import com.maximillianleonov.cinemax.core.ui.R
import com.maximillianleonov.cinemax.core.ui.common.EventHandler
Expand All @@ -32,6 +33,7 @@ import javax.inject.Inject

@HiltViewModel
class SettingsViewModel @Inject constructor(
private val getSettingsRepoUrlUseCase: GetSettingsRepoUrlUseCase,
private val getSettingsPrivacyPolicyUrlUseCase: GetSettingsPrivacyPolicyUrlUseCase,
private val getSettingsVersionUseCase: GetSettingsVersionUseCase
) : ViewModel(), EventHandler<SettingsEvent> {
Expand All @@ -41,10 +43,16 @@ class SettingsViewModel @Inject constructor(
override fun onEvent(event: SettingsEvent) = Unit

private fun getInitialUiState(): SettingsUiState {
val repoUrl = getSettingsRepoUrlUseCase().toUri()
val privacyPolicyUrl = getSettingsPrivacyPolicyUrlUseCase().toUri()
val version = getSettingsVersionUseCase()

val aboutSettings = listOf(
Settings.IntentAction(
iconResourceId = R.drawable.ic_github,
titleResourceId = R.string.source_code_github,
intent = Intent(Intent.ACTION_VIEW, repoUrl)
),
Settings.IntentAction(
iconResourceId = R.drawable.ic_shield,
titleResourceId = R.string.privacy_policy,
Expand Down

0 comments on commit 59336d5

Please sign in to comment.