134 lines
4.7 KiB
Java
134 lines
4.7 KiB
Java
package com.keypalette.theme.activity;
|
|
|
|
import static com.bumptech.glide.request.RequestOptions.bitmapTransform;
|
|
|
|
import android.graphics.Rect;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewTreeObserver;
|
|
import android.view.WindowManager;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
import com.bumptech.glide.Glide;
|
|
import com.bumptech.glide.load.DataSource;
|
|
import com.bumptech.glide.load.engine.GlideException;
|
|
import com.bumptech.glide.request.RequestListener;
|
|
import com.bumptech.glide.request.target.Target;
|
|
import com.keypalette.theme.databinding.PageSuccessBinding;
|
|
import com.keypalette.theme.other.ResName;
|
|
import com.keypalette.theme.other.Helper;
|
|
import com.keypalette.theme.other.SpSkins;
|
|
|
|
import jp.wasabeef.glide.transformations.BlurTransformation;
|
|
|
|
;
|
|
|
|
|
|
public class PageSuccess extends AppCompatActivity {
|
|
private PageSuccessBinding vb;
|
|
public static String key_name = "key_name";
|
|
private int mPreviousKeyboardHeight = -1;
|
|
|
|
|
|
@Override
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
Helper.INSTANCE.initFullScreen(this,true);
|
|
vb = PageSuccessBinding.inflate(getLayoutInflater());
|
|
setContentView(vb.getRoot());
|
|
;
|
|
onInit();
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onInit() {
|
|
|
|
String stringExtra = getIntent().getStringExtra(key_name);
|
|
vb.title.setText(stringExtra);
|
|
|
|
String curPath = SpSkins.INSTANCE.getSkinPath();
|
|
|
|
vb.idBack.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
finish();
|
|
}
|
|
});
|
|
if (curPath == null) {
|
|
return;
|
|
}
|
|
|
|
String bgPath = curPath+"res/drawable-xxhdpi-v4/"+ ResName.previewBg;
|
|
|
|
Drawable bgDraw = Helper.INSTANCE.getBgDrawable(this, bgPath);
|
|
if (bgDraw != null) {
|
|
|
|
Glide.with(this)
|
|
.load(bgDraw)
|
|
.apply(bitmapTransform(new BlurTransformation(15, 3))) // 设置模糊半径和模糊采样
|
|
.listener(new RequestListener<Drawable>() {
|
|
@Override
|
|
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean onResourceReady(@NonNull Drawable resource, @NonNull Object model, Target<Drawable> target, @NonNull DataSource dataSource, boolean isFirstResource) {
|
|
vb.relayout.setBackground(resource);
|
|
// new Thread(new Runnable() {
|
|
// @Override
|
|
// public void run() {
|
|
// String s = getCacheDir() + "/test.jpg";
|
|
// File file = new File(s);
|
|
// try {
|
|
// DownloadSkinManager.saveDrawableToFile(resource,file);
|
|
// } catch (IOException e) {
|
|
//
|
|
// }
|
|
// }
|
|
// }).start();
|
|
return false;
|
|
}
|
|
})
|
|
.preload();
|
|
|
|
}
|
|
keyboardheight();
|
|
vb.et.requestFocus();
|
|
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
private void keyboardheight() {
|
|
final View rootView = getWindow().getDecorView();
|
|
rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
|
|
|
|
@Override
|
|
public void onGlobalLayout() {
|
|
Rect r = new Rect();
|
|
rootView.getWindowVisibleDisplayFrame(r);
|
|
int screenHeight = rootView.getRootView().getHeight();
|
|
int keypadHeight = screenHeight - r.bottom;
|
|
|
|
if (keypadHeight != mPreviousKeyboardHeight) {
|
|
if (mPreviousKeyboardHeight < keypadHeight) {
|
|
mPreviousKeyboardHeight = keypadHeight;
|
|
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) vb.et.getLayoutParams();
|
|
params.bottomMargin = mPreviousKeyboardHeight;
|
|
vb.et.setLayoutParams(params);
|
|
}
|
|
|
|
}
|
|
}
|
|
});
|
|
}
|
|
} |