Bug Fixes

Bug Fixes
master
msmannan00 2021-04-18 20:47:09 +05:00
parent 7635345265
commit 242057bd51
9 changed files with 216 additions and 84 deletions

View File

@ -141,6 +141,6 @@ dependencies {
implementation 'com.android.support:design:28.0.0' implementation 'com.android.support:design:28.0.0'
implementation 'com.android.volley:volley:1.2.0' implementation 'com.android.volley:volley:1.2.0'
implementation 'com.github.instacart.truetime-android:library-extension-rx:3.3' implementation 'com.github.instacart.truetime-android:library-extension-rx:3.3'
implementation files('libs\\httpclientandroidlib-1.2.1.jar') implementation files('libs/httpclientandroidlib-1.2.1.jar')
implementation 'net.zetetic:android-database-sqlcipher:4.4.3@aar'
} }

View File

@ -32,9 +32,14 @@ import android.widget.ScrollView;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.TimePicker; import android.widget.TimePicker;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.darkweb.genesissearchengine.helperManager.PathUtil; import com.darkweb.genesissearchengine.helperManager.PathUtil;
import com.darkweb.genesissearchengine.helperManager.helperMethod; import com.darkweb.genesissearchengine.helperManager.helperMethod;
import com.example.myapplication.R;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -42,33 +47,34 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.Locale; import java.util.Locale;
import org.jetbrains.annotations.NotNull;
import org.mozilla.geckoview.AllowOrDeny; import org.mozilla.geckoview.AllowOrDeny;
import org.mozilla.geckoview.GeckoResult; import org.mozilla.geckoview.GeckoResult;
import org.mozilla.geckoview.GeckoSession; import org.mozilla.geckoview.GeckoSession;
import org.mozilla.geckoview.GeckoSession.PermissionDelegate.MediaSource;
import org.mozilla.geckoview.SlowScriptResponse; import org.mozilla.geckoview.SlowScriptResponse;
final class geckoPromptView implements GeckoSession.PromptDelegate { final class geckoPromptView implements GeckoSession.PromptDelegate {
protected static final String LOGTAG = "geckoPromptView"; protected static final String LOGTAG = "BasicGeckoViewPrompt";
private final WeakReference<Activity> mActivity; private final AppCompatActivity mActivity;
public int filePickerRequestCode = 1; public int filePickerRequestCode = 1;
private int mFileType; private int mFileType;
private GeckoResult<PromptResponse> mFileResponse; private GeckoResult<PromptResponse> mFileResponse;
private FilePrompt mFilePrompt; private FilePrompt mFilePrompt;
public geckoPromptView(final Activity activity) { public geckoPromptView(final AppCompatActivity activity) {
mActivity = new WeakReference(activity); mActivity = activity;
} }
@Override @Override
public GeckoResult<PromptResponse> onAlertPrompt(final GeckoSession session, public GeckoResult<PromptResponse> onAlertPrompt(final GeckoSession session,
final AlertPrompt prompt) { final AlertPrompt prompt) {
final Activity activity = mActivity.get(); final Activity activity = mActivity;
if (activity == null) { if (activity == null) {
return GeckoResult.fromValue(prompt.dismiss()); return GeckoResult.fromValue(prompt.dismiss());
} }
final AlertDialog.Builder builder = new AlertDialog.Builder(activity.getApplicationContext()) final AlertDialog.Builder builder = new AlertDialog.Builder(activity)
.setTitle(prompt.title) .setTitle(prompt.title)
.setMessage(prompt.message) .setMessage(prompt.message)
.setPositiveButton(android.R.string.ok, /* onClickListener */ null); .setPositiveButton(android.R.string.ok, /* onClickListener */ null);
@ -80,11 +86,11 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
@Override @Override
public GeckoResult<PromptResponse> onButtonPrompt(final GeckoSession session, public GeckoResult<PromptResponse> onButtonPrompt(final GeckoSession session,
final ButtonPrompt prompt) { final ButtonPrompt prompt) {
final Activity activity = mActivity.get(); final Activity activity = mActivity;
if (activity == null) { if (activity == null) {
return GeckoResult.fromValue(prompt.dismiss()); return GeckoResult.fromValue(prompt.dismiss());
} }
final AlertDialog.Builder builder = new AlertDialog.Builder(activity.getApplicationContext()) final AlertDialog.Builder builder = new AlertDialog.Builder(activity)
.setTitle(prompt.title) .setTitle(prompt.title)
.setMessage(prompt.message); .setMessage(prompt.message);
@ -111,6 +117,74 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
return res; return res;
} }
@Override
public GeckoResult<PromptResponse> onSharePrompt(final GeckoSession session,
final SharePrompt prompt) {
return GeckoResult.fromValue(prompt.dismiss());
}
@Nullable
@Override
public GeckoResult<PromptResponse> onRepostConfirmPrompt(final GeckoSession session,
final RepostConfirmPrompt prompt) {
final Activity activity = mActivity;
if (activity == null) {
return GeckoResult.fromValue(prompt.dismiss());
}
final AlertDialog.Builder builder = new AlertDialog.Builder(activity)
.setTitle("Are you sure?")
.setMessage("To display this page, GeckoViewExample must send information that will repeat any action (such as a search or order confirmation) that was performed earlier.");
GeckoResult<PromptResponse> res = new GeckoResult<>();
final DialogInterface.OnClickListener listener = (dialog, which) -> {
if (which == DialogInterface.BUTTON_POSITIVE) {
res.complete(prompt.confirm(AllowOrDeny.ALLOW));
} else if (which == DialogInterface.BUTTON_NEGATIVE) {
res.complete(prompt.confirm(AllowOrDeny.DENY));
} else {
res.complete(prompt.dismiss());
}
};
builder.setPositiveButton("Resend", listener);
builder.setNegativeButton("Cancel", listener);
createStandardDialog(builder, prompt, res).show();
return res;
}
@Nullable
@Override
public GeckoResult<PromptResponse> onBeforeUnloadPrompt(final GeckoSession session,
final BeforeUnloadPrompt prompt) {
final Activity activity = mActivity;
if (activity == null) {
return GeckoResult.fromValue(prompt.dismiss());
}
final AlertDialog.Builder builder = new AlertDialog.Builder(activity)
.setTitle("Are you sure?")
.setMessage("This page is asking you to confirm that you want to leave - data you have entered may not be saved");
GeckoResult<PromptResponse> res = new GeckoResult<>();
final DialogInterface.OnClickListener listener = (dialog, which) -> {
if (which == DialogInterface.BUTTON_POSITIVE) {
res.complete(prompt.confirm(AllowOrDeny.ALLOW));
} else if (which == DialogInterface.BUTTON_NEGATIVE) {
res.complete(prompt.confirm(AllowOrDeny.DENY));
} else {
res.complete(prompt.dismiss());
}
};
builder.setPositiveButton("Leave Page", listener);
builder.setNegativeButton("Stay on Page", listener);
createStandardDialog(builder, prompt, res).show();
return res;
}
private int getViewPadding(final AlertDialog.Builder builder) { private int getViewPadding(final AlertDialog.Builder builder) {
final TypedArray attr = builder.getContext().obtainStyledAttributes( final TypedArray attr = builder.getContext().obtainStyledAttributes(
new int[] { android.R.attr.listPreferredItemPaddingLeft }); new int[] { android.R.attr.listPreferredItemPaddingLeft });
@ -153,11 +227,11 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
@Override @Override
public GeckoResult<PromptResponse> onTextPrompt(final GeckoSession session, public GeckoResult<PromptResponse> onTextPrompt(final GeckoSession session,
final TextPrompt prompt) { final TextPrompt prompt) {
final Activity activity = mActivity.get(); final Activity activity = mActivity;
if (activity == null) { if (activity == null) {
return GeckoResult.fromValue(prompt.dismiss()); return GeckoResult.fromValue(prompt.dismiss());
} }
final AlertDialog.Builder builder = new AlertDialog.Builder(activity.getApplicationContext()); final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
final LinearLayout container = addStandardLayout(builder, prompt.title, prompt.message); final LinearLayout container = addStandardLayout(builder, prompt.title, prompt.message);
final EditText editText = new EditText(builder.getContext()); final EditText editText = new EditText(builder.getContext());
editText.setText(prompt.defaultValue); editText.setText(prompt.defaultValue);
@ -181,11 +255,11 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
@Override @Override
public GeckoResult<PromptResponse> onAuthPrompt(final GeckoSession session, public GeckoResult<PromptResponse> onAuthPrompt(final GeckoSession session,
final AuthPrompt prompt) { final AuthPrompt prompt) {
final Activity activity = mActivity.get(); final Activity activity = mActivity;
if (activity == null) { if (activity == null) {
return GeckoResult.fromValue(prompt.dismiss()); return GeckoResult.fromValue(prompt.dismiss());
} }
final AlertDialog.Builder builder = new AlertDialog.Builder(activity.getApplicationContext()); final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
final LinearLayout container = addStandardLayout(builder, prompt.title, prompt.message); final LinearLayout container = addStandardLayout(builder, prompt.title, prompt.message);
final int flags = prompt.authOptions.flags; final int flags = prompt.authOptions.flags;
@ -193,7 +267,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
final EditText username; final EditText username;
if ((flags & AuthPrompt.AuthOptions.Flags.ONLY_PASSWORD) == 0) { if ((flags & AuthPrompt.AuthOptions.Flags.ONLY_PASSWORD) == 0) {
username = new EditText(builder.getContext()); username = new EditText(builder.getContext());
username.setHint(""); username.setHint("Username");
username.setText(prompt.authOptions.username); username.setText(prompt.authOptions.username);
container.addView(username); container.addView(username);
} else { } else {
@ -201,7 +275,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
} }
final EditText password = new EditText(builder.getContext()); final EditText password = new EditText(builder.getContext());
password.setHint(""); password.setHint("Password");
password.setText(prompt.authOptions.password); password.setText(prompt.authOptions.password);
password.setInputType(InputType.TYPE_CLASS_TEXT | password.setInputType(InputType.TYPE_CLASS_TEXT |
InputType.TYPE_TEXT_VARIATION_PASSWORD); InputType.TYPE_TEXT_VARIATION_PASSWORD);
@ -281,12 +355,12 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
final String message, final int type, final String message, final int type,
final ChoicePrompt.Choice[] choices, final ChoicePrompt prompt, final ChoicePrompt.Choice[] choices, final ChoicePrompt prompt,
final GeckoResult<PromptResponse> res) { final GeckoResult<PromptResponse> res) {
final Activity activity = mActivity.get(); final Activity activity = mActivity;
if (activity == null) { if (activity == null) {
res.complete(prompt.dismiss()); res.complete(prompt.dismiss());
return; return;
} }
final AlertDialog.Builder builder = new AlertDialog.Builder(activity.getApplicationContext()); final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
addStandardLayout(builder, title, message); addStandardLayout(builder, title, message);
final ListView list = new ListView(builder.getContext()); final ListView list = new ListView(builder.getContext());
@ -472,11 +546,11 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
@Override @Override
public GeckoResult<PromptResponse> onColorPrompt(final GeckoSession session, public GeckoResult<PromptResponse> onColorPrompt(final GeckoSession session,
final ColorPrompt prompt) { final ColorPrompt prompt) {
final Activity activity = mActivity.get(); final Activity activity = mActivity;
if (activity == null) { if (activity == null) {
return GeckoResult.fromValue(prompt.dismiss()); return GeckoResult.fromValue(prompt.dismiss());
} }
final AlertDialog.Builder builder = new AlertDialog.Builder(activity.getApplicationContext()); final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
addStandardLayout(builder, prompt.title, /* msg */ null); addStandardLayout(builder, prompt.title, /* msg */ null);
final int initial = parseColor(prompt.defaultValue, /* def */ 0); final int initial = parseColor(prompt.defaultValue, /* def */ 0);
@ -583,7 +657,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
@Override @Override
public GeckoResult<PromptResponse> onDateTimePrompt(final GeckoSession session, public GeckoResult<PromptResponse> onDateTimePrompt(final GeckoSession session,
final DateTimePrompt prompt) { final DateTimePrompt prompt) {
final Activity activity = mActivity.get(); final Activity activity = mActivity;
if (activity == null) { if (activity == null) {
return GeckoResult.fromValue(prompt.dismiss()); return GeckoResult.fromValue(prompt.dismiss());
} }
@ -609,7 +683,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
final Calendar cal = formatter.getCalendar(); final Calendar cal = formatter.getCalendar();
cal.setTime(date); cal.setTime(date);
final AlertDialog.Builder builder = new AlertDialog.Builder(activity.getApplicationContext()); final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
final LayoutInflater inflater = LayoutInflater.from(builder.getContext()); final LayoutInflater inflater = LayoutInflater.from(builder.getContext());
final DatePicker datePicker; final DatePicker datePicker;
if (prompt.type == DateTimePrompt.Type.DATE || prompt.type == DateTimePrompt.Type.MONTH || if (prompt.type == DateTimePrompt.Type.DATE || prompt.type == DateTimePrompt.Type.MONTH ||
@ -691,7 +765,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
} }
}; };
builder.setNegativeButton(android.R.string.cancel, /* listener */ null) builder.setNegativeButton(android.R.string.cancel, /* listener */ null)
.setNeutralButton("Dismiss", listener) .setNeutralButton("Clear", listener)
.setPositiveButton(android.R.string.ok, listener); .setPositiveButton(android.R.string.ok, listener);
createStandardDialog(builder, prompt, res).show(); createStandardDialog(builder, prompt, res).show();
@ -702,15 +776,11 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
@TargetApi(19) @TargetApi(19)
public GeckoResult<PromptResponse> onFilePrompt(GeckoSession session, FilePrompt prompt) public GeckoResult<PromptResponse> onFilePrompt(GeckoSession session, FilePrompt prompt)
{ {
final Activity activity = mActivity.get(); final Activity activity = mActivity;
if (activity == null) { if (activity == null) {
return GeckoResult.fromValue(prompt.dismiss()); return GeckoResult.fromValue(prompt.dismiss());
} }
if(!helperMethod.checkPermissions((AppCompatActivity)mActivity.get().getApplicationContext())){
return GeckoResult.fromValue(prompt.dismiss());
}
// Merge all given MIME types into one, using wildcard if needed. // Merge all given MIME types into one, using wildcard if needed.
String mimeType = null; String mimeType = null;
String mimeSubtype = null; String mimeSubtype = null;
@ -763,7 +833,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
return res; return res;
} }
void onFileCallbackResult(final int resultCode, final Intent data) { public void onFileCallbackResult(final int resultCode, final Intent data) {
if (mFileResponse == null) { if (mFileResponse == null) {
return; return;
} }
@ -774,29 +844,17 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
final FilePrompt prompt = mFilePrompt; final FilePrompt prompt = mFilePrompt;
mFilePrompt = null; mFilePrompt = null;
if (resultCode != Activity.RESULT_OK || data == null || data.getData()==null) { if (resultCode != Activity.RESULT_OK || data == null) {
res.complete(prompt.dismiss()); res.complete(prompt.dismiss());
return; return;
} }
Uri uri = data.getData(); final Uri uri = data.getData();
String filePath = null;
filePath = PathUtil.getPath(mActivity.get().getApplicationContext(),uri);
if (filePath==null) {
res.complete(prompt.dismiss());
return;
}
uri = Uri.parse("file://"+filePath);
final ClipData clip = data.getClipData(); final ClipData clip = data.getClipData();
if (prompt.type == FilePrompt.Type.SINGLE || if (prompt.type == FilePrompt.Type.SINGLE ||
(prompt.type == FilePrompt.Type.MULTIPLE && clip == null)) { (prompt.type == FilePrompt.Type.MULTIPLE && clip == null)) {
res.complete(prompt.confirm(mActivity.get().getApplicationContext(), uri)); res.complete(prompt.confirm(mActivity, uri));
} else if (prompt.type == FilePrompt.Type.MULTIPLE) { } else if (prompt.type == FilePrompt.Type.MULTIPLE) {
if (clip == null) { if (clip == null) {
Log.w(LOGTAG, "No selected file"); Log.w(LOGTAG, "No selected file");
@ -808,18 +866,18 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
uris.add(clip.getItemAt(i).getUri()); uris.add(clip.getItemAt(i).getUri());
} }
res.complete(prompt.confirm(mActivity.get().getApplicationContext(), uris.toArray(new Uri[uris.size()]))); res.complete(prompt.confirm(mActivity, uris.toArray(new Uri[uris.size()])));
} }
} }
public void onPermissionPrompt(final GeckoSession session, final String title, public void onPermissionPrompt(final GeckoSession session, final String title,
final GeckoSession.PermissionDelegate.Callback callback) { final GeckoSession.PermissionDelegate.Callback callback) {
final Activity activity = mActivity.get(); final Activity activity = mActivity;
if (activity == null) { if (activity == null) {
callback.reject(); callback.reject();
return; return;
} }
final AlertDialog.Builder builder = new AlertDialog.Builder(activity.getApplicationContext()); final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(title) builder.setTitle(title)
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override @Override
@ -839,11 +897,11 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
} }
public void onSlowScriptPrompt(GeckoSession geckoSession, String title, GeckoResult<SlowScriptResponse> reportAction) { public void onSlowScriptPrompt(GeckoSession geckoSession, String title, GeckoResult<SlowScriptResponse> reportAction) {
final Activity activity = mActivity.get(); final Activity activity = mActivity;
if (activity == null) { if (activity == null) {
return; return;
} }
final AlertDialog.Builder builder = new AlertDialog.Builder(activity.getApplicationContext()); final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(title) builder.setTitle(title)
.setNegativeButton("Wait", new DialogInterface.OnClickListener() { .setNegativeButton("Wait", new DialogInterface.OnClickListener() {
@Override @Override
@ -863,13 +921,13 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
} }
private Spinner addMediaSpinner(final Context context, final ViewGroup container, private Spinner addMediaSpinner(final Context context, final ViewGroup container,
final MediaSource[] sources, final String[] sourceNames) { final GeckoSession.PermissionDelegate.MediaSource[] sources, final String[] sourceNames) {
final ArrayAdapter<MediaSource> adapter = new ArrayAdapter<MediaSource>( final ArrayAdapter<GeckoSession.PermissionDelegate.MediaSource> adapter = new ArrayAdapter<GeckoSession.PermissionDelegate.MediaSource>(
context, android.R.layout.simple_spinner_item) { context, android.R.layout.simple_spinner_item) {
private View convertView(final int position, final View view) { private View convertView(final int position, final View view) {
if (view != null) { if (view != null) {
final MediaSource item = getItem(position); final GeckoSession.PermissionDelegate.MediaSource item = getItem(position);
((TextView) view).setText(sourceNames != null ? sourceNames[position] : item.name); ((TextView) view).setText(sourceNames != null ? sourceNames[position] : "media");
} }
return view; return view;
} }
@ -897,15 +955,15 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
} }
public void onMediaPrompt(final GeckoSession session, final String title, public void onMediaPrompt(final GeckoSession session, final String title,
final MediaSource[] video, final MediaSource[] audio, final GeckoSession.PermissionDelegate.MediaSource[] video, final GeckoSession.PermissionDelegate.MediaSource[] audio,
final String[] videoNames, final String[] audioNames, final String[] videoNames, final String[] audioNames,
final GeckoSession.PermissionDelegate.MediaCallback callback) { final GeckoSession.PermissionDelegate.MediaCallback callback) {
final Activity activity = mActivity.get(); final Activity activity = mActivity;
if (activity == null || (video == null && audio == null)) { if (activity == null || (video == null && audio == null)) {
callback.reject(); callback.reject();
return; return;
} }
final AlertDialog.Builder builder = new AlertDialog.Builder(activity.getApplicationContext()); final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
final LinearLayout container = addStandardLayout(builder, title, /* msg */ null); final LinearLayout container = addStandardLayout(builder, title, /* msg */ null);
final Spinner videoSpinner; final Spinner videoSpinner;
@ -927,10 +985,10 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(final DialogInterface dialog, final int which) { public void onClick(final DialogInterface dialog, final int which) {
final MediaSource video = (videoSpinner != null) final GeckoSession.PermissionDelegate.MediaSource video = (videoSpinner != null)
? (MediaSource) videoSpinner.getSelectedItem() : null; ? (GeckoSession.PermissionDelegate.MediaSource) videoSpinner.getSelectedItem() : null;
final MediaSource audio = (audioSpinner != null) final GeckoSession.PermissionDelegate.MediaSource audio = (audioSpinner != null)
? (MediaSource) audioSpinner.getSelectedItem() : null; ? (GeckoSession.PermissionDelegate.MediaSource) audioSpinner.getSelectedItem() : null;
callback.grant(video, audio); callback.grant(video, audio);
} }
}); });
@ -946,7 +1004,7 @@ final class geckoPromptView implements GeckoSession.PromptDelegate {
} }
public void onMediaPrompt(final GeckoSession session, final String title, public void onMediaPrompt(final GeckoSession session, final String title,
final MediaSource[] video, final MediaSource[] audio, final GeckoSession.PermissionDelegate.MediaSource[] video, final GeckoSession.PermissionDelegate.MediaSource[] audio,
final GeckoSession.PermissionDelegate.MediaCallback callback) { final GeckoSession.PermissionDelegate.MediaCallback callback) {
onMediaPrompt(session, title, video, audio, null, null, callback); onMediaPrompt(session, title, video, audio, null, null, callback);
} }

View File

@ -11,7 +11,6 @@ import android.content.pm.ActivityInfo;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.InsetDrawable; import android.graphics.drawable.InsetDrawable;
@ -27,7 +26,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.*; import android.widget.*;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
@ -39,22 +37,18 @@ import androidx.core.graphics.ColorUtils;
import androidx.core.widget.NestedScrollView; import androidx.core.widget.NestedScrollView;
import androidx.fragment.app.FragmentContainerView; import androidx.fragment.app.FragmentContainerView;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.darkweb.genesissearchengine.appManager.historyManager.historyRowModel;
import com.darkweb.genesissearchengine.constants.*; import com.darkweb.genesissearchengine.constants.*;
import com.darkweb.genesissearchengine.dataManager.dataController; import com.darkweb.genesissearchengine.dataManager.dataController;
import com.darkweb.genesissearchengine.dataManager.dataEnums; import com.darkweb.genesissearchengine.dataManager.dataEnums;
import com.darkweb.genesissearchengine.helperManager.animatedColor; import com.darkweb.genesissearchengine.helperManager.animatedColor;
import com.darkweb.genesissearchengine.helperManager.autoCompleteAdapter;
import com.darkweb.genesissearchengine.helperManager.eventObserver; import com.darkweb.genesissearchengine.helperManager.eventObserver;
import com.darkweb.genesissearchengine.helperManager.helperMethod; import com.darkweb.genesissearchengine.helperManager.helperMethod;
import com.darkweb.genesissearchengine.widget.progressBar.AnimatedProgressBar; import com.darkweb.genesissearchengine.widget.progressBar.AnimatedProgressBar;
import com.example.myapplication.R; import com.example.myapplication.R;
import com.google.android.gms.ads.AdView; import com.google.android.gms.ads.AdView;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import org.mozilla.geckoview.GeckoView; import org.mozilla.geckoview.GeckoView;
import org.torproject.android.service.wrapper.orbotLocalConstants; import org.torproject.android.service.wrapper.orbotLocalConstants;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -281,7 +275,7 @@ class homeViewController
public void onHideTabContainer(){ public void onHideTabContainer(){
if(mTabFragment.getAlpha()>0 || mTabFragment.getVisibility()!=View.GONE){ if(mTabFragment.getAlpha()>0 || mTabFragment.getVisibility()!=View.GONE){
Log.i("SUPERFUCK4","SUPERFUCK");
mNewTab.setPressed(false); mNewTab.setPressed(false);
new Handler().postDelayed(() -> new Handler().postDelayed(() ->
{ {
@ -289,7 +283,8 @@ class homeViewController
mEvent.invokeObserver(null, enums.etype.M_UPDATE_THEME); mEvent.invokeObserver(null, enums.etype.M_UPDATE_THEME);
}, 250); }, 250);
mTabFragment.animate().setDuration(150).alpha(0f).withEndAction(() -> { mTabFragment.animate().cancel();
mTabFragment.animate().setDuration(100).alpha(0f).withEndAction(() -> {
mTabFragment.setVisibility(View.GONE); mTabFragment.setVisibility(View.GONE);
mEvent.invokeObserver(null, enums.etype.M_UPDATE_PIXEL_BACKGROUND); mEvent.invokeObserver(null, enums.etype.M_UPDATE_PIXEL_BACKGROUND);
}); });
@ -1345,16 +1340,12 @@ class homeViewController
{ {
if(msg.what == messages.MESSAGE_ON_URL_LOAD) if(msg.what == messages.MESSAGE_ON_URL_LOAD)
{ {
Log.i("SUPEEEE","SUPEEE1");
if(mEvent.invokeObserver(null, enums.etype.M_HOME_PAGE)==null){ if(mEvent.invokeObserver(null, enums.etype.M_HOME_PAGE)==null){
mEvent.invokeObserver(null, enums.etype.M_PRELOAD_URL); mEvent.invokeObserver(null, enums.etype.M_PRELOAD_URL);
Log.i("SUPEEEE","SUPEEE2");
if(status.sSettingRedirectStatus.equals(strings.GENERIC_EMPTY_STR)){ if(status.sSettingRedirectStatus.equals(strings.GENERIC_EMPTY_STR)){
mEvent.invokeObserver(Collections.singletonList(helperMethod.getDomainName(status.sSettingSearchStatus)), enums.etype.on_url_load); mEvent.invokeObserver(Collections.singletonList(helperMethod.getDomainName(status.sSettingSearchStatus)), enums.etype.on_url_load);
Log.i("SUPEEEE","SUPEEE5");
}else { }else {
mEvent.invokeObserver(Collections.singletonList(helperMethod.getDomainName(status.sSettingRedirectStatus)), enums.etype.on_url_load); mEvent.invokeObserver(Collections.singletonList(helperMethod.getDomainName(status.sSettingRedirectStatus)), enums.etype.on_url_load);
Log.i("SUPEEEE","SUPEEE5");
} }
} }
if(!status.sExternalWebsite.equals(strings.GENERIC_EMPTY_STR) ){ if(!status.sExternalWebsite.equals(strings.GENERIC_EMPTY_STR) ){

View File

@ -324,6 +324,15 @@ public class tabAdapter extends RecyclerView.Adapter<tabAdapter.listViewHolder>
if(model.getmId()==null){ if(model.getmId()==null){
mItemSelectionMenu.setVisibility(View.VISIBLE); mItemSelectionMenu.setVisibility(View.VISIBLE);
mItemSelectionMenuButton.setOnClickListener(this); mItemSelectionMenuButton.setOnClickListener(this);
if(status.sTabGridLayoutEnabled){
itemView.setVisibility(View.GONE);
itemView.setClickable(false);
itemView.setFocusable(false);
itemView.setEnabled(false);
return;
}
}else { }else {
mLoadSession.setOnLongClickListener(this); mLoadSession.setOnLongClickListener(this);
mRemoveRow.setOnClickListener(this); mRemoveRow.setOnClickListener(this);

View File

@ -50,6 +50,7 @@ public class tabController extends Fragment
private ImageView mRemoveSelection; private ImageView mRemoveSelection;
private ImageButton mMenuButton; private ImageButton mMenuButton;
private ImageButton mClearSelection; private ImageButton mClearSelection;
private ImageButton mNewTab;
private TextView mEmptyView; private TextView mEmptyView;
private View mPopupUndo; private View mPopupUndo;
private TextView mSelectionCount; private TextView mSelectionCount;
@ -191,8 +192,9 @@ public class tabController extends Fragment
mSelectionCount = mRootView.findViewById(R.id.pSelectionCount); mSelectionCount = mRootView.findViewById(R.id.pSelectionCount);
mBlocker = mRootView.findViewById(R.id.pBlocker); mBlocker = mRootView.findViewById(R.id.pBlocker);
mNestedScrollView = mRootView.findViewById(R.id.pNestedScroll); mNestedScrollView = mRootView.findViewById(R.id.pNestedScroll);
mNewTab = mRootView.findViewById(R.id.pNewTab);
mtabViewController = new tabViewController(this, mTabs, mRemoveSelection, mMenuButton, mClearSelection, mPopupUndo, mSelectionCount, mBlocker, mRecycleView, mNestedScrollView, mEmptyView); mtabViewController = new tabViewController(this, mTabs, mRemoveSelection, mMenuButton, mClearSelection, mPopupUndo, mSelectionCount, mBlocker, mRecycleView, mNestedScrollView, mEmptyView, mNewTab);
} }
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
@ -350,6 +352,7 @@ public class tabController extends Fragment
mListModel.onTrigger(tabEnums.eModelCallback.M_REMOVE_TAB,Collections.singletonList(pIndex)); mListModel.onTrigger(tabEnums.eModelCallback.M_REMOVE_TAB,Collections.singletonList(pIndex));
if(mListModel.getList().size()<1){ if(mListModel.getList().size()<1){
mRecycleView.animate().setDuration(200).alpha(0); mRecycleView.animate().setDuration(200).alpha(0);
onClearSelection(null);
} }
initTabCount(400); initTabCount(400);
activityContextManager.getInstance().getHomeController().onLoadTabFromTabController(); activityContextManager.getInstance().getHomeController().onLoadTabFromTabController();
@ -369,6 +372,7 @@ public class tabController extends Fragment
onShowUndoDialog(); onShowUndoDialog();
} }
mTabAdapter.notifyDataSetChanged(); mTabAdapter.notifyDataSetChanged();
onClearSelection(null);
}); });
activityContextManager.getInstance().getHomeController().onLoadTabFromTabController(); activityContextManager.getInstance().getHomeController().onLoadTabFromTabController();
new Handler().postDelayed(() -> { new Handler().postDelayed(() -> {
@ -485,6 +489,7 @@ public class tabController extends Fragment
mRecycleView.animate().setDuration(200).alpha(0).withEndAction(() -> { mRecycleView.animate().setDuration(200).alpha(0).withEndAction(() -> {
mTabAdapter.onTrigger(tabEnums.eTabAdapterCommands.M_REMOVE_ALL_SELECTION, null); mTabAdapter.onTrigger(tabEnums.eTabAdapterCommands.M_REMOVE_ALL_SELECTION, null);
//onShowUndoDialog(); //onShowUndoDialog();
onClearSelection(null);
}); });
}else { }else {
mTabAdapter.onTrigger(tabEnums.eTabAdapterCommands.M_REMOVE_ALL_SELECTION, null); mTabAdapter.onTrigger(tabEnums.eTabAdapterCommands.M_REMOVE_ALL_SELECTION, null);
@ -525,19 +530,30 @@ public class tabController extends Fragment
public void onMenuTrigger(View pView){ public void onMenuTrigger(View pView){
if(pView.getId() == R.id.pNewTab){ if(pView.getId() == R.id.pNewTab){
onNewTabInvoked(); if(!isSelectionOpened()){
onClearTabBackup();
mListModel.onTrigger(tabEnums.eModelCallback.M_CLEAR_BACKUP_RETAIN_DATABASE,null);
onNewTabInvoked();
mClosedByNewTab = true;
}
mHomeController.onBackPressed(); mHomeController.onBackPressed();
mClosedByNewTab = true;
} }
if(pView.getId() == R.id.pNewTabMenu){ if(pView.getId() == R.id.pNewTabMenu){
onClearTabBackup();
mListModel.onTrigger(tabEnums.eModelCallback.M_CLEAR_BACKUP_RETAIN_DATABASE,null);
onNewTabInvoked(); onNewTabInvoked();
mHomeController.onBackPressed(); mHomeController.onBackPressed();
mClosedByNewTab = true; mClosedByNewTab = true;
} }
else if(pView.getId() == R.id.pCloseTab){ else if(pView.getId() == R.id.pCloseTab){
onExitAndClearBackup(); onClearTabBackup();
mListModel.onTrigger(tabEnums.eModelCallback.M_CLEAR_BACKUP_RETAIN_DATABASE,null);
mRecycleView.animate().setDuration(250).alpha(0).withEndAction(() -> { mRecycleView.animate().setDuration(250).alpha(0).withEndAction(() -> {
mTabAdapter.onTrigger(tabEnums.eTabAdapterCommands.REMOVE_ALL, null); mTabAdapter.onTrigger(tabEnums.eTabAdapterCommands.REMOVE_ALL, null);
onClearSelection(null);
onClearTabBackup();
mListModel.onTrigger(tabEnums.eModelCallback.M_CLEAR_BACKUP_RETAIN_DATABASE,null);
}); });
} }
else if(pView.getId() == R.id.pOpenSetting){ else if(pView.getId() == R.id.pOpenSetting){

View File

@ -52,6 +52,7 @@ class tabViewController
private RecyclerView mRecycleView; private RecyclerView mRecycleView;
private NestedScrollView mNestedScrollView; private NestedScrollView mNestedScrollView;
private TextView mEmptyView; private TextView mEmptyView;
private ImageButton mNewTab;
/*Private Local Variables*/ /*Private Local Variables*/
private Handler mDelayHandler = new Handler(); private Handler mDelayHandler = new Handler();
@ -59,7 +60,7 @@ class tabViewController
/*Initializations*/ /*Initializations*/
tabViewController(Fragment mContext, Button pTabs, ImageView pRemoveSelection, ImageButton pMenuButton, ImageButton pClearSelection, View pToastLayoutRoot, TextView pSelectionCount, ImageView pBlocker, RecyclerView pRecycleView, NestedScrollView pNestedScrollView, TextView pEmptyView) tabViewController(Fragment mContext, Button pTabs, ImageView pRemoveSelection, ImageButton pMenuButton, ImageButton pClearSelection, View pToastLayoutRoot, TextView pSelectionCount, ImageView pBlocker, RecyclerView pRecycleView, NestedScrollView pNestedScrollView, TextView pEmptyView, ImageButton pNewTab)
{ {
this.mContext = mContext; this.mContext = mContext;
this.mTabs = pTabs; this.mTabs = pTabs;
@ -72,6 +73,7 @@ class tabViewController
this.mRecycleView = pRecycleView; this.mRecycleView = pRecycleView;
this.mNestedScrollView = pNestedScrollView; this.mNestedScrollView = pNestedScrollView;
this.mEmptyView = pEmptyView; this.mEmptyView = pEmptyView;
this.mNewTab = pNewTab;
initUI(); initUI();
initPostUI(); initPostUI();
@ -139,6 +141,11 @@ class tabViewController
mMenuButton.setVisibility(View.GONE); mMenuButton.setVisibility(View.GONE);
mSelectionCount.setVisibility(View.VISIBLE); mSelectionCount.setVisibility(View.VISIBLE);
mClearSelection.setVisibility(View.VISIBLE); mClearSelection.setVisibility(View.VISIBLE);
mNewTab.setVisibility(View.GONE);
mNewTab.animate().setDuration(250).alpha(0);
mNewTab.setEnabled(false);
mNewTab.setFocusable(false);
} }
private void onShowSelectionMenu(boolean pStatus, int pCount) { private void onShowSelectionMenu(boolean pStatus, int pCount) {
@ -157,6 +164,11 @@ class tabViewController
mClearSelection.setVisibility(View.GONE); mClearSelection.setVisibility(View.GONE);
mMenuButton.setVisibility(View.VISIBLE); mMenuButton.setVisibility(View.VISIBLE);
mTabs.animate().setStartDelay(0).setDuration(250).alpha(1); mTabs.animate().setStartDelay(0).setDuration(250).alpha(1);
mNewTab.setVisibility(View.VISIBLE);
mNewTab.animate().setDuration(250).alpha(1);
mNewTab.setEnabled(true);
mNewTab.setFocusable(true);
} }
private void onShowUndoDialog(int pTabCount) { private void onShowUndoDialog(int pTabCount) {

View File

@ -83,6 +83,7 @@ public class constants
/*ENCRYPTION KEY*/ /*ENCRYPTION KEY*/
public static final String CONST_ENCRYPTION_KEY = "Zr4u7x!A%D*F-JaNdRgUkXp2s5v8y/B?"; public static final String CONST_ENCRYPTION_KEY = "Zr4u7x!A%D*F-JaNdRgUkXp2s5v8y/B?";
public static final String CONST_ENCRYPTION_KEY_DATABASE = "Zr4u7x!!A%D*F-JaNdsS@@gUbbp^^5v8y/B?";
} }

View File

@ -2,7 +2,6 @@ package com.darkweb.genesissearchengine.databaseManager;
import android.content.ContentValues; import android.content.ContentValues;
import android.database.Cursor; import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.darkweb.genesissearchengine.appManager.activityContextManager; import com.darkweb.genesissearchengine.appManager.activityContextManager;
import com.darkweb.genesissearchengine.appManager.bookmarkManager.bookmarkRowModel; import com.darkweb.genesissearchengine.appManager.bookmarkManager.bookmarkRowModel;
@ -10,12 +9,17 @@ import com.darkweb.genesissearchengine.appManager.historyManager.historyRowModel
import com.darkweb.genesissearchengine.appManager.homeManager.geckoManager.geckoSession; import com.darkweb.genesissearchengine.appManager.homeManager.geckoManager.geckoSession;
import com.darkweb.genesissearchengine.appManager.tabManager.tabRowModel; import com.darkweb.genesissearchengine.appManager.tabManager.tabRowModel;
import com.darkweb.genesissearchengine.constants.constants; import com.darkweb.genesissearchengine.constants.constants;
import net.sqlcipher.database.SQLiteDatabaseHook;
import net.sqlcipher.database.SQLiteDatabase;
import java.io.File;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.Locale; import java.util.Locale;
import static android.content.Context.MODE_PRIVATE;
import static com.darkweb.genesissearchengine.constants.constants.CONST_DATABASE_NAME;
public class databaseController public class databaseController
{ {
@ -23,7 +27,7 @@ public class databaseController
/*Private Variables*/ /*Private Variables*/
private static final databaseController sOurInstance = new databaseController(); private static final databaseController sOurInstance = new databaseController();
private SQLiteDatabase mDatabaseInstance; private static SQLiteDatabase mDatabaseInstance;
public static databaseController getInstance() public static databaseController getInstance()
{ {
@ -36,11 +40,21 @@ public class databaseController
/*Initializations*/ /*Initializations*/
public void prepareDatabaseEnvironment(AppCompatActivity app_context) {
File databaseFile = app_context.getDatabasePath(CONST_DATABASE_NAME);
if (!databaseFile.exists()) {
databaseFile.getParentFile().mkdirs();
}
}
public void initialize(AppCompatActivity app_context) public void initialize(AppCompatActivity app_context)
{ {
try try
{ {
mDatabaseInstance = app_context.openOrCreateDatabase(constants.CONST_DATABASE_NAME, MODE_PRIVATE, null); SQLiteDatabase.loadLibs(app_context);
prepareDatabaseEnvironment(app_context);
mDatabaseInstance = mDatabaseInstance.openOrCreateDatabase(app_context.getDatabasePath(CONST_DATABASE_NAME), constants.CONST_ENCRYPTION_KEY_DATABASE,null, wrapHook(null));
mDatabaseInstance.execSQL("CREATE TABLE IF NOT EXISTS " + "history" + " (id INT(4) PRIMARY KEY,date DATETIME,url VARCHAR,title VARCHAR);"); mDatabaseInstance.execSQL("CREATE TABLE IF NOT EXISTS " + "history" + " (id INT(4) PRIMARY KEY,date DATETIME,url VARCHAR,title VARCHAR);");
mDatabaseInstance.execSQL("CREATE TABLE IF NOT EXISTS " + "bookmark" + " (id INT(4) PRIMARY KEY,title VARCHAR,url VARCHAR);"); mDatabaseInstance.execSQL("CREATE TABLE IF NOT EXISTS " + "bookmark" + " (id INT(4) PRIMARY KEY,title VARCHAR,url VARCHAR);");
@ -56,6 +70,37 @@ public class databaseController
/*Helper Methods*/ /*Helper Methods*/
public SQLiteDatabaseHook wrapHook(final SQLiteDatabaseHook hook) {
if (hook == null)
{
return keyHook;
}
return new SQLiteDatabaseHook() {
@Override
public void preKey(net.sqlcipher.database.SQLiteDatabase sqLiteDatabase) {
keyHook.preKey(sqLiteDatabase);
hook.preKey(sqLiteDatabase);
}
@Override
public void postKey(net.sqlcipher.database.SQLiteDatabase sqLiteDatabase) {
keyHook.postKey(sqLiteDatabase);
hook.preKey(sqLiteDatabase);
}
};
}
SQLiteDatabaseHook keyHook = new SQLiteDatabaseHook() {
@Override
public void preKey(net.sqlcipher.database.SQLiteDatabase sqLiteDatabase) {
}
@Override
public void postKey(net.sqlcipher.database.SQLiteDatabase sqLiteDatabase) {
}
};
public void execSQL(String query,String[] params) public void execSQL(String query,String[] params)
{ {

View File

@ -122,7 +122,7 @@ public class localFileDownloader extends AsyncTask<String, Integer, String> {
try { try {
URL url = new URL(f_url[0]); URL url = new URL(f_url[0]);
Proxy proxy = new Proxy(Proxy.Type.SOCKS, InetSocketAddress.createUnresolved(PROXY_ADDRESS, PROXY_PORT)); Proxy proxy = new Proxy(Proxy.Type.SOCKS, InetSocketAddress.createUnresolved(PROXY_ADDRESS, PROXY_PORT));
URLConnection conection= null; URLConnection conection;
conection = url.openConnection(proxy); conection = url.openConnection(proxy);
//conection = (HttpsURLConnection)ProxySelector.openConnectionWithProxy(new URI(f_url[0])); //conection = (HttpsURLConnection)ProxySelector.openConnectionWithProxy(new URI(f_url[0]));