Skip to content

Commit

Permalink
Begin to implement new styles for dialogs
Browse files Browse the repository at this point in the history
- Mostly change the colours and text styles to match CorsixTH design. There
are still a few places where it's visibly wrong, and it's difficult to
match up with the bitmap font exactly whilst still allowing control by the
user display preferences. Notably the dialog buttons and the checkboxes
don't follow any particular colour scheme yet.
- Provide a back button on the save and settings dialogs to make it easier
for gesture based controls
  • Loading branch information
alanwoolley committed Sep 14, 2023
1 parent 8375cf8 commit ac7f4a7
Show file tree
Hide file tree
Showing 17 changed files with 264 additions and 29 deletions.
Binary file added res/drawable-hdpi/frame.9.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/frame.9.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/frame.9.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xxhdpi/frame.9.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xxxhdpi/frame.9.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/frame.9.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions res/drawable/lowered.xml
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="2dp" android:bottom="2dp" android:right="2dp" android:left="2dp">
<shape>
<solid android:color="@color/cth_window_caption" />
</shape>
</item>
<item>
<shape>
<stroke
android:width="1dp"
android:color="@color/cth_window_caption_highlight" />
</shape>
</item>
<item android:bottom="1dp" android:right="1dp">
<shape>
<padding
android:left="0dp"
android:top="0dp"
android:bottom="1dp"
android:right="1dp" />
<stroke
android:width="1dp"
android:color="@color/cth_window_caption_shadow" />
</shape>
</item>
</layer-list>
27 changes: 27 additions & 0 deletions res/drawable/raised.xml
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="2dp" android:bottom="2dp" android:right="2dp" android:left="2dp">
<shape android:layout_width="wrap_content">
<solid android:color="@color/cth_window_background" />
</shape>
</item>
<item>
<shape>
<stroke
android:width="1dp"
android:color="@color/cth_window_caption_shadow" />
</shape>
</item>
<item android:bottom="1dp" android:right="1dp">
<shape>
<padding
android:left="0dp"
android:top="0dp"
android:bottom="1dp"
android:right="1dp" />
<stroke
android:width="1dp"
android:color="@color/cth_window_caption_highlight" />
</shape>
</item>
</layer-list>
5 changes: 3 additions & 2 deletions res/layout/new_save_list_item.xml
Expand Up @@ -11,10 +11,11 @@
android:id="@+id/imageView2"
android:layout_width="120dp"
android:layout_height="80dp"
android:contentDescription="Plus Icon"
android:scaleType="centerInside"
android:src="@drawable/baseline_add_24"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:contentDescription="Plus Icon" />
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textView"
Expand Down
31 changes: 27 additions & 4 deletions res/layout/save_activity.xml
@@ -1,9 +1,32 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<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:background="@color/cth_window_background"
android:orientation="vertical">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
style="ToolbarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme">

<FrameLayout
style="@style/ToolbarTitleBackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<TextView
android:id="@+id/toolbar_title"
style="@style/ToolbarTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
</androidx.appcompat.widget.Toolbar>

<FrameLayout
android:id="@+id/save"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent" />
</LinearLayout>
3 changes: 2 additions & 1 deletion res/layout/save_list_item.xml
Expand Up @@ -5,7 +5,8 @@
android:id="@+id/saveLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="4dp">
android:layout_marginVertical="4dp"
android:padding="4dp">

<ImageView
android:id="@+id/saveImage"
Expand Down
33 changes: 29 additions & 4 deletions res/layout/settings_activity.xml
@@ -1,9 +1,34 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="@color/cth_window_background"
android:orientation="vertical">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="ToolbarStyle"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme">

<FrameLayout
style="@style/ToolbarTitleBackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<TextView
android:id="@+id/toolbar_title"
style="@style/ToolbarTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_activity_settings" />
</FrameLayout>
</androidx.appcompat.widget.Toolbar>

<FrameLayout
android:id="@+id/settings"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent" />
</LinearLayout>
13 changes: 8 additions & 5 deletions res/values/colors.xml
@@ -1,7 +1,10 @@
<resources>
<color name="light_blue_600">#FF039BE5</color>
<color name="light_blue_900">#FF01579B</color>
<color name="light_blue_A200">#FF40C4FF</color>
<color name="light_blue_A400">#FF00B0FF</color>
<color name="black_overlay">#66000000</color>
<color name="cth_window_background">#9a92c6</color>
<color name="cth_window_text">#fdfdfd</color>
<color name="cth_window_secondary">#DDDDDD</color>
<color name="cth_window_text_shadow">#2b2b2b</color>
<color name="cth_window_caption">#aea6da</color>
<color name="cth_window_caption_highlight">#d6ceff</color>
<color name="cth_window_caption_shadow">#867eb2</color>

</resources>
90 changes: 84 additions & 6 deletions res/values/styles.xml
Expand Up @@ -3,16 +3,99 @@

<style name="Theme.AppTheme" parent="Theme.AppCompat.Light.NoActionBar" />

<style name="ToolbarStyle">
<item name="android:background">@color/cth_window_background</item>
</style>

<style name="ToolbarTitle">
<item name="android:textAppearance">@style/TextAppearance.Widget.AppCompat.Toolbar.Title
</item>
<item name="android:textColor">@color/cth_window_text</item>
<item name="android:layout_marginStart">40dp</item>
<item name="android:layout_marginTop">2dp</item>
<item name="android:layout_marginEnd">40dp</item>
<item name="android:layout_marginBottom">2dp</item>
<item name="android:layout_gravity">center</item>
</style>

<style name="ToolbarTitleBackground">
<item name="android:layout_gravity">center</item>
<item name="android:background">@drawable/lowered</item>
</style>

