updated some wrappers

This commit is contained in:
gdlbo
2022-07-19 21:38:17 +03:00
parent 9f2f6d6f60
commit 3849569794
3 changed files with 12 additions and 31 deletions
@@ -30,7 +30,8 @@ public class OTADialog implements OTAHelper.OTAListener{
mActivity.runOnUiThread(() -> {
// Toast.makeText(mActivity, "Обновления найдены", Toast.LENGTH_SHORT).show();
new ModalBottomSheetWrapper(mActivity)
.setUpdateInfoView(mHelper.getNewVersionName(), mHelper.getUpdateDescription())
.setTitle(getString("newversion") + " " + mHelper.getNewVersionName())
.setUpdateInfoView(mHelper.getUpdateDescription())
.setPositiveButton(getString("updateanddownload"), () -> {
OTADownloader.downloadBuild(mHelper.getDownloadUrl());
})
@@ -1,8 +1,10 @@
package ru.vtosters.lite.ui.vkui;
import static ru.vtosters.lite.utils.Globals.*;
import static ru.vtosters.lite.utils.Globals.getString;
import static ru.vtosters.lite.utils.Themes.getTextAttr;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Typeface;
import android.view.View;
@@ -21,27 +23,19 @@ public class ModalBottomSheetWrapper{
}
public ModalBottomSheetWrapper setTitle(String title){
builder.b(title);
builder.d(title);
return this;
}
public ModalBottomSheetWrapper setUpdateInfoView(String version, String changelog){
var context = Globals.getContext();
@SuppressLint("SetTextI18n")
public ModalBottomSheetWrapper setUpdateInfoView(String changelog){
var context = getContext();
var container = new LinearLayout(context);
var title = new TextView(context);
var changelogView = new TextView(context);
container.setOrientation(LinearLayout.VERTICAL);
title.setText(getString("newversion") + " " + version);
title.setTypeface(title.getTypeface(), Typeface.BOLD);
title.setSingleLine(true);
title.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
title.setTextColor(getTextAttr());
title.setTextSize(24.0f);
container.addView(title, new LinearLayout.LayoutParams(-1, -2));
changelogView.setPadding(0, Globals.convertDpToPixel(8), 0, 0);
changelogView.setPadding(0, convertDpToPixel(8), 0, 0);
changelogView.setText(getString("changelog") + ": \n" + changelog);
changelogView.setTextColor(getTextAttr());
container.addView(changelogView, new LinearLayout.LayoutParams(-1, -2));
@@ -51,15 +45,6 @@ public class ModalBottomSheetWrapper{
return this;
}
// try to call a true function and you will understand my pain
public ModalBottomSheetWrapper setMessage(
String text
){
builder.a(text, listener -> {
});
return this;
}
public ModalBottomSheetWrapper setClickableMessage(
String text,
Runnable callback
@@ -76,11 +61,6 @@ public class ModalBottomSheetWrapper{
return this;
}
public ModalBottomSheetWrapper setSubtitle(String text){
builder.b((CharSequence) text);
return this;
}
public ModalBottomSheetWrapper setView(View view){
builder.a(view);
return this;
@@ -12,6 +12,8 @@ public class VBottomSheetBuilder{
builder.setView(content.view);
builder.setTitle(content.title);
builder.setPositiveButton(content.button.title, () -> {
// Button OnClick
new Handler(Looper.getMainLooper()).post(content.button.action);
@@ -23,13 +25,11 @@ public class VBottomSheetBuilder{
public static class VBSContent{
public String title;
@Nullable
public String subtitle;
public View view;
public VBSButton button;
public VBSContent(String title, @Nullable String subtitle, View view, VBSButton button){
public VBSContent(String title, @Nullable View view, VBSButton button){
this.title = title;
this.subtitle = subtitle;
this.view = view;
this.button = button;
}