|
|
@ -21,6 +21,8 @@ import android.content.Context;
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
import android.os.Build.VERSION;
|
|
|
|
import android.os.Build.VERSION;
|
|
|
|
import android.os.Build.VERSION_CODES;
|
|
|
|
import android.os.Build.VERSION_CODES;
|
|
|
|
|
|
|
|
import android.os.Handler;
|
|
|
|
|
|
|
|
import android.os.Looper;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
|
|
|
|
|
@ -42,6 +44,8 @@ import network.loki.messenger.BuildConfig;
|
|
|
|
|
|
|
|
|
|
|
|
public class Util {
|
|
|
|
public class Util {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static volatile Handler handler;
|
|
|
|
|
|
|
|
|
|
|
|
public static String join(String[] list, String delimiter) {
|
|
|
|
public static String join(String[] list, String delimiter) {
|
|
|
|
return join(Arrays.asList(list), delimiter);
|
|
|
|
return join(Arrays.asList(list), delimiter);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -144,4 +148,24 @@ public class Util {
|
|
|
|
public static boolean isMmsCapable(Context context) {
|
|
|
|
public static boolean isMmsCapable(Context context) {
|
|
|
|
return (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) || OutgoingLegacyMmsConnection.isConnectionPossible(context);
|
|
|
|
return (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) || OutgoingLegacyMmsConnection.isConnectionPossible(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static boolean isMainThread() {
|
|
|
|
|
|
|
|
return Looper.myLooper() == Looper.getMainLooper();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void runOnMain(final @NonNull Runnable runnable) {
|
|
|
|
|
|
|
|
if (isMainThread()) runnable.run();
|
|
|
|
|
|
|
|
else getHandler().post(runnable);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Handler getHandler() {
|
|
|
|
|
|
|
|
if (handler == null) {
|
|
|
|
|
|
|
|
synchronized (Util.class) {
|
|
|
|
|
|
|
|
if (handler == null) {
|
|
|
|
|
|
|
|
handler = new Handler(Looper.getMainLooper());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return handler;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|