-
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
0 parents
commit f805210
Showing
29 changed files
with
1,221 additions
and
0 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,10 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
.idea/ | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
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,63 @@ | ||
import com.android.build.gradle.ProguardFiles.ProguardFile | ||
import org.gradle.kotlin.dsl.support.kotlinCompilerOptions | ||
|
||
plugins { | ||
alias(libs.plugins.android.application) | ||
alias(libs.plugins.kotlin.android) | ||
alias(libs.plugins.compose) | ||
} | ||
|
||
android { | ||
namespace = "ru.cookedapp.insetsvisualizer" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
applicationId = "ru.cookedapp.insetsvisualizer" | ||
minSdk = 26 | ||
targetSdk = 34 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
} | ||
|
||
buildFeatures { | ||
compose = true | ||
} | ||
buildTypes { | ||
release { | ||
isMinifyEnabled = true | ||
proguardFiles(getDefaultProguardFile(ProguardFile.OPTIMIZE.fileName), "proguard-rules.pro") | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
packaging { | ||
resources { | ||
excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
} | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = "17" | ||
} | ||
} | ||
|
||
kotlin { | ||
sourceSets.all { | ||
languageSettings.enableLanguageFeature("ExplicitBackingFields") | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(platform(libs.androidx.compose.bom)) | ||
implementation(libs.androidx.ui) | ||
implementation(libs.androidx.ui.graphics) | ||
implementation(libs.androidx.ui.tooling.preview) | ||
implementation(libs.androidx.material3) | ||
implementation(libs.androidx.activity.compose) | ||
implementation(libs.androidx.lifecycle.runtime) | ||
implementation(libs.androidx.lifecycle.compose) | ||
implementation(libs.androidx.core) | ||
debugImplementation(libs.androidx.ui.tooling) | ||
} |
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 |
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: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/Theme.InsetsVisualizer" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true" | ||
android:label="@string/app_name" | ||
android:theme="@style/Theme.InsetsVisualizer"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
7 changes: 7 additions & 0 deletions
7
app/src/main/kotlin/ru/cookedapp/insetsvisualizer/ActivityExtensions.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,7 @@ | ||
package ru.cookedapp.insetsvisualizer | ||
|
||
import android.app.Activity | ||
import android.content.res.Configuration | ||
|
||
internal val Activity.isDarkModeEnabled: Boolean | ||
get() = (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES |
17 changes: 17 additions & 0 deletions
17
app/src/main/kotlin/ru/cookedapp/insetsvisualizer/InsetsType.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,17 @@ | ||
package ru.cookedapp.insetsvisualizer | ||
|
||
enum class InsetsType { | ||
STATUS_BARS, | ||
STATUS_BARS_IGNORING_VISIBILITY, | ||
NAVIGATION_BARS, | ||
NAVIGATION_BARS_IGNORING_VISIBILITY, | ||
CAPTION_BAR, | ||
CAPTION_BAR_IGNORING_VISIBILITY, | ||
TAPPABLE_ELEMENT, | ||
TAPPABLE_ELEMENT_IGNORING_VISIBILITY, | ||
SYSTEM_GESTURES, | ||
MANDATORY_SYSTEM_GESTURES, | ||
IME, | ||
WATERFALL, | ||
DISPLAY_CUTOUT; | ||
} |
71 changes: 71 additions & 0 deletions
71
app/src/main/kotlin/ru/cookedapp/insetsvisualizer/InsetsTypeExtensions.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,71 @@ | ||
package ru.cookedapp.insetsvisualizer | ||
|
||
import androidx.annotation.StringRes | ||
import androidx.compose.foundation.layout.ExperimentalLayoutApi | ||
import androidx.compose.foundation.layout.WindowInsets | ||
import androidx.compose.foundation.layout.captionBar | ||
import androidx.compose.foundation.layout.captionBarIgnoringVisibility | ||
import androidx.compose.foundation.layout.displayCutout | ||
import androidx.compose.foundation.layout.ime | ||
import androidx.compose.foundation.layout.mandatorySystemGestures | ||
import androidx.compose.foundation.layout.navigationBars | ||
import androidx.compose.foundation.layout.navigationBarsIgnoringVisibility | ||
import androidx.compose.foundation.layout.statusBars | ||
import androidx.compose.foundation.layout.statusBarsIgnoringVisibility | ||
import androidx.compose.foundation.layout.systemBars | ||
import androidx.compose.foundation.layout.tappableElement | ||
import androidx.compose.foundation.layout.tappableElementIgnoringVisibility | ||
import androidx.compose.foundation.layout.waterfall | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.graphics.Color | ||
|
||
@Composable | ||
@OptIn(ExperimentalLayoutApi::class) | ||
fun InsetsType.toInsets(): WindowInsets = when (this) { | ||
InsetsType.STATUS_BARS -> WindowInsets.statusBars | ||
InsetsType.STATUS_BARS_IGNORING_VISIBILITY -> WindowInsets.statusBarsIgnoringVisibility | ||
InsetsType.NAVIGATION_BARS -> WindowInsets.navigationBars | ||
InsetsType.NAVIGATION_BARS_IGNORING_VISIBILITY -> WindowInsets.navigationBarsIgnoringVisibility | ||
InsetsType.CAPTION_BAR -> WindowInsets.captionBar | ||
InsetsType.CAPTION_BAR_IGNORING_VISIBILITY -> WindowInsets.captionBarIgnoringVisibility | ||
InsetsType.TAPPABLE_ELEMENT -> WindowInsets.tappableElement | ||
InsetsType.TAPPABLE_ELEMENT_IGNORING_VISIBILITY -> WindowInsets.tappableElementIgnoringVisibility | ||
InsetsType.SYSTEM_GESTURES -> WindowInsets.systemBars | ||
InsetsType.MANDATORY_SYSTEM_GESTURES -> WindowInsets.mandatorySystemGestures | ||
InsetsType.IME -> WindowInsets.ime | ||
InsetsType.WATERFALL -> WindowInsets.waterfall | ||
InsetsType.DISPLAY_CUTOUT -> WindowInsets.displayCutout | ||
} | ||
|
||
fun InsetsType.toColor(): Color = when (this) { | ||
InsetsType.STATUS_BARS -> 0xFFF00000 | ||
InsetsType.STATUS_BARS_IGNORING_VISIBILITY -> 0xFF0F0000 | ||
InsetsType.NAVIGATION_BARS -> 0xFF00F000 | ||
InsetsType.NAVIGATION_BARS_IGNORING_VISIBILITY -> 0xFF000F00 | ||
InsetsType.CAPTION_BAR -> 0xFF0000F0 | ||
InsetsType.CAPTION_BAR_IGNORING_VISIBILITY -> 0xFF00000F | ||
InsetsType.TAPPABLE_ELEMENT -> 0xFFFF0000 | ||
InsetsType.TAPPABLE_ELEMENT_IGNORING_VISIBILITY -> 0xFF00FF00 | ||
InsetsType.SYSTEM_GESTURES -> 0xFF0000FF | ||
InsetsType.MANDATORY_SYSTEM_GESTURES -> 0xFFF0000F | ||
InsetsType.IME -> 0xFFFFF000 | ||
InsetsType.WATERFALL -> 0xFF000FFF | ||
InsetsType.DISPLAY_CUTOUT -> 0xFF0FFFF0 | ||
}.let(::Color).copy(alpha = 0.3f) | ||
|
||
@StringRes | ||
fun InsetsType.toName(): Int = when (this) { | ||
InsetsType.STATUS_BARS -> R.string.inset_type_status_bars | ||
InsetsType.STATUS_BARS_IGNORING_VISIBILITY -> R.string.inset_type_status_bars_ignoring_visibility | ||
InsetsType.NAVIGATION_BARS -> R.string.inset_type_navigation_bars | ||
InsetsType.NAVIGATION_BARS_IGNORING_VISIBILITY -> R.string.inset_type_navigation_bars_ignoring_visibility | ||
InsetsType.CAPTION_BAR -> R.string.inset_type_caption_bar | ||
InsetsType.CAPTION_BAR_IGNORING_VISIBILITY -> R.string.inset_type_caption_bar_ignoring_visibility | ||
InsetsType.TAPPABLE_ELEMENT -> R.string.inset_type_tappable_element | ||
InsetsType.TAPPABLE_ELEMENT_IGNORING_VISIBILITY -> R.string.inset_type_tappable_element_ignoring_visibility | ||
InsetsType.SYSTEM_GESTURES -> R.string.inset_type_system_gestures | ||
InsetsType.MANDATORY_SYSTEM_GESTURES -> R.string.inset_type_mandatory_system_gestures | ||
InsetsType.IME -> R.string.inset_type_ime | ||
InsetsType.WATERFALL -> R.string.inset_type_waterfall | ||
InsetsType.DISPLAY_CUTOUT -> R.string.inset_type_display_cutout | ||
} |
Oops, something went wrong.