diff --git a/app/build.gradle b/app/build.gradle index 87f5e40d..c255c1d0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,55 +1,122 @@ apply plugin: 'com.android.application' apply plugin: 'maven' +apply plugin: 'io.fabric' ext { - geckoviewChannel = "" - geckoviewVersion = "66.0.20190322021635" + geckoviewChannel = "nightly" + geckoviewVersion = "64.0.20180927100037" } + +repositories { + maven { + url "https://maven.mozilla.org/maven2/" + mavenLocal() + mavenCentral() + google() + jcenter() + maven { url "https://raw.githubusercontent.com/guardianproject/gpmaven/master" } + } +} + android { compileSdkVersion 28 defaultConfig { applicationId "com.darkweb.genesissearchengine" minSdkVersion 21 targetSdkVersion 28 - versionCode 61 - versionName "61.0" + versionCode 126 + versionName "126.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } flavorDimensions "abi" // Note: compileOptions is only required for minSdkVersion < 24 + // Note: compileOptions is only required for minSdkVersion < 26 (not 24) compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + + flavorDimensions "abi" + productFlavors { - x86 { dimension "abi" } - x86_64 { dimension "abi" } - arm { dimension "abi" } - aarch64 { dimension "abi" } + arm { + versionCode 131 + versionName "131" + dimension "abi" + } + aarch64 { + versionCode 132 + versionName "132" + dimension "abi" + } + x86_64 { + versionCode 135 + versionName "135" + dimension "abi" + } + x86 { + versionCode 134 + versionName "134" + dimension "abi" + } } + buildTypes { release { minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + + splits { + abi { + enable true + reset() + include 'arm64-v8a' + //include 'x86' + //include 'armeabi-v7a' + //include 'x86_64' + //include 'armeabi' + + universalApk true + } + } + } +} + +configurations.all { + resolutionStrategy.eachDependency { DependencyResolveDetails details -> + def requested = details.requested + if (requested.group == 'com.android.support') { + if (!requested.name.startsWith("multidex")) { + details.useVersion '26.1.0' + } } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.google.android.gms:play-services-ads:17.1.1' implementation "cz.msebera.android:httpclient:4.4.1.2" - implementation 'info.guardianproject.netcipher:netcipher:2.0.0-alpha1' - implementation 'info.guardianproject.netcipher:netcipher-okhttp3:2.0.0-alpha1' - armImplementation "org.mozilla.geckoview:geckoview-armeabi-v7a:${geckoviewVersion}" - aarch64Implementation "org.mozilla.geckoview:geckoview-arm64-v8a:${geckoviewVersion}" - implementation 'com.yarolegovich:lovely-dialog:1.1.0' + + //x86Implementation "org.mozilla.geckoview:geckoview-nightly-x86:68.0.20190405111221" + //x86_64Implementation "org.mozilla.geckoview:geckoview-nightly-x86_64:68.0.20190405111221" + //armImplementation "org.mozilla.geckoview:geckoview-nightly-armeabi-v7a:68.0.20190405111221" + aarch64Implementation "org.mozilla.geckoview:geckoview-nightly-arm64-v8a:68.0.20190405111221" + + implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9' + implementation 'com.crowdfire.cfalertdialog:cfalertdialog:1.1.0' + + implementation 'com.github.jehy:Tor-Onion-Proxy-Library:0.0.7' + implementation 'org.slf4j:slf4j-api:1.7.7' + implementation 'org.slf4j:slf4j-android:1.7.7' + implementation 'com.android.support:design:28.0.0' } apply plugin: 'com.android.application' \ No newline at end of file diff --git a/app/fabric.properties b/app/fabric.properties new file mode 100644 index 00000000..61550369 --- /dev/null +++ b/app/fabric.properties @@ -0,0 +1,3 @@ +#Contains API Secret used to validate your application. Commit to internal source control; avoid making secret public. +#Wed May 01 00:42:45 PKT 2019 +apiSecret=042501af0b2390b9f064ff9a0823e52a2dd04b2280c9b675925cebbb9620ecbf diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 70e67f1e..6ede54c9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,7 +13,7 @@ android:supportsRtl="true" android:theme="@style/AppTheme" android:networkSecurityConfig="@xml/network_security_config" - android:usesCleartextTraffic="true" tools:ignore="GoogleAppIndexingWarning"> + android:usesCleartextTraffic="true" > @@ -21,11 +21,14 @@ android:screenOrientation="portrait" > - + - + diff --git a/app/src/main/java/com/darkweb/genesissearchengine/admanager.java b/app/src/main/java/com/darkweb/genesissearchengine/admanager.java index 2c374e8e..65996619 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/admanager.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/admanager.java @@ -37,7 +37,7 @@ public class admanager { @Override public void onAdFailedToLoad(int errorCode) { - mInterstitialAd.loadAd(new AdRequest.Builder().build()); + } @Override @@ -59,6 +59,7 @@ public class admanager { public void showAd() { mInterstitialAd.show(); + mInterstitialAd.loadAd(new AdRequest.Builder().build()); } } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/analyticmanager.java b/app/src/main/java/com/darkweb/genesissearchengine/analyticmanager.java new file mode 100644 index 00000000..ebab303f --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/analyticmanager.java @@ -0,0 +1,47 @@ +package com.darkweb.genesissearchengine; + +import android.content.Context; +import android.content.SharedPreferences; +import com.crashlytics.android.Crashlytics; + +import java.util.UUID; + +public class analyticmanager { + private static final analyticmanager ourInstance = new analyticmanager(); + + public static analyticmanager getInstance() { + return ourInstance; + } + String uniqueID = null; + + private analyticmanager() + { + } + + public void logUser() + { + Crashlytics.setUserIdentifier(uniqueID); + Crashlytics.setUserEmail("user@fabric.io"); + Crashlytics.setUserName(uniqueID); + } + + public void setDeviceID(Context context) + { + final String PREF_UNIQUE_ID = "PREF_UNIQUE_ID"; + + if (uniqueID == null) + { + SharedPreferences sharedPrefs = context.getSharedPreferences( + PREF_UNIQUE_ID, Context.MODE_PRIVATE); + uniqueID = sharedPrefs.getString(PREF_UNIQUE_ID, null); + if (uniqueID == null) { + uniqueID = UUID.randomUUID().toString(); + SharedPreferences.Editor editor = sharedPrefs.edit(); + editor.putString(PREF_UNIQUE_ID, uniqueID); + editor.commit(); + } + } + } + + +} diff --git a/app/src/main/java/com/darkweb/genesissearchengine/application_controller.java b/app/src/main/java/com/darkweb/genesissearchengine/application_controller.java index bb9b1fd2..fbd3def1 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/application_controller.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/application_controller.java @@ -1,31 +1,34 @@ package com.darkweb.genesissearchengine; -import android.app.Application; import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; +import android.content.pm.ActivityInfo; import android.graphics.Color; +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.Log; import android.util.Patterns; import android.view.KeyEvent; import android.view.View; +import android.view.Window; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; import android.webkit.*; import android.widget.*; - +import com.crashlytics.android.Crashlytics; +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 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; @@ -37,12 +40,13 @@ public class application_controller extends AppCompatActivity { /*View Objects*/ - private WebView webView1; - private WebView webView2; + public WebView webView1; + public WebView webView2; private GeckoView webLoader; private ProgressBar progressBar; private ConstraintLayout requestFailure; private ConstraintLayout splashScreen; + private FloatingActionButton floatingButton; private Button reloadButton; private ImageButton homeButton; private EditText searchbar; @@ -52,26 +56,61 @@ public class application_controller extends AppCompatActivity private String version_code = "3.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; /*-------------------------------------------------------INITIALIZATION-------------------------------------------------------*/ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + //initializeCrashlytics(); + initializeBackgroundColor(); + //setOrientation(); setContentView(R.layout.application_view); + orbot_manager.getInstance().initializeTorClient(this); + initializeStatus(); initializeRunnable(); - initializeProxy(); initializeConnections(); - initializeOrbot(); initializeWebViews(); initializeView(); initializeAds(); + checkSSLTextColor(); + } + + public void setOrientation() + { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + } + + public void initializeBackgroundColor() + { + if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.M){ + getWindow().setBackgroundDrawableResource(R.drawable.backgradientwhite); + } else{ + getWindow().setBackgroundDrawableResource(R.drawable.backgradientblack); + } + } + + public void initializeStatus() + { + helperMethod.setPlaystoreStatus(this); + } + + public void initializeCrashlytics() + { + Fabric.with(this, new Crashlytics()); + analyticmanager.getInstance().setDeviceID(this); + analyticmanager.getInstance().logUser(); } public void versionChecker() @@ -92,10 +131,11 @@ public class application_controller extends AppCompatActivity Runnable my_runnable = new Runnable() { @Override public void run() { - if(!isBlackPage) + if(!isBlackPage || startPage>1) { - Log.i("SHIT1 : ",status.currentURL); + Log.i("PROBLEM24",""); progressBar.animate().setDuration(150).alpha(0f).withEndAction((() -> progressBar.setVisibility(View.INVISIBLE)));; + Log.i("SHIT1 : ",status.currentURL); datamodel.getInstance().setIsLoadingURL(false); message_manager.getInstance().URLNotFoundError(application_controller.this); } @@ -108,67 +148,39 @@ public class application_controller extends AppCompatActivity 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); - PrefsHelper.setPref("browser.cache.memory.enable",false); - 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); + webView1 = (WebView) findViewById(R.id.pageLoader1); + webView2 = (WebView) findViewById(R.id.pageLoader2); + progressBar = (ProgressBar) findViewById(R.id.progressBar); + requestFailure = (ConstraintLayout) findViewById(R.id.requestFailure); + splashScreen = (ConstraintLayout) findViewById(R.id.splashScreen); + reloadButton = (Button) findViewById(R.id.reloadButton); + homeButton = (ImageButton) findViewById(R.id.home); + searchbar = (EditText) findViewById(R.id.search); + floatingButton = (FloatingActionButton) findViewById(R.id.floatingActionButton3); + topbar = (LinearLayout) findViewById(R.id.topbar); + webLoader = (GeckoView) findViewById(R.id.webLoader); } public void initializeWebViews() { - webRequestHandler.getInstance().initialization(webView1,webView2,progressBar,searchbar,requestFailure,this,splashScreen); + webRequestHandler.getInstance().initialization(webView1,webView2,progressBar,searchbar,requestFailure,this,splashScreen,this); webView1.bringToFront(); + Log.i("PROBLEM25",""); progressBar.animate().setDuration(150).alpha(0f); + //floatingButton.setAlpha(0); - new Thread() + session1 = new GeckoSession(); + runtime1 = GeckoRuntime.getDefault(application_controller.this); + session1.open(runtime1); + if(session1.isOpen()) { - 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(); + webLoader.releaseSession(); + } + webLoader.setSession(session1); + session1.setProgressDelegate(new progressDelegate()); + webLoader.setVisibility(View.INVISIBLE); } /*Initialization*/ @@ -179,16 +191,19 @@ public class application_controller extends AppCompatActivity 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); progressBar.setVisibility(View.INVISIBLE); requestFailure.animate().setDuration(0).alpha(0.0f); + Log.i("PROBLEM26",""); progressBar.animate().setDuration(150).alpha(0f); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); @@ -199,12 +214,57 @@ public class application_controller extends AppCompatActivity private void initializeViewClients() { searchbar.setOnEditorActionListener((v, actionId, event) -> { - return onEditorClicked(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(application_controller.this,searchbar.getText().toString()); + } }); } /*-------------------------------------------------------WEBVIEW LISTENERS-------------------------------------------------------*/ + public void loadGeckoURL(String url) + { + + boolean init_status=orbot_manager.getInstance().reinitOrbot(application_controller.this); + if(init_status) + { + searchbar.setText(url.replaceAll("boogle.store","genesis.onion")); + checkSSLTextColor(); + KeyboardUtils.hideKeyboard(application_controller.this); + + progressBar.setAlpha(0); + progressBar.setVisibility(View.VISIBLE); + Log.i("PROBLEM11",""); + progressBar.animate().setDuration(150).setDuration(300).alpha(1f); + + 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() @@ -220,33 +280,26 @@ public class application_controller extends AppCompatActivity if(!url.toString().contains("boogle")) { - boolean init_status=orbot_manager.getInstance().reinitOrbot(application_controller.this); - if(init_status) + try { - searchbar.setText(url.replaceAll("boogle.store","genesis.onion")); - KeyboardUtils.hideKeyboard(application_controller.this); - admanager.getInstance().showAd(); - - progressBar.setAlpha(0); - progressBar.setVisibility(View.VISIBLE); - progressBar.animate().setDuration(150).setDuration(300).alpha(1f); - - isOnnionUrlHalted = false; - session1.stop(); - session1.close(); - webLoader.releaseSession(); - session1 = new GeckoSession(); - session1.open(runtime1); - session1.setProgressDelegate(new progressDelegate()); - webLoader.setSession(session1); - - session1.loadUri(url); + if(orbot_manager.getInstance().reinitOrbot(application_controller.this)) + { + loadGeckoURL(url); + } + } + catch (Exception ex) + { + ex.printStackTrace(); } return true; } else { + session1.stop(); + session1.close(); + searchbar.setText(url.replaceAll("boogle.store","genesis.onion")); + checkSSLTextColor(); KeyboardUtils.hideKeyboard(application_controller.this); if(traceUrlList.size()==0 || !status.currentURL.equals(traceUrlList.peek())) { @@ -266,34 +319,68 @@ public class application_controller extends AppCompatActivity { super.onPageFinished(view, url); - webView1.stopLoading(); - webView2.stopLoading(); - 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)));; - - }));; - - progressBar.animate().setDuration(150).alpha(0f).withEndAction((() -> progressBar.setVisibility(View.INVISIBLE)));; - - if(!status.hasApplicationLoaded) + handler = new Handler(); + int delay = 800; + if(startPage>2) { - 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(); + delay = 0; } + handler.postDelayed(new Runnable() { + @Override + public void run() { + webView1.stopLoading(); + webView2.stopLoading(); + if(webView1.getAlpha()==0) + { + webView1.animate().setDuration(250).alpha(1f); + } + else + { + webView2.animate().setDuration(250).alpha(1f); + } + //.withEndAction((() -> { - InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(searchbar.getWindowToken(), 0); + //}));; + datamodel.getInstance().setIsLoadingURL(false); + requestFailure.animate().alpha(0f).setDuration(300).withEndAction((() -> requestFailure.setVisibility(View.INVISIBLE)));; + Log.i("PROBLEM12",""); + + if(searchbar.getText().toString().contains("genesis.onion")) + { + progressBar.animate().setDuration(150).alpha(0f).withEndAction((() -> progressBar.setVisibility(View.INVISIBLE)));; + } + + if(!status.hasApplicationLoaded) + { + status.hasApplicationLoaded = true; + handler = new Handler(); + + splashScreen.animate().alpha(0.0f).setStartDelay(500).setDuration(300).setListener(null).withEndAction((() -> splashScreen.setVisibility(View.GONE))); + versionChecker(); + + + } + + InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(searchbar.getWindowToken(), 0); + + } + }, delay); + + + + Handler popuphandler = new Handler(); + + popuphandler.postDelayed(new Runnable() { + @Override + public void run() { + if(status.hasApplicationLoaded && !isTutorialPopupShown) + { + message_manager.getInstance().welcomeMessage(application_controller.this,application_controller.this); + isTutorialPopupShown = true; + } + } + }, 2000); } @Override @@ -303,11 +390,13 @@ public class application_controller extends AppCompatActivity handler.postDelayed(new Runnable() { @Override public void run() { + Log.i("PROBLEM13",""); 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); + status.isTorInitialized = false; } }, 3000); @@ -328,6 +417,7 @@ public class application_controller extends AppCompatActivity requestFailure.setVisibility(View.VISIBLE); requestFailure.animate().alpha(1.0f); + status.isTorInitialized = false; loadErrorPage(); } @@ -340,7 +430,9 @@ class progressDelegate implements GeckoSession.ProgressDelegate @Override public void onPageStart(GeckoSession session, String url) { - if(!orbot_manager.getInstance().reinitOrbot(application_controller.this)) + isGeckoURLLoadded = false; + isBlackPage = url.equals("about:blank"); + if(!isBlackPage && !orbot_manager.getInstance().reinitOrbot(application_controller.this)) { session1.stop(); session1.close(); @@ -371,10 +463,12 @@ class progressDelegate implements GeckoSession.ProgressDelegate } datamodel.getInstance().setIsLoadingURL(true); - isBlackPage = url.equals("about:blank"); if(!isBlackPage) { + Log.i("HUTEES : 1","11"); searchbar.setText(url); + checkSSLTextColor(); + //initGeckoFailureHandler(); } if(!isBlackPage && progressBar.getVisibility() == View.INVISIBLE) { @@ -386,43 +480,67 @@ class progressDelegate implements GeckoSession.ProgressDelegate @Override public void onPageStop(GeckoSession session, boolean success) { + Log.i("STATUS-- : ",success+""); if(!success) { - handler.postDelayed(geckoRunnable, 15000); + initGeckoFailureHandler(isGeckoURLLoadded); + isGeckoURLLoadded = false; + } + if(success) + { + Log.i("PROBLEM14",""); + isGeckoURLLoadded = false; } } @Override public void onProgressChange(GeckoSession session, int progress) { + if(geckoHandler!=null) + { + geckoHandler.removeCallbacks(geckoRunnableError); + geckoHandler = null; + Log.i("HUTEES : 4","11"); + } if(progress>=100) { + isGeckoURLLoadded = true; + floatingButton.animate().alpha(1); + + if(status.currentURL.contains("://boogle.store")) + { + admanager.getInstance().showAd(); + } 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) { - Log.i("SHIT2 : ",status.currentURL); traceUrlList.add(status.currentURL); searchbar.setText(url); + checkSSLTextColor(); status.currentURL = url; } + wasBackPressed=false; } + progressBar.animate().setDuration(150).alpha(0f).withEndAction((() -> progressBar.setVisibility(View.INVISIBLE)));; isLoadedUrlSet = true; } + else if(progress<100) + { + //Log.i("HUTEES : 3","11"); + //initGeckoFailureHandler(); + } if(progress>=100) { - progressBar.animate().setDuration(150).alpha(0f).withEndAction((() -> progressBar.setVisibility(View.INVISIBLE)));; datamodel.getInstance().setIsLoadingURL(false); } - - handler.removeCallbacks(geckoRunnable); + //handler.removeCallbacks(geckoRunnable); } @Override @@ -430,6 +548,42 @@ class progressDelegate implements GeckoSession.ProgressDelegate { } } + public void initGeckoFailureHandler(boolean hasURLLoaded) + { + int delay = 15000; + if(!helperMethod.isNetworkAvailable(application_controller.this) || hasURLLoaded) + { + delay=0; + } + + if(geckoHandler == null) + { + geckoHandler = new Handler(); + geckoRunnableError = new Runnable() { + @Override + public void run() { + floatingButton.animate().alpha(0); + Log.i("PROBLEM15",""); + datamodel.getInstance().setIsLoadingURL(false); + requestFailure.setAlpha(0.0f); + requestFailure.setVisibility(View.VISIBLE); + requestFailure.animate().alpha(1.0f); + Log.i("PROBLEM16",""); + progressBar.animate().setDuration(150).alpha(0f).withEndAction((() -> progressBar.setVisibility(View.INVISIBLE)));; + geckoHandler = null; + + if(!helperMethod.isNetworkAvailable(application_controller.this)) + { + orbot_manager.getInstance().restartOrbot(application_controller.this); + } + wasBackPressed=false; + + } + }; + geckoHandler.postDelayed(geckoRunnableError, delay); + } + } + /*-------------------------------------------------------Helper Method-------------------------------------------------------*/ public void loadErrorPage() @@ -441,19 +595,33 @@ class progressDelegate implements GeckoSession.ProgressDelegate public void loadURLAnimate(String url) { + 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(status.currentURL); + status.currentURL=url; + progressBar.setAlpha(0f); + progressBar.setVisibility(View.VISIBLE); + Log.i("PROBLEM17",""); + progressBar.animate().setDuration(150).alpha(1f); + } + public void onHomeButtonPressed(View view) { webRequestHandler.getInstance().isUrlStoped=true; searchbar.setText("https://genesis.onion"); - + checkSSLTextColor(); status.currentURL="https://boogle.store"; progressBar.setAlpha(0f); progressBar.setVisibility(View.VISIBLE); + Log.i("PROBLEM18",""); progressBar.animate().setDuration(150).alpha(1f); loadURLAnimate("https://boogle.store"); webView1.stopLoading(); @@ -468,39 +636,99 @@ class progressDelegate implements GeckoSession.ProgressDelegate public void onReloadButtonPressed(View view) { webRequestHandler.getInstance().isReloadedUrl = true; + Log.i("PROBLEM19",""); progressBar.animate().setDuration(150).alpha(0f); progressBar.setVisibility(View.VISIBLE); - progressBar.animate().setDuration(150).alpha(1f); - loadURLAnimate(status.currentURL); + if(searchbar.getText().toString().contains("://genesis.onion")) + { + Log.i("PROBLEM20",""); + progressBar.animate().setDuration(150).alpha(1f); + loadURLAnimate(status.currentURL); + } + else + { + if(status.isTorInitialized) + { + Log.i("PROBLEM21",""); + progressBar.animate().setDuration(150).alpha(1f); + wasBackPressed = true; + loadGeckoURL(searchbar.getText().toString()); + } + else + { + orbot_manager.getInstance().reinitOrbot(application_controller.this); + } + } } - @Override - public void onBackPressed() + 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() { - session1.stop(); if(traceUrlList.size()>0) { - searchbar.setText(traceUrlList.peek().toString().replaceAll("boogle.store","genesis.onion")); if(traceUrlList.peek().toString().contains("boogle.store")) { + session1.stop(); + session1.close(); if(!status.currentURL.contains("boogle.store")) { - Log.i("FITS4 : " , ""); + searchbar.setText(traceUrlList.peek().toString().replaceAll("boogle.store","genesis.onion")); isOnnionUrlHalted=true; session1.stop(); session1.close(); webLoader.releaseSession(); + webLoader.releaseSession(); status.currentURL = traceUrlList.pop().toString(); - progressBar.animate().setDuration(150).alpha(0f).withEndAction((() -> progressBar.setVisibility(View.INVISIBLE)));; + Log.i("PROBLEM22",""); webLoader.animate().alpha(0f).withEndAction((() -> webLoader.setVisibility(View.INVISIBLE)));; - isOnnionUrlHalted = true; - wasBackPressed = false; + //isOnnionUrlHalted = true; KeyboardUtils.hideKeyboard(application_controller.this); + if(requestFailure.getAlpha()==1) + { + requestFailure.animate().alpha(0f).withEndAction((() -> requestFailure.setVisibility(View.INVISIBLE)));; + } + else + { + progressBar.animate().alpha(0f).withEndAction((() -> progressBar.setVisibility(View.INVISIBLE)));; + } + floatingButton.animate().alpha(0); } else { + //if(progressBar.getAlpha()==0) + //{ + //progressBar.animate().setDuration(150).setDuration(300).alpha(1f); + Log.i("1LOG3","LOG1"); + searchbar.setText(traceUrlList.peek().toString().replaceAll("boogle.store","genesis.onion")); session1.close(); - Log.i("FITS3 : " , ""); loadURLAnimate(traceUrlList.pop().toString()); if(traceUrlList.size()<=0) { @@ -510,49 +738,71 @@ class progressDelegate implements GeckoSession.ProgressDelegate { status.currentURL = traceUrlList.peek().toString(); } + floatingButton.animate().alpha(0); + //} } } else { if(traceUrlList.size()<=0 || traceUrlList.peek().toString().contains("boogle.store")) { - Log.i("FITS2 : " , ""); + session1.stop(); + session1.close(); + + searchbar.setText(traceUrlList.peek().toString().replaceAll("boogle.store","genesis.onion")); status.currentURL = "https://boogle.store"; webLoader.animate().setDuration(250).alpha(0); traceUrlList.pop(); wasBackPressed = false; session1.close(); + floatingButton.animate().alpha(0); } else { - webLoader.animate().setDuration(250).alpha(1); - status.currentURL = traceUrlList.peek().toString(); - String prevURL = traceUrlList.pop().toString(); - Log.i("FITS : " , prevURL); - session1.goBack(); - wasBackPressed = true; + if(orbot_manager.getInstance().reinitOrbot(this)) + { + searchbar.setText(traceUrlList.peek().toString().replaceAll("boogle.store","genesis.onion")); + status.currentURL = traceUrlList.peek().toString(); + String prevURL = traceUrlList.pop().toString(); + boolean init_status=orbot_manager.getInstance().reinitOrbot(application_controller.this); + //isOnnionUrlHalted = true; + if(init_status) + { + searchbar.setText(status.currentURL.replaceAll("boogle.store","genesis.onion")); + KeyboardUtils.hideKeyboard(application_controller.this); + progressBar.animate().alpha(1); + progressBar.setVisibility(View.VISIBLE); + wasBackPressed = true; + requestFailure.animate().alpha(0); + session1.goBack(); + } + else + { + session1.stop(); + session1.close(); + orbot_manager.getInstance().reinitOrbot(application_controller.this); + } + } } } if(traceUrlList.size()==0) { searchbar.setText("https://genesis.onion/"); } + checkSSLTextColor(); } } - public void loadGeckoUrl(String url) + @Override + public void onBackPressed() { - session1.close(); - session1 = new GeckoSession(); - session1.open(runtime1); - session1.setProgressDelegate(new application_controller.progressDelegate()); - webLoader.releaseSession(); - webLoader.setSession(session1); - session1.loadUri(url); + backPressed(); } public boolean onEditorClicked(TextView v, int actionId, KeyEvent event) { + KeyboardUtils.hideKeyboard(application_controller.this); + Log.i("FUCKOFF : ",actionId+""); try { session1.stop(); @@ -570,21 +820,34 @@ class progressDelegate implements GeckoSession.ProgressDelegate 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)) { - loadURLAnimate(v.getText().toString()); + floatingButton.animate().alpha(0); + loadURLAnimate(url); return true; } else if(host.getHost().contains(constants.allowedHost)) { - if(!orbot_manager.getInstance().reinitOrbot(this)) + if(!url.contains("://boogle.store")) + { + orbot_manager.getInstance().reinitOrbot(this); + } + + if(status.isTorInitialized) { session1.stop(); session1.loadUri(url); } + else + { + orbot_manager.getInstance().reinitOrbot(application_controller.this); + message_manager.getInstance().startingOrbotInfo(this); + } + return true; } else @@ -597,7 +860,6 @@ class progressDelegate implements GeckoSession.ProgressDelegate { loadURLAnimate("https://boogle.store/search?q="+v.getText().toString().replaceAll(" ","+")+"&p_num=1&s_type=all"); } - orbot_manager.getInstance().reinitOrbot(this); } catch (IOException e) diff --git a/app/src/main/java/com/darkweb/genesissearchengine/helperMethod.java b/app/src/main/java/com/darkweb/genesissearchengine/helperMethod.java index 7e862a61..06d8b676 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/helperMethod.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/helperMethod.java @@ -1,8 +1,15 @@ package com.darkweb.genesissearchengine; import android.content.Context; +import android.content.SharedPreferences; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.preference.PreferenceManager; + +import java.util.List; +import java.util.UUID; public class helperMethod { @@ -17,4 +24,37 @@ public class helperMethod return false; } + public static boolean readPrefs(String valueKey,Context applicationContext) { + SharedPreferences prefs = PreferenceManager + .getDefaultSharedPreferences(applicationContext); + return prefs.getBoolean(valueKey,false); + } + + public static void savePrefs(String valueKey, boolean value,Context applicationContext) { + SharedPreferences prefs = PreferenceManager + .getDefaultSharedPreferences(applicationContext); + SharedPreferences.Editor edit = prefs.edit(); + edit.putBoolean(valueKey, value); + edit.commit(); + } + + public static void setPlaystoreStatus(Context context) { + + String GooglePlayStorePackageNameOld = "com.google.market"; + String GooglePlayStorePackageNameNew = "com.android.vending"; + + PackageManager packageManager = context.getPackageManager(); + List packages = packageManager.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES); + + for (PackageInfo packageInfo : packages) + { + if (packageInfo.packageName.equals(GooglePlayStorePackageNameOld) || + packageInfo.packageName.equals(GooglePlayStorePackageNameNew)) { + status.isPlayStoreInstalled = true; + break; + } + } + + } + } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/message_manager.java b/app/src/main/java/com/darkweb/genesissearchengine/message_manager.java index 0540c43d..2d29c8a2 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/message_manager.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/message_manager.java @@ -1,12 +1,9 @@ package com.darkweb.genesissearchengine; +import android.app.Application; import android.content.Context; -import android.content.Intent; -import android.net.Uri; -import android.view.View; -import com.example.myapplication.R; -import com.yarolegovich.lovelydialog.LovelyInfoDialog; -import com.yarolegovich.lovelydialog.LovelyStandardDialog; +import android.graphics.Color; +import com.crowdfire.cfalertdialog.CFAlertDialog; public class message_manager { private static final message_manager ourInstance = new message_manager(); @@ -18,38 +15,166 @@ public class message_manager { private message_manager() { } + public void welcomeMessage(Context application_context, application_controller controller) + { + if(!helperMethod.readPrefs("FirstTimeLoaded",application_context)) + { + CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) + .setDialogStyle(CFAlertDialog.CFAlertStyle.ALERT) + .setTitle("DeepWeb Gateway | Welcome") + .setBackgroundColor(Color.argb(230,33,45,69)) + .setTextColor(Color.argb(255,0,38,77)) + .setMessage("\nWelcome to DeepWeb | Darkweb Gateway. This application provide you a platform to Search and Open DarkWeb urls.\n\nYou cannot open any url related to normal internet as its not the intended purpose. You can check out following urls to get yourself started\n\nHere are few Suggestions\n") + + .addButton("DeepWeb Online Market", -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED , (dialog, which) -> { + dialog.dismiss(); + controller.initializePopupView("https://boogle.store/search?q=black+market&p_num=1&s_type=all"); + controller.loadURLAnimate("https://boogle.store/search?q=black+market&p_num=1&s_type=all"); + }) + .addButton("Leaked Documents and Books", -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED , (dialog, which) -> { + dialog.dismiss(); + controller.initializePopupView("https://boogle.store/search?q=leaked+document&p_num=1&s_type=all&p_num=1&s_type=all"); + controller.loadURLAnimate("https://boogle.store/search?q=leaked+document&p_num=1&s_type=all&p_num=1&s_type=all"); + }) + .addButton("Darkweb News and Articles", -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED , (dialog, which) -> { + dialog.dismiss(); + controller.initializePopupView("https://boogle.store/search?q=latest%20news&p_num=1&s_type=news"); + controller.loadURLAnimate("https://boogle.store/search?q=latest%20news&p_num=1&s_type=news"); + }) + .addButton("Secret Softwares and Hacking Tools", -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED , (dialog, which) -> { + dialog.dismiss(); + controller.initializePopupView("https://boogle.store/search?q=softwares+tools&p_num=1&s_type=all&p_num=1&s_type=all"); + controller.loadURLAnimate("https://boogle.store/search?q=softwares+tools&p_num=1&s_type=all&p_num=1&s_type=all"); + }) + .addButton("Don't Show Again", -1, -1, CFAlertDialog.CFAlertActionStyle.NEGATIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED , (dialog, which) -> { + dialog.dismiss(); + helperMethod.savePrefs("FirstTimeLoaded",true,application_context); + }); + builder.show(); + } + + + // Create Alert using Builder + /* + new LovelyStandardDialog(application_context) + .setTopColorRes(R.color.header) + .setTopTitleColor(Color.argb(255,255,255,255)) + .setTopTitle("Welcome") + .setMessage("This software can only be used to access hidden web such as \"Onion\" and \"I2P\" \n\nFor accessing Surface Web use Google or Bing") + .setPositiveButton(android.R.string.ok, new View.OnClickListener() { + @Override/ + public void onClick(View v) + { + } + }) + .setNegativeButton("Don't Show Again", null) + .show();*/ + } + + public void baseURLError(Context application_context) { - new LovelyInfoDialog(application_context) - .setTopColorRes(R.color.header) - .setIcon(R.drawable.logo) - .setTitle("Surface Web URL Not Allowed") - .setMessage("This software can only be used to search hidden web such as \"Onion\" and \"I2P\" for searching in Surface Web use \"Google\" or \"Bing\"") - .show(); + CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) + .setDialogStyle(CFAlertDialog.CFAlertStyle.BOTTOM_SHEET) + .setTitle("Darkweb URL | Invalid URL") + .setBackgroundColor(Color.argb(230,33,45,69)) + .setTextColor(Color.argb(255,255,255,255)) + .setMessage("This software can only be used to access hidden web such as \"Onion\" and \"I2P\" \n\nFor accessing Surface Web use Google or Bing\n") + .addButton("Dismiss", -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.END, (dialog, which) -> { + dialog.dismiss(); + }); + + builder.show(); + } + + public void illegalWarningDialog(Context application_context,application_controller controller) + { + CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) + .setDialogStyle(CFAlertDialog.CFAlertStyle.BOTTOM_SHEET) + .setTitle("Illegal Activity Detected") + .setBackgroundColor(Color.argb(255,33,45,69)) + .setTextColor(Color.argb(255,255,255,255)) + .setMessage("This software can only be used to access hidden web such as \"Onion\" and \"I2P\" \n\nFor accessing Surface Web use Google or Bing\n") + .addButton("Go Back", -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.END, (dialog, which) -> { + dialog.dismiss(); + }) + .addButton("Dismiss", -1, -1, CFAlertDialog.CFAlertActionStyle.NEGATIVE, CFAlertDialog.CFAlertActionAlignment.END, (dialog, which) -> { + dialog.dismiss(); + controller.backPressed(); + }); + + builder.show(); } public void URLNotFoundError(Context application_context) { - new LovelyInfoDialog(application_context) - .setTopColorRes(R.color.header) - .setIcon(R.drawable.logo) - .setTitle("URL Temporarily Unavailable") - .setMessage("Site is Down or temporarily Unavailabe. Try again after a while") - .show(); + CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) + .setDialogStyle(CFAlertDialog.CFAlertStyle.BOTTOM_SHEET) + .setTitle("Darkweb URL | Invalid") + .setBackgroundColor(Color.argb(230,33,45,69)) + .setTextColor(Color.argb(255,255,255,255)) + .setMessage("This software can only be used to access hidden web such as \"Onion\" and \"I2P\" \n\nFor accessing Surface Web use Google or Bing\n") + .addButton("Dismiss", -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.END, (dialog, which) -> { + dialog.dismiss(); + }); + + builder.show(); + } + + public void reportedSuccessfully(Context application_context) + { + CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) + .setDialogStyle(CFAlertDialog.CFAlertStyle.BOTTOM_SHEET) + .setTitle("URL Reported Successfully") + .setBackgroundColor(Color.argb(230,33,45,69)) + .setTextColor(Color.argb(255,255,255,255)) + .setMessage("URL has been succuessfully repotorted. It will take about a week to completely remove this website from our server\n") + .addButton("Dismiss", -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED, (dialog, which) -> { + dialog.dismiss(); + }); + + builder.show(); + } + + public void reportURL(Context application_context,String URL) + { + CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) + .setDialogStyle(CFAlertDialog.CFAlertStyle.BOTTOM_SHEET) + .setTitle("Report URL | "+status.currentURL.substring(0,status.currentURL.indexOf(".onion"))) + .setBackgroundColor(Color.argb(230,33,45,69)) + .setTextColor(Color.argb(255,255,255,255)) + .setMessage("If you think url is illegal or disturbing report us so that we can update our database\n") + .addButton("Report", -1, -1, CFAlertDialog.CFAlertActionStyle.NEGATIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED, (dialog, which) -> { + + String reportURL = "https://boogle.store/reportus?r_key="+URL; + webRequestHandler.getInstance().reportURL(reportURL); + dialog.dismiss(); + reportedSuccessfully(application_context); + }) + .addButton("Dismiss", -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED, (dialog, which) -> { + dialog.dismiss(); + }); + + builder.show(); } public void startingOrbotInfo(Context application_context) { - new LovelyInfoDialog(application_context) - .setTopColorRes(R.color.header) - .setIcon(R.drawable.logo) - .setTitle("Orbot is Starting") - .setMessage("Looks Like Orbot is Installed but not Running. Please wait while we Start Orbot for you") - .show(); + CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) + .setDialogStyle(CFAlertDialog.CFAlertStyle.BOTTOM_SHEET) + .setTitle("Initializing Darkweb") + .setBackgroundColor(Color.argb(230,33,45,69)) + .setTextColor(Color.argb(255,255,255,255)) + .setMessage("Please wait! While we connect you to hidden web. This might take few seconds\n") + .addButton("Dismiss", -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.END, (dialog, which) -> { + dialog.dismiss(); + }); + + builder.show(); } public void versionWarning(Context application_context) - { + {/* new LovelyStandardDialog(application_context) .setTopColorRes(R.color.header) .setIcon(R.drawable.logo) @@ -67,7 +192,7 @@ public class message_manager { }) .setNegativeButton(android.R.string.no, null) .show(); - + */ } } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/orbot_manager.java b/app/src/main/java/com/darkweb/genesissearchengine/orbot_manager.java index c7667399..4cf5a240 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/orbot_manager.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/orbot_manager.java @@ -1,18 +1,18 @@ package com.darkweb.genesissearchengine; -import android.content.BroadcastReceiver; import android.content.Context; -import android.content.Intent; -import android.net.Uri; -import android.text.TextUtils; -import android.view.View; -import com.example.myapplication.R; -import com.yarolegovich.lovelydialog.LovelyStandardDialog; -import info.guardianproject.netcipher.proxy.OrbotHelper; +import android.util.Log; +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 static final orbot_manager ourInstance = new orbot_manager(); boolean isOrbotRunning = false; + boolean isLoading = false; + OnionProxyManager onionProxyManager = null; public static orbot_manager getInstance() { return ourInstance; @@ -21,62 +21,118 @@ public class orbot_manager { private orbot_manager() { } - public BroadcastReceiver orbotStatusReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (TextUtils.equals(intent.getAction(), - OrbotHelper.ACTION_STATUS)) { - String status = intent.getStringExtra(OrbotHelper.EXTRA_STATUS); - if (status.equals(OrbotHelper.STATUS_ON)) - { - isOrbotRunning = true; - } - else if (status.equals(OrbotHelper.STATUS_OFF)) - { - isOrbotRunning = false; - } - else if (status.equals(OrbotHelper.STATUS_STARTING)) - { - } - else if (status.equals(OrbotHelper.STATUS_STOPPING)) - { - } - } - } - }; - public boolean reinitOrbot(Context application_context) { - if(!OrbotHelper.isOrbotInstalled(application_context)) + if(!status.isTorInitialized) { - OrbotHelper.getOrbotInstallIntent(application_context); - new LovelyStandardDialog(application_context) - .setTopColorRes(R.color.header) - .setIcon(R.drawable.logo) - .setTitle("Orbot Proxy Not Installed") - .setMessage("Hidden Web can only be access by Special Proxies. Please Install Orbot Proxy from Playstore") - .setPositiveButton(android.R.string.ok, new View.OnClickListener() { - @Override - public void onClick(View v) { - final String appPackageName = "org.torproject.android"; // getPackageName() from Context or Activity object - try { - application_context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); - } catch (android.content.ActivityNotFoundException anfe) { - application_context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName))); - } - } - }) - .setNegativeButton(android.R.string.no, null) - .show(); - return false; - } - if(!isOrbotRunning) - { - OrbotHelper.get(application_context).init(); message_manager.getInstance().startingOrbotInfo(application_context); + initializeTorClient(application_context); return false; } - return true; + else + { + return true; + } } + public void restartOrbot(Context applicationContext) + { + isOrbotRunning = false; + status.isTorInitialized = false; + if(onionProxyManager!=null) + { + new Thread() + { + public void run() + { + try + { + onionProxyManager.stop(); + //initializeTorClient(applicationContext); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + }.start(); + } + } + + public void initializeTorClient(Context applicationContext) + { + if(isLoading) + { + return; + } + new Thread() + { + public void run() + { + try + { + isLoading = true; + String fileStorageLocation = "torfiles"; + onionProxyManager = new AndroidOnionProxyManager(applicationContext, fileStorageLocation); + int totalSecondsPerTorStartup = 4 * 60; + int totalTriesPerTorStartup = 5; + try { + boolean ok = onionProxyManager.startWithRepeat(totalSecondsPerTorStartup, totalTriesPerTorStartup); + if (!ok) { + Log.i("TorTest", "Couldn't start Tor!"); + return; + } + else + { + if(onionProxyManager.isRunning()) { + Log.i("My App", "Tor initialized on port " + onionProxyManager.getIPv4LocalHostSocksPort()); + } + } + } + catch (Exception ex) { + ex.printStackTrace(); + } + + while (!onionProxyManager.isRunning()) + { + sleep(1000); + } + if(onionProxyManager.isRunning()) + { + Log.i("My App", "Tor initialized on port " + onionProxyManager.getIPv4LocalHostSocksPort()); + status.port = onionProxyManager.getIPv4LocalHostSocksPort(); + initializeProxy(); + sleep(1500); + status.isTorInitialized = true; + } + isLoading = false; + } + catch (InterruptedException e) + { + isLoading = false; + e.printStackTrace(); + } catch (IOException e) { + isLoading = false; + e.printStackTrace(); + } + } + }.start(); + } + + + 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",status.port); //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); + PrefsHelper.setPref("browser.cache.memory.enable",false); + 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); + } + + } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/status.java b/app/src/main/java/com/darkweb/genesissearchengine/status.java index 3a14a5e1..d4129b09 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/status.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/status.java @@ -4,4 +4,7 @@ public class status { public static boolean hasApplicationLoaded = false; public static String currentURL = "http://boogle.store/"; + public static boolean isPlayStoreInstalled = false; + public static int port = 9150; + public static boolean isTorInitialized = false; } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/webRequestHandler.java b/app/src/main/java/com/darkweb/genesissearchengine/webRequestHandler.java index b13af2d1..24da288e 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/webRequestHandler.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/webRequestHandler.java @@ -2,6 +2,7 @@ package com.darkweb.genesissearchengine; import android.annotation.SuppressLint; import android.content.Context; +import android.os.AsyncTask; import android.os.Message; import android.support.constraint.ConstraintLayout; import android.util.Log; @@ -10,6 +11,7 @@ import android.webkit.WebView; import android.widget.EditText; import android.widget.ProgressBar; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -17,17 +19,22 @@ import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; import android.os.Handler; import cz.msebera.android.httpclient.HttpResponse; import cz.msebera.android.httpclient.client.HttpClient; import cz.msebera.android.httpclient.client.methods.HttpGet; +import cz.msebera.android.httpclient.conn.ssl.NoopHostnameVerifier; +import cz.msebera.android.httpclient.conn.ssl.SSLConnectionSocketFactory; +import cz.msebera.android.httpclient.conn.ssl.TrustSelfSignedStrategy; import cz.msebera.android.httpclient.impl.client.DefaultHttpClient; -import info.guardianproject.netcipher.NetCipher; -import info.guardianproject.netcipher.client.StrongBuilder; -import info.guardianproject.netcipher.proxy.OrbotHelper; +import cz.msebera.android.httpclient.impl.client.HttpClients; +import cz.msebera.android.httpclient.ssl.SSLContexts; -public class webRequestHandler implements StrongBuilder.Callback +public class webRequestHandler { private static final webRequestHandler ourInstance = new webRequestHandler(); private WebView[] view = new WebView[2]; @@ -35,6 +42,7 @@ public class webRequestHandler implements StrongBuilder.Callback private EditText searchbar; private ConstraintLayout requestFailure; + public boolean reloadError=false; public boolean isReloadedUrl = false; private int viewIndex = 1; private int currentViewIndex = 0; @@ -49,6 +57,7 @@ public class webRequestHandler implements StrongBuilder.Callback private final static int INTERNET_ERROR =2; private final static int MESSAGE_UPDATE_TEXT_CHILD_THREAD =1; private final static int RELOAD_ERROR =3; + private application_controller controller; public static webRequestHandler getInstance() { return ourInstance; @@ -58,33 +67,34 @@ public class webRequestHandler implements StrongBuilder.Callback { } - public void initialization(WebView view1, WebView view2, ProgressBar progressBar, EditText searchbar, ConstraintLayout requestFailure, Context applicationContext,ConstraintLayout splash) + public void initialization(WebView view1, WebView view2, ProgressBar progressBar, EditText searchbar, ConstraintLayout requestFailure, Context applicationContext,ConstraintLayout splash,application_controller controller) { + this.controller = controller; this.splash = splash; this.view[0] = view1; this.view[1] = view2; this.progressBar = progressBar; this.searchbar = searchbar; this.requestFailure = requestFailure; - OrbotHelper.get(applicationContext).init(); createUpdateUiHandler(); } public void loadURL(final String url) { + Log.i("STEST : 1","1 : " + currenturl.equals(url) + " : " + isReloadedUrl + " : " + !reloadError); try { - Log.i("WOW MAN 0","WOW MAN 2 : " + currenturl + "----" + url); - if(!currenturl.equals(url) || isReloadedUrl) + if(!currenturl.equals(url) || isReloadedUrl || !reloadError) { - Log.i("WOW MAN 1","WOW MAN 2"); + Log.i("STEST : 2","1"); isReloadedUrl = false; - currenturl = url; preInitialization(url); + currenturl = url; } else { + Log.i("STEST : 3","1"); Message message = new Message(); message.what = RELOAD_ERROR; updateUIHandler.sendMessage(message); @@ -93,28 +103,34 @@ public class webRequestHandler implements StrongBuilder.Callback } catch (Exception e) { + Log.i("STEST : 4","1 : " + e.getMessage()); e.printStackTrace(); } clientThread = new Thread(() -> { try { + Log.i("STEST : 5","1"); currenturl = url; if(url.contains("boogle.store")) { + Log.i("STEST : 6","1"); nonProxyConnection(url); } else { + Log.i("STEST : 7","1"); proxyConnection(url); } } catch (Exception e) { - if(!e.getMessage().contains("failed to respond")) + Log.i("STEST : 8","1"); + if(!e.getMessage().contains("Socket closed") && !e.getMessage().contains("failed to respond") && e.getMessage().contains("Unable to resolve host \"boogle.store\"")) { - Log.i("SUP3",e.getMessage()+""); + Log.i("STEST99 : 9","1 : "+e.getMessage()); onError(); + reloadError=true; e.printStackTrace(); } } @@ -124,6 +140,12 @@ public class webRequestHandler implements StrongBuilder.Callback public void preInitialization(String url) { + Log.i("WOW MAN 0","WOW MAN 2 : " + currenturl + "----" + url); + progressBar.setAlpha(0); + progressBar.setVisibility(View.VISIBLE); + progressBar.animate().setDuration(150).alpha(1f); + Log.i("WOW MAN 1","WOW MAN 2 : " + currenturl + "----" + url); + if(!datamodel.getInstance().getIsLoadingURL()) { datamodel.getInstance().setIsLoadingURL(true); @@ -137,16 +159,25 @@ public class webRequestHandler implements StrongBuilder.Callback clientThread = null; searchbar.setText(url.replace("http://boogle.store","http://genesis.onion")); } - progressBar.animate().setDuration(150).alpha(0f); - progressBar.setVisibility(View.VISIBLE); - progressBar.animate().setDuration(150).alpha(1f); - } public void nonProxyConnection(String url) throws IOException { url = url.replace("http://boogle","https://boogle"); + HttpClient client=new DefaultHttpClient();; + try { + SSLConnectionSocketFactory scsf = new SSLConnectionSocketFactory( + SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(), + NoopHostnameVerifier.INSTANCE); + client = HttpClients.custom().setSSLSocketFactory(scsf).build(); + + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (KeyManagementException e) { + e.printStackTrace(); + } catch (KeyStoreException e) { + e.printStackTrace(); + } - HttpClient client = new DefaultHttpClient(); request = new HttpGet(url); baseURL = url; HttpResponse response = client.execute(request); @@ -168,33 +199,40 @@ public class webRequestHandler implements StrongBuilder.Callback } - public void proxyConnection(String url) throws Exception { - NetCipher.useTor(); - HttpURLConnection connection = NetCipher.getHttpURLConnection(url); - connection.setRequestProperty("User-Agent","Mozilla/5.0 ( compatible ) "); - connection.setRequestProperty("Accept","*/*"); - connection.connect(); - - BufferedReader br = new BufferedReader(new InputStreamReader((connection.getInputStream()))); - StringBuilder sb = new StringBuilder(); - String output; - while ((output = br.readLine()) != null) { - sb.append(output); + public void reportURL(String url) + { + try + { + HttpGet reportrequest = new HttpGet(url); + HttpClient client=new DefaultHttpClient();; + HttpResponse response = client.execute(reportrequest); } - html = sb.toString(); + catch (Exception ex) + { + ex.printStackTrace(); + } + } - Message message = new Message(); - message.what = MESSAGE_UPDATE_TEXT_CHILD_THREAD; - updateUIHandler.sendMessage(message); + public void proxyConnection(String url) throws Exception { } public void onError() { + Log.i("WOW222","WOW222 : " + isReloadedUrl); + reloadError = true; if(!isReloadedUrl) { Message message = new Message(); message.what = INTERNET_ERROR; updateUIHandler.sendMessage(message); + Log.i("WOW222","WOW333 : " + isReloadedUrl); + } + else + { + Log.i("SUSHIT5","5"); + Message message = new Message(); + message.what = RELOAD_ERROR; + updateUIHandler.sendMessage(message); } isReloadedUrl = false; } @@ -211,9 +249,11 @@ public class webRequestHandler implements StrongBuilder.Callback public void handleMessage(Message msg) { if(msg.what == MESSAGE_UPDATE_TEXT_CHILD_THREAD) { - view[viewIndex].animate().setDuration(0).alpha(0f); + reloadError = false; + view[viewIndex].setAlpha(0); view[viewIndex].bringToFront(); view[viewIndex].loadDataWithBaseURL(baseURL,html, "text/html", "utf-8", null); + //view[currentViewIndex].animate().alpha(1); if(viewIndex==1) { @@ -225,24 +265,34 @@ public class webRequestHandler implements StrongBuilder.Callback viewIndex = 1; currentViewIndex=0; } - view[currentViewIndex].animate().setDuration(0).alpha(0f).withEndAction((() -> { - })); + //view[currentViewIndex].animate().setDuration(0).alpha(0f).withEndAction((() -> { + //})); } else if (msg.what == INTERNET_ERROR) { splash.animate().setStartDelay(2000).alpha(0); datamodel.getInstance().setIsLoadingURL(false); + Log.i("PROBLEM28",""); progressBar.animate().setDuration(150).alpha(0f); requestFailure.setVisibility(View.VISIBLE); requestFailure.animate().alpha(1f).setDuration(300).withEndAction((() -> { })); + + if(!helperMethod.isNetworkAvailable(controller)) + { + orbot_manager.getInstance().restartOrbot(controller); + } + + Log.i("SUSHIT2","2"); } else if (msg.what == RELOAD_ERROR) { + Log.i("SUSHIT1","1"); Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { + Log.i("PROBLEM29",""); progressBar.animate().setDuration(150).alpha(0f); } }, 1000); @@ -253,25 +303,6 @@ public class webRequestHandler implements StrongBuilder.Callback } } - @Override - public void onConnected(HttpClient httpClient) { - - } - - @Override - public void onConnectionException(Exception e) { - - } - - @Override - public void onTimeout() { - } - - @Override - public void onInvalid() { - - } - public void getVersion(Context applicationContext) { new Thread() @@ -304,4 +335,9 @@ public class webRequestHandler implements StrongBuilder.Callback }.start(); } + + /*****--------------------ASYNC TASK--------------------******/ + + + } diff --git a/app/src/main/res/drawable/backgradient.xml b/app/src/main/res/drawable/backgradient.xml index b08efe05..0c3122cd 100644 --- a/app/src/main/res/drawable/backgradient.xml +++ b/app/src/main/res/drawable/backgradient.xml @@ -1,8 +1,8 @@ \ No newline at end of file diff --git a/app/src/main/res/drawable/backgradientblack.xml b/app/src/main/res/drawable/backgradientblack.xml new file mode 100644 index 00000000..03fcdcd2 --- /dev/null +++ b/app/src/main/res/drawable/backgradientblack.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/backgradientwhite.xml b/app/src/main/res/drawable/backgradientwhite.xml new file mode 100644 index 00000000..dac75f00 --- /dev/null +++ b/app/src/main/res/drawable/backgradientwhite.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ban.png b/app/src/main/res/drawable/ban.png new file mode 100644 index 00000000..92689739 Binary files /dev/null and b/app/src/main/res/drawable/ban.png differ diff --git a/app/src/main/res/drawable/baseline_info_black_48dp.png b/app/src/main/res/drawable/baseline_info_black_48dp.png new file mode 100644 index 00000000..eec71311 Binary files /dev/null and b/app/src/main/res/drawable/baseline_info_black_48dp.png differ diff --git a/app/src/main/res/drawable/baseline_language_black_48dp.png b/app/src/main/res/drawable/baseline_language_black_48dp.png new file mode 100644 index 00000000..15576578 Binary files /dev/null and b/app/src/main/res/drawable/baseline_language_black_48dp.png differ diff --git a/app/src/main/res/drawable/lock.png b/app/src/main/res/drawable/lock.png new file mode 100644 index 00000000..d43e5559 Binary files /dev/null and b/app/src/main/res/drawable/lock.png differ diff --git a/app/src/main/res/drawable/lockstyle.xml b/app/src/main/res/drawable/lockstyle.xml new file mode 100644 index 00000000..e4606a8a --- /dev/null +++ b/app/src/main/res/drawable/lockstyle.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/logo.png b/app/src/main/res/drawable/logo.png index b989bc39..a14ba0dc 100644 Binary files a/app/src/main/res/drawable/logo.png and b/app/src/main/res/drawable/logo.png differ diff --git a/app/src/main/res/drawable/welcome.png b/app/src/main/res/drawable/welcome.png new file mode 100644 index 00000000..022e5b18 Binary files /dev/null and b/app/src/main/res/drawable/welcome.png differ diff --git a/app/src/main/res/layout-v26/application_view.xml b/app/src/main/res/layout-v26/application_view.xml index 60d09d22..734a7b5d 100644 --- a/app/src/main/res/layout-v26/application_view.xml +++ b/app/src/main/res/layout-v26/application_view.xml @@ -62,7 +62,7 @@ app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="74dp" app:layout_constraintEnd_toEndOf="parent" tools:ignore="TextViewEdits"/>