package net.chaoswebs.snow10; import android.content.Intent; import android.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.KeyEvent; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends AppCompatActivity { /* Snow10 - Whitespace steganography. electronic invisible ink. Copyright (C) 2017 Kevin Froman https://ChaosWebs.net/ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ private WebView view; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); view = new WebView(this); view.setWebViewClient(new WebViewClient(){ public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url != null && url.startsWith("http://") || url.startsWith("https://")) { view.getContext().startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse(url))); return true; } else { return false; } } }); view.getSettings().setJavaScriptEnabled(true); view.loadUrl("file:///android_asset/index.html"); setContentView(view); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK) && view.canGoBack()) { //if Back key pressed and webview can navigate to previous page view.goBack(); // go back to previous page return true; } else { finish(); // finish the activity } return super.onKeyDown(keyCode, event); } }