2017-04-01 20:27:55 +00:00
|
|
|
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 {
|
2017-04-02 04:10:10 +00:00
|
|
|
/* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2017-04-01 20:27:55 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|