FaithChannel v1.1版本的 MD5 值为:0ae9b60bf0ade21502e9498f31962e98

以下内容为反编译后的 MainActivity.java 源代码,内容仅作参考


package com.faithnetwork.faithchannel;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class MainActivity extends AppCompatActivity {
    public static final String PREFS_NAME = "MyPrefsFile";
    private static String TAG = MainActivity.class.getSimpleName();
    private ImageView mDrawerButton;
    private DrawerLayout mDrawerLayout;
    ListView mDrawerList;
    RelativeLayout mDrawerPane;
    private ActionBarDrawerToggle mDrawerToggle;
    ListView mListItemsList;
    ArrayList<NavItem> mNavItems = new ArrayList<>();
    WebView myWebView;
    ProgressDialog pd;
    String theEmail;
    String theFirstName;
    String theLastName;
    String theUserGuid;

    public void sendUserAddList(View view) {
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        getWindow().setFlags(1024, 1024);
        setContentView(R.layout.activity_main);
        SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences("MyPref", 0);
        this.theUserGuid = sharedPreferences.getString("userGuid", null);
        this.theFirstName = sharedPreferences.getString("firstName", null);
        this.theLastName = sharedPreferences.getString("lastName", null);
        this.theEmail = sharedPreferences.getString("email", null);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().hide();
        this.mDrawerButton = (ImageView) findViewById(R.id.drawerButton);
        if (this.theUserGuid == null) {
            sendUserLogIn();
            return;
        }
        new JsonTask().execute(getResources().getString(R.string.baseUrl) + "/rss/json/userbyuserguid.aspx?u=" + this.theUserGuid);
        this.mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
        ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, this.mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {
            @Override
            public void onDrawerOpened(View view) {
                super.onDrawerOpened(view);
                MainActivity.this.invalidateOptionsMenu();
            }

            @Override
            public void onDrawerClosed(View view) {
                super.onDrawerClosed(view);
                String str = MainActivity.TAG;
                Log.d(str, "onDrawerClosed: " + ((Object) MainActivity.this.getTitle()));
                MainActivity.this.invalidateOptionsMenu();
            }
        };
        this.mDrawerToggle = actionBarDrawerToggle;
        this.mDrawerLayout.setDrawerListener(actionBarDrawerToggle);
        this.mDrawerButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (!MainActivity.this.mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
                    MainActivity.this.mDrawerLayout.openDrawer(GravityCompat.START);
                } else {
                    MainActivity.this.mDrawerLayout.closeDrawer(GravityCompat.START);
                }
            }
        });
        Log.d("LOG", "http://teamchurch.com/rss/json/apphomenavigation.aspx?appguid=50601c29-fad5-4f26-b44d-2cf9275893aa");
        new JSONTaskNAV().execute(getResources().getString(R.string.baseUrl) + "/rss/json/appnavigation.aspx?appguid=" + getResources().getString(R.string.appGuid));
        String str = getResources().getString(R.string.baseUrl) + "/custom/loginmobile.aspx?a=" + this.theUserGuid;
        WebView webView = (WebView) findViewById(R.id.webview);
        this.myWebView = webView;
        WebSettings settings = webView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setDomStorageEnabled(true);
        this.myWebView.setBackgroundColor(0);
        this.myWebView.setPadding(0, 0, 0, 0);
        this.myWebView.setInitialScale(getScale());
        this.myWebView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView webView2, String str2) {
                String str3;
                if (str2.contains("?")) {
                    str3 = str2 + "&hide=1";
                } else {
                    str3 = str2 + "?hide=1";
                }
                if (str3.contains("https://") && !str3.contains("faithchannel.com")) {
                    Log.d("URL", str3);
                    MainActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str3)));
                    return true;
                } else if (str3.contains(".pdf")) {
                    String str4 = "http://docs.google.com/gview?embedded=true&url=" + str3;
                    Log.d("URL", str4);
                    MainActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str4)));
                    return true;
                } else {
                    webView2.loadUrl(str3);
                    return true;
                }
            }
        });
        this.myWebView.setWebChromeClient(new MyChrome());
        if (Build.VERSION.SDK_INT >= 21) {
            this.myWebView.getSettings().setMixedContentMode(0);
        }
        this.myWebView.loadUrl(str);
    }

    public void sendUserLogIn() {
        startActivity(new Intent(this, LogInActivity.class));
    }

    public void selectItemFromDrawer(int i) {
        String str = this.mNavItems.get(i).mTitle;
        String str2 = this.mNavItems.get(i).mType;
        String str3 = this.mNavItems.get(i).mUrl;
        this.mDrawerList.setItemChecked(i, true);
        this.mDrawerLayout.closeDrawer(this.mDrawerPane);
        Log.d("LOG", str);
        Log.d("LOG", str2);
        Log.d("LOG", str3);
        if (str2.equals("webviewcontentpage") || str2.equals("webviewlinkurl") || str2.equals("webviewevite") || str2.equals("livestream") || str2.equals("webviewprayerrequest") || str2.equals("webviewcontentpagepadding")) {
            new Intent(getApplicationContext(), WebViewActivity.class);
            if (str3.equals("logout")) {
                getApplicationContext().getSharedPreferences("MyPref", 0).edit().clear().commit();
                sendUserLogIn();
            } else if (str3.contains("https://") && !str3.contains("faithchannel.com")) {
                Log.d("URL", str3);
                startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str3)));
            } else {
                WebView webView = this.myWebView;
                webView.loadUrl(getResources().getString(R.string.baseUrl) + str3);
            }
        }
    }

    public class JSONTaskNAV extends AsyncTask<String, String, ArrayList<NavItem>> {
        public JSONTaskNAV() {
        }

        @Override
        public ArrayList<NavItem> doInBackground(String... strArr) {
            BufferedReader bufferedReader;
            BufferedReader bufferedReader2;
            int i;
            HttpURLConnection httpURLConnection = null;
            try {
                try {
                    try {
                        strArr = (HttpURLConnection) new URL(strArr[0]).openConnection();
                    } catch (Throwable th) {
                        th = th;
                    }
                    try {
                        strArr.connect();
                        bufferedReader2 = new BufferedReader(new InputStreamReader(strArr.getInputStream()));
                        try {
                            StringBuffer stringBuffer = new StringBuffer();
                            while (true) {
                                String readLine = bufferedReader2.readLine();
                                if (readLine == null) {
                                    break;
                                }
                                stringBuffer.append(readLine);
                            }
                            JSONArray jSONArray = new JSONArray(stringBuffer.toString());
                            ArrayList<NavItem> arrayList = new ArrayList<>();
                            for (i = 0; i < jSONArray.length(); i++) {
                                JSONObject jSONObject = jSONArray.getJSONObject(i);
                                arrayList.add(new NavItem(jSONObject.getString("title"), jSONObject.getString("type"), jSONObject.getString("url")));
                                Log.d("LOG", jSONObject.getString("title"));
                            }
                            if (strArr != 0) {
                                strArr.disconnect();
                            }
                            try {
                                bufferedReader2.close();
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                            return arrayList;
                        } catch (MalformedURLException e2) {
                            e = e2;
                            e.printStackTrace();
                            if (strArr != 0) {
                                strArr.disconnect();
                            }
                            if (bufferedReader2 != null) {
                                bufferedReader2.close();
                            }
                            return null;
                        } catch (IOException e3) {
                            e = e3;
                            e.printStackTrace();
                            if (strArr != 0) {
                                strArr.disconnect();
                            }
                            if (bufferedReader2 != null) {
                                bufferedReader2.close();
                            }
                            return null;
                        } catch (JSONException e4) {
                            e = e4;
                            e.printStackTrace();
                            if (strArr != 0) {
                                strArr.disconnect();
                            }
                            if (bufferedReader2 != null) {
                                bufferedReader2.close();
                            }
                            return null;
                        }
                    } catch (MalformedURLException e5) {
                        e = e5;
                        bufferedReader2 = null;
                    } catch (IOException e6) {
                        e = e6;
                        bufferedReader2 = null;
                    } catch (JSONException e7) {
                        e = e7;
                        bufferedReader2 = null;
                    } catch (Throwable th2) {
                        th = th2;
                        bufferedReader = null;
                        httpURLConnection = strArr;
                        if (httpURLConnection != null) {
                            httpURLConnection.disconnect();
                        }
                        if (bufferedReader != null) {
                            try {
                                bufferedReader.close();
                            } catch (IOException e8) {
                                e8.printStackTrace();
                            }
                        }
                        throw th;
                    }
                } catch (MalformedURLException e9) {
                    e = e9;
                    strArr = 0;
                    bufferedReader2 = null;
                } catch (IOException e10) {
                    e = e10;
                    strArr = 0;
                    bufferedReader2 = null;
                } catch (JSONException e11) {
                    e = e11;
                    strArr = 0;
                    bufferedReader2 = null;
                } catch (Throwable th3) {
                    th = th3;
                    bufferedReader = null;
                    if (httpURLConnection != null) {
                    }
                    if (bufferedReader != null) {
                    }
                    throw th;
                }
            } catch (IOException e12) {
                e12.printStackTrace();
            }
        }

        @Override
        public void onPostExecute(ArrayList<NavItem> arrayList) {
            super.onPostExecute((JSONTaskNAV) arrayList);
            MainActivity.this.mNavItems = arrayList;
            MainActivity mainActivity = MainActivity.this;
            mainActivity.mDrawerPane = (RelativeLayout) mainActivity.findViewById(R.id.drawerPane);
            MainActivity mainActivity2 = MainActivity.this;
            mainActivity2.mDrawerList = (ListView) mainActivity2.findViewById(R.id.navList);
            MainActivity mainActivity3 = MainActivity.this;
            MainActivity.this.mDrawerList.setAdapter((ListAdapter) new DrawerListAdapter(mainActivity3.getApplicationContext(), MainActivity.this.mNavItems));
            MainActivity.this.mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
                    MainActivity.this.selectItemFromDrawer(i);
                }
            });
        }
    }

    public class NavItem {
        String mTitle;
        String mType;
        String mUrl;

        public NavItem(String str, String str2, String str3) {
            this.mTitle = str;
            this.mType = str2;
            this.mUrl = str3;
        }
    }

    public class DrawerListAdapter extends BaseAdapter {
        Context mContext;
        ArrayList<NavItem> mNavItems;

        @Override
        public long getItemId(int i) {
            return 0L;
        }

        public DrawerListAdapter(Context context, ArrayList<NavItem> arrayList) {
            this.mContext = context;
            this.mNavItems = arrayList;
        }

        @Override
        public int getCount() {
            return this.mNavItems.size();
        }

        @Override
        public Object getItem(int i) {
            return this.mNavItems.get(i);
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {
            if (view == null) {
                view = ((LayoutInflater) this.mContext.getSystemService("layout_inflater")).inflate(R.layout.drawer_item, (ViewGroup) null);
            }
            TextView textView = (TextView) view.findViewById(R.id.title);
            textView.setText(this.mNavItems.get(i).mTitle);
            textView.setTextColor(-1);
            return view;
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (this.mDrawerToggle.onOptionsItemSelected(menuItem)) {
            return true;
        }
        return super.onOptionsItemSelected(menuItem);
    }

    @Override
    public void onPostCreate(Bundle bundle) {
        super.onPostCreate(bundle);
    }

    private int getScale() {
        return Double.valueOf(Double.valueOf(new Double(((WindowManager) getSystemService("window")).getDefaultDisplay().getWidth()).doubleValue() / new Double(500.0d).doubleValue()).doubleValue() * 100.0d).intValue();
    }

    private class JsonTask extends AsyncTask<String, String, String> {
        private JsonTask() {
        }

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            MainActivity.this.pd = new ProgressDialog(MainActivity.this);
            MainActivity.this.pd.setMessage("Please wait");
            MainActivity.this.pd.setCancelable(false);
            MainActivity.this.pd.show();
        }

        @Override
        public String doInBackground(String... strArr) {
            BufferedReader bufferedReader;
            Throwable th;
            BufferedReader bufferedReader2;
            try {
                try {
                    try {
                        strArr = (HttpURLConnection) new URL(strArr[0]).openConnection();
                    } catch (Throwable th2) {
                        th = th2;
                    }
                    try {
                        strArr.connect();
                        bufferedReader2 = new BufferedReader(new InputStreamReader(strArr.getInputStream()));
                        try {
                            StringBuffer stringBuffer = new StringBuffer();
                            while (true) {
                                String readLine = bufferedReader2.readLine();
                                if (readLine == null) {
                                    break;
                                }
                                stringBuffer.append(readLine + "\n");
                                Log.d("Response: ", "> " + readLine);
                            }
                            String stringBuffer2 = stringBuffer.toString();
                            if (strArr != 0) {
                                strArr.disconnect();
                            }
                            try {
                                bufferedReader2.close();
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                            return stringBuffer2;
                        } catch (MalformedURLException e2) {
                            e = e2;
                            e.printStackTrace();
                            if (strArr != 0) {
                                strArr.disconnect();
                            }
                            if (bufferedReader2 != null) {
                                bufferedReader2.close();
                            }
                            return null;
                        } catch (IOException e3) {
                            e = e3;
                            e.printStackTrace();
                            if (strArr != 0) {
                                strArr.disconnect();
                            }
                            if (bufferedReader2 != null) {
                                bufferedReader2.close();
                            }
                            return null;
                        }
                    } catch (MalformedURLException e4) {
                        e = e4;
                        bufferedReader2 = null;
                    } catch (IOException e5) {
                        e = e5;
                        bufferedReader2 = null;
                    } catch (Throwable th3) {
                        bufferedReader = null;
                        th = th3;
                        if (strArr != 0) {
                            strArr.disconnect();
                        }
                        if (bufferedReader != null) {
                            try {
                                bufferedReader.close();
                            } catch (IOException e6) {
                                e6.printStackTrace();
                            }
                        }
                        throw th;
                    }
                } catch (MalformedURLException e7) {
                    e = e7;
                    strArr = 0;
                    bufferedReader2 = null;
                } catch (IOException e8) {
                    e = e8;
                    strArr = 0;
                    bufferedReader2 = null;
                } catch (Throwable th4) {
                    bufferedReader = null;
                    th = th4;
                    strArr = 0;
                }
            } catch (IOException e9) {
                e9.printStackTrace();
            }
        }

        @Override
        public void onPostExecute(String str) {
            super.onPostExecute((JsonTask) str);
            if (MainActivity.this.pd.isShowing()) {
                MainActivity.this.pd.dismiss();
            }
            try {
                JSONObject jSONObject = new JSONArray(str).getJSONObject(0);
                String string = jSONObject.getString("userGuid");
                String string2 = jSONObject.getString("firstName");
                String string3 = jSONObject.getString("lastName");
                String string4 = jSONObject.getString("email");
                if (string.equals("none")) {
                    MainActivity.this.sendUserLogIn();
                    return;
                }
                SharedPreferences.Editor edit = MainActivity.this.getApplicationContext().getSharedPreferences("MyPref", 0).edit();
                edit.putString("userGuid", string);
                edit.putString("firstName", string2);
                edit.putString("lastName", string3);
                edit.putString("email", string4);
                edit.commit();
                Log.d("LOG", "User account isSuccessful and isActive");
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

    private class MyChrome extends WebChromeClient {
        private View mCustomView;
        private WebChromeClient.CustomViewCallback mCustomViewCallback;
        protected FrameLayout mFullscreenContainer;
        private int mOriginalOrientation;
        private int mOriginalSystemUiVisibility;

        MyChrome() {
        }

        @Override
        public Bitmap getDefaultVideoPoster() {
            if (this.mCustomView == null) {
                return null;
            }
            return BitmapFactory.decodeResource(MainActivity.this.getApplicationContext().getResources(), 2130837573);
        }

        @Override
        public void onHideCustomView() {
            ((FrameLayout) MainActivity.this.getWindow().getDecorView()).removeView(this.mCustomView);
            this.mCustomView = null;
            MainActivity.this.getWindow().getDecorView().setSystemUiVisibility(this.mOriginalSystemUiVisibility);
            MainActivity.this.setRequestedOrientation(this.mOriginalOrientation);
            this.mCustomViewCallback.onCustomViewHidden();
            this.mCustomViewCallback = null;
        }

        @Override
        public void onShowCustomView(View view, WebChromeClient.CustomViewCallback customViewCallback) {
            if (this.mCustomView != null) {
                onHideCustomView();
                return;
            }
            this.mCustomView = view;
            this.mOriginalSystemUiVisibility = MainActivity.this.getWindow().getDecorView().getSystemUiVisibility();
            this.mOriginalOrientation = MainActivity.this.getRequestedOrientation();
            this.mCustomViewCallback = customViewCallback;
            ((FrameLayout) MainActivity.this.getWindow().getDecorView()).addView(this.mCustomView, new FrameLayout.LayoutParams(-1, -1));
            MainActivity.this.getWindow().getDecorView().setSystemUiVisibility(3846);
        }
    }

    public void onMoreClick(View view) {
        if (!this.mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
            this.mDrawerLayout.openDrawer(GravityCompat.START);
        } else {
            this.mDrawerLayout.closeDrawer(GravityCompat.START);
        }
    }

    public void onHomeClick(View view) {
        WebView webView = this.myWebView;
        webView.loadUrl(getResources().getString(R.string.baseUrl) + "/members/index.aspx?hide=1");
    }

    public void onFeaturedClick(View view) {
        WebView webView = this.myWebView;
        webView.loadUrl(getResources().getString(R.string.baseUrl) + "/members/videosfeatured.aspx?subheadertext=Featured&hide=1");
    }

    public void onCollectionsClick(View view) {
        WebView webView = this.myWebView;
        webView.loadUrl(getResources().getString(R.string.baseUrl) + "/members/messagearchive.aspx?hide=1");
    }

    public void onSearchClick(View view) {
        WebView webView = this.myWebView;
        webView.loadUrl(getResources().getString(R.string.baseUrl) + "/members/searchapp.aspx?subheadertext=Search&hide=1");
    }
}