From 64be4761704be6473a92841a8907226916bac8ef Mon Sep 17 00:00:00 2001 From: msmannan00 Date: Mon, 12 Aug 2019 01:12:53 +0500 Subject: [PATCH] bug fixes --- app/build.gradle | 12 ++++-- app/src/main/AndroidManifest.xml | 3 ++ .../home_activity/geckoClients.java | 5 ++- .../home_activity/home_controller.java | 5 ++- .../home_activity/home_ehandler.java | 41 ++++++++++++++++--- .../home_activity/viewController.java | 35 +++++++++++++++- .../setting_view_controller.java | 7 ++++ .../setting_manager/settings_ehandler.java | 9 +--- .../constants/messages.java | 2 + .../pluginManager/fabricManager.java | 15 ++++--- .../pluginManager/orbot_manager.java | 2 +- app/src/main/res/layout/home_view.xml | 9 ++-- app/src/main/res/menu/menu_main.xml | 10 +++-- build.gradle | 3 +- 14 files changed, 123 insertions(+), 35 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ebed4259..ac86f569 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,6 +2,7 @@ apply plugin: 'com.android.application' apply from: 'variables.gradle' apply plugin: 'maven' +apply plugin: 'io.fabric' ext { @@ -12,6 +13,7 @@ ext { repositories { maven { url "https://maven.mozilla.org/maven2/" + maven { url 'https://maven.fabric.io/public' } mavenLocal() mavenCentral() google() @@ -19,6 +21,7 @@ repositories { } } + android { compileSdkVersion project.ext.compileSdkVersion defaultConfig { @@ -96,13 +99,16 @@ dependencies { implementation 'com.android.support:appcompat-v7:28.0.0' /*Firefox ABI Splits*/ - //implementation "org.mozilla.geckoview:geckoview-${geckoviewChannel}:${geckoviewVersion}" - //x86_64Implementation "org.mozilla.geckoview:geckoview-x86_64:68.0.20190711090008" - //armImplementation "org.mozilla.geckoview:geckoview-armeabi-v7a:68.0.20190711090008" + x86Implementation "org.mozilla.geckoview:geckoview-${geckoviewChannel}:${geckoviewVersion}" + x86_64Implementation "org.mozilla.geckoview:geckoview-${geckoviewChannel}:${geckoviewVersion}" + armImplementation "org.mozilla.geckoview:geckoview-${geckoviewChannel}:${geckoviewVersion}" aarch64Implementation "org.mozilla.geckoview:geckoview-${geckoviewChannel}:${geckoviewVersion}" /*Alert Dialog*/ implementation 'com.crowdfire.cfalertdialog:cfalertdialog:1.1.0' + implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') { + transitive = true; + } /*Onion Proxy*/ implementation 'com.github.jehy:Tor-Onion-Proxy-Library:0.0.7' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b822e229..6295106f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -4,6 +4,7 @@ package="com.example.myapplication"> + @@ -20,9 +21,11 @@ diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/home_activity/geckoClients.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/home_activity/geckoClients.java index 4978fa9a..98116093 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/home_activity/geckoClients.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/home_activity/geckoClients.java @@ -5,6 +5,7 @@ import android.content.ActivityNotFoundException; import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; +import android.os.Build; import android.os.Environment; import android.os.Handler; import android.util.Log; @@ -380,8 +381,10 @@ class geckoClients void downloadFile() { + if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + localNotification.getInstance().createNotification("Downloading | " + downloadFile,"Starting Download"); + } home_model.getInstance().getHomeInstance().startService(DownloadFileService.getDownloadService(home_model.getInstance().getHomeInstance(), url.toString()+"__"+downloadFile, Environment.DIRECTORY_DOWNLOADS)); - localNotification.getInstance().createNotification("Downloading | " + downloadFile,"Starting Download"); } private class ExampleContentBlockingDelegate diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/home_activity/home_controller.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/home_activity/home_controller.java index 107cc426..4c7df472 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/home_activity/home_controller.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/home_activity/home_controller.java @@ -51,9 +51,9 @@ public class home_controller extends AppCompatActivity setContentView(R.layout.home_view); initializeAppModel(); preference_manager.getInstance().initialize(); + initializeCrashlytics(); status.initStatus(); - initializeCrashlytics(); initializeConnections(); initializeWebView(); initializeLocalEventHandlers(); @@ -70,6 +70,7 @@ public class home_controller extends AppCompatActivity } else { + //initializeCrashlytics(); initializeAppModel(); setContentView(R.layout.invalid_setup_view); message_manager.getInstance().abiError(Build.SUPPORTED_ABIS[0]); @@ -160,7 +161,7 @@ public class home_controller extends AppCompatActivity public void initializeCrashlytics() { - fabricManager.getInstance().init(); + fabricManager.getInstance().init(this); } public void initializeWebView() diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/home_activity/home_ehandler.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/home_activity/home_ehandler.java index 87f6ef20..45b0d483 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/home_activity/home_ehandler.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/home_activity/home_ehandler.java @@ -2,17 +2,22 @@ package com.darkweb.genesissearchengine.appManager.home_activity; import android.util.Patterns; import android.view.KeyEvent; +import android.view.MenuItem; import android.view.View; import android.view.inputmethod.EditorInfo; import android.widget.TextView; import com.darkweb.genesissearchengine.appManager.list_manager.list_controller; import com.darkweb.genesissearchengine.appManager.setting_manager.setting_controller; +import com.darkweb.genesissearchengine.appManager.setting_manager.setting_model; import com.darkweb.genesissearchengine.constants.constants; import com.darkweb.genesissearchengine.constants.enums; +import com.darkweb.genesissearchengine.constants.keys; import com.darkweb.genesissearchengine.constants.status; +import com.darkweb.genesissearchengine.dataManager.preference_manager; import com.darkweb.genesissearchengine.helperMethod; import com.darkweb.genesissearchengine.pluginManager.fabricManager; import com.darkweb.genesissearchengine.pluginManager.message_manager; +import com.darkweb.genesissearchengine.pluginManager.orbot_manager; import com.example.myapplication.R; import java.io.IOException; @@ -93,12 +98,12 @@ public class home_ehandler appContoller.onReload(); } - public void onMenuButtonPressed(View view) + void onMenuButtonPressed(View view) { appContoller.openMenu(view); } - public void onHomeButtonPressed() + void onHomeButtonPressed() { appContoller.stopHiddenView(true,false); fabricManager.getInstance().sendEvent("HOME BUTTON PRESSSED : "); @@ -107,25 +112,25 @@ public class home_ehandler helperMethod.hideKeyboard(); } - public void onFloatingButtonPressed() + void onFloatingButtonPressed() { fabricManager.getInstance().sendEvent("FLOATING BUTTON PRESSSED : "); message_manager.getInstance().reportURL(); } - public void onBackPressed() + void onBackPressed() { fabricManager.getInstance().sendEvent("BACK BUTTON PRESSSED : "); appContoller.onBackPressedView(); } - public void onMenuPressed(int menuId) + void onMenuPressed(int menuId) { if (menuId == R.id.menu1) { helperMethod.openActivity(list_controller.class,constants.list_history); } else if (menuId == R.id.menu2) { - helperMethod.openActivity(setting_controller.class,constants.list_history); + switchSearchEngine(); } else if (menuId == R.id.menu3) { helperMethod.openActivity(setting_controller.class,constants.list_history); @@ -157,5 +162,29 @@ public class home_ehandler } + private void switchSearchEngine() + { + setting_model.getInstance().search_status = "Google"; + preference_manager.getInstance().setString(keys.search_engine, setting_model.getInstance().search_status); + + + if(status.search_status.equals("Google")) + { + preference_manager.getInstance().setString(keys.search_engine,"Darkweb"); + status.search_status = "Darkweb"; + home_model.getInstance().getHomeInstance().initSearchEngine(); + } + else + { + if(orbot_manager.getInstance().initOrbot("https://google.com")) + { + preference_manager.getInstance().setString(keys.search_engine,"Google"); + status.search_status = "Google"; + home_model.getInstance().getHomeInstance().initSearchEngine(); + } + } + + } + } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/home_activity/viewController.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/home_activity/viewController.java index fb52a345..1e4e6fa5 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/home_activity/viewController.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/home_activity/viewController.java @@ -1,6 +1,7 @@ package com.darkweb.genesissearchengine.appManager.home_activity; import android.annotation.SuppressLint; +import android.content.pm.ActivityInfo; import android.content.res.Resources; import android.graphics.Color; import android.graphics.drawable.Drawable; @@ -15,6 +16,7 @@ import android.webkit.WebView; import android.widget.*; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.core.view.MenuCompat; +import com.darkweb.genesissearchengine.appManager.setting_manager.setting_model; import com.darkweb.genesissearchengine.constants.*; import com.darkweb.genesissearchengine.dataManager.preference_manager; import com.darkweb.genesissearchengine.helperMethod; @@ -164,11 +166,23 @@ public class viewController try { boolean isFirstInstall = preference_manager.getInstance().getBool(keys.hasOrbotInstalled,true); + boolean isHidden = (status.search_status.equals(enums.searchEngine.Google.toString()) || status.search_status.equals(enums.searchEngine.Bing.toString())); while (!status.isTorInitialized && (isFirstInstall || status.search_status.equals(enums.searchEngine.Google.toString()) || status.search_status.equals(enums.searchEngine.Bing.toString()))) { startPostTask(messages.UPDATE_LOADING_TEXT); sleep(100); } + if(isHidden) + { + if(!isFirstInstall) + { + startPostTask(messages.LOAD_COMPLETED); + } + else + { + startPostTask(messages.INSTALL_COMPLETED); + } + } preference_manager.getInstance().setBool(keys.hasOrbotInstalled,false); startPostTask(messages.DISABLE_SPLASH_SCREEN); } @@ -196,7 +210,15 @@ public class viewController @Override public void handleMessage(Message msg) { - if(msg.what == messages.UPDATE_LOADING_TEXT) + if(msg.what == messages.INSTALL_COMPLETED) + { + loadingText.setText("Installed Successfully | Starting Search"); + } + else if(msg.what == messages.LOAD_COMPLETED) + { + loadingText.setText("Loading Successfully | Starting Search"); + } + else if(msg.what == messages.UPDATE_LOADING_TEXT) { loadingText.setText(orbot_manager.getInstance().getLogs()); } @@ -436,6 +458,17 @@ public class viewController home_model.getInstance().getHomeInstance().onMenuOptionSelected(item); return true; }); + MenuItem item = popup.getMenu().findItem(R.id.menu2); + + if(status.search_status.equals("Google")) + { + item.setTitle("Switch | Secure Darkweb"); + } + else + { + item.setTitle("Switch | Secure Google"); + } + popup.show(); view.bringToFront(); } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/setting_manager/setting_view_controller.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/setting_manager/setting_view_controller.java index 461adb81..d41e3a9c 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/setting_manager/setting_view_controller.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/setting_manager/setting_view_controller.java @@ -45,6 +45,7 @@ class setting_view_controller private void initJavascript() { + setting_model.getInstance().java_status = java_status; if (java_status) { javascript.setSelection(0); @@ -57,6 +58,7 @@ class setting_view_controller private void initHistory() { + setting_model.getInstance().history_status = history_status; if (history_status) { history.setSelection(0); @@ -71,6 +73,8 @@ class setting_view_controller private void initSearchEngine() { String myString = preference_manager.getInstance().getString(keys.search_engine, strings.darkweb); + setting_model.getInstance().search_status = myString; + ArrayAdapter myAdap = (ArrayAdapter) search.getAdapter(); int spinnerPosition = myAdap.getPosition(myString); search.setSelection(spinnerPosition); @@ -85,14 +89,17 @@ class setting_view_controller { status.search_status = setting_model.getInstance().search_status; home_model.getInstance().getHomeInstance().initSearchEngine(); + preference_manager.getInstance().setString(keys.search_engine, setting_model.getInstance().search_status); } else if(status.java_status != setting_model.getInstance().java_status) { status.java_status = setting_model.getInstance().java_status; home_model.getInstance().getHomeInstance().onReInitGeckoView(); + preference_manager.getInstance().setBool(keys.java_script, status.java_status); } status.history_status = setting_model.getInstance().history_status; + preference_manager.getInstance().setBool(keys.history_clear, status.history_status); setting_model.getInstance().getSettingInstance().finish(); } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/setting_manager/settings_ehandler.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/setting_manager/settings_ehandler.java index c1d6db46..dd96727e 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/setting_manager/settings_ehandler.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/setting_manager/settings_ehandler.java @@ -26,15 +26,13 @@ public class settings_ehandler private void onJavaScriptListener(int position) { - if(position==1 && setting_model.getInstance().java_status) + if(position==0 && setting_model.getInstance().java_status) { setting_model.getInstance().java_status = false; - preference_manager.getInstance().setBool(keys.java_script, false); } else if(!setting_model.getInstance().java_status) { setting_model.getInstance().java_status = true; - preference_manager.getInstance().setBool(keys.java_script, true); } } @@ -43,21 +41,18 @@ public class settings_ehandler if(!setting_model.getInstance().search_status.equals(parentView.getItemAtPosition(position).toString())) { setting_model.getInstance().search_status = parentView.getItemAtPosition(position).toString(); - preference_manager.getInstance().setString(keys.search_engine, setting_model.getInstance().search_status); } } private void onHistoryListener(int position) { - if(position==1 && setting_model.getInstance().history_status) + if(position==0 && setting_model.getInstance().history_status) { setting_model.getInstance().history_status = false; - preference_manager.getInstance().setBool(keys.history_clear, false); } else if(!setting_model.getInstance().history_status) { setting_model.getInstance().history_status = true; - preference_manager.getInstance().setBool(keys.history_clear, true); } } 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 e2c67e54..50f2602d 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/constants/messages.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/messages.java @@ -10,4 +10,6 @@ public class messages public final static int UPDATE_LOADING_TEXT =5; public final static int SHOW_ADS =6; public final static int DOWNLOAD_NOTIFICATION =7; + public final static int INSTALL_COMPLETED =8; + public final static int LOAD_COMPLETED =9; } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/fabricManager.java b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/fabricManager.java index 9c6a2ce9..476a6269 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/fabricManager.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/fabricManager.java @@ -1,5 +1,10 @@ package com.darkweb.genesissearchengine.pluginManager; +import android.content.Context; +import com.crashlytics.android.Crashlytics; +import com.darkweb.genesissearchengine.appManager.home_activity.home_model; +import io.fabric.sdk.android.Fabric; + public class fabricManager { /*Private Variables*/ @@ -17,17 +22,17 @@ public class fabricManager { } - public void init() + public void init(Context context) { - //Fabric.with(home_model.getInstance().getAppContext(), new Crashlytics()); - //analyticmanager.getInstance().initialize(home_model.getInstance().getAppContext()); - //analyticmanager.getInstance().logUser(); + Fabric.with(context, new Crashlytics()); + analyticmanager.getInstance().initialize(home_model.getInstance().getAppContext()); + analyticmanager.getInstance().logUser(); } /*Helper Methods*/ public void sendEvent(String value) { - analyticmanager.getInstance().sendEvent(value); + //analyticmanager.getInstance().sendEvent(value); } } 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 fcfbbfab..6c4b3107 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 @@ -166,7 +166,7 @@ public class orbot_manager { return "Loading Please Wait"; } Logs=Logs.replace("FAILED","Securing"); - return Logs; + return "Installing | " + Logs; } return "Loading Please Wait"; } diff --git a/app/src/main/res/layout/home_view.xml b/app/src/main/res/layout/home_view.xml index 49f0f075..cf076181 100644 --- a/app/src/main/res/layout/home_view.xml +++ b/app/src/main/res/layout/home_view.xml @@ -174,6 +174,8 @@ android:layout_marginStart="0dp" android:paddingBottom="19dp" android:paddingTop="19dp" + android:paddingLeft="8dp" + android:paddingRight="8dp" android:layout_marginEnd="0dp" android:id="@+id/menu" android:scaleType="fitCenter" @@ -230,9 +232,10 @@ android:layout_width="35dp" android:layout_height="35dp" app:srcCompat="@drawable/icon_loading" - android:id="@+id/imageView_loading_back" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintHorizontal_bias="0.5" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toTopOf="parent"/> + android:id="@+id/imageView_loading_back" + app:layout_constraintStart_toEndOf="@+id/backsplash" + app:layout_constraintEnd_toStartOf="@+id/backsplash" + app:layout_constraintBottom_toTopOf="@+id/loadingText" android:layout_marginBottom="25dp"/> + + + -