Skip to content

Commit

Permalink
fix neko Icon selector
Browse files Browse the repository at this point in the history
  • Loading branch information
luvletter2333 committed Jul 10, 2022
1 parent de2d167 commit 11f055d
Show file tree
Hide file tree
Showing 21 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holderView.bind(icon);
holderView.iconView.setBackground(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(ICONS_ROUND_RADIUS), Color.TRANSPARENT, Theme.getColor(Theme.key_listSelector), Color.BLACK));
holderView.iconView.setForeground(icon.foreground);
holderView.iconView.setIsNekoXIcon(icon.isNekoX());
}

@Override
Expand Down Expand Up @@ -289,6 +290,7 @@ private void bind(LauncherIconController.LauncherIcon icon) {
}

public static class AdaptiveIconImageView extends ImageView {
private boolean isNekoXIcon = false;
private Drawable foreground;
private Path path = new Path();
private int outerPadding = AndroidUtilities.dp(5);
Expand All @@ -303,6 +305,10 @@ public void setForeground(int res) {
invalidate();
}

public void setIsNekoXIcon(boolean value) {
this.isNekoXIcon = value;
}

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
Expand All @@ -325,11 +331,12 @@ public void setBackgroundOuterPadding(int backgroundOuterPadding) {
public void draw(Canvas canvas) {
canvas.save();
canvas.clipPath(path);
canvas.scale(1f + backgroundOuterPadding / (float) getWidth(), 1f + backgroundOuterPadding / (float) getHeight(), getWidth() / 2f, getHeight() / 2f);
if (!this.isNekoXIcon)
canvas.scale(1f + backgroundOuterPadding / (float) getWidth(), 1f + backgroundOuterPadding / (float) getHeight(), getWidth() / 2f, getHeight() / 2f);
super.draw(canvas);
canvas.restore();

if (foreground != null) {
if (foreground != null && !this.isNekoXIcon) {
foreground.setBounds(-outerPadding, -outerPadding, getWidth() + outerPadding, getHeight() + outerPadding);
foreground.draw(canvas);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ public AppIconBulletinLayout(@NonNull Context context, LauncherIconController.La
textView.setTypeface(Typeface.SANS_SERIF);
addView(textView, LayoutHelper.createFrameRelatively(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL, 56, 0, 16, 0));

// NekoX: try to fix NekoX icon
imageView.setImageDrawable(ContextCompat.getDrawable(context, icon.background));
imageView.setOuterPadding(AndroidUtilities.dp(8));
imageView.setBackgroundOuterPadding(AndroidUtilities.dp(24));
imageView.setForeground(icon.foreground);
imageView.setIsNekoXIcon(icon.isNekoX());
textView.setText(AndroidUtilities.replaceTags(LocaleController.formatString(R.string.AppIconChangedTo, LocaleController.getString(icon.title))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private AdaptiveIconImageView newIconView(Context ctx, int i) {
AdaptiveIconImageView iconImageView = new AdaptiveIconImageView(ctx, i);
iconImageView.setLayoutParams(LayoutHelper.createFrame(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER, 0, 52, 0, 0));
iconImageView.setForeground(icon.foreground);
iconImageView.setIsNekoXIcon(icon.isNekoX());
iconImageView.setBackgroundResource(icon.background);
iconImageView.setPadding(AndroidUtilities.dp(8));
iconImageView.setBackgroundOuterPadding(AndroidUtilities.dp(32));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public static void setIcon(LauncherIcon icon) {
}

public enum LauncherIcon {
DEFAULT("DefaultIcon", R.drawable.icon_background_sa, R.mipmap.icon_foreground_sa, R.string.AppIconDefault),
DEFAULT("DefaultIcon", R.drawable.ic_launcher_foreground, R.mipmap.ic_launcher, R.string.AppIconDefault),
VINTAGE("VintageIcon", R.drawable.icon_6_background_sa, R.mipmap.icon_6_foreground_sa, R.string.AppIconVintage),
AQUA("AquaIcon", R.drawable.icon_4_background_sa, R.mipmap.icon_foreground_sa, R.string.AppIconAqua),
PREMIUM("PremiumIcon", R.drawable.icon_3_background_sa, R.mipmap.icon_3_foreground_sa, R.string.AppIconPremium, true),
TURBO("TurboIcon", R.drawable.icon_5_background_sa, R.mipmap.icon_5_foreground_sa, R.string.AppIconTurbo, true),
NOX("NoxIcon", R.drawable.icon_2_background_sa, R.mipmap.icon_foreground_sa, R.string.AppIconNox, true);
PREMIUM("PremiumIcon", R.drawable.icon_3_background_sa, R.mipmap.icon_3_foreground_sa, R.string.AppIconPremium),
TURBO("TurboIcon", R.drawable.icon_5_background_sa, R.mipmap.icon_5_foreground_sa, R.string.AppIconTurbo),
NOX("NoxIcon", R.drawable.icon_2_background_sa, R.mipmap.icon_foreground_sa, R.string.AppIconNox);

public final String key;
public final int background;
Expand Down Expand Up @@ -67,5 +67,9 @@ public ComponentName getComponentName(Context ctx) {
this.title = title;
this.premium = premium;
}

public boolean isNekoX() {
return this == DEFAULT;
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/icon_2_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<foreground android:drawable="@mipmap/icon_foreground" />
</adaptive-icon>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/icon_2_background_round" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<foreground android:drawable="@mipmap/icon_foreground_round" />
</adaptive-icon>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/icon_4_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<foreground android:drawable="@mipmap/icon_foreground" />
</adaptive-icon>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/icon_4_background_round" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<foreground android:drawable="@mipmap/icon_foreground_round" />
</adaptive-icon>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 11f055d

Please sign in to comment.