Skip to content

Commit

Permalink
Update URLs.
Browse files Browse the repository at this point in the history
  • Loading branch information
msimonides committed Mar 17, 2024
1 parent 3d8e8aa commit 2138a54
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import com.studio4plus.homerplayer2.BuildConfig
import com.studio4plus.homerplayer2.R
import com.studio4plus.homerplayer2.base.Constants
import com.studio4plus.homerplayer2.utils.openWebUrl

@Composable
fun SettingsAboutRoute(
navigateLicenses: () -> Unit,
) {
val privacyPolicyUrl = stringResource(R.string.privacy_policy_url)
val context = LocalContext.current
val openPrivacyPolicy = { openWebUrl(context, privacyPolicyUrl) }
val openPrivacyPolicy = { openWebUrl(context, Constants.UrlPrivacyPolicy) }

SettingsAbout(
navigateLicenses = navigateLicenses,
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<resources>
<string name="app_name" translatable="false">Homer Player 2</string>
<string name="app_tag" translatable="false">homerplayer2</string>
<string name="privacy_policy_url" translatable="false">https://msimonides.github.io/homerplayer/privacy</string>

<string name="audiobook_folder_add_button">Add folder…</string>
<string name="audiobook_folder_delete_button">Remove</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
* SOFTWARE.
*/

package com.studio4plus.homerplayer2.kiosk
package com.studio4plus.homerplayer2.base

object Constants {
const val TargetAppPackage = "com.studio4plus.homerplayer2"
const val TargetHomeActivityClass = "com.studio4plus.homerplayer2.app.HomeActivity"
const val UrlSetupInstructions = "https://msimonides.github.io/homerplayer"
const val PlayerAppPackage = "com.studio4plus.homerplayer2"
const val PlayerHomeActivityClass = "com.studio4plus.homerplayer2.app.HomeActivity"
const val UrlKioskSetupInstructions = "https://msimonides.github.io/homerplayer2"
const val UrlPrivacyPolicy = "https://msimonides.github.io/homerplayer2/privacy"
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import com.studio4plus.homerplayer2.kiosk.Constants
import com.studio4plus.homerplayer2.base.Constants
import org.koin.core.annotation.Factory
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
Expand All @@ -46,12 +46,12 @@ class DeviceAdmin(
if (isOwner) {
dpm.setLockTaskPackages(
DeviceAdminReceiver.component(appContext),
arrayOf(Constants.TargetAppPackage)
arrayOf(Constants.PlayerAppPackage)
)
setPreferredHomeActivity(
appContext,
dpm,
ComponentName(Constants.TargetAppPackage, Constants.TargetHomeActivityClass)
ComponentName(Constants.PlayerAppPackage, Constants.PlayerHomeActivityClass)
)
deviceAdminStatus.setIsDeviceOwner(true)
}
Expand All @@ -63,7 +63,7 @@ class DeviceAdmin(
if (dpm.isDeviceOwnerApp(appContext.packageName)) {
dpm.clearPackagePersistentPreferredActivities(
DeviceAdminReceiver.component(appContext),
Constants.TargetAppPackage
Constants.PlayerAppPackage
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ package com.studio4plus.homerplayer2.kiosk.ui
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import com.studio4plus.homerplayer2.kiosk.Constants
import com.studio4plus.homerplayer2.base.Constants
import org.koin.core.annotation.Factory

@Factory
class Intents(
private val packageManager: PackageManager,
) {
fun openPlayer(): Intent? =
packageManager.getLaunchIntentForPackage(Constants.TargetAppPackage)
packageManager.getLaunchIntentForPackage(Constants.PlayerAppPackage)

fun installPlayer(): Intent = Intent(
Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=${Constants.TargetAppPackage}")
Uri.parse("https://play.google.com/store/apps/details?id=${Constants.PlayerAppPackage}")
)

fun openInstructions(): Intent = Intent(
Intent.ACTION_VIEW,
Uri.parse(Constants.UrlSetupInstructions)
Uri.parse(Constants.UrlKioskSetupInstructions)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@

package com.studio4plus.homerplayer2.kiosk.ui

import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import androidx.annotation.StringRes
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.studio4plus.homerplayer2.kiosk.Constants
import com.studio4plus.homerplayer2.base.Constants
import com.studio4plus.homerplayer2.kiosk.R
import com.studio4plus.homerplayer2.kiosk.deviceadmin.DeviceAdminStatus
import kotlinx.coroutines.flow.Flow
Expand Down Expand Up @@ -78,7 +76,7 @@ class MainScreenViewModel(
mainActionIntent =
if (isDeviceOwner) playerIntent ?: intents.installPlayer()
else intents.openInstructions(),
mainActionWebsiteUrl = Constants.UrlSetupInstructions.takeIf { !isDeviceOwner },
mainActionWebsiteUrl = Constants.UrlKioskSetupInstructions.takeIf { !isDeviceOwner },
dropPrivilegeEnabled = isDeviceOwner
)
}.shareIn(viewModelScope, SharingStarted.WhileSubscribed())
Expand Down

0 comments on commit 2138a54

Please sign in to comment.