generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 28
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
1 parent
67fd9d3
commit cd204b9
Showing
53 changed files
with
1,869 additions
and
18 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
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 @@ | ||
/build |
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,129 @@ | ||
plugins { | ||
alias(libs.plugins.android.application) | ||
alias(libs.plugins.detekt) | ||
alias(libs.plugins.hilt) | ||
alias(libs.plugins.kotlin.android) | ||
alias(libs.plugins.kotlin.serialization) | ||
alias(libs.plugins.ksp) | ||
kotlin("kapt") | ||
} | ||
|
||
android { | ||
namespace = "com.x8bit.bitwarden" | ||
compileSdk = libs.versions.compileSdk.get().toInt() | ||
|
||
defaultConfig { | ||
applicationId = "com.x8bit.bitwarden" | ||
minSdk = libs.versions.minSdk.get().toInt() | ||
targetSdk = libs.versions.targetSdk.get().toInt() | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility(libs.versions.jvmTarget.get()) | ||
targetCompatibility(libs.versions.jvmTarget.get()) | ||
} | ||
kotlinOptions { | ||
jvmTarget = libs.versions.jvmTarget.get() | ||
} | ||
buildFeatures { | ||
compose = true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtensionVersion.get() | ||
} | ||
packaging { | ||
resources { | ||
excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
} | ||
} | ||
@Suppress("UnstableApiUsage") | ||
testOptions { | ||
// Required for Robolectric | ||
unitTests.isIncludeAndroidResources = true | ||
unitTests.isReturnDefaultValues = true | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(libs.androidx.activity.compose) | ||
implementation(platform(libs.androidx.compose.bom)) | ||
implementation(libs.androidx.compose.animation) | ||
implementation(libs.androidx.compose.material3) | ||
implementation(libs.androidx.compose.runtime) | ||
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.hilt.navigation.compose) | ||
implementation(libs.androidx.lifecycle.runtime.ktx) | ||
implementation(libs.androidx.navigation.compose) | ||
ksp(libs.androidx.room.compiler) | ||
implementation(libs.androidx.room.ktx) | ||
implementation(libs.androidx.room.runtime) | ||
implementation(platform(libs.google.firebase.bom)) | ||
implementation(libs.bumptech.glide) | ||
implementation(libs.google.firebase.cloud.messaging) | ||
implementation(libs.google.firebase.crashlytics) | ||
implementation(libs.google.hilt.android) | ||
kapt(libs.google.hilt.compiler) | ||
implementation(libs.jakewharton.retrofit.kotlinx.serialization) | ||
implementation(libs.kotlinx.coroutines.android) | ||
implementation(libs.kotlinx.serialization) | ||
implementation(libs.nulab.zxcvbn4j) | ||
implementation(libs.square.okhttp) | ||
implementation(libs.square.okhttp.logging) | ||
implementation(libs.square.retrofit) | ||
implementation(libs.zxing.zxing.core) | ||
|
||
// For now we are restricted to running Compose tests for debug builds only | ||
debugImplementation(libs.androidx.compose.ui.test.manifest) | ||
debugImplementation(libs.androidx.compose.ui.tooling) | ||
|
||
testImplementation(libs.androidx.compose.ui.test) | ||
testImplementation(libs.google.hilt.android.testing) | ||
testImplementation(libs.junit.junit5) | ||
testImplementation(libs.junit.vintage) | ||
testImplementation(libs.kotlinx.coroutines.test) | ||
testImplementation(libs.mockk.mockk) | ||
testImplementation(libs.robolectric.robolectric) | ||
testImplementation(libs.square.turbine) | ||
|
||
detektPlugins(libs.detekt.detekt.formatting) | ||
detektPlugins(libs.detekt.detekt.rules) | ||
} | ||
|
||
detekt { | ||
autoCorrect = true | ||
config.from(files("$rootDir/detekt-config.yml")) | ||
} | ||
|
||
tasks { | ||
getByName("check") { | ||
// Add detekt with type resolution to check | ||
dependsOn("detektMain") | ||
} | ||
|
||
withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach { | ||
jvmTarget = libs.versions.jvmTarget.get() | ||
} | ||
withType<io.gitlab.arturbosch.detekt.DetektCreateBaselineTask>().configureEach { | ||
jvmTarget = libs.versions.jvmTarget.get() | ||
} | ||
|
||
withType<Test> { | ||
useJUnitPlatform() | ||
} | ||
} |
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,64 @@ | ||
################################################################################ | ||
# Firebase Crashlytics | ||
################################################################################ | ||
|
||
# Keep file names and line numbers. | ||
-keepattributes SourceFile,LineNumberTable | ||
|
||
# Keep custom exceptions. | ||
-keep public class * extends java.lang.Exception | ||
|
||
################################################################################ | ||
# kotlinx.serialization | ||
################################################################################ | ||
|
||
-keepattributes *Annotation*, InnerClasses | ||
|
||
# JsonElement serializers | ||
-keep,includedescriptorclasses class kotlinx.serialization.json.**$$serializer { *; } | ||
-keep,includedescriptorclasses class com.x8bit.bitwarden.**$$serializer { *; } | ||
-keepclassmembers class com.x8bit.bitwarden.** { | ||
*** Companion; | ||
} | ||
-keepclasseswithmembers class om.x8bit.bitwarden.** { | ||
kotlinx.serialization.KSerializer serializer(...); | ||
} | ||
|
||
# kotlinx-serialization-json specific. | ||
-keepclassmembers class kotlinx.serialization.json.** { | ||
*** Companion; | ||
} | ||
-keepclasseswithmembers class kotlinx.serialization.json.** { | ||
kotlinx.serialization.KSerializer serializer(...); | ||
} | ||
|
||
################################################################################ | ||
# Glide | ||
################################################################################ | ||
|
||
-keep public class * implements com.bumptech.glide.module.GlideModule | ||
-keep public class * extends com.bumptech.glide.module.AppGlideModule | ||
|
||
################################################################################ | ||
# Okhttp/Retrofit https://square.github.io/okhttp/ & https://square.github.io/retrofit/ | ||
################################################################################ | ||
|
||
# https://github.com/square/okhttp/blob/339732e3a1b78be5d792860109047f68a011b5eb/okhttp/src/jvmMain/resources/META-INF/proguard/okhttp3.pro#L11-L14 | ||
-dontwarn okhttp3.internal.platform.** | ||
-dontwarn org.bouncycastle.** | ||
# Related to this issue on https://github.com/square/retrofit/issues/3880 | ||
# Check https://github.com/square/retrofit/tags for new versions | ||
-keep,allowobfuscation,allowshrinking interface retrofit2.Call | ||
-keep,allowobfuscation,allowshrinking class retrofit2.Response | ||
# This solves this issue https://github.com/square/retrofit/issues/3880 | ||
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation | ||
|
||
################################################################################ | ||
# ZXing | ||
################################################################################ | ||
|
||
# Suppress zxing missing class error due to circular references | ||
-dontwarn com.google.zxing.BarcodeFormat | ||
-dontwarn com.google.zxing.EncodeHintType | ||
-dontwarn com.google.zxing.MultiFormatWriter | ||
-dontwarn com.google.zxing.common.BitMatrix |
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,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<application | ||
android:name=".BitwardenApplication" | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/LaunchTheme" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true" | ||
android:theme="@style/LaunchTheme"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/x8bit/bitwarden/BitwardenApplication.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,10 @@ | ||
package com.x8bit.bitwarden | ||
|
||
import android.app.Application | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
/** | ||
* Custom application class. | ||
*/ | ||
@HiltAndroidApp | ||
class BitwardenApplication : Application() |
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,35 @@ | ||
package com.x8bit.bitwarden | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.material3.Text | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import com.x8bit.bitwarden.ui.theme.BitwardenTheme | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
/** | ||
* Primary entry point for the application. | ||
*/ | ||
@AndroidEntryPoint | ||
class MainActivity : ComponentActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContent { | ||
BitwardenTheme { | ||
Surface( | ||
modifier = Modifier.fillMaxSize(), | ||
color = MaterialTheme.colorScheme.background, | ||
) { | ||
Text( | ||
text = stringResource(id = R.string.app_name), | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
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,74 @@ | ||
package com.x8bit.bitwarden.ui.theme | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import android.os.Build | ||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.material3.ColorScheme | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.darkColorScheme | ||
import androidx.compose.material3.dynamicDarkColorScheme | ||
import androidx.compose.material3.dynamicLightColorScheme | ||
import androidx.compose.material3.lightColorScheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.SideEffect | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.toArgb | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.platform.LocalView | ||
import androidx.core.view.WindowCompat | ||
import com.x8bit.bitwarden.R | ||
import com.x8bit.bitwarden.R.color | ||
|
||
/** | ||
* The overall application theme. This can be configured to support a [darkTheme] and | ||
* [dynamicColor]. | ||
*/ | ||
@Composable | ||
fun BitwardenTheme( | ||
darkTheme: Boolean = isSystemInDarkTheme(), | ||
dynamicColor: Boolean = false, | ||
content: @Composable () -> Unit, | ||
) { | ||
// Get the current scheme | ||
val context = LocalContext.current | ||
val colorScheme = when { | ||
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { | ||
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) | ||
} | ||
|
||
darkTheme -> darkColorScheme(context) | ||
else -> lightColorScheme(context) | ||
} | ||
|
||
// Update status bar according to scheme | ||
val view = LocalView.current | ||
if (!view.isInEditMode) { | ||
SideEffect { | ||
val window = (view.context as Activity).window | ||
window.statusBarColor = colorScheme.primary.toArgb() | ||
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme | ||
} | ||
} | ||
|
||
// Set overall theme based on color scheme and typography settings | ||
MaterialTheme( | ||
colorScheme = colorScheme, | ||
typography = Typography, | ||
content = content, | ||
) | ||
} | ||
|
||
private fun darkColorScheme(context: Context): ColorScheme = | ||
darkColorScheme( | ||
primary = Color(context.getColor(color.dark_primary)), | ||
secondary = Color(context.getColor(R.color.dark_primary)), | ||
tertiary = Color(context.getColor(R.color.dark_primary)), | ||
) | ||
|
||
private fun lightColorScheme(context: Context): ColorScheme = | ||
lightColorScheme( | ||
primary = Color(context.getColor(color.primary)), | ||
secondary = Color(context.getColor(R.color.primary)), | ||
tertiary = Color(context.getColor(R.color.primary)), | ||
) |
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,17 @@ | ||
package com.x8bit.bitwarden.ui.theme | ||
|
||
import androidx.compose.material3.Typography | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontFamily | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.sp | ||
|
||
val Typography: Typography = Typography( | ||
bodyLarge = TextStyle( | ||
fontFamily = FontFamily.Default, | ||
fontWeight = FontWeight.Normal, | ||
fontSize = 16.sp, | ||
lineHeight = 24.sp, | ||
letterSpacing = 0.5.sp, | ||
), | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.