优化项目结构

This commit is contained in:
xuhuixiang
2025-03-18 17:08:36 +08:00
parent 052d034696
commit 679b3b3ce3
52 changed files with 58 additions and 630 deletions

View File

@@ -4,10 +4,10 @@ package com.web.FreeAUD;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import com.web.base.MainActivity2;
import com.google.firebase.messaging.FirebaseMessaging;
public class MainActivity extends com.web.base.MainActivity2 {
public class MainActivity extends MainActivity2 {
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -28,11 +28,6 @@ public class MainActivity extends com.web.base.MainActivity2 {
//订阅主题
FirebaseMessaging.getInstance().subscribeToTopic("demo")
.addOnCompleteListener(task -> {
String msg = "Subscribed";
if (!task.isSuccessful()) {
msg = "Subscribe failed";
}
});
}
@@ -45,7 +40,5 @@ public class MainActivity extends com.web.base.MainActivity2 {
} catch (PackageManager.NameNotFoundException e) {
return 0;
}
}
}

View File

@@ -7,16 +7,13 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.core.app.NotificationCompat;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.google.gson.Gson;
import com.web.base.GsonUtils;
import com.web.base.MessageInfo;
import java.util.Map;
import java.util.Random;
@@ -34,17 +31,12 @@ public class MyFirebaseMessageingService extends FirebaseMessagingService {
Gson gson = new Gson();
MessageInfo messageInfo = gson.fromJson(value, MessageInfo.class);
showNotification(messageInfo);
// if (remoteMessage.getNotification() != null) {
// showNotification(remoteMessage.getNotification().getTitle(), remoteMessage.getNotification().getBody());
// }
} else {
//收到通知 创建notify
if (remoteMessage.getNotification() != null) {
showNotification(remoteMessage.getNotification().getTitle(), remoteMessage.getNotification().getBody());
}
}
}
private void showNotification(MessageInfo messageInfo) {
@@ -57,23 +49,11 @@ public class MyFirebaseMessageingService extends FirebaseMessagingService {
.getComponent();
notifyIntent.setComponent(launchComponent);
}
notifyIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
notifyIntent.setAction(Intent.ACTION_VIEW);
notifyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // 必须
notifyIntent.putExtra("message", messageInfo);
PendingIntent pendingIntent = PendingIntent.getActivity(this, new Random().nextInt(10000), notifyIntent, PendingIntent.FLAG_IMMUTABLE);
// Intent notifyIntent = new Intent(this, MainActivity2.class);
// notifyIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
// // notifyIntent.putExtra("message", messageInfo);
// notifyIntent.setAction(Intent.ACTION_VIEW);
// notifyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // 必须
// PendingIntent pendingIntent;
// pendingIntent = PendingIntent.getActivity
// (this, 0, notifyIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channelwinway = null;
NotificationCompat.Builder notificationBuilder = null;
@@ -113,8 +93,6 @@ public class MyFirebaseMessageingService extends FirebaseMessagingService {
notifyIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
notifyIntent.setAction(Intent.ACTION_VIEW);
notifyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // 必须
PendingIntent pendingIntent = PendingIntent.getActivity(this, new Random().nextInt(10000), notifyIntent, PendingIntent.FLAG_IMMUTABLE);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channelwinway = null;
@@ -143,29 +121,5 @@ public class MyFirebaseMessageingService extends FirebaseMessagingService {
.setContentIntent(pendingIntent);
}
notificationManager.notify(0, notificationBuilder.build());
//存储数据
// saveNotifyMessage(body);
}
// public void saveNotifyMessage(String body) {
// MessageInfo messageInfo = GsonUtils.getObjFromJSON(body, MessageInfo.class);
// String savenotify = Utils.get(getApplication(),ApiService.savenotify,"");
// if(messageInfo!=null){
// if(TextUtils.isEmpty(savenotify)){
// GsonUtils.getListFromJSON(savenotify,)
// }
// }
// String jsonString = GsonUtils.beanToJSONString(chatMessageBeans);
// }
//
// /**
// * @param key 要设置的key
// */
// public static void set(Context activity, String key, String is) {
// SharedPreferences nameSetting = getConfigShared(activity);
// SharedPreferences.Editor namePref = nameSetting.edit();
// namePref.putString(key, is);
// namePref.commit();
// }
}

View File

