-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
6,793 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
plugins { | ||
alias(libs.plugins.android.library) | ||
alias(libs.plugins.kotlin.android) | ||
alias(libs.plugins.compose.compiler) | ||
} | ||
|
||
val sharedCompileSdk: Int by rootProject.extra | ||
val sharedMinSdk: Int by rootProject.extra | ||
val sharedJavaVersion: JavaVersion by rootProject.extra | ||
|
||
android { | ||
namespace = "com.infomaniak.core2.compose.core" | ||
compileSdk = sharedCompileSdk | ||
|
||
defaultConfig { | ||
minSdk = sharedMinSdk | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles("consumer-rules.pro") | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = sharedJavaVersion | ||
targetCompatibility = sharedJavaVersion | ||
} | ||
buildFeatures { | ||
compose = true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion = "1.5.14" | ||
} | ||
kotlinOptions { | ||
jvmTarget = sharedJavaVersion.toString() | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(platform(core2.compose.bom)) | ||
implementation(core2.compose.runtime) | ||
implementation(core2.compose.ui.tooling) | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
46 changes: 46 additions & 0 deletions
46
Core2/Compose/Core/src/main/java/com/infomaniak/core2/compose/core/ScreenUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Infomaniak SwissTransfer - Android | ||
* Copyright (C) 2024 Infomaniak Network SA | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.infomaniak.core2.compose.core | ||
|
||
import android.annotation.SuppressLint | ||
import android.app.Activity | ||
import android.content.Context | ||
import android.content.ContextWrapper | ||
import android.content.pm.ActivityInfo | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.ui.platform.LocalContext | ||
|
||
@Composable | ||
fun LockScreenOrientation(isLocked: Boolean) { | ||
if (!isLocked) return | ||
|
||
val context = LocalContext.current | ||
LaunchedEffect(Unit) { | ||
val activity = context.findActivity() ?: return@LaunchedEffect | ||
|
||
@SuppressLint("SourceLockedOrientationActivity") | ||
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT | ||
} | ||
} | ||
|
||
private tailrec fun Context.findActivity(): Activity? = when (this) { | ||
is Activity -> this | ||
is ContextWrapper -> baseContext.findActivity() | ||
else -> null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
plugins { | ||
alias(libs.plugins.android.library) | ||
alias(libs.plugins.kotlin.android) | ||
alias(libs.plugins.compose.compiler) | ||
} | ||
|
||
val sharedCompileSdk: Int by rootProject.extra | ||
val sharedMinSdk: Int by rootProject.extra | ||
val sharedJavaVersion: JavaVersion by rootProject.extra | ||
|
||
android { | ||
namespace = "com.infomaniak.library.onboarding" | ||
compileSdk = sharedCompileSdk | ||
|
||
defaultConfig { | ||
minSdk = sharedMinSdk | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles("consumer-rules.pro") | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = sharedJavaVersion | ||
targetCompatibility = sharedJavaVersion | ||
} | ||
buildFeatures { | ||
compose = true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion = "1.5.14" | ||
} | ||
kotlinOptions { | ||
jvmTarget = sharedJavaVersion.toString() | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(platform(core2.compose.bom)) | ||
implementation(core2.androidx.core.ktx) | ||
implementation(core2.compose.foundation) | ||
implementation(core2.compose.material3) | ||
implementation(core2.compose.runtime) | ||
implementation(core2.compose.ui.tooling.preview) | ||
|
||
debugImplementation(core2.compose.ui.tooling) | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
59 changes: 59 additions & 0 deletions
59
Core2/Onboarding/src/main/java/com/infomaniak/library/onboarding/HorizontalPagerIndicator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Infomaniak SwissTransfer - Android | ||
* Copyright (C) 2024 Infomaniak Network SA | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.infomaniak.library.onboarding | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.foundation.pager.PagerState | ||
import androidx.compose.foundation.pager.rememberPagerState | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
|
||
// TODO: Simple placeholder code for now. Will be styled correctly in the next PR | ||
@Composable | ||
fun HorizontalPagerIndicator(modifier: Modifier = Modifier, pagerState: PagerState) { | ||
Row( | ||
modifier | ||
.wrapContentHeight() | ||
.fillMaxWidth() | ||
.padding(bottom = 8.dp), | ||
horizontalArrangement = Arrangement.Center | ||
) { | ||
repeat(pagerState.pageCount) { iteration -> | ||
val color = if (pagerState.currentPage == iteration) Color.DarkGray else Color.LightGray | ||
Box( | ||
modifier = Modifier | ||
.padding(2.dp) | ||
.clip(CircleShape) | ||
.background(color) | ||
.size(16.dp) | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun Preview() { | ||
HorizontalPagerIndicator(pagerState = rememberPagerState { 3 }) | ||
} |
Oops, something went wrong.