diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 3beb1542..1e93f24d 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -1,17 +1,17 @@ - + - + - + - - + + \ No newline at end of file diff --git a/.safedk/api/SafeDKAndroid-5.9.2.jar b/.safedk/api/SafeDKAndroid-5.9.2.jar new file mode 100644 index 00000000..b6a7c018 Binary files /dev/null and b/.safedk/api/SafeDKAndroid-5.9.2.jar differ diff --git a/.safedk/dex/SafeDKAndroid-5.9.1.dex b/.safedk/dex/SafeDKAndroid-5.9.1.dex deleted file mode 100644 index b7a7263c..00000000 Binary files a/.safedk/dex/SafeDKAndroid-5.9.1.dex and /dev/null differ diff --git a/.safedk/dex/SafeDKAndroid-5.9.2.dex b/.safedk/dex/SafeDKAndroid-5.9.2.dex new file mode 100644 index 00000000..496f8824 Binary files /dev/null and b/.safedk/dex/SafeDKAndroid-5.9.2.dex differ diff --git a/.safedk/hashes.safedk b/.safedk/hashes.safedk index 2319d73c..0d71384b 100644 --- a/.safedk/hashes.safedk +++ b/.safedk/hashes.safedk @@ -1,3 +1,3 @@ -#Sun Jan 01 02:47:09 PKT 2023 +#Wed Jan 04 13:50:34 PKT 2023 \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000= -json=1692972943 +json=1038193561 diff --git a/.safedk/plugin.properties b/.safedk/plugin.properties index 53831df6..9e8d765a 100644 --- a/.safedk/plugin.properties +++ b/.safedk/plugin.properties @@ -1,6 +1,6 @@ # -#Sun Jan 01 02:48:31 PKT 2023 +#Wed Jan 04 13:50:34 PKT 2023 \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000= -sdk_analysis_plugin_version=4.8.1 +sdk_analysis_plugin_version=4.8.2 set_multidex=true pCPe4EeU2ZQVwQPeHLgseRqHBX1V5pvo9Piuu4J809dRhadEgukXa1A8po_UeXu5hmPOTaP1v4QPaMKIEOhh50=hGlhanpemGqPOKKAgaXvhyxwZaG9uD68csy1OadWTNhEgKvBWR7-7KSpyFr6nfZ4KMOuBBV5J49s2LLSg-SVxg diff --git a/app/build.gradle b/app/build.gradle index f2be12d8..1e1e6a47 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -71,6 +71,7 @@ android { sourceSets { main { res.srcDirs = project.ext.resource_directories + jniLibs.srcDirs = ['src/main/jniLibs'] } orionRelease.root = project.ext.releaseRoot diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6a2c7301..593306e1 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,352 +1,349 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/hiddenservices/onionservices/appManager/bookmarkManager/bookmarkHome/bookmarkViewController.java b/app/src/main/java/com/hiddenservices/onionservices/appManager/bookmarkManager/bookmarkHome/bookmarkViewController.java index 7c788a56..3ec5ea0c 100644 --- a/app/src/main/java/com/hiddenservices/onionservices/appManager/bookmarkManager/bookmarkHome/bookmarkViewController.java +++ b/app/src/main/java/com/hiddenservices/onionservices/appManager/bookmarkManager/bookmarkHome/bookmarkViewController.java @@ -69,6 +69,10 @@ class bookmarkViewController { } private void initPostUI() { + + mSearchInput.setLongClickable(false); + mSearchInput.setOnLongClickListener(v -> false); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = mContext.getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); diff --git a/app/src/main/java/com/hiddenservices/onionservices/appManager/bookmarkManager/bookmarkSettings/bookmarkSettingViewController.java b/app/src/main/java/com/hiddenservices/onionservices/appManager/bookmarkManager/bookmarkSettings/bookmarkSettingViewController.java index 905d3c74..a101b7a6 100644 --- a/app/src/main/java/com/hiddenservices/onionservices/appManager/bookmarkManager/bookmarkSettings/bookmarkSettingViewController.java +++ b/app/src/main/java/com/hiddenservices/onionservices/appManager/bookmarkManager/bookmarkSettings/bookmarkSettingViewController.java @@ -36,6 +36,9 @@ class bookmarkSettingViewController { } private void initPostUI() { + mBookmarName.setLongClickable(false); + mBookmarName.setOnLongClickListener(v -> false); + sharedUIMethod.updateStatusBar(mContext); } diff --git a/app/src/main/java/com/hiddenservices/onionservices/appManager/bridgeManager/bridgeViewController.java b/app/src/main/java/com/hiddenservices/onionservices/appManager/bridgeManager/bridgeViewController.java index 11f353de..4321086d 100644 --- a/app/src/main/java/com/hiddenservices/onionservices/appManager/bridgeManager/bridgeViewController.java +++ b/app/src/main/java/com/hiddenservices/onionservices/appManager/bridgeManager/bridgeViewController.java @@ -50,6 +50,8 @@ class bridgeViewController { private void initPostUI() { sharedUIMethod.updateStatusBar(mContext); + mBridgeSettingBridgeCustom.setLongClickable(false); + mBridgeSettingBridgeCustom.setOnLongClickListener(v -> false); } private void animateColor(TextView p_view, int p_from, int p_to, String p_command, int p_duration) { diff --git a/app/src/main/java/com/hiddenservices/onionservices/appManager/historyManager/historyViewController.java b/app/src/main/java/com/hiddenservices/onionservices/appManager/historyManager/historyViewController.java index 862c2158..91ecf497 100644 --- a/app/src/main/java/com/hiddenservices/onionservices/appManager/historyManager/historyViewController.java +++ b/app/src/main/java/com/hiddenservices/onionservices/appManager/historyManager/historyViewController.java @@ -67,6 +67,10 @@ class historyViewController { } private void initPostUI() { + + mSearchInput.setLongClickable(false); + mSearchInput.setOnLongClickListener(v -> false); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = mContext.getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); diff --git a/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/geckoManager/geckoDownloadManager.java b/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/geckoManager/geckoDownloadManager.java index d7c416b3..992ed186 100644 --- a/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/geckoManager/geckoDownloadManager.java +++ b/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/geckoManager/geckoDownloadManager.java @@ -3,6 +3,7 @@ package com.hiddenservices.onionservices.appManager.homeManager.geckoManager; import android.Manifest; import android.content.pm.PackageManager; import android.net.Uri; +import android.os.Build; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; @@ -35,7 +36,7 @@ class geckoDownloadManager { } private void downloadFile(WebResponse response, String userAgent, AppCompatActivity context, geckoSession session, eventObserver.eventListener event) { - if (ContextCompat.checkSelfPermission(context, + if ( Build.VERSION.SDK_INT <= Build.VERSION_CODES.O_MR1 && ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(context, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, diff --git a/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/geckoManager/geckoPromptView.java b/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/geckoManager/geckoPromptView.java index 4eed565c..1b210ca2 100644 --- a/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/geckoManager/geckoPromptView.java +++ b/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/geckoManager/geckoPromptView.java @@ -5,6 +5,7 @@ import android.app.Activity; import android.app.AlertDialog; import android.content.ActivityNotFoundException; import android.content.ClipData; +import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -20,6 +21,7 @@ import android.view.InflateException; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.webkit.MimeTypeMap; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.CheckedTextView; @@ -35,7 +37,12 @@ import android.widget.TimePicker; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ShareCompat; +import com.hiddenservices.onionservices.appManager.activityContextManager; +import com.hiddenservices.onionservices.helperManager.helperMethod; + +import java.io.File; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -61,9 +68,16 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { mActivity = activity; } + public void stopMedia(){ + try { + activityContextManager.getInstance().getHomeController().onKillMedia(); + }catch (Exception ex){} + } + @Override public GeckoResult onAlertPrompt(final GeckoSession session, final AlertPrompt prompt) { + stopMedia(); final Activity activity = mActivity; if (activity == null) { return GeckoResult.fromValue(prompt.dismiss()); @@ -80,6 +94,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { @Override public GeckoResult onButtonPrompt(final GeckoSession session, final ButtonPrompt prompt) { + stopMedia(); final Activity activity = mActivity; if (activity == null) { return GeckoResult.fromValue(prompt.dismiss()); @@ -111,16 +126,66 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { return res; } + public static String getMimeType(Context context, Uri uri) { + String extension; + + //Check uri format to avoid null + if (uri.getScheme().equals(ContentResolver.SCHEME_CONTENT)) { + //If scheme is a content + final MimeTypeMap mime = MimeTypeMap.getSingleton(); + extension = mime.getExtensionFromMimeType(context.getContentResolver().getType(uri)); + } else { + //If scheme is a File + //This will replace white spaces with %20 and also other special characters. This will avoid returning null values on file name with spaces and special characters. + extension = MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(new File(uri.getPath())).toString()); + + } + + return extension; + } + + static boolean mPopupOpened = false; @Override public GeckoResult onSharePrompt(final GeckoSession session, final SharePrompt prompt) { - return GeckoResult.fromValue(prompt.dismiss()); + stopMedia(); + new Thread(){ + public void run(){ + try { + sleep(4000); + mPopupOpened = false; + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + if(!mPopupOpened){ + mPopupOpened = true; + }else { + return GeckoResult.fromValue(prompt.confirm(SharePrompt.Result.ABORT)); + } + try { + String m_data = prompt.uri; + if(prompt.text!=null){ + m_data += " : " + prompt.text; + } + + ShareCompat.IntentBuilder.from(mActivity) + .setType("text/x-uri") + .setChooserTitle(prompt.title) + .setText(m_data) + .startChooser(); + }catch (Exception ex){} + + return GeckoResult.fromValue(prompt.confirm(SharePrompt.Result.SUCCESS)); + } @Nullable @Override public GeckoResult onRepostConfirmPrompt(final GeckoSession session, final RepostConfirmPrompt prompt) { + stopMedia(); final Activity activity = mActivity; if (activity == null) { return GeckoResult.fromValue(prompt.dismiss()); @@ -157,6 +222,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { @Override public GeckoResult onBeforeUnloadPrompt(final GeckoSession session, final BeforeUnloadPrompt prompt) { + stopMedia(); final Activity activity = mActivity; if (activity == null) { return GeckoResult.fromValue(prompt.dismiss()); @@ -185,6 +251,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { } private int getViewPadding(final AlertDialog.Builder builder) { + stopMedia(); final TypedArray attr = builder.getContext().obtainStyledAttributes( new int[]{android.R.attr.listPreferredItemPaddingLeft}); final int padding = attr.getDimensionPixelSize(0, 1); @@ -194,6 +261,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { private LinearLayout addStandardLayout(final AlertDialog.Builder builder, final String title, final String msg) { + stopMedia(); final ScrollView scrollView = new ScrollView(builder.getContext()); final LinearLayout container = new LinearLayout(builder.getContext()); final int horizontalPadding = getViewPadding(builder); @@ -212,6 +280,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { final BasePrompt prompt, final GeckoResult response) { final AlertDialog dialog = builder.create(); + stopMedia(); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(final DialogInterface dialog) { @@ -227,6 +296,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { public GeckoResult onTextPrompt(final GeckoSession session, final TextPrompt prompt) { final Activity activity = mActivity; + stopMedia(); if (activity == null) { return GeckoResult.fromValue(prompt.dismiss()); } @@ -255,6 +325,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { public GeckoResult onAuthPrompt(final GeckoSession session, final AuthPrompt prompt) { final Activity activity = mActivity; + stopMedia(); if (activity == null) { return GeckoResult.fromValue(prompt.dismiss()); } @@ -321,6 +392,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { private void addChoiceItems(final int type, final ArrayAdapter list, final ChoicePrompt.Choice[] items, final String indent) { + stopMedia(); if (type == ChoicePrompt.Type.MENU) { for (final ChoicePrompt.Choice item : items) { list.add(new ModifiableChoice(item)); @@ -354,6 +426,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { final String message, final int type, final ChoicePrompt.Choice[] choices, final ChoicePrompt prompt, final GeckoResult res) { + stopMedia(); final Activity activity = mActivity; if (activity == null) { res.complete(prompt.dismiss()); @@ -533,6 +606,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { @Override public GeckoResult onChoicePrompt(final GeckoSession session, final ChoicePrompt prompt) { + stopMedia(); final GeckoResult res = new GeckoResult(); onChoicePromptImpl(session, prompt.title, prompt.message, prompt.type, prompt.choices, prompt, res); @@ -550,6 +624,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { @Override public GeckoResult onColorPrompt(final GeckoSession session, final ColorPrompt prompt) { + stopMedia(); final Activity activity = mActivity; if (activity == null) { return GeckoResult.fromValue(prompt.dismiss()); @@ -661,6 +736,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { @Override public GeckoResult onDateTimePrompt(final GeckoSession session, final DateTimePrompt prompt) { + stopMedia(); final Activity activity = mActivity; if (activity == null) { return GeckoResult.fromValue(prompt.dismiss()); @@ -779,6 +855,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { @Override @TargetApi(19) public GeckoResult onFilePrompt(GeckoSession session, FilePrompt prompt) { + stopMedia(); final Activity activity = mActivity; if (activity == null) { return GeckoResult.fromValue(prompt.dismiss()); @@ -837,6 +914,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { } public void onFileCallbackResult(final int resultCode, final Intent data) { + stopMedia(); if (mFileResponse == null) { return; } @@ -875,6 +953,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { public void onPermissionPrompt(final GeckoSession session, final String title, final GeckoSession.PermissionDelegate.Callback callback) { + stopMedia(); final Activity activity = mActivity; if (activity == null) { callback.reject(); @@ -900,6 +979,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { } public void onSlowScriptPrompt(GeckoSession geckoSession, String title, GeckoResult reportAction) { + stopMedia(); final Activity activity = mActivity; if (activity == null) { return; @@ -962,6 +1042,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { final String[] videoNames, final String[] audioNames, final GeckoSession.PermissionDelegate.MediaCallback callback) { final Activity activity = mActivity; + stopMedia(); if (activity == null || (video == null && audio == null)) { callback.reject(); return; @@ -1009,12 +1090,14 @@ final class geckoPromptView implements GeckoSession.PromptDelegate { public void onMediaPrompt(final GeckoSession session, final String title, final GeckoSession.PermissionDelegate.MediaSource[] video, final GeckoSession.PermissionDelegate.MediaSource[] audio, final GeckoSession.PermissionDelegate.MediaCallback callback) { + stopMedia(); onMediaPrompt(session, title, video, audio, null, null, callback); } @Override public GeckoResult onPopupPrompt(final GeckoSession session, final PopupPrompt prompt) { + stopMedia(); return GeckoResult.fromValue(prompt.confirm(AllowOrDeny.ALLOW)); } } \ No newline at end of file diff --git a/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/geckoManager/geckoSession.java b/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/geckoManager/geckoSession.java index 6fe36a98..ac9a1a93 100644 --- a/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/geckoManager/geckoSession.java +++ b/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/geckoManager/geckoSession.java @@ -162,6 +162,7 @@ geckoSession extends GeckoSession implements MediaSession.Delegate, GeckoSession public void onActivated(@NonNull GeckoSession session, @NonNull MediaSession mediaSession) { MediaSession.Delegate.super.onActivated(session, mediaSession); mMediaSession = mediaSession; + isMediaRunning = true; } @Override @@ -176,7 +177,8 @@ geckoSession extends GeckoSession implements MediaSession.Delegate, GeckoSession @Override public void onMetadata(@NonNull GeckoSession session, @NonNull MediaSession mediaSession, @NonNull MediaSession.Metadata meta) { mMediaTitle = meta.title; - if(!isMediaRunning || mediaDelegateItem == null){ + + if(mediaDelegateItem == null){ return; } @@ -193,7 +195,9 @@ geckoSession extends GeckoSession implements MediaSession.Delegate, GeckoSession } }.start(); MediaSession.Delegate.super.onMetadata(session, mediaSession, meta); - mediaDelegateItem.showNotification(this.mContext.get(), mMediaTitle, helperMethod.getHost(mCurrentURL), mMediaImage, !isMediaRunning); + if(isMediaRunning){ + mediaDelegateItem.showNotification(this.mContext.get(), mMediaTitle, helperMethod.getHost(mCurrentURL), mMediaImage, !isMediaRunning); + } } @Override diff --git a/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/homeController/homeController.java b/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/homeController/homeController.java index 1e186e2d..fd2e0efb 100644 --- a/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/homeController/homeController.java +++ b/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/homeController/homeController.java @@ -1,6 +1,8 @@ package com.hiddenservices.onionservices.appManager.homeManager.homeController; +import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE; import static android.app.Notification.FLAG_AUTO_CANCEL; +import static android.os.Build.VERSION.SDK_INT; import android.annotation.SuppressLint; import android.app.ActivityManager; @@ -33,6 +35,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.preference.PreferenceManager; +import android.provider.Settings; import android.speech.RecognizerIntent; import android.text.Editable; import android.text.TextWatcher; @@ -51,6 +54,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatDelegate; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout; +import androidx.core.app.ActivityCompat; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; import androidx.core.content.ContextCompat; @@ -273,6 +277,37 @@ public class homeController extends AppCompatActivity implements ComponentCallba if (!status.sTorBrowsing) { onStartApplication(null); } + if(status.sNoTorTriggered){ + if(status.sSettingDefaultSearchEngine.equals(constants.CONST_BACKEND_GENESIS_URL)){ + status.sSettingDefaultSearchEngine = constants.CONST_BACKEND_DUCK_DUCK_GO_URL; + } + pluginController.getInstance().onOrbotInvoke(null, pluginEnums.eOrbotManager.M_DISABLE_NOTIFICATION); + Intent mServiceIntent = new Intent(this.getApplicationContext(), OrbotService.class); + this.stopService(mServiceIntent); + + if (OrbotService.getServiceObject() != null) { + OrbotService.getServiceObject().onDestroy(); + } + new Handler().postDelayed(() -> + { + onShowDefaultNotification(); + }, 500); + }else { + onHideDefaultNotification(); + int notificationStatus = status.sBridgeNotificationManual; + if (notificationStatus == 0) { + pluginController.getInstance().onOrbotInvoke(null, pluginEnums.eOrbotManager.M_DISABLE_NOTIFICATION); + activityContextManager.getInstance().getHomeController().onShowDefaultNotification(); + } else { + if(status.mThemeApplying){ + new Handler().postDelayed(() -> + { + onHideDefaultNotification(); + pluginController.getInstance().onOrbotInvoke(null, pluginEnums.eOrbotManager.M_ENABLE_NOTIFICATION); + }, 500); + } + } + } } public void initBundle() { @@ -369,7 +404,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba if (status.mThemeApplying) { mSplashScreen.setAlpha(0); mSplashScreen.setVisibility(View.GONE); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (SDK_INT >= Build.VERSION_CODES.M) { mHomeViewController.initStatusBarColor(false); } else { Window window = getWindow(); @@ -586,7 +621,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba } String strManufacturer = android.os.Build.MANUFACTURER; - if ((Build.VERSION.SDK_INT == Build.VERSION_CODES.O || Build.VERSION.SDK_INT == Build.VERSION_CODES.O_MR1) && strManufacturer.equals("samsung")) { + if ((SDK_INT == Build.VERSION_CODES.O || SDK_INT == Build.VERSION_CODES.O_MR1) && strManufacturer.equals("samsung")) { PackageManager packageManager = getApplicationContext().getPackageManager(); packageManager.setComponentEnabledSetting(new ComponentName(getApplicationContext(), widgetController.class), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } else { @@ -858,7 +893,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba PendingIntent action; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (SDK_INT >= Build.VERSION_CODES.M) { action = PendingIntent.getActivity(context, 1025, new Intent(context, homeController.class), PendingIntent.FLAG_IMMUTABLE); // Flag indicating that if the described PendingIntent already exists, the current one should be canceled before generating a new one. }else { action = PendingIntent.getActivity(context, 1025, new Intent(context, homeController.class), 0); // Flag indicating that if the described PendingIntent already exists, the current one should be canceled before generating a new one. @@ -873,13 +908,13 @@ public class homeController extends AppCompatActivity implements ComponentCallba .setColor(getResources().getColor(R.color.c_tab_border)) .setContentTitle(title); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) + if (SDK_INT >= Build.VERSION_CODES.O) { - String channelId = "default_home_notification"; - NotificationChannel channel = new NotificationChannel(channelId, "default_home_notification", NotificationManager.IMPORTANCE_DEFAULT); - channel.setSound(null, null); - manager.createNotificationChannel(channel); - builder.setChannelId(channelId); + //String channelId = "default_home_notification"; + //NotificationChannel channel = new NotificationChannel(channelId, "default_home_notification", NotificationManager.IMPORTANCE_DEFAULT); + //channel.setSound(null, null); + //manager.createNotificationChannel(channel); + //builder.setChannelId(channelId); } Intent intentActionOpen = new Intent(context,homeController.class); @@ -895,14 +930,14 @@ public class homeController extends AppCompatActivity implements ComponentCallba Notification notification = builder.build(); PendingIntent dummyIntent = null; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (SDK_INT >= Build.VERSION_CODES.M) { PendingIntent.getActivity(context, 1025, new Intent(), PendingIntent.FLAG_IMMUTABLE); }else { PendingIntent.getActivity(context, 1025, new Intent(), 0); } notification.fullScreenIntent = dummyIntent; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU){ + if (SDK_INT >= Build.VERSION_CODES.TIRAMISU){ notification.flags = Notification.FLAG_AUTO_CANCEL|Notification.FLAG_ONGOING_EVENT; }else { notification.flags |= Notification.FLAG_NO_CLEAR; @@ -974,7 +1009,6 @@ public class homeController extends AppCompatActivity implements ComponentCallba @SuppressLint("ClickableViewAccessibility") @Override protected void onDestroy() { - status.sNoTorTriggered = false; orbotLocalConstants.mAppForceExit = true; NotificationManagerCompat.from(this).cancel(1030); if(manager!=null){ @@ -1015,6 +1049,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba NotificationManagerCompat.from(this).cancel(1030); if (!status.mThemeApplying) { + status.sNoTorTriggered = false; new Handler().postDelayed(() -> { android.os.Process.killProcess(android.os.Process.myPid()); @@ -2013,19 +2048,34 @@ public class homeController extends AppCompatActivity implements ComponentCallba onHomeButton(null); } + + private void requestWritePermission() { + if (SDK_INT >= Build.VERSION_CODES.R) { + try { + Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION); + intent.addCategory("android.intent.category.DEFAULT"); + intent.setData(Uri.parse(String.format("package:%s",getApplicationContext().getPackageName()))); + startActivityForResult(intent, 2296); + } catch (Exception e) { + Intent intent = new Intent(); + intent.setAction(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION); + startActivityForResult(intent, 2296); + } + } else { + //below android 11 + ActivityCompat.requestPermissions(this, new String[]{WRITE_EXTERNAL_STORAGE}, 1); + } + } + public void onDownloadFile() { mGeckoClient.downloadFile(homeController.this); } public void onManualDownload(String url) { - - /*EXTERNAL STORAGE REQUEST*/ mGeckoClient.manual_download(url, this); } public void onManualDownloadFileName(String pURL, String pPath) { - - /*EXTERNAL STORAGE REQUEST*/ mGeckoClient.manualDownloadWithName(pURL, pPath, this); } @@ -2711,7 +2761,7 @@ public class homeController extends AppCompatActivity implements ComponentCallba if (mNewTab.isPressed() || mTabFragment == null || mTabFragment.getVisibility() == View.VISIBLE || mHomeViewController.getMenuPopup() != null && mHomeViewController.getMenuPopup().isShowing()) { return; } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + if (SDK_INT >= Build.VERSION_CODES.O) { if (this.isActivityTransitionRunning()) { return; } diff --git a/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/homeController/homeViewController.java b/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/homeController/homeViewController.java index 84629cca..92475046 100644 --- a/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/homeController/homeViewController.java +++ b/app/src/main/java/com/hiddenservices/onionservices/appManager/homeManager/homeController/homeViewController.java @@ -244,6 +244,12 @@ class homeViewController { mCopyright.setVisibility(View.GONE); } + mSearchbar.setLongClickable(false); + mSearchbar.setOnLongClickListener(v -> false); + + mFindText.setLongClickable(false); + mFindText.setOnLongClickListener(v -> false); + } public void initSearchEngineView() { diff --git a/app/src/main/java/com/hiddenservices/onionservices/dataManager/crawlerDataModel.java b/app/src/main/java/com/hiddenservices/onionservices/dataManager/crawlerDataModel.java index 58e149a6..55c563e1 100644 --- a/app/src/main/java/com/hiddenservices/onionservices/dataManager/crawlerDataModel.java +++ b/app/src/main/java/com/hiddenservices/onionservices/dataManager/crawlerDataModel.java @@ -36,11 +36,13 @@ class crawlerDataModel { private Set mDuplicate; private ArrayList mHTML; private AppCompatActivity mContext; + RequestQueue mRequestQueue; crawlerDataModel(AppCompatActivity pContext) { mDuplicate = new HashSet<>(); mHTML = new ArrayList<>(); mContext = pContext; + mRequestQueue = Volley.newRequestQueue(mContext, new ProxiedHurlStack()); } private void onInit() { @@ -82,7 +84,6 @@ class crawlerDataModel { String mURL = strings.GENERIC_EMPTY_STR; private void onSendRequest() { - RequestQueue mRequestQueue = Volley.newRequestQueue(mContext, new ProxiedHurlStack()); String url = "http://167.86.99.31/user_index/"; StringRequest mRequestData = new StringRequest(Request.Method.POST, url, response -> { diff --git a/app/src/main/java/com/hiddenservices/onionservices/helperManager/helperMethod.java b/app/src/main/java/com/hiddenservices/onionservices/helperManager/helperMethod.java index f57b58b4..0354b14d 100644 --- a/app/src/main/java/com/hiddenservices/onionservices/helperManager/helperMethod.java +++ b/app/src/main/java/com/hiddenservices/onionservices/helperManager/helperMethod.java @@ -600,8 +600,8 @@ public class helperMethod { } public static void vibrate(AppCompatActivity context) { - Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); - v.vibrate(50); + // Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); + // v.vibrate(50); } public static void shareURL(AppCompatActivity context, String p_share) { @@ -975,9 +975,12 @@ public class helperMethod { } public static boolean checkPermissions(AppCompatActivity context) { + if(Build.VERSION.SDK_INT > Build.VERSION_CODES.O_MR1){ + return true; + } String[] permissions = new String[]{ Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.READ_EXTERNAL_STORAGE }; int result; @@ -989,7 +992,7 @@ public class helperMethod { } } if (!listPermissionsNeeded.isEmpty()) { - ActivityCompat.requestPermissions(context, listPermissionsNeeded.toArray(new String[0]), 100); + ActivityCompat.requestPermissions(context, listPermissionsNeeded.toArray(new String[0]), 1050); return false; } return true; diff --git a/app/src/main/java/com/hiddenservices/onionservices/pluginManager/messagePluginManager/messageManager.java b/app/src/main/java/com/hiddenservices/onionservices/pluginManager/messagePluginManager/messageManager.java index db29e325..50654c44 100644 --- a/app/src/main/java/com/hiddenservices/onionservices/pluginManager/messagePluginManager/messageManager.java +++ b/app/src/main/java/com/hiddenservices/onionservices/pluginManager/messagePluginManager/messageManager.java @@ -22,24 +22,18 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ScrollView; import android.widget.TextView; - import androidx.appcompat.app.AppCompatActivity; import androidx.constraintlayout.widget.ConstraintLayout; - -import com.hiddenservices.onionservices.appManager.homeManager.homeController.homeController; import com.hiddenservices.onionservices.constants.constants; import com.hiddenservices.onionservices.constants.enums; import com.hiddenservices.onionservices.constants.status; import com.hiddenservices.onionservices.constants.strings; import com.hiddenservices.onionservices.eventObserver; import com.hiddenservices.onionservices.helperManager.helperMethod; -import com.hiddenservices.onionservices.pluginManager.pluginController; import com.hiddenservices.onionservices.pluginManager.pluginEnums; import com.example.myapplication.R; import com.google.android.material.switchmaterial.SwitchMaterial; - import org.mozilla.geckoview.ContentBlocking; - import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -281,6 +275,12 @@ public class messageManager implements View.OnClickListener, DialogInterface.OnD mPopupCreateBookmarkNext.setOnClickListener(this); } + private void disableLongClick(EditText pEdittext){ + pEdittext.setLongClickable(false); + pEdittext.setOnLongClickListener(v -> false); + } + + private void onUpdateBridges() { initializeDialog(R.layout.popup_bridge_setting_custom, Gravity.CENTER); mContext.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); @@ -289,6 +289,8 @@ public class messageManager implements View.OnClickListener, DialogInterface.OnD String mBridgeType = (String) mEvent.invokeObserver(null, M_BRIDGE_TYPE); EditText mBridgeSettingCustomInput = mDialog.findViewById(R.id.pBridgeSettingCustomInput); EditText mBridgeSettingBridgeType = mDialog.findViewById(R.id.pBridgeSettingBridgeType); + disableLongClick(mBridgeSettingCustomInput); + disableLongClick(mBridgeSettingBridgeType); Button mBridgeSettingCustomRequest = mDialog.findViewById(R.id.pBridgeSettingCustomRequest); ImageButton mBridgeSettingCustomClear = mDialog.findViewById(R.id.pBridgeSettingCustomClear); Button mBridgeSettingCustomNext = mDialog.findViewById(R.id.pBridgeSettingCustomNext); @@ -568,6 +570,7 @@ public class messageManager implements View.OnClickListener, DialogInterface.OnD onDismiss(); helperMethod.hideKeyboard(mContext); EditText mPopupCreateBookmarkInput = mDialog.findViewById(R.id.pPopupCreateBookmarkInput); + disableLongClick(mPopupCreateBookmarkInput); String mBookmarkName = mPopupCreateBookmarkInput.getText().toString(); String mURL = mData.get(0).toString().replace(CONST_GENESIS_ONION, CONST_GENESIS_ONION_V2); if (mURL.startsWith(constants.CONST_PRIVACY_POLICY_URL_NON_TOR)) { @@ -607,11 +610,13 @@ public class messageManager implements View.OnClickListener, DialogInterface.OnD }); } else if (view.getId() == R.id.pBridgeSettingCustomClear) { EditText mBridges = mDialog.findViewById(R.id.pBridgeSettingCustomInput); + disableLongClick(mBridges); TextView mTextView = mDialog.findViewById(R.id.pBridgeSettingCustomError); mBridges.setText(strings.GENERIC_EMPTY_STR); mTextView.animate().setDuration(250).alpha(0); } else if (view.getId() == R.id.pBridgeSettingCustomNext) { + disableLongClick(mDialog.findViewById(R.id.pBridgeSettingCustomInput)); String mBridges = ((EditText) mDialog.findViewById(R.id.pBridgeSettingCustomInput)).getText().toString(); boolean mBridgeTypeExist = !mBridges.contains("obfs3") && !mBridges.contains("obfs4") && !mBridges.contains("fle") && !mBridges.contains("meek"); @@ -636,6 +641,7 @@ public class messageManager implements View.OnClickListener, DialogInterface.OnD onDismiss(); mContext.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); helperMethod.hideKeyboard(mContext); + disableLongClick(mDialog.findViewById(R.id.pBridgeSettingBridgeType)); mEvent.invokeObserver(Arrays.asList(mBridges, ((EditText) mDialog.findViewById(R.id.pBridgeSettingBridgeType)).getText().toString()), M_SET_BRIDGES); } else if (view.getId() == R.id.pPopupRateFailureNext) { onDismiss(); diff --git a/app/src/main/res/layouts/home/layout/home_view.xml b/app/src/main/res/layouts/home/layout/home_view.xml index 664b0945..0095225c 100644 --- a/app/src/main/res/layouts/home/layout/home_view.xml +++ b/app/src/main/res/layouts/home/layout/home_view.xml @@ -129,7 +129,6 @@ android:background="@color/c_home_side" android:translationZ="1dp" tools:ignore="RtlSymmetry" /> -