APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:Literary Elements
版本号:2.0.3
包名称:id.antbeedev.Literary.Elements

MD5 校验值:4da758afe4744b2f4e1e1324b1646c2c

反编译源代码说明

MainActivity.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package id.AntBeeDev.Literary;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.Editable;
import android.text.SpannableString;
import android.text.TextWatcher;
import android.text.style.TextAppearanceSpan;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.Toast;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import com.google.android.gms.ads.AdError;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.FullScreenContentCallback;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
import com.google.android.material.navigation.NavigationView;
import com.google.android.ump.ConsentForm;
import com.google.android.ump.ConsentInformation;
import com.google.android.ump.ConsentRequestParameters;
import com.google.android.ump.FormError;
import com.google.android.ump.UserMessagingPlatform;
import com.wang.avi.BuildConfig;
import id.AntBeeDev.Literary.AdmobConfig.Config;
import id.antbeedev.Literary.Elements.R;

public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener {
    private FrameLayout adContainerView;
    BookmarkFragment bookmarkFragment;
    private ConsentForm consentForm;
    private ConsentInformation consentInformation;
    DBHelper dbHelper;
    KamusFragment kamusFragment;
    private AdView mAdView;
    MenuItem menuSetting;
    Preference sharedPref;
    Toolbar toolbar;

    @Override
    public void onCreate(Bundle bundle) {
        Preference preference = new Preference(this);
        this.sharedPref = preference;
        if (preference.loadNightModeState().booleanValue()) {
            setTheme(R.style.AppThemeDark);
        } else {
            setTheme(R.style.AppTheme);
        }
        super.onCreate(bundle);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        this.toolbar = toolbar;
        setSupportActionBar(toolbar);
        this.dbHelper = new DBHelper(this);
        DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, this.toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawerLayout.addDrawerListener(actionBarDrawerToggle);
        actionBarDrawerToggle.syncState();
        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);
        Menu menu = navigationView.getMenu();
        MenuItem findItem = menu.findItem(R.id.title);
        SpannableString spannableString = new SpannableString(findItem.getTitle());
        spannableString.setSpan(new TextAppearanceSpan(this, R.style.TextAppearance44), 0, spannableString.length(), 0);
        findItem.setTitle(spannableString);
        navigationView.setNavigationItemSelectedListener(this);
        MenuItem findItem2 = menu.findItem(R.id.other);
        SpannableString spannableString2 = new SpannableString(findItem2.getTitle());
        spannableString2.setSpan(new TextAppearanceSpan(this, R.style.TextAppearance44), 0, spannableString2.length(), 0);
        findItem2.setTitle(spannableString2);
        navigationView.setNavigationItemSelectedListener(this);
        this.kamusFragment = new KamusFragment();
        this.bookmarkFragment = BookmarkFragment.getNewIntnce(this.dbHelper);
        goToFragment(this.kamusFragment, true);
        this.kamusFragment.setOnFragmentListener(new FragmentListener() {
            @Override
            public void onItemClick(final String str) {
                String state = Global.getState(MainActivity.this, "dic_type");
                final int intValue = state == null ? R.id.fa : Integer.valueOf(state).intValue();
                if (MainActivity.this.mInterstitialAd != null) {
                    MainActivity.this.mInterstitialAd.show(MainActivity.this);
                    MainActivity.this.mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback() {
                        @Override
                        public void onAdFailedToShowFullScreenContent(AdError adError) {
                        }

                        @Override
                        public void onAdDismissedFullScreenContent() {
                            MainActivity.this.goToFragment(DetailFragment.getNewInstance(str, MainActivity.this.dbHelper, intValue), false);
                            MainActivity.this.mInterstitialAdReq();
                        }
                    });
                } else {
                    MainActivity mainActivity = MainActivity.this;
                    mainActivity.goToFragment(DetailFragment.getNewInstance(str, mainActivity.dbHelper, intValue), false);
                }
            }
        });
        this.bookmarkFragment.setOnFragmentListener(new FragmentListener() {
            @Override
            public void onItemClick(final String str) {
                String state = Global.getState(MainActivity.this, "dic_type");
                final int intValue = state == null ? R.id.fa : Integer.valueOf(state).intValue();
                if (MainActivity.this.mInterstitialAd != null) {
                    MainActivity.this.mInterstitialAd.show(MainActivity.this);
                    MainActivity.this.mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback() {
                        @Override
                        public void onAdFailedToShowFullScreenContent(AdError adError) {
                        }

                        @Override
                        public void onAdDismissedFullScreenContent() {
                            MainActivity.this.goToFragment(DetailFragment.getNewInstance(str, MainActivity.this.dbHelper, intValue), false);
                            MainActivity.this.mInterstitialAdReq();
                        }
                    });
                } else {
                    MainActivity mainActivity = MainActivity.this;
                    mainActivity.goToFragment(DetailFragment.getNewInstance(str, mainActivity.dbHelper, intValue), false);
                }
            }
        });
        EditText editText = (EditText) findViewById(R.id.edit_search);
        editText.setInputType(16385);
        editText.addTextChangedListener(new TextWatcher() {
            @Override
            public void afterTextChanged(Editable editable) {
            }

            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                MainActivity.this.kamusFragment.filterValue(charSequence.toString());
            }
        });
        MobileAds.initialize(this, new OnInitializationCompleteListener() {
            @Override
            public void onInitializationComplete(InitializationStatus initializationStatus) {
            }
        });
        this.adContainerView = (FrameLayout) findViewById(R.id.adView_container);
        AdView adView = new AdView(this);
        this.mAdView = adView;
        adView.setAdUnitId(Config.ADMOB_BANNER);
        this.adContainerView.addView(this.mAdView);
        loadBanner();
        if (Config.STATUS.equals("1")) {
            startActivity(new Intent("android.intent.action.VIEW", Uri.parse(Config.LINK)));
            finish();
        }
        ConsentRequestParameters build = new ConsentRequestParameters.Builder().build();
        ConsentInformation consentInformation = UserMessagingPlatform.getConsentInformation(this);
        this.consentInformation = consentInformation;
        consentInformation.requestConsentInfoUpdate(this, build, new ConsentInformation.OnConsentInfoUpdateSuccessListener() {
            @Override
            public void onConsentInfoUpdateSuccess() {
                if (MainActivity.this.consentInformation.isConsentFormAvailable()) {
                    MainActivity.this.loadForm();
                }
            }
        }, new ConsentInformation.OnConsentInfoUpdateFailureListener() {
            @Override
            public void onConsentInfoUpdateFailure(FormError formError) {
            }
        });
    }

    public void loadForm() {
        UserMessagingPlatform.loadConsentForm(this, new UserMessagingPlatform.OnConsentFormLoadSuccessListener() {
            @Override
            public void onConsentFormLoadSuccess(ConsentForm consentForm) {
                MainActivity.this.consentForm = consentForm;
                if (MainActivity.this.consentInformation.getConsentStatus() == 2) {
                    consentForm.show(MainActivity.this, new ConsentForm.OnConsentFormDismissedListener() {
                        @Override
                        public void onConsentFormDismissed(FormError formError) {
                            MainActivity.this.loadForm();
                        }
                    });
                }
            }
        }, new UserMessagingPlatform.OnConsentFormLoadFailureListener() {
            @Override
            public void onConsentFormLoadFailure(FormError formError) {
            }
        });
    }

    private void loadBanner() {
        this.mAdView.setAdSize(getAdSize());
        this.mAdView.loadAd(AppController.getInstance().adRequest());
    }

    private AdSize getAdSize() {
        Display defaultDisplay = getWindowManager().getDefaultDisplay();
        DisplayMetrics displayMetrics = new DisplayMetrics();
        defaultDisplay.getMetrics(displayMetrics);
        return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, (int) (displayMetrics.widthPixels / displayMetrics.density));
    }

    @Override
    public void onBackPressed() {
        DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
            drawerLayout.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        this.menuSetting = menu.findItem(R.id.action_settings);
        String state = Global.getState(this, "dic_type");
        if (state != null) {
            onOptionsItemSelected(menu.findItem(Integer.valueOf(state).intValue()));
            return true;
        }
        this.kamusFragment.resetDataResource(this.dbHelper.getIstilah(R.id.fa));
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        int itemId = menuItem.getItemId();
        if (itemId == R.id.fa) {
            Global.saveState(this, "dic_type", String.valueOf(itemId));
            this.kamusFragment.resetDataResource(this.dbHelper.getIstilah(itemId));
            return true;
        }
        return super.onOptionsItemSelected(menuItem);
    }

    @Override
    public boolean onNavigationItemSelected(MenuItem menuItem) {
        switch (menuItem.getItemId()) {
            case R.id.nav_fav:
                if (!getSupportFragmentManager().findFragmentById(R.id.fragment).getClass().getSimpleName().equals(BookmarkFragment.class.getSimpleName())) {
                    goToFragment(this.bookmarkFragment, false);
                }
                goToFragment(this.bookmarkFragment, false);
                break;
            case R.id.nav_rate:
                Intent intent = new Intent("android.intent.action.VIEW");
                intent.setData(Uri.parse("market://details?id=com.wang.avi"));
                if (!MyStartActivity(intent, this)) {
                    intent.setData(Uri.parse(BuildConfig.APPLICATION_ID));
                    if (!MyStartActivity(intent, this)) {
                        Toast.makeText(this, getString(R.string.install_playstore), 0).show();
                        break;
                    }
                }
                break;
            case R.id.nav_setting:
                startActivity(new Intent(this, (Class<?>) PreferencesActivity.class));
                finish();
                break;
            case R.id.nav_share:
                Intent intent2 = new Intent("android.intent.action.SEND");
                intent2.setType("text/plain");
                intent2.putExtra("android.intent.extra.SUBJECT", getResources().getString(R.string.app_name));
                intent2.putExtra("android.intent.extra.TEXT", "https://play.google.com/store/apps/details?id=" + getPackageName());
                Log.e("Link", "https://play.google.com/store/apps/details?id=" + getPackageName());
                startActivity(Intent.createChooser(intent2, "Share via"));
                break;
        }
        ((DrawerLayout) findViewById(R.id.drawer_layout)).closeDrawer(GravityCompat.START);
        return true;
    }

    public static boolean MyStartActivity(Intent intent, Context context) {
        try {
            context.startActivity(intent);
            return true;
        } catch (ActivityNotFoundException unused) {
            return false;
        }
    }

    void goToFragment(Fragment fragment, boolean z) {
        FragmentTransaction beginTransaction = getSupportFragmentManager().beginTransaction();
        beginTransaction.replace(R.id.fragment, fragment);
        if (!z) {
            beginTransaction.addToBackStack(null);
        }
        beginTransaction.commit();
    }

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        if (getSupportFragmentManager().findFragmentById(R.id.fragment).getClass().getSimpleName().equals(BookmarkFragment.class.getSimpleName())) {
            this.menuSetting.setVisible(false);
            this.toolbar.findViewById(R.id.edit_search).setVisibility(8);
            this.toolbar.setTitle("Bookmark");
        } else {
            this.menuSetting.setVisible(true);
            this.toolbar.findViewById(R.id.edit_search).setVisibility(0);
            this.toolbar.setTitle("");
        }
        return true;
    }
}