code cleanup
This commit is contained in:
@@ -80,13 +80,11 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
ToastUtils.a(requireContext().getString(R.string.fcmtokenget));
|
||||
ToastUtils.a(requireContext().getString(R.string.fcmtokenfixed));
|
||||
}, 1000);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
findPreference("applicationstop").setOnPreferenceClickListener(preference -> {
|
||||
System.exit(0);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -95,20 +93,17 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
Toast.makeText(requireContext(), requireContext().getString(R.string.copybtn), LENGTH_SHORT).show();
|
||||
ToastUtils.a(requireContext().getString(R.string.tokenwarning));
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
findPreference("copydebuginfo").setOnPreferenceClickListener(preference -> {
|
||||
copyText(new DeviceInfoCollector().collect().forLogging());
|
||||
Toast.makeText(requireContext(), "Информация об устройстве скопирована", LENGTH_SHORT).show();
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
findPreference("applicationrestart").setOnPreferenceClickListener(preference -> {
|
||||
restartApplication();
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -133,6 +128,8 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
return true;
|
||||
});
|
||||
|
||||
findPreference("dialogrecomm").setVisible(!Preferences.hasVerification());
|
||||
|
||||
findPreference("updateverifdata").setOnPreferenceClickListener(preference -> {
|
||||
UsersList.getUsersList();
|
||||
VTVerifications.load(requireContext());
|
||||
@@ -140,11 +137,6 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
return true;
|
||||
});
|
||||
|
||||
findPreference("contacts_sync").setOnPreferenceClickListener(preference -> {
|
||||
ContactsUtils.getContactsStatus(requireContext());
|
||||
return true;
|
||||
});
|
||||
|
||||
var pref = getDefaultPrefs().getString("autoclearcache", "Default");
|
||||
switch (pref) {
|
||||
case "Default":
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static androidx.core.app.ActivityCompat.requestPermissions;
|
||||
import static ru.vtosters.lite.net.Request.makeRequest;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
|
||||
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.SyncResult;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.StrictMode;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.vk.auth.VKAuthUtils;
|
||||
import com.vk.contacts.ContactsSyncAdapterService;
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vk.core.network.Network;
|
||||
import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.auth.VKAccountManager;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
public class ContactsUtils {
|
||||
public static void setContactsSync(boolean enabled) {
|
||||
makeRequest("https://" + getApi() + "/method/account.setInfo?" + "name=im_user_name_type&value=" + (enabled ? "contact" : "vk") + "&https=1&v=5.153&access_token=" + getUserToken(),
|
||||
response -> {
|
||||
try {
|
||||
JSONObject mainJson = new JSONObject(response);
|
||||
Log.d("ContactsUtils", "Result: " + mainJson + ", enabled sync: " + enabled);
|
||||
} catch (JSONException e) {
|
||||
Log.d("ContactsUtils", e.getMessage());
|
||||
sendToast(AndroidUtils.getString(R.string.contact_sync_error));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void uploadContacts(Activity ctx) {
|
||||
try {
|
||||
if (ContextCompat.checkSelfPermission(ctx, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
|
||||
sendToast(ctx.getString(R.string.contact_permission_toast));
|
||||
requestPermissions(LifecycleUtils.getCurrentActivity(), new String[]{Manifest.permission.READ_CONTACTS}, 11111);
|
||||
sendToast(ctx.getString(R.string.contact_permission_toast));
|
||||
requestPermissions(ctx, new String[]{Manifest.permission.READ_CONTACTS}, 11111);
|
||||
} else {
|
||||
var account = VKAuthUtils.a.a(VKAccountManager.d().Z());
|
||||
ContactsSyncAdapterService.c(ctx, account, new Bundle(), new SyncResult());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.d("ContactsUtils", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void getContactsStatus(Context ctx) {
|
||||
final ProgressDialog progressDialog = new ProgressDialog(ctx);
|
||||
progressDialog.setMessage(ctx.getString(R.string.contact_info_loading));
|
||||
progressDialog.show();
|
||||
|
||||
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
||||
StrictMode.setThreadPolicy(policy);
|
||||
|
||||
var request = new okhttp3.Request.a()
|
||||
.b("https://" + getApi() + "/method/execute?https=1&v=5.153&code=return%20API.account.getInfo().settings%5B44%5D.value%3B&access_token=" + getUserToken())
|
||||
.a(Headers.a("User-Agent", Network.l.c().a(), "Content-Type", "application/x-www-form-urlencoded; charset=utf-8"))
|
||||
.a();
|
||||
|
||||
try {
|
||||
var response = new OkHttpClient().a(request).execute().a().g();
|
||||
progressDialog.cancel();
|
||||
|
||||
try {
|
||||
String resp = new JSONObject(response).optString("response");
|
||||
|
||||
Log.d("ContactsUtils", new JSONObject(response).toString());
|
||||
|
||||
boolean enabledsync = resp.equals("contact");
|
||||
|
||||
new VkAlertDialog.Builder(ctx)
|
||||
.setTitle(R.string.contact_sync_title)
|
||||
.setMessage(ctx.getString(R.string.contact_sync_state) + ": " + ctx.getString(enabledsync ? R.string.contact_sync_enabled : R.string.contact_sync_disabled))
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(!enabledsync ? R.string.enable : R.string.proxy_disable,
|
||||
(dialog, which) -> setContactsSync(!enabledsync)
|
||||
)
|
||||
// .setNegativeButton("Импортировать контакты",
|
||||
// (dialog, which) -> uploadContacts(ctx))
|
||||
.show();
|
||||
} catch (JSONException e) {
|
||||
Log.d("ContactsUtils", e.getMessage());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.d("ContactsUtils", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,10 +60,6 @@ public class Preferences {
|
||||
return getGlobalContext().getSharedPreferences(filename, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public static boolean opusmodule() {
|
||||
return getBoolValue("opusmodule", true);
|
||||
}
|
||||
|
||||
public static boolean systemtheme() {
|
||||
return Build.VERSION.SDK_INT >= 28 && milkshake() && (getPreferences().getString("currsystemtheme", "system").equals("system") || getPreferences().getString("currsystemtheme", "system").isEmpty());
|
||||
}
|
||||
@@ -80,10 +76,6 @@ public class Preferences {
|
||||
return getBoolValue("copyright_post", false);
|
||||
}
|
||||
|
||||
public static boolean default_ad_list() {
|
||||
return getBoolValue("default_ad_list", false);
|
||||
}
|
||||
|
||||
public static boolean shitposting() {
|
||||
return getBoolValue("shitposting", false);
|
||||
}
|
||||
@@ -296,12 +288,8 @@ public class Preferences {
|
||||
return getBoolValue("vkme_notifs", false);
|
||||
}
|
||||
|
||||
public static boolean podcastcatalog() {
|
||||
return getBoolValue("podcastcatalog", false);
|
||||
}
|
||||
|
||||
public static boolean screenshotdetect() {
|
||||
return getBoolValue("screenshotdetect", false);
|
||||
return getBoolValue("screenshotdetect", true);
|
||||
}
|
||||
|
||||
public static boolean checkupdates() {
|
||||
@@ -352,18 +340,4 @@ public class Preferences {
|
||||
}
|
||||
return origquality;
|
||||
}
|
||||
|
||||
public static String photoQuality(String url) {
|
||||
// if (dev()) Log.d("PhotoQuality", url);
|
||||
|
||||
// if (url.contains("quality=") && !url.contains("quality=100") && !getBoolValue("compressPhotos", true)) {
|
||||
// if (url.contains("quality=95")) {
|
||||
// url = url.replace("quality=95", "quality=99");
|
||||
// } else {
|
||||
// url = url.replace("quality=96", "quality=99");
|
||||
// }
|
||||
// }
|
||||
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user