Skip to content

Commit

Permalink
Use vector drawables
Browse files Browse the repository at this point in the history
closes #88
  • Loading branch information
eltos committed Jul 31, 2023
1 parent 2c82864 commit 5a15e9d
Show file tree
Hide file tree
Showing 31 changed files with 64 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,14 @@ private void update() {

switch (mStyle) {
case CHECK:
mCheckView.setImageResource(R.drawable.ic_check_white);
mCheckView.setImageResource(R.drawable.ic_check);
mCheckView.setColorFilter(isColorDark(mColor) ? Color.WHITE : Color.BLACK);
mColorView.setVisibility(VISIBLE);
mRippleView.setForeground(createRippleDrawable(getDarkRippleColor(mColor)));
break;

case PALETTE:
mCheckView.setImageResource(mColor != NONE ? R.drawable.ic_palette_white :
R.drawable.ic_palette_color);
mCheckView.setImageResource(R.drawable.ic_palette_color);
mCheckView.setVisibility(VISIBLE);
mDarkRippleDrawable = createRippleDrawable(getDarkRippleColor(mColor));
mLightRippleDrawable = createRippleDrawable(getLightRippleColor(mColor));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.graphics.drawable.Drawable;
import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;
import androidx.core.content.res.ResourcesCompat;
import com.google.android.material.textfield.MaterialAutoCompleteTextView;
import android.text.Editable;
import android.text.TextWatcher;
Expand Down Expand Up @@ -176,8 +177,7 @@ private void init(Context context, @Nullable AttributeSet attrs) {
}

if (xD == null){
//noinspection deprecation
xD = getResources().getDrawable(R.drawable.ic_clear_search);
xD = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_clear_search, context.getTheme());
}
if (xD != null) {
xD.setBounds(0, 0, xD.getIntrinsicWidth(), xD.getIntrinsicHeight());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z"/>
<path
android:fillColor="#000"
android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorAccent">
<path
android:fillColor="@android:color/white"
android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z"/>
<path
android:fillColor="#000"
android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z"/>
</vector>
10 changes: 10 additions & 0 deletions simpledialogfragments/src/main/res/drawable-anydpi/ic_check.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal" >
<path
android:fillColor="#000"
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="#000"
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,3c-4.97,0 -9,4.03 -9,9s4.03,9 9,9c0.83,0 1.5,-0.67 1.5,-1.5 0,-0.39 -0.15,-0.74 -0.39,-1.01 -0.23,-0.26 -0.38,-0.61 -0.38,-0.99 0,-0.83 0.67,-1.5 1.5,-1.5L16,16c2.76,0 5,-2.24 5,-5 0,-4.42 -4.03,-8 -9,-8zM6.5,12c-0.83,0 -1.5,-0.67 -1.5,-1.5S5.67,9 6.5,9 8,9.67 8,10.5 7.33,12 6.5,12zM9.5,8C8.67,8 8,7.33 8,6.5S8.67,5 9.5,5s1.5,0.67 1.5,1.5S10.33,8 9.5,8zM14.5,8c-0.83,0 -1.5,-0.67 -1.5,-1.5S13.67,5 14.5,5s1.5,0.67 1.5,1.5S15.33,8 14.5,8zM17.5,12c-0.83,0 -1.5,-0.67 -1.5,-1.5S16.67,9 17.5,9s1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5z">
<aapt:attr name="android:fillColor">
<gradient android:type="linear"
android:startX="6" android:startY="6"
android:endX="18" android:endY="14">

<!-- Edit this gradient at https://eltos.github.io/gradient/#7C419F-1DAEC2-94C81D-FFE001-FE742C -->
<item android:offset="0.000" android:color="#7C419F" />
<item android:offset="0.250" android:color="#1DAEC2" />
<item android:offset="0.500" android:color="#94C81D" />
<item android:offset="0.750" android:color="#FFE001" />
<item android:offset="1.000" android:color="#FE742C" />

</gradient>
</aapt:attr>
</path>
</vector>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
android:layout_gravity="center"
android:scaleType="fitCenter"
android:visibility="invisible"
android:src="@drawable/ic_check_white" />
android:src="@drawable/ic_check" />

</FrameLayout>
11 changes: 9 additions & 2 deletions testApp/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorSecondary">@color/colorAccent</item>

<!-- Optional custom theme
<!-- Default dialog themes
- @style/SimpleDialogTheme.AppCompat (for app theme Theme.AppCompat.DayNight)
- @style/SimpleDialogTheme.MaterialComponents (for app theme Theme.MaterialComponents.DayNight)
- @style/SimpleDialogTheme.Material3 (for app theme Theme.Material3.DayNight)
-->
<item name="simpleDialogTheme">@style/SimpleDialogTheme.Material3</item>

<!-- Custom dialog themes
- simpleDialogTheme applies to simple dialogs only
- alertDialogTheme applies to all dialogs (including simple dialogs)
- imageDialogTheme applies to image dialogs only
-->
<item name="simpleDialogTheme">@style/MyDialogTheme.Material3</item>
<!--<item name="simpleDialogTheme">@style/MyDialogTheme.Material3</item>-->
<!--<item name="alertDialogTheme">@style/MyDialogTheme.MaterialComponents</item>-->
<!--<item name="imageDialogTheme">@style/MyImageDialogTheme</item>-->
</style>
Expand Down

0 comments on commit 5a15e9d

Please sign in to comment.