mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-07 03:05:18 +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:
@@ -17,6 +17,7 @@ import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.termux.shared.R;
|
||||
import com.termux.shared.activity.media.AppCompatActivityUtils;
|
||||
import com.termux.shared.data.DataUtils;
|
||||
import com.termux.shared.file.FileUtils;
|
||||
import com.termux.shared.file.filesystem.FileType;
|
||||
@@ -26,6 +27,7 @@ import com.termux.shared.termux.TermuxConstants;
|
||||
import com.termux.shared.markdown.MarkdownUtils;
|
||||
import com.termux.shared.interact.ShareUtils;
|
||||
import com.termux.shared.models.ReportInfo;
|
||||
import com.termux.shared.theme.NightMode;
|
||||
|
||||
import org.commonmark.node.FencedCodeBlock;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -72,6 +74,8 @@ public class ReportActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
Logger.logVerbose(LOG_TAG, "onCreate");
|
||||
|
||||
AppCompatActivityUtils.setNightMode(this, NightMode.getAppNightMode().getName(), true);
|
||||
|
||||
setContentView(R.layout.activity_report);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
|
@@ -0,0 +1,120 @@
|
||||
package com.termux.shared.activity.media;
|
||||
|
||||
import androidx.annotation.IdRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import com.termux.shared.logger.Logger;
|
||||
import com.termux.shared.theme.NightMode;
|
||||
|
||||
public class AppCompatActivityUtils {
|
||||
|
||||
private static final String LOG_TAG = "AppCompatActivityUtils";
|
||||
|
||||
|
||||
/** Set activity night mode.
|
||||
*
|
||||
* @param activity The host {@link AppCompatActivity}.
|
||||
* @param name The {@link String} representing the name for a {@link NightMode}.
|
||||
* @param local If set to {@code true}, then a call to {@link AppCompatDelegate#setLocalNightMode(int)}
|
||||
* will be made, otherwise to {@link AppCompatDelegate#setDefaultNightMode(int)}.
|
||||
*/
|
||||
public static void setNightMode(AppCompatActivity activity, String name, boolean local) {
|
||||
if (name == null) return;
|
||||
NightMode nightMode = NightMode.modeOf(name);
|
||||
if (nightMode != null) {
|
||||
if (local) {
|
||||
if (activity != null) {
|
||||
activity.getDelegate().setLocalNightMode(nightMode.getMode());
|
||||
}
|
||||
} else {
|
||||
AppCompatDelegate.setDefaultNightMode(nightMode.getMode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Set activity toolbar.
|
||||
*
|
||||
* @param activity The host {@link AppCompatActivity}.
|
||||
* @param id The toolbar resource id.
|
||||
*/
|
||||
public static void setToolbar(@NonNull AppCompatActivity activity, @IdRes int id) {
|
||||
Toolbar toolbar = activity.findViewById(id);
|
||||
if (toolbar != null)
|
||||
activity.setSupportActionBar(toolbar);
|
||||
}
|
||||
|
||||
/** Set activity toolbar title.
|
||||
*
|
||||
* @param activity The host {@link AppCompatActivity}.
|
||||
* @param id The toolbar resource id.
|
||||
* @param title The toolbar title {@link String}.
|
||||
* @param titleAppearance The toolbar title TextAppearance resource id.
|
||||
*/
|
||||
public static void setToolbarTitle(@NonNull AppCompatActivity activity, @IdRes int id,
|
||||
String title, @StyleRes int titleAppearance) {
|
||||
Toolbar toolbar = activity.findViewById(id);
|
||||
if (toolbar != null) {
|
||||
//toolbar.setTitle(title); // Does not work
|
||||
final ActionBar actionBar = activity.getSupportActionBar();
|
||||
if (actionBar != null)
|
||||
actionBar.setTitle(title);
|
||||
|
||||
try {
|
||||
if (titleAppearance != 0)
|
||||
toolbar.setTitleTextAppearance(activity, titleAppearance);
|
||||
} catch (Exception e) {
|
||||
Logger.logStackTraceWithMessage(LOG_TAG, "Failed to set toolbar title appearance to style resource id " + titleAppearance, e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/** Set activity toolbar subtitle.
|
||||
*
|
||||
* @param activity The host {@link AppCompatActivity}.
|
||||
* @param id The toolbar resource id.
|
||||
* @param subtitle The toolbar subtitle {@link String}.
|
||||
* @param subtitleAppearance The toolbar subtitle TextAppearance resource id.
|
||||
*/
|
||||
public static void setToolbarSubtitle(@NonNull AppCompatActivity activity, @IdRes int id,
|
||||
String subtitle, @StyleRes int subtitleAppearance) {
|
||||
Toolbar toolbar = activity.findViewById(id);
|
||||
if (toolbar != null) {
|
||||
toolbar.setSubtitle(subtitle);
|
||||
try {
|
||||
if (subtitleAppearance != 0)
|
||||
toolbar.setSubtitleTextAppearance(activity, subtitleAppearance);
|
||||
} catch (Exception e) {
|
||||
Logger.logStackTraceWithMessage(LOG_TAG, "Failed to set toolbar subtitle appearance to style resource id " + subtitleAppearance, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Set whether back button should be shown in activity toolbar.
|
||||
*
|
||||
* @param activity The host {@link AppCompatActivity}.
|
||||
* @param showBackButtonInActionBar Set to {@code true} to enable and {@code false} to disable.
|
||||
*/
|
||||
public static void setShowBackButtonInActionBar(@NonNull AppCompatActivity activity,
|
||||
boolean showBackButtonInActionBar) {
|
||||
final ActionBar actionBar = activity.getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
if (showBackButtonInActionBar) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setDisplayShowHomeEnabled(true);
|
||||
} else {
|
||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
||||
actionBar.setDisplayShowHomeEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -17,6 +17,7 @@ import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.termux.shared.R;
|
||||
import com.termux.shared.theme.ThemeUtils;
|
||||
|
||||
import org.commonmark.ext.gfm.strikethrough.Strikethrough;
|
||||
import org.commonmark.node.BlockQuote;
|
||||
@@ -152,11 +153,14 @@ public class MarkdownUtils {
|
||||
|
||||
@Override
|
||||
public void configureSpansFactory(@NonNull MarkwonSpansFactory.Builder builder) {
|
||||
builder
|
||||
// set color for inline code
|
||||
.setFactory(Code.class, (configuration, props) -> new Object[]{
|
||||
new BackgroundColorSpan(ContextCompat.getColor(context, R.color.background_markdown_code_inline)),
|
||||
});
|
||||
// Do not change color for night themes
|
||||
if (!ThemeUtils.isNightModeEnabled(context)) {
|
||||
builder
|
||||
// set color for inline code
|
||||
.setFactory(Code.class, (configuration, props) -> new Object[]{
|
||||
new BackgroundColorSpan(ContextCompat.getColor(context, R.color.background_markdown_code_inline)),
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
@@ -32,7 +32,9 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.termux.shared.R;
|
||||
import com.termux.shared.termux.terminal.io.TerminalExtraKeys;
|
||||
import com.termux.shared.theme.ThemeUtils;
|
||||
|
||||
/**
|
||||
* A {@link View} showing extra keys (such as Escape, Ctrl, Alt) not normally available on an Android soft
|
||||
@@ -107,16 +109,26 @@ public final class ExtraKeysView extends GridLayout {
|
||||
}
|
||||
|
||||
|
||||
/** Defines the default value for {@link #mButtonTextColor}. */
|
||||
/** Defines the default value for {@link #mButtonTextColor} defined by current theme. */
|
||||
public static final int ATTR_BUTTON_TEXT_COLOR = R.attr.extraKeysButtonTextColor;
|
||||
/** Defines the default value for {@link #mButtonActiveTextColor} defined by current theme. */
|
||||
public static final int ATTR_BUTTON_ACTIVE_TEXT_COLOR = R.attr.extraKeysButtonActiveTextColor;
|
||||
/** Defines the default value for {@link #mButtonBackgroundColor} defined by current theme. */
|
||||
public static final int ATTR_BUTTON_BACKGROUND_COLOR = R.attr.extraKeysButtonBackgroundColor;
|
||||
/** Defines the default value for {@link #mButtonActiveBackgroundColor} defined by current theme. */
|
||||
public static final int ATTR_BUTTON_ACTIVE_BACKGROUND_COLOR = R.attr.extraKeysButtonActiveBackgroundColor;
|
||||
|
||||
/** Defines the default fallback value for {@link #mButtonTextColor} if {@link #ATTR_BUTTON_TEXT_COLOR} is undefined. */
|
||||
public static final int DEFAULT_BUTTON_TEXT_COLOR = 0xFFFFFFFF;
|
||||
/** Defines the default value for {@link #mButtonActiveTextColor}. */
|
||||
/** Defines the default fallback value for {@link #mButtonActiveTextColor} if {@link #ATTR_BUTTON_ACTIVE_TEXT_COLOR} is undefined. */
|
||||
public static final int DEFAULT_BUTTON_ACTIVE_TEXT_COLOR = 0xFF80DEEA;
|
||||
/** Defines the default value for {@link #mButtonBackgroundColor}. */
|
||||
/** Defines the default fallback value for {@link #mButtonBackgroundColor} if {@link #ATTR_BUTTON_BACKGROUND_COLOR} is undefined. */
|
||||
public static final int DEFAULT_BUTTON_BACKGROUND_COLOR = 0x00000000;
|
||||
/** Defines the default value for {@link #mButtonActiveBackgroundColor}. */
|
||||
/** Defines the default fallback value for {@link #mButtonActiveBackgroundColor} if {@link #ATTR_BUTTON_ACTIVE_BACKGROUND_COLOR} is undefined. */
|
||||
public static final int DEFAULT_BUTTON_ACTIVE_BACKGROUND_COLOR = 0xFF7F7F7F;
|
||||
|
||||
|
||||
|
||||
/** Defines the minimum allowed duration in milliseconds for {@link #mLongPressTimeout}. */
|
||||
public static final int MIN_LONG_PRESS_DURATION = 200;
|
||||
/** Defines the maximum allowed duration in milliseconds for {@link #mLongPressTimeout}. */
|
||||
@@ -202,8 +214,13 @@ public final class ExtraKeysView extends GridLayout {
|
||||
|
||||
setRepetitiveKeys(ExtraKeysConstants.PRIMARY_REPETITIVE_KEYS);
|
||||
setSpecialButtons(getDefaultSpecialButtons(this));
|
||||
setButtonColors(DEFAULT_BUTTON_TEXT_COLOR, DEFAULT_BUTTON_ACTIVE_TEXT_COLOR,
|
||||
DEFAULT_BUTTON_BACKGROUND_COLOR, DEFAULT_BUTTON_ACTIVE_BACKGROUND_COLOR);
|
||||
|
||||
setButtonColors(
|
||||
ThemeUtils.getSystemAttrColor(context, ATTR_BUTTON_TEXT_COLOR, DEFAULT_BUTTON_TEXT_COLOR),
|
||||
ThemeUtils.getSystemAttrColor(context, ATTR_BUTTON_ACTIVE_TEXT_COLOR, DEFAULT_BUTTON_ACTIVE_TEXT_COLOR),
|
||||
ThemeUtils.getSystemAttrColor(context, ATTR_BUTTON_BACKGROUND_COLOR, DEFAULT_BUTTON_BACKGROUND_COLOR),
|
||||
ThemeUtils.getSystemAttrColor(context, ATTR_BUTTON_ACTIVE_BACKGROUND_COLOR, DEFAULT_BUTTON_ACTIVE_BACKGROUND_COLOR));
|
||||
|
||||
setLongPressTimeout(ViewConfiguration.getLongPressTimeout());
|
||||
setLongPressRepeatDelay(DEFAULT_LONG_PRESS_REPEAT_DELAY);
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ public enum NightMode {
|
||||
private static final String LOG_TAG = "NightMode";
|
||||
|
||||
private final String name;
|
||||
private final int mode;
|
||||
private final @AppCompatDelegate.NightMode int mode;
|
||||
|
||||
NightMode(final String name, int mode) {
|
||||
this.name = name;
|
||||
|
@@ -1,10 +1,19 @@
|
||||
package com.termux.shared.theme;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.TypedArray;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class ThemeUtils {
|
||||
|
||||
public static final int ATTR_TEXT_COLOR_PRIMARY = android.R.attr.textColorPrimary;
|
||||
public static final int ATTR_TEXT_COLOR_SECONDARY = android.R.attr.textColorSecondary;
|
||||
public static final int ATTR_TEXT_COLOR = android.R.attr.textColor;
|
||||
public static final int ATTR_TEXT_COLOR_LINK = android.R.attr.textColorLink;
|
||||
|
||||
/**
|
||||
* Will return true if system has enabled night mode.
|
||||
* https://developer.android.com/guide/topics/resources/providing-resources#NightQualifier
|
||||
@@ -28,4 +37,50 @@ public class ThemeUtils {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Get {@link #ATTR_TEXT_COLOR_PRIMARY} value being used by current theme. */
|
||||
public static int getTextColorPrimary(Context context) {
|
||||
return getSystemAttrColor(context, ATTR_TEXT_COLOR_PRIMARY);
|
||||
}
|
||||
|
||||
/** Get {@link #ATTR_TEXT_COLOR_SECONDARY} value being used by current theme. */
|
||||
public static int getTextColorSecondary(Context context) {
|
||||
return getSystemAttrColor(context, ATTR_TEXT_COLOR_SECONDARY);
|
||||
}
|
||||
|
||||
/** Get {@link #ATTR_TEXT_COLOR} value being used by current theme. */
|
||||
public static int getTextColor(Context context) {
|
||||
return getSystemAttrColor(context, ATTR_TEXT_COLOR);
|
||||
}
|
||||
|
||||
/** Get {@link #ATTR_TEXT_COLOR_LINK} value being used by current theme. */
|
||||
public static int getTextColorLink(Context context) {
|
||||
return getSystemAttrColor(context, ATTR_TEXT_COLOR_LINK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Wrapper for {@link #getSystemAttrColor(Context, int, int)} with {@code def} value {@code 0}. */
|
||||
public static int getSystemAttrColor(Context context, int attr) {
|
||||
return getSystemAttrColor(context, attr, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a values defined by the current heme listed in attrs.
|
||||
*
|
||||
* @param context The context for operations. It must be an instance of {@link Activity} or
|
||||
* {@link AppCompatActivity} or one with which a theme attribute can be got.
|
||||
* Do no use application context.
|
||||
* @param attr The attr id.
|
||||
* @param def The def value to return.
|
||||
* @return Returns the {@code attr} value if found, otherwise {@code def}.
|
||||
*/
|
||||
public static int getSystemAttrColor(Context context, int attr, int def) {
|
||||
TypedArray typedArray = context.getTheme().obtainStyledAttributes(new int[] { attr });
|
||||
int color = typedArray.getColor(0, def);
|
||||
typedArray.recycle();
|
||||
return color;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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