2019-04-28 18:54:22 +02:00
|
|
|
package com.darkweb.genesissearchengine;
|
2019-03-27 19:07:03 +01:00
|
|
|
|
2019-04-28 18:54:22 +02:00
|
|
|
import android.app.Application;
|
2019-03-27 19:07:03 +01:00
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
import android.graphics.Color;
|
2019-04-06 15:44:27 +02:00
|
|
|
import android.os.Handler;
|
2019-03-27 19:07:03 +01:00
|
|
|
import android.support.constraint.ConstraintLayout;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.support.v7.app.AppCompatActivity;
|
2019-04-06 15:44:27 +02:00
|
|
|
import android.util.Log;
|
2019-03-27 19:07:03 +01:00
|
|
|
import android.util.Patterns;
|
|
|
|
import android.view.KeyEvent;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.WindowManager;
|
|
|
|
import android.view.inputmethod.InputMethodManager;
|
|
|
|
import android.webkit.*;
|
|
|
|
import android.widget.*;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.net.MalformedURLException;
|
|
|
|
import java.net.URL;
|
|
|
|
import java.util.Stack;
|
|
|
|
|
2019-04-28 18:54:22 +02:00
|
|
|
import com.example.myapplication.R;
|
2019-03-27 19:07:03 +01:00
|
|
|
import info.guardianproject.netcipher.proxy.OrbotHelper;
|
|
|
|
import org.mozilla.gecko.PrefsHelper;
|
|
|
|
import org.mozilla.geckoview.GeckoRuntime;
|
|
|
|
import org.mozilla.geckoview.GeckoSession;
|
|
|
|
import org.mozilla.geckoview.GeckoView;
|
|
|
|
|
|
|
|
|
|
|
|
import static java.lang.Thread.sleep;
|
|
|
|
|
|
|
|
public class application_controller extends AppCompatActivity
|
|
|
|
{
|
|
|
|
|
|
|
|
/*View Objects*/
|
|
|
|
private WebView webView1;
|
|
|
|
private WebView webView2;
|
|
|
|
private GeckoView webLoader;
|
|
|
|
private ProgressBar progressBar;
|
|
|
|
private ConstraintLayout requestFailure;
|
|
|
|
private ConstraintLayout splashScreen;
|
|
|
|
private Button reloadButton;
|
|
|
|
private ImageButton homeButton;
|
|
|
|
private EditText searchbar;
|
|
|
|
private LinearLayout topbar;
|
|
|
|
private GeckoSession session1;
|
|
|
|
private GeckoRuntime runtime1;
|
2019-04-28 18:54:22 +02:00
|
|
|
private String version_code = "3.0";
|
2019-04-06 15:44:27 +02:00
|
|
|
private boolean wasBackPressed = false;
|
|
|
|
private boolean isLoadedUrlSet = false;
|
|
|
|
private boolean isOnnionUrlHalted = false;
|
|
|
|
Handler handler = null;
|
2019-04-07 19:25:58 +02:00
|
|
|
Runnable geckoRunnable = null;
|
|
|
|
boolean isBlackPage = false;
|
2019-03-27 19:07:03 +01:00
|
|
|
/*helper Variables*/
|
|
|
|
Stack traceUrlList = new Stack<String>();
|
|
|
|
|
|
|
|
/*-------------------------------------------------------INITIALIZATION-------------------------------------------------------*/
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState)
|
|
|
|
{
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.application_view);
|
2019-04-07 19:25:58 +02:00
|
|
|
initializeRunnable();
|
2019-03-27 19:07:03 +01:00
|
|
|
initializeProxy();
|
|
|
|
initializeConnections();
|
|
|
|
initializeOrbot();
|
|
|
|
initializeWebViews();
|
|
|
|
initializeView();
|
|
|
|
initializeAds();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void versionChecker()
|
|
|
|
{
|
|
|
|
String version = preference_manager.getInstance().getString("version","none",this);
|
|
|
|
if(!version.equals(version_code) && !version.equals("none"))
|
|
|
|
{
|
|
|
|
message_manager.getInstance().versionWarning(this);
|
|
|
|
}
|
2019-04-06 15:44:27 +02:00
|
|
|
webRequestHandler.getInstance().getVersion(this);
|
2019-03-27 19:07:03 +01:00
|
|
|
}
|
|
|
|
|
2019-04-07 19:25:58 +02:00
|
|
|
public void initializeRunnable()
|
|
|
|
{
|
|
|
|
handler = new Handler();
|
|
|
|
handler.postDelayed(geckoRunnable,15000);
|
|
|
|
|
|
|
|
Runnable my_runnable = new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
if(!isBlackPage)
|
|
|
|
{
|
|
|
|
Log.i("SHIT1 : ",status.currentURL);
|
|
|
|
progressBar.animate().setDuration(150).alpha(0f).withEndAction((() -> progressBar.setVisibility(View.INVISIBLE)));;
|
|
|
|
datamodel.getInstance().setIsLoadingURL(false);
|
|
|
|
message_manager.getInstance().URLNotFoundError(application_controller.this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-03-27 19:07:03 +01:00
|
|
|
public void initializeAds()
|
|
|
|
{
|
|
|
|
admanager.getInstance().initialize(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void initializeProxy()
|
|
|
|
{
|
|
|
|
PrefsHelper.setPref("network.proxy.type",1); //manual proxy settings
|
|
|
|
PrefsHelper.setPref("network.proxy.socks","127.0.0.1"); //manual proxy settings
|
|
|
|
PrefsHelper.setPref("network.proxy.socks_port",9050); //manual proxy settings
|
|
|
|
PrefsHelper.setPref("network.proxy.socks_version",5); //manual proxy settings
|
|
|
|
PrefsHelper.setPref("network.proxy.socks_remote_dns",true); //manual proxy settings
|
|
|
|
PrefsHelper.setPref("browser.cache.disk.enable",false);
|
2019-04-06 15:44:27 +02:00
|
|
|
PrefsHelper.setPref("browser.cache.memory.enable",false);
|
2019-03-27 19:07:03 +01:00
|
|
|
PrefsHelper.setPref("general.useragent.override", "Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20100101 Firefox/17.0");
|
|
|
|
PrefsHelper.setPref("privacy.donottrackheader.enabled",false);
|
|
|
|
PrefsHelper.setPref("privacy.donottrackheader.value",1);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void initializeConnections()
|
|
|
|
{
|
|
|
|
webView1 = findViewById(R.id.pageLoader1);
|
|
|
|
webView2 = findViewById(R.id.pageLoader2);
|
|
|
|
progressBar = findViewById(R.id.progressBar);
|
|
|
|
requestFailure = findViewById(R.id.requestFailure);
|
|
|
|
splashScreen = findViewById(R.id.splashScreen);
|
|
|
|
reloadButton = findViewById(R.id.reloadButton);
|
|
|
|
homeButton = findViewById(R.id.home);
|
|
|
|
searchbar = findViewById(R.id.search);
|
|
|
|
topbar = findViewById(R.id.topbar);
|
|
|
|
webLoader = findViewById(R.id.webLoader);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void initializeOrbot()
|
|
|
|
{
|
|
|
|
Intent orbot = OrbotHelper.getOrbotStartIntent(getApplicationContext());
|
|
|
|
getApplicationContext().registerReceiver(orbot_manager.getInstance().orbotStatusReceiver,new IntentFilter(OrbotHelper.ACTION_STATUS));
|
|
|
|
getApplicationContext().sendBroadcast(orbot);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void initializeWebViews()
|
|
|
|
{
|
2019-04-07 19:25:58 +02:00
|
|
|
webRequestHandler.getInstance().initialization(webView1,webView2,progressBar,searchbar,requestFailure,this,splashScreen);
|
2019-03-27 19:07:03 +01:00
|
|
|
webView1.bringToFront();
|
2019-04-07 19:25:58 +02:00
|
|
|
progressBar.animate().setDuration(150).alpha(0f);
|
2019-03-27 19:07:03 +01:00
|
|
|
|
2019-04-28 18:54:22 +02:00
|
|
|
new Thread()
|
|
|
|
{
|
|
|
|
public void run()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
session1 = new GeckoSession();
|
|
|
|
runtime1 = GeckoRuntime.create(application_controller.this);
|
|
|
|
session1.open(runtime1);
|
|
|
|
webLoader.setSession(session1);
|
|
|
|
session1.setProgressDelegate(new progressDelegate());
|
|
|
|
webLoader.setVisibility(View.INVISIBLE);
|
|
|
|
sleep(2000);
|
|
|
|
}
|
|
|
|
catch (InterruptedException e)
|
|
|
|
{
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.start();
|
2019-03-27 19:07:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*Initialization*/
|
|
|
|
public void initializeView()
|
|
|
|
{
|
|
|
|
webView1.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
|
|
|
|
webView1.setBackgroundColor(Color.WHITE);
|
|
|
|
webView1.setWebViewClient(loadWebViewClient());
|
|
|
|
webView1.getSettings().setJavaScriptEnabled(true);
|
|
|
|
webView1.getSettings().setUseWideViewPort(true);
|
|
|
|
|
|
|
|
webView2.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
|
|
|
|
webView2.setBackgroundColor(Color.WHITE);
|
|
|
|
webView2.setWebViewClient(loadWebViewClient());
|
|
|
|
webView2.getSettings().setJavaScriptEnabled(true);
|
|
|
|
webView2.getSettings().setUseWideViewPort(true);
|
|
|
|
|
|
|
|
webView2.animate().setDuration(0).alpha(0f);
|
|
|
|
progressBar.setVisibility(View.INVISIBLE);
|
|
|
|
requestFailure.animate().setDuration(0).alpha(0.0f);
|
2019-04-07 19:25:58 +02:00
|
|
|
progressBar.animate().setDuration(150).alpha(0f);
|
2019-03-27 19:07:03 +01:00
|
|
|
|
|
|
|
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
|
|
|
loadURLAnimate(constants.backendUrl);
|
|
|
|
initializeViewClients();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void initializeViewClients()
|
|
|
|
{
|
|
|
|
searchbar.setOnEditorActionListener((v, actionId, event) -> {
|
|
|
|
return onEditorClicked(v, actionId, event);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------WEBVIEW LISTENERS-------------------------------------------------------*/
|
|
|
|
|
|
|
|
private WebViewClient loadWebViewClient()
|
|
|
|
{
|
|
|
|
WebViewClient client = new WebViewClient()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean shouldOverrideUrlLoading(WebView view, String url)
|
|
|
|
{
|
2019-04-06 15:44:27 +02:00
|
|
|
if(url.equals(searchbar.getText().toString()))
|
|
|
|
{
|
|
|
|
view.stopLoading();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-27 19:07:03 +01:00
|
|
|
if(!url.toString().contains("boogle"))
|
|
|
|
{
|
|
|
|
boolean init_status=orbot_manager.getInstance().reinitOrbot(application_controller.this);
|
2019-04-28 18:54:22 +02:00
|
|
|
if(init_status)
|
2019-03-27 19:07:03 +01:00
|
|
|
{
|
2019-04-28 18:54:22 +02:00
|
|
|
searchbar.setText(url.replaceAll("boogle.store","genesis.onion"));
|
|
|
|
KeyboardUtils.hideKeyboard(application_controller.this);
|
|
|
|
admanager.getInstance().showAd();
|
|
|
|
|
2019-04-06 15:44:27 +02:00
|
|
|
progressBar.setAlpha(0);
|
|
|
|
progressBar.setVisibility(View.VISIBLE);
|
2019-04-07 19:25:58 +02:00
|
|
|
progressBar.animate().setDuration(150).setDuration(300).alpha(1f);
|
2019-04-06 15:44:27 +02:00
|
|
|
|
|
|
|
isOnnionUrlHalted = false;
|
|
|
|
session1.stop();
|
2019-03-27 19:07:03 +01:00
|
|
|
session1.close();
|
2019-04-06 15:44:27 +02:00
|
|
|
webLoader.releaseSession();
|
2019-03-27 19:07:03 +01:00
|
|
|
session1 = new GeckoSession();
|
|
|
|
session1.open(runtime1);
|
|
|
|
session1.setProgressDelegate(new progressDelegate());
|
|
|
|
webLoader.setSession(session1);
|
|
|
|
|
|
|
|
session1.loadUri(url);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-28 18:54:22 +02:00
|
|
|
searchbar.setText(url.replaceAll("boogle.store","genesis.onion"));
|
|
|
|
KeyboardUtils.hideKeyboard(application_controller.this);
|
2019-03-27 19:07:03 +01:00
|
|
|
if(traceUrlList.size()==0 || !status.currentURL.equals(traceUrlList.peek()))
|
|
|
|
{
|
|
|
|
traceUrlList.add(status.currentURL);
|
|
|
|
status.currentURL = url;
|
|
|
|
}
|
2019-04-28 18:54:22 +02:00
|
|
|
if(url.contains("?"))
|
|
|
|
{
|
|
|
|
url = url+"&savesearch=on";
|
|
|
|
}
|
2019-03-27 19:07:03 +01:00
|
|
|
loadURLAnimate(url);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public void onPageFinished(WebView view, String url)
|
|
|
|
{
|
|
|
|
super.onPageFinished(view, url);
|
|
|
|
|
2019-04-06 15:44:27 +02:00
|
|
|
webView1.stopLoading();
|
|
|
|
webView2.stopLoading();
|
2019-03-27 19:07:03 +01:00
|
|
|
webView1.animate().setDuration(250).alpha(1f);
|
|
|
|
webView2.animate().setDuration(250).alpha(1f).withEndAction((() -> {
|
|
|
|
datamodel.getInstance().setIsLoadingURL(false);
|
|
|
|
requestFailure.animate().alpha(0f).setDuration(300).withEndAction((() -> requestFailure.setVisibility(View.INVISIBLE)));;
|
|
|
|
|
|
|
|
}));;
|
|
|
|
|
2019-04-07 19:25:58 +02:00
|
|
|
progressBar.animate().setDuration(150).alpha(0f).withEndAction((() -> progressBar.setVisibility(View.INVISIBLE)));;
|
2019-03-27 19:07:03 +01:00
|
|
|
|
|
|
|
if(!status.hasApplicationLoaded)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
sleep(2000);
|
|
|
|
}
|
|
|
|
catch (InterruptedException e)
|
|
|
|
{
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
status.hasApplicationLoaded = true;
|
|
|
|
splashScreen.animate().alpha(0.0f).setDuration(300).setListener(null).withEndAction((() -> splashScreen.setVisibility(View.GONE)));
|
|
|
|
versionChecker();
|
|
|
|
}
|
|
|
|
|
|
|
|
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
imm.hideSoftInputFromWindow(searchbar.getWindowToken(), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
|
|
|
|
{
|
2019-04-07 19:25:58 +02:00
|
|
|
handler = new Handler();
|
|
|
|
handler.postDelayed(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
progressBar.animate().setDuration(150).alpha(0f).withEndAction((() -> progressBar.setVisibility(View.INVISIBLE)));;
|
|
|
|
datamodel.getInstance().setIsLoadingURL(false);
|
|
|
|
splashScreen.animate().alpha(0);
|
|
|
|
requestFailure.setVisibility(View.VISIBLE);
|
|
|
|
requestFailure.animate().alpha(1.0f);
|
|
|
|
}
|
|
|
|
}, 3000);
|
|
|
|
|
2019-03-27 19:07:03 +01:00
|
|
|
super.onReceivedError(view, errorCode, description, failingUrl);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if(!helperMethod.isNetworkAvailable(this))
|
|
|
|
{
|
|
|
|
status.hasApplicationLoaded = true;
|
|
|
|
splashScreen.animate().setStartDelay(2000).alpha(0.0f).setDuration(300).setListener(null).withEndAction((new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run()
|
|
|
|
{
|
|
|
|
splashScreen.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
|
|
|
requestFailure.setVisibility(View.VISIBLE);
|
|
|
|
requestFailure.animate().alpha(1.0f);
|
|
|
|
loadErrorPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
return client;
|
|
|
|
}
|
|
|
|
|
2019-04-07 19:25:58 +02:00
|
|
|
|
2019-03-27 19:07:03 +01:00
|
|
|
class progressDelegate implements GeckoSession.ProgressDelegate
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void onPageStart(GeckoSession session, String url)
|
|
|
|
{
|
2019-04-28 18:54:22 +02:00
|
|
|
if(!orbot_manager.getInstance().reinitOrbot(application_controller.this))
|
|
|
|
{
|
|
|
|
session1.stop();
|
|
|
|
session1.close();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-04-06 15:44:27 +02:00
|
|
|
if(isOnnionUrlHalted)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
isLoadedUrlSet = false;
|
|
|
|
KeyboardUtils.hideKeyboard(application_controller.this);
|
2019-03-27 19:07:03 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
URL host = new URL(url);
|
|
|
|
if(!host.getHost().contains("onion"))
|
|
|
|
{
|
|
|
|
session1.stop();
|
2019-04-06 15:44:27 +02:00
|
|
|
//session1.close();
|
|
|
|
//session1.stop();
|
2019-03-27 19:07:03 +01:00
|
|
|
message_manager.getInstance().baseURLError(application_controller.this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (MalformedURLException e)
|
|
|
|
{
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
datamodel.getInstance().setIsLoadingURL(true);
|
2019-04-07 19:25:58 +02:00
|
|
|
isBlackPage = url.equals("about:blank");
|
2019-03-27 19:07:03 +01:00
|
|
|
if(!isBlackPage)
|
|
|
|
{
|
2019-04-06 15:44:27 +02:00
|
|
|
searchbar.setText(url);
|
2019-03-27 19:07:03 +01:00
|
|
|
}
|
2019-04-06 15:44:27 +02:00
|
|
|
if(!isBlackPage && progressBar.getVisibility() == View.INVISIBLE)
|
2019-03-27 19:07:03 +01:00
|
|
|
{
|
|
|
|
progressBar.setAlpha(0);
|
|
|
|
progressBar.setVisibility(View.VISIBLE);
|
2019-04-07 19:25:58 +02:00
|
|
|
progressBar.animate().setDuration(150).alpha(1f);
|
2019-03-27 19:07:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public void onPageStop(GeckoSession session, boolean success)
|
|
|
|
{
|
2019-04-07 19:25:58 +02:00
|
|
|
if(!success)
|
|
|
|
{
|
|
|
|
handler.postDelayed(geckoRunnable, 15000);
|
|
|
|
}
|
2019-03-27 19:07:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onProgressChange(GeckoSession session, int progress)
|
|
|
|
{
|
2019-04-06 15:44:27 +02:00
|
|
|
if(progress>=100)
|
2019-03-27 19:07:03 +01:00
|
|
|
{
|
2019-04-06 15:44:27 +02:00
|
|
|
if(!isLoadedUrlSet &&!isOnnionUrlHalted)
|
|
|
|
{
|
|
|
|
webLoader.bringToFront();
|
|
|
|
webLoader.animate().setDuration(100).alpha(1);
|
|
|
|
webLoader.setVisibility(View.VISIBLE);
|
|
|
|
requestFailure.animate().alpha(0f).setDuration(300).withEndAction((() -> requestFailure.setVisibility(View.INVISIBLE)));;
|
|
|
|
|
|
|
|
String url = searchbar.getText().toString();
|
|
|
|
boolean isBlackPage = url.equals("about:blank");
|
|
|
|
if(!isBlackPage && !wasBackPressed)
|
|
|
|
{
|
2019-04-07 19:25:58 +02:00
|
|
|
Log.i("SHIT2 : ",status.currentURL);
|
2019-04-06 15:44:27 +02:00
|
|
|
traceUrlList.add(status.currentURL);
|
|
|
|
searchbar.setText(url);
|
|
|
|
status.currentURL = url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
isLoadedUrlSet = true;
|
|
|
|
}
|
|
|
|
if(progress>=100)
|
|
|
|
{
|
2019-04-07 19:25:58 +02:00
|
|
|
progressBar.animate().setDuration(150).alpha(0f).withEndAction((() -> progressBar.setVisibility(View.INVISIBLE)));;
|
2019-04-06 15:44:27 +02:00
|
|
|
datamodel.getInstance().setIsLoadingURL(false);
|
|
|
|
}
|
2019-03-27 19:07:03 +01:00
|
|
|
|
2019-04-07 19:25:58 +02:00
|
|
|
handler.removeCallbacks(geckoRunnable);
|
2019-03-27 19:07:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSecurityChange(GeckoSession session, SecurityInformation securityInfo)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*-------------------------------------------------------Helper Method-------------------------------------------------------*/
|
|
|
|
|
|
|
|
public void loadErrorPage()
|
|
|
|
{
|
|
|
|
requestFailure.animate().alpha(0.0f).setDuration(300).setListener(null).withEndAction((() -> {
|
|
|
|
requestFailure.setVisibility(View.GONE);
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void loadURLAnimate(String url)
|
|
|
|
{
|
|
|
|
webRequestHandler.getInstance().loadURL(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------EVENT LISTENERS-------------------------------------------------------*/
|
|
|
|
|
|
|
|
public void onHomeButtonPressed(View view)
|
|
|
|
{
|
2019-04-06 15:44:27 +02:00
|
|
|
webRequestHandler.getInstance().isUrlStoped=true;
|
2019-04-07 19:25:58 +02:00
|
|
|
searchbar.setText("https://genesis.onion");
|
|
|
|
|
|
|
|
status.currentURL="https://boogle.store";
|
|
|
|
progressBar.setAlpha(0f);
|
2019-03-27 19:07:03 +01:00
|
|
|
progressBar.setVisibility(View.VISIBLE);
|
2019-04-07 19:25:58 +02:00
|
|
|
progressBar.animate().setDuration(150).alpha(1f);
|
|
|
|
loadURLAnimate("https://boogle.store");
|
2019-04-06 15:44:27 +02:00
|
|
|
webView1.stopLoading();
|
|
|
|
webView2.stopLoading();
|
|
|
|
session1.close();
|
|
|
|
isOnnionUrlHalted = true;
|
|
|
|
wasBackPressed = false;
|
|
|
|
KeyboardUtils.hideKeyboard(application_controller.this);
|
|
|
|
webRequestHandler.getInstance().isUrlStoped=false;
|
2019-03-27 19:07:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onReloadButtonPressed(View view)
|
|
|
|
{
|
2019-04-07 19:25:58 +02:00
|
|
|
webRequestHandler.getInstance().isReloadedUrl = true;
|
|
|
|
progressBar.animate().setDuration(150).alpha(0f);
|
2019-03-27 19:07:03 +01:00
|
|
|
progressBar.setVisibility(View.VISIBLE);
|
2019-04-07 19:25:58 +02:00
|
|
|
progressBar.animate().setDuration(150).alpha(1f);
|
2019-03-27 19:07:03 +01:00
|
|
|
loadURLAnimate(status.currentURL);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBackPressed()
|
|
|
|
{
|
2019-04-06 15:44:27 +02:00
|
|
|
session1.stop();
|
2019-03-27 19:07:03 +01:00
|
|
|
if(traceUrlList.size()>0)
|
|
|
|
{
|
|
|
|
searchbar.setText(traceUrlList.peek().toString().replaceAll("boogle.store","genesis.onion"));
|
|
|
|
if(traceUrlList.peek().toString().contains("boogle.store"))
|
|
|
|
{
|
|
|
|
if(!status.currentURL.contains("boogle.store"))
|
|
|
|
{
|
2019-04-06 15:44:27 +02:00
|
|
|
Log.i("FITS4 : " , "");
|
|
|
|
isOnnionUrlHalted=true;
|
|
|
|
session1.stop();
|
|
|
|
session1.close();
|
|
|
|
webLoader.releaseSession();
|
2019-03-27 19:07:03 +01:00
|
|
|
status.currentURL = traceUrlList.pop().toString();
|
2019-04-07 19:25:58 +02:00
|
|
|
progressBar.animate().setDuration(150).alpha(0f).withEndAction((() -> progressBar.setVisibility(View.INVISIBLE)));;
|
2019-04-06 15:44:27 +02:00
|
|
|
webLoader.animate().alpha(0f).withEndAction((() -> webLoader.setVisibility(View.INVISIBLE)));;
|
|
|
|
isOnnionUrlHalted = true;
|
|
|
|
wasBackPressed = false;
|
|
|
|
KeyboardUtils.hideKeyboard(application_controller.this);
|
2019-03-27 19:07:03 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-06 15:44:27 +02:00
|
|
|
session1.close();
|
|
|
|
Log.i("FITS3 : " , "");
|
2019-03-27 19:07:03 +01:00
|
|
|
loadURLAnimate(traceUrlList.pop().toString());
|
|
|
|
if(traceUrlList.size()<=0)
|
|
|
|
{
|
2019-04-07 19:25:58 +02:00
|
|
|
status.currentURL = "https://boogle.store";
|
2019-03-27 19:07:03 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
status.currentURL = traceUrlList.peek().toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(traceUrlList.size()<=0 || traceUrlList.peek().toString().contains("boogle.store"))
|
|
|
|
{
|
2019-04-06 15:44:27 +02:00
|
|
|
Log.i("FITS2 : " , "");
|
2019-04-07 19:25:58 +02:00
|
|
|
status.currentURL = "https://boogle.store";
|
2019-03-27 19:07:03 +01:00
|
|
|
webLoader.animate().setDuration(250).alpha(0);
|
2019-04-06 15:44:27 +02:00
|
|
|
traceUrlList.pop();
|
|
|
|
wasBackPressed = false;
|
|
|
|
session1.close();
|
2019-03-27 19:07:03 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
webLoader.animate().setDuration(250).alpha(1);
|
|
|
|
status.currentURL = traceUrlList.peek().toString();
|
2019-04-06 15:44:27 +02:00
|
|
|
String prevURL = traceUrlList.pop().toString();
|
|
|
|
Log.i("FITS : " , prevURL);
|
|
|
|
session1.goBack();
|
|
|
|
wasBackPressed = true;
|
2019-03-27 19:07:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(traceUrlList.size()==0)
|
|
|
|
{
|
2019-04-06 15:44:27 +02:00
|
|
|
searchbar.setText("https://genesis.onion/");
|
2019-03-27 19:07:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-06 15:44:27 +02:00
|
|
|
public void loadGeckoUrl(String url)
|
|
|
|
{
|
|
|
|
session1.close();
|
|
|
|
session1 = new GeckoSession();
|
|
|
|
session1.open(runtime1);
|
|
|
|
session1.setProgressDelegate(new application_controller.progressDelegate());
|
|
|
|
webLoader.releaseSession();
|
|
|
|
webLoader.setSession(session1);
|
|
|
|
session1.loadUri(url);
|
|
|
|
}
|
|
|
|
|
2019-03-27 19:07:03 +01:00
|
|
|
public boolean onEditorClicked(TextView v, int actionId, KeyEvent event)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
session1.stop();
|
2019-04-06 15:44:27 +02:00
|
|
|
webView1.stopLoading();
|
|
|
|
webView2.stopLoading();
|
|
|
|
//session1.close();
|
2019-03-27 19:07:03 +01:00
|
|
|
String url = v.getText().toString();
|
|
|
|
if(!url.startsWith("www.")&& !url.startsWith("http://")&& !url.startsWith("https://")){
|
|
|
|
url = "www."+url;
|
|
|
|
}
|
|
|
|
if(!url.startsWith("http://")&&!url.startsWith("https://")){
|
|
|
|
url = "http://"+url;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
boolean isUrlValid = Patterns.WEB_URL.matcher(url).matches();
|
|
|
|
|
|
|
|
URL host = new URL(url);
|
|
|
|
if(isUrlValid && host.getHost().replace("www.","").contains("."))
|
|
|
|
{
|
|
|
|
if(host.getHost().contains(constants.backendUrlHost)||host.getHost().contains(constants.frontEndUrlHost))
|
|
|
|
{
|
|
|
|
loadURLAnimate(v.getText().toString());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(host.getHost().contains(constants.allowedHost))
|
|
|
|
{
|
2019-04-06 15:44:27 +02:00
|
|
|
if(!orbot_manager.getInstance().reinitOrbot(this))
|
2019-03-27 19:07:03 +01:00
|
|
|
{
|
2019-04-06 15:44:27 +02:00
|
|
|
session1.stop();
|
2019-03-27 19:07:03 +01:00
|
|
|
session1.loadUri(url);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_manager.getInstance().baseURLError(this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-06 15:44:27 +02:00
|
|
|
loadURLAnimate("https://boogle.store/search?q="+v.getText().toString().replaceAll(" ","+")+"&p_num=1&s_type=all");
|
2019-03-27 19:07:03 +01:00
|
|
|
}
|
2019-04-06 15:44:27 +02:00
|
|
|
orbot_manager.getInstance().reinitOrbot(this);
|
2019-03-27 19:07:03 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
catch (IOException e)
|
|
|
|
{
|
2019-04-06 15:44:27 +02:00
|
|
|
loadURLAnimate("https://boogle.store/search?q="+v.getText().toString().replaceAll(" ","+")+"&p_num=1&s_type=all");
|
2019-03-27 19:07:03 +01:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-04-06 15:44:27 +02:00
|
|
|
|
|
|
|
|
2019-03-27 19:07:03 +01:00
|
|
|
}
|
2019-04-06 15:44:27 +02:00
|
|
|
|