<style name="FloatingDialogTitle" parent="Base.DialogWindowTitle.AppCompat">
<item name="android:background">@color/cth_window_background</item>
<item name="android:textColor">@color/cth_window_text</item>
<item name="android:gravity">center</item>
<item name="android:layout_width">wrap_content</item>
</style>

<style name="FloatingDialogLoweredTitleBackground" parent="FloatingDialogTitle">
<item name="android:background">@drawable/lowered</item>
</style>

<style name="Theme.FloatingTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="windowMinWidthMajor">65%</item>
<item name="windowMinWidthMinor">90%</item>
<item name="android:windowBackground">@drawable/frame</item>
<item name="android:windowTitleStyle">@style/FloatingDialogTitle</item>
<item name="android:textViewStyle">@style/ShadowText</item>
<item name="android:textColorSecondary">@color/cth_window_secondary</item>
</style>

<style name="Theme.SettingsDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:windowBackground">@drawable/frame</item>
<item name="android:windowTitleStyle">@style/FloatingDialogLoweredTitleBackground</item>
<item name="android:textViewStyle">@style/ShadowText</item>
<item name="android:checkedTextViewStyle">@style/CheckedShadowText</item>
<item name="android:textColorSecondary">@color/cth_window_secondary</item>
<item name="android:background">@color/cth_window_background</item>
<item name="android:windowIsTranslucent">false</item>
<item name="textColorAlertDialogListItem">@color/cth_window_text</item>
</style>

<style name="Theme.SettingsTheme" parent="Theme.FloatingTheme" />
<style name="Theme.SettingsTheme" parent="Theme.FloatingTheme">
<item name="android:windowNoTitle">true</item>
<item name="windowFixedHeightMinor">90%</item>
<item name="windowFixedHeightMajor">80%</item>
<item name="preferenceCategoryTitleTextColor">@color/cth_window_text</item>
<item name="alertDialogTheme">@style/Theme.SettingsDialog</item>
<item name="android:tint">@color/cth_window_text_shadow</item>
</style>

<style name="Theme.SaveTheme" parent="Theme.FloatingTheme">
<item name="windowFixedHeightMinor">90%</item>
<item name="windowFixedHeightMajor">65%</item>
<item name="alertDialogTheme">@style/Theme.SettingsDialog</item>
<item name="android:windowNoTitle">true</item>
</style>

<style name="CheckedShadowText" parent="android:Widget.Material.Light.CheckedTextView">
<item name="android:shadowDx">1</item>
<item name="android:shadowDy">2</item>
<item name="android:shadowRadius">1</item>
<item name="android:shadowColor">@color/cth_window_text_shadow</item>
<item name="android:textColor">@color/cth_window_text</item>
<item name="android:textColorSecondary">@color/cth_window_text</item>
</style>

<style name="ShadowText" parent="android:Widget.TextView">
<item name="android:shadowDx">1</item>
<item name="android:shadowDy">2</item>
<item name="android:shadowRadius">1</item>
<item name="android:shadowColor">@color/cth_window_text_shadow</item>
<item name="android:textColor">@color/cth_window_text</item>
<item name="android:textColorSecondary">@color/cth_window_text</item>
<item name="textColorAlertDialogListItem">@color/cth_window_text</item>
</style>

<style name="FloatingToolbarTitle" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
<!--Any text styling can be done here-->
<item name="android:gravity">center</item>
</style>

<style name="FloatingDialogActionBar" parent="Widget.AppCompat.Toolbar">
<item name="android:titleTextStyle">@style/FloatingToolbarTitle</item>
</style>

<color name="background">#000000</color>
Expand Down Expand Up @@ -51,9 +134,4 @@
<style name="activated" parent="Theme.AppTheme">
<item name="android:background">?android:attr/activatedBackgroundIndicator</item>
</style>

<style name="Widget.Theme.AppTheme.ButtonBar.Fullscreen" parent="">
<item name="android:background">@color/black_overlay</item>
<item name="android:buttonBarStyle">?android:attr/buttonBarStyle</item>
</style>
</resources>
3 changes: 2 additions & 1 deletion res/xml/main_preferences.xml
@@ -1,4 +1,5 @@
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<Preference
app:persistent="false"
app:selectable="false"
Expand Down
26 changes: 25 additions & 1 deletion src/Java/uk/co/armedpineapple/cth/files/SaveActivity.kt
Expand Up @@ -3,18 +3,23 @@ package uk.co.armedpineapple.cth.files
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.view.MenuItem
import android.view.Window
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.setFragmentResultListener
import uk.co.armedpineapple.cth.R


/**
* An activity for loading or saving games.
*/
class SaveActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

supportRequestWindowFeature(Window.FEATURE_NO_TITLE)
setContentView(R.layout.save_activity)
setSupportActionBar(findViewById(R.id.toolbar))
val isLoad = intent.getBooleanExtra(EXTRA_IS_LOAD, false);
if (savedInstanceState == null) {
val newFragment = SaveLoadFragment.newInstance(isLoad)
Expand All @@ -32,6 +37,25 @@ class SaveActivity : AppCompatActivity() {
false -> getString(R.string.save_game)
true -> getString(R.string.load_game)
}

supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowTitleEnabled(false)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
android.R.id.home -> {
finish()
return true
}
}
return super.onOptionsItemSelected(item)
}


override fun setTitle(title: CharSequence?) {
super.setTitle(title)
(findViewById<TextView>(R.id.toolbar_title)).text = title
}

companion object {
Expand Down

0 comments on commit ac7f4a7

Please sign in to comment.