mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-10 04:24:05 +08:00
Added: Add support for shared day/night theming across termux apps
With this commit, activities will automatically change theme between day/night if `night-mode` `termux.properties` is not set or is set to `system` without requiring app restart. Dialog theming will be fully added in a later commit and may currently be in an inconsistent state or have crashes. The `uiMode` has been removed from `configChanges` of `TermuxActivity`, this may cause termux app to restart if samsung DEX mode is changed, if it does, then users should report it so that it can be fixed by re-adding the value and ignoring the change inside `TermuxActivity.onConfigurationChanged()`. The docs don't state if its necessary. Check related pull request #1446. Running `termux-reload-settings` will also restart `TermuxActivity`, the activity data should be preserved.
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<include
|
||||
layout="@layout/partial_toolbar"
|
||||
android:id="@+id/partial_toolbar"/>
|
||||
layout="@layout/partial_primary_toolbar"
|
||||
android:id="@+id/partial_primary_toolbar"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
|
@@ -5,8 +5,8 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<include
|
||||
layout="@layout/partial_toolbar"
|
||||
android:id="@+id/partial_toolbar"/>
|
||||
layout="@layout/partial_primary_toolbar"
|
||||
android:id="@+id/partial_primary_toolbar"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_io_label"
|
||||
|
@@ -21,6 +21,8 @@
|
||||
android:paddingRight="16dip"
|
||||
android:paddingBottom="8dip"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textColorLink="?android:attr/textColorLink"
|
||||
android:textSize="12sp" />
|
||||
|
||||
</HorizontalScrollView>
|
||||
|
@@ -11,5 +11,6 @@
|
||||
android:paddingTop="8dip"
|
||||
android:paddingBottom="8dip"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textColor="#000"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textColorLink="?android:attr/textColorLink"
|
||||
android:textSize="12sp" />
|
||||
|
@@ -13,10 +13,10 @@
|
||||
android:background="?attr/colorPrimaryDark"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
||||
app:titleTextAppearance="@style/Toolbar.Title">
|
||||
|
||||
android:theme="@style/ThemeOverlay.AppCompat.DayNight.ActionBar"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.DayNight"
|
||||
app:titleTextAppearance="@style/TextAppearance.Widget.BaseToolbar.Title"
|
||||
app:subtitleTextAppearance="@style/TextAppearance.Widget.BaseToolbar.Subtitle">
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
</LinearLayout>
|
@@ -1,19 +1,65 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<style name="Theme.MaterialComponents.DayNight.TermuxPrimaryActivity" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!--
|
||||
https://material.io/develop/android/theming/dark
|
||||
-->
|
||||
|
||||
<!--
|
||||
BaseActivity DayNight DarkActionBar theme.
|
||||
https://github.com/material-components/material-components-android/blob/1.4.0/lib/java/com/google/android/material/theme/res/values/themes.xml#L27
|
||||
-->
|
||||
<style name="Theme.BaseActivity.DayNight.DarkActionBar" parent="Theme.MaterialComponents">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/red_400</item>
|
||||
<item name="colorPrimaryVariant">@color/red_800</item>
|
||||
<item name="colorOnPrimary">@color/black</item>
|
||||
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/grey_900</item>
|
||||
<item name="colorSecondaryVariant">@color/black</item>
|
||||
<item name="colorOnSecondary">@color/white</item>
|
||||
<item name="colorSecondary">@color/grey_400</item>
|
||||
<item name="colorSecondaryVariant">@color/grey_500</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<item name="colorPrimaryDark" tools:targetApi="l">?attr/colorPrimary</item>
|
||||
|
||||
<!-- Text color. -->
|
||||
<item name="android:textColorLink">@color/grey_200</item>
|
||||
<item name="android:textColorLink">@color/blue_link_dark</item>
|
||||
</style>
|
||||
|
||||
<!-- BaseActivity DayNight NoActionBar theme. -->
|
||||
<style name="Theme.BaseActivity.DayNight.NoActionBar" parent="Theme.BaseActivity.DayNight.DarkActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
BaseDialog DayNight theme.
|
||||
https://github.com/material-components/material-components-android/blob/1.4.0/lib/java/com/google/android/material/dialog/res/values/themes.xml#L70
|
||||
-->
|
||||
<style name="ThemeOverlay.BaseDialog.DayNight" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/red_400</item>
|
||||
<item name="colorPrimaryVariant">@color/red_800</item>
|
||||
<item name="colorOnPrimary">@color/black</item>
|
||||
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/grey_400</item>
|
||||
<item name="colorSecondaryVariant">@color/grey_500</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
|
||||
<!-- Surface color. -->
|
||||
<item name="colorSurface">@color/design_dark_default_color_surface</item>
|
||||
<item name="colorOnSurface">@color/design_dark_default_color_on_surface</item>
|
||||
|
||||
<!-- Dialog title panel style. -->
|
||||
<item name="materialAlertDialogTitlePanelStyle">@style/BaseDialog.Title.Panel</item>
|
||||
|
||||
<!-- Dialog message text style. -->
|
||||
<item name="materialAlertDialogBodyTextStyle">@style/BaseDialog.Message.Text.Dark</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
7
termux-shared/src/main/res/values/attrs.xml
Normal file
7
termux-shared/src/main/res/values/attrs.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<attr name="extraKeysButtonTextColor" format="reference" />
|
||||
<attr name="extraKeysButtonActiveTextColor" format="reference" />
|
||||
<attr name="extraKeysButtonBackgroundColor" format="reference" />
|
||||
<attr name="extraKeysButtonActiveBackgroundColor" format="reference" />
|
||||
</resources>
|
@@ -10,9 +10,14 @@
|
||||
<color name="red_800">#C4001D</color>
|
||||
|
||||
<color name="grey_200">#EEEEEE</color>
|
||||
<color name="grey_400">#BDBDBD</color>
|
||||
<color name="grey_500">#9E9E9E</color>
|
||||
<color name="grey_800">#424242</color>
|
||||
<color name="grey_900">#212121</color>
|
||||
|
||||
<color name="red_error">#DC143C</color>
|
||||
<color name="red_error_link">#FC143C</color>
|
||||
|
||||
<color name="blue_link_light">#0969DA</color>
|
||||
<color name="blue_link_dark">#58A6FF</color>
|
||||
</resources>
|
||||
|
@@ -4,7 +4,8 @@
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
|
||||
<dimen name="content_padding_half">4dip</dimen>
|
||||
<dimen name="content_padding">8dip</dimen>
|
||||
<dimen name="content_padding_double">16dip</dimen>
|
||||
<dimen name="content_padding_half">4dip</dimen>
|
||||
<dimen name="content_padding_triple">32dip</dimen>
|
||||
</resources>
|
||||
|
67
termux-shared/src/main/res/values/styles.xml
Normal file
67
termux-shared/src/main/res/values/styles.xml
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- BaseToolbar Title text appearance. -->
|
||||
<style name="TextAppearance.Widget.BaseToolbar.Title" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
|
||||
<item name="android:textSize">14sp</item>
|
||||
</style>
|
||||
|
||||
<!-- BaseToolbar Subtitle text appearance. -->
|
||||
<style name="TextAppearance.Widget.BaseToolbar.Subtitle" parent="TextAppearance.Widget.AppCompat.Toolbar.Subtitle">
|
||||
<item name="android:textSize">12sp</item>
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
BaseDialog Title Panel materialAlertDialogTitlePanelStyle.
|
||||
https://github.com/material-components/material-components-android/blob/1.4.0/lib/java/com/google/android/material/dialog/res/layout/mtrl_alert_dialog_title.xml#L29
|
||||
https://github.com/material-components/material-components-android/blob/1.4.0/lib/java/com/google/android/material/dialog/res/values/themes.xml#L71
|
||||
-->
|
||||
<style name="BaseDialog.Title.Panel" parent="@style/MaterialAlertDialog.MaterialComponents.Title.Panel">
|
||||
<!-- Title background. -->
|
||||
<item name="android:background">@color/red_400</item>
|
||||
|
||||
<!-- Center Title. -->
|
||||
<item name="android:paddingTop">14dp</item>
|
||||
<item name="android:paddingBottom">14dp</item>
|
||||
</style>
|
||||
|
||||
|
||||
<!--
|
||||
BaseDialog Message Text Light materialAlertDialogBodyTextStyle.
|
||||
https://github.com/material-components/material-components-android/blob/1.4.0/lib/java/com/google/android/material/dialog/res/layout/mtrl_alert_dialog.xml#L59
|
||||
https://github.com/material-components/material-components-android/blob/1.4.0/lib/java/com/google/android/material/dialog/res/values/themes_base.xml#L133
|
||||
-->
|
||||
<style name="BaseDialog.Message.Text.Light" parent="@style/MaterialAlertDialog.MaterialComponents.Body.Text">
|
||||
<!-- Text color. -->
|
||||
<item name="android:textColorPrimary">@color/black</item>
|
||||
<item name="android:textColorLink">@color/blue_link_light</item>
|
||||
</style>
|
||||
|
||||
<!--
|
||||
BaseDialog Message Text Dark materialAlertDialogBodyTextStyle.
|
||||
https://github.com/material-components/material-components-android/blob/1.4.0/lib/java/com/google/android/material/dialog/res/layout/mtrl_alert_dialog.xml#L59
|
||||
https://github.com/material-components/material-components-android/blob/1.4.0/lib/java/com/google/android/material/dialog/res/values/themes_base.xml#L133
|
||||
-->
|
||||
<style name="BaseDialog.Message.Text.Dark" parent="@style/MaterialAlertDialog.MaterialComponents.Body.Text">
|
||||
<!-- Text color. -->
|
||||
<item name="android:textColorLink">@color/blue_link_light</item>
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ViewDivider style. -->
|
||||
<style name="ViewDivider">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">1dp</item>
|
||||
<item name="android:layout_marginTop">@dimen/activity_vertical_margin</item>
|
||||
<item name="android:layout_marginBottom">@dimen/activity_vertical_margin</item>
|
||||
<item name="android:background">?android:attr/listDivider</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
@@ -1,6 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<style name="Theme.MaterialComponents.DayNight.TermuxPrimaryActivity" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!--
|
||||
The light themes are only for day mode and must not be defined in night/theme.xml.
|
||||
https://material.io/develop/android/theming/dark
|
||||
-->
|
||||
|
||||
<!--
|
||||
BaseActivity Light DarkActionBar theme.
|
||||
https://github.com/material-components/material-components-android/blob/1.4.0/lib/java/com/google/android/material/theme/res/values/themes.xml#L33
|
||||
-->
|
||||
<style name="Theme.BaseActivity.Light.DarkActionBar" parent="Theme.MaterialComponents.Light.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/red_400</item>
|
||||
<item name="colorPrimaryVariant">@color/red_800</item>
|
||||
@@ -13,30 +22,81 @@
|
||||
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<item name="colorPrimaryDark" tools:targetApi="l">?attr/colorPrimary</item>
|
||||
|
||||
<!-- Text color. -->
|
||||
<item name="android:textColorPrimary">@color/black</item>
|
||||
<item name="android:textColorLink">@color/grey_800</item>
|
||||
<item name="android:textColorSecondary">@color/white</item>
|
||||
<item name="android:textColorLink">@color/blue_link_light</item>
|
||||
|
||||
<!--
|
||||
Dialog Themes.
|
||||
These MUST be defined for the application `android:theme` so that if dialogs
|
||||
are shown from non-activity context with TYPE_SYSTEM_ALERT, the correct dialog theme is
|
||||
applied, otherwise exceptions like `UnsupportedOperationException: Failed to resolve attribute
|
||||
at index... TypedValue` will be thrown, since ThemeOverlay would have all the activity
|
||||
theme attributes defined.
|
||||
-->
|
||||
<item name="alertDialogTheme">@style/ThemeOverlay.BaseDialog.DayNight</item>
|
||||
<item name="materialAlertDialogTheme">@style/ThemeOverlay.BaseDialog.DayNight</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.AppCompat.TermuxReportActivity" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="colorPrimaryDark">#FF0000</item>
|
||||
<!-- BaseActivity Light NoActionBar theme. -->
|
||||
<style name="Theme.BaseActivity.Light.NoActionBar" parent="Theme.BaseActivity.Light.DarkActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.AppCompat.TermuxTextIOActivity" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="colorPrimaryDark">#FF0000</item>
|
||||
|
||||
|
||||
<!-- BaseActivity DayNight DarkActionBar theme. -->
|
||||
<style name="Theme.BaseActivity.DayNight.DarkActionBar" parent="Theme.BaseActivity.Light.DarkActionBar"/>
|
||||
<!-- BaseActivity DayNight NoActionBar theme. -->
|
||||
<style name="Theme.BaseActivity.DayNight.NoActionBar" parent="Theme.BaseActivity.Light.NoActionBar"/>
|
||||
|
||||
|
||||
|
||||
<!-- BaseActivity extended classes Day NoActionBar themes. -->
|
||||
<style name="Theme.MediaViewActivity.Light" parent="Theme.BaseActivity.Light.NoActionBar"/>
|
||||
<style name="Theme.MarkdownViewActivity.Light" parent="Theme.MediaViewActivity.Light"/>
|
||||
|
||||
<!-- BaseActivity extended classes DayNight NoActionBar themes. -->
|
||||
<style name="Theme.MediaViewActivity.DayNight" parent="Theme.BaseActivity.DayNight.NoActionBar"/>
|
||||
<style name="Theme.MarkdownViewActivity.DayNight" parent="Theme.MediaViewActivity.DayNight"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
BaseDialog Light theme.
|
||||
https://github.com/material-components/material-components-android/blob/1.4.0/lib/java/com/google/android/material/dialog/res/values/themes.xml#L70
|
||||
-->
|
||||
<style name="ThemeOverlay.BaseDialog.Light" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/red_400</item>
|
||||
<item name="colorPrimaryVariant">@color/red_800</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/grey_900</item>
|
||||
<item name="colorSecondaryVariant">@color/black</item>
|
||||
<item name="colorOnSecondary">@color/white</item>
|
||||
|
||||
<!-- Surface color. -->
|
||||
<item name="colorSurface">@color/design_default_color_surface</item>
|
||||
<item name="colorOnSurface">@color/design_default_color_on_surface</item>
|
||||
|
||||
<!-- Dialog title panel style. -->
|
||||
<item name="materialAlertDialogTitlePanelStyle">@style/BaseDialog.Title.Panel</item>
|
||||
|
||||
<!-- Dialog message text style. -->
|
||||
<item name="materialAlertDialogBodyTextStyle">@style/BaseDialog.Message.Text.Light</item>
|
||||
</style>
|
||||
|
||||
<style name="Toolbar.Title" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
|
||||
<item name="android:textSize">14sp</item>
|
||||
</style>
|
||||
<!-- BaseDialog DayNight theme. -->
|
||||
<style name="ThemeOverlay.BaseDialog.DayNight" parent="ThemeOverlay.BaseDialog.Light"/>
|
||||
|
||||
<!-- BaseDialog extended classes DayNight themes. -->
|
||||
<style name="ThemeOverlay.MessageDialog.DayNight" parent="ThemeOverlay.BaseDialog.DayNight"/>
|
||||
|
||||
<style name="ViewDivider">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">1dp</item>
|
||||
<item name="android:layout_marginTop">@dimen/activity_vertical_margin</item>
|
||||
<item name="android:layout_marginBottom">@dimen/activity_vertical_margin</item>
|
||||
<item name="android:background">?android:attr/listDivider</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
Reference in New Issue
Block a user