NetCapture v2.1.82021972349版本的 MD5 值为:dfbd8054127041af5d65fa43eaf2e1d0
以下内容为反编译后的 BaseActivity.java 源代码,内容仅作参考
package com.minhui.networkcapture.base;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.MenuItem;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import com.minhui.networkcapture.R;
import com.minhui.networkcapture.tracker.Tracker;
import com.minhui.networkcapture.tracker.TrackerConstant;
import com.minhui.networkcapture.utils.AppConstants;
import com.minhui.networkcapture.utils.ContextUtil;
public abstract class BaseActivity extends AppCompatActivity {
private static final String TAG = "BaseActivity";
protected Handler handler;
protected abstract int getLayout();
protected boolean isMainActivity() {
return false;
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
this.handler = new Handler();
setContentView(getLayout());
enableBackIndicator();
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public void setTitle(CharSequence charSequence) {
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setTitle(charSequence);
}
}
@Override
public void setTitle(int i) {
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setTitle(i);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (!isMainActivity() && menuItem.getItemId() == 16908332) {
onBackPressed();
return true;
}
return super.onOptionsItemSelected(menuItem);
}
public void disableBackIndicator() {
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setDisplayHomeAsUpEnabled(false);
}
}
public void enableBackIndicator() {
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
}
public void setBackIndicator(int i) {
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setHomeAsUpIndicator(i);
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
}
public void setBackIndicator(Drawable drawable) {
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setHomeAsUpIndicator(drawable);
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
}
public void showMsg(String str) {
Toast.makeText(this, str, 0).show();
}
public void sendRecommend(String str) {
Bundle bundle = new Bundle();
bundle.putString(TrackerConstant.RECOMMEND_REMOVE_ADS_STATE, str);
Tracker.sendEvent(TrackerConstant.RECOMMEND_REMOVE_ADS, bundle);
}
public void recommendPro(String str) {
if (!ContextUtil.isGooglePlayChannel(getApplicationContext()) || ContextUtil.isProVersion(getApplicationContext())) {
return;
}
new AlertDialog.Builder(this).setMessage(str).setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
BaseActivity.this.gotoPro();
dialogInterface.dismiss();
BaseActivity.this.sendRecommend(TrackerConstant.GO_TO_PRO);
}
}).setNegativeButton(getString(R.string.not_now), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
BaseActivity.this.sendRecommend(TrackerConstant.NOT_ENTER_PRO);
}
}).show().setCanceledOnTouchOutside(false);
}
public void gotoPro() {
if (!ContextUtil.isGooglePlayChannel(getApplicationContext())) {
launchBrowser("https://www.pgyer.com/wOLk");
return;
}
try {
try {
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("market://details?id=com.minhui.networkcapture.pro"));
intent.setPackage("com.android.vending");
startActivity(intent);
} catch (Exception unused) {
}
} catch (Exception unused2) {
launchBrowser("https://play.google.com/store/apps/details?id=com.minhui.networkcapture.pro");
}
getSharedPreferences(AppConstants.DATA_SAVE, 0).edit().putBoolean(AppConstants.HAS_SHOW_RECOMMEND, true).apply();
}
public void launchBrowser(String str) {
Intent intent = new Intent("android.intent.action.VIEW");
intent.setData(Uri.parse(str));
try {
startActivity(intent);
} catch (ActivityNotFoundException | SecurityException e) {
Log.d(TAG, "failed to launchBrowser " + e.getMessage());
}
}
}