Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Added PrivacyPolicyActivity to accept Privacy Policy

Michael Rademaker839545a4c84d
diff --git a/console/android/GenericApp/app/build.gradle b/console/android/GenericApp/app/build.gradle
index afec78c5e..6bdb64ee8 100644
--- a/console/android/GenericApp/app/build.gradle
+++ b/console/android/GenericApp/app/build.gradle
@@ -10,7 +10,7 @@ android {
applicationId "io.openremote.app"
minSdkVersion 25
targetSdkVersion 30
- versionCode 21
+ versionCode 22
versionName "1.0.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -47,4 +47,5 @@ dependencies {
implementation platform('com.google.firebase:firebase-bom:26.0.0')
implementation 'com.google.firebase:firebase-messaging-ktx'
implementation 'com.google.android.material:material:1.3.0'
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
\ No newline at end of file
diff --git a/console/android/GenericApp/app/src/main/AndroidManifest.xml b/console/android/GenericApp/app/src/main/AndroidManifest.xml
index a5b62db75..048113d43 100644
--- a/console/android/GenericApp/app/src/main/AndroidManifest.xml
+++ b/console/android/GenericApp/app/src/main/AndroidManifest.xml
@@ -19,6 +19,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/OpenRemoteTheme">
+ <activity android:name=".ui.PrivacyPolicyActivity"></activity>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
@@ -50,27 +51,22 @@
android:label="@string/title_activity_project" />
<activity android:name=".ui.MainActivity" />
- <service android:name="io.openremote.app.service.ORFirebaseMessagingService">
+ <service android:name=".service.ORFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
-
- <service android:name="io.openremote.app.service.ORMessagingActionService">
-
- </service>
+ <service android:name=".service.ORMessagingActionService"></service>
<receiver android:name=".service.GeofenceBootCompleteReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
-
<receiver
android:name=".service.GeofenceTransitionsIntentService"
android:enabled="true"
android:exported="true" />
-
</application>
</manifest>
\ No newline at end of file
diff --git a/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/PrivacyPolicyActivity.kt b/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/PrivacyPolicyActivity.kt
new file mode 100644
index 000000000..9260fcbde
--- /dev/null
+++ b/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/PrivacyPolicyActivity.kt
@@ -0,0 +1,37 @@
+package io.openremote.app.ui
+
+import android.content.Intent
+import android.os.Bundle
+import android.view.View
+import androidx.appcompat.app.AppCompatActivity
+import io.openremote.app.databinding.ActivityPrivacyPolicyBinding
+
+class PrivacyPolicyActivity : AppCompatActivity() {
+
+ private lateinit var binding: ActivityPrivacyPolicyBinding
+ private var isAccepted = false
+
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ binding = ActivityPrivacyPolicyBinding.inflate(layoutInflater)
+ val view = binding.root
+ setContentView(view)
+
+ binding.webView.loadUrl("https://openremote.io/privacy-policy/")
+
+ binding.buttonAccept.setOnClickListener {
+ if (isAccepted) {
+ val intent = Intent()
+ setResult(RESULT_OK, intent)
+ finish()
+ }
+ }
+
+ binding.checkbox.setOnClickListener(View.OnClickListener { v: View? ->
+ isAccepted = !isAccepted
+
+ binding.buttonAccept.setEnabled(isAccepted)
+ })
+ }
+}
\ No newline at end of file
diff --git a/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/SplashActivity.kt b/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/SplashActivity.kt
index c710e22e8..32e1c27a1 100644
--- a/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/SplashActivity.kt
+++ b/console/android/GenericApp/app/src/main/java/io/openremote/app/ui/SplashActivity.kt
@@ -12,6 +12,8 @@ import io.openremote.app.ui.MainActivity.Companion.APP_CONFIG_KEY
class SplashActivity : Activity() {
+ private val SHOW_CONDITIONS_REQUEST = 34563
+
private lateinit var binding: ActivitySplashBinding
var sharedPreferences: SharedPreferences? = null
@@ -24,6 +26,17 @@ class SplashActivity : Activity() {
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
+ val privacyPolicyAccepted = sharedPreferences!!.getBoolean("privacyPolicyAccepted", false)
+
+ if (!privacyPolicyAccepted) {
+ val intent = Intent(this@SplashActivity, PrivacyPolicyActivity::class.java)
+ startActivityForResult(intent, SHOW_CONDITIONS_REQUEST)
+ } else {
+ startNextActivity()
+ }
+ }
+
+ private fun startNextActivity() {
val project = sharedPreferences!!.getString("project", null)
val realm = sharedPreferences!!.getString("realm", null)
@@ -32,7 +45,11 @@ class SplashActivity : Activity() {
apiManager.getAppConfig { statusCode, appConfig, error ->
if (statusCode in 200..299) {
val intent = Intent(this@SplashActivity, MainActivity::class.java)
- intent.putExtra(APP_CONFIG_KEY, jacksonObjectMapper().writeValueAsString(appConfig))
+ intent.putExtra(
+ APP_CONFIG_KEY, jacksonObjectMapper().writeValueAsString(
+ appConfig
+ )
+ )
startActivity(intent)
finish()
} else {
@@ -45,4 +62,14 @@ class SplashActivity : Activity() {
finish()
}
}
+
+ override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
+ if(requestCode == SHOW_CONDITIONS_REQUEST) {
+ if (resultCode == RESULT_OK) {
+ sharedPreferences!!.edit().putBoolean("privacyPolicyAccepted", true).apply()
+ startNextActivity()
+ }
+ }
+ super.onActivityResult(requestCode, resultCode, data)
+ }
}
\ No newline at end of file
diff --git a/console/android/GenericApp/app/src/main/res/layout/activity_privacy_policy.xml b/console/android/GenericApp/app/src/main/res/layout/activity_privacy_policy.xml
new file mode 100644
index 000000000..b9879a747
--- /dev/null
+++ b/console/android/GenericApp/app/src/main/res/layout/activity_privacy_policy.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".ui.PrivacyPolicyActivity">
+
+ <WebView
+ android:id="@+id/webView"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ app:layout_constraintBottom_toTopOf="@id/acceptView"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:id="@+id/acceptView"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:layout_margin="10dp"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintRight_toRightOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/webView"
+ >
+
+ <CheckBox
+ android:id="@+id/checkbox"
+ android:layout_width="50dp"
+ android:layout_height="50dp"
+ android:button="@null"
+ android:textColor="@color/medium_green"
+ android:background="?android:attr/listChoiceIndicatorMultiple"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toStartOf="@+id/button_accept"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <Button
+ android:id="@+id/button_accept"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="end"
+ android:background="@color/medium_green"
+ android:minWidth="300dp"
+ android:text="@string/button_accept"
+ android:textColor="@color/white"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ android:enabled="false"/>
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+
+</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/console/android/GenericApp/app/src/main/res/values/strings.xml b/console/android/GenericApp/app/src/main/res/values/strings.xml
index 80d4e5575..47d3b3ed5 100644
--- a/console/android/GenericApp/app/src/main/res/values/strings.xml
+++ b/console/android/GenericApp/app/src/main/res/values/strings.xml
@@ -20,4 +20,5 @@
<string name="location_background_disabled_title">Background location disabled</string>
<string name="background_location_decline">No</string>
<string name="background_location_accept">Yes</string>
+ <string name="button_accept">Accept</string>
</resources>
\ No newline at end of file