diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..4c35c3ec --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/app_model.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/app_model.java index ba08cb79..cd014321 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/app_model.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/app_model.java @@ -7,7 +7,7 @@ public class app_model /*Data Objects*/ private static String currentURL = "http://boogle.store/"; private static int port = 9150; - private boolean isLoadingURL = false; + private boolean isURLLoading = true; private Context appContext; private application_controller appInstance; @@ -21,16 +21,6 @@ public class app_model /*Getters Setters*/ - public boolean getIsLoadingURL() - { - return isLoadingURL; - } - - public void setIsLoadingURL(boolean status) - { - isLoadingURL = status; - } - public int getPort() { return port; @@ -41,16 +31,6 @@ public class app_model this.port = port; } - public String getCurrentURL() - { - return currentURL; - } - - public void setCurrentURL(String currentURL) - { - this.currentURL = currentURL; - } - public Context getAppContext() { return appContext; diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/applicationViewController.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/applicationViewController.java index a7731375..2aef774a 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/applicationViewController.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/applicationViewController.java @@ -1,24 +1,49 @@ package com.darkweb.genesissearchengine.appManager; +import android.graphics.Color; +import android.graphics.drawable.Drawable; +import android.os.Handler; import android.support.constraint.ConstraintLayout; +import android.support.design.widget.FloatingActionButton; +import android.text.SpannableString; +import android.text.Spanned; +import android.text.style.ForegroundColorSpan; +import android.util.Log; import android.view.View; +import android.view.WindowManager; import android.webkit.WebView; import android.widget.EditText; +import android.widget.ImageView; import android.widget.ProgressBar; import com.darkweb.genesissearchengine.constants.constants; +import com.darkweb.genesissearchengine.constants.status; +import com.darkweb.genesissearchengine.dataManager.preference_manager; +import com.darkweb.genesissearchengine.helperMethod; +import com.darkweb.genesissearchengine.httpManager.serverRequestManager; +import com.darkweb.genesissearchengine.pluginManager.message_manager; +import com.example.myapplication.R; + +import static java.lang.Thread.sleep; public class applicationViewController { /*ViewControllers*/ - private WebView webView1; - private WebView webView2; + private WebView webView; private ProgressBar progressBar; private EditText searchbar; private ConstraintLayout splashScreen; private ConstraintLayout requestFailure; + private FloatingActionButton floatingButton; + private ImageView loading; + private ImageView splashlogo; + private boolean pageLoadedSuccessfully = true; + + /*ProgressBar Delayed Updater*/ + Handler progressBarHandler = null; /*Initializations*/ private static final applicationViewController ourInstance = new applicationViewController(); + public static applicationViewController getInstance() { return ourInstance; @@ -28,55 +53,227 @@ public class applicationViewController { } - public void initialization(WebView webView1,WebView webView2,ProgressBar progressBar,EditText searchbar,ConstraintLayout splashScreen,ConstraintLayout requestFailure) + public void initialization(WebView webView1, ProgressBar progressBar, EditText searchbar, ConstraintLayout splashScreen, ConstraintLayout requestFailure, FloatingActionButton floatingButton, ImageView loading, ImageView splashlogo) { - this.webView1 = webView1; - this.webView2 = webView2; + this.webView = webView1; this.progressBar = progressBar; this.searchbar = searchbar; this.splashScreen = splashScreen; this.requestFailure = requestFailure; + this.floatingButton = floatingButton; + this.loading = loading; + this.splashlogo = splashlogo; + + app_model.getInstance().getAppInstance().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); + checkSSLTextColor(); + initSplashScreen(); + initLock(); + initViews(); } - public void onRequestURL() + public boolean isHiddenView() { - webView1.stopLoading(); - webView2.stopLoading(); + return app_model.getInstance().getAppInstance().isGeckoViewRunning(); + } - progressBar.setProgress(5); - progressBar.setVisibility(View.VISIBLE); - progressBar.animate().setDuration(150).alpha(1f); + public void initViews() + { + floatingButton.setVisibility(View.INVISIBLE); + } + + public void initLock() + { + Drawable img = app_model.getInstance().getAppInstance().getResources().getDrawable( R.drawable.icon_lock); + searchbar.measure(0, 0); + img.setBounds( 0, (int)(searchbar.getMeasuredHeight()*0.00), (int)(searchbar.getMeasuredHeight()*1.10), (int)(searchbar.getMeasuredHeight()*0.69) ); + searchbar.setCompoundDrawables( img, null, null, null ); + } + + public void onRequestTriggered(boolean isHiddenWeb,String url) + { + onProgressBarUpdate(4); + helperMethod.hideKeyboard(); + pageLoadedSuccessfully = true; + onUpdateSearchBar(url); + checkSSLTextColor(); + onClearSearchBarCursor(); + + searchbar.setFocusableInTouchMode(false); + searchbar.setFocusable(false); + searchbar.setFocusableInTouchMode(true); + searchbar.setFocusable(true); } /*Helper Methods*/ public void onInternetError() { splashScreen.animate().setStartDelay(2000).alpha(0); - progressBar.animate().alpha(0); - requestFailure.setVisibility(View.VISIBLE); - requestFailure.animate().alpha(1f).setDuration(300); + webView.setAlpha(0); + requestFailure.animate().alpha(1f).setDuration(150); + pageLoadedSuccessfully = false; + Log.i("jhgjhg",0+""); + onClearSearchBarCursor(); + onProgressBarUpdate(0); } - public void loadUrlOnWebview(String html) + public void onDisableInternetError() { - WebView webView = getCurrentView(); - webView.bringToFront(); - webView.loadDataWithBaseURL(app_model.getInstance().getCurrentURL(),html, "text/html", "utf-8", null); + requestFailure.animate().alpha(0f).setDuration(150).withEndAction((() -> requestFailure.setVisibility(View.INVISIBLE)));; } - public WebView getCurrentView() + public void onPageFinished(boolean status) { - WebView tempView; - if(webView1.getAlpha()==0) + helperMethod.hideKeyboard(); + progressBar.setProgress(100); + + if(!status) { - tempView = webView1; + if(pageLoadedSuccessfully) + { + requestFailure.animate().alpha(0f).setStartDelay(200).setDuration(200).withEndAction((() -> requestFailure.setVisibility(View.INVISIBLE))); + onUpdateView(true); + } + //onUpdateSearchBar(webView.getUrl()); + splashScreen.animate().alpha(0.0f).setStartDelay(150).setDuration(200).setListener(null).withEndAction((() -> splashScreen.setVisibility(View.GONE))); + floatingButton.animate().alpha(0).withEndAction((() -> floatingButton.setVisibility(View.GONE)));; + onWelcomeMessageCheck(); + + app_model.getInstance().getAppInstance().stopHiddenView(); } else { - tempView = webView2; + onUpdateView(false); + floatingButton.animate().alpha(1).withEndAction((() -> floatingButton.setVisibility(View.VISIBLE)));; } - return tempView; } -} + public void checkSSLTextColor() + { + if (searchbar == null) + { + return; + } + + if (searchbar.getText().toString().contains("https://")) + { + SpannableString ss = new SpannableString(searchbar.getText()); + ss.setSpan(new ForegroundColorSpan(Color.argb(255, 0, 123, 43)), 0, 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + ss.setSpan(new ForegroundColorSpan(Color.GRAY), 5, 8, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + searchbar.setText(ss); + } else if (searchbar.getText().toString().contains("http://")) + { + SpannableString ss = new SpannableString(searchbar.getText()); + ss.setSpan(new ForegroundColorSpan(Color.argb(255, 0, 128, 43)), 0, 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + ss.setSpan(new ForegroundColorSpan(Color.GRAY), 4, 7, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + searchbar.setText(ss); + } else + { + SpannableString ss = new SpannableString(searchbar.getText()); + ss.setSpan(new ForegroundColorSpan(Color.BLACK), 0, searchbar.getText().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + searchbar.setText(ss); + } + } + + public void onClearSearchBarCursor() + { + searchbar.clearFocus(); + } + + public void disableFloatingView() + { + floatingButton.animate().alpha(0).withEndAction((() -> floatingButton.setVisibility(View.GONE)));; + + } + + public void onUpdateSearchBar(String url) + { + searchbar.setText(url.replace(constants.backendUrlHost,constants.frontEndUrlHost_v1)); + checkSSLTextColor(); + } + + public void initSplashScreen() + { + boolean hasSoftKey = helperMethod.hasSoftKeys(app_model.getInstance().getAppInstance().getWindowManager()); + int height = helperMethod.screenHeight(hasSoftKey); + + splashlogo.getLayoutParams().height = height; + loading.setAnimation(helperMethod.getRotationAnimation()); + loading.setLayoutParams(helperMethod.getCenterScreenPoint(loading.getLayoutParams())); + } + + public void onProgressBarUpdate(int progress) + { + progressBar.setVisibility(View.VISIBLE); + if(progress==0) + { + progressBar.animate().alpha(0).withEndAction((() -> progressBar.setProgress(progress))); + } + else + { + progressBar.setProgress(progress); + progressBar.setAlpha(1); + } + } + + public void onBackPressed() + { + if(!isHiddenView()) + { + webView.goBack(); + webView.bringToFront(); + webView.setAlpha(1); + webView.setVisibility(View.VISIBLE); + requestFailure.animate().alpha(0f).setDuration(200).withEndAction((() -> requestFailure.setVisibility(View.INVISIBLE))); + onUpdateSearchBar(webView.getUrl()); + } + else + { + app_model.getInstance().getAppInstance().onHiddenGoBack(); + } + } + + public void onUpdateView(boolean status) + { + if(status) + { + floatingButton.animate().alpha(0).withEndAction((() -> floatingButton.setVisibility(View.GONE)));; + webView.setAlpha(1); + webView.setVisibility(View.VISIBLE); + webView.bringToFront(); + onProgressBarUpdate(0); + onUpdateSearchBar(webView.getUrl()); + } + else + { + webView.animate().alpha(0).setDuration(150).withEndAction((() -> webView.setVisibility(View.GONE))); + } + } + + public void onWelcomeMessageCheck() + { + if(!status.isApplicationLoaded) + { + if(!preference_manager.getInstance().getBool("FirstTimeLoaded",false)) + { + message_manager.getInstance().welcomeMessage(); + } + serverRequestManager.getInstance().versionChecker(); + } + } + + public void onReload() + { + if(!isHiddenView()) + { + onRequestTriggered(false,webView.getUrl()); + webView.reload(); + } + else + { + app_model.getInstance().getAppInstance().onReloadHiddenView(); + } + } + + +} \ No newline at end of file diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/application_controller.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/application_controller.java index f8b9bbce..123fa483 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/application_controller.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/application_controller.java @@ -1,84 +1,44 @@ package com.darkweb.genesissearchengine.appManager; -import android.content.Context; import android.content.Intent; -import android.content.pm.ActivityInfo; -import android.content.res.Resources; import android.graphics.Color; -import android.graphics.Point; -import android.graphics.drawable.Drawable; -import android.net.Uri; import android.os.Build; -import android.os.Handler; import android.support.constraint.ConstraintLayout; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AppCompatActivity; -import android.text.SpannableString; -import android.text.Spanned; -import android.text.style.ForegroundColorSpan; -import android.util.DisplayMetrics; import android.util.Log; -import android.util.Patterns; import android.view.*; -import android.view.animation.Animation; -import android.view.animation.RotateAnimation; -import android.view.inputmethod.InputMethodManager; import android.webkit.*; import android.widget.*; -import com.crashlytics.android.Crashlytics; import com.darkweb.genesissearchengine.*; import com.darkweb.genesissearchengine.constants.constants; -import com.darkweb.genesissearchengine.constants.status; -import com.darkweb.genesissearchengine.httpManager.webRequestHandler; +import com.darkweb.genesissearchengine.dataManager.preference_manager; import com.darkweb.genesissearchengine.pluginManager.*; -import com.example.myapplication.BuildConfig; -import io.fabric.sdk.android.Fabric; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Stack; import com.example.myapplication.R; -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 Webviews*/ + private WebView webView; + private GeckoView geckoView; /*View Objects*/ - public WebView webView1; - public WebView webView2; private ProgressBar progressBar; private ConstraintLayout requestFailure; private ConstraintLayout splashScreen; private EditText searchbar; - - private GeckoView webLoader; private FloatingActionButton floatingButton; - private Button reloadButton; - private ImageButton homeButton; - private LinearLayout topbar; - private GeckoSession session1; - private GeckoRuntime runtime1; - private String version_code = "5.0"; - private boolean wasBackPressed = false; - private boolean isLoadedUrlSet = false; - private boolean isGeckoURLLoadded = false; - private boolean isOnnionUrlHalted = false; - Handler handler = null; - Runnable geckoRunnable = null; - boolean isBlackPage = false; - int startPage=0; - Handler geckoHandler = null; - Runnable geckoRunnableError = null; - /*helper Variables*/ - Stack traceUrlList = new Stack(); - boolean isTutorialPopupShown = false; + private ImageView loadingIcon; + private ImageView splashlogo; + + /*Redirection Objects*/ + private geckoClients geckoclient = null; + private webviewClient webviewclient = null; + private eventHandler eventhandler = null; /*-------------------------------------------------------INITIALIZATION-------------------------------------------------------*/ @Override @@ -86,24 +46,22 @@ public class application_controller extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.application_view); - if(BuildConfig.FLAVOR.equals("aarch64")&&Build.SUPPORTED_ABIS[0].equals("arm64-v8a") || BuildConfig.FLAVOR.equals("arm")&&Build.SUPPORTED_ABIS[0].equals("armeabi-v7a") || BuildConfig.FLAVOR.equals("x86")&&Build.SUPPORTED_ABIS[0].equals("x86") || BuildConfig.FLAVOR.equals("x86_64")&&Build.SUPPORTED_ABIS[0].equals("x86_64")) - { - //initializeCrashlytics(); - initializeBackgroundColor(); - setContentView(R.layout.application_view); - app_model.getInstance().setAppContext(this); - app_model.getInstance().setAppInstance(this); - preference_manager.getInstance().initialize(this); - orbot_manager.getInstance().initializeTorClient(); - initializeStatus(); - initializeRunnable(); + if(helperMethod.isBuildValid()) + { + initializeAppModel(); + initializeCrashlytics(); initializeConnections(); - initializeWebViews(); - initializeView(); - initializeAds(); - checkSSLTextColor(); - initSplashScreen(); + initializeWebView(); + initializeLocalEventHandlers(); + + preference_manager.getInstance().initialize(); + orbot_manager.getInstance().reinitOrbot(); + admanager.getInstance().initialize(); + applicationViewController.getInstance().initialization(webView,progressBar,searchbar,splashScreen,requestFailure,floatingButton, loadingIcon,splashlogo); + geckoclient.initialize(geckoView); + + startApplication(); } else { @@ -113,884 +71,182 @@ public class application_controller extends AppCompatActivity } - public void setOrientation() + public void startApplication() { - setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + fabricManager.getInstance().sendEvent("HOME PAGE LOADING : " ); + webView.loadUrl(constants.backendUrl); } - public void initSplashScreen() + public void initializeAppModel() { - ImageView view = findViewById(R.id.imageView_loading_back); - RotateAnimation rotate = new RotateAnimation(0, 360,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f); - - rotate.setDuration(2000); - rotate.setRepeatCount(Animation.INFINITE); - view.setAnimation(rotate); - Display display = getWindowManager().getDefaultDisplay(); - Point size = new Point(); - display.getSize(size); - - ImageView splashlogo = findViewById(R.id.backsplash); - ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) splashlogo.getLayoutParams(); - int height = screenHeight(); - splashlogo.getLayoutParams().height = height; - - ImageView loading = findViewById(R.id.imageView_loading_back); - double heightloader = Resources.getSystem().getDisplayMetrics().heightPixels*0.78; - ViewGroup.MarginLayoutParams params_loading = (ViewGroup.MarginLayoutParams) loading.getLayoutParams(); - params_loading.topMargin = (int)(heightloader); - loading.setLayoutParams(params_loading); - } - - public int screenHeight() - { - if(!hasSoftKeys(this.getWindowManager())) - { - return (int)(Resources.getSystem().getDisplayMetrics().heightPixels)-(getNavigationBarHeight(this)); - } - else - { - return (int)(Resources.getSystem().getDisplayMetrics().heightPixels); - } - } - - public boolean hasSoftKeys(WindowManager windowManager) - { - Display d = windowManager.getDefaultDisplay(); - - DisplayMetrics realDisplayMetrics = new DisplayMetrics(); - d.getRealMetrics(realDisplayMetrics); - - int realHeight = realDisplayMetrics.heightPixels; - int realWidth = realDisplayMetrics.widthPixels; - - DisplayMetrics displayMetrics = new DisplayMetrics(); - d.getMetrics(displayMetrics); - - int displayHeight = displayMetrics.heightPixels; - int displayWidth = displayMetrics.widthPixels; - - return (realWidth - displayWidth) > 0 || (realHeight - displayHeight) > 0; - } - - public int getStatusBarHeight(Context c) { - int result = 0; - int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); - if (resourceId > 0) { - result = getResources().getDimensionPixelSize(resourceId); - } - return result; - } - - public int getNavigationBarHeight(Context c) { - Resources resources = c.getResources(); - int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); - if (resourceId > 0) { - return resources.getDimensionPixelSize(resourceId); - } - return 0; - } - - - public void initializeBackgroundColor() - { - /* - if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.M){ - getWindow().setBackgroundDrawableResource(R.xml.splash_wall_white); - } else{ - getWindow().setBackgroundDrawableResource(R.xml.splash_wall_black); - }*/ - } - - public void initializeStatus() - { - //helperMethod.setPlaystoreStatus(this); - } - - public void initializeCrashlytics() - { - Fabric.with(this, new Crashlytics()); - analyticmanager.getInstance().initialize(this); - analyticmanager.getInstance().logUser(); - } - - 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,Build.SUPPORTED_ABIS[0]); - } - webRequestHandler.getInstance().getVersion(this);*/ - } - - public void initializeRunnable() - { - handler = new Handler(); - handler.postDelayed(geckoRunnable,15000); - - Runnable my_runnable = new Runnable() { - @Override - public void run() { - if(!isBlackPage || startPage>1) - { - Log.i("PROBLEM24",""); - Log.i("SHIT1 : ", app_model.getInstance().getCurrentURL()); - //app_model.getInstance().setIsLoadingURL(false); - message_manager.getInstance().baseURLError(); - } - } - }; - } - - public void initializeAds() - { - admanager.getInstance().initialize(); + app_model.getInstance().setAppContext(this); + app_model.getInstance().setAppInstance(this); } public void initializeConnections() { - webView1 = findViewById(R.id.pageLoader1); - webView2 = findViewById(R.id.pageLoader2); + webView = findViewById(R.id.pageLoader1); + geckoView = findViewById(R.id.webLoader); + 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); floatingButton = findViewById(R.id.floatingActionButton3); - topbar = findViewById(R.id.topbar); - webLoader = findViewById(R.id.webLoader); + loadingIcon = findViewById(R.id.imageView_loading_back); + splashlogo = findViewById(R.id.backsplash); + geckoView = findViewById(R.id.webLoader); + + webviewclient = new webviewClient(); + geckoclient = new geckoClients(); + eventhandler = new eventHandler(); } - public void initializeWebViews() + public void initializeCrashlytics() { - applicationViewController.getInstance().initialization(webView1,webView2,progressBar,searchbar, splashScreen, requestFailure); - webView1.bringToFront(); - progressBar.animate().setDuration(150).alpha(0f); + fabricManager.getInstance().init(); + } - session1 = new GeckoSession(); - runtime1 = GeckoRuntime.getDefault(application_controller.this); - session1.open(runtime1); - if(session1.isOpen()) + public void initializeWebView() + { + setWebViewSettings(webView); + webviewclient.loadWebViewClient(webView); + } + + public void setWebViewSettings(WebView view) + { + view.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); + view.getSettings().setUseWideViewPort(true); + } + + /*------------------------------------------------------- Event Handler ----------------------------------------------------*/ + + private void initializeLocalEventHandlers() + { + searchbar.setOnEditorActionListener((v, actionId, event) -> { - webLoader.releaseSession(); - } - webLoader.setSession(session1); - session1.setProgressDelegate(new progressDelegate()); - webLoader.setVisibility(View.INVISIBLE); - - Drawable img = getResources().getDrawable( R.drawable.icon_lock); - searchbar.measure(0, 0); - img.setBounds( 0, (int)(searchbar.getMeasuredHeight()*0.00), (int)(searchbar.getMeasuredHeight()*1.10), (int)(searchbar.getMeasuredHeight()*0.69) ); - searchbar.setCompoundDrawables( img, null, null, null ); - } - - /*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); - webView1.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); - - webView2.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); - webView2.setBackgroundColor(Color.WHITE); - webView2.setWebViewClient(loadWebViewClient()); - webView2.getSettings().setJavaScriptEnabled(true); - webView2.getSettings().setUseWideViewPort(true); - webView2.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); - - webView2.animate().setDuration(0).alpha(0f); - requestFailure.animate().setDuration(0).alpha(0.0f); - - getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); - loadURLAnimate(constants.backendUrl); - webView2.setAlpha(0); - webView1.setAlpha(0); - initializeViewClients(); - } - - private void initializeViewClients() - { - - webView1.setWebChromeClient(new WebChromeClient(){ - public void onProgressChanged(WebView view, int newProgress){ - if(newProgress<95 && newProgress>5 && view.equals(applicationViewController.getInstance().getCurrentView())) - { - Log.i("SHIT","SHIT1 : " + newProgress); - progressBar.setProgress(newProgress); - } - } + return eventhandler.onEditorClicked(v,actionId,event); }); - webView2.setWebChromeClient(new WebChromeClient(){ - public void onProgressChanged(WebView view, int newProgress){ - if(newProgress<95 && newProgress>5 && view.equals(applicationViewController.getInstance().getCurrentView())) - { - Log.i("SHIT","SHIT2 : " + newProgress); - progressBar.setProgress(newProgress); - } - } - }); - - searchbar.setOnEditorActionListener((v, actionId, event) -> { - Log.i("1actionId : ",actionId+""); - if (actionId == 5) - { - return onEditorClicked(v, actionId, event); - } - else - { - return false; - } - }); - - floatingButton.setOnClickListener(new View.OnClickListener(){ - - @Override - public void onClick(View v) - { - message_manager.getInstance().reportURL(searchbar.getText().toString()); - } - }); - } - - /*-------------------------------------------------------WEBVIEW LISTENERS-------------------------------------------------------*/ - - public void loadGeckoURL(String url) - { - - boolean init_status=orbot_manager.getInstance().initOrbot(); - if(init_status) - { - searchbar.setText(url.replaceAll("boogle.store","genesis.onion")); - checkSSLTextColor(); - helperMethod.hideKeyboard(); - - Log.i("PROBLEM11",""); - - isOnnionUrlHalted = false; - session1.stop(); - session1.close(); - webLoader.releaseSession(); - session1 = new GeckoSession(); - session1.open(runtime1); - session1.setProgressDelegate(new progressDelegate()); - webLoader.setSession(session1); - - session1.loadUri(url); - } - } - - private WebViewClient loadWebViewClient() - { - WebViewClient client = new WebViewClient() - { - @Override - public boolean shouldOverrideUrlLoading(WebView view, String url) - { - URL host = null; - - if(url.equals(searchbar.getText().toString())) - { - view.stopLoading(); - return true; - } - - if(!url.toString().contains("boogle")) - { - try - { - if(orbot_manager.getInstance().initOrbot()) - { - loadGeckoURL(url); - } - } - catch (Exception ex) - { - ex.printStackTrace(); - } - return true; - } - else - { - session1.stop(); - session1.close(); - - searchbar.setText(url.replaceAll("boogle.store","genesis.onion")); - checkSSLTextColor(); - helperMethod.hideKeyboard(); - if(traceUrlList.size()==0 || !app_model.getInstance().getCurrentURL().equals(traceUrlList.peek())) - { - traceUrlList.add(app_model.getInstance().getCurrentURL()); - } - if(url.contains("?")) - { - url = url+"&savesearch=on"; - } - if(!app_model.getInstance().getCurrentURL().equals(url)) - { - - } - - loadURLAnimate(url); - return true; - } - } - @Override - public void onPageFinished(WebView view, String url) - { - super.onPageFinished(view, url); - - handler = new Handler(); - int delay = 150; - if(startPage>2) - { - delay = 0; - } - handler.postDelayed(new Runnable() { - @Override - public void run() { - webView1.stopLoading(); - webView2.stopLoading(); - - int duration = 200; - if(requestFailure.getAlpha()==1) - duration=1; - - progressBar.setProgress(100); - requestFailure.animate().alpha(0f).setDuration(200).withEndAction((() -> requestFailure.setVisibility(View.INVISIBLE)));; - - if(webView1.getAlpha()==0) - { - webView1.animate().setDuration(duration).alpha(1f).withEndAction((() -> webView2.setAlpha(0))); - } - else - { - webView2.animate().setDuration(duration).alpha(1f).withEndAction((() -> webView1.setAlpha(0))); - } - progressBar.animate().alpha(0).withEndAction((() -> progressBar.setVisibility(View.INVISIBLE))); - - //.withEndAction((() -> { - - //}));; - //app_model.getInstance().setIsLoadingURL(false); - //requestFailure.animate().alpha(0f).setDuration(300).withEndAction((() -> requestFailure.setVisibility(View.INVISIBLE)));; - Log.i("PROBLEM12",""); - - - splashScreen.animate().alpha(0.0f).setStartDelay(150).setDuration(200).setListener(null).withEndAction((() -> splashScreen.setVisibility(View.GONE))); - if(!status.isApplicationLoaded) - { - status.isApplicationLoaded = true; - handler = new Handler(); - - Handler popuphandler = new Handler(); - - popuphandler.postDelayed(new Runnable() { - @Override - public void run() { - if(status.isApplicationLoaded && !isTutorialPopupShown) - { - if(!preference_manager.getInstance().getBool("FirstTimeLoaded",false)) { - message_manager.getInstance().welcomeMessage(); - isTutorialPopupShown = true; - } - else if(constants.build_type.equals("local")) - { - versionChecker(); - } - } - } - }, 1000); - - } - - InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(searchbar.getWindowToken(), 0); - - } - }, delay); - } - - @Override - public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) - { - super.onReceivedError(view, errorCode, description, failingUrl); - } - }; - - if(!helperMethod.isNetworkAvailable()) - { - status.isApplicationLoaded = 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); - status.isTorInitialized = false; - loadErrorPage(); - } - - return client; - } - - -class progressDelegate implements GeckoSession.ProgressDelegate -{ - @Override - public void onPageStart(GeckoSession session, String url) - { - isGeckoURLLoadded = false; - isBlackPage = url.equals("about:blank"); - if(!isBlackPage && !orbot_manager.getInstance().initOrbot()) - { - session1.stop(); - session1.close(); - return; - } - - if(isOnnionUrlHalted) - { - return; - } - - isLoadedUrlSet = false; - helperMethod.hideKeyboard(); - try - { - URL host = new URL(url); - if(!host.getHost().contains("onion")) - { - session1.stop(); - //session1.close(); - //session1.stop(); - message_manager.getInstance().baseURLError(); - } - } - catch (MalformedURLException e) - { - e.printStackTrace(); - } - - //app_model.getInstance().setIsLoadingURL(true); - if(!isBlackPage && !wasBackPressed) - { - searchbar.setText(url); - checkSSLTextColor(); - } - if(!isBlackPage && progressBar.getVisibility() == View.INVISIBLE) - { - } - } - @Override - public void onPageStop(GeckoSession session, boolean success) - { - if(!success) - { - initGeckoFailureHandler(isGeckoURLLoadded); - isGeckoURLLoadded = false; - } - if(success) - { - isGeckoURLLoadded = false; - } - } - - @Override - public void onProgressChange(GeckoSession session, int progress) - { - if(geckoHandler!=null) - { - geckoHandler.removeCallbacks(geckoRunnableError); - geckoHandler = null; - } - if(progress>=100) - { - isGeckoURLLoadded = true; - floatingButton.animate().alpha(1); - - 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) - { - checkSSLTextColor(); - traceUrlList.add(app_model.getInstance().getCurrentURL()); - if(app_model.getInstance().getCurrentURL().contains("boogle.store")) - { - admanager.getInstance().showAd(true); - } - else - { - admanager.getInstance().showAd(false); - } - //app_model.getInstance().setCurrentURL(url); - } - wasBackPressed=false; - } - isLoadedUrlSet = true; - } - if(progress>=100) - { - //app_model.getInstance().setIsLoadingURL(false); - } - } - - @Override - public void onSecurityChange(GeckoSession session, SecurityInformation securityInfo) - { - } -} - public void initGeckoFailureHandler(boolean hasURLLoaded) - { - int delay = 15000; - if(!helperMethod.isNetworkAvailable() || hasURLLoaded) - { - delay=0; - } - - if(geckoHandler == null) - { - geckoHandler = new Handler(); - geckoRunnableError = new Runnable() { - @Override - public void run() { - floatingButton.animate().alpha(0); - Log.i("PROBLEM15",""); - //app_model.getInstance().setIsLoadingURL(false); - //requestFailure.setAlpha(0.0f); - //requestFailure.setVisibility(View.VISIBLE); - //requestFailure.animate().alpha(1.0f); - Log.i("PROBLEM16",""); - geckoHandler = null; - - if(!helperMethod.isNetworkAvailable()) - { - //orbot_manager.getInstance().restartOrbot(); - } - wasBackPressed=false; - - } - }; - geckoHandler.postDelayed(geckoRunnableError, delay); - } - } - - /*-------------------------------------------------------Helper Method-------------------------------------------------------*/ - - public void loadErrorPage() - { - //requestFailure.animate().alpha(0.0f).setDuration(300).setListener(null).withEndAction((() -> { - // requestFailure.setVisibility(View.GONE); - //})); - } - - public void loadURLAnimate(String url) - { - if(!app_model.getInstance().getCurrentURL().equals(url)) - { - loadURL(url); - } - } - public void loadURL(String url) - { - app_model.getInstance().setCurrentURL(url); - applicationViewController.getInstance().onRequestURL(); - floatingButton.animate().alpha(0); - webRequestHandler.getInstance().loadURL(url); - } - - /*-------------------------------------------------------EVENT LISTENERS-------------------------------------------------------*/ - - public void initializePopupView(String url) - { - searchbar.setText(url.replaceAll("boogle.store","genesis.onion")); - checkSSLTextColor(); - traceUrlList.add(app_model.getInstance().getCurrentURL()); - //app_model.getInstance().setCurrentURL(url); - Log.i("PROBLEM17",""); - } - - public void onHomeButtonPressed(View view) - { - searchbar.setText(constants.frontUrlSlashed); - checkSSLTextColor(); - traceUrlList.clear(); - loadURLAnimate(constants.backendUrlSlashed); - helperMethod.hideKeyboard(); - - session1.close(); - isOnnionUrlHalted = true; - wasBackPressed = false; } public void onReloadButtonPressed(View view) { - if(searchbar.getText().toString().contains("://genesis.onion")) - { - loadURL(app_model.getInstance().getCurrentURL()); - } - else - { - if(status.isTorInitialized) - { - wasBackPressed = true; - loadGeckoURL(searchbar.getText().toString()); - } - else - { - orbot_manager.getInstance().initOrbot(); - } - } - } - - public void checkSSLTextColor() - { - if(searchbar==null) - { - return; - } - - if(searchbar.getText().toString().contains("https://")) - { - SpannableString ss = new SpannableString(searchbar.getText()); - ss.setSpan(new ForegroundColorSpan(Color.argb(255,0,123,43)),0,5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - ss.setSpan(new ForegroundColorSpan(Color.GRAY),5,8, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - searchbar.setText(ss); - } - else if(searchbar.getText().toString().contains("http://")) - { - SpannableString ss = new SpannableString(searchbar.getText()); - ss.setSpan(new ForegroundColorSpan(Color.argb(255,0,128,43)),0,4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - ss.setSpan(new ForegroundColorSpan(Color.GRAY),4,7, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - searchbar.setText(ss); - } - else - { - SpannableString ss = new SpannableString(searchbar.getText()); - ss.setSpan(new ForegroundColorSpan(Color.BLACK),0,searchbar.getText().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - searchbar.setText(ss); - } - } - - public void backPressed() - { - if(traceUrlList.size()>0) - { - if(traceUrlList.peek().toString().contains("boogle.store")) - { - session1.stop(); - session1.close(); - if(!app_model.getInstance().getCurrentURL().contains("boogle.store")) - { - searchbar.setText(traceUrlList.peek().toString().replaceAll("boogle.store","genesis.onion")); - isOnnionUrlHalted=true; - session1.stop(); - session1.close(); - webLoader.releaseSession(); - webLoader.releaseSession(); - //app_model.getInstance().setCurrentURL(traceUrlList.pop().toString()); - Log.i("PROBLEM22",""); - webLoader.animate().alpha(0f).withEndAction((() -> webLoader.setVisibility(View.INVISIBLE)));; - //isOnnionUrlHalted = true; - helperMethod.hideKeyboard(); - if(requestFailure.getAlpha()==1) - { - //requestFailure.animate().alpha(0f).withEndAction((() -> requestFailure.setVisibility(View.INVISIBLE)));; - } - else - { - } - floatingButton.animate().alpha(0); - } - else - { - Log.i("1LOG3","LOG1"); - searchbar.setText(traceUrlList.peek().toString().replaceAll("boogle.store","genesis.onion")); - session1.close(); - loadURLAnimate(traceUrlList.pop().toString()); - if(traceUrlList.size()<=0) - { - //app_model.getInstance().setCurrentURL("https://boogle.store"); - } - else - { - //app_model.getInstance().setCurrentURL(traceUrlList.peek().toString()); - } - floatingButton.animate().alpha(0); - //} - } - } - else - { - if(traceUrlList.size()<=0 || traceUrlList.peek().toString().contains("boogle.store")) - { - session1.stop(); - session1.close(); - - searchbar.setText(traceUrlList.peek().toString().replaceAll("boogle.store","genesis.onion")); - //app_model.getInstance().setCurrentURL("https://boogle.store"); - webLoader.animate().setDuration(250).alpha(0); - traceUrlList.pop(); - wasBackPressed = false; - session1.close(); - floatingButton.animate().alpha(0); - } - else - { - if(orbot_manager.getInstance().initOrbot() && progressBar.getAlpha()==0) - { - //app_model.getInstance().setCurrentURL(traceUrlList.peek().toString()); - traceUrlList.pop().toString(); - boolean init_status=orbot_manager.getInstance().initOrbot(); - if(init_status) - { - searchbar.setText(app_model.getInstance().getCurrentURL().replaceAll("boogle.store","genesis.onion")); - helperMethod.hideKeyboard(); - wasBackPressed = true; - //requestFailure.animate().alpha(0); - session1.loadUri(app_model.getInstance().getCurrentURL()); - } - } - } - } - if(traceUrlList.size()==0) - { - searchbar.setText("https://genesis.onion/"); - } - checkSSLTextColor(); - } + eventhandler.onReloadButtonPressed(view); } @Override public void onBackPressed() { - backPressed(); + eventhandler.onBackPressed(); } - public boolean onEditorClicked(TextView v, int actionId, KeyEvent event) + public void onFloatingButtonPressed(View view) { - helperMethod.hideKeyboard(); - try - { - session1.stop(); - webView1.stopLoading(); - webView2.stopLoading(); - //session1.close(); - 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 = url.replace("genesis.onion","boogle.store"); - URL host = new URL(url); - if(isUrlValid && host.getHost().replace("www.","").contains(".")) - { - if(host.getHost().contains(constants.backendUrlHost)||host.getHost().contains(constants.frontEndUrlHost)) - { - floatingButton.animate().alpha(0); - loadURLAnimate(url); - return true; - } - else if(host.getHost().contains(constants.allowedHost)) - { - if(!url.contains("://boogle.store")) - { - orbot_manager.getInstance().initOrbot(); - } - - if(status.isTorInitialized) - { - session1.stop(); - session1.loadUri(url); - } - else - { - orbot_manager.getInstance().initOrbot(); - message_manager.getInstance().startingOrbotInfo(); - } - - return true; - } - else - { - message_manager.getInstance().baseURLError(); - return true; - } - } - else - { - String editedURL = "https://boogle.store/search?q="+v.getText().toString().replaceAll(" ","+")+"&p_num=1&s_type=all&savesearch=on"; - //app_model.getInstance().setCurrentURL(editedURL); - searchbar.setText(editedURL.replace("boogle.store","genesis.onion")); - searchbar.clearFocus(); - loadURLAnimate(editedURL); - } - - } - catch (IOException e) - { - String editedURL = "https://boogle.store/search?q="+v.getText().toString().replaceAll(" ","+")+"&p_num=1&s_type=all&savesearch=on"; - //app_model.getInstance().setCurrentURL(editedURL); - searchbar.clearFocus(); - searchbar.setText(editedURL.replace("boogle.store","genesis.onion")); - loadURLAnimate(editedURL); - e.printStackTrace(); - } - return true; + eventhandler.onFloatingButtonPressed(); } + public void onHomeButtonPressed(View view) + { + eventhandler.onHomeButtonPressed(); + } + /*-------------------------------------------------------Helper Method In UI Redirection----------------------------------------------------*/ + public void onloadURL(String url,boolean isHiddenWeb) + { + if(isHiddenWeb) + { + geckoclient.loadGeckoURL(url,geckoView); + } + else + { + webView.loadUrl(url); + onRequestTriggered(isHiddenWeb,url); + } + } + public void onRequestTriggered(boolean isHiddenWeb,String url) + { + applicationViewController.getInstance().onRequestTriggered(isHiddenWeb,url); + } + public void onClearSearchBarCursorView() + { + applicationViewController.getInstance().onClearSearchBarCursor(); + } + public void onUpdateSearchBarView(String url) + { + applicationViewController.getInstance().onUpdateSearchBar(url); + } - - - - - - - - - - - - - - - - - - - public void onInternetError() + public void onInternetErrorView() { applicationViewController.getInstance().onInternetError(); + applicationViewController.getInstance().disableFloatingView(); } - public void loadUrlOnWebview(String html) + public void onDisableInternetError() { - applicationViewController.getInstance().loadUrlOnWebview(html); + applicationViewController.getInstance().onDisableInternetError(); } + + public void onProgressBarUpdateView(int progress) + { + applicationViewController.getInstance().onProgressBarUpdate(progress); + } + + public void onBackPressedView() + { + applicationViewController.getInstance().onBackPressed(); + } + + public void onPageFinished(boolean isHidden) + { + applicationViewController.getInstance().onPageFinished(isHidden); + } + + public void onUpdateView(boolean status) + { + applicationViewController.getInstance().onUpdateView(status); + } + + public void onReload() + { + applicationViewController.getInstance().onReload(); + } + + + /*-------------------------------------------------------Helper Method Out UI Redirection----------------------------------------------------*/ + + public void onHiddenGoBack() + { + geckoclient.onHiddenGoBack(geckoView); + } + + public void stopHiddenView() + { + geckoclient.stopHiddenView(geckoView); + } + + public void onReloadHiddenView() + { + geckoclient.onReloadHiddenView(); + } + + public boolean isGeckoViewRunning() + { + return geckoclient.isGeckoViewRunning(); + } + + public void forcedCachePatch() + { + } + + public boolean isInternetErrorOpened() + { + return requestFailure.getAlpha()==1; + } + } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/eventHandler.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/eventHandler.java new file mode 100644 index 00000000..678e041f --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/eventHandler.java @@ -0,0 +1,100 @@ +package com.darkweb.genesissearchengine.appManager; + +import android.util.Patterns; +import android.view.KeyEvent; +import android.view.View; +import android.view.inputmethod.EditorInfo; +import android.widget.TextView; +import com.darkweb.genesissearchengine.constants.constants; +import com.darkweb.genesissearchengine.helperMethod; +import com.darkweb.genesissearchengine.pluginManager.fabricManager; +import com.darkweb.genesissearchengine.pluginManager.message_manager; + +import java.io.IOException; +import java.net.URL; + +public class eventHandler +{ + application_controller appContoller; + + public eventHandler() + { + appContoller = app_model.getInstance().getAppInstance(); + } + + public boolean onEditorClicked(TextView v, int actionId, KeyEvent event) + { + + if (actionId != EditorInfo.IME_ACTION_NEXT) + { + return false; + } + + helperMethod.hideKeyboard(); + String url = helperMethod.completeURL(v.getText().toString()); + try + { + URL host = new URL(url); + boolean isUrlValid = Patterns.WEB_URL.matcher(url).matches(); + + if(isUrlValid && host.getHost().replace("www.","").contains(".")) + { + if(host.getHost().contains(constants.backendUrlHost) || host.getHost().contains(constants.frontEndUrlHost) || host.getHost().contains(constants.frontEndUrlHost_v1)) + { + fabricManager.getInstance().sendEvent("EDITOR BASE URL REQUEST : " + url); + appContoller.onloadURL(url.replace(constants.frontEndUrlHost_v1,constants.backendUrlHost),false); + return true; + } + else /*if(host.getHost().contains(constants.allowedHost))*/ + { + fabricManager.getInstance().sendEvent("EDITOR ONION URL REQUEST : " + url); + app_model.getInstance().getAppInstance().onloadURL(url,true); + return true; + }/* + else + { + message_manager.getInstance().baseURLError(); + return true; + }*/ + } + } + + catch (IOException e){} + + String editedURL = "https://boogle.store/search?q="+v.getText().toString().replaceAll(" ","+")+"&p_num=1&s_type=all&savesearch=on"; + appContoller.onloadURL(editedURL,false); + appContoller.onClearSearchBarCursorView(); + fabricManager.getInstance().sendEvent("EDITOR SEARCHED : " + editedURL); + + return true; + } + + public void onReloadButtonPressed(View view) + { + fabricManager.getInstance().sendEvent("RELOAD BUTTON PRESSSED : "); + appContoller.onReload(); + } + + public void onHomeButtonPressed() + { + fabricManager.getInstance().sendEvent("HOME BUTTON PRESSSED : "); + applicationViewController.getInstance().checkSSLTextColor(); + appContoller.onloadURL(constants.backendUrlSlashed,false); + helperMethod.hideKeyboard(); + appContoller.onUpdateSearchBarView(constants.frontUrlSlashed); + appContoller.stopHiddenView(); + } + + public void onFloatingButtonPressed() + { + fabricManager.getInstance().sendEvent("FLOATING BUTTON PRESSSED : "); + message_manager.getInstance().reportURL(); + } + + public void onBackPressed() + { + fabricManager.getInstance().sendEvent("BACK BUTTON PRESSSED : "); + appContoller.onBackPressedView(); + } + +} diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/geckoClients.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/geckoClients.java new file mode 100644 index 00000000..b3458176 --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/geckoClients.java @@ -0,0 +1,199 @@ +package com.darkweb.genesissearchengine.appManager; + +import android.graphics.drawable.Drawable; +import android.os.Handler; +import android.util.Log; +import android.view.View; +import com.darkweb.genesissearchengine.helperMethod; +import com.darkweb.genesissearchengine.pluginManager.fabricManager; +import com.darkweb.genesissearchengine.pluginManager.orbot_manager; +import org.mozilla.geckoview.GeckoRuntime; +import org.mozilla.geckoview.GeckoSession; +import org.mozilla.geckoview.GeckoView; + +public class geckoClients +{ + private GeckoSession session1 = null; + private GeckoRuntime runtime1; + private final Handler internetErrorHandler = new Handler(); + + boolean canSessionGoBack = false; + boolean isRunning = false; + boolean isContentLoading = false; + String navigatedURL = ""; + + private boolean loadingCompeleted = false; + private String currentURL = ""; + + public void loadGeckoURL(String url,GeckoView geckoView) + { + boolean init_status = orbot_manager.getInstance().initOrbot(url); + if (init_status) + { + loadingCompeleted = false; + initialize(geckoView); + session1.loadUri(url); + app_model.getInstance().getAppInstance().onRequestTriggered(true,url); + app_model.getInstance().getAppInstance().onProgressBarUpdateView(4); + } + } + + public void initialize(GeckoView geckoView) + { + session1 = new GeckoSession(); + runtime1 = GeckoRuntime.getDefault(app_model.getInstance().getAppContext()); + session1.open(runtime1); + geckoView.releaseSession(); + geckoView.setSession(session1); + session1.setProgressDelegate(new progressDelegate()); + session1.setNavigationDelegate(new navigationDelegate()); + geckoView.setVisibility(View.VISIBLE); + geckoView.setAlpha(1); + } + + class navigationDelegate implements GeckoSession.NavigationDelegate + { + @Override + public void onLocationChange(GeckoSession session, String url) + { + navigatedURL = url; + Log.i("SHITJ1",""+url); + } + + @Override + public void onCanGoBack(GeckoSession session, boolean canGoBack) + { + canSessionGoBack = canGoBack; + } + } + + class progressDelegate implements GeckoSession.ProgressDelegate + { + @Override + public void onPageStart(GeckoSession session, String url) + { + isRunning = true; + loadingCompeleted = false; + currentURL = url; + fabricManager.getInstance().sendEvent("ONION GECKO_CLIENT URL REQEST : " + url + "--"); + + if(navigatedURL.equals(currentURL)) + { + isContentLoading = false; + } + else + { + isContentLoading = true; + } + + Log.i("SHITJ2",""+navigatedURL + "--" + currentURL + "--" + isContentLoading); + navigatedURL = url; + } + + @Override + public void onPageStop(GeckoSession session, boolean success) + { + internetErrorHandler.removeCallbacksAndMessages(null); + + internetErrorHandler.postDelayed(new Runnable() { + @Override + public void run() + { + if(loadingCompeleted) + { + if(!success && !isContentLoading) + { + app_model.getInstance().getAppInstance().onInternetErrorView(); + fabricManager.getInstance().sendEvent("ONION GECKO_CLIENT URL ERROR : " + success + "--" + isContentLoading); + } + else if(success) + { + app_model.getInstance().getAppInstance().onDisableInternetError(); + app_model.getInstance().getAppInstance().onProgressBarUpdateView(0); + fabricManager.getInstance().sendEvent("ONION GECKO_CLIENT URL SUCCESS : " + success + "--" + isContentLoading); + } + } + } + }, 500); + } + + + + @Override + public void onProgressChange(GeckoSession session, int progress) + { + if(progress>=100) + { + app_model.getInstance().getAppInstance().onPageFinished(true); + loadingCompeleted = true; + isContentLoading = false; + } + + if(progress>=5) + { + app_model.getInstance().getAppInstance().onProgressBarUpdateView(progress); + } + else + { + app_model.getInstance().getAppInstance().onProgressBarUpdateView(4); + } + } + + @Override + public void onSecurityChange(GeckoSession session, SecurityInformation securityInfo) + { + } + + } + + public void onHiddenGoBack(GeckoView geckoView) + { + boolean init_status = orbot_manager.getInstance().initOrbot(""); + if (init_status) + { + if(canSessionGoBack) + { + app_model.getInstance().getAppInstance().onDisableInternetError(); + session1.goBack(); + fabricManager.getInstance().sendEvent("ONION LOCAL RETURNED : "); + } + else if(isRunning) + { + fabricManager.getInstance().sendEvent("ONION RETURNED TO GENESIS : "); + geckoView.releaseSession(); + stopHiddenView(geckoView); + app_model.getInstance().getAppInstance().onUpdateView(true); + } + } + } + + public void stopHiddenView(GeckoView geckoView) + { + if(session1!=null) + { + isRunning = false; + loadingCompeleted = false; + session1.stop(); + session1.close(); + } + } + + public boolean isGeckoViewRunning() + { + return isRunning; + } + + public void onReloadHiddenView() + { + boolean init_status = orbot_manager.getInstance().initOrbot(""); + if (init_status) + { + if(session1!=null) + { + loadingCompeleted = false; + session1.stop(); + session1.reload(); + } + } + } +} diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/webviewClient.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/webviewClient.java new file mode 100644 index 00000000..6ecba436 --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/webviewClient.java @@ -0,0 +1,84 @@ +package com.darkweb.genesissearchengine.appManager; + +import android.util.Log; +import android.webkit.WebChromeClient; +import android.webkit.WebView; +import android.webkit.WebViewClient; +import com.darkweb.genesissearchengine.constants.status; +import com.darkweb.genesissearchengine.pluginManager.fabricManager; +import com.darkweb.genesissearchengine.pluginManager.orbot_manager; + +public class webviewClient +{ + boolean isGeckoView = false; + + public void loadWebViewClient(WebView webview) + { + WebViewClient client = new WebViewClient() + { + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) + { + isGeckoView = false; + if(url.equals(view.getUrl()) && !app_model.getInstance().getAppInstance().isInternetErrorOpened() || url.contains("https://boogle.store/search?q=&")) + { + app_model.getInstance().getAppInstance().onProgressBarUpdateView(0); + return true; + } + if(!url.contains("boogle")) + { + fabricManager.getInstance().sendEvent("BASE SIMPLE SEARCHED : " + url); + isGeckoView = true; + if(orbot_manager.getInstance().initOrbot(url)) + { + app_model.getInstance().getAppInstance().onloadURL(url,true); + } + return true; + } + else + { + fabricManager.getInstance().sendEvent("BASE ONION SEARCHED : " + url); + app_model.getInstance().getAppInstance().onRequestTriggered(false,url); + return false; + } + } + @Override + public void onPageFinished(WebView view, String url) + { + super.onPageFinished(view, url); + app_model.getInstance().getAppInstance().onPageFinished(false); + app_model.getInstance().getAppInstance().onUpdateSearchBarView(url); + app_model.getInstance().getAppInstance().onProgressBarUpdateView(0); + status.isApplicationLoaded = true; + fabricManager.getInstance().sendEvent("BASE SUCCESSFULLY LOADED : " + url); + } + + @Override + public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) + { + fabricManager.getInstance().sendEvent("BASE URL ERROR : " + failingUrl + "--" + description); + app_model.getInstance().getAppInstance().onInternetErrorView(); + } + }; + + webview.setWebViewClient(client); + + webview.setWebChromeClient(new WebChromeClient() + { + public void onProgressChanged(WebView view, int newProgress) + { + if(!isGeckoView) + { + if(newProgress<95 && newProgress>5) + { + app_model.getInstance().getAppInstance().onProgressBarUpdateView(newProgress); + } + else if(newProgress<=5) + { + app_model.getInstance().getAppInstance().onProgressBarUpdateView(4); + } + } + } + }); + } +} diff --git a/app/src/main/java/com/darkweb/genesissearchengine/constants/constants.java b/app/src/main/java/com/darkweb/genesissearchengine/constants/constants.java index ee935195..dfec2583 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/constants/constants.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/constants.java @@ -14,6 +14,7 @@ public class constants public static String backendUrlSlashed = "https://boogle.store/"; public static String frontUrlSlashed = "https://genesis.onion/"; public static String frontEndUrlHost = "genesis.store"; + public static String frontEndUrlHost_v1 = "genesis.onion"; public static String allowedHost = ".onion"; public static String reportUrl = "https://boogle.store/reportus?r_key="; public static String updateUrl = "https://boogle.store/manual?abi="; diff --git a/app/src/main/java/com/darkweb/genesissearchengine/constants/enums.java b/app/src/main/java/com/darkweb/genesissearchengine/constants/enums.java index d533f692..90de3ef5 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/constants/enums.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/enums.java @@ -2,6 +2,7 @@ package com.darkweb.genesissearchengine.constants; public class enums { + /*Web Request*/ public enum webRequestStatus{notRunning,running,repeat;} diff --git a/app/src/main/java/com/darkweb/genesissearchengine/constants/keys.java b/app/src/main/java/com/darkweb/genesissearchengine/constants/keys.java index 1172d22e..9a386195 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/constants/keys.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/keys.java @@ -14,8 +14,8 @@ public class keys public static String proxy_socks_port = "network.proxy.socks_port"; public static String proxy_socks_version = "network.proxy.socks_version"; public static String proxy_socks_remote_dns = "network.proxy.socks_remote_dns"; - //public static String proxy_cache = "browser.cache.disk.enable"; - //public static String proxy_memory = "browser.cache.memory.enable"; + public static String proxy_cache = "browser.cache.disk.enable"; + public static String proxy_memory = "browser.cache.memory.enable"; public static String proxy_useragent_override = "general.useragent.override"; public static String proxy_donottrackheader_enabled = "privacy.donottrackheader.enabled"; public static String proxy_donottrackheader_value = "privacy.donottrackheader.value"; diff --git a/app/src/main/java/com/darkweb/genesissearchengine/constants/messages.java b/app/src/main/java/com/darkweb/genesissearchengine/constants/messages.java index c38fadc8..578f93b4 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/constants/messages.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/messages.java @@ -6,5 +6,5 @@ public class messages public final static int LOCAL_HOMEPAGE_CACHED =3; public final static int INTERNET_ERROR =2; public final static int MESSAGE_UPDATE_TEXT_CHILD_THREAD =1; - + public final static int LOAD_WEBVIEW_BACKGROUND = 2; } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/constants/status.java b/app/src/main/java/com/darkweb/genesissearchengine/constants/status.java index 18045f33..24558af9 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/constants/status.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/status.java @@ -5,4 +5,6 @@ public class status public static boolean isApplicationLoaded = false; public static boolean isPlayStoreInstalled = false; public static boolean isTorInitialized = false; + + public static String version_code = "5.0"; } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/constants/strings.java b/app/src/main/java/com/darkweb/genesissearchengine/constants/strings.java index 61ac9bd8..d289d9bd 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/constants/strings.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/strings.java @@ -27,6 +27,7 @@ public class strings public static String orbot_init_title = "Initializing"; public static String orbot_init_desc = "Please wait! While we connect you to hidden web. This might take few minutes\n"; public static String orbot_init_bt1 = "Dismiss"; + public static String orbot_init_bt2 = "Try Again"; public static String version_title = "Update Pending"; public static String version_desc = "You have not updated this app for a while please update it to get best performance\n"; diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/preference_manager.java b/app/src/main/java/com/darkweb/genesissearchengine/dataManager/preference_manager.java similarity index 86% rename from app/src/main/java/com/darkweb/genesissearchengine/pluginManager/preference_manager.java rename to app/src/main/java/com/darkweb/genesissearchengine/dataManager/preference_manager.java index f69abcf4..a5f97dcf 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/preference_manager.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/dataManager/preference_manager.java @@ -1,8 +1,8 @@ -package com.darkweb.genesissearchengine.pluginManager; +package com.darkweb.genesissearchengine.dataManager; -import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; +import com.darkweb.genesissearchengine.appManager.app_model; public class preference_manager { @@ -21,9 +21,9 @@ public class preference_manager { } - public void initialize(Context applicationContext) + public void initialize() { - prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext); + prefs = PreferenceManager.getDefaultSharedPreferences(app_model.getInstance().getAppContext()); edit = prefs.edit(); } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/helperMethod.java b/app/src/main/java/com/darkweb/genesissearchengine/helperMethod.java index 51e9d116..76935ca5 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/helperMethod.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/helperMethod.java @@ -2,13 +2,24 @@ package com.darkweb.genesissearchengine; import android.content.Context; import android.content.SharedPreferences; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.Canvas; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.os.Build; import android.preference.PreferenceManager; +import android.util.DisplayMetrics; +import android.view.Display; import android.view.View; +import android.view.ViewGroup; +import android.view.WindowManager; +import android.view.animation.Animation; +import android.view.animation.RotateAnimation; import android.view.inputmethod.InputMethodManager; import com.darkweb.genesissearchengine.appManager.app_model; import com.darkweb.genesissearchengine.constants.keys; +import com.example.myapplication.BuildConfig; public class helperMethod { @@ -39,6 +50,17 @@ public class helperMethod } + public static String completeURL(String url) + { + if(!url.startsWith("www.")&& !url.startsWith("http://")&& !url.startsWith("https://")){ + url = "www."+url; + } + if(!url.startsWith("http://")&&!url.startsWith("https://")){ + url = "http://"+url; + } + return url; + } + public static void hideKeyboard() { View view = app_model.getInstance().getAppInstance().findViewById(android.R.id.content); @@ -49,4 +71,82 @@ public class helperMethod } } + public static int screenHeight(boolean hasSoftKeys) + { + if(!hasSoftKeys) + { + return (int)(Resources.getSystem().getDisplayMetrics().heightPixels)-(helperMethod.getNavigationBarHeight()); + } + else + { + return (int)(Resources.getSystem().getDisplayMetrics().heightPixels); + } + } + + public static int getNavigationBarHeight() { + Resources resources = app_model.getInstance().getAppContext().getResources(); + int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); + if (resourceId > 0) { + return resources.getDimensionPixelSize(resourceId); + } + return 0; + } + + public static RotateAnimation getRotationAnimation() + { + RotateAnimation rotate = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f); + rotate.setDuration(2000); + rotate.setRepeatCount(Animation.INFINITE); + return rotate; + } + + public static Bitmap screenShot(View view) + { + Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(bitmap); + view.draw(canvas); + return bitmap; + } + + public static ViewGroup.MarginLayoutParams getCenterScreenPoint(ViewGroup.LayoutParams itemLayoutParams) + { + double heightloader = Resources.getSystem().getDisplayMetrics().heightPixels*0.78; + ViewGroup.MarginLayoutParams params_loading = (ViewGroup.MarginLayoutParams) itemLayoutParams; + params_loading.topMargin = (int)(heightloader); + + return params_loading; + } + + public static boolean hasSoftKeys(WindowManager windowManager) + { + Display d = windowManager.getDefaultDisplay(); + + DisplayMetrics realDisplayMetrics = new DisplayMetrics(); + d.getRealMetrics(realDisplayMetrics); + + int realHeight = realDisplayMetrics.heightPixels; + int realWidth = realDisplayMetrics.widthPixels; + + DisplayMetrics displayMetrics = new DisplayMetrics(); + d.getMetrics(displayMetrics); + + int displayHeight = displayMetrics.heightPixels; + int displayWidth = displayMetrics.widthPixels; + + return (realWidth - displayWidth) > 0 || (realHeight - displayHeight) > 0; + } + + public static boolean isBuildValid () + { + if(BuildConfig.FLAVOR.equals("aarch64")&& Build.SUPPORTED_ABIS[0].equals("arm64-v8a") || BuildConfig.FLAVOR.equals("arm")&&Build.SUPPORTED_ABIS[0].equals("armeabi-v7a") || BuildConfig.FLAVOR.equals("x86")&&Build.SUPPORTED_ABIS[0].equals("x86") || BuildConfig.FLAVOR.equals("x86_64")&&Build.SUPPORTED_ABIS[0].equals("x86_64")) + { + return true; + } + else + { + return false; + } + + } + } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/httpManager/httpclient.java b/app/src/main/java/com/darkweb/genesissearchengine/httpManager/httpclient.java index e1b4f6e0..13f1e52d 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/httpManager/httpclient.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/httpManager/httpclient.java @@ -33,7 +33,7 @@ public class httpclient { try { - String c_url = url.replace("http://boogle","https://boogle"); + String c_url = url.replace("http://boogle","https://boogle").replaceAll("genesis.onion","boogle.store").replaceAll("genesis.store","boogle.store"); HttpClient client=new DefaultHttpClient();; SSLConnectionSocketFactory scsf = new SSLConnectionSocketFactory( @@ -55,15 +55,6 @@ public class httpclient in.close(); html = str.toString(); - if(c_url.equals(constants.backendUrlSlashed)) - { - html = html.replace("/privacy","https://boogle.store/privacy").replace("/about","https://boogle.store/about").replace("/reportus","https://boogle.store/reportus").replace("\"search\"","https://boogle.store/search").replace("/create","https://boogle.store/create"); - helperMethod.setHomepageHTML(html, app_model.getInstance().getAppContext()); - } - if(!isCachedRequest) - { - startPostTask(messages.MESSAGE_UPDATE_TEXT_CHILD_THREAD,updateUIHandler); - } } catch (Exception e) { diff --git a/app/src/main/java/com/darkweb/genesissearchengine/httpManager/serverRequestManager.java b/app/src/main/java/com/darkweb/genesissearchengine/httpManager/serverRequestManager.java index d12f5c93..64fd1368 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/httpManager/serverRequestManager.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/httpManager/serverRequestManager.java @@ -1,7 +1,7 @@ package com.darkweb.genesissearchengine.httpManager; import android.content.Context; -import com.darkweb.genesissearchengine.pluginManager.preference_manager; +import com.darkweb.genesissearchengine.dataManager.preference_manager; import cz.msebera.android.httpclient.client.HttpClient; import cz.msebera.android.httpclient.client.methods.HttpGet; import cz.msebera.android.httpclient.impl.client.DefaultHttpClient; @@ -72,4 +72,14 @@ public class serverRequestManager }.start(); } + 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,Build.SUPPORTED_ABIS[0]); + } + webRequestHandler.getInstance().getVersion(this);*/ + } + } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/httpManager/webRequestHandler.java b/app/src/main/java/com/darkweb/genesissearchengine/httpManager/webRequestHandler.java index f54a2bb9..113d6128 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/httpManager/webRequestHandler.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/httpManager/webRequestHandler.java @@ -6,13 +6,7 @@ import android.os.Message; import android.os.Handler; import com.darkweb.genesissearchengine.appManager.app_model; -import com.darkweb.genesissearchengine.constants.constants; -import com.darkweb.genesissearchengine.constants.enums; import com.darkweb.genesissearchengine.constants.messages; -import com.darkweb.genesissearchengine.helperMethod; - -import static com.darkweb.genesissearchengine.constants.enums.webRequestStatus.*; -import static java.lang.Thread.sleep; public class webRequestHandler { @@ -20,7 +14,7 @@ public class webRequestHandler private String html = ""; private Handler updateUIHandler = null; private httpclient client; - + private String requestedUrl = ""; /*Initialization*/ private static final webRequestHandler ourInstance = new webRequestHandler(); @@ -48,21 +42,8 @@ public class webRequestHandler public void cachedURLSelector() { - if(app_model.getInstance().getCurrentURL().equals(constants.backendUrlSlashed)) - { - String html_local = helperMethod.readHomepageHTML(app_model.getInstance().getAppContext()); - if(html_local.length()>1) - { - html = html_local; - client = new httpclient(); - client.httpConnection(app_model.getInstance().getCurrentURL(),updateUIHandler,true); - startPostTask(messages.LOCAL_HOMEPAGE_CACHED); - return; - } - } - client = new httpclient(); - client.httpConnection(app_model.getInstance().getCurrentURL(),updateUIHandler,false); + client.httpConnection(requestedUrl,updateUIHandler,false); } public void startPostTask(int m_id) @@ -80,17 +61,13 @@ public class webRequestHandler @Override public void handleMessage(Message msg) { - if(msg.what == messages.LOCAL_HOMEPAGE_CACHED) - { - app_model.getInstance().getAppInstance().loadUrlOnWebview(html); - } if(msg.what == messages.MESSAGE_UPDATE_TEXT_CHILD_THREAD) { - app_model.getInstance().getAppInstance().loadUrlOnWebview(client.getHtmlResponse()); + //app_model.getInstance().getAppInstance().onloadURL(client.getHtmlResponse()); } else if (msg.what == messages.INTERNET_ERROR) { - app_model.getInstance().getAppInstance().onInternetError(); + app_model.getInstance().getAppInstance().onInternetErrorView(); } } }; diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/analyticmanager.java b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/analyticmanager.java index c75d9688..b5b3fbe8 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/analyticmanager.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/analyticmanager.java @@ -3,6 +3,8 @@ package com.darkweb.genesissearchengine.pluginManager; import android.content.Context; import android.content.SharedPreferences; import com.crashlytics.android.Crashlytics; +import com.crashlytics.android.answers.Answers; +import com.crashlytics.android.answers.CustomEvent; import java.util.UUID; @@ -48,4 +50,11 @@ public class analyticmanager Crashlytics.setUserName(uniqueID); } + public void sendEvent(String value) + { + Answers.getInstance().logCustom(new CustomEvent(value) + .putCustomAttribute(analyticmanager.getInstance().uniqueID,value)); + + } + } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/fabricManager.java b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/fabricManager.java new file mode 100644 index 00000000..ffe88bc6 --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/fabricManager.java @@ -0,0 +1,33 @@ +package com.darkweb.genesissearchengine.pluginManager; + +import com.crashlytics.android.Crashlytics; +import com.crashlytics.android.answers.Answers; +import com.crashlytics.android.answers.CustomEvent; +import com.darkweb.genesissearchengine.appManager.app_model; +import io.fabric.sdk.android.Fabric; + +public class fabricManager +{ + private static final fabricManager ourInstance = new fabricManager(); + + public static fabricManager getInstance() + { + return ourInstance; + } + + private fabricManager() + { + } + + public void init() + { + Fabric.with(app_model.getInstance().getAppContext(), new Crashlytics()); + analyticmanager.getInstance().initialize(app_model.getInstance().getAppContext()); + analyticmanager.getInstance().logUser(); + } + + public void sendEvent(String value) + { + analyticmanager.getInstance().sendEvent(value); + } +} diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/message_manager.java b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/message_manager.java index 951ecdf8..2a9dd8f9 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/message_manager.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/message_manager.java @@ -4,18 +4,22 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; +import android.os.Handler; import com.crowdfire.cfalertdialog.CFAlertDialog; import com.darkweb.genesissearchengine.appManager.app_model; import com.darkweb.genesissearchengine.appManager.application_controller; import com.darkweb.genesissearchengine.constants.constants; import com.darkweb.genesissearchengine.constants.keys; import com.darkweb.genesissearchengine.constants.strings; +import com.darkweb.genesissearchengine.dataManager.preference_manager; import com.darkweb.genesissearchengine.httpManager.serverRequestManager; import com.example.myapplication.R; public class message_manager { /*Initializations*/ + private boolean isPopupOn = false; + private static final message_manager ourInstance = new message_manager(); public static message_manager getInstance() @@ -36,29 +40,28 @@ public class message_manager CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) .setDialogStyle(CFAlertDialog.CFAlertStyle.ALERT) .setTitle(strings.welcome_message_title) - .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v1)) + .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v2)) .setTextColor(application_context.getResources().getColor(R.color.blue_dark)) .setMessage(strings.welcome_message_desc) - .addButton(strings.welcome_message_bt1, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED , (dialog, which) -> { dialog.dismiss(); - controller.initializePopupView(constants.blackMarket); - controller.loadURLAnimate(constants.blackMarket); + controller.onloadURL(constants.blackMarket,false); + controller.onloadURL(constants.blackMarket,false); }) .addButton(strings.welcome_message_bt2, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED , (dialog, which) -> { dialog.dismiss(); - controller.initializePopupView(constants.leakedDocument); - controller.loadURLAnimate(constants.leakedDocument); + controller.onloadURL(constants.leakedDocument,false); + controller.onloadURL(constants.leakedDocument,false); }) .addButton(strings.welcome_message_bt3, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED , (dialog, which) -> { dialog.dismiss(); - controller.initializePopupView(constants.news); - controller.loadURLAnimate(constants.news); + controller.onloadURL(constants.news,false); + controller.onloadURL(constants.news,false); }) .addButton(strings.welcome_message_bt4, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED , (dialog, which) -> { dialog.dismiss(); - controller.initializePopupView(constants.softwares); - controller.loadURLAnimate(constants.softwares); + controller.onloadURL(constants.softwares,false); + controller.onloadURL(constants.softwares,false); }) .addButton(strings.welcome_message_bt5, -1, -1, CFAlertDialog.CFAlertActionStyle.NEGATIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED , (dialog, which) -> { dialog.dismiss(); @@ -75,7 +78,7 @@ public class message_manager CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) .setDialogStyle(CFAlertDialog.CFAlertStyle.BOTTOM_SHEET) .setTitle(strings.base_error_title) - .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v1)) + .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v2)) .setTextColor(application_context.getResources().getColor(R.color.black)) .setMessage(strings.base_error_desc) .addButton(strings.base_error_bt1, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.END, (dialog, which) -> { @@ -91,7 +94,7 @@ public class message_manager CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) .setDialogStyle(CFAlertDialog.CFAlertStyle.BOTTOM_SHEET) .setTitle(strings.abi_error_title) - .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v1)) + .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v2)) .setTextColor(application_context.getResources().getColor(R.color.black)) .onDismissListener(new DialogInterface.OnDismissListener() { @Override @@ -118,7 +121,7 @@ public class message_manager CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) .setDialogStyle(CFAlertDialog.CFAlertStyle.BOTTOM_SHEET) .setTitle(strings.report_success_title) - .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v1)) + .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v2)) .setTextColor(application_context.getResources().getColor(R.color.black)) .setMessage(strings.report_success_desc) .addButton(strings.report_success_bt1, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED, (dialog, which) -> { @@ -128,19 +131,19 @@ public class message_manager builder.show(); } - public void reportURL(String URL) + public void reportURL() { Context application_context = app_model.getInstance().getAppContext(); CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) .setDialogStyle(CFAlertDialog.CFAlertStyle.BOTTOM_SHEET) .setTitle(strings.report_url_title) - .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v1)) + .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v2)) .setTextColor(application_context.getResources().getColor(R.color.black)) .setMessage(strings.report_url_desc) .addButton(strings.report_url_bt1, -1, -1, CFAlertDialog.CFAlertActionStyle.NEGATIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED, (dialog, which) -> { - String reportURL = constants.reportUrl+URL; - serverRequestManager.getInstance().reportURL(reportURL); + //String reportURL = constants.reportUrl+URL; + //serverRequestManager.getInstance().reportURL(reportURL); dialog.dismiss(); reportedSuccessfully(); }) @@ -151,20 +154,51 @@ public class message_manager builder.show(); } - public void startingOrbotInfo() + public void startingOrbotInfo(String url) { - Context application_context = app_model.getInstance().getAppContext(); - CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) - .setDialogStyle(CFAlertDialog.CFAlertStyle.BOTTOM_SHEET) - .setTitle(strings.orbot_init_title) - .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v1)) - .setTextColor(application_context.getResources().getColor(R.color.black)) - .setMessage(strings.orbot_init_desc) - .addButton(strings.orbot_init_bt1, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.END, (dialog, which) -> { - dialog.dismiss(); - }); + if(!isPopupOn) + { + isPopupOn = true; + Context application_context = app_model.getInstance().getAppContext(); + CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) + .setDialogStyle(CFAlertDialog.CFAlertStyle.BOTTOM_SHEET) + .setTitle(strings.orbot_init_title) + .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v2)) + .setTextColor(application_context.getResources().getColor(R.color.black)) + .setMessage(strings.orbot_init_desc) + .onDismissListener(new DialogInterface.OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + isPopupOn = false; + } + }) + .addButton(strings.orbot_init_bt1, -1, -1, CFAlertDialog.CFAlertActionStyle.NEGATIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED, (dialog, which) -> { + dialog.dismiss(); + isPopupOn = false; + }).addButton(strings.orbot_init_bt2, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED, (dialog, which) -> { + dialog.dismiss(); + isPopupOn = false; - builder.show(); + final Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + @Override + public void run() + { + if(!url.equals("")) + { + app_model.getInstance().getAppInstance().onloadURL(url,true); + } + else + { + app_model.getInstance().getAppInstance().onReload(); + } + } + }, 500); + + }); + + builder.show(); + } } public void versionWarning(String currentAbi) @@ -173,7 +207,7 @@ public class message_manager CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) .setDialogStyle(CFAlertDialog.CFAlertStyle.BOTTOM_SHEET) .setTitle(strings.version_title) - .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v1)) + .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v2)) .setTextColor(application_context.getResources().getColor(R.color.black)) .setMessage(strings.version_desc) .addButton(strings.version_bt1, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.END, (dialog, which) -> { diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/orbot_manager.java b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/orbot_manager.java index 9f12d42f..13318090 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/orbot_manager.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/orbot_manager.java @@ -1,14 +1,18 @@ package com.darkweb.genesissearchengine.pluginManager; +import android.util.Log; import com.darkweb.genesissearchengine.appManager.app_model; import com.darkweb.genesissearchengine.constants.constants; import com.darkweb.genesissearchengine.constants.keys; import com.darkweb.genesissearchengine.constants.status; import com.darkweb.genesissearchengine.constants.strings; +import com.darkweb.genesissearchengine.helperMethod; import com.msopentech.thali.android.toronionproxy.AndroidOnionProxyManager; import com.msopentech.thali.toronionproxy.OnionProxyManager; import org.mozilla.gecko.PrefsHelper; +import java.io.IOException; + public class orbot_manager { /*Private Variables*/ @@ -28,12 +32,11 @@ public class orbot_manager { } /*Orbot Initialization*/ - public boolean initOrbot() + public boolean initOrbot(String url) { if(!status.isTorInitialized) { - message_manager.getInstance().startingOrbotInfo(); - initializeTorClient(); + message_manager.getInstance().startingOrbotInfo(url); return false; } else @@ -42,6 +45,37 @@ public class orbot_manager { } } + public void reinitOrbot() + { + new Thread() + { + public void run() + { + try + { + while (true) + { + if(!isLoading && (onionProxyManager == null || !onionProxyManager.isRunning())) + { + if(onionProxyManager != null) + { + onionProxyManager.stop(); + } + isLoading = false; + status.isTorInitialized = false; + initializeTorClient(); + } + sleep(1000); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + }.start(); + } + public void initializeTorClient() { if(!isLoading) @@ -61,29 +95,27 @@ public class orbot_manager { { break; } + onionProxyManager = new AndroidOnionProxyManager(app_model.getInstance().getAppContext(), fileStorageLocation); int totalSecondsPerTorStartup = 4 * 60; int totalTriesPerTorStartup = 5; + boolean ok = onionProxyManager.startWithRepeat(totalSecondsPerTorStartup, totalTriesPerTorStartup); - if (!ok) { - return; - } else { - if (onionProxyManager.isRunning()) { - } + + if (!ok) + { + continue; } - while (!onionProxyManager.isRunning()) { - sleep(1000); - } if (onionProxyManager.isRunning()) { app_model.getInstance().setPort(onionProxyManager.getIPv4LocalHostSocksPort()); initializeProxy(); - sleep(1500); + //sleep(1500); status.isTorInitialized = true; + isLoading = false; break; } - isLoading = false; } catch (Exception ex) { ex.printStackTrace(); continue; @@ -103,8 +135,8 @@ public class orbot_manager { PrefsHelper.setPref(keys.proxy_socks_port, app_model.getInstance().getPort()); //manual proxy settings PrefsHelper.setPref(keys.proxy_socks_version,constants.proxy_socks_version); //manual proxy settings PrefsHelper.setPref(keys.proxy_socks_remote_dns,constants.proxy_socks_remote_dns); //manual proxy settings - //PrefsHelper.setPref(keys.proxy_cache,constants.proxy_cache); - //PrefsHelper.setPref(keys.proxy_memory,constants.proxy_memory); + PrefsHelper.setPref(keys.proxy_cache,constants.proxy_cache); + PrefsHelper.setPref(keys.proxy_memory,constants.proxy_memory); PrefsHelper.setPref(keys.proxy_useragent_override, constants.proxy_useragent_override); PrefsHelper.setPref(keys.proxy_donottrackheader_enabled,constants.proxy_donottrackheader_enabled); PrefsHelper.setPref(keys.proxy_donottrackheader_value,constants.proxy_donottrackheader_value); diff --git a/app/src/main/res/drawable/icon_homeicon.png b/app/src/main/res/drawable/icon_homeicon.png index 60f3721f..1e18f50f 100644 Binary files a/app/src/main/res/drawable/icon_homeicon.png and b/app/src/main/res/drawable/icon_homeicon.png differ diff --git a/app/src/main/res/layout/application_view.xml b/app/src/main/res/layout/application_view.xml index f25f7f64..b120f471 100644 --- a/app/src/main/res/layout/application_view.xml +++ b/app/src/main/res/layout/application_view.xml @@ -9,34 +9,41 @@ + + + - - - - + + + + @@ -189,6 +207,7 @@ android:src="@drawable/icon_ban" android:layout_height="wrap_content" android:alpha="0" + android:onClick="onFloatingButtonPressed" app:borderWidth="0dp" app:elevation="10dp" android:backgroundTint="@color/white" diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 665e0c0e..a3c23db0 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -6,6 +6,7 @@ #b3d1ff #00264d #212d45 + #CC212d45 #000000 #212f45 @@ -20,4 +21,6 @@ #ffffff #f32323 + + #CC212d45 diff --git a/app/src/main/res/xml/floating_button_border.xml b/app/src/main/res/xml/floating_button_border.xml index 84273072..c3269bde 100644 --- a/app/src/main/res/xml/floating_button_border.xml +++ b/app/src/main/res/xml/floating_button_border.xml @@ -3,17 +3,17 @@ - + - + - - + + diff --git a/app/src/main/res/xml/home_pressed_state.xml b/app/src/main/res/xml/home_pressed_state.xml index f67f18bf..6476db64 100644 --- a/app/src/main/res/xml/home_pressed_state.xml +++ b/app/src/main/res/xml/home_pressed_state.xml @@ -1,55 +1,13 @@ - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - + + + \ No newline at end of file diff --git a/tor-android-binary-0.3.4.9/build.gradle b/tor-android-binary-0.3.4.9/build.gradle new file mode 100644 index 00000000..b1834eb7 --- /dev/null +++ b/tor-android-binary-0.3.4.9/build.gradle @@ -0,0 +1,2 @@ +configurations.maybeCreate("default") +artifacts.add("default", file('tor-android-binary-0.3.4.9.aar')) \ No newline at end of file diff --git a/tor-android-binary-0.3.4.9/tor-android-binary-0.3.4.9.aar b/tor-android-binary-0.3.4.9/tor-android-binary-0.3.4.9.aar new file mode 100644 index 00000000..bf99792e Binary files /dev/null and b/tor-android-binary-0.3.4.9/tor-android-binary-0.3.4.9.aar differ