Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions FreeRASPDemoApp/app/build.gradle

This file was deleted.

52 changes: 52 additions & 0 deletions FreeRASPDemoApp/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
}
8 changes: 6 additions & 2 deletions FreeRASPDemoApp/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<!-- Optional for unsecure WiFi detection feature -->
<!-- Optional for unsecure Wi-Fi detection feature -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Expand All @@ -22,12 +22,16 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.FreeRASPDemoApp">
<activity android:name=".MainActivity"

<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
}
}
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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,
)
}
18 changes: 0 additions & 18 deletions FreeRASPDemoApp/app/src/main/res/layout/activity_main.xml

This file was deleted.

18 changes: 5 additions & 13 deletions FreeRASPDemoApp/app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.FreeRASPDemoApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<!-- Base application theme, only used briefly for the window background before
Compose takes over and applies FreeRASPDemoAppTheme (see ui/theme/Theme.kt). -->
<style name="Theme.FreeRASPDemoApp" parent="android:Theme.Material.NoActionBar">
<item name="android:windowBackground">@color/black</item>
<item name="android:statusBarColor" tools:targetApi="l">@color/purple_700</item>
</style>
</resources>
18 changes: 5 additions & 13 deletions FreeRASPDemoApp/app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.FreeRASPDemoApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<!-- Base application theme, only used briefly for the window background before
Compose takes over and applies FreeRASPDemoAppTheme (see ui/theme/Theme.kt). -->
<style name="Theme.FreeRASPDemoApp" parent="android:Theme.Material.Light.NoActionBar">
<item name="android:windowBackground">@color/white</item>
<item name="android:statusBarColor" tools:targetApi="l">@color/purple_700</item>
</style>
</resources>
Original file line number Diff line number Diff line change
@@ -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
}
19 changes: 7 additions & 12 deletions FreeRASPDemoApp/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
kotlin.code.style=official
Loading