2020-01-24 16:23:31 +01:00
|
|
|
package com.darkweb.genesissearchengine.pluginManager;
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
2020-10-20 16:55:08 +02:00
|
|
|
import android.app.Dialog;
|
|
|
|
import android.content.Context;
|
2020-01-24 16:23:31 +01:00
|
|
|
import android.content.Intent;
|
2020-12-01 23:10:05 +01:00
|
|
|
import android.content.res.Resources;
|
2020-12-11 08:05:08 +01:00
|
|
|
import android.graphics.Color;
|
2020-10-20 16:55:08 +02:00
|
|
|
import android.graphics.drawable.ColorDrawable;
|
2020-12-01 23:10:05 +01:00
|
|
|
import android.graphics.drawable.Drawable;
|
2020-12-11 08:05:08 +01:00
|
|
|
import android.graphics.drawable.InsetDrawable;
|
2020-01-24 16:23:31 +01:00
|
|
|
import android.net.Uri;
|
|
|
|
import android.os.Handler;
|
|
|
|
import android.view.Gravity;
|
2021-01-18 11:07:12 +01:00
|
|
|
import android.view.Window;
|
2020-10-20 16:55:08 +02:00
|
|
|
import android.view.inputmethod.InputMethodManager;
|
2020-01-24 16:23:31 +01:00
|
|
|
import android.widget.EditText;
|
2020-10-20 16:55:08 +02:00
|
|
|
import android.widget.RatingBar;
|
|
|
|
import android.widget.TextView;
|
2020-01-24 16:23:31 +01:00
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
2021-01-18 11:07:12 +01:00
|
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
|
|
|
2020-10-20 16:55:08 +02:00
|
|
|
import com.darkweb.genesissearchengine.appManager.activityContextManager;
|
2020-01-24 16:23:31 +01:00
|
|
|
import com.darkweb.genesissearchengine.constants.constants;
|
|
|
|
import com.darkweb.genesissearchengine.constants.enums;
|
|
|
|
import com.darkweb.genesissearchengine.constants.status;
|
|
|
|
import com.darkweb.genesissearchengine.constants.strings;
|
|
|
|
import com.darkweb.genesissearchengine.helperManager.eventObserver;
|
|
|
|
import com.darkweb.genesissearchengine.helperManager.helperMethod;
|
|
|
|
import com.example.myapplication.R;
|
2021-01-18 11:07:12 +01:00
|
|
|
import com.google.android.material.switchmaterial.SwitchMaterial;
|
|
|
|
|
2020-01-24 16:23:31 +01:00
|
|
|
import java.io.File;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
class messageManager
|
|
|
|
{
|
|
|
|
/*Private Variables*/
|
|
|
|
|
2020-11-27 12:40:46 +01:00
|
|
|
private List<Object> data;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2020-12-01 23:10:05 +01:00
|
|
|
private AppCompatActivity mContext;
|
2020-01-24 16:23:31 +01:00
|
|
|
private eventObserver.eventListener event;
|
2020-10-20 16:55:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
Dialog dialog = null;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
|
|
|
/*Initializations*/
|
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
private void initializeDialog(int pLayout, int pGravity){
|
2020-11-27 12:40:46 +01:00
|
|
|
if(dialog!=null && dialog.isShowing()){
|
|
|
|
dialog.dismiss();
|
|
|
|
}
|
|
|
|
|
2020-12-01 23:10:05 +01:00
|
|
|
dialog = new Dialog(mContext);
|
2020-11-27 12:40:46 +01:00
|
|
|
dialog.getWindow().setGravity(pGravity);
|
|
|
|
dialog.getWindow().getAttributes().windowAnimations = R.style.dialiog_animation;
|
2020-12-01 23:10:05 +01:00
|
|
|
|
|
|
|
Drawable myDrawable;
|
|
|
|
Resources res = mContext.getResources();
|
|
|
|
try {
|
|
|
|
myDrawable = Drawable.createFromXml(res, res.getXml(R.xml.hox_rounded_corner));
|
|
|
|
dialog.getWindow().setBackgroundDrawable(myDrawable);
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
}
|
|
|
|
|
2020-11-27 12:40:46 +01:00
|
|
|
dialog.setCancelable(true);
|
|
|
|
dialog.setContentView(pLayout);
|
|
|
|
dialog.show();
|
|
|
|
}
|
|
|
|
|
2020-01-24 16:23:31 +01:00
|
|
|
messageManager(eventObserver.eventListener event)
|
|
|
|
{
|
|
|
|
this.event = event;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Helper Methods*/
|
|
|
|
private void welcomeMessage()
|
|
|
|
{
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_welcome, Gravity.CENTER);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.findViewById(R.id.pOption1).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(constants.CONST_BLACK_MARKET_URL), enums.eMessageEnums.M_WELCOME);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
dialog.findViewById(R.id.pOption2).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(constants.CONST_LEAKED_DOCUMENT_URL), enums.eMessageEnums.M_WELCOME);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
dialog.findViewById(R.id.pOption3).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(constants.CONST_NEWS_URL), enums.eMessageEnums.M_WELCOME);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
dialog.findViewById(R.id.pOption4).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(constants.CONST_SOFTWARE_URL), enums.eMessageEnums.M_WELCOME);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
2020-10-22 10:36:44 +02:00
|
|
|
dialog.findViewById(R.id.pOption5).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(constants.CONST_SOFTWARE_FINANCE), enums.eMessageEnums.M_WELCOME);
|
2020-10-22 10:36:44 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.findViewById(R.id.pOption6).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(constants.CONST_COMMUNITIES), enums.eMessageEnums.M_WELCOME);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
2020-10-22 10:36:44 +02:00
|
|
|
dialog.findViewById(R.id.pDontShowAgain).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(null, enums.eMessageEnums.M_CANCEL_WELCOME);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
2020-11-11 13:11:13 +01:00
|
|
|
@SuppressLint("QueryPermissionsNeeded")
|
2020-01-24 16:23:31 +01:00
|
|
|
private void abiError()
|
|
|
|
{
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_abi_error, Gravity.CENTER);
|
2020-11-11 13:11:13 +01:00
|
|
|
dialog.findViewById(R.id.pOption1).setOnClickListener(v -> {
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(constants.CONST_GENESIS_UPDATE_URL + status.sAppCurrentABI));
|
2020-12-01 23:10:05 +01:00
|
|
|
if(browserIntent.resolveActivity(mContext.getPackageManager()) != null)
|
2020-10-20 16:55:08 +02:00
|
|
|
{
|
2020-12-01 23:10:05 +01:00
|
|
|
mContext.startActivity(browserIntent);
|
2020-10-20 16:55:08 +02:00
|
|
|
}else {
|
2020-12-01 23:10:05 +01:00
|
|
|
helperMethod.showToastMessage("Not Supported", mContext);
|
2020-10-20 16:55:08 +02:00
|
|
|
}
|
|
|
|
});
|
2020-12-11 08:05:08 +01:00
|
|
|
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.findViewById(R.id.pOption2).setOnClickListener(v -> {
|
|
|
|
dialog.dismiss();
|
|
|
|
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(constants.CONST_PLAYSTORE_URL));
|
2020-12-01 23:10:05 +01:00
|
|
|
if(browserIntent.resolveActivity(mContext.getPackageManager()) != null)
|
2020-10-20 16:55:08 +02:00
|
|
|
{
|
2020-12-01 23:10:05 +01:00
|
|
|
mContext.startActivity(browserIntent);
|
2020-10-20 16:55:08 +02:00
|
|
|
}else {
|
2020-12-01 23:10:05 +01:00
|
|
|
helperMethod.showToastMessage("Playstore Not Found", mContext);
|
2020-10-20 16:55:08 +02:00
|
|
|
}
|
|
|
|
});
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
2020-10-20 16:55:08 +02:00
|
|
|
private void rateFailure()
|
2020-01-24 16:23:31 +01:00
|
|
|
{
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_rate_failure, Gravity.CENTER);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.findViewById(R.id.pDismiss).setOnClickListener(v -> dialog.dismiss());
|
|
|
|
dialog.findViewById(R.id.pNext).setOnClickListener(v -> {
|
|
|
|
dialog.dismiss();
|
|
|
|
final Handler handler = new Handler();
|
|
|
|
Runnable runnable = () -> {
|
|
|
|
try{
|
2021-01-18 11:07:12 +01:00
|
|
|
helperMethod.sendIssueEmail(mContext);
|
2020-10-20 16:55:08 +02:00
|
|
|
}
|
|
|
|
catch (Exception ex){
|
2020-12-11 08:05:08 +01:00
|
|
|
createMessage(mContext,Collections.singletonList(mContext.getString(R.string.ALERT_NOT_SUPPORTED_MESSAGE)),enums.eMessageEnums.M_NOT_SUPPORTED);
|
2020-10-20 16:55:08 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
handler.postDelayed(runnable, 1000);
|
|
|
|
});
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void reportedSuccessfully()
|
|
|
|
{
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_reported_successfully, Gravity.CENTER);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.findViewById(R.id.pNext).setOnClickListener(v -> dialog.dismiss());
|
2020-02-28 19:10:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void notSupportMessage()
|
|
|
|
{
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_not_supported, Gravity.BOTTOM);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.findViewById(R.id.pDismiss).setOnClickListener(v -> dialog.dismiss());
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
2020-11-11 13:11:13 +01:00
|
|
|
private void dataClearedSuccessfully()
|
|
|
|
{
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_data_cleared, Gravity.BOTTOM);
|
|
|
|
|
|
|
|
ColorDrawable back = new ColorDrawable(Color.TRANSPARENT);
|
|
|
|
InsetDrawable inset = new InsetDrawable(back, 0,0,0,helperMethod.pxFromDp(25));
|
|
|
|
dialog.getWindow().setBackgroundDrawable(inset);
|
|
|
|
dialog.findViewById(R.id.pNext).setOnClickListener(v -> dialog.dismiss());
|
2021-01-18 11:07:12 +01:00
|
|
|
dialog.findViewById(R.id.pDismiss).setOnClickListener(v -> dialog.dismiss());
|
2020-11-11 13:11:13 +01:00
|
|
|
}
|
|
|
|
|
2020-11-27 12:40:46 +01:00
|
|
|
|
2021-01-18 11:07:12 +01:00
|
|
|
private void openSecureConnectionPopup()
|
|
|
|
{
|
|
|
|
initializeDialog(R.layout.secure_connection_popup, Gravity.TOP);
|
|
|
|
Window window = dialog.getWindow();
|
|
|
|
window.setLayout(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.WRAP_CONTENT);
|
|
|
|
|
|
|
|
ColorDrawable back = new ColorDrawable(Color.TRANSPARENT);
|
|
|
|
InsetDrawable inset = new InsetDrawable(back, 0,0,0,0);
|
|
|
|
dialog.getWindow().setBackgroundDrawable(inset);
|
|
|
|
dialog.setCancelable(true);
|
|
|
|
dialog.setCanceledOnTouchOutside(true);
|
|
|
|
dialog.findViewById(R.id.pDismiss).setOnClickListener(v -> dialog.dismiss());
|
|
|
|
dialog.findViewById(R.id.pNext).setOnClickListener(v -> { event.invokeObserver(null, enums.eMessageEnums.M_SECURE_CONNECTION); });
|
|
|
|
|
|
|
|
String mJavascript = "| Disabled";
|
|
|
|
String mDoNotTrack = "| Disabled";
|
|
|
|
String mTrackingProtection = "| Disabled";
|
|
|
|
|
|
|
|
if((boolean)data.get(1)){
|
|
|
|
((SwitchMaterial)dialog.findViewById(R.id.pJSStatus)).setChecked(true);
|
|
|
|
}else {
|
|
|
|
((SwitchMaterial)dialog.findViewById(R.id.pJSStatus)).setChecked(false);
|
|
|
|
}
|
|
|
|
if((boolean)data.get(2)){
|
|
|
|
((SwitchMaterial)dialog.findViewById(R.id.pDTStatus)).setChecked(true);
|
|
|
|
}else {
|
|
|
|
((SwitchMaterial)dialog.findViewById(R.id.pDTStatus)).setChecked(false);
|
|
|
|
}
|
|
|
|
if((boolean)data.get(3)){
|
|
|
|
((SwitchMaterial)dialog.findViewById(R.id.pTPStatus)).setChecked(true);
|
|
|
|
}else {
|
|
|
|
((SwitchMaterial)dialog.findViewById(R.id.pTPStatus)).setChecked(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
((TextView)dialog.findViewById(R.id.pHeaderSubpart)).setText(helperMethod.getDomainName(data.get(0).toString()));
|
|
|
|
//((TextView)dialog.findViewById(R.id.pJSStatus)).setText(mJavascript);
|
|
|
|
//((TextView)dialog.findViewById(R.id.pDTStatus)).setText(mDoNotTrack);
|
|
|
|
//((TextView)dialog.findViewById(R.id.pTPStatus)).setText(mTrackingProtection);
|
|
|
|
}
|
|
|
|
|
2020-01-24 16:23:31 +01:00
|
|
|
@SuppressLint("ResourceType")
|
|
|
|
private void bookmark()
|
|
|
|
{
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_create_bookmark, Gravity.CENTER);
|
2020-10-20 16:55:08 +02:00
|
|
|
EditText mBoomMarkTitle = dialog.findViewById(R.id.pBookmark);
|
|
|
|
dialog.setOnDismissListener(dialog -> {
|
|
|
|
final Handler handler = new Handler();
|
|
|
|
Runnable runnable = () -> {
|
|
|
|
helperMethod.hideKeyboard(activityContextManager.getInstance().getHomeController());
|
|
|
|
dialog.dismiss();
|
|
|
|
};
|
|
|
|
handler.postDelayed(runnable, 50);
|
|
|
|
});
|
|
|
|
dialog.findViewById(R.id.pDismiss).setOnClickListener(v -> {
|
|
|
|
dialog.dismiss();
|
|
|
|
helperMethod.hideKeyboard(activityContextManager.getInstance().getHomeController());
|
|
|
|
});
|
|
|
|
|
|
|
|
mBoomMarkTitle.requestFocus();
|
2020-12-01 23:10:05 +01:00
|
|
|
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
|
2020-10-20 16:55:08 +02:00
|
|
|
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
|
|
|
|
|
|
|
|
dialog.findViewById(R.id.pNext).setOnClickListener(v -> {
|
|
|
|
dialog.dismiss();
|
2020-12-01 23:10:05 +01:00
|
|
|
helperMethod.hideKeyboard(mContext);
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(data.get(0).toString().replace("genesis.onion","boogle.store")+"split"+((EditText)dialog.findViewById(R.id.pBookmark)).getText().toString()), enums.eMessageEnums.M_BOOKMARK);
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
2020-10-20 16:55:08 +02:00
|
|
|
private void clearHistory()
|
2020-01-24 16:23:31 +01:00
|
|
|
{
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_clear_history, Gravity.CENTER);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.findViewById(R.id.pDismiss).setOnClickListener(v -> dialog.dismiss());
|
|
|
|
dialog.findViewById(R.id.pNext).setOnClickListener(v -> {
|
|
|
|
dialog.dismiss();
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(null, enums.eMessageEnums.M_CLEAR_HISTORY);
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void clearBookmark()
|
|
|
|
{
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_clear_bookmark, Gravity.CENTER);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.findViewById(R.id.pDismiss).setOnClickListener(v -> dialog.dismiss());
|
|
|
|
dialog.findViewById(R.id.pNext).setOnClickListener(v -> {
|
|
|
|
dialog.dismiss();
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(null, enums.eMessageEnums.M_CLEAR_BOOKMARK);
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void reportURL()
|
|
|
|
{
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_report_url, Gravity.CENTER);
|
2021-01-18 11:07:12 +01:00
|
|
|
((TextView)dialog.findViewById(R.id.pHeader)).setText(data.get(0).toString());
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.findViewById(R.id.pDismiss).setOnClickListener(v -> dialog.dismiss());
|
|
|
|
dialog.findViewById(R.id.pNext).setOnClickListener(v -> {
|
|
|
|
dialog.dismiss();
|
|
|
|
final Handler handler = new Handler();
|
2020-12-11 08:05:08 +01:00
|
|
|
Runnable runnable = () -> createMessage(mContext,Collections.singletonList(strings.GENERIC_EMPTY_STR), enums.eMessageEnums.M_RATE_SUCCESS);
|
2020-10-20 16:55:08 +02:00
|
|
|
handler.postDelayed(runnable, 1000);
|
|
|
|
});
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
2020-11-11 13:11:13 +01:00
|
|
|
@SuppressLint("QueryPermissionsNeeded")
|
2020-01-24 16:23:31 +01:00
|
|
|
private void rateApp()
|
|
|
|
{
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_rate_us, Gravity.CENTER);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.findViewById(R.id.pDismiss).setOnClickListener(v -> dialog.dismiss());
|
|
|
|
dialog.findViewById(R.id.pNext).setOnClickListener(v -> {
|
|
|
|
RatingBar mRatingBar = dialog.findViewById(R.id.pRating);
|
|
|
|
if(mRatingBar.getRating()>=3){
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(null, enums.eMessageEnums.M_APP_RATED);
|
2020-10-20 16:55:08 +02:00
|
|
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.darkweb.genesissearchengine"));
|
2020-12-01 23:10:05 +01:00
|
|
|
if(intent.resolveActivity(mContext.getPackageManager()) != null)
|
2020-10-20 16:55:08 +02:00
|
|
|
{
|
2020-12-01 23:10:05 +01:00
|
|
|
mContext.startActivity(intent);
|
2020-10-20 16:55:08 +02:00
|
|
|
}else {
|
2020-12-01 23:10:05 +01:00
|
|
|
helperMethod.showToastMessage("Playstore Not Found", mContext);
|
2020-10-20 16:55:08 +02:00
|
|
|
}
|
|
|
|
dialog.dismiss();
|
|
|
|
}else if(mRatingBar.getRating()>0) {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(null, enums.eMessageEnums.M_APP_RATED);
|
2020-10-20 16:55:08 +02:00
|
|
|
final Handler handler = new Handler();
|
2020-12-11 08:05:08 +01:00
|
|
|
handler.postDelayed(() -> createMessage(mContext,Collections.singletonList(strings.GENERIC_EMPTY_STR), enums.eMessageEnums.M_RATE_FAILURE), 1000);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
}
|
|
|
|
});
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void downloadFile()
|
|
|
|
{
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_download_file, Gravity.BOTTOM);
|
2020-12-01 23:10:05 +01:00
|
|
|
((TextView)dialog.findViewById(R.id.pDescription)).setText((mContext.getString(R.string.ALERT_DOWNLOAD_MESSAGE) + data.get(0)));
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.findViewById(R.id.pDismiss).setOnClickListener(v -> dialog.dismiss());
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressLint("ResourceAsColor")
|
|
|
|
private void downloadFileLongPress()
|
|
|
|
{
|
2020-11-27 12:40:46 +01:00
|
|
|
File f = new File(data.get(0).toString());
|
2020-01-24 16:23:31 +01:00
|
|
|
String name = f.getName();
|
2020-11-27 12:40:46 +01:00
|
|
|
String title = data.get(1).toString();
|
2020-01-24 16:23:31 +01:00
|
|
|
|
|
|
|
int size = name.length();
|
2020-11-11 13:11:13 +01:00
|
|
|
if(size>235){
|
|
|
|
size = 235;
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_file_longpress, Gravity.CENTER);
|
2020-11-27 12:40:46 +01:00
|
|
|
((TextView)dialog.findViewById(R.id.pDescription)).setText((title + " | " + data.get(0).toString().substring(0,size)+"..."));
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.findViewById(R.id.pDismiss).setOnClickListener(v -> dialog.dismiss());
|
|
|
|
dialog.findViewById(R.id.pOption1).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(data.get(0)), enums.eMessageEnums.M_DOWNLOAD_FILE_MANUAL);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
dialog.findViewById(R.id.pOption2).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(data.get(0)), enums.eMessageEnums.M_OPEN_LINK_CURRENT_TAB);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
dialog.findViewById(R.id.pOption3).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(data.get(0)), enums.eMessageEnums.M_COPY_LINK);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
dialog.findViewById(R.id.pOption3).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(data.get(0)), enums.eMessageEnums.M_COPY_LINK);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void openURLLongPress()
|
|
|
|
{
|
2020-11-27 12:40:46 +01:00
|
|
|
int size = data.get(0).toString().length()-1;
|
|
|
|
String title = data.get(1).toString();
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2020-11-11 13:11:13 +01:00
|
|
|
if(size>235){
|
|
|
|
size = 235;
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_url_longpress, Gravity.CENTER);
|
2020-11-27 12:40:46 +01:00
|
|
|
((TextView)dialog.findViewById(R.id.pDescription)).setText((title + data.get(0).toString().substring(0,size)+"..."));
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.findViewById(R.id.pDismiss).setOnClickListener(v -> dialog.dismiss());
|
|
|
|
dialog.findViewById(R.id.pOption1).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(data.get(0)), enums.eMessageEnums.M_OPEN_LINK_NEW_TAB);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
dialog.findViewById(R.id.pOption2).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(data.get(0)), enums.eMessageEnums.M_OPEN_LINK_CURRENT_TAB);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
dialog.findViewById(R.id.pOption3).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(data.get(0)), enums.eMessageEnums.M_COPY_LINK);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
2020-02-28 19:10:00 +01:00
|
|
|
}
|
|
|
|
|
2020-01-24 16:23:31 +01:00
|
|
|
private void popupDownloadFull(){
|
2020-11-27 12:40:46 +01:00
|
|
|
String url = data.get(0).toString();
|
|
|
|
String file = data.get(1).toString();
|
|
|
|
String title = data.get(2).toString();
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2020-12-01 23:10:05 +01:00
|
|
|
String data_local = mContext.getString(R.string.ALERT_LONG_URL_MESSAGE);
|
2020-01-24 16:23:31 +01:00
|
|
|
|
|
|
|
int size = url.length();
|
2020-11-11 13:11:13 +01:00
|
|
|
if(size>235){
|
|
|
|
size = 235;
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int size1 = file.length();
|
2020-11-11 13:11:13 +01:00
|
|
|
if(size1>235){
|
|
|
|
size1 = 235;
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!url.equals("")){
|
|
|
|
data_local = title + url.substring(0,size)+"...";
|
|
|
|
}
|
|
|
|
else if(!file.equals("")){
|
2020-11-11 13:11:13 +01:00
|
|
|
data_local = file.substring(0,size1)+"...";
|
|
|
|
}
|
|
|
|
String mTitle = title;
|
|
|
|
if(mTitle.length()<=1){
|
2020-11-27 12:40:46 +01:00
|
|
|
mTitle = data.get(0).toString().substring(0,size)+"...";
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_download_full, Gravity.CENTER);
|
2020-11-11 13:11:13 +01:00
|
|
|
((TextView)dialog.findViewById(R.id.pHeader)).setText(mTitle);
|
2020-10-20 16:55:08 +02:00
|
|
|
((TextView)dialog.findViewById(R.id.pDescription)).setText((data_local));
|
|
|
|
dialog.findViewById(R.id.pDismiss).setOnClickListener(v -> dialog.dismiss());
|
|
|
|
dialog.findViewById(R.id.pOption1).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(data.get(0)), enums.eMessageEnums.M_OPEN_LINK_NEW_TAB);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
dialog.findViewById(R.id.pOption2).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(data.get(0)), enums.eMessageEnums.M_OPEN_LINK_CURRENT_TAB);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
dialog.findViewById(R.id.pOption3).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(data.get(0)), enums.eMessageEnums.M_COPY_LINK);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
dialog.findViewById(R.id.pOption3).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(data.get(0)), enums.eMessageEnums.M_COPY_LINK);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
dialog.findViewById(R.id.pOption3).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(data.get(0)), enums.eMessageEnums.M_COPY_LINK);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
dialog.findViewById(R.id.pOption3).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(data.get(0)), enums.eMessageEnums.M_COPY_LINK);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
|
|
|
dialog.findViewById(R.id.pOption3).setOnClickListener(v -> {
|
2020-12-11 08:05:08 +01:00
|
|
|
event.invokeObserver(Collections.singletonList(data.get(0)), enums.eMessageEnums.M_COPY_LINK);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.dismiss();
|
|
|
|
});
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void startingOrbotInfo()
|
|
|
|
{
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_starting_orbot_info, Gravity.BOTTOM);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.findViewById(R.id.pDismiss).setOnClickListener(v -> dialog.dismiss());
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
2020-02-28 19:10:00 +01:00
|
|
|
private void sendBridgeMail()
|
|
|
|
{
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_bridge_mail, Gravity.CENTER);
|
2020-10-20 16:55:08 +02:00
|
|
|
dialog.findViewById(R.id.pDismiss).setOnClickListener(v -> dialog.dismiss());
|
|
|
|
dialog.findViewById(R.id.pNext).setOnClickListener(v -> {
|
|
|
|
dialog.dismiss();
|
|
|
|
final Handler handler = new Handler();
|
|
|
|
Runnable runnable = () -> {
|
|
|
|
try{
|
2020-12-01 23:10:05 +01:00
|
|
|
helperMethod.sendBridgeEmail(mContext);
|
2020-10-20 16:55:08 +02:00
|
|
|
}
|
|
|
|
catch (Exception ex){
|
2020-12-11 08:05:08 +01:00
|
|
|
createMessage(mContext,Collections.singletonList(mContext.getString(R.string.ALERT_NOT_SUPPORTED_MESSAGE)),enums.eMessageEnums.M_NOT_SUPPORTED);
|
2020-10-20 16:55:08 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
handler.postDelayed(runnable, 1000);
|
|
|
|
});
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void onReset(){
|
2020-10-20 16:55:08 +02:00
|
|
|
if(dialog!=null){
|
|
|
|
dialog.dismiss();
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*External Helper Methods*/
|
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
void createMessage(AppCompatActivity app_context, List<Object> data, enums.eMessageEnums type)
|
2020-01-24 16:23:31 +01:00
|
|
|
{
|
2020-12-01 23:10:05 +01:00
|
|
|
this.mContext = app_context;
|
2020-01-24 16:23:31 +01:00
|
|
|
this.data = data;
|
|
|
|
|
2020-10-20 16:55:08 +02:00
|
|
|
switch (type)
|
|
|
|
{
|
2020-12-11 08:05:08 +01:00
|
|
|
case M_WELCOME:
|
2020-10-20 16:55:08 +02:00
|
|
|
welcomeMessage();
|
|
|
|
break;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
case M_ABI_ERROR:
|
2020-10-20 16:55:08 +02:00
|
|
|
abiError();
|
|
|
|
break;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
case M_RATE_FAILURE:
|
2020-10-20 16:55:08 +02:00
|
|
|
rateFailure();
|
|
|
|
break;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
case M_RATE_SUCCESS:
|
2020-10-20 16:55:08 +02:00
|
|
|
reportedSuccessfully();
|
|
|
|
break;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
case M_BOOKMARK:
|
2020-10-20 16:55:08 +02:00
|
|
|
bookmark();
|
|
|
|
break;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
case M_CLEAR_HISTORY:
|
2020-10-20 16:55:08 +02:00
|
|
|
clearHistory();
|
|
|
|
break;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
case M_CLEAR_BOOKMARK:
|
2020-10-20 16:55:08 +02:00
|
|
|
clearBookmark();
|
|
|
|
break;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
case M_REPORT_URL:
|
2020-10-20 16:55:08 +02:00
|
|
|
reportURL();
|
|
|
|
break;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
case M_RATE_APP:
|
2020-10-20 16:55:08 +02:00
|
|
|
rateApp();
|
|
|
|
break;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
case M_DOWNLOAD_FILE:
|
2020-10-20 16:55:08 +02:00
|
|
|
downloadFile();
|
|
|
|
break;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
case M_START_ORBOT:
|
2020-10-20 16:55:08 +02:00
|
|
|
startingOrbotInfo();
|
|
|
|
break;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
case M_LONG_PRESS_DOWNLOAD:
|
2020-10-20 16:55:08 +02:00
|
|
|
downloadFileLongPress();
|
|
|
|
break;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
case M_LONG_PRESS_URL:
|
2020-10-20 16:55:08 +02:00
|
|
|
openURLLongPress();
|
|
|
|
break;
|
2020-02-28 19:10:00 +01:00
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
case M_LONG_PRESS_WITH_LINK:
|
2020-10-20 16:55:08 +02:00
|
|
|
popupDownloadFull();
|
2020-11-11 13:11:13 +01:00
|
|
|
break;
|
2020-02-28 19:10:00 +01:00
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
case M_BRIDGE_MAIL:
|
2020-10-20 16:55:08 +02:00
|
|
|
sendBridgeMail();
|
|
|
|
break;
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
case M_NOT_SUPPORTED:
|
2020-10-20 16:55:08 +02:00
|
|
|
notSupportMessage();
|
|
|
|
break;
|
2020-11-11 13:11:13 +01:00
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
case M_DATA_CLEARED:
|
2020-11-11 13:11:13 +01:00
|
|
|
dataClearedSuccessfully();
|
|
|
|
break;
|
2021-01-18 11:07:12 +01:00
|
|
|
|
|
|
|
case M_SECURE_CONNECTION:
|
|
|
|
openSecureConnectionPopup();
|
|
|
|
break;
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|