diff --git a/play-services-core/src/main/kotlin/com/google/android/gms/wearable/consent/TermsOfServiceActivity.kt b/play-services-core/src/main/kotlin/com/google/android/gms/wearable/consent/TermsOfServiceActivity.kt index 83246ba405..e46c6bbc23 100644 --- a/play-services-core/src/main/kotlin/com/google/android/gms/wearable/consent/TermsOfServiceActivity.kt +++ b/play-services-core/src/main/kotlin/com/google/android/gms/wearable/consent/TermsOfServiceActivity.kt @@ -1,18 +1,54 @@ -/** +/* * SPDX-FileCopyrightText: 2025 microG Project Team * SPDX-License-Identifier: Apache-2.0 */ package com.google.android.gms.wearable.consent +import android.content.SharedPreferences import android.os.Bundle import androidx.appcompat.app.AppCompatActivity +import com.google.android.gms.wearable.R class TermsOfServiceActivity : AppCompatActivity() { + companion object { + const val WEARABLE_TOS_ACCEPTED = "wearable_tos_accepted" + const val WEARABLE_TOS_PREFS = "wearable_tos_prefs" + } + + private var resultCode: Int = RESULT_CANCELED + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setResult(RESULT_CANCELED) - finish() + setContentView(R.layout.activity_wearable_tos) + + findViewById(R.id.button_accept).setOnClickListener { + resultCode = RESULT_OK + saveTosAccepted(true) + finish() + } + + findViewById(R.id.button_decline).setOnClickListener { + resultCode = RESULT_CANCELED + finish() + } + } + + override fun finish() { + setResult(resultCode) + super.finish() + } + + private fun saveTosAccepted(accepted: Boolean) { + getSharedPreferences(WEARABLE_TOS_PREFS, MODE_PRIVATE) + .edit() + .putBoolean(WEARABLE_TOS_ACCEPTED, accepted) + .apply() + } + + fun isTosAccepted(): Boolean { + return getSharedPreferences(WEARABLE_TOS_PREFS, MODE_PRIVATE) + .getBoolean(WEARABLE_TOS_ACCEPTED, false) } } \ No newline at end of file diff --git a/play-services-core/src/main/res/layout/activity_wearable_tos.xml b/play-services-core/src/main/res/layout/activity_wearable_tos.xml new file mode 100644 index 0000000000..208edd33f5 --- /dev/null +++ b/play-services-core/src/main/res/layout/activity_wearable_tos.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + +