Skip to content

Commit

Permalink
visual changes
Browse files Browse the repository at this point in the history
new md3 style slider
less color from image in MainActivity
  • Loading branch information
Steve-Mr committed Apr 12, 2024
1 parent dd91bed commit 1e1866c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
3 changes: 1 addition & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

// implementation 'com.hoko:hoko-blur:1.3.5'
implementation 'io.github.hokofly:hoko-blur:1.5.3'
implementation 'com.google.android.material:material:1.11.0'
implementation 'com.google.android.material:material:1.12.0-rc01'

implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.7.0"
Expand Down
34 changes: 16 additions & 18 deletions app/src/main/java/com/maary/shareas/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
Expand Down Expand Up @@ -89,6 +91,7 @@ public class MainActivity extends AppCompatActivity {
int device_height, device_width;

Palette.Swatch vibrant;
Palette.Swatch darkVibrant;
Palette.Swatch dominant;
Palette.Swatch muted ;

Expand Down Expand Up @@ -230,15 +233,14 @@ protected void onCreate(Bundle savedInstanceState) {
vibrant = palette.getVibrantSwatch();
muted = palette.getMutedSwatch();
dominant = palette.getDominantSwatch();
darkVibrant = palette.getDarkVibrantSwatch();


if (vibrant != null) {
fab.setBackgroundTintList(ColorStateList.valueOf(vibrant.getRgb()));
} else {
fab.setBackgroundColor(palette.getVibrantColor(getColor(R.color.colorAccent)));
}
if (muted != null) {
bottomAppBar.setBackgroundTint(ColorStateList.valueOf(muted.getRgb()));
}


});
Expand Down Expand Up @@ -298,21 +300,22 @@ public void onColorsChanged(@Nullable WallpaperColors colors, int which) {
// 获取 Drawable 对象
Drawable drawable = AppCompatResources.getDrawable(this, R.drawable.dialog_background);

// 复制 Drawable 对象,以便进行修改
assert drawable != null;
Drawable modifiedDrawable = drawable.getConstantState().newDrawable().mutate();
modifiedDrawable.setTint(muted.getRgb());
Drawable modifiedDrawable = Objects.requireNonNull(drawable.getConstantState()).newDrawable().mutate();
// 复制 Drawable 对象,以便进行修改
int currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
switch (currentNightMode) {
case Configuration.UI_MODE_NIGHT_NO:
modifiedDrawable.setTint(Color.WHITE);
break;
case Configuration.UI_MODE_NIGHT_YES:
modifiedDrawable.setTint(Color.BLACK);
break;
}

dialog.getWindow().setBackgroundDrawable(modifiedDrawable);
dialog.show();

TextView title_blur_view = dialog.findViewById(R.id.title_blur);
TextView title_brightness_view = dialog.findViewById(R.id.title_brightness);
assert title_blur_view != null;
title_blur_view.setTextColor(muted.getBodyTextColor());
assert title_brightness_view != null;
title_brightness_view.setTextColor(muted.getBodyTextColor());

Slider sliderBlur = dialog.findViewById(R.id.dialog_slider_blur);
assert sliderBlur != null;
sliderBlur.setLabelBehavior(LABEL_GONE);
Expand All @@ -336,15 +339,10 @@ public void onColorsChanged(@Nullable WallpaperColors colors, int which) {
sliderBrightness.setTrackActiveTintList(ColorStateList.valueOf(vibrant.getRgb()));
}

dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(muted.getTitleTextColor());
dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(muted.getTitleTextColor());
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(muted.getTitleTextColor());

chipLock.setChecked(applyEditToLock);
chipHome.setChecked(applyEditToHome);

chipLock.setOnCheckedChangeListener((buttonView, isChecked) -> applyEditToLock = isChecked);

chipHome.setOnCheckedChangeListener((buttonView, isChecked) -> applyEditToHome = isChecked);

sliderBlur.setValueFrom(0);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/layout_dialog_adjustment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
android:padding="8dp"
android:text="@string/blur"
android:textStyle="bold"
android:textColor="?attr/colorOnSurface"
android:textSize="24sp"
/>

Expand All @@ -37,6 +38,7 @@
app:layout_constraintStart_toStartOf="parent"
android:padding="8dp"
android:text="@string/brightness"
android:textColor="?attr/colorOnSurface"
android:textStyle="bold"
android:textSize="24sp"
/>
Expand Down

0 comments on commit 1e1866c

Please sign in to comment.