搜书大师 v23.2版本的 MD5 值为:5ee433f6456b6278bd6e80a5d44df55e
以下内容为反编译后的 z2.java 源代码,内容仅作参考
package com.flyersoft.baseapplication;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.StrictMode;
import android.text.Html;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.webkit.CookieManager;
import android.webkit.MimeTypeMap;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.EditText;
import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.FileProvider;
import cd.InterfaceC0548;
import com.flyersoft.baseapplication.applocation.BaseMainApplication;
import com.ksdk.ssds.manager.b;
import com.lygame.aaa.e50;
import com.lygame.aaa.pl2;
import com.lygame.aaa.rv;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.StringReader;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import javax.net.ssl.HttpsURLConnection;
public class z2 {
public static final String ABOUT_THIRD_SOURCE = "about_third_source.htm";
public static final String ABOUT_THIRD_SOURCE2 = "about_third_source2.htm";
public static final String DELETE_SELF_COMM = "这个操作是删除自己的短评, 删除短评将不可恢复,是否删除?";
private static final String[][] MIME_MapTable = {new String[]{".3gp", "video/3gpp"}, new String[]{".apk", "application/vnd.android.package-archive"}, new String[]{".asf", "video/x-ms-asf"}, new String[]{".avi", "video/x-msvideo"}, new String[]{".bin", "application/octet-stream"}, new String[]{".bmp", "image/bmp"}, new String[]{".class", "application/octet-stream"}, new String[]{".doc", "application/msword"}, new String[]{".exe", "application/octet-stream"}, new String[]{".gif", "image/gif"}, new String[]{".gtar", "application/x-gtar"}, new String[]{".gz", "application/x-gzip"}, new String[]{".jar", "application/java-archive"}, new String[]{".jpeg", "image/jpeg"}, new String[]{".jpg", "image/jpeg"}, new String[]{".m3u", "audio/x-mpegurl"}, new String[]{".m4a", "audio/mp4a-latm"}, new String[]{".m4b", "audio/mp4a-latm"}, new String[]{".m4p", "audio/mp4a-latm"}, new String[]{".m4u", "video/vnd.mpegurl"}, new String[]{".m4v", "video/x-m4v"}, new String[]{".mov", "video/quicktime"}, new String[]{".mp2", "audio/x-mpeg"}, new String[]{".mp3", "audio/x-mpeg"}, new String[]{".mp4", "video/mp4"}, new String[]{".mpc", "application/vnd.mpohun.certificate"}, new String[]{".mpe", "video/mpeg"}, new String[]{".mpeg", "video/mpeg"}, new String[]{".mpg", "video/mpeg"}, new String[]{".mpg4", "video/mp4"}, new String[]{".mpga", "audio/mpeg"}, new String[]{".msg", "application/vnd.ms-outlook"}, new String[]{".ogg", "audio/ogg"}, new String[]{".pdf", "application/pdf"}, new String[]{".doc", "application/doc"}, new String[]{".doc", "application/mkv"}, new String[]{e50.ja, "image/png"}, new String[]{".pps", "application/vnd.ms-powerpoint"}, new String[]{".ppt", "application/vnd.ms-powerpoint"}, new String[]{".rar", "application/x-rar-compressed"}, new String[]{".rmvb", "video/x-pn-realaudio"}, new String[]{".rm", "video/x-pn-realaudio"}, new String[]{".rtf", "application/rtf"}, new String[]{".tar", "application/x-tar"}, new String[]{".tgz", "application/x-compressed"}, new String[]{".wav", "audio/x-wav"}, new String[]{".wma", "audio/x-ms-wma"}, new String[]{".wmv", "audio/x-ms-wmv"}, new String[]{".wps", "application/vnd.ms-works"}, new String[]{".z", "application/x-compress"}, new String[]{".zip", "application/zip"}, new String[]{"", InterfaceC0548.f1142}};
public static final String POST_LOCKED = "当前页已被锁定, 不能评论";
public static String SELECTED_URL = "http://www.moonreader.cn/downloader/";
public static String appDetailInfo;
public static ArrayList<String> blockBookList;
public static ArrayList<String> blockFullList;
public static String channel;
private static boolean disabledUriExpose;
public static String download_cache_path;
public static boolean enableZk;
public static boolean firstTimeInstall;
private static Toast mToast;
public static boolean night;
public static int onlineAppVersion;
public static long qqNumber;
public static int replaceGdtWithTT;
private static String rom_info;
public static boolean signatureFailed;
public static String signatureSerial;
public static String signatureSubject;
public static boolean splashDownloadAsk;
public static boolean splashTapBar;
public static int storeLevel;
public static int useOtherAd;
public static String verifyKey;
public static String xml_files_folder;
public interface FileResultOK {
boolean isResultOk(String filename);
}
public static class ShuPingViewClient extends WebViewClient {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, final String url) {
if (z2.openAppInWebView(url)) {
return true;
}
view.loadUrl(url);
return true;
}
}
public static AlertDialog.Builder alertDialog(Context context) {
return new AlertDialog.Builder(context, night ? R.style.AlertDialogStyleNight : R.style.AlertDialogStyleDay);
}
public static void animateInfoPanel(Context context, final View v, boolean visible) {
Animation loadAnimation = AnimationUtils.loadAnimation(context, !visible ? R.anim.menu_top_right2 : R.anim.menu_top_right);
if (visible) {
v.setVisibility(0);
loadAnimation.setDuration(200L);
} else {
loadAnimation.setDuration(100L);
loadAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
v.setVisibility(8);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationStart(Animation animation) {
}
});
}
v.startAnimation(loadAnimation);
}
public static boolean appendFileText(String filename, String text) {
BufferedWriter bufferedWriter;
if (!createFolder(getFilePath(filename))) {
return false;
}
BufferedWriter bufferedWriter2 = null;
try {
try {
bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename, true)));
} catch (Exception e) {
e = e;
}
} catch (Throwable th) {
th = th;
}
try {
bufferedWriter.write(text);
try {
bufferedWriter.close();
} catch (Exception e2) {
error(e2);
}
return true;
} catch (Exception e3) {
e = e3;
bufferedWriter2 = bufferedWriter;
error(e);
if (bufferedWriter2 != null) {
try {
bufferedWriter2.close();
} catch (Exception e4) {
error(e4);
}
}
return false;
} catch (Throwable th2) {
th = th2;
bufferedWriter2 = bufferedWriter;
if (bufferedWriter2 != null) {
try {
bufferedWriter2.close();
} catch (Exception e5) {
error(e5);
}
}
throw th;
}
}
public static boolean bitmapToFile(Bitmap bm, String filename) {
FileOutputStream fileOutputStream;
if (!createFolder(getFilePath(filename))) {
return false;
}
FileOutputStream fileOutputStream2 = null;
try {
try {
fileOutputStream = new FileOutputStream(filename);
} catch (Throwable th) {
th = th;
}
} catch (Exception e) {
e = e;
} catch (OutOfMemoryError unused) {
}
try {
if (!filename.endsWith(".jpg") && !filename.endsWith(".jpeg")) {
bm.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
fileOutputStream.close();
return true;
}
bm.compress(Bitmap.CompressFormat.JPEG, 90, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
fileOutputStream.close();
return true;
} catch (Exception e2) {
e = e2;
fileOutputStream2 = fileOutputStream;
e.printStackTrace();
if (fileOutputStream2 != null) {
try {
fileOutputStream2.close();
} catch (Exception e3) {
e3.printStackTrace();
}
}
return false;
} catch (OutOfMemoryError unused2) {
fileOutputStream2 = fileOutputStream;
System.gc();
if (fileOutputStream2 != null) {
try {
fileOutputStream2.close();
} catch (Exception e4) {
e4.printStackTrace();
}
}
return false;
} catch (Throwable th2) {
th = th2;
fileOutputStream2 = fileOutputStream;
if (fileOutputStream2 != null) {
try {
fileOutputStream2.close();
} catch (Exception e5) {
e5.printStackTrace();
}
}
throw th;
}
}
public static boolean bookInBlockList(String name) {
if (isNull(name)) {
return true;
}
ArrayList<String> arrayList = blockBookList;
if (arrayList != null) {
Iterator<String> it = arrayList.iterator();
while (it.hasNext()) {
String next = it.next();
if (name.equals(next)) {
return true;
}
if (name.startsWith(next) && name.length() > next.length() && Character.getType(name.charAt(next.length())) != 5) {
return true;
}
}
}
ArrayList<String> arrayList2 = blockFullList;
if (arrayList2 == null) {
return false;
}
Iterator<String> it2 = arrayList2.iterator();
while (it2.hasNext()) {
if (name.contains((String) it2.next())) {
return true;
}
}
return false;
}
public static boolean charIsNumber(char c) {
return c >= '0' && c <= '9';
}
public static String chinaDate(Long time) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("", Locale.SIMPLIFIED_CHINESE);
simpleDateFormat.applyPattern("yyyy年MM月dd日");
return simpleDateFormat.format(time);
}
public static String chinaTime(Long time) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("", Locale.SIMPLIFIED_CHINESE);
simpleDateFormat.applyPattern("yyyy年MM月dd日 HH时mm分ss秒");
return simpleDateFormat.format(time);
}
public static int colorValue(int color) {
return Color.red(color) + Color.green(color) + Color.blue(color);
}
public static boolean createFolder(String path) {
if (isNull(path)) {
return false;
}
File file = new File(path);
if (file.isFile()) {
return false;
}
return file.exists() || file.mkdirs();
}
public static WebView createShuPingBrowser(ViewGroup parent) {
WebView webView = new WebView(parent.getContext());
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setDatabaseEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setMixedContentMode(0);
webView.setWebViewClient(new ShuPingViewClient());
CookieManager.getInstance().setAcceptCookie(true);
CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
parent.addView(webView, -1, -1);
return webView;
}
public static int d(float i) {
return (int) (i * getDensity());
}
public static String dateTimeToStr(Long time) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("", Locale.US);
simpleDateFormat.applyPattern("yyyy-MM-dd HH:mm:ss");
return simpleDateFormat.format(time);
}
public static long day(long day) {
return day * 24 * 60 * 60 * 1000;
}
public static void deleteFile(String filename) {
File file = new File(filename);
if (file.isFile()) {
file.delete();
}
}
public static float df(float i) {
return i * getDensity();
}
public static void disableUriExpose() {
if (Build.VERSION.SDK_INT < 24 || disabledUriExpose) {
return;
}
try {
disabledUriExpose = true;
StrictMode.class.getMethod("disableDeathOnFileUriExposure", new Class[0]).invoke(null, new Object[0]);
} catch (Exception e) {
e.printStackTrace();
}
}
public static Bitmap drawableToBitmap(Drawable d) {
if (d == null) {
return null;
}
if (d instanceof BitmapDrawable) {
return ((BitmapDrawable) d).getBitmap();
}
return drawableToBitmap(d, d.getIntrinsicWidth(), d.getIntrinsicHeight());
}
public static void error(Throwable e) {
error(e, true);
}
public static String errorMsg(Throwable e) {
String message = e.getMessage();
if (message != null) {
return message;
}
try {
return e.toString();
} catch (Throwable th) {
th.printStackTrace();
return "";
}
}
public static String errorSaveFile() {
String str = "";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("", Locale.US);
simpleDateFormat.applyPattern("MM.dd");
try {
str = "" + getContext().getPackageManager().getPackageInfo(getContext().getPackageName(), 0).versionCode;
} catch (PackageManager.NameNotFoundException unused) {
}
return download_cache_path + "/err/err" + str + "_" + simpleDateFormat.format(Long.valueOf(System.currentTimeMillis())) + ".txt";
}
public static void forceTextViewNightColor(View v) {
forceTextViewNightColor(v, null);
}
public static int getBaseColor() {
return getContext().getResources().getColor(R.color.base_color);
}
public static Context getContext() {
return BaseMainApplication.application.getApplicationContext();
}
public static float getDensity() {
return Resources.getSystem().getDisplayMetrics().density;
}
public static String getFileExt(String filename) {
int lastIndexOf;
return (filename == null || (lastIndexOf = filename.lastIndexOf(".")) == -1) ? "" : filename.substring(lastIndexOf).toLowerCase();
}
public static OutputStream getFileOutputStream(String filename) {
return getFileOutputStream(filename, false);
}
public static String getFilePath(String filename) {
int lastIndexOf;
return (isNull(filename) || (lastIndexOf = filename.lastIndexOf(b.b)) == -1) ? "" : filename.substring(0, lastIndexOf);
}
public static long getFileSize(String filename) {
if (isNull(filename)) {
return 0L;
}
File file = new File(filename);
if (file.isFile()) {
return file.length();
}
return 0L;
}
public static String getFileText(String filename) {
return getFileText(filename, "UTF-8");
}
public static String getFilename(String filename) {
if (filename == null) {
return "";
}
int indexOf = filename.indexOf("?");
if (indexOf != -1) {
filename = filename.substring(indexOf + 1);
}
int lastIndexOf = filename.lastIndexOf(b.b);
return lastIndexOf == -1 ? filename : filename.substring(lastIndexOf + 1);
}
public static String getMIMEType(String filename) {
int lastIndexOf;
if (filename == null || (lastIndexOf = filename.lastIndexOf(".")) < 0) {
return InterfaceC0548.f1142;
}
int i = lastIndexOf + 1;
String mimeTypeFromExtension = MimeTypeMap.getSingleton().getMimeTypeFromExtension(filename.substring(i));
if (mimeTypeFromExtension != null) {
return mimeTypeFromExtension;
}
String lowerCase = filename.substring(lastIndexOf).toLowerCase();
int i2 = 0;
while (true) {
String[][] strArr = MIME_MapTable;
if (i2 < strArr.length) {
if (lowerCase.equals(strArr[i2][0])) {
return strArr[i2][1];
}
i2++;
} else {
return "application/" + filename.substring(i).toLowerCase();
}
}
}
public static long getNetTime() {
log("local: " + dateTimeToStr(Long.valueOf(System.currentTimeMillis())));
long netTime = getNetTime("http://www.baidu.com");
if (netTime != 0) {
return netTime;
}
long netTime2 = getNetTime("http://www.163.com");
return netTime2 == 0 ? getNetTime("http://www.qq.com") : netTime2;
}
public static String getOnlyFilename(String filename) {
if (filename == null) {
return "";
}
String filename2 = getFilename(filename);
int lastIndexOf = filename2.lastIndexOf(".");
return lastIndexOf == -1 ? filename2 : filename2.substring(0, lastIndexOf);
}
public static String getROMInfo() {
if (rom_info == null) {
StringBuilder sb = new StringBuilder();
try {
sb.append("*" + Build.MODEL + " (" + Build.CPU_ABI);
sb.append(", " + Build.MANUFACTURER + ", " + Build.PRODUCT + ", " + Build.ID + ")\n");
} catch (Exception e) {
error(e);
}
rom_info = sb.toString().toLowerCase();
}
return rom_info;
}
public static int getScreenHeight() {
return getContext().getResources().getDisplayMetrics().heightPixels;
}
public static int getScreenWidth() {
return getContext().getResources().getDisplayMetrics().widthPixels;
}
public static int getSelectedBorderlessRes(Context context) {
return getThemeResId(context, R.attr.selectableItemBackgroundBorderless);
}
public static int getSelectedRes(Context context) {
return getThemeResId(context, R.attr.selectableItemBackground);
}
public static String getShortText(String s) {
return s.substring(0, s.length() <= 10 ? s.length() : 10);
}
public static String getSourcesAboutText(boolean isWorkTime) {
String inputStream2String;
String str = isWorkTime ? ABOUT_THIRD_SOURCE2 : ABOUT_THIRD_SOURCE;
try {
if (isFile(xml_files_folder + b.b + str)) {
inputStream2String = getFileText(xml_files_folder + b.b + str);
} else {
inputStream2String = inputStream2String(getContext().getAssets().open(str));
}
return inputStream2String;
} catch (Exception e) {
error(e);
return "";
}
}
public static int getThemeResId(Context context, int id) {
TypedValue typedValue = new TypedValue();
context.getTheme().resolveAttribute(id, typedValue, true);
return typedValue.resourceId;
}
public static Uri getUriProvider(Context a, File file) {
Uri fromFile;
if (Build.VERSION.SDK_INT >= 24) {
fromFile = FileProvider.getUriForFile(a, a.getPackageName() + ".fileprovider", file);
} else {
fromFile = Uri.fromFile(file);
}
log("getUriProvider:" + fromFile);
return fromFile;
}
public static String getUrlText(String url_str) {
return getUrlText(url_str, "");
}
public static void hideToast() {
Toast toast = mToast;
if (toast != null) {
toast.cancel();
}
}
public static CharSequence highlight(String text, String key) {
int indexOf;
if (text == null || key == null || (indexOf = text.indexOf(key)) == -1) {
return text;
}
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(text);
spannableStringBuilder.setSpan(new ForegroundColorSpan(getBaseColor()), indexOf, key.length() + indexOf, 33);
return spannableStringBuilder;
}
public static long hour(long hour) {
return hour * 60 * 60 * 1000;
}
public static boolean inputStream2File(InputStream is, String filename) {
if (!createFolder(getFilePath(filename))) {
return false;
}
OutputStream outputStream = null;
try {
try {
OutputStream fileOutputStream = getFileOutputStream(filename);
if (fileOutputStream == null) {
if (fileOutputStream != null) {
try {
fileOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
if (is != null) {
is.close();
}
return false;
}
byte[] bArr = new byte[8192];
while (true) {
int read = is.read(bArr);
if (read == -1) {
break;
}
fileOutputStream.write(bArr, 0, read);
}
try {
fileOutputStream.close();
is.close();
} catch (Exception e2) {
e2.printStackTrace();
}
return true;
} catch (Throwable th) {
if (0 != 0) {
try {
outputStream.close();
} catch (Exception e3) {
e3.printStackTrace();
throw th;
}
}
if (is != null) {
is.close();
}
throw th;
}
} catch (Exception e4) {
e4.printStackTrace();
if (0 != 0) {
try {
outputStream.close();
} catch (Exception e5) {
e5.printStackTrace();
return false;
}
}
if (is != null) {
is.close();
}
return false;
}
}
public static String inputStream2String(InputStream is) {
return inputStream2String(is, "UTF-8", 0);
}
public static boolean isFile(String filename) {
if (isNull(filename)) {
return false;
}
return new File(filename).isFile();
}
public static boolean isFolder(String folder) {
if (folder == null || folder.equals("")) {
return false;
}
return new File(folder).isDirectory();
}
public static boolean isHttp(String url) {
return !isNull(url) && url.toLowerCase().startsWith(rv.a) && url.contains(".") && url.length() > 10;
}
public static boolean isNetworkConnecting() {
try {
NetworkInfo activeNetworkInfo = ((ConnectivityManager) getContext().getSystemService("connectivity")).getActiveNetworkInfo();
if (activeNetworkInfo == null) {
return false;
}
return activeNetworkInfo.isConnected();
} catch (Exception e) {
error(e);
return false;
}
}
public static boolean isNull(String s) {
return s == null || s.length() == 0;
}
public static boolean isOldAppVersion() {
try {
if (onlineAppVersion > 0) {
return getContext().getPackageManager().getPackageInfo(getContext().getPackageName(), 0).versionCode < onlineAppVersion;
}
return false;
} catch (Exception unused) {
return false;
}
}
public static boolean isWhiteFont(int color) {
return colorValue(color) > 355;
}
public static boolean isWorkTime() {
long netTime = isNetworkConnecting() ? getNetTime() : 0L;
if (netTime == 0) {
netTime = System.currentTimeMillis();
}
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(netTime);
calendar.setTimeZone(TimeZone.getTimeZone("GMT+8"));
int i = calendar.get(7);
int i2 = calendar.get(11);
log("day:" + i + " hour:" + i2);
return i != 1 && i != 7 && i2 >= 9 && i2 < 18;
}
public static boolean isYousuuEmptyPic(String url) {
return url != null && url.toLowerCase().endsWith("uifqcd.jpg");
}
public static void log(String s) {
}
public static long minute(long minute) {
return minute * 60 * 1000;
}
public static int myRandom(int range) {
return new Double(Math.ceil(Math.random() * range)).intValue() - 1;
}
public static void notifyAlbumUpdate(final Context context, String imageFile) {
try {
Intent intent = new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE");
intent.setData(Uri.fromFile(new File(imageFile)));
context.sendBroadcast(intent);
} catch (Exception e) {
error(e);
}
}
public static boolean openAppInWebView(String url) {
try {
if (url.startsWith("http:") || url.startsWith("https:")) {
return false;
}
getContext().startActivity(new Intent("android.intent.action.VIEW", Uri.parse(url)));
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public static boolean openMarketPage(Context con) {
try {
con.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("market://details?id=" + con.getPackageName())));
return true;
} catch (Exception e) {
error(e);
return false;
}
}
public static URLConnection openUrlConnection(String url_str) throws Exception {
return openUrlConnection(url_str, null, null);
}
public static PopupMenu popupMenu(Context context, View view) {
if (night) {
return new PopupMenu(new ContextThemeWrapper(context, R.style.PopMenuNight), view);
}
return new PopupMenu(context, view);
}
public static boolean saveFileText(String filename, String text, String encoding) {
if (isNull(filename) || text == null) {
return false;
}
try {
if (encoding == null) {
return saveFileText(filename, text);
}
return inputStream2File(new ByteArrayInputStream(text.getBytes(encoding)), filename);
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public static void sendFile(Context context, String filename) {
try {
Intent intent = new Intent("android.intent.action.SEND");
intent.putExtra("android.intent.extra.EMAIL", new String[]{""});
intent.setType(getMIMEType(filename));
intent.putExtra("android.intent.extra.STREAM", getUriProvider(context, new File(filename)));
intent.putExtra("android.intent.extra.SUBJECT", "");
intent.putExtra("android.intent.extra.TEXT", "");
intent.addFlags(1);
intent.addFlags(268435456);
context.startActivity(Intent.createChooser(intent, "发送文件"));
} catch (Exception e) {
error(e);
}
}
private static void setToastColors() {
View view;
if (Build.VERSION.SDK_INT < 28 || getROMInfo().contains("xiaomi") || getROMInfo().contains("samsung") || (view = mToast.getView()) == null) {
return;
}
view.setBackgroundResource(R.drawable.round_grey);
TextView textView = (TextView) view.findViewById(android.R.id.message);
if (textView != null) {
textView.setTextColor(-1);
}
}
public static void showToastText(final CharSequence text) {
new Handler(getContext().getMainLooper()).post(new Runnable() {
@Override
public void run() {
z2.showToastText(z2.getContext(), text, 1);
}
});
}
public static float string2Float(String s) {
if (isNull(s)) {
return 0.0f;
}
int i = 0;
while (i < s.length() && s.charAt(i) != '.' && s.charAt(i) != '-' && (s.charAt(i) < '0' || s.charAt(i) > '9')) {
i++;
}
int i2 = i;
while (i2 < s.length() && (s.charAt(i2) == '.' || s.charAt(i2) == '-' || (s.charAt(i2) >= '0' && s.charAt(i2) <= '9'))) {
i2++;
}
try {
return Float.valueOf(s.substring(i, i2)).floatValue();
} catch (Exception e) {
error(e);
return 0.0f;
}
}
public static int string2Int(String s) {
if (isNull(s)) {
return 0;
}
int i = 0;
while (i < s.length() && ((s.charAt(i) < '0' || s.charAt(i) > '9') && s.charAt(i) != '-')) {
i++;
}
int i2 = i;
while (i2 < s.length() && ((s.charAt(i2) >= '0' && s.charAt(i2) <= '9') || (i == i2 && s.charAt(i2) == '-'))) {
i2++;
}
try {
return Integer.valueOf(s.substring(i, i2)).intValue();
} catch (Exception e) {
error(e);
return 0;
}
}
public static String stringList2Text(ArrayList<String> list) {
StringBuilder sb = new StringBuilder();
if (list != null) {
Iterator<String> it = list.iterator();
while (it.hasNext()) {
sb.append(it.next() + "\n");
}
}
return sb.toString();
}
public static ArrayList<String> text2StringList(String text) {
ArrayList<String> arrayList = new ArrayList<>();
if (isNull(text)) {
return arrayList;
}
int i = 0;
String replace = text.replace(pl2.e, "");
while (true) {
int indexOf = replace.indexOf("\n", i);
if (indexOf == -1) {
break;
}
arrayList.add(replace.substring(i, indexOf));
i = indexOf + 1;
}
if (i < replace.length()) {
arrayList.add(replace.substring(i));
}
return arrayList;
}
public static Drawable zoomDrawable(Resources res, Drawable d, int w, int h) {
try {
if (d instanceof BitmapDrawable) {
return new BitmapDrawable(res, Bitmap.createScaledBitmap(((BitmapDrawable) d).getBitmap(), w, h, true));
}
return new BitmapDrawable(res, drawableToBitmap(d, w, h));
} catch (Exception e) {
e.printStackTrace();
return d;
}
}
public static Bitmap zoomImage(Bitmap bm, int newWidth, int newHeight) {
if (newWidth <= 0) {
newWidth = 1;
}
if (newHeight <= 0) {
newHeight = 1;
}
try {
int width = bm.getWidth();
int height = bm.getHeight();
Matrix matrix = new Matrix();
matrix.postScale(newWidth / width, newHeight / height);
return Bitmap.createBitmap(bm, 0, 0, width, height, matrix, true);
} catch (Exception e) {
e.printStackTrace();
return bm;
} catch (OutOfMemoryError unused) {
System.gc();
return bm;
}
}
public static void error(Throwable e, boolean saveLogToFile) {
try {
if (e instanceof OutOfMemoryError) {
log("####OutOfMemoryError####-----------------------------------");
return;
}
log("####ERROR####-----------------------------------");
String errorMsg = errorMsg(e);
log(errorMsg + "##");
e.printStackTrace();
if (saveLogToFile) {
StringBuilder sb = new StringBuilder();
sb.append("\n\n-------" + dateTimeToStr(Long.valueOf(System.currentTimeMillis())) + "-------\n");
sb.append(errorMsg);
sb.append("\n-");
for (StackTraceElement stackTraceElement : e.getStackTrace()) {
sb.append("\n" + stackTraceElement.toString());
}
if (getFileSize(errorSaveFile()) > 100000) {
deleteFile(errorSaveFile());
}
appendFileText(errorSaveFile(), sb.toString());
}
} catch (Throwable th) {
th.printStackTrace();
}
}
public static void forceTextViewNightColor(View v, ArrayList<View> ignore) {
if (v instanceof TextView) {
TextView textView = (TextView) v;
if (v instanceof EditText) {
((EditText) v).setHintTextColor(-10395295);
}
if (isWhiteFont(textView.getCurrentTextColor())) {
return;
}
textView.setTextColor(getContext().getResources().getColor(R.color.material_grey_200));
return;
}
if (v instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) v;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
forceTextViewNightColor(viewGroup.getChildAt(i), ignore);
}
}
}
public static OutputStream getFileOutputStream(String filename, boolean append) {
if (!createFolder(getFilePath(filename))) {
return null;
}
try {
return new FileOutputStream(filename, append);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static String getFileText(String filename, String encoding) {
try {
return getFileText(filename, encoding, true);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static String getUrlText(String url_str, String user_agent) {
try {
URLConnection openUrlConnection = isNull(user_agent) ? openUrlConnection(url_str) : new URL(url_str).openConnection();
if (!isNull(user_agent)) {
openUrlConnection.setRequestProperty("User-Agent", user_agent);
}
return inputStream2String(openUrlConnection.getInputStream());
} catch (Exception e) {
error(e, false);
return null;
}
}
public static String inputStream2String(InputStream is, String encoding) {
return inputStream2String(is, encoding, 0);
}
public static boolean isNull(CharSequence s) {
return s == null || s.length() == 0;
}
public static URLConnection openUrlConnection(String url_str, String user_agent) throws Exception {
return openUrlConnection(url_str, user_agent, null);
}
public static void showToastText(final String title, final String text) {
new Handler(getContext().getMainLooper()).post(new Runnable() {
@Override
public void run() {
z2.showToastText(z2.getContext(), title, text, 1);
}
});
}
public static String inputStream2String(InputStream is, String encoding, int type) {
BufferedReader bufferedReader;
StringBuilder sb;
if (is == null) {
return "";
}
StringBuilder sb2 = null;
try {
try {
int available = is.available();
try {
if (type == 0 && available > 0) {
sb = new StringBuilder(available + 16);
} else {
sb = new StringBuilder();
}
sb2 = sb;
} catch (OutOfMemoryError e) {
error(e);
sb2 = new StringBuilder();
}
if (encoding.equals("")) {
bufferedReader = new BufferedReader(new InputStreamReader(is));
} else {
bufferedReader = new BufferedReader(new InputStreamReader(is, encoding));
}
if (type == 1) {
sb2.append(bufferedReader.readLine());
} else {
char[] cArr = new char[type == 0 ? 8192 : 100];
do {
int read = bufferedReader.read(cArr);
if (read != -1) {
sb2.append(String.valueOf(cArr, 0, read));
}
if (read == -1) {
break;
}
} while (type == 0);
bufferedReader.close();
}
return sb2.toString();
} catch (OutOfMemoryError unused) {
System.gc();
if (sb2 != null) {
return "";
}
try {
return sb2.toString();
} catch (OutOfMemoryError unused2) {
System.gc();
return "";
}
}
} catch (Exception e2) {
error(e2);
if (sb2 != null) {
}
}
}
public static boolean isNull(List<?> list) {
return list == null || list.size() == 0;
}
public static URLConnection openUrlConnection(String url_str, String user_agent, String cookies) throws Exception {
URL url = new URL(url_str);
URLConnection openConnection = url.openConnection();
if (!isNull(user_agent)) {
openConnection.setRequestProperty("User-agent", user_agent);
}
if (!isNull(cookies)) {
openConnection.setRequestProperty("Cookie", cookies);
}
if (openConnection instanceof HttpsURLConnection) {
return openConnection;
}
String headerField = openConnection.getHeaderField("Location");
if (isNull(headerField) || headerField.equals(url.toString())) {
return openConnection;
}
log("redirect to: " + headerField);
return new URL(headerField).openConnection();
}
public static void showToastText(Context context, CharSequence text) {
showToastText(context, text, 0);
}
public static String getFileText(String str, String str2, boolean z) throws Exception {
BufferedReader bufferedReader;
InputStream inputStream = null;
r0 = null;
inputStream = null;
StringBuilder sb = null;
if (str == null || str2 == null) {
return null;
}
File file = new File(str);
?? isFile = file.isFile();
try {
if (isFile == 0) {
return null;
}
try {
try {
isFile = new DataInputStream(new FileInputStream(str));
try {
try {
if (str2.equals("")) {
bufferedReader = new BufferedReader(new InputStreamReader(isFile));
} else {
bufferedReader = new BufferedReader(new InputStreamReader((InputStream) isFile, str2));
}
try {
sb = new StringBuilder(((int) file.length()) + 16);
} catch (OutOfMemoryError e) {
e.printStackTrace();
sb = new StringBuilder();
}
char[] cArr = new char[8192];
while (true) {
int read = bufferedReader.read(cArr);
if (read == -1) {
break;
}
sb.append(String.valueOf(cArr, 0, read));
}
bufferedReader.close();
String sb2 = sb.toString();
try {
isFile.close();
} catch (Exception e2) {
e2.printStackTrace();
}
return sb2;
} catch (OutOfMemoryError e3) {
e = e3;
e.printStackTrace();
System.gc();
if (!z && sb != null && sb.length() > 0) {
try {
String sb3 = sb.toString();
if (isFile != 0) {
try {
isFile.close();
} catch (Exception e4) {
e4.printStackTrace();
}
}
return sb3;
} catch (OutOfMemoryError e5) {
throw new Exception(e5);
}
}
throw new Exception(e);
}
} catch (Exception e6) {
e = e6;
inputStream = isFile;
e.printStackTrace();
throw new Exception(e);
}
} catch (Throwable th) {
th = th;
if (inputStream != null) {
}
throw th;
}
} catch (Exception e7) {
e = e7;
} catch (OutOfMemoryError e8) {
e = e8;
isFile = 0;
}
} catch (Throwable th2) {
th = th2;
inputStream = isFile;
if (inputStream != null) {
try {
inputStream.close();
} catch (Exception e9) {
e9.printStackTrace();
}
}
throw th;
}
}
public static void showToastText(Context context, CharSequence text, int duration) {
showToastText(context, text, duration, 80);
}
private static long getNetTime(String url_str) {
try {
URLConnection openConnection = new URL(url_str).openConnection();
openConnection.connect();
long date = openConnection.getDate();
log("remote: " + dateTimeToStr(Long.valueOf(date)));
return date;
} catch (Exception e) {
error(e);
return 0L;
}
}
public static void showToastText(Context context, CharSequence text, int duration, int gravity) {
try {
if (mToast != null) {
if (Build.VERSION.SDK_INT >= 26) {
mToast.cancel();
mToast = Toast.makeText(context, text, duration);
} else {
mToast.setText(text);
mToast.setDuration(duration);
}
} else {
mToast = Toast.makeText(context, text, duration);
}
mToast.setGravity(gravity, 0, gravity == 80 ? getScreenHeight() / 10 : 0);
setToastColors();
mToast.show();
log("Toast: " + text.toString());
} catch (Throwable th) {
error(th);
hideToast();
}
}
public static Bitmap drawableToBitmap(Drawable d, int width, int height) {
return drawableToBitmap(d, width, height, false);
}
public static boolean saveFileText(String filename, String text) {
if (isNull(filename) || text == null) {
return false;
}
BufferedReader bufferedReader = null;
try {
try {
if (!createFolder(getFilePath(filename))) {
return false;
}
File file = new File(filename);
BufferedReader bufferedReader2 = new BufferedReader(new StringReader(text));
try {
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file));
char[] cArr = new char[1024];
while (true) {
int read = bufferedReader2.read(cArr);
if (read != -1) {
bufferedWriter.write(cArr, 0, read);
} else {
bufferedWriter.flush();
bufferedReader2.close();
bufferedWriter.close();
try {
bufferedReader2.close();
return true;
} catch (Exception e) {
e.printStackTrace();
return true;
}
}
}
} catch (Exception e2) {
e = e2;
bufferedReader = bufferedReader2;
e.printStackTrace();
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (Exception e3) {
e3.printStackTrace();
}
}
return false;
} catch (OutOfMemoryError e4) {
e = e4;
bufferedReader = bufferedReader2;
e.printStackTrace();
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (Exception e5) {
e5.printStackTrace();
}
}
return false;
} catch (Throwable th) {
th = th;
bufferedReader = bufferedReader2;
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (Exception e6) {
e6.printStackTrace();
}
}
throw th;
}
} catch (Throwable th2) {
th = th2;
}
} catch (Exception e7) {
e = e7;
} catch (OutOfMemoryError e8) {
e = e8;
}
}
public static Bitmap drawableToBitmap(Drawable d, int width, int height, boolean copy) {
if (!copy) {
try {
if ((d instanceof BitmapDrawable) && d.getIntrinsicWidth() == width && d.getIntrinsicHeight() == height) {
return ((BitmapDrawable) d).getBitmap();
}
} catch (Exception e) {
e.printStackTrace();
return null;
} catch (OutOfMemoryError e2) {
System.gc();
e2.printStackTrace();
return null;
}
}
Bitmap.Config config = d.getOpacity() != -1 ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
if (width <= 0) {
width = 1;
}
if (height <= 0) {
height = 1;
}
Bitmap createBitmap = Bitmap.createBitmap(width, height, config);
Canvas canvas = new Canvas(createBitmap);
d.setBounds(0, 0, width, height);
d.draw(canvas);
return createBitmap;
}
public static void showToastText(Context context, String title, String text, int duration) {
showToastText(context, title, text, duration, 80);
}
public static void showToastText(Context context, String title, String text, int duration, int gravity) {
Spanned fromHtml;
if (Build.VERSION.SDK_INT >= 26) {
fromHtml = Html.fromHtml("" + title + "<br>" + text);
} else {
fromHtml = Html.fromHtml("<b><font color=\"#FFFF00\">" + title + "</font></b><br>" + text);
}
showToastText(context, fromHtml, duration, gravity);
}
}