+ theme test for testing material design stuff (because old theming is broken after upgrading to sdk-style projects)
6
src/AndroidThemeTest/AndroidManifest.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:label="@string/app_name" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true">
|
||||||
|
</application>
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
</manifest>
|
22
src/AndroidThemeTest/AndroidThemeTest.csproj
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0-android</TargetFramework>
|
||||||
|
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<ApplicationId>keepass2android.themetest</ApplicationId>
|
||||||
|
<ApplicationVersion>1</ApplicationVersion>
|
||||||
|
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="Resources\values\colors.xml" />
|
||||||
|
<None Remove="Resources\values\themes.xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.7.0.4" />
|
||||||
|
<PackageReference Include="Xamarin.AndroidX.AppCompat.AppCompatResources" Version="1.7.0.4" />
|
||||||
|
<PackageReference Include="Xamarin.AndroidX.Core" Version="1.15.0.1" />
|
||||||
|
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.12.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
72
src/AndroidThemeTest/MainActivity.cs
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
using Android.Content;
|
||||||
|
using AndroidX.AppCompat.App;
|
||||||
|
|
||||||
|
namespace AndroidThemeTest
|
||||||
|
{
|
||||||
|
public class TestActivity : AndroidX.AppCompat.App.AppCompatActivity
|
||||||
|
{
|
||||||
|
protected override void OnCreate(Bundle? savedInstanceState)
|
||||||
|
{
|
||||||
|
base.OnCreate(savedInstanceState);
|
||||||
|
|
||||||
|
// Set our view from the "main" layout resource
|
||||||
|
SetContentView(Resource.Layout.activity_main);
|
||||||
|
|
||||||
|
//FindViewById<TextView>(Resource.Id.textView).Click += MainActivity_Click;
|
||||||
|
FindViewById<Button>(Resource.Id.with_actionbar).Click += (sender, args) =>
|
||||||
|
{
|
||||||
|
Intent intent = new Intent(this, typeof(ActivityWithActionBar));
|
||||||
|
StartActivity(intent);
|
||||||
|
};
|
||||||
|
FindViewById<Button>(Resource.Id.with_blue_actionbar).Click += (sender, args) =>
|
||||||
|
{
|
||||||
|
Intent intent = new Intent(this, typeof(ActivityWithBlueActionBar));
|
||||||
|
StartActivity(intent);
|
||||||
|
};
|
||||||
|
FindViewById<Button>(Resource.Id.without_actionbar).Click += (sender, args) =>
|
||||||
|
{
|
||||||
|
Intent intent = new Intent(this, typeof(ActivityWithoutActionBar));
|
||||||
|
StartActivity(intent);
|
||||||
|
};
|
||||||
|
FindViewById<Button>(Resource.Id.theme_light).Click += (sender, args) =>
|
||||||
|
{
|
||||||
|
OnSelectTheme(AppCompatDelegate.ModeNightNo);
|
||||||
|
};
|
||||||
|
FindViewById<Button>(Resource.Id.theme_dark).Click += (sender, args) =>
|
||||||
|
{
|
||||||
|
OnSelectTheme(AppCompatDelegate.ModeNightYes);
|
||||||
|
};
|
||||||
|
FindViewById<Button>(Resource.Id.theme_auto).Click += (sender, args) =>
|
||||||
|
{
|
||||||
|
OnSelectTheme(AppCompatDelegate.ModeNightFollowSystem);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnSelectTheme(int mode)
|
||||||
|
{
|
||||||
|
AppCompatDelegate.DefaultNightMode = mode;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[Activity(Label = "@string/app_name", MainLauncher = true, Theme= "@style/Kp2aTheme_ActionBar")]
|
||||||
|
public class ActivityWithActionBar : TestActivity
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Activity(Label = "@string/app_name", Theme = "@style/Kp2aTheme_BlueActionBar")]
|
||||||
|
public class ActivityWithBlueActionBar : TestActivity
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Activity(Label = "@string/app_name", Theme = "@style/Kp2aTheme_NoActionBar")]
|
||||||
|
public class ActivityWithoutActionBar : TestActivity
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
44
src/AndroidThemeTest/Resources/AboutResources.txt
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
Images, layout descriptions, binary blobs and string dictionaries can be included
|
||||||
|
in your application as resource files. Various Android APIs are designed to
|
||||||
|
operate on the resource IDs instead of dealing with images, strings or binary blobs
|
||||||
|
directly.
|
||||||
|
|
||||||
|
For example, a sample Android app that contains a user interface layout (main.xml),
|
||||||
|
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
|
||||||
|
would keep its resources in the "Resources" directory of the application:
|
||||||
|
|
||||||
|
Resources/
|
||||||
|
drawable/
|
||||||
|
icon.png
|
||||||
|
|
||||||
|
layout/
|
||||||
|
main.xml
|
||||||
|
|
||||||
|
values/
|
||||||
|
strings.xml
|
||||||
|
|
||||||
|
In order to get the build system to recognize Android resources, set the build action to
|
||||||
|
"AndroidResource". The native Android APIs do not operate directly with filenames, but
|
||||||
|
instead operate on resource IDs. When you compile an Android application that uses resources,
|
||||||
|
the build system will package the resources for distribution and generate a class called "Resource"
|
||||||
|
(this is an Android convention) that contains the tokens for each one of the resources
|
||||||
|
included. For example, for the above Resources layout, this is what the Resource class would expose:
|
||||||
|
|
||||||
|
public class Resource {
|
||||||
|
public class Drawable {
|
||||||
|
public const int icon = 0x123;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Layout {
|
||||||
|
public const int main = 0x456;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Strings {
|
||||||
|
public const int first_string = 0xabc;
|
||||||
|
public const int second_string = 0xbcd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
You would then use Resource.Drawable.icon to reference the drawable/icon.png file, or
|
||||||
|
Resource.Layout.main to reference the layout/main.xml file, or Resource.Strings.first_string
|
||||||
|
to reference the first string in the dictionary file values/strings.xml.
|
44
src/AndroidThemeTest/Resources/layout/activity_main.xml
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
|
||||||
|
android:text="@string/app_text"
|
||||||
|
/>
|
||||||
|
<com.google.android.material.button.MaterialButton android:id="@+id/with_actionbar" android:text="with actionbar" android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
<com.google.android.material.button.MaterialButton android:id="@+id/with_blue_actionbar" android:text="with blue actionbar" android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
<com.google.android.material.button.MaterialButton android:id="@+id/without_actionbar" android:text="without actionbar" android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton style="?attr/materialButtonOutlinedStyle" android:id="@+id/theme_light" android:text="light" android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
<com.google.android.material.button.MaterialButton style="?attr/materialButtonOutlinedStyle" android:id="@+id/theme_dark" android:text="dark" android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
<com.google.android.material.button.MaterialButton style="?attr/materialButtonOutlinedStyle" android:id="@+id/theme_auto" android:text="auto" android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/contained_btn_w_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:insetTop="0dp"
|
||||||
|
android:insetBottom="0dp"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="Contained Button W Icon"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
app:icon="@mipmap/appicon_foreground"
|
||||||
|
app:iconGravity="top"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@@ -0,0 +1,4 @@
|
|||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@mipmap/appicon_background" />
|
||||||
|
<foreground android:drawable="@mipmap/appicon_foreground" />
|
||||||
|
</adaptive-icon>
|
@@ -0,0 +1,4 @@
|
|||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@mipmap/appicon_background" />
|
||||||
|
<foreground android:drawable="@mipmap/appicon_foreground" />
|
||||||
|
</adaptive-icon>
|
BIN
src/AndroidThemeTest/Resources/mipmap-hdpi/appicon.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 97 B |
After Width: | Height: | Size: 1.2 KiB |
BIN
src/AndroidThemeTest/Resources/mipmap-mdpi/appicon.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 92 B |
After Width: | Height: | Size: 1.2 KiB |
BIN
src/AndroidThemeTest/Resources/mipmap-xhdpi/appicon.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 100 B |
After Width: | Height: | Size: 1.8 KiB |
BIN
src/AndroidThemeTest/Resources/mipmap-xxhdpi/appicon.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 108 B |
After Width: | Height: | Size: 1.9 KiB |
BIN
src/AndroidThemeTest/Resources/mipmap-xxxhdpi/appicon.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
After Width: | Height: | Size: 117 B |
After Width: | Height: | Size: 2.7 KiB |
29
src/AndroidThemeTest/Resources/values/colors.xml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="ic_launcher_background">#2C3E50</color>
|
||||||
|
|
||||||
|
<color name="bgColorLight">#fff</color>
|
||||||
|
<color name="bgColorDark">#0000</color>
|
||||||
|
|
||||||
|
<color name="appPrimaryColor">#8bc34a</color>
|
||||||
|
<color name="appPrimaryDarkColor">#548a2e</color>
|
||||||
|
<color name="appAccentColor">#0277bd</color>
|
||||||
|
<color name="appAccentColorDark">#015080</color>
|
||||||
|
|
||||||
|
<color name="blue_highlight">#0000dd</color>
|
||||||
|
<color name="group">#333333</color>
|
||||||
|
<color name="icon_background">#00555555</color>
|
||||||
|
<color name="icon_text">#000000</color>
|
||||||
|
<color name="light_gray">#a8a8a8</color>
|
||||||
|
<color name="dark_gray">#303030</color>
|
||||||
|
|
||||||
|
<color name="element_being_moved">#a8a8a8</color>
|
||||||
|
|
||||||
|
<color name="emphasis">#31b6e7</color>
|
||||||
|
<color name="emphasis2">#4f7a8a</color>
|
||||||
|
|
||||||
|
<color name="warning_color">#f4511e</color>
|
||||||
|
<color name="hint_color">#42000000</color>
|
||||||
|
<color name="success_color">#009688</color>
|
||||||
|
|
||||||
|
</resources>
|
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="ic_launcher_background">#2C3E50</color>
|
||||||
|
</resources>
|
4
src/AndroidThemeTest/Resources/values/strings.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">AndroidThemeTest</string>
|
||||||
|
<string name="app_text">Hello, Android!</string>
|
||||||
|
</resources>
|
84
src/AndroidThemeTest/Resources/values/themes.xml
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file is based on Keepassdroid, Copyright Brian Pellin.
|
||||||
|
|
||||||
|
Keepass2Android is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Keepass2Android is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<style name="Kp2aTheme_ActionBar" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||||
|
<!--<item name="android:windowNoTitle">true</item>
|
||||||
|
<item name="windowActionBar">true</item>-->
|
||||||
|
<item name="colorPrimary">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorPrimaryDark">@color/appPrimaryDarkColor</item>
|
||||||
|
<item name="colorAccent">@color/appAccentColor</item>
|
||||||
|
<item name="colorSurface">@color/appPrimaryColor</item>
|
||||||
|
|
||||||
|
<item name="colorPrimaryInverse">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorPrimaryContainer">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorOnPrimaryContainer">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorSecondaryContainer">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorOnSecondaryContainer">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorTertiary">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorOnTertiary">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorTertiaryContainer">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorOnTertiaryContainer">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorSurfaceVariant">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorOnSurfaceVariant">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorSurfaceInverse">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorOnSurfaceInverse">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorOutline">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorErrorContainer">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorOnErrorContainer">@color/appPrimaryColor</item>
|
||||||
|
<item name="textAppearanceDisplayLarge">@style/TextAppearance.Material3.DisplayLarge</item>
|
||||||
|
<item name="textAppearanceDisplayMedium">@style/TextAppearance.Material3.DisplayMedium</item>
|
||||||
|
<item name="textAppearanceDisplaySmall">@style/TextAppearance.Material3.DisplaySmall</item>
|
||||||
|
<item name="textAppearanceHeadlineLarge">@style/TextAppearance.Material3.HeadlineLarge</item>
|
||||||
|
<item name="textAppearanceHeadlineMedium">@style/TextAppearance.Material3.HeadlineMedium</item>
|
||||||
|
<item name="textAppearanceHeadlineSmall">@style/TextAppearance.Material3.HeadlineSmall</item>
|
||||||
|
<item name="textAppearanceTitleLarge">@style/TextAppearance.Material3.TitleLarge</item>
|
||||||
|
<item name="textAppearanceTitleMedium">@style/TextAppearance.Material3.TitleMedium</item>
|
||||||
|
<item name="textAppearanceTitleSmall">@style/TextAppearance.Material3.TitleSmall</item>
|
||||||
|
<item name="textAppearanceBodyLarge">@style/TextAppearance.Material3.BodyLarge</item>
|
||||||
|
<item name="textAppearanceBodyMedium">@style/TextAppearance.Material3.BodyMedium</item>
|
||||||
|
<item name="textAppearanceBodySmall">@style/TextAppearance.Material3.BodySmall</item>
|
||||||
|
<item name="textAppearanceLabelLarge">@style/TextAppearance.Material3.LabelLarge</item>
|
||||||
|
<item name="textAppearanceLabelMedium">@style/TextAppearance.Material3.LabelMedium</item>
|
||||||
|
<item name="textAppearanceLabelSmall">@style/TextAppearance.Material3.LabelSmall</item>
|
||||||
|
<item name="shapeAppearanceSmallComponent">@style/ShapeAppearance.Material3.SmallComponent</item>
|
||||||
|
<item name="shapeAppearanceMediumComponent">@style/ShapeAppearance.Material3.MediumComponent</item>
|
||||||
|
<item name="shapeAppearanceLargeComponent">@style/ShapeAppearance.Material3.LargeComponent</item>
|
||||||
|
|
||||||
|
</style>
|
||||||
|
<style name="Kp2aTheme_NoActionBar" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||||
|
<item name="windowActionBar">false</item>
|
||||||
|
<item name="windowNoTitle">true</item>
|
||||||
|
<item name="colorPrimary">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorPrimaryDark">@color/appPrimaryDarkColor</item>
|
||||||
|
<item name="colorAccent">@color/appAccentColor</item>
|
||||||
|
|
||||||
|
|
||||||
|
</style>
|
||||||
|
<style name="Kp2aTheme_BlueActionBar" parent="Kp2aTheme_ActionBar">
|
||||||
|
<item name="colorPrimary">@color/appAccentColor</item>
|
||||||
|
<item name="colorPrimaryDark">@color/appAccentColorDark</item>
|
||||||
|
<item name="colorAccent">@color/appPrimaryColor</item>
|
||||||
|
<item name="colorSurface">@color/appAccentColor</item>
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</resources>
|