diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f408d141..690a16ab 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -84,6 +84,7 @@ android:windowSoftInputMode="adjustPan" /> + + + + mWebIcon = new HashMap<>(); /*Local Variables*/ @@ -273,6 +278,10 @@ public class historyAdapter extends RecyclerView.Adapter6){ break; } } + mContext.runOnUiThread(() -> { - Bitmap mBitmap = helperMethod.drawableToBitmap(mHindTypeIconTemp.getDrawable()); - mFaviconLogo.setImageBitmap(mBitmap); + mFaviconLogo.setColorFilter(null); + mFaviconLogo.clearColorFilter(); + mFaviconLogo.setImageTintList(null); + mFaviconLogo.setClipToOutline(true); + mWebIcon.put(model.getDescription(),mHindTypeIconTemp.getDrawable()); + if(mHindTypeIconTemp.getDrawable() != null){ + mFaviconLogo.setImageDrawable(mHindTypeIconTemp.getDrawable()); + }else { + Resources res = itemView.getContext().getResources(); + try { + mFaviconLogo.setImageDrawable(Drawable.createFromXml(res, res.getXml(R.xml.ic_baseline_browser))); + } catch (Exception ignored) { + } + } + }); + } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/geckoManager/geckoSession.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/geckoManager/geckoSession.java index cb49c0e3..c8802aa3 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/geckoManager/geckoSession.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/geckoManager/geckoSession.java @@ -9,6 +9,8 @@ import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.RectF; @@ -62,7 +64,9 @@ import java.io.IOException; import java.io.OutputStream; import java.lang.ref.WeakReference; import java.net.URLEncoder; +import java.text.SimpleDateFormat; import java.util.Arrays; +import java.util.Date; import java.util.List; import java.util.Objects; @@ -663,19 +667,37 @@ public class geckoSession extends GeckoSession implements GeckoSession.MediaDele } } - private boolean createAndSaveFileFromBase64Url(String url) { + private void saveImage(Bitmap finalBitmap) { - if(!url.startsWith("data") && !url.startsWith("blob")){ - return false; + String root = Environment.getExternalStorageDirectory().toString(); + File myDir = new File(root + "/saved_images"); + myDir.mkdirs(); + + String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); + String fname = "Shutta_"+ timeStamp +".jpg"; + + File file = new File(myDir, fname); + if (file.exists()) file.delete (); + try { + FileOutputStream out = new FileOutputStream(file); + finalBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out); + out.flush(); + out.close(); + } catch (Exception e) { + e.printStackTrace(); } - else if(url.startsWith("blob")){ - Toast toast = Toast.makeText(mContext.get().getApplicationContext(), - "Unable to download urls that contain prefix blob. Not Supported", - Toast.LENGTH_SHORT); + } - toast.show(); + /* Checks if external storage is available for read and write */ + public boolean isExternalStorageWritable() { + String state = Environment.getExternalStorageState(); + if (Environment.MEDIA_MOUNTED.equals(state)) { return true; } + return false; + } + + private boolean createAndSaveFileFromBase64Url(String url) { try{ File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); @@ -731,7 +753,7 @@ public class geckoSession extends GeckoSession implements GeckoSession.MediaDele String channel_id = createNotificationChannel(mContext.get().getApplicationContext()); assert channel_id != null; NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mContext.get().getApplicationContext(), channel_id) - .setSmallIcon(R.xml.ic_download) + .setSmallIcon(R.drawable.ic_download) .setContentTitle(filename) .setContentIntent(pIntent); @@ -741,7 +763,7 @@ public class geckoSession extends GeckoSession implements GeckoSession.MediaDele NotificationManager notificationManager = (NotificationManager) mContext.get().getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(notificationId, notificationBuilder.build()); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } diff --git a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/hintManager/hintAdapter.java b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/hintManager/hintAdapter.java index f4499558..86500968 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/hintManager/hintAdapter.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/appManager/homeManager/hintManager/hintAdapter.java @@ -183,7 +183,7 @@ public class hintAdapter extends RecyclerView.Adapter)dataController.getInstance().invokeSuggestions(dataEnums.eSuggestionCommands.M_GET_SUGGESTIONS, Collections.singletonList(mText)); - mEdittextChanged.postDelayed(postToServerRunnable, 150); + mEdittextChanged.postDelayed(postToServerRunnable, 350); return; } if(mSuggestions.size()>0){ @@ -859,7 +859,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba mSearchBarLoading = true; mEdittextChanged.postDelayed(postToServerRunnable, 0); }else{ - mEdittextChanged.postDelayed(postToServerRunnable, 150); + mEdittextChanged.postDelayed(postToServerRunnable, 350); } } } @@ -952,7 +952,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba final Handler handler = new Handler(); handler.postDelayed(() -> { mSearchBarLoading = false; - }, 150); + }, 350); }; public void onSearchBarInvoked(View view){ @@ -1377,6 +1377,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba pluginController.getInstance().onLanguageInvoke(Collections.singletonList(this), pluginEnums.eLangManager.M_INIT_LOCALE); mHomeViewController.onUpdateSearchEngineBar(false, 0); mNewTab.setPressed(false); + pluginController.getInstance().onMessageManagerInvoke(null, M_RESET); } status.mThemeApplying = false; diff --git a/app/src/main/java/com/darkweb/genesissearchengine/dataManager/suggestionDataModel.java b/app/src/main/java/com/darkweb/genesissearchengine/dataManager/suggestionDataModel.java index fe74cf16..12d3d29a 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/dataManager/suggestionDataModel.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/dataManager/suggestionDataModel.java @@ -206,7 +206,7 @@ public class suggestionDataModel implements SpellCheckerSession.SpellCheckerSess if(pQuery.length()>0){ if(!pQuery.equals("about:blank")){ - mCurrentList.add( mSize,new historyRowModel(pQuery, strings.GENERIC_EMPTY_STR,-1)); + mCurrentList.add( 0,new historyRowModel(pQuery, strings.GENERIC_EMPTY_STR,-1)); } } if(mCurrentList.size()<=0) { diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/notifictionManager.java b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/notifictionManager.java index e769d571..65106f17 100644 --- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/notifictionManager.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/notifictionManager.java @@ -6,6 +6,7 @@ import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; +import android.graphics.Color; import android.os.SystemClock; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.NotificationCompat; @@ -53,10 +54,11 @@ class notifictionManager private Notification getNotification () { NotificationCompat.Builder builder = new NotificationCompat.Builder(mAppContext.get().getApplicationContext(), CONST_NOTIFICATION_ID_NAME) ; builder.setContentTitle(CONST_NOTIFICATION_TITLE) ; - builder.setSmallIcon(R.drawable.notification_logo); - builder.setAutoCancel(true) ; - builder.setChannelId(CONST_NOTIFICATION_ID_NAME) ; - return builder.build() ; + builder.setSmallIcon(R.mipmap.ic_stat_tor_logo); + builder.setAutoCancel(true); + builder.setColor(Color.parseColor("#84989f")); + builder.setChannelId(CONST_NOTIFICATION_ID_NAME); + return builder.build(); } /*External Triggers*/ diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/orbotManager.java b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/orbotManager.java index e3692e81..04912183 100755 --- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/orbotManager.java +++ b/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/orbotManager.java @@ -20,7 +20,7 @@ class orbotManager /*Private Variables*/ - private WeakReference mAppContext; + private WeakReference mAppContext; private boolean mLogsStarted = false; /*Initialization*/ @@ -46,7 +46,7 @@ class orbotManager orbotLocalConstants.mIsManualBridge = status.sBridgeGatewayManual; orbotLocalConstants.mManualBridgeType = status.sBridgeCustomType; Prefs.putBridgesEnabled(status.sBridgeStatus); - Intent mServiceIntent = new Intent(mAppContext.get().getApplicationContext(), OrbotService.class); + Intent mServiceIntent = new Intent(mAppContext.get(), OrbotService.class); mServiceIntent.setAction(ACTION_START); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { mAppContext.get().getApplicationContext().startForegroundService(mServiceIntent); diff --git a/app/src/main/res/drawable-hdpi/notification_logo.png b/app/src/main/res/drawable-hdpi/notification_logo.png deleted file mode 100644 index 701eed46..00000000 Binary files a/app/src/main/res/drawable-hdpi/notification_logo.png and /dev/null differ diff --git a/orbotservice/src/main/res/drawable-mdpi/ic_stat_tor_logo.png b/app/src/main/res/drawable-mdpi/genesis_logo.png similarity index 100% rename from orbotservice/src/main/res/drawable-mdpi/ic_stat_tor_logo.png rename to app/src/main/res/drawable-mdpi/genesis_logo.png diff --git a/app/src/main/res/drawable-mdpi/ic_genesis_logo.png b/app/src/main/res/drawable-mdpi/ic_genesis_logo.png new file mode 100644 index 00000000..790ee517 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_genesis_logo.png differ diff --git a/orbotservice/src/main/res/drawable-xhdpi/ic_stat_tor_logo.png b/app/src/main/res/drawable-xhdpi/genesis_logo.png similarity index 100% rename from orbotservice/src/main/res/drawable-xhdpi/ic_stat_tor_logo.png rename to app/src/main/res/drawable-xhdpi/genesis_logo.png diff --git a/app/src/main/res/drawable-xhdpi/ic_genesis_logo.png b/app/src/main/res/drawable-xhdpi/ic_genesis_logo.png new file mode 100644 index 00000000..15e40cd5 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_genesis_logo.png differ diff --git a/orbotservice/src/main/res/drawable-xxhdpi/ic_stat_tor_logo.png b/app/src/main/res/drawable-xxhdpi/genesis_logo.png similarity index 100% rename from orbotservice/src/main/res/drawable-xxhdpi/ic_stat_tor_logo.png rename to app/src/main/res/drawable-xxhdpi/genesis_logo.png diff --git a/app/src/main/res/drawable-xxhdpi/ic_genesis_logo.png b/app/src/main/res/drawable-xxhdpi/ic_genesis_logo.png new file mode 100644 index 00000000..90d63cd5 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_genesis_logo.png differ diff --git a/orbotservice/src/main/res/drawable-xxxhdpi/ic_stat_tor_logo.png b/app/src/main/res/drawable-xxxhdpi/genesis_logo.png similarity index 100% rename from orbotservice/src/main/res/drawable-xxxhdpi/ic_stat_tor_logo.png rename to app/src/main/res/drawable-xxxhdpi/genesis_logo.png diff --git a/app/src/main/res/drawable-xxxhdpi/ic_genesis_logo.png b/app/src/main/res/drawable-xxxhdpi/ic_genesis_logo.png new file mode 100644 index 00000000..ae5e1ad5 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_genesis_logo.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_genesis_logo.png b/app/src/main/res/mipmap-hdpi/ic_genesis_logo.png new file mode 100644 index 00000000..7e0c0da9 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_genesis_logo.png differ diff --git a/orbotservice/build.gradle b/orbotservice/build.gradle index b4a3b569..3cf234ae 100755 --- a/orbotservice/build.gradle +++ b/orbotservice/build.gradle @@ -53,6 +53,5 @@ dependencies { implementation 'com.offbynull.portmapper:portmapper:2.0.5' implementation 'info.guardianproject:jtorctl:0.4' implementation 'com.github.tladesignz:IPtProxy:0.5.2' - testImplementation 'junit:junit:4.13.2' } diff --git a/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java b/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java index 9fb2873d..db244de3 100644 --- a/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java +++ b/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java @@ -90,6 +90,8 @@ import java.util.concurrent.TimeoutException; import IPtProxy.IPtProxy; +import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; + public class OrbotService extends VpnService implements TorServiceConstants, OrbotConstants { public final static String BINARY_TOR_VERSION = org.torproject.android.binary.TorServiceConstants.BINARY_TOR_VERSION; @@ -195,7 +197,7 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb } private void showConnectedToTorNetworkNotification() { - showToolbarNotification(getString(R.string.status_activated), NOTIFY_ID, R.drawable.ic_stat_tor_logo); + showToolbarNotification(getString(R.string.status_activated), NOTIFY_ID, R.mipmap.ic_stat_tor_logo); } private boolean findExistingTorDaemon() { @@ -262,7 +264,7 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb .setCategory(Notification.CATEGORY_SERVICE) .setContentTitle("Genesis") .setColor(Color.parseColor("#84989f")) - .setSmallIcon(R.drawable.ic_stat_tor_logo) + .setSmallIcon(R.mipmap.ic_stat_tor_logo) .setOngoing(Prefs.persistNotifications()); } @@ -270,9 +272,13 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb if (conn != null) { // only add new identity action when there is a connection Intent intentRefresh = new Intent(CMD_NEWNYM); PendingIntent pendingIntentNewNym = PendingIntent.getBroadcast(this, 0, intentRefresh, PendingIntent.FLAG_UPDATE_CURRENT); - mNotifyBuilder.addAction(R.drawable.ic_refresh_white_24dp, getString(R.string.menu_new_identity), pendingIntentNewNym); + mNotifyBuilder.addAction(0, getString(R.string.menu_new_identity), pendingIntentNewNym); } + Intent intentRefresh = new Intent(CMD_setting); + PendingIntent pendingIntentNewNym = PendingIntent.getBroadcast(this, 0, intentRefresh, PendingIntent.FLAG_UPDATE_CURRENT); + mNotifyBuilder.addAction(0, "Notification Settings", pendingIntentNewNym); + mNotifyBuilder.setContentText(notifyMsg) .setSmallIcon(icon) .setTicker(notifyType != NOTIFY_ID ? notifyMsg : null); @@ -320,7 +326,7 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb public void onTaskRemoved(Intent rootIntent) { Log.d(OrbotConstants.TAG, "task removed"); Intent intent = new Intent(this, DummyActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.addFlags(FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } @@ -512,6 +518,7 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb IntentFilter filter = new IntentFilter(); filter.addAction(CMD_NEWNYM); + filter.addAction(CMD_setting); filter.addAction(CMD_ACTIVE); mActionBroadcastReceiver = new ActionBroadcastReceiver(); registerReceiver(mActionBroadcastReceiver, filter); @@ -1158,12 +1165,16 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb } } + public void notificationSetting() { + + } + public void newIdentity() { if (conn != null) { // it is possible to not have a connection yet, and someone might try to newnym new Thread() { public void run() { try { - int iconId = R.drawable.ic_stat_tor_logo; + int iconId = R.mipmap.ic_stat_tor_logo; if (conn != null) { if (mCurrentStatus.equals(STATUS_ON) && Prefs.expandedNotifications()) @@ -1774,7 +1785,10 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb requestTorRereadConfig(); } else if (action.equals(CMD_NEWNYM)) { newIdentity(); - } else if (action.equals(CMD_ACTIVE)) { + } else if (action.equals(CMD_setting)) { + notificationSetting(); + } + else if (action.equals(CMD_ACTIVE)) { sendSignalActive(); } else if (action.equals(CMD_SET_EXIT)) { setExitNode(mIntent.getStringExtra("exit")); @@ -1857,6 +1871,17 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb return self; } + public void onSettingRegister(){ + try { + Intent intent = null; + intent = new Intent(this, Class.forName("com.darkweb.genesissearchengine.appManager.settingManager.notificationManager.settingNotificationController")); + intent.setFlags(FLAG_ACTIVITY_NEW_TASK); + getApplicationContext().startActivity(intent); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + public void disableNotification(){ if(mNotificationManager!=null){ mNotificationManager.cancel(NOTIFY_ID); @@ -1867,12 +1892,12 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb public void enableTorNotificationNoBandwidth(){ orbotLocalConstants.mNotificationStatus = 1; - showToolbarNotification("Connected to the Tor network", HS_NOTIFY_ID, R.drawable.ic_stat_tor_logo); + showToolbarNotification("Connected to the Tor network", HS_NOTIFY_ID, R.mipmap.ic_stat_tor_logo); } public void enableNotification(){ orbotLocalConstants.mNotificationStatus = 1; - showToolbarNotification(0+"kbps ⇣ / " +0+"kbps ⇡", HS_NOTIFY_ID, R.drawable.ic_stat_tor_logo); + showToolbarNotification(0+"kbps ⇣ / " +0+"kbps ⇡", HS_NOTIFY_ID, R.mipmap.ic_stat_tor_logo); } private class ActionBroadcastReceiver extends BroadcastReceiver { @@ -1882,6 +1907,10 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb newIdentity(); break; } + case CMD_setting: { + onSettingRegister(); + break; + } case CMD_ACTIVE: { sendSignalActive(); break; diff --git a/orbotservice/src/main/java/org/torproject/android/service/TorEventHandler.java b/orbotservice/src/main/java/org/torproject/android/service/TorEventHandler.java index cd141362..2f94f3bf 100755 --- a/orbotservice/src/main/java/org/torproject/android/service/TorEventHandler.java +++ b/orbotservice/src/main/java/org/torproject/android/service/TorEventHandler.java @@ -92,11 +92,11 @@ public class TorEventHandler implements EventHandler, TorServiceConstants { if (lastWritten > BW_THRESDHOLD || lastRead > BW_THRESDHOLD) { - int iconId = R.drawable.ic_stat_tor_logo; + int iconId = R.mipmap.ic_stat_tor_logo; if (read > 0 || written > 0){ if(orbotLocalConstants.mIsTorInitialized){ - iconId = R.drawable.ic_stat_tor_logo; + iconId = R.mipmap.ic_stat_tor_logo; }else { iconId = R.drawable.ic_stat_starting_tor_logo; } diff --git a/orbotservice/src/main/java/org/torproject/android/service/TorServiceConstants.java b/orbotservice/src/main/java/org/torproject/android/service/TorServiceConstants.java index e69d8ba6..d37fdacb 100755 --- a/orbotservice/src/main/java/org/torproject/android/service/TorServiceConstants.java +++ b/orbotservice/src/main/java/org/torproject/android/service/TorServiceConstants.java @@ -103,6 +103,7 @@ public interface TorServiceConstants { // actions for internal command Intents String CMD_SIGNAL_HUP = "signal_hup"; String CMD_NEWNYM = "newnym"; + String CMD_setting = "setting"; String CMD_SET_EXIT = "setexit"; String CMD_ACTIVE = "ACTIVE"; diff --git a/orbotservice/src/main/res/drawable-hdpi/ic_stat_tor_logo.png b/orbotservice/src/main/res/drawable-hdpi/ic_stat_tor_logo.png deleted file mode 100644 index ee9992fa..00000000 Binary files a/orbotservice/src/main/res/drawable-hdpi/ic_stat_tor_logo.png and /dev/null differ diff --git a/orbotservice/src/main/res/mipmap-mdpi/ic_stat_tor_logo.png b/orbotservice/src/main/res/mipmap-mdpi/ic_stat_tor_logo.png new file mode 100644 index 00000000..84149132 Binary files /dev/null and b/orbotservice/src/main/res/mipmap-mdpi/ic_stat_tor_logo.png differ diff --git a/orbotservice/src/main/res/mipmap-xhdpi/ic_stat_tor_logo.png b/orbotservice/src/main/res/mipmap-xhdpi/ic_stat_tor_logo.png new file mode 100644 index 00000000..08161fcc Binary files /dev/null and b/orbotservice/src/main/res/mipmap-xhdpi/ic_stat_tor_logo.png differ diff --git a/orbotservice/src/main/res/mipmap-xxhdpi/ic_stat_tor_logo.png b/orbotservice/src/main/res/mipmap-xxhdpi/ic_stat_tor_logo.png new file mode 100644 index 00000000..0edd077b Binary files /dev/null and b/orbotservice/src/main/res/mipmap-xxhdpi/ic_stat_tor_logo.png differ diff --git a/orbotservice/src/main/res/mipmap-xxxhdpi/ic_stat_tor_logo.png b/orbotservice/src/main/res/mipmap-xxxhdpi/ic_stat_tor_logo.png new file mode 100644 index 00000000..ae5e1ad5 Binary files /dev/null and b/orbotservice/src/main/res/mipmap-xxxhdpi/ic_stat_tor_logo.png differ