refactored vk alert dialog and imagine array adapter
This commit is contained in:
@@ -18,7 +18,6 @@ import java.io.File;
|
||||
import b.h.g.m.FileUtils;
|
||||
import ru.vtosters.lite.ui.activities.APKInstallActivity;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class OTADownloader {
|
||||
|
||||
@@ -73,17 +72,21 @@ public class OTADownloader {
|
||||
manager.enqueue(request);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
VkAlertDialog.Builder alertDialog = new VkAlertDialog.Builder(context, ThemesUtils.getAlertStyle());
|
||||
alertDialog.setTitle(AndroidUtils.getString("update_error"));
|
||||
alertDialog.setMessage(AndroidUtils.getString("update_error_text"));
|
||||
alertDialog.setPositiveButton(AndroidUtils.getString("no"), (dialog, which) -> {
|
||||
dialog.cancel();
|
||||
});
|
||||
alertDialog.setNeutralButton(AndroidUtils.getString("yes"), (dialog, which) -> {
|
||||
context.startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://github.com/vtosters/lite/releases/latest/download/VTLite.apk")));
|
||||
});
|
||||
var alert = alertDialog.create();
|
||||
alert.show();
|
||||
|
||||
new VkAlertDialog.Builder(context)
|
||||
.setTitle(AndroidUtils.getString("update_error"))
|
||||
.setMessage(AndroidUtils.getString("update_error_text"))
|
||||
.setPositiveButton(AndroidUtils.getString("no"),
|
||||
(dialog, which) -> dialog.cancel()
|
||||
)
|
||||
.setNeutralButton(AndroidUtils.getString("yes"),
|
||||
(dialog, which) -> {
|
||||
var intent = new Intent(Intent.ACTION_VIEW)
|
||||
.setData(Uri.parse("https://github.com/vtosters/lite/releases/latest/download/VTLite.apk"));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,17 +112,17 @@ public class VideoDownloader {
|
||||
return;
|
||||
}
|
||||
|
||||
var builder = new VkAlertDialog.Builder(context);
|
||||
builder.setItems(max, ((dialog, which) -> {
|
||||
var url = urls.get(which);
|
||||
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
|
||||
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
||||
request.setTitle(videoFile.toString());
|
||||
request.allowScanningByMediaScanner();
|
||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_MOVIES, videoFile + ".mp4");
|
||||
((DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);
|
||||
}));
|
||||
builder.show();
|
||||
new VkAlertDialog.Builder(context)
|
||||
.setItems(max, ((dialog, which) -> {
|
||||
var url = urls.get(which);
|
||||
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
|
||||
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
||||
request.setTitle(videoFile.toString());
|
||||
request.allowScanningByMediaScanner();
|
||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_MOVIES, videoFile + ".mp4");
|
||||
((DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);
|
||||
}))
|
||||
.show();
|
||||
}
|
||||
|
||||
public static void parseVideoLink(String url, Context ctx) {
|
||||
|
||||
@@ -33,7 +33,6 @@ import java.util.regex.Pattern;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.OkHttpClient;
|
||||
import ru.vtosters.lite.net.Request;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class FoafBase {
|
||||
private static final Pattern FOAF_REGEX = Pattern.compile("<ya:created dc:date=\"(.+?)\"\\/>");
|
||||
@@ -144,8 +143,15 @@ public class FoafBase {
|
||||
matcher2.find();
|
||||
String normalHumanDate = getNormalHumanDate(Objects.requireNonNull(matcher.group(1)));
|
||||
getNormalHumanDate(Objects.requireNonNull(matcher2.group(1)));
|
||||
VkAlertDialog.Builder a2 = new VkAlertDialog.Builder(context, ThemesUtils.getAlertStyle()).setTitle(getIdentifier("addinf", "string"));
|
||||
a2.setMessage(getString("foafid") + " " + i + getString("foafregdate") + " " + normalHumanDate + getString("foafdate") + " " + daysPassedFromFoafDate(normalHumanDate)).setPositiveButton(17039370, null).create().show();
|
||||
|
||||
new VkAlertDialog.Builder(context)
|
||||
.setTitle(getIdentifier("addinf", "string"))
|
||||
.setMessage(getString("foafid") +
|
||||
" " + i + getString("foafregdate")
|
||||
+ " " + normalHumanDate + getString("foafdate")
|
||||
+ " " + daysPassedFromFoafDate(normalHumanDate))
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
makeText(getGlobalContext(), getString("foaferr"), LENGTH_SHORT).show();
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.Objects;
|
||||
|
||||
import ru.vtosters.lite.encryption.EncryptProvider;
|
||||
import ru.vtosters.lite.encryption.base.IMProcessor;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class CryptImHook {
|
||||
public static boolean isPrivateProcessor(int peerID) {
|
||||
@@ -64,7 +63,7 @@ public class CryptImHook {
|
||||
return;
|
||||
}
|
||||
|
||||
new VkAlertDialog.Builder(ctx, ThemesUtils.getAlertStyle())
|
||||
new VkAlertDialog.Builder(ctx)
|
||||
.setTitle(getString("encryption_sett"))
|
||||
.setSingleChoiceItems(titles, enabledPosition, (dialog, which) -> {
|
||||
if (which == 0) {
|
||||
@@ -82,7 +81,8 @@ public class CryptImHook {
|
||||
|
||||
dialog.dismiss();
|
||||
forceInvalidateDialogActions(d);
|
||||
}).create().show();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
public static void hookPref(int peerId) {
|
||||
@@ -129,15 +129,14 @@ public class CryptImHook {
|
||||
editText.setText(key == null ? "" : key);
|
||||
|
||||
IMProcessor finalEnabled = enabled;
|
||||
var alert = new VkAlertDialog.Builder(ctx, ThemesUtils.getAlertStyle())
|
||||
new VkAlertDialog.Builder(ctx)
|
||||
.setTitle(getString("encryption_enter_key"))
|
||||
.setMessage(String.format(getString("encryption_current_algorithm_title"), enabled.getUIName()))
|
||||
.setView(linearLayout)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
Editable edit = editText.getText();
|
||||
finalEnabled.setEncryptionKeyFor(peerId, edit == null ? null : edit.toString());
|
||||
}).setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
alert.setView(linearLayout);
|
||||
alert.show();
|
||||
.show();
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ import ru.vtosters.lite.downloaders.notifications.NotificationChannels;
|
||||
import ru.vtosters.lite.ui.dialogs.DisableBattery;
|
||||
import ru.vtosters.lite.ui.dialogs.InstallGMS;
|
||||
import ru.vtosters.lite.ui.dialogs.OTADialog;
|
||||
import ru.vtosters.lite.ui.dialogs.ServerDialog;
|
||||
import ru.vtosters.lite.ui.dialogs.Start;
|
||||
import ru.vtosters.lite.utils.DeletedMessagesHandler;
|
||||
|
||||
@@ -27,7 +26,6 @@ import ru.vtosters.lite.utils.DeletedMessagesHandler;
|
||||
public class MainActivityInjector {
|
||||
public static void inject(Activity activity) {
|
||||
setNeededTheme(activity);
|
||||
ServerDialog.activity = activity;
|
||||
sendRequest();
|
||||
if (checkupdates()) OTADialog.checkUpdates(activity);
|
||||
VkExecutors.x.f().a(DeletedMessagesHandler::reloadMessagesList); // ioScheduler
|
||||
|
||||
@@ -71,33 +71,31 @@ public class ProxyHook {
|
||||
rgRandomProxy.setChecked(isRandomProxyEnabled());
|
||||
rgVika.setChecked(isVikaProxyEnabled());
|
||||
|
||||
var builder = new VkAlertDialog.Builder(ctx, ThemesUtils.getAlertStyle());
|
||||
builder.setTitle(AndroidUtils.getString("vtlproxy"));
|
||||
builder.setMessage(AndroidUtils.getString("proxy_warning"));
|
||||
builder.setPositiveButton(AndroidUtils.getString("vtl_confirm"), ((dialog, which) -> { // Применить
|
||||
if (rgZaborona.isChecked()) {
|
||||
edit().putString("proxy", "zaborona").commit();
|
||||
restartApplication();
|
||||
} else if (rgRandomProxy.isChecked()) {
|
||||
edit().putString("proxy", "randomproxy").commit();
|
||||
restartApplication();
|
||||
} else if (rgVika.isChecked()) {
|
||||
edit().putString("proxy", "vika").commit();
|
||||
restartApplication();
|
||||
} else {
|
||||
edit().putString("proxy", "noproxy").commit();
|
||||
restartApplication();
|
||||
}
|
||||
}));
|
||||
|
||||
builder.setNeutralButton(AndroidUtils.getString("proxy_settings"), ((dialog, which) -> {
|
||||
Intent a2 = new Navigator(ProxySettingsFragment.class).b(ctx);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
ctx.startActivity(a2);
|
||||
}));
|
||||
|
||||
var alert = builder.create();
|
||||
alert.setView(rg);
|
||||
alert.show();
|
||||
new VkAlertDialog.Builder(ctx)
|
||||
.setTitle(AndroidUtils.getString("vtlproxy"))
|
||||
.setMessage(AndroidUtils.getString("proxy_warning"))
|
||||
.setView(rg)
|
||||
.setPositiveButton(AndroidUtils.getString("vtl_confirm"), ((dialog, which) -> { // Применить
|
||||
if (rgZaborona.isChecked()) {
|
||||
edit().putString("proxy", "zaborona").commit();
|
||||
restartApplication();
|
||||
} else if (rgRandomProxy.isChecked()) {
|
||||
edit().putString("proxy", "randomproxy").commit();
|
||||
restartApplication();
|
||||
} else if (rgVika.isChecked()) {
|
||||
edit().putString("proxy", "vika").commit();
|
||||
restartApplication();
|
||||
} else {
|
||||
edit().putString("proxy", "noproxy").commit();
|
||||
restartApplication();
|
||||
}
|
||||
}))
|
||||
.setNeutralButton(AndroidUtils.getString("proxy_settings"), ((dialog, which) -> {
|
||||
var intent = new Navigator(ProxySettingsFragment.class)
|
||||
.b(ctx)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
ctx.startActivity(intent);
|
||||
}))
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,6 @@ import com.vtosters.lite.ui.MaterialSwitchPreference;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class PreferencesUtil {
|
||||
|
||||
public static void addListPreference(MaterialPreferenceToolbarFragment fragment, String key, String def, CharSequence title, CharSequence[] entries, CharSequence[] entriesValue) {
|
||||
@@ -179,22 +177,19 @@ public class PreferencesUtil {
|
||||
margin.setMargins(dp2px(20f), 0, dp2px(20f), 0);
|
||||
editText.setLayoutParams(margin);
|
||||
|
||||
var builder = new VkAlertDialog.Builder(fragment.getContext(), ThemesUtils.getAlertStyle());
|
||||
builder.setTitle(title);
|
||||
builder.setPositiveButton("OK", (dialog, which) -> {
|
||||
boolean change = editTextPrefChangeListener.onChanged(preference, editText.getText().toString());
|
||||
if (!change)
|
||||
return;
|
||||
new VkAlertDialog.Builder(fragment.getContext())
|
||||
.setTitle(title)
|
||||
.setPositiveButton("OK", (dialog, which) -> {
|
||||
boolean change = editTextPrefChangeListener.onChanged(preference, editText.getText().toString());
|
||||
if (!change)
|
||||
return;
|
||||
|
||||
PreferenceManager.getDefaultSharedPreferences(getGlobalContext())
|
||||
.edit()
|
||||
.putString(key, editText.getText().toString())
|
||||
.apply();
|
||||
});
|
||||
|
||||
var alert = builder.create();
|
||||
alert.setView(linearLayout);
|
||||
alert.show();
|
||||
PreferenceManager.getDefaultSharedPreferences(getGlobalContext())
|
||||
.edit()
|
||||
.putString(key, editText.getText().toString())
|
||||
.apply();
|
||||
})
|
||||
.show();
|
||||
return false;
|
||||
}); // preference.setOnPreferenceClickListener(listener)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package ru.vtosters.lite.ui.adapters;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -15,28 +16,27 @@ import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.widget.TextViewCompat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.LayoutUtils;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class ImagineArrayAdapter extends ArrayAdapter<ImagineArrayAdapter.ImagineArrayAdapterItem> {
|
||||
|
||||
private final OnClickListener mListener;
|
||||
private List<ImagineArrayAdapterItem> mItems = new ArrayList<>();
|
||||
private int mSelectedIndex = -1;
|
||||
|
||||
public ImagineArrayAdapter(@NonNull Context context, OnClickListener listener) {
|
||||
public ImagineArrayAdapter(@NonNull Context context) {
|
||||
super(context, 0);
|
||||
this.mListener = listener;
|
||||
}
|
||||
|
||||
public ImagineArrayAdapter(@NonNull Context context, List<ImagineArrayAdapterItem> items, OnClickListener listener) {
|
||||
public ImagineArrayAdapter(@NonNull Context context, List<ImagineArrayAdapterItem> items) {
|
||||
super(context, 0, items);
|
||||
mItems = items;
|
||||
this.mListener = listener;
|
||||
}
|
||||
|
||||
public void setSelected(int i) {
|
||||
@@ -89,33 +89,26 @@ public class ImagineArrayAdapter extends ArrayAdapter<ImagineArrayAdapter.Imagin
|
||||
container.setGravity(Gravity.CENTER_VERTICAL);
|
||||
container.setPadding(0, AndroidUtils.dp2px(5.0f), 0, AndroidUtils.dp2px(5.0f));
|
||||
container.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
|
||||
container.setOnClickListener(v -> {
|
||||
if (position != mSelectedIndex) {
|
||||
mListener.onClick(position);
|
||||
}
|
||||
});
|
||||
|
||||
// if make radiobutton without layout inflation it can't be unclickable
|
||||
var checkedTextView = (CheckedTextView) LayoutInflater.from(getContext())
|
||||
.inflate(AndroidUtils.getIdentifier("select_dialog_singlechoice_material", "layout"), parent, false);
|
||||
// for amoled
|
||||
var tintList = new ColorStateList(
|
||||
new int[][] { new int[] { android.R.attr.state_checked }, new int[] { -android.R.attr.state_checked }},
|
||||
new int[] { ThemesUtils.getAccentColor(), ThemesUtils.getSTextAttr() });
|
||||
TextViewCompat.setCompoundDrawableTintList(checkedTextView, tintList);
|
||||
checkedTextView.setChecked(position == mSelectedIndex);
|
||||
container.addView(checkedTextView, LayoutUtils.createLinear(AndroidUtils.dp2px(50.0f), -2));
|
||||
|
||||
var item = mItems.get(position);
|
||||
|
||||
var imageView = new ImageView(getContext());
|
||||
imageView.setImageDrawable(item.getIcon());
|
||||
imageView.setPadding(
|
||||
AndroidUtils.dp2px(13.0f),
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
var imageViewParams = LayoutUtils.createLinear(
|
||||
AndroidUtils.dp2px(50.0f),
|
||||
AndroidUtils.dp2px(50.0f)
|
||||
);
|
||||
container.addView(imageView, imageViewParams);
|
||||
var icon = new ImageView(getContext());
|
||||
icon.setImageDrawable(item.getIcon());
|
||||
icon.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
var iconParams = LayoutUtils.createLinear(AndroidUtils.dp2px(35.0f), AndroidUtils.dp2px(35.0f));
|
||||
iconParams.leftMargin = AndroidUtils.dp2px(10);
|
||||
container.addView(icon, iconParams);
|
||||
|
||||
var textView = new CheckedTextView(getContext());
|
||||
textView.setText(item.getText());
|
||||
@@ -133,10 +126,6 @@ public class ImagineArrayAdapter extends ArrayAdapter<ImagineArrayAdapter.Imagin
|
||||
return container;
|
||||
}
|
||||
|
||||
public interface OnClickListener {
|
||||
void onClick(int i);
|
||||
}
|
||||
|
||||
public static class ImagineArrayAdapterItem {
|
||||
private final Drawable mIcon;
|
||||
private final String mText;
|
||||
|
||||
@@ -11,33 +11,30 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
|
||||
import ru.vtosters.lite.deviceinfo.OEMDetector;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class DisableBattery {
|
||||
public static void alert(Activity activity) {
|
||||
if (OEMDetector.isOEM() && Build.VERSION.SDK_INT >= 23 && getBoolValue("showDoze", true)) {
|
||||
final Context context = getGlobalContext();
|
||||
if (!((PowerManager) context.getSystemService(Context.POWER_SERVICE)).isIgnoringBatteryOptimizations(context.getPackageName())) {
|
||||
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(activity, ThemesUtils.getAlertStyle());
|
||||
builder.setTitle(getString("batteryissuetitle"));
|
||||
builder.setMessage(getString("batteryissuesumm"));
|
||||
builder.setCancelable(false);
|
||||
// android.content.DialogInterface.OnClickListener
|
||||
builder.setPositiveButton(getString("batteryissuebtn1"), (dialogInterface, i) -> {
|
||||
Intent intent = new Intent("android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("package:");
|
||||
sb.append(context.getPackageName());
|
||||
intent.setData(Uri.parse(sb.toString()));
|
||||
context.startActivity(intent);
|
||||
});
|
||||
// android.content.DialogInterface.OnClickListener
|
||||
builder.setNeutralButton(getString("batteryissuebtn2"), (dialogInterface, i) -> edit().putBoolean("showDoze", false).apply());
|
||||
builder.show();
|
||||
new VkAlertDialog.Builder(activity)
|
||||
.setTitle(getString("batteryissuetitle"))
|
||||
.setMessage(getString("batteryissuesumm"))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(getString("batteryissuebtn1"), (dialogInterface, i) -> {
|
||||
var intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
|
||||
.setData(Uri.parse("package:" + context.getPackageName()));
|
||||
context.startActivity(intent);
|
||||
})
|
||||
.setNeutralButton(getString("batteryissuebtn2"),
|
||||
(dialogInterface, i) -> edit().putBoolean("showDoze", false).apply()
|
||||
)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,33 +7,32 @@ import static ru.vtosters.lite.utils.GmsUtils.isGmsInstalled;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vk.navigation.Navigator;
|
||||
|
||||
import ru.vtosters.lite.ui.fragments.InstallGMSFragment;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class InstallGMS {
|
||||
public static void alert(final Activity activity) {
|
||||
if (!isGmsInstalled()) {
|
||||
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(activity, ThemesUtils.getAlertStyle());
|
||||
builder.setTitle(getString("warning"));
|
||||
builder.setMessage(getString("gmsissuesumm"));
|
||||
builder.setCancelable(false);
|
||||
builder.setPositiveButton(getString("gmsissuebtn1"), (dialogInterface, i) -> edit().putBoolean("showAlertGms", false).apply());
|
||||
builder.setNeutralButton(getString("gmsissuebtn2"), (dialogInterface, i) -> {
|
||||
edit().putBoolean("showAlertGms", false).apply();
|
||||
Context context = getGlobalContext();
|
||||
Intent a2 = new Navigator(InstallGMSFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
});
|
||||
if (getBoolValue("showAlertGms", true)) {
|
||||
builder.show();
|
||||
}
|
||||
if (!isGmsInstalled() && getBoolValue("showAlertGms", true)) {
|
||||
new VkAlertDialog.Builder(activity)
|
||||
.setTitle(getString("warning"))
|
||||
.setMessage(getString("gmsissuesumm"))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(getString("gmsissuebtn1"), (
|
||||
dialogInterface, i) -> edit().putBoolean("showAlertGms", false).apply()
|
||||
)
|
||||
.setNeutralButton(getString("gmsissuebtn2"), (dialogInterface, i) -> {
|
||||
edit().putBoolean("showAlertGms", false).apply();
|
||||
var context = getGlobalContext();
|
||||
var intent = new Navigator(InstallGMSFragment.class)
|
||||
.b(context)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
})
|
||||
.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ import androidx.appcompat.view.ContextThemeWrapper;
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.LayoutUtils;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class MessageSettings {
|
||||
public static Boolean isSilentEnabled = false;
|
||||
@@ -31,12 +31,12 @@ public class MessageSettings {
|
||||
rg.setOrientation(LinearLayout.VERTICAL);
|
||||
rg.setPadding(dp2px(18f), dp2px(12f), dp2px(18f), 0);
|
||||
|
||||
RadioButton zero = new RadioButton(new ContextThemeWrapper(context, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
|
||||
RadioButton one = new RadioButton(new ContextThemeWrapper(context, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
|
||||
RadioButton two = new RadioButton(new ContextThemeWrapper(context, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
|
||||
RadioButton three = new RadioButton(new ContextThemeWrapper(context, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
|
||||
RadioButton four = new RadioButton(new ContextThemeWrapper(context, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
|
||||
RadioButton five = new RadioButton(new ContextThemeWrapper(context, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
|
||||
RadioButton zero = new RadioButton(new ContextThemeWrapper(context, R.style.Widget_AppCompat_CompoundButton_RadioButton));
|
||||
RadioButton one = new RadioButton(new ContextThemeWrapper(context, R.style.Widget_AppCompat_CompoundButton_RadioButton));
|
||||
RadioButton two = new RadioButton(new ContextThemeWrapper(context, R.style.Widget_AppCompat_CompoundButton_RadioButton));
|
||||
RadioButton three = new RadioButton(new ContextThemeWrapper(context, R.style.Widget_AppCompat_CompoundButton_RadioButton));
|
||||
RadioButton four = new RadioButton(new ContextThemeWrapper(context, R.style.Widget_AppCompat_CompoundButton_RadioButton));
|
||||
RadioButton five = new RadioButton(new ContextThemeWrapper(context, R.style.Widget_AppCompat_CompoundButton_RadioButton));
|
||||
|
||||
rg.addView(zero);
|
||||
rg.addView(one);
|
||||
@@ -88,7 +88,7 @@ public class MessageSettings {
|
||||
}
|
||||
|
||||
@SuppressLint("UseSwitchCompatOrMaterialCode")
|
||||
var silentSwitch = new SwitchCompat(new ContextThemeWrapper(context, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_Switch));
|
||||
var silentSwitch = new SwitchCompat(new ContextThemeWrapper(context, R.style.Widget_AppCompat_CompoundButton_Switch));
|
||||
silentSwitch.setText(AndroidUtils.getString("silent_messages"));
|
||||
silentSwitch.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f));
|
||||
silentSwitch.setTextColor(getTextAttr());
|
||||
@@ -105,30 +105,29 @@ public class MessageSettings {
|
||||
mContainer.addView(rg, LayoutUtils.createLinear(-1, -2));
|
||||
mContainer.addView(silentSwitch, LayoutUtils.createLinear(-1, -2));
|
||||
|
||||
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(context, ThemesUtils.getAlertStyle());
|
||||
builder.setTitle(AndroidUtils.getString("message_send_settings_title"));
|
||||
builder.setMessage(AndroidUtils.getString("silent_messages_time_select"));
|
||||
builder.setCancelable(true);
|
||||
builder.setNegativeButton(AndroidUtils.getString("cancel"), null);
|
||||
builder.setView(mContainer);
|
||||
builder.setPositiveButton(AndroidUtils.getString("vtl_confirm"), (dialog, which) -> { // Применить
|
||||
var checked = rg.getCheckedRadioButtonId();
|
||||
new VkAlertDialog.Builder(context)
|
||||
.setTitle(AndroidUtils.getString("message_send_settings_title"))
|
||||
.setMessage(AndroidUtils.getString("silent_messages_time_select"))
|
||||
.setCancelable(true)
|
||||
.setView(mContainer)
|
||||
.setNegativeButton(AndroidUtils.getString("cancel"), null)
|
||||
.setPositiveButton(AndroidUtils.getString("vtl_confirm"), (dialog, which) -> { // Применить
|
||||
var checked = rg.getCheckedRadioButtonId();
|
||||
|
||||
if (checked == zero.getId()) {
|
||||
bombCount = "0";
|
||||
} else if (checked == one.getId()) {
|
||||
bombCount = "15s";
|
||||
} else if (checked == two.getId()) {
|
||||
bombCount = "1m";
|
||||
} else if (checked == three.getId()) {
|
||||
bombCount = "5m";
|
||||
} else if (checked == four.getId()) {
|
||||
bombCount = "1h";
|
||||
} else if (checked == five.getId()) {
|
||||
bombCount = "24h";
|
||||
}
|
||||
});
|
||||
|
||||
builder.show();
|
||||
if (checked == zero.getId()) {
|
||||
bombCount = "0";
|
||||
} else if (checked == one.getId()) {
|
||||
bombCount = "15s";
|
||||
} else if (checked == two.getId()) {
|
||||
bombCount = "1m";
|
||||
} else if (checked == three.getId()) {
|
||||
bombCount = "5m";
|
||||
} else if (checked == four.getId()) {
|
||||
bombCount = "1h";
|
||||
} else if (checked == five.getId()) {
|
||||
bombCount = "24h";
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.LayoutUtils;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class RoundingSeekbarDialog {
|
||||
public static void dialog(Context context) {
|
||||
@@ -26,17 +25,16 @@ public class RoundingSeekbarDialog {
|
||||
|
||||
mContainer.addView(seek, LayoutUtils.createLinear(-1, -2));
|
||||
|
||||
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(context, ThemesUtils.getAlertStyle());
|
||||
builder.setTitle(AndroidUtils.getString("pic_rounding_title"));
|
||||
builder.setMessage(AndroidUtils.getString("pic_rounding_info"));
|
||||
builder.setCancelable(true);
|
||||
builder.setNegativeButton(AndroidUtils.getString("cancel"), null);
|
||||
builder.setView(mContainer);
|
||||
builder.setPositiveButton(AndroidUtils.getString("vtl_confirm"), (dialog, which) -> {
|
||||
edit().putInt("pic_rounding", seek.getProgress()).commit();
|
||||
restartApplicationWithTimer();
|
||||
});
|
||||
|
||||
builder.show();
|
||||
new VkAlertDialog.Builder(context)
|
||||
.setTitle(AndroidUtils.getString("pic_rounding_title"))
|
||||
.setMessage(AndroidUtils.getString("pic_rounding_info"))
|
||||
.setCancelable(true)
|
||||
.setNegativeButton(AndroidUtils.getString("cancel"), null)
|
||||
.setView(mContainer)
|
||||
.setPositiveButton(AndroidUtils.getString("vtl_confirm"), (dialog, which) -> {
|
||||
edit().putInt("pic_rounding", seek.getProgress()).commit();
|
||||
restartApplicationWithTimer();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import static ru.vtosters.lite.utils.NetworkUtils.isNetworkIsSlow;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.hasVerification;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
@@ -23,12 +22,11 @@ import okhttp3.Callback;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
|
||||
public class ServerDialog {
|
||||
private static final OkHttpClient client = new OkHttpClient();
|
||||
public static Boolean showAlert;
|
||||
public static Activity activity;
|
||||
private static String title;
|
||||
private static String message;
|
||||
private static String positiveButton;
|
||||
@@ -94,20 +92,22 @@ public class ServerDialog {
|
||||
|
||||
showAlert = true;
|
||||
|
||||
if (activity != null) {
|
||||
var activity = LifecycleUtils.getCurrentActivity();
|
||||
if (activity != null && getBoolValue(key, true) && showForNotVerified() && showAlert) {
|
||||
activity.runOnUiThread(() -> {
|
||||
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(activity, ThemesUtils.getAlertStyle());
|
||||
builder.setTitle(title);
|
||||
builder.setMessage(message);
|
||||
builder.setCancelable(cancelable);
|
||||
builder.setPositiveButton(positiveButton, (dialogInterface, i) -> edit().putBoolean(key, false).apply());
|
||||
builder.setNeutralButton(neutralButton, (dialogInterface, i) -> {
|
||||
edit().putBoolean(key, false).apply();
|
||||
activity.startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse(link)));
|
||||
});
|
||||
if (getBoolValue(key, true) && showForNotVerified() && showAlert) {
|
||||
builder.show();
|
||||
}
|
||||
new VkAlertDialog.Builder(activity)
|
||||
.setTitle(title)
|
||||
.setMessage(message)
|
||||
.setCancelable(cancelable)
|
||||
.setPositiveButton(positiveButton,
|
||||
(dialogInterface, i) -> edit().putBoolean(key, false).apply())
|
||||
.setNeutralButton(neutralButton, (dialogInterface, i) -> {
|
||||
edit().putBoolean(key, false).apply();
|
||||
var intent = new Intent(Intent.ACTION_VIEW)
|
||||
.setData(Uri.parse(link));
|
||||
activity.startActivity(intent);
|
||||
})
|
||||
.show();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,27 +12,28 @@ import android.os.Build;
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
|
||||
import ru.vtosters.lite.deviceinfo.OEMDetector;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class Start {
|
||||
public static void alert(final Activity activity) {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
activity.requestPermissions(new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 228);
|
||||
}
|
||||
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(activity, ThemesUtils.getAlertStyle());
|
||||
builder.setTitle(getString("warning"));
|
||||
builder.setMessage(getWelcome());
|
||||
builder.setCancelable(false);
|
||||
// android.content.DialogInterface.OnClickListener
|
||||
builder.setPositiveButton(getString("startbtn2"), (dialogInterface, i) -> edit().putBoolean("showAlert", false).apply());
|
||||
// android.content.DialogInterface.OnClickListener
|
||||
builder.setNeutralButton(getString("startbtn1"), (dialogInterface, i) -> {
|
||||
edit().putBoolean("showAlert", false).apply();
|
||||
activity.startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://t.me/vtosters")));
|
||||
});
|
||||
if (getBoolValue("showAlert", true)) {
|
||||
builder.show();
|
||||
}
|
||||
if (getBoolValue("showAlert", true))
|
||||
new VkAlertDialog.Builder(activity)
|
||||
.setTitle(getString("warning"))
|
||||
.setMessage(getWelcome())
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(getString("startbtn2"),
|
||||
(dialogInterface, i) -> edit().putBoolean("showAlert", false).apply()
|
||||
)
|
||||
.setNeutralButton(getString("startbtn1"),
|
||||
(dialogInterface, i) -> {
|
||||
edit().putBoolean("showAlert", false).apply();
|
||||
activity.startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://t.me/vtosters")));
|
||||
}
|
||||
)
|
||||
.show();
|
||||
|
||||
}
|
||||
|
||||
private static String getWelcome() {
|
||||
|
||||
@@ -10,12 +10,11 @@ import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vk.core.ui.themes.VKThemeHelper;
|
||||
|
||||
import ru.vtosters.lite.hooks.VKUIHook;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class ThemeChanging {
|
||||
public static void changeTheme(Activity activity, float[] f) {
|
||||
if (getBoolValue("systemtheme", true)) {
|
||||
new VkAlertDialog.Builder(activity, ThemesUtils.getAlertStyle())
|
||||
new VkAlertDialog.Builder(activity)
|
||||
.setTitle(getString("warning"))
|
||||
.setMessage(getString("system_theme_warning"))
|
||||
.setCancelable(false)
|
||||
|
||||
@@ -2,6 +2,8 @@ package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@@ -11,7 +13,6 @@ import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
|
||||
import ru.vtosters.lite.translators.BaseTranslator;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class Translate {
|
||||
public static void showTranslatedText(Context context, String text) {
|
||||
@@ -28,19 +29,17 @@ public class Translate {
|
||||
}
|
||||
|
||||
private static void showDialog(Context context, String text) {
|
||||
VkAlertDialog.Builder alertDialog = new VkAlertDialog.Builder(context, ThemesUtils.getAlertStyle());
|
||||
alertDialog.setTitle(AndroidUtils.getString("translator_title"));
|
||||
alertDialog.setMessage(text);
|
||||
alertDialog.setPositiveButton(AndroidUtils.getString("close"), (dialog, which) -> {
|
||||
dialog.cancel();
|
||||
});
|
||||
alertDialog.setNeutralButton(AndroidUtils.getString("copy"), (dialog, which) -> {
|
||||
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
android.content.ClipData clip = android.content.ClipData.newPlainText("Copied Text", text);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
sendToast(AndroidUtils.getString("copied_to_clipboard"));
|
||||
});
|
||||
var alert = alertDialog.create();
|
||||
alert.show();
|
||||
new VkAlertDialog.Builder(context)
|
||||
.setTitle(AndroidUtils.getString("translator_title"))
|
||||
.setMessage(text)
|
||||
.setPositiveButton(AndroidUtils.getString("close"),
|
||||
(dialog, which) -> dialog.cancel())
|
||||
.setNeutralButton(AndroidUtils.getString("copy"), (dialog, which) -> {
|
||||
var clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
var clip = ClipData.newPlainText("Copied Text", text);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
sendToast(AndroidUtils.getString("copied_to_clipboard"));
|
||||
})
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,26 +13,26 @@ import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vk.navigation.Navigator;
|
||||
|
||||
import ru.vtosters.lite.ui.fragments.VKUIwrapper;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class VKIDProtection {
|
||||
public static void alert(final Activity activity) {
|
||||
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(activity, ThemesUtils.getAlertStyle());
|
||||
builder.setTitle(getString("warning"));
|
||||
builder.setMessage(getString("vkidsumm"));
|
||||
builder.setCancelable(false);
|
||||
// android.content.DialogInterface.OnClickListener
|
||||
builder.setPositiveButton(getString("startbtn2"), (dialogInterface, i) -> edit().putBoolean("showAlertVkId", false).apply());
|
||||
// android.content.DialogInterface.OnClickListener
|
||||
builder.setNeutralButton(getString("vkiddisable"), (dialogInterface, i) -> {
|
||||
edit().putBoolean("showAlertVkId", false).apply();
|
||||
VKUIwrapper.setLink((isAnyProxyEnabled() ? "https://id.vk.com/account" : "https://" + getApi() + "/_/id.vk.com/account"));
|
||||
Intent a2 = new Navigator(VKUIwrapper.class).b(activity);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
activity.startActivity(a2);
|
||||
});
|
||||
if (getBoolValue("showAlertVkId", true)) {
|
||||
builder.show();
|
||||
}
|
||||
if (!getBoolValue("showAlertVkId", true)) return;
|
||||
new VkAlertDialog.Builder(activity)
|
||||
.setTitle(getString("warning"))
|
||||
.setMessage(getString("vkidsumm"))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(getString("startbtn2"),
|
||||
(dialogInterface, i) -> edit().putBoolean("showAlertVkId", false).apply())
|
||||
.setNeutralButton(getString("vkiddisable"), (dialogInterface, i) -> {
|
||||
edit().putBoolean("showAlertVkId", false).apply();
|
||||
VKUIwrapper.setLink(
|
||||
isAnyProxyEnabled()
|
||||
? "https://id.vk.com/account"
|
||||
: "https://" + getApi() + "/_/id.vk.com/account");
|
||||
var intent = new Navigator(VKUIwrapper.class).b(activity)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
activity.startActivity(intent);
|
||||
})
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
|
||||
|
||||
import ru.vtosters.lite.ui.components.NewsfeedListManager;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class FeedFragment extends MaterialPreferenceToolbarFragment {
|
||||
@Override
|
||||
@@ -94,17 +93,18 @@ public class FeedFragment extends MaterialPreferenceToolbarFragment {
|
||||
}
|
||||
|
||||
private void remdialog(String key, Context context) {
|
||||
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(context, ThemesUtils.getAlertStyle());
|
||||
builder.setTitle(AndroidUtils.getString("warning"));
|
||||
builder.setMessage(AndroidUtils.getString("delete_elements_confirm"));
|
||||
builder.setCancelable(false);
|
||||
builder.setPositiveButton(AndroidUtils.getString("yes"), (dialogInterface, i) -> {
|
||||
edit().remove(key).apply();
|
||||
sendToast(AndroidUtils.getString("elements_deleted_success"));
|
||||
setupFilters();
|
||||
});
|
||||
builder.setNegativeButton(AndroidUtils.getString("cancel"), (dialogInterface, i) -> dialogInterface.dismiss());
|
||||
builder.show();
|
||||
new VkAlertDialog.Builder(context)
|
||||
.setTitle(AndroidUtils.getString("warning"))
|
||||
.setMessage(AndroidUtils.getString("delete_elements_confirm"))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(AndroidUtils.getString("yes"), (dialogInterface, i) -> {
|
||||
edit().remove(key).apply();
|
||||
sendToast(AndroidUtils.getString("elements_deleted_success"));
|
||||
setupFilters();
|
||||
})
|
||||
.setNegativeButton(AndroidUtils.getString("cancel"),
|
||||
(dialogInterface, i) -> dialogInterface.dismiss())
|
||||
.show();
|
||||
}
|
||||
|
||||
private String countSet(String key) {
|
||||
|
||||
@@ -34,7 +34,6 @@ import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
|
||||
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class IconsFragment extends MaterialPreferenceToolbarFragment {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@@ -71,33 +70,30 @@ public class IconsFragment extends MaterialPreferenceToolbarFragment {
|
||||
rgVK.setChecked(defname.contains("standard"));
|
||||
rgDefault.setChecked(defname.contains("vt") || defname.isEmpty());
|
||||
|
||||
var builder = new VkAlertDialog.Builder(ctx, ThemesUtils.getAlertStyle());
|
||||
builder.setTitle(AndroidUtils.getString("app_name_select_title"));
|
||||
builder.setPositiveButton(AndroidUtils.getString("vtl_confirm"), ((dialog, which) -> {
|
||||
if (rgDefault.isChecked()) {
|
||||
edit().putString("appname", "vt").commit();
|
||||
edit().putString("selectedicon", appicon).commit();
|
||||
new VkAlertDialog.Builder(ctx)
|
||||
.setTitle(AndroidUtils.getString("app_name_select_title"))
|
||||
.setView(rg)
|
||||
.setPositiveButton(AndroidUtils.getString("vtl_confirm"), ((dialog, which) -> {
|
||||
if (rgDefault.isChecked()) {
|
||||
edit().putString("appname", "vt").commit();
|
||||
edit().putString("selectedicon", appicon).commit();
|
||||
|
||||
switchComponent(appicon, "vt", deficon, defname);
|
||||
} else if (rgVK.isChecked()) {
|
||||
edit().putString("appname", "standard").commit();
|
||||
edit().putString("selectedicon", appicon).commit();
|
||||
switchComponent(appicon, "vt", deficon, defname);
|
||||
} else if (rgVK.isChecked()) {
|
||||
edit().putString("appname", "standard").commit();
|
||||
edit().putString("selectedicon", appicon).commit();
|
||||
|
||||
switchComponent(appicon, "standard", deficon, defname);
|
||||
} else if (rgVKontakte.isChecked()) {
|
||||
edit().putString("appname", "vkontakte").commit();
|
||||
edit().putString("selectedicon", appicon).commit();
|
||||
switchComponent(appicon, "standard", deficon, defname);
|
||||
} else if (rgVKontakte.isChecked()) {
|
||||
edit().putString("appname", "vkontakte").commit();
|
||||
edit().putString("selectedicon", appicon).commit();
|
||||
|
||||
switchComponent(appicon, "vkontakte", deficon, defname);
|
||||
}
|
||||
}));
|
||||
builder.setNegativeButton(AndroidUtils.getString("cancel"), ((dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
}));
|
||||
|
||||
var alert = builder.create();
|
||||
alert.setView(rg);
|
||||
alert.show();
|
||||
switchComponent(appicon, "vkontakte", deficon, defname);
|
||||
}
|
||||
}))
|
||||
.setNegativeButton(AndroidUtils.getString("cancel"),
|
||||
((dialog, which) -> dialog.dismiss()))
|
||||
.show();
|
||||
}
|
||||
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
|
||||
@@ -20,12 +20,10 @@ import android.content.res.ColorStateList;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@@ -49,28 +47,29 @@ import ru.vtosters.lite.music.Scrobbler;
|
||||
import ru.vtosters.lite.music.cache.CacheDatabaseDelegate;
|
||||
import ru.vtosters.lite.ui.adapters.ImagineArrayAdapter;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class MediaFragment extends MaterialPreferenceToolbarFragment {
|
||||
private static final ExecutorService executor = Executors.newCachedThreadPool();
|
||||
|
||||
public static void download(Context ctx) {
|
||||
var alertDialog = new VkAlertDialog.Builder(ctx, ThemesUtils.getAlertStyle());
|
||||
alertDialog.setTitle(AndroidUtils.getString("video_dl_enter_link"));
|
||||
|
||||
final EditText input = new EditText(ctx);
|
||||
input.setTextColor(getTextAttr());
|
||||
input.setBackgroundTintList(ColorStateList.valueOf(getAccentColor()));
|
||||
|
||||
var lp = new FrameLayout.LayoutParams(-1, -2);
|
||||
lp.leftMargin = AndroidUtils.dp2px(16);
|
||||
lp.rightMargin = AndroidUtils.dp2px(16);
|
||||
lp.gravity = Gravity.CENTER;
|
||||
input.setTextColor(getTextAttr());
|
||||
input.setBackgroundTintList(ColorStateList.valueOf(getAccentColor()));
|
||||
var container = new FrameLayout(ctx);
|
||||
|
||||
container.addView(input, lp);
|
||||
alertDialog.setPositiveButton(AndroidUtils.getString("download"), (dialog, which) -> VideoDownloader.parseVideoLink(input.getText().toString(), ctx));
|
||||
var alert = alertDialog.create();
|
||||
alert.setView(container);
|
||||
alert.show();
|
||||
|
||||
new VkAlertDialog.Builder(ctx)
|
||||
.setTitle(AndroidUtils.getString("video_dl_enter_link"))
|
||||
.setPositiveButton(AndroidUtils.getString("download"),
|
||||
(dialog, which) -> VideoDownloader.parseVideoLink(input.getText().toString(), ctx))
|
||||
.setView(container)
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,19 +137,15 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
|
||||
new ImagineArrayAdapter.ImagineArrayAdapterItem(getIdentifier("microsoft", "drawable"), "Bing")
|
||||
);
|
||||
|
||||
var alert = new VkAlertDialog.Builder(getActivity(), ThemesUtils.getAlertStyle())
|
||||
.create();
|
||||
|
||||
var listView = (ListView) LayoutInflater.from(getContext()).inflate(com.vtosters.lite.R.layout.abc_select_dialog_material, null, false);
|
||||
var adapter = new ImagineArrayAdapter(getContext(), items, i -> {
|
||||
getPreferences().edit().putInt("search_engine", i).apply();
|
||||
alert.dismiss();
|
||||
});
|
||||
var adapter = new ImagineArrayAdapter(getContext(), items);
|
||||
adapter.setSelected(getPreferences().getInt("search_engine", 0));
|
||||
listView.setAdapter(adapter);
|
||||
alert.setView(listView);
|
||||
alert.show();
|
||||
|
||||
new VkAlertDialog.Builder(getActivity())
|
||||
.setAdapter(adapter, (dialog, which) -> {
|
||||
getPreferences().edit().putInt("search_engine", which).apply();
|
||||
dialog.cancel();
|
||||
})
|
||||
.show();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@@ -179,66 +174,52 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
|
||||
ln.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
ln.setLayoutParams(margin);
|
||||
|
||||
var alertDialog = new VkAlertDialog.Builder(ctx, ThemesUtils.getAlertStyle());
|
||||
alertDialog.setTitle(AndroidUtils.getString("lastfm_enter_credentials"));
|
||||
|
||||
alertDialog.setPositiveButton(AndroidUtils.getString("lastfm_enter"), (dialog, which) -> {
|
||||
String login = fn.getText().toString();
|
||||
String pass = ln.getText().toString();
|
||||
|
||||
Scrobbler.auth(login, pass);
|
||||
});
|
||||
var alert = alertDialog.create();
|
||||
alert.setView(linearLayout);
|
||||
alert.show();
|
||||
new VkAlertDialog.Builder(ctx)
|
||||
.setTitle(AndroidUtils.getString("lastfm_enter_credentials"))
|
||||
.setPositiveButton(AndroidUtils.getString("lastfm_enter"),
|
||||
(dialog, which) -> {
|
||||
String login = fn.getText().toString();
|
||||
String pass = ln.getText().toString();
|
||||
Scrobbler.auth(login, pass);
|
||||
}
|
||||
)
|
||||
.setView(linearLayout)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void logout(Context ctx) {
|
||||
VkAlertDialog.Builder alertDialog = new VkAlertDialog.Builder(ctx, ThemesUtils.getAlertStyle());
|
||||
alertDialog.setTitle(AndroidUtils.getString("lastfm_logout_title"));
|
||||
alertDialog.setMessage(AndroidUtils.getString("lastfm_logout_confirm"));
|
||||
alertDialog.setPositiveButton(AndroidUtils.getString("vkim_yes"), (dialog, which) -> {
|
||||
Scrobbler.logout();
|
||||
});
|
||||
alertDialog.setNeutralButton(AndroidUtils.getString("vkim_no"), (dialog, which) -> {
|
||||
dialog.cancel();
|
||||
});
|
||||
var alert = alertDialog.create();
|
||||
alert.show();
|
||||
|
||||
|
||||
new VkAlertDialog.Builder(ctx)
|
||||
.setTitle(AndroidUtils.getString("lastfm_logout_title"))
|
||||
.setMessage(AndroidUtils.getString("lastfm_logout_confirm"))
|
||||
.setPositiveButton(AndroidUtils.getString("vkim_yes"),
|
||||
(dialog, which) -> Scrobbler.logout())
|
||||
.setNeutralButton(AndroidUtils.getString("vkim_no"),
|
||||
(dialog, which) -> dialog.cancel())
|
||||
.show();
|
||||
}
|
||||
|
||||
private void delcache(Context ctx) {
|
||||
VkAlertDialog.Builder alertDialog = new VkAlertDialog.Builder(ctx);
|
||||
alertDialog.setTitle(AndroidUtils.getString("warning"));
|
||||
alertDialog.setMessage(AndroidUtils.getString("cached_tracks_remove_confirm"));
|
||||
alertDialog.setPositiveButton(AndroidUtils.getString("yes"), (dialog, which) -> {
|
||||
executor.submit(CacheDatabaseDelegate::clear);
|
||||
});
|
||||
alertDialog.setNeutralButton(AndroidUtils.getString("no"), (dialog, which) -> {
|
||||
dialog.cancel();
|
||||
});
|
||||
var alert = alertDialog.create();
|
||||
alert.show();
|
||||
|
||||
|
||||
new VkAlertDialog.Builder(ctx)
|
||||
.setTitle(AndroidUtils.getString("warning"))
|
||||
.setMessage(AndroidUtils.getString("cached_tracks_remove_confirm"))
|
||||
.setPositiveButton(AndroidUtils.getString("yes"),
|
||||
(dialog, which) -> executor.submit(CacheDatabaseDelegate::clear))
|
||||
.setNeutralButton(AndroidUtils.getString("no"),
|
||||
(dialog, which) -> dialog.cancel())
|
||||
.show();
|
||||
}
|
||||
|
||||
private void dlaudio(Context ctx) {
|
||||
VkAlertDialog.Builder alertDialog = new VkAlertDialog.Builder(ctx);
|
||||
alertDialog.setTitle(AndroidUtils.getString("download_method"));
|
||||
alertDialog.setMessage(AndroidUtils.getString("download_method_desc"));
|
||||
alertDialog.setPositiveButton(AndroidUtils.getString("download_method_cache"), (dialog, which) -> {
|
||||
executor.submit(AudioDownloader::cacheAllAudios);
|
||||
});
|
||||
alertDialog.setNegativeButton(AndroidUtils.getString("download_method_mp3"), (dialog, which) -> {
|
||||
executor.submit(AudioDownloader::downloadAllAudios);
|
||||
});
|
||||
var alert = alertDialog.create();
|
||||
alert.show();
|
||||
|
||||
|
||||
new VkAlertDialog.Builder(ctx)
|
||||
.setTitle(AndroidUtils.getString("download_method"))
|
||||
.setMessage(AndroidUtils.getString("download_method_desc"))
|
||||
.setPositiveButton(AndroidUtils.getString("download_method_cache"), (dialog, which) -> {
|
||||
executor.submit(AudioDownloader::cacheAllAudios);
|
||||
})
|
||||
.setNegativeButton(AndroidUtils.getString("download_method_mp3"), (dialog, which) -> {
|
||||
executor.submit(AudioDownloader::downloadAllAudios);
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
public void deleteVideoHistory() {
|
||||
@@ -271,15 +252,15 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
|
||||
}
|
||||
|
||||
private void deleteVideoHistoryDialog(Context context) {
|
||||
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(context);
|
||||
builder.setTitle(AndroidUtils.getString("warning"));
|
||||
builder.setMessage(AndroidUtils.getString("delete_video_history_confirm"));
|
||||
builder.setCancelable(false);
|
||||
builder.setPositiveButton(AndroidUtils.getString("yes"), (dialogInterface, i) -> {
|
||||
deleteVideoHistory();
|
||||
});
|
||||
builder.setNegativeButton(AndroidUtils.getString("cancel"), (dialogInterface, i) -> dialogInterface.dismiss());
|
||||
builder.show();
|
||||
new VkAlertDialog.Builder(context)
|
||||
.setTitle(AndroidUtils.getString("warning"))
|
||||
.setMessage(AndroidUtils.getString("delete_video_history_confirm"))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(AndroidUtils.getString("yes"),
|
||||
(dialogInterface, i) -> deleteVideoHistory())
|
||||
.setNegativeButton(AndroidUtils.getString("cancel"),
|
||||
(dialogInterface, i) -> dialogInterface.dismiss())
|
||||
.show();
|
||||
}
|
||||
|
||||
private static class restart implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
@@ -13,8 +13,6 @@ import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.ListView;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@@ -26,7 +24,6 @@ import java.util.Arrays;
|
||||
|
||||
import ru.vtosters.lite.ui.adapters.ImagineArrayAdapter;
|
||||
import ru.vtosters.lite.ui.wallpapers.WallpaperMenuFragment;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class MessagesFragment extends MaterialPreferenceToolbarFragment {
|
||||
@Override
|
||||
@@ -52,18 +49,15 @@ public class MessagesFragment extends MaterialPreferenceToolbarFragment {
|
||||
// new ImagineArrayAdapter.ImagineArrayAdapterItem(getIdentifier("ic_deepl_logo_icon", "drawable"), "DeepL")
|
||||
);
|
||||
|
||||
var alert = new VkAlertDialog.Builder(getActivity(), ThemesUtils.getAlertStyle())
|
||||
.create();
|
||||
|
||||
var listView = (ListView) LayoutInflater.from(getContext()).inflate(com.vtosters.lite.R.layout.abc_select_dialog_material, null, false);
|
||||
var adapter = new ImagineArrayAdapter(requireContext(), items, i -> {
|
||||
getPreferences().edit().putInt("translator", i).apply();
|
||||
alert.dismiss();
|
||||
});
|
||||
var adapter = new ImagineArrayAdapter(requireContext(), items);
|
||||
adapter.setSelected(getPreferences().getInt("translator", 0));
|
||||
listView.setAdapter(adapter);
|
||||
alert.setView(listView);
|
||||
alert.show();
|
||||
|
||||
new VkAlertDialog.Builder(getActivity())
|
||||
.setAdapter(adapter, (dialog, which) -> {
|
||||
getPreferences().edit().putInt("translator", which).apply();
|
||||
dialog.cancel();
|
||||
})
|
||||
.show();
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -194,101 +194,86 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
four.setChecked(val == 4);
|
||||
five.setChecked(val == 5);
|
||||
|
||||
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(getContext(), ThemesUtils.getAlertStyle());
|
||||
builder.setTitle(AndroidUtils.getString("cache_clean_title"));
|
||||
builder.setMessage(AndroidUtils.getString("cache_select_size"));
|
||||
builder.setCancelable(true);
|
||||
builder.setNegativeButton(AndroidUtils.getString("cancel"), null);
|
||||
builder.setView(rg);
|
||||
builder.setPositiveButton(AndroidUtils.getString("save"), (dialog, which) -> {
|
||||
var pref = getDefaultPrefs().edit();
|
||||
var checked = rg.getCheckedRadioButtonId();
|
||||
|
||||
if (checked == zero.getId()) {
|
||||
pref.putInt("autoclearcache_size", 0);
|
||||
pref.putString("autoclearcache", "Default");
|
||||
} else if (checked == one.getId()) {
|
||||
pref.putInt("autoclearcache_size", 1);
|
||||
pref.putString("autoclearcache", "100mb");
|
||||
} else if (checked == two.getId()) {
|
||||
pref.putInt("autoclearcache_size", 2);
|
||||
pref.putString("autoclearcache", "500mb");
|
||||
} else if (checked == three.getId()) {
|
||||
pref.putInt("autoclearcache_size", 3);
|
||||
pref.putString("autoclearcache", "1gb");
|
||||
} else if (checked == four.getId()) {
|
||||
pref.putInt("autoclearcache_size", 4);
|
||||
pref.putString("autoclearcache", "2gb");
|
||||
} else if (checked == five.getId()) {
|
||||
pref.putInt("autoclearcache_size", 5);
|
||||
pref.putString("autoclearcache", "5gb");
|
||||
}
|
||||
|
||||
pref.apply();
|
||||
});
|
||||
builder.show();
|
||||
new VkAlertDialog.Builder(getContext())
|
||||
.setTitle(AndroidUtils.getString("cache_clean_title"))
|
||||
.setMessage(AndroidUtils.getString("cache_select_size"))
|
||||
.setCancelable(true)
|
||||
.setNegativeButton(AndroidUtils.getString("cancel"), null)
|
||||
.setView(rg)
|
||||
.setPositiveButton(AndroidUtils.getString("save"), (dialog, which) -> {
|
||||
var sizes = new String[] { "Default", "100mb", "500mb", "1gb", "2gb", "5gb" };
|
||||
var id = rg.getCheckedRadioButtonId();
|
||||
getDefaultPrefs().edit()
|
||||
.putInt("autoclearcache_size", id)
|
||||
.putString("autoclearcache", sizes[id])
|
||||
.apply();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void cacheCleanDialog() {
|
||||
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(getContext(), ThemesUtils.getAlertStyle());
|
||||
builder.setTitle(AndroidUtils.getString("select_which_clean"));
|
||||
builder.setItems(AndroidUtils.getArray("cache_cleaner"), (dialog, which) -> {
|
||||
switch (which) {
|
||||
case 0: {
|
||||
SharedPreferences prefs2 = getContext().getSharedPreferences("stickers_storage", Context.MODE_PRIVATE);
|
||||
prefs2.edit().clear().commit();
|
||||
new WebView(getActivity()).clearCache(true);
|
||||
VKImageLoader.e();
|
||||
ImEngineProvider.b().a();
|
||||
ImAudioMsgPlayerProvider.b().e(PlayerActionSources.a);
|
||||
ImAudioMsgPlayerProvider.b().d(PlayerActionSources.a);
|
||||
FileUtils.l();
|
||||
Stickers.l.c();
|
||||
ImEngineExt.a(ImEngine1.a());
|
||||
AutoPlayCacheHolder.d.a();
|
||||
MediaStorage.a();
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
SharedPreferences prefs2 = getContext().getSharedPreferences("stickers_storage", Context.MODE_PRIVATE);
|
||||
prefs2.edit().clear().commit();
|
||||
Stickers.l.c();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
VKImageLoader.e();
|
||||
ImEngineExt.a(ImEngine1.a());
|
||||
break;
|
||||
case 3:
|
||||
AutoPlayCacheHolder.d.a();
|
||||
MediaStorage.a();
|
||||
break;
|
||||
case 4:
|
||||
ImEngineProvider.b().a();
|
||||
ImAudioMsgPlayerProvider.b().e(PlayerActionSources.a);
|
||||
ImAudioMsgPlayerProvider.b().d(PlayerActionSources.a);
|
||||
break;
|
||||
case 5:
|
||||
new WebView(getActivity()).clearCache(true);
|
||||
break;
|
||||
}
|
||||
new VkAlertDialog.Builder(getContext())
|
||||
.setTitle(AndroidUtils.getString("select_which_clean"))
|
||||
.setItems(AndroidUtils.getArray("cache_cleaner"), (dialog, which) -> {
|
||||
switch (which) {
|
||||
case 0: {
|
||||
SharedPreferences prefs2 = getContext().getSharedPreferences("stickers_storage", Context.MODE_PRIVATE);
|
||||
prefs2.edit().clear().commit();
|
||||
clearWebViewCache();
|
||||
VKImageLoader.e();
|
||||
ImEngineProvider.b().a();
|
||||
ImAudioMsgPlayerProvider.b().e(PlayerActionSources.a);
|
||||
ImAudioMsgPlayerProvider.b().d(PlayerActionSources.a);
|
||||
FileUtils.l();
|
||||
Stickers.l.c();
|
||||
ImEngineExt.a(ImEngine1.a());
|
||||
AutoPlayCacheHolder.d.a();
|
||||
MediaStorage.a();
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
SharedPreferences prefs2 = getContext().getSharedPreferences("stickers_storage", Context.MODE_PRIVATE);
|
||||
prefs2.edit().clear().commit();
|
||||
Stickers.l.c();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
VKImageLoader.e();
|
||||
ImEngineExt.a(ImEngine1.a());
|
||||
break;
|
||||
case 3:
|
||||
AutoPlayCacheHolder.d.a();
|
||||
MediaStorage.a();
|
||||
break;
|
||||
case 4:
|
||||
ImEngineProvider.b().a();
|
||||
ImAudioMsgPlayerProvider.b().e(PlayerActionSources.a);
|
||||
ImAudioMsgPlayerProvider.b().d(PlayerActionSources.a);
|
||||
break;
|
||||
case 5:
|
||||
clearWebViewCache();
|
||||
break;
|
||||
}
|
||||
Toast.makeText(getContext(), AndroidUtils.getString("cache_cleaned"), LENGTH_SHORT).show();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
Toast.makeText(getContext(), AndroidUtils.getString("cache_cleaned"), LENGTH_SHORT).show();
|
||||
});
|
||||
builder.create().show();
|
||||
private void clearWebViewCache() {
|
||||
new WebView(requireContext()).clearCache(true);
|
||||
}
|
||||
|
||||
private void delprefs(Context context) {
|
||||
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(context, ThemesUtils.getAlertStyle());
|
||||
builder.setTitle(AndroidUtils.getString("warning"));
|
||||
builder.setMessage(AndroidUtils.getString("settings_reset_confirm"));
|
||||
builder.setCancelable(false);
|
||||
builder.setPositiveButton(AndroidUtils.getString("yes"), (dialogInterface, i) -> {
|
||||
deletePrefs();
|
||||
restartApplication();
|
||||
});
|
||||
builder.setNegativeButton(AndroidUtils.getString("cancel"), (dialogInterface, i) -> dialogInterface.dismiss());
|
||||
builder.show();
|
||||
new VkAlertDialog.Builder(context)
|
||||
.setTitle(AndroidUtils.getString("warning"))
|
||||
.setMessage(AndroidUtils.getString("settings_reset_confirm"))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(AndroidUtils.getString("yes"), (dialogInterface, i) -> {
|
||||
deletePrefs();
|
||||
restartApplication();
|
||||
})
|
||||
.setNegativeButton(AndroidUtils.getString("cancel"), (dialogInterface, i) -> dialogInterface.dismiss())
|
||||
.show();
|
||||
}
|
||||
|
||||
public static class d implements Preference.OnPreferenceClickListener {
|
||||
@@ -365,7 +350,7 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
var arr = BackupManager.getBackupsNames();
|
||||
var adapter = new ArrayAdapter(getContext(), android.R.layout.simple_list_item_1, arr);
|
||||
new VkAlertDialog.Builder(getContext(), ThemesUtils.getAlertStyle())
|
||||
new VkAlertDialog.Builder(getContext())
|
||||
.setTitle(AndroidUtils.getString("select_backup"))
|
||||
.setAdapter(adapter, (dialog, which) -> {
|
||||
try {
|
||||
@@ -375,7 +360,8 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(getContext(), AndroidUtils.getString("backup_error"), LENGTH_LONG).show();
|
||||
}
|
||||
}).create().show();
|
||||
})
|
||||
.show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,6 @@ import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.CacheUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
import ru.vtosters.lite.utils.SSFSUtils;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
public static String getValAsString(String stringid, Boolean value) {
|
||||
@@ -179,7 +178,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
final var isDarkTheme = !switchPreference.isChecked();
|
||||
|
||||
if (Preferences.systemtheme()) {
|
||||
new VkAlertDialog.Builder(requireActivity(), ThemesUtils.getAlertStyle())
|
||||
new VkAlertDialog.Builder(requireActivity())
|
||||
.setTitle(AndroidUtils.getString("warning"))
|
||||
.setMessage(AndroidUtils.getString("system_theme_warning"))
|
||||
.setCancelable(false)
|
||||
|
||||
@@ -182,29 +182,23 @@ public class StickersFragment extends BaseToolbarFragment {
|
||||
margin.setMargins(dp2px(24f), 0, dp2px(24f), 0);
|
||||
editText.setLayoutParams(margin);
|
||||
|
||||
var dlg = new VkAlertDialog.Builder(getContext(), ThemesUtils.getAlertStyle());
|
||||
dlg.setTitle(AndroidUtils.getString("stickershelp1"));
|
||||
dlg.setMessage(AndroidUtils.getString("stickershelp2"));
|
||||
dlg.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
String pack = editText.getText().toString();
|
||||
if (!pack.startsWith("https://")) {
|
||||
pack = "https://" + pack;
|
||||
} else if (!pack.contains("addstickers")) {
|
||||
sendToast("Invalid pack name");
|
||||
}
|
||||
pack = parsePack(pack);
|
||||
mService.requestPackDownload(pack, new File(getContext().getFilesDir(), new File("VT-Stickers", pack).getAbsolutePath()));
|
||||
});
|
||||
dlg.setNeutralButton(android.R.string.cancel, (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
var alert = dlg.create();
|
||||
alert.setView(linearLayout);
|
||||
alert.show();
|
||||
|
||||
|
||||
|
||||
new VkAlertDialog.Builder(getContext())
|
||||
.setTitle(AndroidUtils.getString("stickershelp1"))
|
||||
.setMessage(AndroidUtils.getString("stickershelp2"))
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
String pack = editText.getText().toString();
|
||||
if (!pack.startsWith("https://")) {
|
||||
pack = "https://" + pack;
|
||||
} else if (!pack.contains("addstickers")) {
|
||||
sendToast("Invalid pack name");
|
||||
}
|
||||
pack = parsePack(pack);
|
||||
mService.requestPackDownload(pack, new File(getContext().getFilesDir(), new File("VT-Stickers", pack).getAbsolutePath()));
|
||||
})
|
||||
.setNeutralButton(android.R.string.cancel,
|
||||
(dialog, which) -> dialog.dismiss()
|
||||
)
|
||||
.show();
|
||||
};
|
||||
if (TGPref.getTGBotKey() == null) enterBotKey(() -> checkApiKey(callback));
|
||||
else checkApiKey(callback);
|
||||
@@ -245,26 +239,25 @@ public class StickersFragment extends BaseToolbarFragment {
|
||||
margin.setMargins(dp2px(24f), 0, dp2px(24f), 0);
|
||||
editText.setLayoutParams(margin);
|
||||
|
||||
var alert = new VkAlertDialog.Builder(getContext(), ThemesUtils.getAlertStyle())
|
||||
.setTitle(AndroidUtils.getString("stickersapi8"))
|
||||
.setMessage(AndroidUtils.getString("stickersapi9") +
|
||||
AndroidUtils.getString("stickersapi10")).setPositiveButton(android.R.string.ok, null)
|
||||
.create();
|
||||
|
||||
var dlg = new VkAlertDialog.Builder(getContext(), ThemesUtils.getAlertStyle());
|
||||
dlg.setTitle(AndroidUtils.getString("stickersapi5"));
|
||||
dlg.setMessage(AndroidUtils.getString("stickersapi6"));
|
||||
dlg.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
setTGBotKey(editText.getText().toString());
|
||||
if (r != null) r.run();
|
||||
});
|
||||
dlg.setNegativeButton(android.R.string.cancel, (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
dlg.setNeutralButton(AndroidUtils.getString("stickersapi7"), (dialog, which) -> alert.show());
|
||||
var alerts = dlg.create();
|
||||
alerts.setView(linearLayout);
|
||||
alerts.show();
|
||||
new VkAlertDialog.Builder(getContext())
|
||||
.setTitle(AndroidUtils.getString("stickersapi5"))
|
||||
.setMessage(AndroidUtils.getString("stickersapi6"))
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
setTGBotKey(editText.getText().toString());
|
||||
if (r != null) r.run();
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel,
|
||||
(dialog, which) -> dialog.dismiss()
|
||||
)
|
||||
.setNeutralButton(AndroidUtils.getString("stickersapi7"),
|
||||
(dialog, which) -> new VkAlertDialog.Builder(getContext())
|
||||
.setTitle(AndroidUtils.getString("stickersapi8"))
|
||||
.setMessage(AndroidUtils.getString("stickersapi9") +
|
||||
AndroidUtils.getString("stickersapi10"))
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show()
|
||||
)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void checkApiKey(Runnable callback) {
|
||||
@@ -294,11 +287,10 @@ public class StickersFragment extends BaseToolbarFragment {
|
||||
@Override
|
||||
public void onNetError() {
|
||||
progressDialog.dismiss();
|
||||
new VkAlertDialog.Builder(context, ThemesUtils.getAlertStyle())
|
||||
new VkAlertDialog.Builder(context)
|
||||
.setMessage(AndroidUtils.getString("stickersapi3"))
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(AndroidUtils.getString("stickersapi4"), (arg0, arg1) -> checkApiKey(callback))
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -83,19 +83,16 @@ public class ContactsUtils {
|
||||
|
||||
boolean enabledsync = resp.equals("contact");
|
||||
|
||||
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(ctx, ThemesUtils.getAlertStyle());
|
||||
builder.setTitle(getString("contact_sync_title"));
|
||||
builder.setMessage(getString("contact_sync_state") + ": " + getString(enabledsync ? "contact_sync_enabled" : "contact_sync_disabled"));
|
||||
builder.setCancelable(true);
|
||||
builder.setPositiveButton((!enabledsync ? getString("enable") : getString("proxy_disable")), (dialog, which) -> {
|
||||
setContactsSync(!enabledsync);
|
||||
});
|
||||
// builder.setNegativeButton("Импортировать контакты", (dialog, which) -> {
|
||||
// uploadContacts(ctx);
|
||||
// });
|
||||
|
||||
builder.show();
|
||||
|
||||
new VkAlertDialog.Builder(ctx)
|
||||
.setTitle(getString("contact_sync_title"))
|
||||
.setMessage(getString("contact_sync_state") + ": " + getString(enabledsync ? "contact_sync_enabled" : "contact_sync_disabled"))
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(getString(!enabledsync ? "enable" : "proxy_disable"),
|
||||
(dialog, which) -> setContactsSync(!enabledsync)
|
||||
)
|
||||
// .setNegativeButton("Импортировать контакты",
|
||||
// (dialog, which) -> uploadContacts(ctx))
|
||||
.show();
|
||||
} catch (JSONException e) {
|
||||
Log.d("ContactsUtils", e.getMessage());
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ExternalLinkParser {
|
||||
startExternalVideo((String) qualities.values().toArray()[0], context);
|
||||
} else {
|
||||
String[] titles = qualities.keySet().toArray(new String[0]);
|
||||
new VkAlertDialog.Builder(context, ThemesUtils.getAlertStyle())
|
||||
new VkAlertDialog.Builder(context)
|
||||
.setItems(titles, ((dialog, which) -> startExternalVideo(qualities.get(titles[which]), context)))
|
||||
.show();
|
||||
}
|
||||
|
||||
@@ -2,14 +2,12 @@ package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getResources;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getAccentColor;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getSTextAttr;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.database.Cursor;
|
||||
@@ -179,31 +177,45 @@ public class RenameTool {
|
||||
var builder = new VkAlertDialog.Builder(ctx)
|
||||
.setTitle(AndroidUtils.getString("rename_title"))
|
||||
.setMessage(AndroidUtils.getString("rename_message"))
|
||||
.setView(linearLayout)
|
||||
.setPositiveButton("OK", (dialog, which) -> {
|
||||
String firstName = fn.getText().toString();
|
||||
String lastName = ln.getText().toString();
|
||||
SQLiteDatabase writableDatabase = getHelper().getWritableDatabase();
|
||||
try {
|
||||
if (isChangedName(id)) {
|
||||
writableDatabase.execSQL(String.format("UPDATE %s SET %s='%s', %s='%s' WHERE %s='%s'", TABLE_NAME, COLUMN_FIRSTNAME, URLEncoder.encode(firstName, "UTF-8"), COLUMN_LASTNAME, URLEncoder.encode(lastName, "UTF-8"), COLUMN_VKID, id));
|
||||
} else {
|
||||
writableDatabase.execSQL(String.format("INSERT INTO %s (%s, %s, %s) VALUES (%s, '%s', '%s')", TABLE_NAME, COLUMN_VKID, COLUMN_FIRSTNAME, COLUMN_LASTNAME, id, URLEncoder.encode(firstName, "UTF-8"), URLEncoder.encode(lastName, "UTF-8")));
|
||||
}
|
||||
updateRequested = true;
|
||||
if (id == AccountManagerUtils.getUserId()) {
|
||||
ctx.sendBroadcast(new Intent("com.vkontakte.android.USER_NAME_CHANGED"));
|
||||
}
|
||||
ctx.sendBroadcast(new Intent("com.vkontakte.android.ACTION_PROFILE_UPDATED").putExtra("uid", id));
|
||||
String firstName = fn.getText().toString();
|
||||
String lastName = ln.getText().toString();
|
||||
SQLiteDatabase writableDatabase = getHelper().getWritableDatabase();
|
||||
try {
|
||||
if (isChangedName(id)) {
|
||||
writableDatabase.execSQL(
|
||||
String.format("UPDATE %s SET %s='%s', %s='%s' WHERE %s='%s'",
|
||||
TABLE_NAME,
|
||||
COLUMN_FIRSTNAME, URLEncoder.encode(firstName, "UTF-8"),
|
||||
COLUMN_LASTNAME, URLEncoder.encode(lastName, "UTF-8"),
|
||||
COLUMN_VKID, id));
|
||||
} else {
|
||||
writableDatabase.execSQL(
|
||||
String.format("INSERT INTO %s (%s, %s, %s) VALUES (%s, '%s', '%s')",
|
||||
TABLE_NAME,
|
||||
COLUMN_VKID, COLUMN_FIRSTNAME, COLUMN_LASTNAME,
|
||||
id, URLEncoder.encode(firstName, "UTF-8"), URLEncoder.encode(lastName, "UTF-8")));
|
||||
}
|
||||
updateRequested = true;
|
||||
if (id == AccountManagerUtils.getUserId()) {
|
||||
ctx.sendBroadcast(new Intent("com.vkontakte.android.USER_NAME_CHANGED"));
|
||||
}
|
||||
ctx.sendBroadcast(new Intent("com.vkontakte.android.ACTION_PROFILE_UPDATED").putExtra("uid", id));
|
||||
|
||||
sendToast(AndroidUtils.getString("rename_success"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
sendToast(AndroidUtils.getString("rename_error"));
|
||||
}
|
||||
sendToast(AndroidUtils.getString("rename_success"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
sendToast(AndroidUtils.getString("rename_error"));
|
||||
}
|
||||
});
|
||||
if (isChangedName(id))
|
||||
builder.setNeutralButton(AndroidUtils.getString("rename_reset"), (dialog, which) -> {
|
||||
getHelper().getWritableDatabase().execSQL(String.format("DELETE FROM %s WHERE %s='%s'", TABLE_NAME, COLUMN_VKID, id));
|
||||
getHelper().getWritableDatabase().execSQL(
|
||||
String.format(
|
||||
"DELETE FROM %s WHERE %s='%s'",
|
||||
TABLE_NAME,
|
||||
COLUMN_VKID, id));
|
||||
if (id == AccountManagerUtils.getUserId()) {
|
||||
ctx.sendBroadcast(new Intent("com.vkontakte.android.USER_NAME_CHANGED"));
|
||||
}
|
||||
@@ -211,10 +223,7 @@ public class RenameTool {
|
||||
ctx.sendBroadcast(new Intent("com.vkontakte.android.ACTION_PROFILE_UPDATED").putExtra("uid", id));
|
||||
sendToast(AndroidUtils.getString("rename_remove_from_bd_success"));
|
||||
});
|
||||
|
||||
var alert = builder.create();
|
||||
alert.setView(linearLayout);
|
||||
alert.show();
|
||||
builder.show();
|
||||
}
|
||||
|
||||
public static void createDialogGroup(ExtendedCommunityProfile eup, final Context ctx) {
|
||||
@@ -240,37 +249,42 @@ public class RenameTool {
|
||||
|
||||
final int id = fid;
|
||||
|
||||
var builder = new VkAlertDialog.Builder(ctx);
|
||||
builder.setTitle(AndroidUtils.getString("rename_title"));
|
||||
builder.setMessage(AndroidUtils.getString("rename_message"));
|
||||
builder.setPositiveButton("OK", (dialog, which) -> {
|
||||
String firstName = fn.getText().toString();
|
||||
SQLiteDatabase writableDatabase = getHelper().getWritableDatabase();
|
||||
try {
|
||||
if (isChangedNameGroup(id)) {
|
||||
writableDatabase.execSQL(String.format("UPDATE %s SET %s='%s' WHERE %s='%s'", TABLE_NAME_GROUP, COLUMN_NAME, URLEncoder.encode(firstName, "UTF-8"), COLUMN_VKID, id));
|
||||
} else {
|
||||
writableDatabase.execSQL(String.format("INSERT INTO %s (%s, %s) VALUES (%s, '%s')", TABLE_NAME_GROUP, COLUMN_VKID, COLUMN_NAME, id, URLEncoder.encode(firstName, "UTF-8")));
|
||||
}
|
||||
updateRequested = true;
|
||||
sendToast(AndroidUtils.getString("rename_group_success"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
var builder = new VkAlertDialog.Builder(ctx)
|
||||
.setTitle(AndroidUtils.getString("rename_title"))
|
||||
.setMessage(AndroidUtils.getString("rename_message"))
|
||||
.setView(linearLayout)
|
||||
.setPositiveButton("OK", (dialog, which) -> {
|
||||
String firstName = fn.getText().toString();
|
||||
SQLiteDatabase writableDatabase = getHelper().getWritableDatabase();
|
||||
try {
|
||||
if (isChangedNameGroup(id)) {
|
||||
writableDatabase.execSQL(
|
||||
String.format(
|
||||
"UPDATE %s SET %s='%s' WHERE %s='%s'",
|
||||
TABLE_NAME_GROUP,
|
||||
COLUMN_NAME, URLEncoder.encode(firstName, "UTF-8"),
|
||||
COLUMN_VKID, id));
|
||||
} else {
|
||||
writableDatabase.execSQL(
|
||||
String.format(
|
||||
"INSERT INTO %s (%s, %s) VALUES (%s, '%s')",
|
||||
TABLE_NAME_GROUP,
|
||||
COLUMN_VKID, COLUMN_NAME,
|
||||
id, URLEncoder.encode(firstName, "UTF-8")));
|
||||
}
|
||||
updateRequested = true;
|
||||
sendToast(AndroidUtils.getString("rename_group_success"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
if (isChangedNameGroup(id))
|
||||
builder.setNeutralButton(AndroidUtils.getString("rename_reset"), (dialog, which) -> {
|
||||
getHelper().getWritableDatabase().execSQL(String.format("DELETE FROM %s WHERE %s='%s'", TABLE_NAME_GROUP, COLUMN_VKID, id));
|
||||
updateRequested = true;
|
||||
sendToast(AndroidUtils.getString("rename_remove_group_from_bd_success"));
|
||||
});
|
||||
|
||||
var alert = builder.create();
|
||||
alert.setView(linearLayout);
|
||||
alert.show();
|
||||
|
||||
|
||||
|
||||
builder.show();
|
||||
}
|
||||
|
||||
public static boolean isChangedName(int uid) {
|
||||
@@ -291,13 +305,21 @@ public class RenameTool {
|
||||
}
|
||||
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL(String.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY AUTOINCREMENT, %s INTEGER, %s TEXT)", TABLE_NAME_GROUP, "_id", COLUMN_VKID, COLUMN_NAME));
|
||||
db.execSQL(String.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY AUTOINCREMENT, %s INTEGER, %s TEXT, %s TEXT)", TABLE_NAME, "_id", COLUMN_VKID, COLUMN_FIRSTNAME, COLUMN_LASTNAME));
|
||||
db.execSQL(String.format(
|
||||
"CREATE TABLE %s (%s INTEGER PRIMARY KEY AUTOINCREMENT, %s INTEGER, %s TEXT)",
|
||||
TABLE_NAME_GROUP,
|
||||
"_id", COLUMN_VKID, COLUMN_NAME));
|
||||
db.execSQL(String.format(
|
||||
"CREATE TABLE %s (%s INTEGER PRIMARY KEY AUTOINCREMENT, %s INTEGER, %s TEXT, %s TEXT)",
|
||||
TABLE_NAME,
|
||||
"_id", COLUMN_VKID, COLUMN_FIRSTNAME, COLUMN_LASTNAME));
|
||||
}
|
||||
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
if (newVersion == 2) {
|
||||
db.execSQL(String.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY AUTOINCREMENT, %s INTEGER, %s TEXT)", TABLE_NAME_GROUP, "_id", COLUMN_VKID, COLUMN_NAME));
|
||||
db.execSQL(String.format(
|
||||
"CREATE TABLE %s (%s INTEGER PRIMARY KEY AUTOINCREMENT, %s INTEGER, %s TEXT)",
|
||||
TABLE_NAME_GROUP, "_id", COLUMN_VKID, COLUMN_NAME));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,9 @@
|
||||
sput-object v0, Lcom/vk/core/dialogs/alert/VkAlertDialog;->e:Lcom/vk/core/dialogs/alert/VkAlertDialog$a;
|
||||
|
||||
.line 1
|
||||
sget v0, Lb/h/z/l;->VkAlertDialogTheme:I
|
||||
invoke-static {}, Lru/vtosters/lite/utils/ThemesUtils;->getAlertStyle()I
|
||||
|
||||
move-result v0
|
||||
|
||||
sput v0, Lcom/vk/core/dialogs/alert/VkAlertDialog;->a:I
|
||||
|
||||
|
||||
Reference in New Issue
Block a user