导航菜单

页面标题

页面副标题

St.John's v1.0.9 - LearningLinkActivity.java 源代码

正在查看: St.John's v1.0.9 应用的 LearningLinkActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.mcb.stjohnsemschool.activity;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.http.SslError;
import android.os.Bundle;
import android.view.MenuItem;
import android.webkit.CookieManager;
import android.webkit.JsResult;
import android.webkit.SslErrorHandler;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.mcb.stjohnsemschool.utils.TransparentProgressDialog;
import com.mcb.stjohnsemschool.utils.Utility;

public class LearningLinkActivity extends AppCompatActivity {
    private int chapterId;
    private Context context;
    private boolean isLearning;
    private TransparentProgressDialog mProgressbar;
    private int resourceId;
    private String subjectGUID = "";
    private int topicId;
    private WebView wv;

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_learning_link);
        this.context = this;
        Bundle extras = getIntent().getExtras();
        final String string = extras.getString("Path", "");
        String string2 = extras.getString("Title", "");
        boolean z = extras.getBoolean("IsLearning", false);
        this.isLearning = z;
        if (z) {
            this.subjectGUID = extras.getString("SubjectGUID", "");
            this.chapterId = extras.getInt("ChapterId", 0);
            this.topicId = extras.getInt("TopicId", 0);
            this.resourceId = extras.getInt("ResourceId", 0);
        }
        getSupportActionBar().setTitle(string2);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        this.mProgressbar = new TransparentProgressDialog(this, R.drawable.spinner_loading_imag);
        this.wv = (WebView) findViewById(2131364517);
        CookieManager.getInstance().setAcceptCookie(true);
        CookieManager.getInstance().setAcceptThirdPartyCookies(this.wv, true);
        WebSettings settings = this.wv.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.getAllowContentAccess();
        settings.setDomStorageEnabled(true);
        settings.setLoadWithOverviewMode(true);
        settings.setUseWideViewPort(true);
        this.wv.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
        this.wv.getSettings().setBuiltInZoomControls(true);
        this.wv.setWebViewClient(new WebViewClient() {
            @Override
            public void onReceivedSslError(WebView webView, final SslErrorHandler sslErrorHandler, SslError sslError) {
                AlertDialog.Builder builder = new AlertDialog.Builder(LearningLinkActivity.this);
                builder.setMessage("SSL Violation Error!,Do you want to proceed?");
                builder.setPositiveButton("Continue", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        sslErrorHandler.proceed();
                    }
                });
                builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        sslErrorHandler.cancel();
                    }
                });
                builder.create().show();
            }

            @Override
            public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
                super.onPageStarted(webView, str, bitmap);
            }

            @Override
            public void onPageFinished(WebView webView, String str) {
                super.onPageFinished(webView, str);
                if (LearningLinkActivity.this.mProgressbar == null || !LearningLinkActivity.this.mProgressbar.isShowing()) {
                    return;
                }
                LearningLinkActivity.this.mProgressbar.dismiss();
            }

            @Override
            public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
                if (string.startsWith("http:") || string.startsWith("https:")) {
                    return false;
                }
                Intent intent = new Intent(LearningLinkActivity.this.getApplicationContext(), (Class<?>) WebViewActivity.class);
                intent.putExtra("URL", string);
                intent.putExtra("Title", "Learning");
                LearningLinkActivity.this.startActivity(intent);
                return true;
            }
        });
        this.wv.setWebChromeClient(new WebChromeClient() {
            @Override
            public boolean onJsAlert(WebView webView, String str, String str2, JsResult jsResult) {
                return super.onJsAlert(webView, str, str2, jsResult);
            }
        });
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
            this.mProgressbar.show();
        }
        this.wv.loadUrl(string);
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() == 16908332) {
            super.onBackPressed();
            return true;
        }
        return super.onOptionsItemSelected(menuItem);
    }

    protected void onResume() {
        super.onResume();
        String string = getSharedPreferences("", 0).getString("usernamekey", "");
        Bundle bundle = new Bundle();
        bundle.putString("user_name", string);
        FirebaseAnalytics.getInstance(this).logEvent("PAGE_LEARNING_LINKS", bundle);
    }

    protected void onDestroy() {
        if (this.isLearning) {
            Utility.saveLinkViewLog(this.context, this.subjectGUID, this.chapterId, this.topicId, this.resourceId, 1);
        }
        super.onDestroy();
    }

    protected void onStop() {
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null && transparentProgressDialog.isShowing()) {
            this.mProgressbar.dismiss();
        }
        super.onStop();
    }
}