I LOVE Android View system

Rewriting Linux kernel in brainfuck is more satisfying than doing anything in Android View System

- Added preview and initial layout for calculator widget

closes #156
This commit is contained in:
Sad Ellie 2024-01-26 23:38:07 +03:00
parent 8dfb63d4a1
commit 9596488b77
7 changed files with 529 additions and 3 deletions

View File

@ -0,0 +1,375 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Unitto is a calculator for Android
~ Copyright (c) 2024 Elshan Agaev
~
~ This program 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 3 of the License, or
~ (at your option) any later version.
~
~ This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/surfaceVariant"
android:orientation="horizontal">
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/primary"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/content_copy"
android:tint="@color/onPrimary" />
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/primary"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/open_in_new"
android:tint="@color/onPrimary" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:background="@color/surfaceVariant"
android:gravity="end"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2+2"
android:textColor="@color/onSurfaceVariant"
android:textSize="36sp"
tools:ignore="HardcodedText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.5"
android:text="4"
android:textColor="@color/onSurfaceVariant"
android:textSize="36sp"
tools:ignore="HardcodedText" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/tertiaryContainer"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/clear"
android:tint="@color/onTertiaryContainer" />
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/primaryContainer"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/brackets"
android:tint="@color/onPrimaryContainer" />
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/primaryContainer"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/percent"
android:tint="@color/onPrimaryContainer" />
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/primaryContainer"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/divide"
android:tint="@color/onPrimaryContainer" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/inverseOnSurface"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/key7"
android:tint="@color/onSurfaceVariant" />
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/inverseOnSurface"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/key8"
android:tint="@color/onSurfaceVariant" />
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/inverseOnSurface"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/key9"
android:tint="@color/onSurfaceVariant" />
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/primaryContainer"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/multiply"
android:tint="@color/onPrimaryContainer" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/inverseOnSurface"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/key4"
android:tint="@color/onSurfaceVariant" />
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/inverseOnSurface"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/key5"
android:tint="@color/onSurfaceVariant" />
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/inverseOnSurface"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/key6"
android:tint="@color/onSurfaceVariant" />
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/primaryContainer"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/minus"
android:tint="@color/onPrimaryContainer" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/inverseOnSurface"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/key1"
android:tint="@color/onSurfaceVariant" />
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/inverseOnSurface"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/key2"
android:tint="@color/onSurfaceVariant" />
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/inverseOnSurface"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/key3"
android:tint="@color/onSurfaceVariant" />
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/primaryContainer"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/plus"
android:tint="@color/onPrimaryContainer" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/inverseOnSurface"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/dot"
android:tint="@color/onSurfaceVariant" />
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/inverseOnSurface"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/key0"
android:tint="@color/onSurfaceVariant" />
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/inverseOnSurface"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/backspace"
android:tint="@color/onSurfaceVariant" />
<ImageButton
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_margin="4dp"
android:layout_weight="1"
android:background="@drawable/rounded_corners_rectangle_shape"
android:backgroundTint="@color/primaryContainer"
android:importantForAccessibility="no"
android:padding="8dp"
android:scaleType="fitCenter"
android:src="@drawable/equal"
android:tint="@color/onPrimaryContainer" />
</LinearLayout>
</LinearLayout>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Unitto is a calculator for Android
~ Copyright (c) 2024 Elshan Agaev
~
~ This program 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 3 of the License, or
~ (at your option) any later version.
~
~ This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminate="true"
android:progressTint="@color/primary" />
</FrameLayout>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Unitto is a calculator for Android
~ Copyright (c) 2024 Elshan Agaev
~
~ This program 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 3 of the License, or
~ (at your option) any later version.
~
~ This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
-->
<resources>
<color name="primary">@android:color/system_primary_dark</color>
<color name="onPrimary">@android:color/system_on_primary_dark</color>
<color name="tertiaryContainer">@android:color/system_tertiary_container_dark</color>
<color name="onTertiaryContainer">@android:color/system_on_tertiary_container_dark</color>
<color name="primaryContainer">@android:color/system_primary_container_dark</color>
<color name="onPrimaryContainer">@android:color/system_on_primary_container_dark</color>
<color name="surfaceVariant">@android:color/system_surface_variant_dark</color>
<color name="onSurfaceVariant">@android:color/system_on_surface_variant_dark</color>
<color name="background">@android:color/system_background_dark</color>
<color name="inverseOnSurface">@android:color/system_surface_container_highest_dark</color>
</resources>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Unitto is a calculator for Android
~ Copyright (c) 2024 Elshan Agaev
~
~ This program 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 3 of the License, or
~ (at your option) any later version.
~
~ This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
-->
<resources>
<color name="primary">#87d991</color>
<color name="onPrimary">#003911</color>
<color name="tertiaryContainer">#1f4d54</color>
<color name="onTertiaryContainer">#bceaf3</color>
<color name="primaryContainer">#00531d</color>
<color name="onPrimaryContainer">#a3f6ab</color>
<color name="surfaceVariant">#414940</color>
<color name="onSurfaceVariant">#c1c9be</color>
<color name="background">#161616</color>
<color name="inverseOnSurface">#1a1c19</color>
</resources>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Unitto is a calculator for Android
~ Copyright (c) 2024 Elshan Agaev
~
~ This program 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 3 of the License, or
~ (at your option) any later version.
~
~ This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
-->
<resources>
<color name="primary">@android:color/system_primary_light</color>
<color name="onPrimary">@android:color/system_on_primary_light</color>
<color name="tertiaryContainer">@android:color/system_tertiary_container_light</color>
<color name="onTertiaryContainer">@android:color/system_on_tertiary_container_light</color>
<color name="primaryContainer">@android:color/system_primary_container_light</color>
<color name="onPrimaryContainer">@android:color/system_on_primary_container_light</color>
<color name="surfaceVariant">@android:color/system_surface_variant_light</color>
<color name="onSurfaceVariant">@android:color/system_on_surface_variant_light</color>
<color name="background">@android:color/system_background_light</color>
<color name="inverseOnSurface">@android:color/system_text_primary_inverse_light</color>
</resources>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Unitto is a calculator for Android
~ Copyright (c) 2024 Elshan Agaev
~
~ This program 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 3 of the License, or
~ (at your option) any later version.
~
~ This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
-->
<resources>
<color name="primary">#186c31</color>
<color name="onPrimary">#ffffff</color>
<color name="tertiaryContainer">#bceaf3</color>
<color name="onTertiaryContainer">#001f24</color>
<color name="primaryContainer">#a3f6ab</color>
<color name="onPrimaryContainer">#002107</color>
<color name="surfaceVariant">#dde5d9</color>
<color name="onSurfaceVariant">#414940</color>
<color name="background">#ffffff</color>
<color name="inverseOnSurface">#f0f1eb</color>
</resources>

View File

@ -19,11 +19,12 @@
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:description="@string/calculator_title"
android:initialLayout="@layout/glance_default_loading_layout"
android:targetCellHeight="4"
android:targetCellWidth="4"
android:initialLayout="@layout/default_initial_layout"
android:minWidth="220dp"
android:minHeight="276dp"
android:previewLayout="@layout/calculator_placeholder"
android:resizeMode="vertical|horizontal"
android:targetCellWidth="4"
android:targetCellHeight="4"
android:widgetCategory="home_screen"
tools:targetApi="s" />