Skip to content
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ android {
applicationId = "org.kabiri.android.usbterminal"
minSdk = 24
targetSdk = 35
versionCode = System.getenv("CIRCLE_BUILD_NUM")?.toIntOrNull() ?: 16
versionName = "0.9.86${System.getenv("CIRCLE_BUILD_NUM") ?: ""}"
versionCode = System.getenv("CIRCLE_BUILD_NUM")?.toIntOrNull() ?: 17
versionName = "0.9.87${System.getenv("CIRCLE_BUILD_NUM") ?: ""}"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:theme="@style/UsbTerminalTheme"
android:dataExtractionRules="@xml/data_extraction_rules"
tools:targetApi="s">

Expand Down
12 changes: 11 additions & 1 deletion app/src/main/java/org/kabiri/android/usbterminal/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,21 @@ class MainActivity : AppCompatActivity() {
viewModel.startObservingUsbDevice()
setContentView(R.layout.activity_main)

// avoid system navbar or soft keyboard overlapping the content.
val rootView = findViewById<View>(R.id.root_view)
val toolbar = findViewById<com.google.android.material.appbar.MaterialToolbar>(R.id.toolbar)
setSupportActionBar(toolbar)

ViewCompat.setOnApplyWindowInsetsListener(rootView) { view, insets ->
val systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
val imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime())

// Toolbar consumes status bar space; content avoids bottom system bars
toolbar.setPadding(
toolbar.paddingLeft,
systemBarsInsets.top,
toolbar.paddingRight,
toolbar.paddingBottom,
)
view.setPadding(0, 0, 0, maxOf(systemBarsInsets.bottom, imeInsets.bottom))
insets
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ open class CustomBottomSheetDialogFragment(
private val canUserDragToCancel: Boolean = true,
): BottomSheetDialogFragment() {

override fun getTheme(): Int = R.style.ModalBottomSheetTheme
override fun getTheme(): Int = R.style.SettingModalBottomSheetTheme

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog =
BottomSheetDialog(requireContext(), theme)
Expand Down
24 changes: 22 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@
android:layout_height="match_parent"
tools:context=".MainActivity">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
style="@style/Widget.MaterialComponents.Toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:titleTextColor="@android:color/white"
app:navigationIconTint="@android:color/white" />

</com.google.android.material.appbar.AppBarLayout>

<TextView
android:id="@+id/tvOutput"
android:layout_width="0dp"
Expand All @@ -22,7 +42,7 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toBottomOf="@id/app_bar" />

<Button
android:id="@+id/btEnter"
Expand All @@ -49,4 +69,4 @@
app:layout_constraintStart_toStartOf="parent"
android:imeOptions="actionSend"/>

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
6 changes: 6 additions & 0 deletions app/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Night: nav bar icons should be light -->
<style name="SettingModalBottomSheetTheme" parent="@style/ModalBottomSheetTheme.Base">
<item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>
</style>
</resources>
12 changes: 12 additions & 0 deletions app/src/main/res/values-v23/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<resources>
<!-- API 23+: control status bar icon contrast (dark icons vs light icons) -->
<style name="UsbTerminalTheme" parent="@style/AppTheme.Base">
<!-- Turquoise status bar needs light icons for readability -->
<item name="android:windowLightStatusBar">false</item>
</style>

<style name="SettingModalBottomSheetTheme" parent="@style/ModalBottomSheetTheme.Base">
<!-- Keep light icons on the turquoise status bar in the modal as well -->
<item name="android:windowLightStatusBar">false</item>
</style>
</resources>
12 changes: 12 additions & 0 deletions app/src/main/res/values-v29/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<resources>
<!-- API 29+: disable forced contrast scrims on system bars -->
<style name="UsbTerminalTheme" parent="@style/AppTheme.Base">
<item name="android:enforceStatusBarContrast">false</item>
<item name="android:enforceNavigationBarContrast">false</item>
</style>

<style name="SettingModalBottomSheetTheme" parent="@style/ModalBottomSheetTheme.Base">
<item name="android:enforceStatusBarContrast">false</item>
<item name="android:enforceNavigationBarContrast">false</item>
</style>
</resources>
21 changes: 13 additions & 8 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
<resources xmlns:tools="http://schemas.android.com/tools">

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar">
<style name="AppTheme.Base" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<!-- Ensure status bar tone matches app bar exactly -->
<item name="colorPrimaryDark">@color/colorPrimary</item>
<item name="colorAccent">@color/colorAccent</item>

<item name="android:textColorPrimary">@color/textColorPrimary</item>
<item name="android:textColorSecondary">@color/textColorSecondary</item>
</style>

<style name="ModalBottomSheet" parent="@style/Widget.Design.BottomSheet.Modal">
<item name="android:background">@drawable/bg_modal_bottom_sheet</item>
<!-- App theme alias; v23 will override this to add icon contrast -->
<style name="UsbTerminalTheme" parent="@style/AppTheme.Base" />

<!-- Common items for the bottom sheet theme -->
<style name="ModalBottomSheetTheme.Base" parent="Theme.Material3.DayNight.BottomSheetDialog">
<!-- Edge-to-edge for modal as well; host handles coloring -->
<item name="android:navigationBarColor">@color/bg_modal_bottom_sheet</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>

<style name="ModalBottomSheetTheme" parent="Theme.Design.BottomSheetDialog">
<item name="android:statusBarColor">@android:color/transparent</item>
<!-- Day variant adds light nav bar icons -->
<style name="SettingModalBottomSheetTheme" parent="@style/ModalBottomSheetTheme.Base">
<item name="android:windowLightNavigationBar" tools:targetApi="27">true</item>
<item name="android:windowIsFloating">false</item>
<item name="bottomSheetStyle">@style/ModalBottomSheet</item>
</style>

</resources>