diff --git a/app/build.gradle b/app/build.gradle index 6220328c..0e6a4422 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,7 +5,7 @@ apply plugin: 'io.fabric' ext { geckoviewChannel = "" - geckoviewVersion = "64.0.20180927100037" + geckoviewVersion = "67.0.20190613202504" } @@ -44,31 +44,30 @@ android { flavorDimensions "abi" productFlavors { - arm { - versionCode 175 - versionName "175" + /*arm { + versionCode 180 + versionName "180" dimension "abi" buildConfigField "String", "VARIANT", "\"arm\"" } aarch64 { - versionCode 176 - versionName "176" + versionCode 181 + versionName "181" dimension "abi" buildConfigField "String", "VARIANT", "\"aarch64\"" - } + }*/ x86 { - versionCode 177 - versionName "177" + versionCode 182 + versionName "182" dimension "abi" buildConfigField "String", "VARIANT", "\"i686\"" } - - x86_64 { - versionCode 178 - versionName "178" + /*x86_64 { + versionCode 183 + versionName "183" dimension "abi" buildConfigField "String", "VARIANT", "\"x86_64\"" - } + }*/ } @@ -109,11 +108,15 @@ dependencies { implementation 'com.android.support.constraint:constraint-layout:2.0.0-beta2' implementation 'cz.msebera.android:httpclient:4.5.8' - x86Implementation "org.mozilla.geckoview:geckoview-x86:67.0.20190521210220" - x86_64Implementation "org.mozilla.geckoview:geckoview-x86_64:67.0.20190521210220" - armImplementation "org.mozilla.geckoview:geckoview-armeabi-v7a:67.0.20190521210220" - implementation 'com.google.firebase:firebase-core:17.0.0' - aarch64Implementation "org.mozilla.geckoview:geckoview-arm64-v8a:67.0.20190521210220" + x86Implementation "org.mozilla.geckoview:geckoview-x86:67.0.20190613202504" + //x86_64Implementation "org.mozilla.geckoview:geckoview-x86_64:67.0.20190613202504" + //armImplementation "org.mozilla.geckoview:geckoview-armeabi-v7a:67.0.20190613202504" + //aarch64Implementation "org.mozilla.geckoview:geckoview-arm64-v8a:67.0.20190613202504" + + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.preference:preference:1.1.0-alpha02' implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' implementation 'com.crowdfire.cfalertdialog:cfalertdialog:1.1.0' @@ -123,6 +126,9 @@ dependencies { implementation 'org.slf4j:slf4j-android:1.7.26' implementation 'com.google.android.gms:play-services-ads:18.0.0' implementation 'com.android.support:design:28.0.0' + androidTestImplementation 'androidx.test:runner:1.2.0-alpha03' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha03' + implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') { transitive = true; } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 698067b4..72c52ac9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,34 +1,50 @@ + xmlns:tools="http://schemas.android.com/tools" + package="com.example.myapplication"> - - + + + + + android:usesCleartextTraffic="true"> + + + + + - + android:required="false"/> + + - + + + + android:value="be76c64dae2519d4ab8daaed88298da14c7c294f"/> 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 deleted file mode 100644 index cd014321..00000000 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/app_model.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.darkweb.genesissearchengine.appManager; - -import android.content.Context; - -public class app_model -{ - /*Data Objects*/ - private static String currentURL = "http://boogle.store/"; - private static int port = 9150; - private boolean isURLLoading = true; - private Context appContext; - private application_controller appInstance; - - - /*Initializations*/ - private static final app_model ourInstance = new app_model(); - public static app_model getInstance() - { - return ourInstance; - } - - - /*Getters Setters*/ - public int getPort() - { - return port; - } - - public void setPort(int port) - { - this.port = port; - } - - public Context getAppContext() - { - return appContext; - } - - public void setAppContext(Context appContext) - { - this.appContext = appContext; - } - - public application_controller getAppInstance() - { - return appInstance; - } - - public void setAppInstance(application_controller appInstance) - { - this.appInstance = appInstance; - } - -} diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/data_helper/database_controller.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/data_helper/database_controller.java new file mode 100644 index 00000000..ca23131a --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/data_helper/database_controller.java @@ -0,0 +1,82 @@ +package com.darkweb.genesissearchengine.appManager.data_helper; + +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteException; +import com.darkweb.genesissearchengine.appManager.list_activity.list_row_model; +import com.darkweb.genesissearchengine.appManager.main_activity.app_model; +import com.darkweb.genesissearchengine.constants.constants; +import com.darkweb.genesissearchengine.helperMethod; + +import java.io.IOException; +import java.util.ArrayList; + +import static android.content.Context.MODE_PRIVATE; + +public class database_controller +{ + private static final database_controller ourInstance = new database_controller(); + + public static database_controller getInstance() + { + return ourInstance; + } + + private SQLiteDatabase database_instance; + + private database_controller() + { + } + + public void initialize() + { + try + { + database_instance = app_model.getInstance().getAppInstance().openOrCreateDatabase("DatabaseName", MODE_PRIVATE, null); + database_instance.execSQL("CREATE TABLE IF NOT EXISTS " + "history" + " (id INT(4),date VARCHAR,url VARCHAR);"); + database_instance.execSQL("CREATE TABLE IF NOT EXISTS " + "bookmark" + " (id INT(4),title VARCHAR,url VARCHAR);"); + + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + } + + public void execSQL(String query) + { + database_instance.execSQL(query); + } + + public ArrayList selectHistory() + { + ArrayList tempmodel = new ArrayList(); + Cursor c = database_instance.rawQuery("SELECT * FROM history ORDER BY id DESC ", null); + if (c.moveToFirst()){ + do { + tempmodel.add(new list_row_model(c.getString(2), c.getString(1),Integer.parseInt(c.getString(0)))); + app_model.getInstance().initSuggestions(c.getString(2)); + } while(c.moveToNext()); + } + c.close(); + + return tempmodel; + } + + public ArrayList selectBookmark() + { + ArrayList tempmodel = new ArrayList(); + Cursor c = database_instance.rawQuery("SELECT * FROM bookmark ORDER BY id DESC ", null); + + if (c.moveToFirst()){ + do { + tempmodel.add(new list_row_model(c.getString(2), c.getString(1),Integer.parseInt(c.getString(0)))); + } while(c.moveToNext()); + } + c.close(); + + return tempmodel; + } + +} diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/data_helper/database_helper.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/data_helper/database_helper.java new file mode 100644 index 00000000..efd410f2 --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/data_helper/database_helper.java @@ -0,0 +1,135 @@ +package com.darkweb.genesissearchengine.appManager.data_helper; + +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteException; +import android.database.sqlite.SQLiteOpenHelper; +import com.darkweb.genesissearchengine.appManager.list_activity.list_model; +import com.darkweb.genesissearchengine.appManager.list_activity.list_row_model; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; + +public class database_helper extends SQLiteOpenHelper +{ + private Context mContext; + private String mDbPath; + private String mDbName; + private int mDbVersion; + + public SQLiteDatabase db; + + public database_helper(Context context, String dbName, int version) { + super(context, dbName, null, version); + mContext = context; + mDbPath = context.getApplicationInfo().dataDir + "/databases/"; + mDbName = dbName; + mDbVersion = version; + } + + public boolean exists() { + SQLiteDatabase db = null; + + try { + db = SQLiteDatabase.openDatabase(mDbPath + mDbName, null, SQLiteDatabase.OPEN_READONLY); + } + catch (SQLiteException e) { + //database does not exist yet. + } + + if (db != null) { + db.close(); + return true; + } else { + return false; + } + } + + public void openDatabase(int flag) throws SQLiteException, IOException { + if (!exists()) { + if (flag == SQLiteDatabase.OPEN_READONLY) { + this.getReadableDatabase(); + } else if (flag == SQLiteDatabase.OPEN_READWRITE) { + this.getWritableDatabase(); + } + InputStream iStream = null; + OutputStream oStream = null; + try { + iStream = mContext.getAssets().open(mDbName); + oStream = new FileOutputStream(mDbPath + mDbName); + byte[] buffer = new byte[1024]; + int length; + + while ((length = iStream.read(buffer)) > 0) { + oStream.write(buffer, 0, length); + } + } catch (IOException e) { + throw e; + } finally { + if (iStream != null) { + iStream.close(); + } + + if (oStream != null) { + oStream.flush(); + oStream.close(); + } + } + } + + try { + if (flag == SQLiteDatabase.OPEN_READONLY) { + db = SQLiteDatabase.openDatabase(mDbPath + mDbName, null, + SQLiteDatabase.OPEN_READONLY); + } else if (flag == SQLiteDatabase.OPEN_READWRITE) { + db = SQLiteDatabase.openDatabase(mDbPath + mDbName, null, + SQLiteDatabase.OPEN_READWRITE); + } + } catch (SQLiteException e) { + throw e; + } + } + + @Override + public synchronized void close() { + if (db != null) { + db.close(); + } + super.close(); + } + + @Override + public void onCreate(SQLiteDatabase db) { + + } + + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + + } + + public void runQuery(String query) + { + db.execSQL(query); + } + + public ArrayList selectHistory() + { + ArrayList tempmodel = new ArrayList(); + Cursor c = db.rawQuery("SELECT * FROM history ", null); + if (c.moveToFirst()){ + do { + tempmodel.add(new list_row_model(c.getString(0),c.getString(1),Integer.parseInt(c.getString(0)))); + } while(c.moveToNext()); + } + c.close(); + ///db.close(); + + return tempmodel; + } +} diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/list_activity/list_adapter.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/list_activity/list_adapter.java new file mode 100644 index 00000000..8a988abd --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/list_activity/list_adapter.java @@ -0,0 +1,159 @@ +package com.darkweb.genesissearchengine.appManager.list_activity; + +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.*; +import androidx.recyclerview.widget.RecyclerView; +import com.darkweb.genesissearchengine.appManager.data_helper.database_controller; +import com.darkweb.genesissearchengine.appManager.main_activity.app_model; +import com.darkweb.genesissearchengine.constants.constants; +import com.darkweb.genesissearchengine.helperMethod; +import com.darkweb.genesissearchengine.pluginManager.orbot_manager; +import com.example.myapplication.R; + +public class list_adapter extends RecyclerView.Adapter +{ + private ImageView empty_list; + private list_controller controller; + + public list_adapter() + { + } + + public void initialize(ImageView empty_list,list_controller controller) + { + this.empty_list = empty_list; + this.controller = controller; + } + + @Override + public listViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_manager_row, parent, false); + listViewHolder viewHolder = new listViewHolder(view); + return viewHolder; + } + + @Override + public void onBindViewHolder(list_adapter.listViewHolder holder, int position) + { + holder.bindListView(list_model.getInstance().getModel().get(position)); + clearMessageItem(holder.messageButton,holder.empty_message,position); + } + + @Override + public int getItemCount() { + return list_model.getInstance().getModel().size(); + } + + public class listViewHolder extends RecyclerView.ViewHolder + { + public TextView heaaderText; + public TextView descriptionText; + public ImageButton messageButton; + public ImageView empty_message; + + public listViewHolder(View itemView) { + super(itemView); + } + + public void bindListView(list_row_model model) { + + heaaderText = itemView.findViewById(R.id.header); + descriptionText = itemView.findViewById(R.id.description); + + String header = model.getHeader(); + descriptionText.setText(model.getDescription()); + + if(model.getHeader().length()<=2) + { + header = model.getDescription() + model.getHeader(); + } + heaaderText.setText(header); + + + messageButton = itemView.findViewById(R.id.message_button); + empty_message = itemView.findViewById(R.id.empty_list); + + setItemViewOnClickListener(itemView,header); + } + } + + public void setItemViewOnClickListener(View itemView,String url) + { + itemView.setOnClickListener(new View.OnClickListener(){ + + @Override + public void onClick(View v) + { + + String tempurl = url; + isValidUrl(tempurl); + controller.finish(); + } + }); + } + + public boolean isValidUrl(String url) + { + url = helperMethod.completeURL(url); + + if(!url.contains("boogle") && !url.equals(constants.backendGoogle) && !url.equals(constants.backendBing)) + { + if(orbot_manager.getInstance().initOrbot(url)) + { + app_model.getInstance().getAppInstance().onloadURL(url,true,false); + return true; + } + return false; + } + else + { + app_model.getInstance().getAppInstance().onloadURL(url,false,false); + return true; + } + } + + public void clearMessageItem(ImageButton messageButton,ImageView view,int index) + { + ImageView newview = view; + messageButton.setOnClickListener(new View.OnClickListener() + { + @Override + public void onClick(View v) + { + deleteFromDatabase(list_model.getInstance().getModel().get(index).getId()); + list_model.getInstance().getModel().remove(index); + list_model.getInstance().removeFromMainList(list_model.getInstance().getIndex().get(index)); + list_model.getInstance().removeIndex(index); + list_adapter.this.notifyItemRemoved(index); + list_adapter.this.notifyDataSetChanged(); + isListEmpty(newview); + } + }); + } + + public void deleteFromDatabase(int index) + { + String table="bookmark"; + if(list_model.getInstance().getType()==constants.list_history) + { + table = "history"; + } + Log.i("dgfdfg","delete from "+table+" where id="+index); + database_controller.getInstance().execSQL("delete from "+table+" where id="+index); + } + + public void isListEmpty(ImageView view) + { + if(list_model.getInstance().getModel().size()<=0) + { + empty_list.setAlpha(0f); + empty_list.setVisibility(View.VISIBLE); + empty_list.animate().alpha(1); + } + + } + +} diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/list_activity/list_controller.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/list_activity/list_controller.java new file mode 100644 index 00000000..24338380 --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/list_activity/list_controller.java @@ -0,0 +1,152 @@ +package com.darkweb.genesissearchengine.appManager.list_activity; + +import android.view.View; +import android.view.inputmethod.EditorInfo; +import android.widget.EditText; +import android.widget.ImageView; +import androidx.appcompat.app.AppCompatActivity; +import android.os.Bundle; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import com.darkweb.genesissearchengine.appManager.data_helper.database_controller; +import com.darkweb.genesissearchengine.appManager.main_activity.app_model; +import com.darkweb.genesissearchengine.constants.constants; +import com.darkweb.genesissearchengine.constants.keys; +import com.darkweb.genesissearchengine.pluginManager.message_manager; +import com.example.myapplication.R; +import java.util.ArrayList; + +public class list_controller extends AppCompatActivity +{ + private ImageView empty_list; + private EditText search_bar; + + @Override + protected void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_app_list_manager); + + initializeListInstance(); + initializeListModel(); + initializeListController(); + initSearchBar(); + updatelist(); + } + + public void initializeListInstance() + { + app_model.getInstance().setListInstance(this); + app_model.getInstance().setListContext(this); + } + + + public void initializeListModel() + { + Bundle bundle = getIntent().getExtras(); + if(bundle.getInt(keys.list_type)==constants.list_bookmark) + { + list_model.getInstance().setType(constants.list_bookmark); + list_model.getInstance().setMainList(app_model.getInstance().getBookmark()); + } + else + { + list_model.getInstance().setType(constants.list_history); + list_model.getInstance().setMainList(app_model.getInstance().getHistory()); + } + } + + public void initializeListController() + { + empty_list = findViewById(R.id.empty_list); + search_bar = findViewById(R.id.search); + RecyclerView list_view = findViewById(R.id.listview); + + list_adapter adapter = new list_adapter(); + adapter.initialize(empty_list,this); + list_view.setAdapter(adapter); + list_view.setLayoutManager(new LinearLayoutManager(this)); + isListEmpty(); + } + + public void clearHistory(View view) + { + if(app_model.getInstance().getHistory().size()>0) + { + message_manager.getInstance().clearData(); + } + } + + public void clearAll() + { + list_model.getInstance().getModel().clear(); + list_model.getInstance().getMainList().clear(); + initializeListController(); + + empty_list.setAlpha(0f); + empty_list.setVisibility(View.VISIBLE); + empty_list.animate().alpha(1); + search_bar.setText(""); + + String table="bookmark"; + if(list_model.getInstance().getType()==constants.list_history) + { + table = "history"; + } + database_controller.getInstance().execSQL("delete from "+table+" where 1"); + + } + + public void isListEmpty() + { + if(list_model.getInstance().getModel().size()<=0) + { + empty_list.setVisibility(View.VISIBLE); + } + else + { + empty_list.setVisibility(View.GONE); + } + + } + + public void initSearchBar() + { + search_bar.setOnEditorActionListener((v, actionId, event) -> + { + if (actionId != EditorInfo.IME_ACTION_NEXT) + { + return false; + } + else + { + return updatelist(); + } + }); + } + + public boolean updatelist() + { + String query = search_bar.getText().toString(); + ArrayList temp_model = new ArrayList(); + list_model.getInstance().getIndex().clear(); + for(int counter=0;counter<=list_model.getInstance().getMainList().size()-1;counter++) + { + if(list_model.getInstance().getMainList().get(counter).getHeader().contains(query) || list_model.getInstance().getMainList().get(counter).getDescription().contains(query)) + { + temp_model.add(list_model.getInstance().getMainList().get(counter)); + list_model.getInstance().setIndex(counter); + } + } + list_model.getInstance().setModel(temp_model); + initializeListController(); + + return true; + } + + public void onBackPressed(View view) + { + finish(); + } + +} diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/list_activity/list_model.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/list_activity/list_model.java new file mode 100644 index 00000000..e9bbf7ba --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/list_activity/list_model.java @@ -0,0 +1,78 @@ +package com.darkweb.genesissearchengine.appManager.list_activity; + +import java.util.ArrayList; + +public class list_model +{ + private static final list_model ourInstance = new list_model(); + + public static list_model getInstance() + { + return ourInstance; + } + + private list_model() + { + } + + public ArrayList list_model = new ArrayList(); + public ArrayList list_index = new ArrayList(); + private ArrayList main_model_ref = new ArrayList(); + + public int listType; + + public void setType(int listType) + { + this.listType = listType; + } + + public int getType() + { + return listType; + } + + public void setModel(ArrayList list_model) + { + this.list_model = list_model; + } + + public ArrayList getModel() + { + return list_model; + } + + public void setIndex(int index) + { + list_index.add(index); + } + + public ArrayList getIndex() + { + return list_index; + } + + public void removeIndex(int index) + { + list_index.remove(index); + for(int counter=index;counter<=list_index.size()-1;counter++) + { + list_index.set(counter,list_index.get(counter)-1); + } + } + + public void setMainList(ArrayList model) + { + main_model_ref = model; + } + + public ArrayList getMainList() + { + return main_model_ref; + } + + public void removeFromMainList(int index) + { + main_model_ref.remove(index); + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/list_activity/list_row_model.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/list_activity/list_row_model.java new file mode 100644 index 00000000..8da32334 --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/list_activity/list_row_model.java @@ -0,0 +1,26 @@ +package com.darkweb.genesissearchengine.appManager.list_activity; + +public class list_row_model +{ + private int id; + private String header; + private String description; + + public list_row_model(String header, String description,int id) { + this.id = id; + this.header = header; + this.description = description; + } + + public String getHeader() { + return header; + } + + public String getDescription() { + return description; + } + + public int getId() { + return id; + } +} diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/AutoCompleteAdapter.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/AutoCompleteAdapter.java new file mode 100644 index 00000000..4c42019a --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/AutoCompleteAdapter.java @@ -0,0 +1,118 @@ +package com.darkweb.genesissearchengine.appManager.main_activity; + +import java.util.ArrayList; +import java.util.List; + +import android.content.Context; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.Filter; +import android.widget.Filterable; + +public class AutoCompleteAdapter extends ArrayAdapter implements Filterable { + + private ArrayList fullList; + private ArrayList mOriginalValues; + private ArrayFilter mFilter; + private int getResultCount=0; + + public int getResultCount() + { + if(getResultCount>0) + return 4; + else + return getResultCount; + } + + public AutoCompleteAdapter(Context context, int resource, int textViewResourceId, List objects) { + + super(context, resource, textViewResourceId, objects); + fullList = (ArrayList) objects; + mOriginalValues = new ArrayList(fullList); + } + + @Override + public int getCount() { + return fullList.size(); + } + + @Override + public String getItem(int position) { + return fullList.get(position); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + return super.getView(position, convertView, parent); + } + + @Override + public Filter getFilter() { + if (mFilter == null) { + mFilter = new ArrayFilter(); + } + return mFilter; + } + + + private class ArrayFilter extends Filter { + private Object lock; + + @Override + protected FilterResults performFiltering(CharSequence prefix) { + FilterResults results = new FilterResults(); + + if (mOriginalValues == null) { + synchronized (lock) { + mOriginalValues = new ArrayList(fullList); + } + } + + if (prefix == null || prefix.length() == 0) { + synchronized (lock) { + ArrayList list = new ArrayList(mOriginalValues); + results.values = list; + results.count = list.size(); + } + } else { + final String prefixString = prefix.toString().toLowerCase(); + + ArrayList values = mOriginalValues; + int count = values.size(); + + ArrayList newValues = new ArrayList(count); + + for (int i = 0; i < count; i++) { + String item = values.get(i); + if (item.toLowerCase().contains(prefixString)) { + newValues.add(item); + } + + } + + results.values = newValues; + results.count = newValues.size(); + } + + getResultCount = results.count; + return results; + } + + @SuppressWarnings("unchecked") + @Override + protected void publishResults(CharSequence constraint, FilterResults results) { + + if(results.values!=null){ + fullList = (ArrayList) results.values; + }else{ + fullList = new ArrayList(); + } + if (results.count > 0) { + notifyDataSetChanged(); + } else { + notifyDataSetInvalidated(); + } + } + } +} diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/app_model.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/app_model.java new file mode 100644 index 00000000..992c6dcf --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/app_model.java @@ -0,0 +1,174 @@ +package com.darkweb.genesissearchengine.appManager.main_activity; + +import android.content.Context; +import android.net.Uri; +import com.darkweb.genesissearchengine.appManager.data_helper.database_controller; +import com.darkweb.genesissearchengine.appManager.list_activity.list_controller; +import com.darkweb.genesissearchengine.appManager.list_activity.list_model; +import com.darkweb.genesissearchengine.appManager.list_activity.list_row_model; +import com.darkweb.genesissearchengine.constants.constants; +import com.darkweb.genesissearchengine.constants.status; +import com.darkweb.genesissearchengine.helperMethod; + +import java.text.SimpleDateFormat; +import java.util.*; + +public class app_model +{ + /*Data Objects*/ + private ArrayList history = new ArrayList(); + private ArrayList bookmarks = new ArrayList(); + private HashSet suggestions = new HashSet(); + private static int port = 9150; + + private Context appContext; + private application_controller appInstance; + + private Context listContext; + private list_controller listInstance; + + /*Initializations*/ + public void initialization() + { + database_controller.getInstance().initialize(); + initializeHistory(); + initializeBookmarks(); + } + + /*Setter Getter Initializations*/ + private static final app_model ourInstance = new app_model(); + public static app_model getInstance() + { + return ourInstance; + } + + + /*Getters Setters*/ + public int getPort() + { + return port; + } + public void setPort(int port) + { + this.port = port; + } + + + public void setAppContext(Context appContext) + { + this.appContext = appContext; + } + public Context getAppContext() + { + return appContext; + } + + + public application_controller getAppInstance() + { + return appInstance; + } + public void setAppInstance(application_controller appInstance) + { + this.appInstance = appInstance; + } + + + public void initializeHistory(){ + if(!status.history_status) + { + history = database_controller.getInstance().selectHistory(); + } + else + { + database_controller.getInstance().execSQL("delete from history where 1"); + } + app_model.getInstance().getAppInstance().reInitializeSuggestion(); + } + public void addHistory(String url) { + + if(history.size()> constants.max_history_size) + { + database_controller.getInstance().execSQL("delete from history where id="+history.get(history.size()-1).getId()); + history.remove(history.size()-1); + } + + int autoval = 0; + if(history.size()>0) + { + autoval = history.get(0).getId()+1; + } + + addSuggestions(url); + SimpleDateFormat d_form = new SimpleDateFormat("yyyy-MM-dd | HH-mm-ss"); + String date = d_form.format(new Date()); + database_controller.getInstance().execSQL("INSERT INTO history(id,date,url) VALUES("+autoval+",'"+date+"','"+url+"');"); + history.add(0,new list_row_model(url,date,autoval)); + } + public ArrayList getHistory() { + return history; + } + + + public void initializeBookmarks(){ + bookmarks = database_controller.getInstance().selectBookmark(); + } + public void addBookmark(String url,String title){ + int autoval = 0; + if(bookmarks.size()> constants.max_bookmark_size) + { + database_controller.getInstance().execSQL("delete from bookmark where id="+bookmarks.get(bookmarks.size()-1).getId()); + bookmarks.remove(history.size()-1); + } + + if(bookmarks.size()>0) + { + autoval = bookmarks.get(0).getId()+1; + } + + if(title.equals("")) + { + title = "New_Bookmark"+autoval; + } + database_controller.getInstance().execSQL("INSERT INTO bookmark(id,title,url) VALUES("+autoval+",'"+title+"','"+url+"');"); + bookmarks.add(0,new list_row_model(url,title,autoval)); + } + public ArrayList getBookmark(){ + return bookmarks; + } + + + public void initSuggestions(String url) { + suggestions.add(url); + } + public void addSuggestions(String url) { + if(url.contains("boogle.store")) + { + Uri uri = Uri.parse(url); + String actual_url = uri.getQueryParameter("q"); + suggestions.add(actual_url); + } + suggestions.add(url); + app_model.getInstance().getAppInstance().reInitializeSuggestion(); + } + public ArrayList getSuggestions() { + return new ArrayList(suggestions); + } + + + public void setListInstance(list_controller listInstance){ + this.listInstance = listInstance; + } + public list_controller getListInstance(){ + return listInstance; + } + + + public void setListContext(Context listContext) { + this.listContext = listContext; + } + public Context getListContext(){ + return listContext; + } + +} diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/applicationViewController.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/applicationViewController.java similarity index 81% rename from app/src/main/java/com/darkweb/genesissearchengine/appManager/applicationViewController.java rename to app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/applicationViewController.java index 4950104d..229d548e 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/applicationViewController.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/applicationViewController.java @@ -1,23 +1,21 @@ -package com.darkweb.genesissearchengine.appManager; +package com.darkweb.genesissearchengine.appManager.main_activity; import android.annotation.SuppressLint; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.os.Handler; -import android.os.Looper; import android.os.Message; import android.text.SpannableString; import android.text.Spanned; import android.text.style.ForegroundColorSpan; import android.util.Log; +import android.view.MenuInflater; 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 android.widget.TextView; +import android.widget.*; import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.core.view.MenuCompat; import com.darkweb.genesissearchengine.constants.constants; import com.darkweb.genesissearchengine.constants.keys; import com.darkweb.genesissearchengine.constants.messages; @@ -25,6 +23,7 @@ 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.admanager; import com.darkweb.genesissearchengine.pluginManager.message_manager; import com.darkweb.genesissearchengine.pluginManager.orbot_manager; import com.example.myapplication.R; @@ -37,7 +36,7 @@ public class applicationViewController /*ViewControllers*/ private WebView webView; private ProgressBar progressBar; - private EditText searchbar; + private AutoCompleteTextView searchbar; private ConstraintLayout splashScreen; private ConstraintLayout requestFailure; private FloatingActionButton floatingButton; @@ -49,6 +48,7 @@ public class applicationViewController private boolean pageLoadedSuccessfully = true; private boolean isSplashLoading = false; private Handler updateUIHandler = null; + private AutoCompleteAdapter suggestionAdapter; /*ProgressBar Delayed Updater*/ Handler progressBarHandler = null; @@ -65,7 +65,7 @@ public class applicationViewController { } - public void initialization(WebView webView1, TextView loadingText, ProgressBar progressBar, EditText searchbar, ConstraintLayout splashScreen, ConstraintLayout requestFailure, FloatingActionButton floatingButton, ImageView loading, ImageView splashlogo) + public void initialization(WebView webView1, TextView loadingText, ProgressBar progressBar, AutoCompleteTextView searchbar, ConstraintLayout splashScreen, ConstraintLayout requestFailure, FloatingActionButton floatingButton, ImageView loading, ImageView splashlogo) { this.webView = webView1; this.progressBar = progressBar; @@ -83,6 +83,26 @@ public class applicationViewController initLock(); initViews(); createUpdateUiHandler(); + initializeSuggestionView(); + } + + private void initializeSuggestionView() + { + suggestionAdapter = new AutoCompleteAdapter(app_model.getInstance().getAppInstance(), R.layout.hint_completion_layout, R.id.hintCompletionText,app_model.getInstance().getSuggestions()); + + searchbar.setThreshold(2); + searchbar.setAdapter(suggestionAdapter); + searchbar.setDropDownVerticalOffset(27); + searchbar.setDropDownWidth(helperMethod.screenWidth()-80); + searchbar.setDropDownHorizontalOffset(-88); + searchbar.setDropDownHeight(Math.round(helperMethod.screenHeight(false)*0.35f)); + searchbar.setDropDownBackgroundDrawable(app_model.getInstance().getAppInstance().getResources().getDrawable(R.drawable.rouned_corner)); + + } + + public void reInitializeSuggestion() + { + initializeSuggestionView(); } public boolean isHiddenView() @@ -143,11 +163,11 @@ public class applicationViewController try { boolean isFirstInstall = preference_manager.getInstance().getBool(keys.hasOrbotInstalled,true); - while (!status.isTorInitialized && isFirstInstall) - { - startPostTask(messages.UPDATE_LOADING_TEXT); - sleep(100); - } + //while (!status.isTorInitialized && isFirstInstall) + //{ + // startPostTask(messages.UPDATE_LOADING_TEXT); + // sleep(100); + //} preference_manager.getInstance().setBool(keys.hasOrbotInstalled,false); startPostTask(messages.DISABLE_SPLASH_SCREEN); } @@ -179,11 +199,16 @@ public class applicationViewController { loadingText.setText(orbot_manager.getInstance().getLogs()); } - if(msg.what == messages.DISABLE_SPLASH_SCREEN) + else if(msg.what == messages.DISABLE_SPLASH_SCREEN) { status.isApplicationLoaded = true; splashScreen.animate().alpha(0.0f).setDuration(200).setListener(null).withEndAction((() -> splashScreen.setVisibility(View.GONE))); onWelcomeMessageCheck(); + //app_model.getInstance().getAppInstance().initAdManager(); + } + else if(msg.what == messages.SHOW_ADS) + { + admanager.getInstance().showAd(true); } } }; @@ -202,6 +227,7 @@ public class applicationViewController } } + @SuppressLint("RestrictedApi") public void onPageFinished(boolean status) { helperMethod.hideKeyboard(); @@ -338,6 +364,20 @@ public class applicationViewController serverRequestManager.getInstance().versionChecker(); } + public void onShowAds() + { + startPostTask(messages.SHOW_ADS); + } + + public void openMenu(View view) + { + PopupMenu popup = new PopupMenu(app_model.getInstance().getAppInstance(), view); + MenuInflater inflater = popup.getMenuInflater(); + inflater.inflate(R.menu.menu_main, popup.getMenu()); + MenuCompat.setGroupDividerEnabled(popup.getMenu(), true); + popup.show(); + } + public void onReload() { if(!isHiddenView()) @@ -351,5 +391,9 @@ public class applicationViewController } } + public String getSearchBarUrl() + { + return searchbar.getText().toString(); + } } \ 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/main_activity/application_controller.java similarity index 73% rename from app/src/main/java/com/darkweb/genesissearchengine/appManager/application_controller.java rename to app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/application_controller.java index f27468f2..914aa6b8 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/application_controller.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/application_controller.java @@ -1,4 +1,4 @@ -package com.darkweb.genesissearchengine.appManager; +package com.darkweb.genesissearchengine.appManager.main_activity; import android.os.Build; import android.os.Bundle; @@ -9,6 +9,8 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.constraintlayout.widget.ConstraintLayout; import com.darkweb.genesissearchengine.*; import com.darkweb.genesissearchengine.constants.constants; +import com.darkweb.genesissearchengine.constants.enums; +import com.darkweb.genesissearchengine.constants.status; import com.darkweb.genesissearchengine.dataManager.preference_manager; import com.darkweb.genesissearchengine.pluginManager.*; @@ -27,7 +29,7 @@ public class application_controller extends AppCompatActivity private ProgressBar progressBar; private ConstraintLayout requestFailure; private ConstraintLayout splashScreen; - private EditText searchbar; + private AutoCompleteTextView searchbar; private FloatingActionButton floatingButton; private ImageView loadingIcon; private ImageView splashlogo; @@ -43,24 +45,27 @@ public class application_controller extends AppCompatActivity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.application_view); + setContentView(R.layout.home_view); if(helperMethod.isBuildValid()) { initializeAppModel(); + preference_manager.getInstance().initialize(); + + status.initStatus(); initializeCrashlytics(); initializeConnections(); initializeWebView(); initializeLocalEventHandlers(); + initAdManager(); - preference_manager.getInstance().initialize(); orbot_manager.getInstance().reinitOrbot(); - admanager.getInstance().initialize(); applicationViewController.getInstance().initialization(webView,loadingText,progressBar,searchbar,splashScreen,requestFailure,floatingButton, loadingIcon,splashlogo); firebase.getInstance().initialize(); geckoclient.initialize(geckoView); + app_model.getInstance().initialization(); - startApplication(); + initSearchEngine(); } else { @@ -70,10 +75,26 @@ public class application_controller extends AppCompatActivity } - public void startApplication() + public void initAdManager() + { + admanager.getInstance().initialize(); + } + + public void initSearchEngine() { fabricManager.getInstance().sendEvent("HOME PAGE LOADING : " ); - webView.loadUrl(constants.backendUrl); + if(status.search_status.equals(enums.searchEngine.Google.toString())) + { + webView.loadUrl(constants.backendGoogle); + } + else if(status.search_status.equals(enums.searchEngine.Bing.toString())) + { + webView.loadUrl(constants.backendBing); + } + else + { + webView.loadUrl(constants.backendGenesis); + } } public void initializeAppModel() @@ -104,7 +125,7 @@ public class application_controller extends AppCompatActivity public void initializeCrashlytics() { - fabricManager.getInstance().init(); + //fabricManager.getInstance().init(); } public void initializeWebView() @@ -116,14 +137,13 @@ public class application_controller extends AppCompatActivity public void setWebViewSettings(WebView view) { view.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); - view.getSettings().setJavaScriptEnabled(true); + view.getSettings().setJavaScriptEnabled(false); view.getSettings().setUseWideViewPort(true); } /*------------------------------------------------------- Event Handler ----------------------------------------------------*/ - private void initializeLocalEventHandlers() - { + private void initializeLocalEventHandlers() { searchbar.setOnEditorActionListener((v, actionId, event) -> { return eventhandler.onEditorClicked(v,actionId,event); @@ -151,13 +171,17 @@ public class application_controller extends AppCompatActivity eventhandler.onHomeButtonPressed(); } + public void onMenuButtonPressed(View view) + { + eventhandler.onMenuButtonPressed(view); + } + /*-------------------------------------------------------Helper Method In UI Redirection----------------------------------------------------*/ - public void onloadURL(String url,boolean isHiddenWeb) - { + public void onloadURL(String url,boolean isHiddenWeb,boolean isUrlSavable) { if(isHiddenWeb) { - geckoclient.loadGeckoURL(url,geckoView); + geckoclient.loadGeckoURL(url,geckoView,isUrlSavable); } else { @@ -166,8 +190,7 @@ public class application_controller extends AppCompatActivity } } - public void onRequestTriggered(boolean isHiddenWeb,String url) - { + public void onRequestTriggered(boolean isHiddenWeb,String url) { applicationViewController.getInstance().onRequestTriggered(isHiddenWeb,url); } @@ -181,8 +204,7 @@ public class application_controller extends AppCompatActivity applicationViewController.getInstance().onUpdateSearchBar(url); } - public void onInternetErrorView() - { + public void onInternetErrorView() { applicationViewController.getInstance().onInternetError(); applicationViewController.getInstance().disableFloatingView(); } @@ -192,8 +214,7 @@ public class application_controller extends AppCompatActivity return applicationViewController.getInstance().onDisableInternetError(); } - public void onProgressBarUpdateView(int progress) - { + public void onProgressBarUpdateView(int progress) { applicationViewController.getInstance().onProgressBarUpdate(progress); } @@ -217,17 +238,39 @@ public class application_controller extends AppCompatActivity applicationViewController.getInstance().onReload(); } + public void onShowAds() + { + applicationViewController.getInstance().onShowAds(); + } + + public void openMenu(View view) { + applicationViewController.getInstance().openMenu(view); + } + + public void reInitializeSuggestion() { + applicationViewController.getInstance().reInitializeSuggestion(); + } /*-------------------------------------------------------Helper Method Out UI Redirection----------------------------------------------------*/ + public String getSearchBarUrl() + { + return applicationViewController.getInstance().getSearchBarUrl(); + } + + public void onReInitGeckoView() { + geckoclient.initialize(geckoView); + geckoclient.onReloadHiddenView(); + } + public void onHiddenGoBack() { geckoclient.onHiddenGoBack(geckoView); } - public void stopHiddenView() - { + public void stopHiddenView() { geckoclient.stopHiddenView(geckoView); + geckoclient.removeHistory(); } public void onReloadHiddenView() @@ -240,14 +283,18 @@ public class application_controller extends AppCompatActivity return geckoclient.isGeckoViewRunning(); } - public void forcedCachePatch() - { - } - public boolean isInternetErrorOpened() { return requestFailure.getAlpha()==1; } + /*-------------------------------------------------------Menu Handler----------------------------------------------------*/ + + public boolean onMenuOptionSelected(MenuItem item) { + + eventhandler.onMenuPressed(item.getItemId()); + return super.onOptionsItemSelected(item); + } + } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/eventHandler.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/eventHandler.java similarity index 54% rename from app/src/main/java/com/darkweb/genesissearchengine/appManager/eventHandler.java rename to app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/eventHandler.java index 678e041f..baeb6284 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/eventHandler.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/eventHandler.java @@ -1,14 +1,19 @@ -package com.darkweb.genesissearchengine.appManager; +package com.darkweb.genesissearchengine.appManager.main_activity; 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.appManager.list_activity.list_controller; +import com.darkweb.genesissearchengine.appManager.setting_manager.setting_controller; import com.darkweb.genesissearchengine.constants.constants; +import com.darkweb.genesissearchengine.constants.enums; +import com.darkweb.genesissearchengine.constants.status; import com.darkweb.genesissearchengine.helperMethod; import com.darkweb.genesissearchengine.pluginManager.fabricManager; import com.darkweb.genesissearchengine.pluginManager.message_manager; +import com.example.myapplication.R; import java.io.IOException; import java.net.URL; @@ -42,47 +47,65 @@ public class eventHandler 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); + appContoller.onloadURL(url.replace(constants.frontEndUrlHost_v1,constants.backendUrlHost),false,true); 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(); + fabricManager.getInstance().sendEvent("EDITOR ONION URL REQUEST : " + url); + app_model.getInstance().getAppInstance().onloadURL(url,true,true); 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); + String editedURL = getSearchEngine(v.getText().toString().replaceAll(" ","+")); + app_model.getInstance().addHistory(editedURL); + appContoller.onloadURL(editedURL,false,true); appContoller.onClearSearchBarCursorView(); fabricManager.getInstance().sendEvent("EDITOR SEARCHED : " + editedURL); return true; } + public String getSearchEngine(String query) + { + if(status.search_status.equals(enums.searchEngine.Darkweb.toString())) + { + return "https://boogle.store/search?q="+query+"&p_num=1&s_type=all&savesearch=on"; + } + else if(status.search_status.equals(enums.searchEngine.Google.toString())) + { + return "https://www.google.com/search?source=hp&q="+query; + } + else + { + return "https://www.bing.com/search?q="+query; + } + + } + public void onReloadButtonPressed(View view) { fabricManager.getInstance().sendEvent("RELOAD BUTTON PRESSSED : "); appContoller.onReload(); } + public void onMenuButtonPressed(View view) + { + appContoller.openMenu(view); + } + public void onHomeButtonPressed() { + appContoller.stopHiddenView(); fabricManager.getInstance().sendEvent("HOME BUTTON PRESSSED : "); applicationViewController.getInstance().checkSSLTextColor(); - appContoller.onloadURL(constants.backendUrlSlashed,false); + appContoller.initSearchEngine(); helperMethod.hideKeyboard(); appContoller.onUpdateSearchBarView(constants.frontUrlSlashed); - appContoller.stopHiddenView(); } public void onFloatingButtonPressed() @@ -97,4 +120,39 @@ public class eventHandler appContoller.onBackPressedView(); } + public 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); + } + else if (menuId == R.id.menu3) { + helperMethod.openActivity(setting_controller.class,constants.list_history); + } + else if (menuId == R.id.menu4) + { + message_manager.getInstance().bookmark(app_model.getInstance().getAppInstance().getSearchBarUrl()); + } + else if (menuId == R.id.menu5) + { + helperMethod.openActivity(list_controller.class,constants.list_bookmark); + } + else if (menuId == R.id.menu6) + { + message_manager.getInstance().reportURL(); + } + else if (menuId == R.id.menu7) + { + helperMethod.rateApp(); + } + else if (menuId == R.id.menu8) + { + helperMethod.shareApp(); + } + + } + + } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/geckoClients.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/geckoClients.java similarity index 69% rename from app/src/main/java/com/darkweb/genesissearchengine/appManager/geckoClients.java rename to app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/geckoClients.java index 69dddd96..0ffd4d25 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/geckoClients.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/geckoClients.java @@ -1,10 +1,13 @@ -package com.darkweb.genesissearchengine.appManager; +package com.darkweb.genesissearchengine.appManager.main_activity; import android.os.Handler; import android.util.Log; import android.view.View; -import com.darkweb.genesissearchengine.pluginManager.admanager; +import com.darkweb.genesissearchengine.constants.keys; +import com.darkweb.genesissearchengine.constants.status; +import com.darkweb.genesissearchengine.dataManager.preference_manager; import com.darkweb.genesissearchengine.pluginManager.fabricManager; +import com.darkweb.genesissearchengine.pluginManager.message_manager; import com.darkweb.genesissearchengine.pluginManager.orbot_manager; import org.mozilla.geckoview.GeckoRuntime; import org.mozilla.geckoview.GeckoSession; @@ -28,13 +31,22 @@ public class geckoClients private boolean loadingCompeleted = false; private String currentURL = ""; private boolean wasBackPressed = false; + private boolean isUrlSavable = true; - public void loadGeckoURL(String url,GeckoView geckoView) + private int urlRequestCount = 0; + private boolean isAppRated = false; + + public geckoClients() + { + isAppRated = preference_manager.getInstance().getBool(keys.isAppRated,false); + } + + public void loadGeckoURL(String url,GeckoView geckoView,boolean isUrlSavable) { boolean init_status = orbot_manager.getInstance().initOrbot(url); if (init_status) { - urlList.clear(); + this.isUrlSavable = isUrlSavable; navigatedURL = ""; loadingCompeleted = false; initialize(geckoView); @@ -42,20 +54,28 @@ public class geckoClients app_model.getInstance().getAppInstance().onRequestTriggered(true,url); app_model.getInstance().getAppInstance().onProgressBarUpdateView(4); isFirstTimeLoad = true; + if(isUrlSavable) + { + urlList.clear(); + } } } 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); + if(urlList.size()<=0) + { + session1 = new GeckoSession(); + runtime1 = GeckoRuntime.getDefault(app_model.getInstance().getAppContext()); + runtime1.getSettings().setJavaScriptEnabled(status.java_status); + 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 @@ -119,19 +139,38 @@ public class geckoClients { if(isFirstTimeLoad) { - admanager.getInstance().showAd(true); + //admanager.getInstance().showAd(true); isFirstTimeLoad = false; } - if((urlList.size()==0 || urlList.size()>0 && !urlList.get(urlList.size()-1).equals(navigatedURL))&&!wasBackPressed) + if((urlList.size()==0 || urlList.size()>0 && !urlList.get(urlList.size()-1).equals(navigatedURL))&& !wasBackPressed) { urlList.add(navigatedURL); } if(urlList.size()>0) { - admanager.getInstance().showAd(false); + //admanager.getInstance().showAd(false); } + urlRequestCount++; + if(urlRequestCount==5) + { + if(!isAppRated) + { + isAppRated = true; + message_manager.getInstance().rateApp(); + } + } + else if(urlRequestCount>=4 && isAppRated) + { + app_model.getInstance().getAppInstance().onShowAds(); + } + + if(isUrlSavable && !urlList.get(urlList.size()-1).equals("navigatedURL")) + { + app_model.getInstance().addHistory(navigatedURL); + } + isUrlSavable = true; app_model.getInstance().getAppInstance().onDisableInternetError(); app_model.getInstance().getAppInstance().onProgressBarUpdateView(0); fabricManager.getInstance().sendEvent("ONION GECKO_CLIENT URL SUCCESS : " + success + "--" + isContentLoading); @@ -209,6 +248,11 @@ public class geckoClients } + public void removeHistory() + { + urlList.clear(); + } + public boolean isGeckoViewRunning() { return isRunning; @@ -216,8 +260,11 @@ public class geckoClients public void onReloadHiddenView() { - wasBackPressed = true; - session1.stop(); - session1.loadUri(navigatedURL); + if(urlList.size()>0) + { + wasBackPressed = true; + session1.stop(); + session1.loadUri(navigatedURL); + } } } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/webviewClient.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/webviewClient.java similarity index 90% rename from app/src/main/java/com/darkweb/genesissearchengine/appManager/webviewClient.java rename to app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/webviewClient.java index 14641e4c..d64ab42e 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/webviewClient.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/main_activity/webviewClient.java @@ -1,9 +1,9 @@ -package com.darkweb.genesissearchengine.appManager; +package com.darkweb.genesissearchengine.appManager.main_activity; -import android.util.Log; import android.webkit.WebChromeClient; import android.webkit.WebView; import android.webkit.WebViewClient; +import com.darkweb.genesissearchengine.constants.constants; import com.darkweb.genesissearchengine.constants.status; import com.darkweb.genesissearchengine.pluginManager.fabricManager; import com.darkweb.genesissearchengine.pluginManager.orbot_manager; @@ -25,19 +25,20 @@ public class webviewClient app_model.getInstance().getAppInstance().onProgressBarUpdateView(0); return true; } - if(!url.contains("boogle")) + if(!url.contains("boogle") && !url.equals(constants.backendGoogle) && !url.equals(constants.backendBing)) { app_model.getInstance().getAppInstance().stopHiddenView(); fabricManager.getInstance().sendEvent("BASE SIMPLE SEARCHED : " + url); isGeckoView = true; if(orbot_manager.getInstance().initOrbot(url)) { - app_model.getInstance().getAppInstance().onloadURL(url,true); + app_model.getInstance().getAppInstance().onloadURL(url,true,true); } return true; } else { + app_model.getInstance().addHistory(url); fabricManager.getInstance().sendEvent("BASE ONION SEARCHED : " + url); app_model.getInstance().getAppInstance().onRequestTriggered(false,url); return false; diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/setting_manager/setting_controller.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/setting_manager/setting_controller.java new file mode 100644 index 00000000..265c034c --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/setting_manager/setting_controller.java @@ -0,0 +1,72 @@ +package com.darkweb.genesissearchengine.appManager.setting_manager; + +import android.os.Bundle; +import android.view.View; +import android.widget.Spinner; +import androidx.appcompat.app.AppCompatActivity; +import com.example.myapplication.R; + +public class setting_controller extends AppCompatActivity +{ + + /*Private Variables*/ + + private setting_view_controller viewController; + private Spinner search; + private Spinner javascript; + private Spinner history; + + /*Initializations*/ + + @Override + protected void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + setContentView(R.layout.settings_activity); + + viewsInitializations(); + listenersInitializations(); + initializeModel(); + } + + public void viewsInitializations() + { + search = findViewById(R.id.search_manager); + javascript = findViewById(R.id.javascript_manager); + history = findViewById(R.id.history_manager); + + viewController = new setting_view_controller(search,javascript,history); + } + + public void listenersInitializations() + { + initializeItemSelectedListener(search); + initializeItemSelectedListener(javascript); + initializeItemSelectedListener(history); + } + + public void initializeModel() + { + setting_model.getInstance().setSettingInstance(this); + } + + /*Event Handlers*/ + + public void initializeItemSelectedListener(Spinner view) + { + settings_ehandler.getInstance().onItemListnerInitialization(view); + } + + public void onBackPressed(View view) + { + settings_ehandler.getInstance().onBackPressed(); + } + + /*View Handlers*/ + + public void closeView() + { + viewController.closeView(); + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/setting_manager/setting_model.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/setting_manager/setting_model.java new file mode 100644 index 00000000..67088e4f --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/setting_manager/setting_model.java @@ -0,0 +1,23 @@ +package com.darkweb.genesissearchengine.appManager.setting_manager; + +public class setting_model +{ + private static final setting_model ourInstance = new setting_model(); + private setting_model(){ + } + public static setting_model getInstance() + { + return ourInstance; + } + + private setting_controller settingInstance; + + setting_controller getSettingInstance() + { + return settingInstance; + } + void setSettingInstance(setting_controller settingInstance) + { + this.settingInstance = settingInstance; + } +} 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 new file mode 100644 index 00000000..7a0cc39d --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/setting_manager/setting_view_controller.java @@ -0,0 +1,73 @@ +package com.darkweb.genesissearchengine.appManager.setting_manager; + +import android.widget.ArrayAdapter; +import android.widget.Spinner; +import com.darkweb.genesissearchengine.constants.keys; +import com.darkweb.genesissearchengine.constants.strings; +import com.darkweb.genesissearchengine.dataManager.preference_manager; + +import static com.darkweb.genesissearchengine.constants.status.history_status; +import static com.darkweb.genesissearchengine.constants.status.java_status; + +class setting_view_controller +{ + /*Private Variables*/ + + private Spinner search; + private Spinner javascript; + private Spinner history; + + /*Initializations*/ + + setting_view_controller(Spinner search, Spinner javascript, Spinner history) + { + this.search = search; + this.search = javascript; + this.search = history; + + initJavascript(); + initHistory(); + initSearchEngine(); + } + + private void initJavascript() + { + if (java_status) + { + javascript.setSelection(0); + } + else + { + javascript.setSelection(1); + } + } + + private void initHistory() + { + if (history_status) + { + history.setSelection(0); + } + else + { + history.setSelection(1); + } + } + + @SuppressWarnings("unchecked") + private void initSearchEngine() + { + String myString = preference_manager.getInstance().getString(keys.search_engine, strings.darkweb); + ArrayAdapter myAdap = (ArrayAdapter) search.getAdapter(); + int spinnerPosition = myAdap.getPosition(myString); + search.setSelection(spinnerPosition); + } + + /*Helper Methods*/ + + void closeView() + { + 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 new file mode 100644 index 00000000..f62db563 --- /dev/null +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/setting_manager/settings_ehandler.java @@ -0,0 +1,104 @@ +package com.darkweb.genesissearchengine.appManager.setting_manager; + +import android.view.View; +import android.widget.AdapterView; +import android.widget.Spinner; +import com.darkweb.genesissearchengine.appManager.main_activity.app_model; +import com.darkweb.genesissearchengine.constants.keys; +import com.darkweb.genesissearchengine.dataManager.preference_manager; +import com.example.myapplication.R; + +import static com.darkweb.genesissearchengine.constants.status.*; +import static com.darkweb.genesissearchengine.constants.status.search_status; + +public class settings_ehandler +{ + /*Initializations*/ + + private static final settings_ehandler ourInstance = new settings_ehandler(); + + public static settings_ehandler getInstance() + { + return ourInstance; + } + + private settings_ehandler() + { + } + + /*Listeners*/ + + @SuppressWarnings("ConstantConditions") + private void onJavaScriptListener(int position) + { + if(position==1 && java_status) + { + java_status = false; + preference_manager.getInstance().setBool(keys.java_script, java_status); + app_model.getInstance().getAppInstance().onReInitGeckoView(); + } + else if(!java_status) + { + java_status = true; + preference_manager.getInstance().setBool(keys.java_script, java_status); + app_model.getInstance().getAppInstance().onReInitGeckoView(); + } + } + + private void onSearchListner(AdapterView parentView,int position) + { + if(!search_status.equals(parentView.getItemAtPosition(position).toString())) + { + search_status = parentView.getItemAtPosition(position).toString(); + preference_manager.getInstance().setString(keys.search_engine, search_status); + app_model.getInstance().getAppInstance().initSearchEngine(); + } + } + + @SuppressWarnings("ConstantConditions") + private void onHistoryListener(int position) + { + if(position==1 && history_status) + { + history_status = false; + preference_manager.getInstance().setBool(keys.history_clear, history_status); + } + else if(!java_status) + { + history_status = true; + preference_manager.getInstance().setBool(keys.history_clear, history_status); + } + } + + void onBackPressed() + { + setting_model.getInstance().getSettingInstance().closeView(); + } + + /*Listener Initializations*/ + + void onItemListnerInitialization(Spinner view) + { + view.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parentView, View selectedItemView, int position, long id) { + if(selectedItemView.getId()== R.id.search_manager) + { + settings_ehandler.getInstance().onJavaScriptListener(position); + } + else if(selectedItemView.getId()== R.id.javascript_manager) + { + settings_ehandler.getInstance().onHistoryListener(position); + } + else if(selectedItemView.getId()== R.id.history_manager) + { + settings_ehandler.getInstance().onSearchListner(parentView,position); + } + } + @Override + public void onNothingSelected(AdapterView parentView) { + } + }); + } + +} 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 dfec2583..6b7bc6e9 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/constants/constants.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/constants.java @@ -9,7 +9,9 @@ public class constants public static String softwares = "https://boogle.store/search?q=softwares+tools&p_num=1&s_type=all&p_num=1&s_type=all"; /*URL CONSTANTS*/ - public static String backendUrl = "https://boogle.store"; + public static String backendGenesis = "https://boogle.store"; + public static String backendGoogle = "https://www.google.com/"; + public static String backendBing = "https://www.bing.com/"; public static String backendUrlHost = "boogle.store"; public static String backendUrlSlashed = "https://boogle.store/"; public static String frontUrlSlashed = "https://genesis.onion/"; @@ -31,7 +33,16 @@ public class constants public static boolean proxy_socks_remote_dns = true; public static boolean proxy_cache = false; public static boolean proxy_memory = false; - public static String proxy_useragent_override = "Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20100101 Firefox/17.0"; + public static String proxy_useragent_override = "Mozilla/5.0 (Android 9; Mobile; rv:67.0) Gecko/67.0 Firefox/67.0"; public static boolean proxy_donottrackheader_enabled = false; public static int proxy_donottrackheader_value = 1; + + public static int list_history = 1; + public static int list_bookmark = 2; + + public static String databae_name="genesis.db"; + public static int databae_version=1; + + public static int max_history_size=3; + public static int max_bookmark_size=3; } 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 90de3ef5..424286f6 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/constants/enums.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/enums.java @@ -5,5 +5,6 @@ public class enums /*Web Request*/ public enum webRequestStatus{notRunning,running,repeat;} + public enum searchEngine{Darkweb,Bing,Google} } \ No newline at end of file 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 ba42f3a3..b0e7fc4d 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/constants/keys.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/keys.java @@ -20,5 +20,12 @@ public class keys public static String proxy_donottrackheader_enabled = "privacy.donottrackheader.enabled"; public static String proxy_donottrackheader_value = "privacy.donottrackheader.value"; public static String hasOrbotInstalled = "hasOrbotInstalled"; + public static String isAppRated = "isAppRated"; + public static String list_type = "list_type"; + + /*Settings*/ + public static String search_engine = "search_engine"; + public static String java_script = "java_script"; + public static String history_clear = "history_clear"; } 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 a3df77fe..ec891b3b 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/constants/messages.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/messages.java @@ -9,4 +9,5 @@ public class messages public final static int LOAD_WEBVIEW_BACKGROUND = 2; public final static int DISABLE_SPLASH_SCREEN =3; public final static int UPDATE_LOADING_TEXT =5; + public final static int SHOW_ADS =6; } 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 3ebb6bbe..7b041ab1 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/constants/status.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/status.java @@ -1,10 +1,25 @@ package com.darkweb.genesissearchengine.constants; +import com.darkweb.genesissearchengine.dataManager.preference_manager; + public class status { + /*App Level*/ public static boolean isApplicationLoaded = false; public static boolean isPlayStoreInstalled = true; public static boolean isTorInitialized = false; + public static String version_code = "6.0"; + + /*Settings Level*/ + public static String search_status = ""; + public static boolean java_status = false; + public static boolean history_status = true; + + public static void initStatus() + { + status.java_status = preference_manager.getInstance().getBool(keys.java_script,true); + status.history_status = preference_manager.getInstance().getBool(keys.history_clear,true); + status.search_status = preference_manager.getInstance().getString(keys.search_engine,"Darkweb"); + } - 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 d289d9bd..24c39d25 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/constants/strings.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/constants/strings.java @@ -2,6 +2,8 @@ package com.darkweb.genesissearchengine.constants; public class strings { + public static String torfolder = "torfiles"; + public static String welcome_message_title = "Welcome | Deep Web Gateway"; public static String welcome_message_desc = "\nWelcome to Deep Web | Dark Web Gateway. This application provide you a platform to Search and Open Dark Web 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"; public static String welcome_message_bt1 = "Deep Web Online Market"; @@ -37,7 +39,27 @@ public class strings public static String report_success_desc = "URL has been successfully reported. It will take about a week to completely remove this website from our servers\n"; public static String report_success_bt1 = "Dismiss"; - public static String torfolder = "torfiles"; + public static String rate_title = "Rate US"; + public static String rate_message = "We dont take donations or earn money from this app. We are trying to make a private anonymous internet \n\nIf you think this app works please rate us it gives us hope and strength to continue"; + public static String rate_positive = "Like This App"; + public static String rate_negative = "Don't Like This App"; + + public static String rate_success_title = "Sorry To Hear That!"; + public static String rate_success_desc = "If you are having any trouble and want to contact us please email us at gamesolstudios@gmail.com \n\nWe will try to solve your problem as soon as possible"; + public static String rate_success_bt1 = "Dismiss"; + + public static String bookmark_url_title = "Bookmark This Page"; + public static String bookmark_url_desc = "Bookmark this URL To Restore It Again Afterward\n"; + public static String bookmark_url_bt1 = "Bookmark"; + public static String bookmark_url_bt2 = "Dismiss"; + + public static String clear_title = "Warning | Clearing Data"; + public static String clear_desc = "You are about to clear your data if you are sure please continue\n"; + public static String clear_bt1 = "Clear Data"; + public static String clear_bt2 = "Dismiss"; + + public static String darkweb = "Darkweb"; + } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/dataManager/preference_manager.java b/app/src/main/java/com/darkweb/genesissearchengine/dataManager/preference_manager.java index 92c1dcbf..3a2a53ab 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/dataManager/preference_manager.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/dataManager/preference_manager.java @@ -2,7 +2,7 @@ package com.darkweb.genesissearchengine.dataManager; import android.content.SharedPreferences; import android.preference.PreferenceManager; -import com.darkweb.genesissearchengine.appManager.app_model; +import com.darkweb.genesissearchengine.appManager.main_activity.app_model; public class preference_manager { diff --git a/app/src/main/java/com/darkweb/genesissearchengine/helperMethod.java b/app/src/main/java/com/darkweb/genesissearchengine/helperMethod.java index 76935ca5..d560c8f4 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/helperMethod.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/helperMethod.java @@ -1,12 +1,14 @@ package com.darkweb.genesissearchengine; import android.content.Context; +import android.content.Intent; 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.net.Uri; import android.os.Build; import android.preference.PreferenceManager; import android.util.DisplayMetrics; @@ -17,10 +19,17 @@ 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 androidx.core.app.ShareCompat; +import com.darkweb.genesissearchengine.appManager.list_activity.list_controller; +import com.darkweb.genesissearchengine.appManager.main_activity.app_model; +import com.darkweb.genesissearchengine.constants.constants; import com.darkweb.genesissearchengine.constants.keys; +import com.darkweb.genesissearchengine.dataManager.preference_manager; import com.example.myapplication.BuildConfig; +import java.net.MalformedURLException; +import java.net.URL; + public class helperMethod { /*Helper Methods*/ @@ -35,20 +44,6 @@ public class helperMethod return false; } - public static String readHomepageHTML(Context applicationContext) - { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext); - return prefs.getString(keys.homepage_html_key,""); - } - - public static void setHomepageHTML(String html, Context applicationContext) - { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext); - SharedPreferences.Editor edit = prefs.edit(); - edit.putString(keys.homepage_html_key, html); - edit.commit(); - - } public static String completeURL(String url) { @@ -83,6 +78,11 @@ public class helperMethod } } + public static int screenWidth() + { + return (int)(Resources.getSystem().getDisplayMetrics().widthPixels); + } + public static int getNavigationBarHeight() { Resources resources = app_model.getInstance().getAppContext().getResources(); int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); @@ -100,14 +100,6 @@ public class helperMethod 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; @@ -149,4 +141,43 @@ public class helperMethod } + public static void rateApp() + { + preference_manager.getInstance().setBool(keys.isAppRated,true); + app_model.getInstance().getAppInstance().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.darkweb.genesissearchengine"))); + } + + public static void shareApp() + { + ShareCompat.IntentBuilder.from(app_model.getInstance().getAppInstance()) + .setType("text/plain") + .setChooserTitle("Genesis | Onion Search") + .setText("http://play.google.com/store/apps/details?id=" + app_model.getInstance().getAppInstance().getPackageName()) + .startChooser(); + } + + public static String getHost(String link) + { + URL url = null; + try + { + url = new URL(link); + String host = url.getHost(); + return host; + } + catch (MalformedURLException e) + { + e.printStackTrace(); + return ""; + } + + } + + public static void openActivity( Class cls,int type) + { + Intent myIntent = new Intent(app_model.getInstance().getAppInstance(), cls); + myIntent.putExtra(keys.list_type, type); + app_model.getInstance().getAppInstance().startActivity(myIntent); + } + } 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 13f1e52d..eced7892 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/httpManager/httpclient.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/httpManager/httpclient.java @@ -2,10 +2,7 @@ package com.darkweb.genesissearchengine.httpManager; import android.os.Handler; import android.os.Message; -import com.darkweb.genesissearchengine.appManager.app_model; -import com.darkweb.genesissearchengine.constants.constants; import com.darkweb.genesissearchengine.constants.messages; -import com.darkweb.genesissearchengine.helperMethod; import cz.msebera.android.httpclient.HttpResponse; import cz.msebera.android.httpclient.client.HttpClient; import cz.msebera.android.httpclient.client.methods.HttpGet; 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 113d6128..5e825f22 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/httpManager/webRequestHandler.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/httpManager/webRequestHandler.java @@ -5,7 +5,7 @@ import android.os.Message; import android.os.Handler; -import com.darkweb.genesissearchengine.appManager.app_model; +import com.darkweb.genesissearchengine.appManager.main_activity.app_model; import com.darkweb.genesissearchengine.constants.messages; public class webRequestHandler diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/admanager.java b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/admanager.java index 530ef3d0..25cfbea8 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/admanager.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/admanager.java @@ -1,6 +1,6 @@ package com.darkweb.genesissearchengine.pluginManager; -import com.darkweb.genesissearchengine.appManager.app_model; +import com.darkweb.genesissearchengine.appManager.main_activity.app_model; import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.InterstitialAd; import com.google.android.gms.ads.MobileAds; @@ -12,6 +12,7 @@ public class admanager private static final admanager ourInstance = new admanager(); private InterstitialAd mInterstitialAd; private int adCount = 0; + boolean isAdShown = false; /*Initializations*/ @@ -24,22 +25,25 @@ public class admanager public void initialize() { - /* - MobileAds.initialize(app_model.getInstance().getAppContext(), "ca-app-pub-5074525529134731~2926711128"); - mInterstitialAd = new InterstitialAd(app_model.getInstance().getAppContext()); + MobileAds.initialize(app_model.getInstance().getAppInstance(), "ca-app-pub-5074525529134731~2926711128"); + mInterstitialAd = new InterstitialAd(app_model.getInstance().getAppInstance()); mInterstitialAd.setAdUnitId("ca-app-pub-5074525529134731/8478420705"); - mInterstitialAd.loadAd(new AdRequest.Builder().build());*/ + mInterstitialAd.loadAd(new AdRequest.Builder().build()); } /*Helper Methods*/ public void showAd(boolean isAdForced) { - /* + if(isAdShown) + { + return; + } + if(!mInterstitialAd.isLoading() && !mInterstitialAd.isLoaded()) { mInterstitialAd.loadAd(new AdRequest.Builder().build()); - if(isAdForced || adCount==0 || adCount%5==0) + if(isAdForced || adCount==0 || adCount%3==0) { adCount = 0; } @@ -54,6 +58,7 @@ public class admanager { if(isAdForced) { + isAdShown = true; mInterstitialAd.show(); adCount = 1; } @@ -66,6 +71,6 @@ public class admanager adCount += 1; } } - }*/ + } } } 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 ffe88bc6..4ae2a869 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/fabricManager.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/fabricManager.java @@ -1,11 +1,5 @@ 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(); @@ -21,13 +15,13 @@ public class fabricManager public void init() { - Fabric.with(app_model.getInstance().getAppContext(), new Crashlytics()); - analyticmanager.getInstance().initialize(app_model.getInstance().getAppContext()); - analyticmanager.getInstance().logUser(); + //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); + //analyticmanager.getInstance().sendEvent(value); } } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/firebase.java b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/firebase.java index e68c9a11..26d017b5 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/firebase.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/firebase.java @@ -1,8 +1,6 @@ package com.darkweb.genesissearchengine.pluginManager; -import android.os.Bundle; -import com.darkweb.genesissearchengine.appManager.app_model; -import com.google.firebase.analytics.FirebaseAnalytics; +//import com.google.firebase.analytics.FirebaseAnalytics; public class firebase { @@ -13,20 +11,21 @@ public class firebase return ourInstance; } - private FirebaseAnalytics mFirebaseAnalytics; + //private FirebaseAnalytics mFirebaseAnalytics; public void initialize() { - mFirebaseAnalytics = FirebaseAnalytics.getInstance(app_model.getInstance().getAppContext()); + //mFirebaseAnalytics = FirebaseAnalytics.getInstance(app_model.getInstance().getAppContext()); } public void logEvent(String value,String id) { + /* Bundle bundle = new Bundle(); bundle.putString(FirebaseAnalytics.Param.ITEM_ID, id); bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, value); bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "Custom"); - mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle); + mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);*/ } private firebase() 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 99221eba..9f4d223c 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 @@ -1,13 +1,19 @@ package com.darkweb.genesissearchengine.pluginManager; +import android.annotation.SuppressLint; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.os.Handler; +import android.widget.RelativeLayout; +import android.widget.RelativeLayout.LayoutParams; +import android.text.InputType; +import android.widget.EditText; +import androidx.core.content.ContextCompat; import com.crowdfire.cfalertdialog.CFAlertDialog; -import com.darkweb.genesissearchengine.appManager.app_model; -import com.darkweb.genesissearchengine.appManager.application_controller; +import com.darkweb.genesissearchengine.appManager.main_activity.app_model; +import com.darkweb.genesissearchengine.appManager.main_activity.application_controller; import com.darkweb.genesissearchengine.constants.constants; import com.darkweb.genesissearchengine.constants.keys; import com.darkweb.genesissearchengine.constants.strings; @@ -44,23 +50,23 @@ public class message_manager .setMessage(strings.welcome_message_desc) .addButton(strings.welcome_message_bt1, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED , (dialog, which) -> { dialog.dismiss(); - controller.onloadURL(constants.blackMarket,false); - controller.onloadURL(constants.blackMarket,false); + controller.onloadURL(constants.blackMarket,false,true); + controller.onloadURL(constants.blackMarket,false,true); }) .addButton(strings.welcome_message_bt2, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED , (dialog, which) -> { dialog.dismiss(); - controller.onloadURL(constants.leakedDocument,false); - controller.onloadURL(constants.leakedDocument,false); + controller.onloadURL(constants.leakedDocument,false,true); + controller.onloadURL(constants.leakedDocument,false,true); }) .addButton(strings.welcome_message_bt3, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED , (dialog, which) -> { dialog.dismiss(); - controller.onloadURL(constants.news,false); - controller.onloadURL(constants.news,false); + controller.onloadURL(constants.news,false,true); + controller.onloadURL(constants.news,false,true); }) .addButton(strings.welcome_message_bt4, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED , (dialog, which) -> { dialog.dismiss(); - controller.onloadURL(constants.softwares,false); - controller.onloadURL(constants.softwares,false); + controller.onloadURL(constants.softwares,false,true); + controller.onloadURL(constants.softwares,false,true); }) .addButton(strings.welcome_message_bt5, -1, -1, CFAlertDialog.CFAlertActionStyle.NEGATIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED , (dialog, which) -> { dialog.dismiss(); @@ -114,15 +120,31 @@ public class message_manager builder.show(); } - public void reportedSuccessfully() + public void ratedSuccessfully() { Context application_context = app_model.getInstance().getAppContext(); CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) .setDialogStyle(CFAlertDialog.CFAlertStyle.BOTTOM_SHEET) - .setTitle(strings.report_success_title) + .setTitle(strings.rate_success_title) .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v2)) .setTextColor(application_context.getResources().getColor(R.color.black)) - .setMessage(strings.report_success_desc) + .setMessage(strings.rate_success_desc) + .addButton(strings.rate_success_bt1, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED, (dialog, which) -> { + dialog.dismiss(); + }); + + builder.show(); + } + + public void reportedSuccessfully(String title,String desc) + { + Context application_context = app_model.getInstance().getAppContext(); + CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) + .setDialogStyle(CFAlertDialog.CFAlertStyle.BOTTOM_SHEET) + .setTitle(title) + .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v2)) + .setTextColor(application_context.getResources().getColor(R.color.black)) + .setMessage(desc) .addButton(strings.report_success_bt1, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED, (dialog, which) -> { dialog.dismiss(); }); @@ -130,6 +152,60 @@ public class message_manager builder.show(); } + @SuppressLint("ResourceType") + public void bookmark(String url) + { + + final EditText input = new EditText(app_model.getInstance().getAppInstance()); + input.setInputType(InputType.TYPE_CLASS_TEXT); + input.setText(""); + input.setBackground(ContextCompat.getDrawable(app_model.getInstance().getAppContext(), R.xml.search_back_default)); + input.setPadding(40,15,40,15); + input.setHeight(80); + input.setTextSize(17); + input.setHint("Enter Bookmark Title"); + + Context application_context = app_model.getInstance().getAppContext(); + CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) + .setDialogStyle(CFAlertDialog.CFAlertStyle.ALERT) + .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v2)) + .setTextColor(application_context.getResources().getColor(R.color.black)) + //.setTitle(strings.bookmark_url_title) + .setHeaderView(input) + .setMessage("Bookmark URL | " + url + "\n") + .addButton(strings.bookmark_url_bt1, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED, (dialog, which) -> { + app_model.getInstance().addBookmark(url.replace("genesis.onion","boogle.store"),input.getText().toString()); + dialog.dismiss(); + }) + .addButton(strings.bookmark_url_bt2, -1, -1, CFAlertDialog.CFAlertActionStyle.NEGATIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED, (dialog, which) -> { + dialog.dismiss(); + }); + + builder.show(); + + } + + public void clearData() + { + Context application_context = app_model.getInstance().getListContext(); + CFAlertDialog.Builder builder = new CFAlertDialog.Builder(app_model.getInstance().getListContext()) + .setDialogStyle(CFAlertDialog.CFAlertStyle.BOTTOM_SHEET) + .setTitle(strings.clear_title) + .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v2)) + .setTextColor(application_context.getResources().getColor(R.color.black)) + .setMessage(strings.clear_desc) + .addButton(strings.clear_bt1, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED, (dialog, which) -> { + app_model.getInstance().getListInstance().clearAll(); + dialog.dismiss(); + }) + .addButton(strings.clear_bt2, -1, -1, CFAlertDialog.CFAlertActionStyle.NEGATIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED, (dialog, which) -> { + dialog.dismiss(); + }); + + builder.show(); + } + + public void reportURL() { Context application_context = app_model.getInstance().getAppContext(); @@ -140,11 +216,8 @@ public class message_manager .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); dialog.dismiss(); - reportedSuccessfully(); + reportedSuccessfully(strings.report_success_title,strings.report_success_desc); }) .addButton(strings.report_url_bt2, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED, (dialog, which) -> { dialog.dismiss(); @@ -153,6 +226,29 @@ public class message_manager builder.show(); } + public void rateApp() + { + Context application_context = app_model.getInstance().getAppContext(); + CFAlertDialog.Builder builder = new CFAlertDialog.Builder(application_context) + .setDialogStyle(CFAlertDialog.CFAlertStyle.ALERT) + .setTitle(strings.rate_title) + .setBackgroundColor(application_context.getResources().getColor(R.color.blue_dark_v2)) + .setTextColor(application_context.getResources().getColor(R.color.black)) + .setMessage(strings.rate_message) + .addButton(strings.rate_positive, -1, -1, CFAlertDialog.CFAlertActionStyle.POSITIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED, (dialog, which) -> { + preference_manager.getInstance().setBool(keys.isAppRated,true); + app_model.getInstance().getAppInstance().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.darkweb.genesissearchengine"))); + dialog.dismiss(); + }) + .addButton(strings.rate_negative, -1, -1, CFAlertDialog.CFAlertActionStyle.NEGATIVE, CFAlertDialog.CFAlertActionAlignment.JUSTIFIED, (dialog, which) -> { + preference_manager.getInstance().setBool(keys.isAppRated,true); + dialog.dismiss(); + ratedSuccessfully(); + }); + + builder.show(); + } + public void startingOrbotInfo(String url) { if(!isPopupOn) @@ -185,7 +281,7 @@ public class message_manager { if(!url.equals("")) { - app_model.getInstance().getAppInstance().onloadURL(url,true); + app_model.getInstance().getAppInstance().onloadURL(url,true,true); } else { 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 059907db..ce7fe711 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,18 +1,14 @@ package com.darkweb.genesissearchengine.pluginManager; -import android.util.Log; -import com.darkweb.genesissearchengine.appManager.app_model; +import com.darkweb.genesissearchengine.appManager.main_activity.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*/ diff --git a/app/src/main/res/drawable/back_arrow.png b/app/src/main/res/drawable/back_arrow.png new file mode 100644 index 00000000..49a4c4a3 Binary files /dev/null and b/app/src/main/res/drawable/back_arrow.png differ diff --git a/app/src/main/res/drawable/cancel.png b/app/src/main/res/drawable/cancel.png new file mode 100644 index 00000000..964dc9d7 Binary files /dev/null and b/app/src/main/res/drawable/cancel.png differ diff --git a/app/src/main/res/drawable/dropdown_arrow.png b/app/src/main/res/drawable/dropdown_arrow.png new file mode 100644 index 00000000..cbfbf8f2 Binary files /dev/null and b/app/src/main/res/drawable/dropdown_arrow.png differ diff --git a/app/src/main/res/drawable/empty_list.png b/app/src/main/res/drawable/empty_list.png new file mode 100644 index 00000000..92c616e3 Binary files /dev/null and b/app/src/main/res/drawable/empty_list.png differ diff --git a/app/src/main/res/drawable/menu_item.png b/app/src/main/res/drawable/menu_item.png new file mode 100644 index 00000000..98f4dc70 Binary files /dev/null and b/app/src/main/res/drawable/menu_item.png differ diff --git a/app/src/main/res/drawable/rouned_corner.xml b/app/src/main/res/drawable/rouned_corner.xml new file mode 100644 index 00000000..79621e37 --- /dev/null +++ b/app/src/main/res/drawable/rouned_corner.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_app_list_manager.xml b/app/src/main/res/layout/activity_app_list_manager.xml new file mode 100644 index 00000000..1cabcb6c --- /dev/null +++ b/app/src/main/res/layout/activity_app_list_manager.xml @@ -0,0 +1,93 @@ + + + + + + +