diff --git a/FreeRASPDemoApp/app/build.gradle b/FreeRASPDemoApp/app/build.gradle deleted file mode 100644 index c230c14..0000000 --- a/FreeRASPDemoApp/app/build.gradle +++ /dev/null @@ -1,35 +0,0 @@ -plugins { - alias(libs.plugins.android.application) -} - -android { - namespace "com.aheaditec.talsec.demoapp" - - defaultConfig { - applicationId "com.aheaditec.talsec.demoapp" - minSdkVersion 23 - compileSdkVersion 36 - targetSdkVersion 36 - versionCode 1 - versionName "1.0" - } - - buildTypes { - release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } -} - -dependencies { - // freeRASP SDK - implementation libs.talsec.freerasp - implementation libs.kotlin.stdlib - implementation libs.bundles.androidx -} \ No newline at end of file diff --git a/FreeRASPDemoApp/app/build.gradle.kts b/FreeRASPDemoApp/app/build.gradle.kts new file mode 100644 index 0000000..04c408c --- /dev/null +++ b/FreeRASPDemoApp/app/build.gradle.kts @@ -0,0 +1,52 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.compose) + alias(libs.plugins.talsec.plugin) +} + +android { + namespace = "com.aheaditec.talsec.demoapp" + compileSdk { + version = release(37) + } + + defaultConfig { + applicationId = "com.aheaditec.talsec.demoapp" + minSdk = 23 + targetSdk = 37 + versionCode = 1 + versionName = "1.0" + } + + buildTypes { + release { + isMinifyEnabled = true + isShrinkResources = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + talsec { + sdkVersion = "19.2.3" // todo + // offlineToken = "..." // optional + // platform = "Flutter" // optional + } +} + +dependencies { + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.activity.compose) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.ui.graphics) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + debugImplementation(libs.androidx.compose.ui.test.manifest) + debugImplementation(libs.androidx.compose.ui.tooling) +} \ No newline at end of file diff --git a/FreeRASPDemoApp/app/src/main/AndroidManifest.xml b/FreeRASPDemoApp/app/src/main/AndroidManifest.xml index 83826bd..0c0cd7f 100644 --- a/FreeRASPDemoApp/app/src/main/AndroidManifest.xml +++ b/FreeRASPDemoApp/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ - + @@ -22,12 +22,16 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.FreeRASPDemoApp"> - + + \ No newline at end of file diff --git a/FreeRASPDemoApp/app/src/main/java/com/aheaditec/talsec/demoapp/MainActivity.kt b/FreeRASPDemoApp/app/src/main/java/com/aheaditec/talsec/demoapp/MainActivity.kt index ee10d35..781fd7c 100644 --- a/FreeRASPDemoApp/app/src/main/java/com/aheaditec/talsec/demoapp/MainActivity.kt +++ b/FreeRASPDemoApp/app/src/main/java/com/aheaditec/talsec/demoapp/MainActivity.kt @@ -3,35 +3,70 @@ package com.aheaditec.talsec.demoapp import android.Manifest import android.content.pm.PackageManager import android.os.Bundle -import androidx.appcompat.app.AppCompatActivity -import androidx.core.app.ActivityCompat +import android.util.Log +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier import androidx.core.content.ContextCompat +import com.aheaditec.talsec.demoapp.ui.theme.FreeRASPDemoAppTheme -class MainActivity : AppCompatActivity() { +class MainActivity : ComponentActivity() { + + private val locationPermissionLauncher = registerForActivityResult( + ActivityResultContracts.RequestMultiplePermissions() + ) { permissions -> + if (permissions.values.all { it }) { + Log.d("MainActivity", "Location permissions were granted") + } + } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) requestFineLocationPermission() + + setContent { + FreeRASPDemoAppTheme { + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background, + ) { + MainScreen() + } + } + } } private fun requestFineLocationPermission() { - if (ContextCompat.checkSelfPermission( - this, - FINE_LOCATION_PERMISSION - ) != PackageManager.PERMISSION_GRANTED - ) { - // Permission is not granted, request it - ActivityCompat.requestPermissions( - this, - arrayOf(COARSE_LOCATION_PERMISSION, FINE_LOCATION_PERMISSION), - 100 + val isFineLocationGranted = ContextCompat.checkSelfPermission( + this, + Manifest.permission.ACCESS_FINE_LOCATION + ) == PackageManager.PERMISSION_GRANTED + + if (!isFineLocationGranted) { + locationPermissionLauncher.launch( + arrayOf( + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.ACCESS_FINE_LOCATION + ) ) } } +} - private companion object { - private const val FINE_LOCATION_PERMISSION = Manifest.permission.ACCESS_FINE_LOCATION - private const val COARSE_LOCATION_PERMISSION = Manifest.permission.ACCESS_COARSE_LOCATION +@Composable +private fun MainScreen() { + Box( + modifier = Modifier.fillMaxSize(), + contentAlignment = Alignment.Center, + ) { + Text(text = "I am secured by freeRASP!") } } \ No newline at end of file diff --git a/FreeRASPDemoApp/app/src/main/java/com/aheaditec/talsec/demoapp/ui/theme/Color.kt b/FreeRASPDemoApp/app/src/main/java/com/aheaditec/talsec/demoapp/ui/theme/Color.kt new file mode 100644 index 0000000..80fbf00 --- /dev/null +++ b/FreeRASPDemoApp/app/src/main/java/com/aheaditec/talsec/demoapp/ui/theme/Color.kt @@ -0,0 +1,9 @@ +package com.aheaditec.talsec.demoapp.ui.theme + +import androidx.compose.ui.graphics.Color + +val Purple200 = Color(0xFFBB86FC) +val Purple500 = Color(0xFF6200EE) +val Purple700 = Color(0xFF3700B3) +val Teal200 = Color(0xFF03DAC5) +val Teal700 = Color(0xFF018786) \ No newline at end of file diff --git a/FreeRASPDemoApp/app/src/main/java/com/aheaditec/talsec/demoapp/ui/theme/Theme.kt b/FreeRASPDemoApp/app/src/main/java/com/aheaditec/talsec/demoapp/ui/theme/Theme.kt new file mode 100644 index 0000000..e52ee9f --- /dev/null +++ b/FreeRASPDemoApp/app/src/main/java/com/aheaditec/talsec/demoapp/ui/theme/Theme.kt @@ -0,0 +1,36 @@ +package com.aheaditec.talsec.demoapp.ui.theme + +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color + +private val DarkColorScheme = darkColorScheme( + primary = Purple200, + onPrimary = Color.Black, + secondary = Teal200, + onSecondary = Color.Black, + tertiary = Teal200, +) + +private val LightColorScheme = lightColorScheme( + primary = Purple500, + onPrimary = Color.White, + secondary = Teal200, + onSecondary = Color.Black, + tertiary = Purple700, +) + +@Composable +fun FreeRASPDemoAppTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + content: @Composable () -> Unit, +) { + val colorScheme = if (darkTheme) DarkColorScheme else LightColorScheme + MaterialTheme( + colorScheme = colorScheme, + content = content, + ) +} \ No newline at end of file diff --git a/FreeRASPDemoApp/app/src/main/res/layout/activity_main.xml b/FreeRASPDemoApp/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index aefe27a..0000000 --- a/FreeRASPDemoApp/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/FreeRASPDemoApp/app/src/main/res/values-night/themes.xml b/FreeRASPDemoApp/app/src/main/res/values-night/themes.xml index 932dc98..640a29a 100644 --- a/FreeRASPDemoApp/app/src/main/res/values-night/themes.xml +++ b/FreeRASPDemoApp/app/src/main/res/values-night/themes.xml @@ -1,16 +1,8 @@ - - \ No newline at end of file diff --git a/FreeRASPDemoApp/app/src/main/res/values/themes.xml b/FreeRASPDemoApp/app/src/main/res/values/themes.xml index 4a9d72b..f91779a 100644 --- a/FreeRASPDemoApp/app/src/main/res/values/themes.xml +++ b/FreeRASPDemoApp/app/src/main/res/values/themes.xml @@ -1,16 +1,8 @@ - - \ No newline at end of file diff --git a/FreeRASPDemoApp/build.gradle b/FreeRASPDemoApp/build.gradle.kts similarity index 60% rename from FreeRASPDemoApp/build.gradle rename to FreeRASPDemoApp/build.gradle.kts index 9d877e8..18318be 100644 --- a/FreeRASPDemoApp/build.gradle +++ b/FreeRASPDemoApp/build.gradle.kts @@ -1,9 +1,5 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { alias(libs.plugins.android.application) apply false -} - -tasks.register('clean', Delete) { - //noinspection GrDeprecatedAPIUsage - delete rootProject.buildDir + alias(libs.plugins.kotlin.compose) apply false } \ No newline at end of file diff --git a/FreeRASPDemoApp/gradle.properties b/FreeRASPDemoApp/gradle.properties index f24c666..99fc155 100644 --- a/FreeRASPDemoApp/gradle.properties +++ b/FreeRASPDemoApp/gradle.properties @@ -8,17 +8,12 @@ # The setting is particularly useful for tweaking memory settings. org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# This option should only be used with decoupled projects. For more details, visit +# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects # org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app"s APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true +# When enabled, the Configuration Cache allows Gradle to skip the configuration +# phase entirely if nothing that affects the build configuration (such as build scripts) +# has changed. Additionally, Gradle applies performance optimizations to task execution. +org.gradle.configuration-cache=true # Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official -# Temporary compatibility settings for AGP 9.0 migration -android.builtInKotlin=true -android.newDsl=false \ No newline at end of file +kotlin.code.style=official \ No newline at end of file diff --git a/FreeRASPDemoApp/gradle/libs.versions.toml b/FreeRASPDemoApp/gradle/libs.versions.toml index 05dc40f..d011926 100644 --- a/FreeRASPDemoApp/gradle/libs.versions.toml +++ b/FreeRASPDemoApp/gradle/libs.versions.toml @@ -1,22 +1,25 @@ [versions] -kotlin = "2.3.0" agp = "9.3.2" -core-ktx = "1.17.0" -appcompat = "1.7.1" -material = "1.14.0" -constraintlayout = "2.2.2" -talsec-freerasp = "19.2.3" +activityCompose = "1.13.0" +composeBom = "2026.08.00" +coreKtx = "1.19.0" +kotlin = "2.4.10" +lifecycleRuntimeKtx = "2.11.0" +talsecPlugin = "0.0.20" # todo [libraries] -kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" } -core-ktx = { module = "androidx.core:core-ktx", version.ref = "core-ktx" } -appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" } -material = { module = "com.google.android.material:material", version.ref = "material" } -constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayout" } -talsec-freerasp = { module = "com.aheaditec.talsec.security:TalsecSecurity-Community", version.ref = "talsec-freerasp" } +androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } +androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" } +androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" } +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" } +androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" } +androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" } +androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } +androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" } +androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } +androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" } - -[bundles] -androidx = ["core-ktx", "appcompat", "material", "constraintlayout"] \ No newline at end of file +kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } +talsec-plugin = { id = "app.talsec.plugin", version.ref = "talsecPlugin" } \ No newline at end of file diff --git a/FreeRASPDemoApp/gradle/wrapper/gradle-wrapper.properties b/FreeRASPDemoApp/gradle/wrapper/gradle-wrapper.properties index 53761cb..64a5b37 100644 --- a/FreeRASPDemoApp/gradle/wrapper/gradle-wrapper.properties +++ b/FreeRASPDemoApp/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists \ No newline at end of file diff --git a/FreeRASPDemoApp/settings.gradle b/FreeRASPDemoApp/settings.gradle deleted file mode 100644 index c9aabb8..0000000 --- a/FreeRASPDemoApp/settings.gradle +++ /dev/null @@ -1,20 +0,0 @@ -pluginManagement { - repositories { - google() - mavenCentral() - gradlePluginPortal() - } -} - -dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) - repositories { - google() - mavenCentral() - maven { url "https://europe-west3-maven.pkg.dev/talsec-artifact-repository/freerasp" } - maven { url 'https://europe-west3-maven.pkg.dev/talsec-artifact-repository/common' } - } -} - -include ':app' -rootProject.name = "FreeRASPDemoApp" \ No newline at end of file diff --git a/FreeRASPDemoApp/settings.gradle.kts b/FreeRASPDemoApp/settings.gradle.kts new file mode 100644 index 0000000..5b58f5d --- /dev/null +++ b/FreeRASPDemoApp/settings.gradle.kts @@ -0,0 +1,26 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + maven { url = uri("https://europe-west3-maven.pkg.dev/talsec-artifact-repository/plugin") } + } +} + +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" +} + +@Suppress("UnstableApiUsage") +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + maven { url = uri("https://europe-west3-maven.pkg.dev/talsec-artifact-repository/common") } + maven { url = uri("https://europe-west3-maven.pkg.dev/talsec-artifact-repository/freerasp") } + } +} + +rootProject.name = "FreeRASPDemoApp" +include(":app") \ No newline at end of file