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:
agnostic-apollo
2022-01-23 00:18:33 +05:00
parent f3f434af92
commit 6631599fb6
30 changed files with 586 additions and 140 deletions

View File

@@ -16,6 +16,7 @@ android {
implementation "androidx.drawerlayout:drawerlayout:1.1.1"
implementation "androidx.preference:preference:1.1.1"
implementation "androidx.viewpager:viewpager:1.0.0"
implementation "com.google.android.material:material:1.4.0"
implementation "com.google.guava:guava:24.1-jre"
implementation "io.noties.markwon:core:$markwonVersion"
implementation "io.noties.markwon:ext-strikethrough:$markwonVersion"

View File

@@ -46,14 +46,15 @@
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="false"
android:theme="@style/Theme.Termux">
android:theme="@style/Theme.TermuxApp.DayNight.DarkActionBar">
<activity
android:name=".app.TermuxActivity"
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|uiMode|keyboard|keyboardHidden|navigation"
android:configChanges="orientation|screenSize|smallestScreenSize|density|screenLayout|keyboard|keyboardHidden|navigation"
android:label="@string/application_name"
android:launchMode="singleTask"
android:resizeableActivity="true">
android:resizeableActivity="true"
android:theme="@style/Theme.TermuxActivity.DayNight.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -88,20 +89,18 @@
android:exported="false"
android:label="@string/application_name"
android:parentActivityName=".app.TermuxActivity"
android:resizeableActivity="true"
android:theme="@android:style/Theme.Material.Light.DarkActionBar" />
android:resizeableActivity="true" />
<activity
android:name=".app.activities.SettingsActivity"
android:exported="true"
android:label="@string/title_activity_termux_settings"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar" />
android:theme="@style/Theme.TermuxApp.DayNight.NoActionBar" />
<activity
android:name=".shared.activities.ReportActivity"
android:theme="@style/Theme.AppCompat.TermuxReportActivity"
android:documentLaunchMode="intoExisting"
/>
android:theme="@style/Theme.MarkdownViewActivity.DayNight"
android:documentLaunchMode="intoExisting" />
<activity
android:name=".filepicker.TermuxFileReceiverActivity"

View File

@@ -1,7 +1,6 @@
package com.termux.app;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
@@ -10,7 +9,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -34,6 +32,7 @@ import com.termux.R;
import com.termux.app.terminal.TermuxActivityRootView;
import com.termux.shared.activities.ReportActivity;
import com.termux.shared.activity.ActivityUtils;
import com.termux.shared.activity.media.AppCompatActivityUtils;
import com.termux.shared.data.IntentUtils;
import com.termux.shared.android.PermissionUtils;
import com.termux.shared.termux.TermuxConstants;
@@ -52,7 +51,6 @@ import com.termux.shared.logger.Logger;
import com.termux.shared.termux.TermuxUtils;
import com.termux.shared.termux.theme.TermuxThemeUtils;
import com.termux.shared.theme.NightMode;
import com.termux.shared.theme.ThemeUtils;
import com.termux.shared.view.ViewUtils;
import com.termux.terminal.TerminalSession;
import com.termux.terminal.TerminalSessionClient;
@@ -62,7 +60,7 @@ import com.termux.view.TerminalViewClient;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.viewpager.widget.ViewPager;
@@ -78,7 +76,7 @@ import java.util.Arrays;
* </ul>
* about memory leaks.
*/
public final class TermuxActivity extends Activity implements ServiceConnection {
public final class TermuxActivity extends AppCompatActivity implements ServiceConnection {
/**
* The connection to the {@link TermuxService}. Requested in {@link #onCreate(Bundle)} with a call to
@@ -228,8 +226,6 @@ public final class TermuxActivity extends Activity implements ServiceConnection
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
setDrawerTheme();
setTermuxTerminalViewAndClients();
setTerminalToolbarView(savedInstanceState);
@@ -340,6 +336,8 @@ public final class TermuxActivity extends Activity implements ServiceConnection
@Override
public void onSaveInstanceState(@NonNull Bundle savedInstanceState) {
Logger.logVerbose(LOG_TAG, "onSaveInstanceState");
super.onSaveInstanceState(savedInstanceState);
saveTerminalToolbarTextInput(savedInstanceState);
}
@@ -413,19 +411,10 @@ public final class TermuxActivity extends Activity implements ServiceConnection
// Update NightMode.APP_NIGHT_MODE
TermuxThemeUtils.setAppNightMode(mProperties.getNightMode());
if (ThemeUtils.shouldEnableDarkTheme(this, NightMode.getAppNightMode().getName())) {
this.setTheme(R.style.Theme_Termux_Black);
} else {
this.setTheme(R.style.Theme_Termux);
}
}
private void setDrawerTheme() {
if (ThemeUtils.shouldEnableDarkTheme(this, NightMode.getAppNightMode().getName())) {
findViewById(R.id.left_drawer).setBackgroundColor(ContextCompat.getColor(this,
android.R.color.background_dark));
((ImageButton) findViewById(R.id.settings_button)).setColorFilter(Color.WHITE);
}
// Set activity night mode. If NightMode.SYSTEM is set, then android will automatically
// trigger recreation of activity when uiMode/dark mode configuration is changed so that
// day or night theme takes affect.
AppCompatActivityUtils.setNightMode(this, NightMode.getAppNightMode().getName(), true);
}
private void setMargins() {
@@ -518,7 +507,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
private void saveTerminalToolbarTextInput(Bundle savedInstanceState) {
if (savedInstanceState == null) return;
final EditText textInputView = findViewById(R.id.terminal_toolbar_text_input);
final EditText textInputView = findViewById(R.id.terminal_toolbar_text_input);
if (textInputView != null) {
String textInput = textInputView.getText().toString();
if (!textInput.isEmpty()) savedInstanceState.putString(ARG_TERMINAL_TOOLBAR_TEXT_INPUT, textInput);
@@ -934,12 +923,9 @@ public final class TermuxActivity extends Activity implements ServiceConnection
mTermuxService.setTerminalTranscriptRows();
// To change the activity and drawer theme, activity needs to be recreated.
// But this will destroy the activity, and will call the onCreate() again.
// We need to investigate if enabling this is wise, since all stored variables and
// views will be destroyed and bindService() will be called again. Extra keys input
// text will we restored since that has already been implemented. Terminal sessions
// and transcripts are also already preserved. Theme does change properly too.
// TermuxActivity.this.recreate();
// It will destroy the activity, including all stored variables and views, and onCreate()
// will be called again. Extra keys input text, terminal sessions and transcripts will be preserved.
TermuxActivity.this.recreate();
}

View File

@@ -1,6 +1,5 @@
package com.termux.app.activities;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
@@ -12,10 +11,12 @@ import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import androidx.appcompat.app.AppCompatActivity;
import com.termux.shared.termux.TermuxConstants;
/** Basic embedded browser for viewing help pages. */
public final class HelpActivity extends Activity {
public final class HelpActivity extends AppCompatActivity {
WebView mWebView;

View File

@@ -5,7 +5,6 @@ import android.os.Bundle;
import android.os.Environment;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
@@ -24,12 +23,17 @@ import com.termux.shared.termux.settings.preferences.TermuxWidgetAppSharedPrefer
import com.termux.shared.android.AndroidUtils;
import com.termux.shared.termux.TermuxConstants;
import com.termux.shared.termux.TermuxUtils;
import com.termux.shared.activity.media.AppCompatActivityUtils;
import com.termux.shared.theme.NightMode;
public class SettingsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AppCompatActivityUtils.setNightMode(this, NightMode.getAppNightMode().getName(), true);
setContentView(R.layout.activity_settings);
if (savedInstanceState == null) {
getSupportFragmentManager()
@@ -37,11 +41,9 @@ public class SettingsActivity extends AppCompatActivity {
.replace(R.id.settings, new RootPreferencesFragment())
.commit();
}
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
AppCompatActivityUtils.setToolbar(this, com.termux.shared.R.id.toolbar);
AppCompatActivityUtils.setShowBackButtonInActionBar(this, true);
}
@Override

View File

@@ -1,6 +1,5 @@
package com.termux.filepicker;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
@@ -8,6 +7,7 @@ import android.provider.OpenableColumns;
import android.util.Patterns;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.termux.R;
import com.termux.shared.data.DataUtils;
@@ -31,7 +31,7 @@ import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.regex.Pattern;
public class TermuxFileReceiverActivity extends Activity {
public class TermuxFileReceiverActivity extends AppCompatActivity {
static final String TERMUX_RECEIVEDIR = TermuxConstants.TERMUX_FILES_DIR_PATH + "/home/downloads";
static final String EDITOR_PROGRAM = TermuxConstants.TERMUX_HOME_DIR_PATH + "/bin/termux-file-editor";

View File

@@ -1,9 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">
<include
layout="@layout/partial_primary_toolbar"
android:id="@+id/partial_primary_toolbar"/>
<FrameLayout
android:id="@+id/settings"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View File

@@ -1,4 +1,5 @@
<com.termux.app.terminal.TermuxActivityRootView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_termux_root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -36,12 +37,12 @@
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
android:orientation="vertical"
android:background="?attr/termuxActivityDrawerBackground">
<LinearLayout
android:layout_width="match_parent"
@@ -53,7 +54,8 @@
android:layout_height="40dp"
android:src="@drawable/ic_settings"
android:background="@null"
android:contentDescription="@string/action_open_settings" />
android:contentDescription="@string/action_open_settings"
app:tint="?attr/termuxActivityDrawerImageTint" />
</LinearLayout>
<ListView
@@ -71,7 +73,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
<com.google.android.material.button.MaterialButton
android:id="@+id/toggle_keyboard_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="match_parent"
@@ -79,7 +81,7 @@
android:layout_weight="1"
android:text="@string/action_toggle_soft_keyboard" />
<Button
<com.google.android.material.button.MaterialButton
android:id="@+id/new_session_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="match_parent"

View File

@@ -1,4 +1,4 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
<com.google.android.material.textview.MaterialTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/session_title"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
https://material.io/develop/android/theming/dark
-->
<!-- TermuxActivity DayNight NoActionBar theme. -->
<!-- See https://developer.android.com/training/material/theme.html for how to customize the Material theme. -->
<!-- NOTE: Cannot use "Light." since it hides the terminal scrollbar on the default black background. -->
<style name="Theme.TermuxActivity.DayNight.NoActionBar" parent="Theme.TermuxApp.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/black</item>
<item name="colorPrimaryVariant">@color/black</item>
<item name="android:windowBackground">@color/black</item>
<!-- Avoid action mode toolbar pushing down terminal content when
selecting text on pre-6.0 (non-floating toolbar). -->
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<!-- https://developer.android.com/training/tv/start/start.html#transition-color -->
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<!-- Left drawer. -->
<item name="buttonBarButtonStyle">@style/TermuxActivity.Drawer.ButtonBarStyle.Dark</item>
<item name="termuxActivityDrawerBackground">@color/black</item>
<item name="termuxActivityDrawerImageTint">@color/white</item>
<!-- Extra keys colors. -->
<item name="extraKeysButtonTextColor">@color/white</item>
<item name="extraKeysButtonActiveTextColor">@color/red_400</item>
<item name="extraKeysButtonBackgroundColor">@color/black</item>
<item name="extraKeysButtonActiveBackgroundColor">@color/grey_500</item>
</style>
</resources>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="termuxActivityDrawerBackground" format="reference" />
<attr name="termuxActivityDrawerImageTint" format="reference" />
</resources>

View File

@@ -1,52 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.Termux" parent="@android:style/Theme.Material.Light.NoActionBar">
<item name="android:statusBarColor">#000000</item>
<item name="android:colorPrimary">#FF000000</item>
<item name="android:windowBackground">@android:color/black</item>
<!-- Seen in buttons on left drawer: -->
<item name="android:colorAccent">#212121</item>
<item name="android:alertDialogTheme">@style/TermuxAlertDialogStyle</item>
<!-- Avoid action mode toolbar pushing down terminal content when
selecting text on pre-6.0 (non-floating toolbar). -->
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<!-- https://developer.android.com/training/tv/start/start.html#transition-color -->
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
</style>
<!-- See https://developer.android.com/training/material/theme.html for how to customize the Material theme. -->
<!-- NOTE: Cannot use "Light." since it hides the terminal scrollbar on the default black background. -->
<style name="Theme.Termux.Black" parent="@android:style/Theme.Material.NoActionBar">
<item name="android:statusBarColor">#000000</item>
<item name="android:colorPrimary">#FF000000</item>
<item name="android:windowBackground">@android:color/black</item>
<!-- Seen in buttons on left drawer: -->
<item name="android:colorAccent">#FDFDFD</item>
<!-- Avoid action mode toolbar pushing down terminal content when
selecting text on pre-6.0 (non-floating toolbar). -->
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<!-- https://developer.android.com/training/tv/start/start.html#transition-color -->
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
</style>
<style name="TermuxAlertDialogStyle" parent="@android:style/Theme.Material.Light.Dialog.Alert">
<!-- Seen in buttons on alert dialog: -->
<item name="android:colorAccent">#212121</item>
</style>
<style name="TermuxActivity.Drawer.ButtonBarStyle.Light" parent="@style/Widget.MaterialComponents.Button.TextButton">
<item name="android:textColor">@color/black</item>
</style>
<style name="TermuxActivity.Drawer.ButtonBarStyle.Dark" parent="@style/Widget.MaterialComponents.Button.TextButton">
<item name="android:textColor">@color/white</item>
</style>
</resources>

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
https://material.io/develop/android/theming/dark
-->
<!-- TermuxApp Light DarkActionBar theme. -->
<style name="Theme.TermuxApp.Light.DarkActionBar" parent="Theme.BaseActivity.Light.DarkActionBar"/>
<!-- TermuxApp Light NoActionBar theme. -->
<style name="Theme.TermuxApp.Light.NoActionBar" parent="Theme.BaseActivity.Light.NoActionBar"/>
<!-- TermuxApp DayNight DarkActionBar theme. -->
<style name="Theme.TermuxApp.DayNight.DarkActionBar" parent="Theme.BaseActivity.DayNight.DarkActionBar"/>
<!-- TermuxApp DayNight NoActionBar theme. -->
<style name="Theme.TermuxApp.DayNight.NoActionBar" parent="Theme.BaseActivity.DayNight.NoActionBar"/>
<!-- TermuxActivity DayNight NoActionBar theme. -->
<style name="Theme.TermuxActivity.DayNight.NoActionBar" parent="Theme.TermuxApp.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/black</item>
<item name="colorPrimaryVariant">@color/black</item>
<item name="android:windowBackground">@color/black</item>
<!-- Avoid action mode toolbar pushing down terminal content when
selecting text on pre-6.0 (non-floating toolbar). -->
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<!-- https://developer.android.com/training/tv/start/start.html#transition-color -->
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<!-- Left drawer. -->
<item name="buttonBarButtonStyle">@style/TermuxActivity.Drawer.ButtonBarStyle.Light</item>
<item name="termuxActivityDrawerBackground">@color/white</item>
<item name="termuxActivityDrawerImageTint">@color/black</item>
<!-- Extra keys colors. -->
<item name="extraKeysButtonTextColor">@color/white</item>
<item name="extraKeysButtonActiveTextColor">@color/red_400</item>
<item name="extraKeysButtonBackgroundColor">@color/black</item>
<item name="extraKeysButtonActiveBackgroundColor">@color/grey_500</item>
</style>
</resources>

View File

@@ -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);

View File

@@ -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);
}
}
}
}

View File

@@ -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();

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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;
}
}

View File

@@ -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"

View File

@@ -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"

View File

@@ -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>

View File

@@ -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" />

View File

@@ -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>

View File

@@ -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>

View 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>

View File

@@ -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>

View File

@@ -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>

View 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>

View File

@@ -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>