Fixed compatibility issues in v21 with vector drawables (See https://issuetracker.google.com/issues/37074370 )

This commit is contained in:
Christopher Beckmann 2020-10-09 15:46:30 +02:00
parent fddcc6961a
commit ce071e2c2e
17 changed files with 36 additions and 352 deletions

View file

@ -197,11 +197,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
} else { } else {
difficultyBar.setRating(GameDifficulty.getValidDifficultyList().indexOf(lastChosenDifficulty) + 1); difficultyBar.setRating(GameDifficulty.getValidDifficultyList().indexOf(lastChosenDifficulty) + 1);
} }
/*LayerDrawable stars = (LayerDrawable)difficultyBar.getProgressDrawable();
stars.getDrawable(2).setColorFilter(getResources().getColor(R.color.colorPrimary), PorterDuff.Mode.SRC_ATOP);//Color for Stars fully selected
stars.getDrawable(1).setColorFilter(getResources().getColor(R.color.middleblue), PorterDuff.Mode.SRC_ATOP);//Color for Stars partially selected
stars.getDrawable(0).setColorFilter(getResources().getColor(R.color.lightblue), PorterDuff.Mode.SRC_ATOP);//color for stars not selected
*/
// on first create always check for loadable levels! // on first create always check for loadable levels!
SharedPreferences.Editor editor = settings.edit(); SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("savesChanged", true); editor.putBoolean("savesChanged", true);

View file

@ -1,34 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background"> <item android:id="@android:id/background">
<bitmap <bitmap
android:src="@drawable/ic_star_black_48dp" android:src="@drawable/ic_star_black_48dp"
android:tint="?attr/rankingStarNotSelected" /> android:tint="@color/middlegrey" />
</item>
<item android:id="@android:id/secondaryProgress">
<bitmap
android:src="@drawable/ic_star_half_black_48dp"
android:tint="?attr/rankingStarNotSelected" />
</item> </item>
<item android:id="@android:id/progress"> <item android:id="@android:id/progress">
<bitmap <bitmap
android:src="@drawable/ic_star_black_48dp" android:src="@drawable/ic_star_black_48dp"
android:tint="?attr/colorAccent" /> android:tint="@color/colorAccent" />
</item> </item>
</layer-list> </layer-list>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="37dp" android:width="38dp"
android:height="37dp" android:height="38dp"
android:viewportWidth="24.0" android:viewportWidth="24.0"
android:viewportHeight="24.0"> android:viewportHeight="24.0">
<path <path

View file

@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="37dp" android:width="38dp"
android:height="37dp" android:height="38dp"
android:viewportWidth="24.0" android:viewportWidth="24.0"
android:viewportHeight="24.0"> android:viewportHeight="24.0">
<path <path

Binary file not shown.

After

Width:  |  Height:  |  Size: 668 B

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="72dp"
android:height="72dp"
android:viewportWidth="72"
android:viewportHeight="72">
<path
android:fillColor="?attr/standardVectorGraphic"
android:name="Color Fill 1"
android:pathData="m36 8 8 18 21 2 -16 14 5 20 -18 -10 -18 10 5 -20 -16 -14 21 -2 8 -18z" />
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="54dp"
android:height="54dp"
android:viewportWidth="54"
android:viewportHeight="54">
<path
android:fillColor="?attr/rankingStarSelected"
android:name="Color Fill 1"
android:pathData="m27 39 13 7 -3 -15 11 -10 -15 -1 -6 -13 -6 13 -15 1 11 10 -3 15 13 -7z" />
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="72dp"
android:height="72dp"
android:viewportWidth="72"
android:viewportHeight="72">
<path
android:fillColor="?attr/standardVectorGraphic"
android:name="Color Fill 1"
android:pathData="m36 53v-43l-8 18l-21 1l16 15l-5 20l18 -11z" />
</vector>

View file