@@ -2,10 +2,8 @@ package com.web.FreeAUD;
import android.app.Application;
import android.content.Context;
import com.tencent.smtt.export.external.TbsCoreSettings;
import com.tencent.smtt.sdk.QbSdk;
import java.util.HashMap;
public class WebApplication extends Application {

View File

@@ -7,8 +7,6 @@ android {
defaultConfig {
minSdkVersion 24
targetSdkVersion 31
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@@ -77,13 +77,10 @@ public class ActionBankInfoDialog extends Dialog {
recyclerView.setLayoutManager(new LinearLayoutManager(context));
adapter = new MyBankListAdapter(listdata);
recyclerView.setAdapter(adapter);
adapter.setOnItemClick(new MyBankListAdapter.onItemClickPostionListener() {
@Override
public void item(int position) {
adapter.setOnItemClick(position -> {
itemSelector = listdata.get(position);
tvbankName.setText(itemSelector.getBankName());
recyclerView.setVisibility(View.GONE);
}
});
tvbankName.setText(MainActivity.getString(context, "bankname", ""));
@@ -157,12 +154,6 @@ public class ActionBankInfoDialog extends Dialog {
adapter.setListdata(listdata);
listCountryAdapter.setListdata(listcountry);
}
// if (o.data != null && o.data.size() > 0) {
// listdata.clear();
// listdata.addAll(o.data);
// adapter.setListdata(listdata);
// recyclerView.setVisibility(View.VISIBLE);
// }
}

View File

@@ -50,14 +50,11 @@ public class ActionSelectDialog extends Dialog {
shareTv = (TextView) findViewById(R.id.share);
checkTv = (TextView) findViewById(R.id.check);
shareTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
shareTv.setOnClickListener(view -> {
dismiss();
if (onToLoginListener != null) {
onToLoginListener.toShare();
}
}
});
checkTv.setOnClickListener(view -> {
dismiss();
@@ -94,25 +91,5 @@ public class ActionSelectDialog extends Dialog {
window.setAttributes(wlp);
}
// private void fullScreenImmersive(View view) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// | View.SYSTEM_UI_FLAG_FULLSCREEN;
// view.setSystemUiVisibility(uiOptions);
// }
// }
//
// @Override
// public void show() {
// this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
// super.show();
// fullScreenImmersive(getWindow().getDecorView());
// this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
// }
}

View File

@@ -19,8 +19,6 @@ import android.widget.Toast;
public class ActionWithDrawApplyDialog extends Dialog {
private final Context context;
private View lineV;
private EditText inputTxt;
private TextView cancelTv;
private TextView sumbitTv;

View File

@@ -18,7 +18,7 @@ public interface ApiService {
String URL = "https://api.liulao.top/";
// String URL = "http://192.168.8.184:8000/";
public static final String savenotify ="notify";
String savenotify ="notify";
@GET("api/system/applicationConf")

View File

@@ -5,6 +5,7 @@ import android.view.View;
import android.view.Window;
import android.view.WindowManager;
@Deprecated
public class DialogUtil {
/**
* 隐藏虚拟栏 ,显示的时候再隐藏掉

View File

@@ -58,12 +58,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
return;
}
// if(getIntent().getBooleanExtra("isChange",false)){
// toNextActivity();
// }else{
// findViewById(R.id.big_v).setVisibility(View.VISIBLE);
// }
setListener();
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(inputTextView, 10, 50, 2, TypedValue.COMPLEX_UNIT_SP);
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(outputTextView, 10, 50, 2, TypedValue.COMPLEX_UNIT_SP);

View File

@@ -11,13 +11,10 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Color;
import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
@@ -31,14 +28,11 @@ import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.ActionBar;
@@ -46,7 +40,6 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.gson.Gson;
import com.king.app.updater.AppUpdater;
@@ -59,14 +52,12 @@ import com.tencent.smtt.sdk.WebChromeClient;
import com.tencent.smtt.sdk.WebSettings;
import com.tencent.smtt.sdk.WebView;
import com.tencent.smtt.sdk.WebViewClient;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
@@ -78,8 +69,6 @@ public class MainActivity2 extends AppCompatActivity {
LinearLayout layoutError;
ImageView show_top_v;
private ImageView showTopV1;
ImageView menu_iv;
private ImageView helpIv;
private LinearLayout showTopLy;
FloatingActionButton floatingActionButton;
CardView otherApp;
@@ -94,35 +83,17 @@ public class MainActivity2 extends AppCompatActivity {
TextView tvLink;
ImageView ivLinkBg;
CardView ivHome;
String downloadImageUrl = "";
private int requestCode;
private String[] permissions;
private int[] grantResults;
private View topVvvv;
private int index = 0;
private FrameLayout videoContainer;
private ImageView backIv;
private ProgressBar progressBar;
//https://m.xiannvtu.com/
//https://m.xiannvtu.com/
// public static String url = "https://candy916.co/";
public static String url = "https://candy916.co/";
//先定义
private static final int REQUEST_EXTERNAL_STORAGE = 1;
public static int userId = 2;
private int notifyVisible = View.GONE;
private String shareUrl;
private String myInviteCode;
private int myInviteNum;
private int contactApply = 1;
private int notifyApply = 1;
private String facebookUrl = "";
private String whatsappUrl = "";
private String telegramUrl = "";
@@ -143,31 +114,14 @@ public class MainActivity2 extends AppCompatActivity {
recordNotify(messageInfo.getPushId());
}
}
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
// if (Build.VERSION.SDK_INT >= 30) {
// } else {
// setTheme(R.style.AppThemeStart1);
// getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
// getWindow().setStatusBarColor(Color.TRANSPARENT);
// }
// if (Build.VERSION.SDK_INT >= 33) {
// getWindow().setDecorFitsSystemWindows(false);
// } else {
// getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
// }
// super.onCreate(savedInstanceState);
getWindow().setNavigationBarColor(Color.parseColor(MainActivity.getString(MainActivity2.this, "style_color", "#FFFFFF")));
getWindow().getDecorView().setBackgroundColor(Color.parseColor(MainActivity.getString(MainActivity2.this, "windows_color", "#FFFFFF")));
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
super.onCreate(savedInstanceState);
View decor = getWindow().getDecorView();
getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
@@ -181,13 +135,6 @@ public class MainActivity2 extends AppCompatActivity {
actionBar.hide();
}
setContentView(R.layout.activity_main2);
// View bottomV = findViewById(R.id.bottom_v);
// if (Build.VERSION.SDK_INT >= 30) {
// ViewGroup.LayoutParams layoutParams = bottomV.getLayoutParams();
// layoutParams.height = getNavigationBarHeight(this);
// bottomV.setLayoutParams(layoutParams);
// getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
// }
String body = getIntent().getStringExtra("message");
if (!TextUtils.isEmpty(body)) {
MessageInfo messageInfo = GsonUtils.getObjFromJSON(body, MessageInfo.class);
@@ -195,39 +142,14 @@ public class MainActivity2 extends AppCompatActivity {
startActivity(new Intent(MainActivity2.this, NotifyListActivity.class).putExtra("message", messageInfo));
recordNotify(messageInfo.getPushId());
}
// if (messageInfo != null && (messageInfo.getType() == 2 || messageInfo.getType() == 3)) {
// startActivity(new Intent(MainActivity2.this, NotifyDetailsActivity.class).putExtra("message", messageInfo));
// } else {
// recordNotify(messageInfo.getPushId());
// }
}
// FirebaseMessaging.getInstance().getToken()
// .addOnCompleteListener(new OnCompleteListener<String>() {
// @Override
// public void onComplete(@NonNull Task<String> task) {
// if (!task.isSuccessful()) {
// LogUtils.d("Fetching FCM registration token failed" + task.getException());
// return;
// }
//
// // Get new FCM registration token
// String token = task.getResult();
//
// // Log and toast
//
// LogUtils.d("token=="+token);
// }
// });
boolean isDownload = MainActivity.getBoolean(MainActivity2.this, "download", false);
if (!isDownload) {
setDownloadNumbers();
}
initView();
// setopHeight();
findViewById(R.id.back_iv).setOnClickListener(view -> onBackPressed());
floatingActionButton = findViewById(R.id.bt_menu);
otherApp = findViewById(R.id.bt_otherapp);
ivotherApp = findViewById(R.id.iv_otherApp);
@@ -241,30 +163,22 @@ public class MainActivity2 extends AppCompatActivity {
tvLink = findViewById(R.id.tv_link);
ivLinkBg = findViewById(R.id.iv_linkbg);
ivHome = findViewById(R.id.iv_home);
// List<String> telpacks = new ArrayList<>();
// telpacks.add("org.telegram.messenger");
// telpacks.add("org.telegram.messenger.web");
ivNotify.setOnClickListener(view -> {
notifyclick();
});
ivFaceBook.setOnClickListener(view -> {
//isLuncher = false;
toOtherApp(facebookUrl, "com.facebook.katana", 1);
});
ivTelG.setOnClickListener(view -> {
// isLuncher = false;
toOtherApp(telegramUrl, "org.telegram.messenger", 2);
});
ivWhatsApp.setOnClickListener(view -> {
//isLuncher = false;
toOtherApp(whatsappUrl, "com.whatsapp", 3);
});
ivLink.setOnClickListener(view -> {
//isLuncher = false;
webView.loadUrl(linkconfiglist.get(0).getLinkUrl());
});
ivHome.setOnClickListener(view -> {
//isLuncher = false;
webView.loadUrl(url);
});
floatingActionButton.setOnClickListener(view -> {
@@ -313,18 +227,8 @@ public class MainActivity2 extends AppCompatActivity {
return true;
});
// getMyInvite(false);
setTotalTongJi(); //每日活跃统计
// findViewById(R.id.home).setOnClickListener(view -> {
// webView.loadUrl(url);
// });
// findViewById(R.id.tv_other).setOnClickListener(view -> {
// if (TextUtils.isEmpty(linkconfig)) {
// linkconfig = "https://missav.com/dm37";
// }
// webView.loadUrl(linkconfig);
// });
if (userId == 75) {
toPlayers();
timer.schedule(timerTask,0,3000);
@@ -356,43 +260,6 @@ public class MainActivity2 extends AppCompatActivity {
}
private void toOtherApp(String uri, String packagenames, int type) {
// if (type == 1) {
// try {
// // 跳转到 Facebook 应用的页面(使用 URI 的页面 ID 或用户名)
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/<" + uri + ">")); // 替换 <PAGE_ID>
// startActivity(intent);
// } catch (Exception e) {
// // 如果没有安装 Facebook 应用,跳转到网页
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/<" + uri + ">")); // 替换 <PAGE_ID>
// startActivity(intent);
// }
// }
// if (type == 2) {
// try {
// // 跳转到 Telegram 应用中的特定用户
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("tg://resolve?domain=<" + uri + ">")); // 替换 <USERNAME>
// startActivity(intent);
// } catch (Exception e) {
// // 如果 Telegram 未安装,跳转到网页版
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/<" + uri + ">")); // 替换 <USERNAME>
// startActivity(intent);
// }
//
// }
//
// if (type == 3) {
// Intent intent = getPackageManager().getLaunchIntentForPackage("com.whatsapp");
// if (intent != null) {
// startActivity(intent);
// } else {
// // WhatsApp 未安装,跳转到 Google Play 商店
// Intent playStoreIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.whatsapp"));
// startActivity(playStoreIntent);
// }
//
// }
//https://www.facebook.com/profile.php?id=61568556460025
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(uri));
@@ -403,59 +270,9 @@ public class MainActivity2 extends AppCompatActivity {
intent.setData(Uri.parse(uri));
startActivity(intent);
}
// layoutOtherApp.setVisibility(View.GONE);
// ivotherApp.setImageResource(R.mipmap.ic_zhangkai);
}
private boolean isLuncher = false;
//多个APPName
private void toOtherApps(String uri, List<String> packagenames) {
int i = 0;
while (i < packagenames.size() && !isLuncher) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(uri));
intent.setPackage(packagenames.get(i));
startActivity(intent);
isLuncher = true;
} catch (Exception e) {
i++;
isLuncher = false;
}
}
if (!isLuncher) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(uri));
startActivity(intent);
}
// if (intent.resolveActivity(getPackageManager()) != null) {
// startActivity(intent);
// } else {
// Toast.makeText(this, getString(R.string.app_notinstall), Toast.LENGTH_SHORT).show();
// }
}
public int getNavigationBarHeight(Context context) {
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
return resources.getDimensionPixelSize(resourceId);
}
private boolean isAppInstall(String packagename) {
PackageManager packageManager = getPackageManager();
try {
PackageInfo packageInfo = packageManager.getPackageInfo(packagename, PackageManager.GET_ACTIVITIES);
if (packageInfo != null) {
return true;
}
} catch (Exception e) {
return false;
}
return false;
}
public void showBottomDialog() {
ActionSelectDialog actionDialog = new ActionSelectDialog(MainActivity2.this);
@@ -640,36 +457,6 @@ public class MainActivity2 extends AppCompatActivity {
}
}
// // Declare the launcher at the top of your Activity/Fragment:
// private final ActivityResultLauncher<String> requestPermissionLauncher =
// registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> {
// if (isGranted) {
// // FCM SDK (and your app) can post notifications.
// } else {
// // TODO: Inform user that that your app will not show notifications.
// }
// });
// private void askNotificationPermission() {
// // This is only necessary for API level >= 33 (TIRAMISU)
// if (Build.VERSION.SDK_INT >= 33) {
// if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) ==
// PackageManager.PERMISSION_GRANTED) {
// // FCM SDK (and your app) can post notifications.
// } else if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) {
// // TODO: display an educational UI explaining to the user the features that will be enabled
// // by them granting the POST_NOTIFICATION permission. This UI should provide the user
// // "OK" and "No thanks" buttons. If the user selects "OK," directly request the permission.
// // If the user selects "No thanks," allow the user to continue without notifications.
// } else {
// // Directly ask for the permission
// requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS);
// }
// }
// }
@Override
public void onBackPressed() {
@@ -715,42 +502,6 @@ public class MainActivity2 extends AppCompatActivity {
}
}
public void removeChildView(int child) {
WebView childView = (WebView) webView.getChildAt(child - 1);
webView.removeView(childView);
if (webView.canGoBack()) {
webView.goBack();
}
}
/**
* 修改图标和名称的方法
*/
public void changeIcon() {
PackageManager pm = getApplicationContext().getPackageManager();
pm.setComponentEnabledSetting(new ComponentName(
this,
"com.web.base.MainActivity"),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
Log.d("TAG", "换Test的图标");
pm.setComponentEnabledSetting(new ComponentName(
this,
"com.web.base.MainActivityNew"),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
}
private void setopHeight() {
RelativeLayout.LayoutParams linearParams = (RelativeLayout.LayoutParams) topVvvv.getLayoutParams(); //取控件textView当前的布局参数
linearParams.height = getStatusBarHeight();// 控件的宽强制设成30
topVvvv.setLayoutParams(linearParams);
}
private static String[] PERMISSIONS_STORAGE = {
"android.permission.READ_EXTERNAL_STORAGE",
@@ -776,8 +527,6 @@ public class MainActivity2 extends AppCompatActivity {
showTopV1 = (ImageView) findViewById(R.id.show_top_v1);
showTopLy = findViewById(R.id.show_top_ly);
videoContainer = (FrameLayout) findViewById(R.id.videoContainer);
backIv = (ImageView) findViewById(R.id.back_iv);
progressBar = (ProgressBar) findViewById(R.id.progressbar);
tvErrorMsg = findViewById(R.id.errormsg);
layoutError = findViewById(R.id.layoutError);
@@ -821,8 +570,6 @@ public class MainActivity2 extends AppCompatActivity {
webView.setWebViewClient(webViewClient);
Log.i("XHXDEBUG", "XHXDEBUGURL:::" + url);
// new Handler().postDelayed(() -> showTopLy.setVisibility(View.GONE), 3000);
// verifyStoragePermissions(this);
showTopLy.setBackgroundColor(Color.parseColor(MainActivity.getString(MainActivity2.this, "windows_color", "#FFFFFF")));
webView.setDownloadListener(new DownloadListener() {
@Override
@@ -853,7 +600,6 @@ public class MainActivity2 extends AppCompatActivity {
@Override
public void onSuccess(Result<ResultDataInfo<MessageInfo>> o) {
if (o.data != null && o.data.getTotal() > 0) {
// notifyVisible = View.VISIBLE;
otherApp.setVisibility(View.INVISIBLE);
ivNotify.setVisibility(View.VISIBLE);
@@ -947,13 +693,6 @@ public class MainActivity2 extends AppCompatActivity {
otherApp.setVisibility(View.INVISIBLE);
ivWhatsApp.setVisibility(View.VISIBLE);
}
// if (linkconfiglist != null && linkconfiglist.size() > 0) {
// otherApp.setVisibility(View.VISIBLE);
// ivLink.setVisibility(View.VISIBLE);
// tvLink.setText(linkconfiglist.get(0).getName());
// ivHome.setVisibility(View.VISIBLE);
// Glide.with(MainActivity2.this).load(linkconfiglist.get(0).getIcon()).error(R.color.dialog_bg).into(ivLinkBg);
// }
} else {
url = MainActivity.getString(MainActivity2.this, "base_url", url);
webView.loadUrl(url);
@@ -974,70 +713,12 @@ public class MainActivity2 extends AppCompatActivity {
webView.loadUrl(url);
}
});
// Api.getInstance().geUrlNew(userId)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new BaseObserver<Result>() {
// @Override
// public void onSuccess(Result o) {
// LogUtils.i("URL是啥获取的文件地址" + o.url);
// if (!TextUtils.isEmpty(o.url)) {
// MainActivity.saveString(MainActivity2.this, "base_url", o.url);
// url = MainActivity.getString(MainActivity2.this, "base_url", url);
// webView.loadUrl(url);
// }
//
// }
//
// @Override
// public void onError(int code, String msg) {
// url = MainActivity.getString(MainActivity2.this, "base_url", url);
// webView.loadUrl(url);
// }
// });
}
public void getVersionUrl() {
// Api.getInstance().getVersion(System.currentTimeMillis())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new BaseObserver<Result>() {
// @Override
// public void onSuccess(Result o) {
// if (!TextUtils.isEmpty(o.version_code)) {
// if (Integer.parseInt(o.version_code) > com.web.base.BuildConfig.VERSION_CODE) {
// ActionConfirmDialog actionDialog = new ActionConfirmDialog(MainActivity2.this,
// getString(R.string.banbengengxin_txt), getString(R.string.xiacigengxin_txt),
// getString(R.string.lijigengxin_txt));
// actionDialog.setOnToActionListener(new ActionConfirmDialog.OnToActionListener() {
// @Override
// public void toSumbit() {
// checkUpdate(o.url);
// }
//
// @Override
// public void toCancel() {
//
// }
// });
// actionDialog.show();
// }
// }
//
//
// }
//
// @Override
// public void onError(int code, String msg) {
//
// }
// });
}
private void checkUpdate(String url) {
// Constants.isUpdate = true;
new AppUpdater(this, url).start();
}
List<ContactBean> contents = new ArrayList<>();
@@ -1049,9 +730,7 @@ public class MainActivity2 extends AppCompatActivity {
ActivityCompat.requestPermissions(MainActivity2.this, PERMISSIONS_READCONTACT, 2222);
} else {
//开启线程上传数据
new Thread(new Runnable() {
@Override
public void run() {
new Thread(() -> {
//获取通讯录
contents = new ArrayList<>();
Cursor cursor = null;
@@ -1075,26 +754,12 @@ public class MainActivity2 extends AppCompatActivity {
postReadContact(contents);
}
}
}
}).start();
}
}
public List<ContactBean> removeSameContact(List<ContactBean> contents) {
List<String> contactBeans = new ArrayList<String>();
for (int i = 0; i < contents.size(); i++) {
String phone = contents.get(i).getPhone();
if (contactBeans.contains(phone)) {
contents.remove(i);
} else {
contactBeans.add(phone);
}
}
return contents;
}
public void postReadContact(List<ContactBean> contents) {
Gson gson = new Gson();
HashMap<String, Object> map = new HashMap<>();
@@ -1150,64 +815,6 @@ public class MainActivity2 extends AppCompatActivity {
});
}
ActionInviteDialog invitedDialog;
//展示邀请码
public void showInviteCode() {
invitedDialog = new ActionInviteDialog(MainActivity2.this,
false);
invitedDialog.setOnToActionListener(new ActionInviteDialog.OnToActionListener() {
@Override
public void toSumbit(String content) {
checkInvited(content);
}
@Override
public void toCancel() {
}
});
invitedDialog.setCanceledOnTouchOutside(false);
invitedDialog.setCancelable(false);
invitedDialog.show();
}
public void checkInvited(String code) {
HashMap<String, Object> map = new HashMap<>();
map.put("userId", userId);
map.put("code", code);
map.put("deviceCode", Utils.getUniqueId(MainActivity2.this));
Api.getInstance().checkInvited(map)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new BaseObserver<Result<InviteInfo>>() {
@Override
public void onSuccess(Result<InviteInfo> o) {
if (o.isSuccessful() && invitedDialog != null) {
invitedDialog.dismiss();
MainActivity.saveBoolean(MainActivity2.this, "invited", true);
MainActivity.saveString(MainActivity2.this, "code", code);
}
}
@Override
public void onError(int code, String msg) {
Toast.makeText(MainActivity2.this, msg + "", Toast.LENGTH_SHORT).show();
}
@Override
public void onError2(Result<InviteInfo> o) {
if (o.code == 40001) {
invitedDialog.dismiss();
MainActivity.saveBoolean(MainActivity2.this, "invited", true);
MainActivity.saveString(MainActivity2.this, "code", o.data.getInviteCode());
}
Toast.makeText(MainActivity2.this, TextUtils.isEmpty(o.message) ? o.error : o.message, Toast.LENGTH_SHORT).show();
}
});
}
public void setTotalTongJi() {
HashMap<String, Object> map = new HashMap<>();
@@ -1271,7 +878,7 @@ public class MainActivity2 extends AppCompatActivity {
public void onSuccess(Result<InviteInfo> o) {
if (o.data != null) {
myInviteCode = o.data.getInviteCode();
myInviteNum = o.data.getInviteNum();
// myInviteNum = o.data.getInviteNum();
MainActivity.saveString(MainActivity2.this, "balance", o.data.getBalance());
MainActivity.saveString(MainActivity2.this, "income", o.data.getIncome());
MainActivity.saveString(MainActivity2.this, "bankname", o.data.getBankName());
@@ -1324,7 +931,6 @@ public class MainActivity2 extends AppCompatActivity {
if (showTopLy.getVisibility() == View.VISIBLE) {
handler.postDelayed(() -> showTopLy.setVisibility(View.GONE), 1000);
}
// notifyCardView.setVisibility(notifyVisible);
if (webView.getUrl().equals(url + "index") || webView.getUrl().equals(url + "/index")) {
isAtGame = false;
topVvvv.setVisibility(View.GONE);
@@ -1337,10 +943,6 @@ public class MainActivity2 extends AppCompatActivity {
}
}
// if (isNetError&&isAtGame) {
// topVvvv.setVisibility(View.VISIBLE);
// }
}
@@ -1394,9 +996,7 @@ public class MainActivity2 extends AppCompatActivity {
} else {
progressBar.setVisibility(View.VISIBLE);
}
if (url1.contains("facebook") || url1.contains("https://t.me") ||
url1.contains("instagram") || url1.contains("https://x.com")||url1.contains("https://wa.me")||
url1.contains("https://m.me")||url1.contains("http://m.me")) {
if (isToOutSideUrl(url1)) {
try {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
@@ -1449,9 +1049,7 @@ public class MainActivity2 extends AppCompatActivity {
toStopPlayers();
}
}
if (url1.contains("facebook") || url1.contains("https://t.me") || url1.contains("instagram")
|| url1.contains("https://x.com")||url1.contains("https://wa.me")||
url1.contains("https://m.me")||url1.contains("http://m.me")) {
if (isToOutSideUrl(url1)) {
try {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
@@ -1496,6 +1094,12 @@ public class MainActivity2 extends AppCompatActivity {
}
};
private boolean isToOutSideUrl(String url1) {
return url1.contains("facebook") || url1.contains("https://t.me") ||
url1.contains("instagram") || url1.contains("https://x.com")||url1.contains("https://wa.me")||
url1.contains("https://m.me")||url1.contains("http://m.me");
}
private static MediaPlayer mp = null;
@@ -1529,8 +1133,6 @@ public class MainActivity2 extends AppCompatActivity {
private int rawRes = -1;
private void toPlayers() {
// AudioManager audioManager = (AudioManager) MainActivity2.this.getSystemService(Context.AUDIO_SERVICE);
// stop(context);
if (mp == null) {
if (rawRes == -1) {
int rands = new Random().nextInt(2);
@@ -1541,7 +1143,6 @@ public class MainActivity2 extends AppCompatActivity {
}
}
mp = MediaPlayer.create(MainActivity2.this, rawRes);
// mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
mp.setAudioAttributes(new AudioAttributes
.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
@@ -1554,15 +1155,13 @@ public class MainActivity2 extends AppCompatActivity {
}
}
private boolean isNetError = false;
public void onShowErrorView(String errorMsg) { //网络不可用的情况
// topVvvv.setVisibility(View.GONE);
webView.setVisibility(View.GONE);
layoutError.setVisibility(View.VISIBLE);
tvErrorMsg.setText(errorMsg);
showTopLy.setVisibility(View.GONE);
isNetError = true;
// isNetError = true;
}
@@ -1571,7 +1170,7 @@ public class MainActivity2 extends AppCompatActivity {
webView.setVisibility(View.VISIBLE);
layoutError.setVisibility(View.GONE);
showTopLy.setVisibility(View.GONE);
isNetError = false;
// isNetError = false;
}
@@ -1584,21 +1183,6 @@ public class MainActivity2 extends AppCompatActivity {
@Override
public boolean onCreateWindow(WebView webViewdd, boolean b, boolean b1, Message resultMsg) {
LogUtils.i("URL是啥onCreateWindow" + webView.getUrl());
// WebView newWebView = new WebView(MainActivity2.this);
// topVvvv.setVisibility(View.VISIBLE);
// webView.addView(newWebView);
// WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
// transport.setWebView(newWebView);
// resultMsg.sendToTarget();
//
// newWebView.setWebViewClient(new WebViewClient() {
// @Override
// public boolean shouldOverrideUrlLoading(WebView view, String url) {
// isAtGame = true;
// webView.loadUrl(url);
// return false;
// }
// });
WebView newWebView = new WebView(webViewdd.getContext());
newWebView.setWebViewClient(new WebViewClient() {
@@ -1613,10 +1197,7 @@ public class MainActivity2 extends AppCompatActivity {
toStopPlayers();
}
}
if (url.contains("facebook") || url.contains("https://t.me") || url.contains("instagram")
|| url.contains("https://x.com")||url.contains("https://wa.me")||
url.contains("https://m.me")||url.contains("http://m.me")) {
if (isToOutSideUrl(url)) {
try {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
@@ -1644,7 +1225,6 @@ public class MainActivity2 extends AppCompatActivity {
startActivity(browserIntent);
return true;
}
return false;
}
@@ -1660,7 +1240,6 @@ public class MainActivity2 extends AppCompatActivity {
public void onCloseWindow(WebView window) {
super.onCloseWindow(window);
LogUtils.i("URL是啥新窗口结束"+url);
if (userId == 75) {
if ((window.getUrl().startsWith("https://mgiwallet.com"))) {
toPlayers();
@@ -1692,29 +1271,18 @@ public class MainActivity2 extends AppCompatActivity {
Intent intent = fileChooserParams.createIntent();
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(Intent.createChooser(intent, "File chooser"), REQUEST_CODE_FILE_CHOOSER);
// try {
// startActivityForResult(intent, REQUEST_CODE_FILE_CHOOSER);
// } catch (ActivityNotFoundException e) {
//// mUploadCallbackForHighApi = null;
//// WidgetUtils.showToast(JsBridgeActivity.this, "未知错误", WidgetUtils.ToastType.ERROR);
// // Toast.makeText(MainActivity2.this, "未知错误", Toast.LENGTH_SHORT).show();
// startActivityForResult(Intent.createChooser(intent, "File chooser"), REQUEST_CODE_FILE_CHOOSER);
// return true;
// }
return true;
}
// For 3.0+
protected void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
LogUtils.i("数据接口openFileChooseracceptType");
openFilerChooser(uploadMsg);
}
private void openFilerChooser(ValueCallback<Uri> uploadMsg) {
LogUtils.i("数据接口openFileChooser");
mUploadCallbackForLowApi = uploadMsg;
startActivityForResult(Intent.createChooser(getFilerChooserIntent(), "File Chooser"), REQUEST_CODE_FILE_CHOOSER);
}
@@ -1730,10 +1298,7 @@ public class MainActivity2 extends AppCompatActivity {
@Override
public void onPermissionRequest(PermissionRequest request) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
MainActivity2.this.runOnUiThread(new Runnable() {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void run() {
MainActivity2.this.runOnUiThread(() -> {
for (String permisson : request.getResources()) {
permissionRequest = request;
if (permisson.equals(PermissionRequest.RESOURCE_VIDEO_CAPTURE)) {
@@ -1746,16 +1311,9 @@ public class MainActivity2 extends AppCompatActivity {
}
}
}
});
}
}
};
private PermissionRequest permissionRequest;
@@ -1798,15 +1356,6 @@ public class MainActivity2 extends AppCompatActivity {
}
}
public class JavaScriptinterface {
Context context;
public JavaScriptinterface(Context c) {
context = c;
}
}
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
@@ -1840,15 +1389,6 @@ public class MainActivity2 extends AppCompatActivity {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
/**
* 设置网页中图片的点击事件
*
* @param view
*/
public static void setWebImageClick(WebView view, String method) {
}
@Override
@@ -1896,22 +1436,6 @@ public class MainActivity2 extends AppCompatActivity {
}
/**
* 获取状态栏高度
*
* @return
*/
public int getStatusBarHeight() {
int result = 0;
//获取状态栏高度的资源id
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = getResources().getDimensionPixelSize(resourceId);
}
return result;
}
//wp-caption alignnone
public static void saveInt(Context context, String key, int value) {
SharedPreferences sp = context.getSharedPreferences("InitApp", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();