|
|
|
|
@ -1,19 +1,13 @@ |
|
|
|
|
package com.fongmi.android.tv.utils; |
|
|
|
|
|
|
|
|
|
import android.app.Activity; |
|
|
|
|
import android.app.PictureInPictureParams; |
|
|
|
|
import android.content.Context; |
|
|
|
|
import android.content.pm.PackageManager; |
|
|
|
|
import android.os.Build; |
|
|
|
|
import android.os.IBinder; |
|
|
|
|
import android.provider.Settings; |
|
|
|
|
import android.util.Base64; |
|
|
|
|
import android.util.Rational; |
|
|
|
|
import android.view.View; |
|
|
|
|
import android.view.inputmethod.InputMethodManager; |
|
|
|
|
|
|
|
|
|
import com.fongmi.android.tv.App; |
|
|
|
|
import com.google.android.exoplayer2.util.Util; |
|
|
|
|
|
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
|
@ -21,34 +15,11 @@ public class Utils { |
|
|
|
|
|
|
|
|
|
private static final Pattern SNIFFER = Pattern.compile("http((?!http).){20,}?\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg)\\?.*|http((?!http).){20,}\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg)|http((?!http).){20,}?\\/m3u8\\?pt=m3u8.*|http((?!http).)*?default\\.ixigua\\.com\\/.*|http((?!http).)*?cdn-tos[^\\?]*|http((?!http).)*?\\/obj\\/tos[^\\?]*|http.*?\\/player\\/m3u8play\\.php\\?url=.*|http.*?\\/player\\/.*?[pP]lay\\.php\\?url=.*|http.*?\\/playlist\\/m3u8\\/\\?vid=.*|http.*?\\.php\\?type=m3u8&.*|http.*?\\/download.aspx\\?.*|http.*?\\/api\\/up_api.php\\?.*|https.*?\\.66yk\\.cn.*|http((?!http).)*?netease\\.com\\/file\\/.*"); |
|
|
|
|
|
|
|
|
|
public static boolean hasPIP() { |
|
|
|
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && App.get().getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void enterPIP(Activity activity) { |
|
|
|
|
try { |
|
|
|
|
if (!hasPIP() || activity.isInPictureInPictureMode()) return; |
|
|
|
|
PictureInPictureParams.Builder builder = new PictureInPictureParams.Builder(); |
|
|
|
|
builder.setAspectRatio(new Rational(16, 9)).build(); |
|
|
|
|
activity.enterPictureInPictureMode(builder.build()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void hideSystemUI(Activity activity) { |
|
|
|
|
int flags = View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
|
|
|
|
activity.getWindow().getDecorView().setSystemUiVisibility(flags); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String getUUID() { |
|
|
|
|
return Settings.Secure.getString(App.get().getContentResolver(), Settings.Secure.ANDROID_ID); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String getUserAgent() { |
|
|
|
|
return Util.getUserAgent(App.get(), App.get().getPackageName().concat(".").concat(getUUID())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static boolean isVideoFormat(String url) { |
|
|
|
|
if (url.contains("=http") || url.contains("=https") || url.contains("=https%3a%2f") || url.contains("=http%3a%2f")) return false; |
|
|
|
|
if (SNIFFER.matcher(url).find()) return !url.contains("cdn-tos") || (!url.contains(".js") && !url.contains(".css")); |
|
|
|
|
|