@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item <item android:id="@android:id/background">
android:id="@android:id/background" <bitmap
android:drawable="@drawable/ic_star_grey_48dp" /> android:src="@drawable/ic_star_grey_36dp" />
<item </item>
android:id="@android:id/secondaryProgress" <item android:id="@android:id/progress">
android:drawable="@drawable/ic_star_half_black_48dp" /> <bitmap
<item android:src="@drawable/ic_star_blue_36dp" />
android:id="@android:id/progress" </item>
android:drawable="@drawable/ic_star_accent_48dp" />
</layer-list> </layer-list>

View file

@ -29,7 +29,6 @@
</androidx.appcompat.widget.Toolbar> </androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<LinearLayout <LinearLayout
@ -112,16 +111,18 @@
android:id="@+id/circleButton" android:id="@+id/circleButton"
style="@style/CheckBox" style="@style/CheckBox"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="0dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:layout_marginRight="4dp" android:layout_marginRight="4dp"
android:layout_marginBottom="1dp"
android:button="@drawable/create_game_src" android:button="@drawable/create_game_src"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="@+id/difficultyBar"
app:layout_constraintEnd_toStartOf="@+id/difficultyBar" app:layout_constraintEnd_toStartOf="@+id/difficultyBar"
app:layout_constraintHorizontal_bias="1.0" app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="@+id/difficultyBar"
app:layout_constraintVertical_bias="0.65" /> app:layout_constraintVertical_bias="0.5" />
<RatingBar <RatingBar
android:id="@+id/difficultyBar" android:id="@+id/difficultyBar"
@ -131,7 +132,7 @@
android:layout_marginStart="41dp" android:layout_marginStart="41dp"
android:layout_marginLeft="41dp" android:layout_marginLeft="41dp"
android:clickable="true" android:clickable="true"
android:numStars="3" android:numStars="4"
android:rating="1" android:rating="1"
android:stepSize="1" android:stepSize="1"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"

View file

@ -1,266 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout android:id="@+id/drawer_layout_main"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:fitsSystemWindows="true"
tools:context="tu_darmstadt.sudoku.ui.MainActivity"
android:layout_height="match_parent"
android:layout_width="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:weightSum="10"
android:id="@+id/main_content"
style="?android:buttonBarStyle"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layoutDirection="ltr"
android:layout_weight="4">
<androidx.viewpager.widget.ViewPager
android:id="@+id/scroller"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<ImageView
android:id="@+id/arrow_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_keyboard_arrow_left_black_24dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:padding="@dimen/activity_horizontal_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_centerVertical="true"
android:onClick="onClick"/>
<ImageView
android:id="@+id/arrow_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_keyboard_arrow_right_black_24dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:padding="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_centerVertical="true"
android:onClick="onClick"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@id/scroller"
android:layout_weight="6"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="tu_darmstadt.sudoku.ui.MainActivity"
android:orientation="vertical"
android:weightSum="8"
android:divider="#000"
android:baselineAligned="false"
android:gravity="center_horizontal"
style="?android:buttonBarStyle">
<TextView
android:id="@+id/difficultyText"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/difficulty_easy"
android:textSize="@dimen/main_text_difficulty"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/circleButton"
style="@style/CheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:layout_marginRight="4dp"
android:button="@drawable/create_game_src"
app:layout_constraintBottom_toBottomOf="@+id/difficultyBar"
app:layout_constraintEnd_toStartOf="@+id/difficultyBar"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/difficultyBar"
app:layout_constraintVertical_bias="0.65" />
<RatingBar
android:id="@+id/difficultyBar"
style="@style/RatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="41dp"
android:layout_marginLeft="41dp"
android:clickable="true"
android:numStars="3"
android:padding="0dp"
android:paddingTop="70dp"
android:rating="1"
android:stepSize="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<Button
android:textColor="?attr/lightestFontColor"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/main_button_padding"
android:layout_marginRight="@dimen/main_button_padding"
android:text="@string/new_game"
android:textStyle="normal"
android:textSize="@dimen/text_size"
android:id="@+id/playButton"
android:layout_gravity="center_horizontal"
android:layout_weight="2"
android:onClick="onClick"
android:capitalize="none"
android:clickable="false"
android:elevation="10dp"
android:background="@drawable/button_standalone"/>
<Button
android:textColor="?attr/lightestFontColor"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="@dimen/main_button_padding"
android:layout_marginRight="@dimen/main_button_padding"
android:text="@string/menu_continue_game"
android:textStyle="normal"
android:textSize="@dimen/text_size"
android:id="@+id/continueButton"
android:layout_gravity="center_horizontal"
android:layout_weight="2"
android:onClick="onClick"
android:capitalize="none"
android:clickable="false"
android:background="@drawable/button_standalone"/>
<!--
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:weightSum="2">
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
android:layout_marginRight="1dp"
android:text="@string/menu_highscore"
android:textStyle="normal"
android:id="@+id/highscoreButton"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:onClick="onClick"
android:capitalize="none"
android:clickable="false"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="1dp"
android:layout_marginRight="30dp"
android:text="@string/menu_settings"
android:textStyle="normal"
android:id="@+id/settingsButton"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:onClick="onClick"
android:capitalize="none"
android:clickable="false"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:weightSum="2">
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
android:layout_marginRight="1dp"
android:text="@string/menu_about"
android:textStyle="normal"
android:id="@+id/aboutButton"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:onClick="onClick"
android:capitalize="none"
android:clickable="false"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="1dp"
android:layout_marginRight="30dp"
android:text="@string/menu_help"
android:textStyle="normal"
android:id="@+id/helpButton"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:onClick="onClick"
android:capitalize="none"
android:clickable="false"/>
</LinearLayout>
-->
</LinearLayout>
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view_main"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="?attr/lightestBackGround"
app:itemTextColor="?attr/menuTextColor"
app:itemIconTint="?attr/menuTextColor"
app:menu="@menu/menu_drawer_main"
app:headerLayout="@layout/nav_header" />
</androidx.drawerlayout.widget.DrawerLayout>

