From da4c7e7ed675c3bf405668739c3012d140856109 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:42 +0200 Subject: Adding upstream version 126.0. Signed-off-by: Daniel Baumann --- .../samples/dataprotect/build.gradle | 35 +++++ .../samples/dataprotect/lint.xml | 12 ++ .../samples/dataprotect/proguard-rules.pro | 21 +++ .../dataprotect/src/main/AndroidManifest.xml | 28 ++++ .../org/mozilla/samples/dataprotect/Constants.kt | 12 ++ .../mozilla/samples/dataprotect/MainActivity.kt | 44 ++++++ .../samples/dataprotect/ProtectedDataAdapter.kt | 43 +++++ .../res/drawable-v24/ic_launcher_foreground.xml | 38 +++++ .../main/res/drawable/ic_launcher_background.xml | 174 +++++++++++++++++++++ .../src/main/res/layout/activity_main.xml | 18 +++ .../src/main/res/layout/protecteddata_item.xml | 21 +++ .../src/main/res/mipmap-anydpi-v26/ic_launcher.xml | 9 ++ .../res/mipmap-anydpi-v26/ic_launcher_round.xml | 9 ++ .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3056 bytes .../src/main/res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 5024 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2096 bytes .../src/main/res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 2858 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4569 bytes .../main/res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 7098 bytes .../src/main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 6464 bytes .../main/res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 10676 bytes .../src/main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 9250 bytes .../main/res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 15523 bytes .../dataprotect/src/main/res/values/colors.xml | 9 ++ .../dataprotect/src/main/res/values/strings.xml | 6 + .../dataprotect/src/main/res/values/styles.xml | 14 ++ .../src/main/res/xml/data_extraction_rules.xml | 9 ++ 27 files changed, 502 insertions(+) create mode 100644 mobile/android/android-components/samples/dataprotect/build.gradle create mode 100644 mobile/android/android-components/samples/dataprotect/lint.xml create mode 100644 mobile/android/android-components/samples/dataprotect/proguard-rules.pro create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/AndroidManifest.xml create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/java/org/mozilla/samples/dataprotect/Constants.kt create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/java/org/mozilla/samples/dataprotect/MainActivity.kt create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/java/org/mozilla/samples/dataprotect/ProtectedDataAdapter.kt create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/drawable/ic_launcher_background.xml create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/layout/activity_main.xml create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/layout/protecteddata_item.xml create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/values/colors.xml create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/values/strings.xml create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/values/styles.xml create mode 100644 mobile/android/android-components/samples/dataprotect/src/main/res/xml/data_extraction_rules.xml (limited to 'mobile/android/android-components/samples/dataprotect') diff --git a/mobile/android/android-components/samples/dataprotect/build.gradle b/mobile/android/android-components/samples/dataprotect/build.gradle new file mode 100644 index 0000000000..f9b70a7368 --- /dev/null +++ b/mobile/android/android-components/samples/dataprotect/build.gradle @@ -0,0 +1,35 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' + +android { + defaultConfig { + applicationId "org.mozilla.samples.dataprotect" + + minSdkVersion config.minSdkVersion + compileSdk config.compileSdkVersion + targetSdkVersion config.targetSdkVersion + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + + namespace 'org.mozilla.samples.dataprotect' +} + +dependencies { + implementation project(':support-ktx') + implementation project(':lib-dataprotect') + + implementation ComponentsDependencies.kotlin_coroutines + + implementation ComponentsDependencies.androidx_appcompat + implementation ComponentsDependencies.androidx_recyclerview +} diff --git a/mobile/android/android-components/samples/dataprotect/lint.xml b/mobile/android/android-components/samples/dataprotect/lint.xml new file mode 100644 index 0000000000..33cf423701 --- /dev/null +++ b/mobile/android/android-components/samples/dataprotect/lint.xml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/mobile/android/android-components/samples/dataprotect/proguard-rules.pro b/mobile/android/android-components/samples/dataprotect/proguard-rules.pro new file mode 100644 index 0000000000..f1b424510d --- /dev/null +++ b/mobile/android/android-components/samples/dataprotect/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/mobile/android/android-components/samples/dataprotect/src/main/AndroidManifest.xml b/mobile/android/android-components/samples/dataprotect/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..72969290ec --- /dev/null +++ b/mobile/android/android-components/samples/dataprotect/src/main/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mobile/android/android-components/samples/dataprotect/src/main/java/org/mozilla/samples/dataprotect/Constants.kt b/mobile/android/android-components/samples/dataprotect/src/main/java/org/mozilla/samples/dataprotect/Constants.kt new file mode 100644 index 0000000000..ab648d4fff --- /dev/null +++ b/mobile/android/android-components/samples/dataprotect/src/main/java/org/mozilla/samples/dataprotect/Constants.kt @@ -0,0 +1,12 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.samples.dataprotect + +import android.util.Base64 + +object Constants { + const val B64_FLAGS = Base64.URL_SAFE or Base64.NO_PADDING or Base64.NO_PADDING + const val KEYSTORE_LABEL = "samples-dataprotect" +} diff --git a/mobile/android/android-components/samples/dataprotect/src/main/java/org/mozilla/samples/dataprotect/MainActivity.kt b/mobile/android/android-components/samples/dataprotect/src/main/java/org/mozilla/samples/dataprotect/MainActivity.kt new file mode 100644 index 0000000000..12e30e638d --- /dev/null +++ b/mobile/android/android-components/samples/dataprotect/src/main/java/org/mozilla/samples/dataprotect/MainActivity.kt @@ -0,0 +1,44 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.samples.dataprotect + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import mozilla.components.lib.dataprotect.SecureAbove22Preferences + +class MainActivity : AppCompatActivity() { + @Suppress("MagicNumber") + private val itemKeys: List = List(5) { "protected item ${it + 1}" } + + private lateinit var listView: RecyclerView + private lateinit var listAdapter: ProtectedDataAdapter + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + val prefs = SecureAbove22Preferences(this, "secret-data-storage") + + prepareProtectedData(prefs) + + // setup recycler + listAdapter = ProtectedDataAdapter(prefs, itemKeys) + listView = findViewById(R.id.protecteddata_list) + listView.apply { + setHasFixedSize(true) + layoutManager = LinearLayoutManager(this@MainActivity) + adapter = listAdapter + } + } + + private fun prepareProtectedData(prefs: SecureAbove22Preferences) { + for (datakey in itemKeys) { + val plain = "value for $datakey" + prefs.putString(datakey, plain) + } + } +} diff --git a/mobile/android/android-components/samples/dataprotect/src/main/java/org/mozilla/samples/dataprotect/ProtectedDataAdapter.kt b/mobile/android/android-components/samples/dataprotect/src/main/java/org/mozilla/samples/dataprotect/ProtectedDataAdapter.kt new file mode 100644 index 0000000000..366f4a9059 --- /dev/null +++ b/mobile/android/android-components/samples/dataprotect/src/main/java/org/mozilla/samples/dataprotect/ProtectedDataAdapter.kt @@ -0,0 +1,43 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.samples.dataprotect + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import mozilla.components.lib.dataprotect.SecureAbove22Preferences + +class ProtectedDataAdapter( + private val prefs: SecureAbove22Preferences, + private val itemKeys: List, +) : RecyclerView.Adapter() { + override fun getItemCount(): Int = itemKeys.size + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder { + val view = LayoutInflater.from(parent.context) + .inflate(R.layout.protecteddata_item, parent, false) + + return Holder(view) + } + + override fun onBindViewHolder(holder: Holder, position: Int) { + val key = itemKeys[position] + var value = prefs.getString(key) + holder.keyView.text = key + holder.valView.text = value + } + + class Holder(val view: View) : RecyclerView.ViewHolder(view) { + var keyView: TextView + var valView: TextView + + init { + keyView = view.findViewById(R.id.protecteddata_item_key_view) + valView = view.findViewById(R.id.protecteddata_item_val_view) + } + } +} diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/drawable-v24/ic_launcher_foreground.xml b/mobile/android/android-components/samples/dataprotect/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000000..772d73c1a8 --- /dev/null +++ b/mobile/android/android-components/samples/dataprotect/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/drawable/ic_launcher_background.xml b/mobile/android/android-components/samples/dataprotect/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000000..84af1fd596 --- /dev/null +++ b/mobile/android/android-components/samples/dataprotect/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/layout/activity_main.xml b/mobile/android/android-components/samples/dataprotect/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000000..96d6ab81da --- /dev/null +++ b/mobile/android/android-components/samples/dataprotect/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + + \ No newline at end of file diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/layout/protecteddata_item.xml b/mobile/android/android-components/samples/dataprotect/src/main/res/layout/protecteddata_item.xml new file mode 100644 index 0000000000..4ad43964ab --- /dev/null +++ b/mobile/android/android-components/samples/dataprotect/src/main/res/layout/protecteddata_item.xml @@ -0,0 +1,21 @@ + + + + + + + + \ No newline at end of file diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000000..f39d507313 --- /dev/null +++ b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000000..f39d507313 --- /dev/null +++ b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-hdpi/ic_launcher.png b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000..a2f5908281 Binary files /dev/null and b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-hdpi/ic_launcher_round.png b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000000..1b52399808 Binary files /dev/null and b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-mdpi/ic_launcher.png b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000..ff10afd6e1 Binary files /dev/null and b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-mdpi/ic_launcher_round.png b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000000..115a4c768a Binary files /dev/null and b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xhdpi/ic_launcher.png b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000..dcd3cd8083 Binary files /dev/null and b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..459ca609d3 Binary files /dev/null and b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xxhdpi/ic_launcher.png b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000..8ca12fe024 Binary files /dev/null and b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..8e19b410a1 Binary files /dev/null and b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000..b824ebdd48 Binary files /dev/null and b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000000..4c19a13c23 Binary files /dev/null and b/mobile/android/android-components/samples/dataprotect/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/values/colors.xml b/mobile/android/android-components/samples/dataprotect/src/main/res/values/colors.xml new file mode 100644 index 0000000000..3a96673022 --- /dev/null +++ b/mobile/android/android-components/samples/dataprotect/src/main/res/values/colors.xml @@ -0,0 +1,9 @@ + + + + #3F51B5 + #303F9F + #FF4081 + diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/values/strings.xml b/mobile/android/android-components/samples/dataprotect/src/main/res/values/strings.xml new file mode 100644 index 0000000000..2883c42227 --- /dev/null +++ b/mobile/android/android-components/samples/dataprotect/src/main/res/values/strings.xml @@ -0,0 +1,6 @@ + + + DataProtect Demo App + diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/values/styles.xml b/mobile/android/android-components/samples/dataprotect/src/main/res/values/styles.xml new file mode 100644 index 0000000000..1f33369bc5 --- /dev/null +++ b/mobile/android/android-components/samples/dataprotect/src/main/res/values/styles.xml @@ -0,0 +1,14 @@ + + + + + + + diff --git a/mobile/android/android-components/samples/dataprotect/src/main/res/xml/data_extraction_rules.xml b/mobile/android/android-components/samples/dataprotect/src/main/res/xml/data_extraction_rules.xml new file mode 100644 index 0000000000..55da967560 --- /dev/null +++ b/mobile/android/android-components/samples/dataprotect/src/main/res/xml/data_extraction_rules.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file -- cgit v1.2.3