View file

@ -110,33 +110,38 @@
<androidx.appcompat.widget.AppCompatCheckBox <androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/circleButton" android:id="@+id/circleButton"
style="@style/CheckBox"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="0dp"
android:layout_marginEnd="4dp" android:layout_marginTop="1dp"
android:layout_marginRight="4dp" android:layout_marginBottom="1dp"
android:layout_marginBottom="7dp"
android:button="@drawable/create_game_src" android:button="@drawable/create_game_src"
app:layout_constraintBottom_toBottomOf="@+id/difficultyBar" app:layout_constraintBottom_toBottomOf="@+id/difficultyBar"
app:layout_constraintDimensionRatio="h,1:1"
app:layout_constraintEnd_toStartOf="@+id/difficultyBar" app:layout_constraintEnd_toStartOf="@+id/difficultyBar"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/difficultyBar" app:layout_constraintTop_toTopOf="@+id/difficultyBar"
app:layout_constraintVertical_bias="0.65" /> app:layout_constraintVertical_bias="0.5" />
<RatingBar <RatingBar
android:id="@+id/difficultyBar" android:id="@+id/difficultyBar"
style="@style/RatingBar" style="@style/RatingBar"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="41dp" android:layout_marginStart="4dp"
android:layout_marginLeft="41dp" android:layout_marginLeft="4dp"
android:layout_marginTop="1dp"
android:layout_marginBottom="16dp"
android:clickable="true" android:clickable="true"
android:numStars="4" android:numStars="4"
android:rating="2" android:rating="2"
android:stepSize="1" android:stepSize="1"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toEndOf="@+id/circleButton"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.5" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<Button <Button

View file

@ -7,7 +7,6 @@
<item name="android:statusBarColor">@android:color/transparent</item> <item name="android:statusBarColor">@android:color/transparent</item>
</style> </style>
<style name="RatingBar" parent="RatingBarStyle"> <style name="RatingBar" parent="RatingBarStyle">
<item name="android:minHeight">57dp</item> <item name="android:minHeight">57dp</item>
<item name="android:maxHeight">57dp</item> <item name="android:maxHeight">57dp</item>