2020-01-24 16:23:31 +01:00
|
|
|
package com.darkweb.genesissearchengine.pluginManager;
|
|
|
|
|
2020-10-20 16:55:08 +02:00
|
|
|
import android.app.Dialog;
|
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;
|
2021-01-28 11:22:41 +01:00
|
|
|
import android.view.WindowManager;
|
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;
|
2021-02-03 11:54:19 +01:00
|
|
|
import com.darkweb.genesissearchengine.constants.status;
|
2020-01-24 16:23:31 +01:00
|
|
|
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;
|
|
|
|
|
2021-02-03 11:54:19 +01:00
|
|
|
import org.mozilla.geckoview.ContentBlocking;
|
|
|
|
|
2021-01-28 11:22:41 +01:00
|
|
|
import java.util.Arrays;
|
2020-01-24 16:23:31 +01:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
|
2021-01-28 11:22:41 +01:00
|
|
|
import static com.darkweb.genesissearchengine.constants.constants.*;
|
|
|
|
import static com.darkweb.genesissearchengine.constants.strings.MESSAGE_PLAYSTORE_NOT_FOUND;
|
|
|
|
import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManager.*;
|
|
|
|
import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManagerCallbacks.*;
|
|
|
|
|
2020-01-24 16:23:31 +01:00
|
|
|
class messageManager
|
|
|
|
{
|
|
|
|
/*Private Variables*/
|
|
|
|
|
2021-01-28 11:22:41 +01:00
|
|
|
private List<Object> mData;
|
2020-12-01 23:10:05 +01:00
|
|
|
private AppCompatActivity mContext;
|
2021-01-28 11:22:41 +01:00
|
|
|
private eventObserver.eventListener mEvent;
|
|
|
|
private Dialog mDialog = 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){
|
2021-01-28 11:22:41 +01:00
|
|
|
if(mDialog !=null && mDialog.isShowing()){
|
|
|
|
mDialog.dismiss();
|
2020-11-27 12:40:46 +01:00
|
|
|
}
|
|
|
|
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog = new Dialog(mContext);
|
|
|
|
mDialog.getWindow().setGravity(pGravity);
|
|
|
|
mDialog.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));
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.getWindow().setBackgroundDrawable(myDrawable);
|
2020-12-01 23:10:05 +01:00
|
|
|
} catch (Exception ignored) {
|
|
|
|
}
|
|
|
|
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.setCancelable(true);
|
|
|
|
mDialog.setContentView(pLayout);
|
|
|
|
|
|
|
|
ColorDrawable back = new ColorDrawable(Color.TRANSPARENT);
|
|
|
|
InsetDrawable inset = new InsetDrawable(back, helperMethod.pxFromDp(15),0,helperMethod.pxFromDp(15),0);
|
|
|
|
mDialog.getWindow().setBackgroundDrawable(inset);
|
|
|
|
mDialog.getWindow().setLayout(helperMethod.pxFromDp(350), -1);
|
|
|
|
mDialog.getWindow().setLayout(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.WRAP_CONTENT);
|
|
|
|
mDialog.show();
|
2020-11-27 12:40:46 +01:00
|
|
|
}
|
|
|
|
|
2020-01-24 16:23:31 +01:00
|
|
|
messageManager(eventObserver.eventListener event)
|
|
|
|
{
|
2021-01-28 11:22:41 +01:00
|
|
|
this.mEvent = event;
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*Helper Methods*/
|
|
|
|
private void welcomeMessage()
|
|
|
|
{
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_welcome, Gravity.CENTER);
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pOption1).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(constants.CONST_BLACK_MARKET_URL), M_OPEN_LINK_CURRENT_TAB);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pOption2).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(constants.CONST_LEAKED_DOCUMENT_URL), M_OPEN_LINK_CURRENT_TAB);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pOption3).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(constants.CONST_NEWS_URL), M_OPEN_LINK_CURRENT_TAB);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pOption4).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(constants.CONST_SOFTWARE_URL), M_OPEN_LINK_CURRENT_TAB);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pOption5).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(constants.CONST_SOFTWARE_FINANCE), M_OPEN_LINK_CURRENT_TAB);
|
|
|
|
mDialog.dismiss();
|
2020-10-22 10:36:44 +02:00
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pOption6).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(constants.CONST_COMMUNITIES), M_OPEN_LINK_CURRENT_TAB);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pDontShowAgain).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(null, M_CANCEL_WELCOME);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
2021-01-28 11:22:41 +01:00
|
|
|
private void languageSupportFailure()
|
2020-01-24 16:23:31 +01:00
|
|
|
{
|
2021-01-28 11:22:41 +01:00
|
|
|
initializeDialog(R.layout.popup_language_support, Gravity.CENTER);
|
|
|
|
((TextView) mDialog.findViewById(R.id.pLanguage)).setText((mData.get(0).toString()));
|
|
|
|
mDialog.findViewById(R.id.pDismiss).setOnClickListener(v -> mDialog.dismiss());
|
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);
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pDismiss).setOnClickListener(v -> mDialog.dismiss());
|
|
|
|
mDialog.findViewById(R.id.pNext).setOnClickListener(v -> {
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
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
|
|
|
}
|
2021-01-28 11:22:41 +01:00
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
onTrigger(Arrays.asList(mContext, mContext.getString(R.string.ALERT_NOT_SUPPORTED_MESSAGE)),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()
|
|
|
|
{
|
2021-01-28 11:22:41 +01:00
|
|
|
initializeDialog(R.layout.popup_reported_successfully, Gravity.BOTTOM);
|
|
|
|
mDialog.findViewById(R.id.pNext).setOnClickListener(v -> mDialog.dismiss());
|
2020-02-28 19:10:00 +01:00
|
|
|
}
|
|
|
|
|
2021-03-23 12:52:22 +01:00
|
|
|
private void newIdentityCreated()
|
|
|
|
{
|
|
|
|
initializeDialog(R.layout.popup_new_circuit, Gravity.BOTTOM);
|
|
|
|
mDialog.findViewById(R.id.pDismiss).setOnClickListener(v -> mDialog.dismiss());
|
|
|
|
|
|
|
|
final Handler handler = new Handler();
|
|
|
|
Runnable runnable = () -> {
|
|
|
|
mDialog.dismiss();
|
|
|
|
};
|
|
|
|
handler.postDelayed(runnable, 1500);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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);
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pDismiss).setOnClickListener(v -> mDialog.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);
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pDismiss).setOnClickListener(v -> mDialog.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);
|
2021-01-28 11:22:41 +01:00
|
|
|
Window window = mDialog.getWindow();
|
2021-01-18 11:07:12 +01:00
|
|
|
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);
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.getWindow().setBackgroundDrawable(inset);
|
|
|
|
mDialog.setCancelable(true);
|
|
|
|
mDialog.setCanceledOnTouchOutside(true);
|
|
|
|
mDialog.findViewById(R.id.pDismiss).setOnClickListener(v -> mDialog.dismiss());
|
|
|
|
mDialog.findViewById(R.id.pNext).setOnClickListener(v -> mEvent.invokeObserver(null, M_SECURE_CONNECTION));
|
|
|
|
|
|
|
|
if((boolean) mData.get(1)){
|
|
|
|
((SwitchMaterial) mDialog.findViewById(R.id.pJSStatus)).setChecked(true);
|
2021-01-18 11:07:12 +01:00
|
|
|
}else {
|
2021-01-28 11:22:41 +01:00
|
|
|
((SwitchMaterial) mDialog.findViewById(R.id.pJSStatus)).setChecked(false);
|
2021-01-18 11:07:12 +01:00
|
|
|
}
|
2021-01-28 11:22:41 +01:00
|
|
|
if((boolean) mData.get(2)){
|
|
|
|
((SwitchMaterial) mDialog.findViewById(R.id.pDTStatus)).setChecked(true);
|
2021-01-18 11:07:12 +01:00
|
|
|
}else {
|
2021-01-28 11:22:41 +01:00
|
|
|
((SwitchMaterial) mDialog.findViewById(R.id.pDTStatus)).setChecked(false);
|
2021-01-18 11:07:12 +01:00
|
|
|
}
|
2021-02-03 11:54:19 +01:00
|
|
|
if((int) mData.get(3) != ContentBlocking.AntiTracking.NONE){
|
2021-01-28 11:22:41 +01:00
|
|
|
((SwitchMaterial) mDialog.findViewById(R.id.pTPStatus)).setChecked(true);
|
2021-01-18 11:07:12 +01:00
|
|
|
}else {
|
2021-01-28 11:22:41 +01:00
|
|
|
((SwitchMaterial) mDialog.findViewById(R.id.pTPStatus)).setChecked(false);
|
2021-01-18 11:07:12 +01:00
|
|
|
}
|
|
|
|
|
2021-01-28 11:22:41 +01:00
|
|
|
((TextView) mDialog.findViewById(R.id.pHeaderSubpart)).setText(helperMethod.getDomainName(mData.get(0).toString()));
|
2021-01-18 11:07:12 +01:00
|
|
|
}
|
|
|
|
|
2020-01-24 16:23:31 +01:00
|
|
|
private void bookmark()
|
|
|
|
{
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_create_bookmark, Gravity.CENTER);
|
2021-01-28 11:22:41 +01:00
|
|
|
mContext.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
|
|
|
|
|
|
|
|
mDialog.setOnShowListener(dialog -> mContext.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING));
|
|
|
|
mDialog.setOnDismissListener(dialog -> {
|
2020-10-20 16:55:08 +02:00
|
|
|
final Handler handler = new Handler();
|
|
|
|
Runnable runnable = () -> {
|
|
|
|
helperMethod.hideKeyboard(activityContextManager.getInstance().getHomeController());
|
|
|
|
dialog.dismiss();
|
2021-01-28 11:22:41 +01:00
|
|
|
mContext.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
2020-10-20 16:55:08 +02:00
|
|
|
};
|
|
|
|
handler.postDelayed(runnable, 50);
|
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pDismiss).setOnClickListener(v -> {
|
|
|
|
mDialog.dismiss();
|
|
|
|
mContext.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
2020-10-20 16:55:08 +02:00
|
|
|
helperMethod.hideKeyboard(activityContextManager.getInstance().getHomeController());
|
|
|
|
});
|
|
|
|
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pNext).setOnClickListener(v -> {
|
|
|
|
mDialog.dismiss();
|
|
|
|
mContext.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
2020-12-01 23:10:05 +01:00
|
|
|
helperMethod.hideKeyboard(mContext);
|
2021-02-03 11:54:19 +01:00
|
|
|
mEvent.invokeObserver(Collections.singletonList(mData.get(0).toString().replace("genesis.onion","boogle.store")+"split"+((EditText) mDialog.findViewById(R.id.pBridgeInput)).getText().toString()), M_BOOKMARK);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onUpdateBridges()
|
|
|
|
{
|
|
|
|
initializeDialog(R.layout.popup_update_bridges, Gravity.CENTER);
|
|
|
|
mContext.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
|
|
|
|
if(!status.sBridgeCustomBridge.equals("meek") && !status.sBridgeCustomBridge.equals("obfs4")){
|
|
|
|
((EditText)mDialog.findViewById(R.id.pBridgeInput)).setText(status.sBridgeCustomBridge);
|
|
|
|
}
|
|
|
|
mDialog.setOnShowListener(dialog -> mContext.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING));
|
|
|
|
mDialog.setOnDismissListener(dialog -> {
|
|
|
|
final Handler handler = new Handler();
|
|
|
|
Runnable runnable = () -> {
|
|
|
|
helperMethod.hideKeyboard(activityContextManager.getInstance().getHomeController());
|
|
|
|
dialog.dismiss();
|
|
|
|
mContext.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
|
|
|
};
|
|
|
|
handler.postDelayed(runnable, 50);
|
|
|
|
});
|
|
|
|
mDialog.findViewById(R.id.pBridgeRequest).setOnClickListener(v -> {
|
|
|
|
final Handler handler = new Handler();
|
|
|
|
Runnable runnable = () -> {
|
|
|
|
try{
|
|
|
|
helperMethod.sendBridgeEmail(mContext);
|
|
|
|
}
|
|
|
|
catch (Exception ex){
|
|
|
|
onTrigger(Arrays.asList(mContext, mContext.getString(R.string.ALERT_NOT_SUPPORTED_MESSAGE)),M_NOT_SUPPORTED);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
handler.postDelayed(runnable, 200);
|
|
|
|
});
|
|
|
|
|
|
|
|
mDialog.findViewById(R.id.pNext).setOnClickListener(v -> {
|
|
|
|
mDialog.dismiss();
|
|
|
|
mContext.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
|
|
|
helperMethod.hideKeyboard(mContext);
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(((EditText)mDialog.findViewById(R.id.pBridgeInput)).getText().toString()), M_SET_BRIDGES);
|
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);
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pDismiss).setOnClickListener(v -> mDialog.dismiss());
|
|
|
|
mDialog.findViewById(R.id.pNext).setOnClickListener(v -> {
|
|
|
|
mDialog.dismiss();
|
|
|
|
mEvent.invokeObserver(null, 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);
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pDismiss).setOnClickListener(v -> mDialog.dismiss());
|
|
|
|
mDialog.findViewById(R.id.pNext).setOnClickListener(v -> {
|
|
|
|
mDialog.dismiss();
|
|
|
|
mEvent.invokeObserver(null, 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-28 11:22:41 +01:00
|
|
|
((TextView) mDialog.findViewById(R.id.pHeader)).setText(mData.get(0).toString());
|
|
|
|
mDialog.findViewById(R.id.pDismiss).setOnClickListener(v -> mDialog.dismiss());
|
|
|
|
mDialog.findViewById(R.id.pNext).setOnClickListener(v -> {
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
final Handler handler = new Handler();
|
2021-01-28 11:22:41 +01:00
|
|
|
Runnable runnable = () -> onTrigger(Arrays.asList(strings.GENERIC_EMPTY_STR, mContext),M_RATE_SUCCESS);
|
2020-10-20 16:55:08 +02:00
|
|
|
handler.postDelayed(runnable, 1000);
|
|
|
|
});
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
2021-03-06 19:55:24 +01:00
|
|
|
private void downloadSingle()
|
|
|
|
{
|
|
|
|
initializeDialog(R.layout.popup_download_url, Gravity.CENTER);
|
|
|
|
((TextView) mDialog.findViewById(R.id.pDescription)).setText(mData.get(0).toString());
|
|
|
|
mDialog.findViewById(R.id.pDismiss).setOnClickListener(v -> mDialog.dismiss());
|
|
|
|
mDialog.findViewById(R.id.pNext).setOnClickListener(v -> {
|
|
|
|
mDialog.dismiss();
|
|
|
|
final Handler handler = new Handler();
|
|
|
|
Runnable runnable = () -> {
|
|
|
|
mEvent.invokeObserver(mData, M_DOWNLOAD_SINGLE);
|
|
|
|
};
|
|
|
|
handler.postDelayed(runnable, 1000);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
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);
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pDismiss).setOnClickListener(v -> mDialog.dismiss());
|
|
|
|
mDialog.findViewById(R.id.pNext).setOnClickListener(v -> {
|
|
|
|
RatingBar mRatingBar = mDialog.findViewById(R.id.pRating);
|
2020-10-20 16:55:08 +02:00
|
|
|
if(mRatingBar.getRating()>=3){
|
2021-01-28 11:22:41 +01:00
|
|
|
mEvent.invokeObserver(null, M_APP_RATED);
|
|
|
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(CONST_PLAYSTORE_URL));
|
|
|
|
try {
|
2020-12-01 23:10:05 +01:00
|
|
|
mContext.startActivity(intent);
|
2021-01-28 11:22:41 +01:00
|
|
|
} catch (Exception ignored) {
|
|
|
|
helperMethod.showToastMessage(MESSAGE_PLAYSTORE_NOT_FOUND, mContext);
|
2020-10-20 16:55:08 +02:00
|
|
|
}
|
2021-01-28 11:22:41 +01:00
|
|
|
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
}else if(mRatingBar.getRating()>0) {
|
2021-01-28 11:22:41 +01:00
|
|
|
mEvent.invokeObserver(null, M_APP_RATED);
|
2020-10-20 16:55:08 +02:00
|
|
|
final Handler handler = new Handler();
|
2021-01-28 11:22:41 +01:00
|
|
|
handler.postDelayed(() -> onTrigger(Arrays.asList(strings.GENERIC_EMPTY_STR, mContext),M_RATE_FAILURE), 1000);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
}
|
|
|
|
});
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void downloadFileLongPress()
|
|
|
|
{
|
2021-01-28 11:22:41 +01:00
|
|
|
String title = mData.get(2).toString();
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2021-01-28 11:22:41 +01:00
|
|
|
if(title.length()>0){
|
|
|
|
title = title + " | ";
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_file_longpress, Gravity.CENTER);
|
2021-01-28 11:22:41 +01:00
|
|
|
((TextView) mDialog.findViewById(R.id.pDescription)).setText((title + mData.get(0).toString()));
|
|
|
|
mDialog.findViewById(R.id.pDismiss).setOnClickListener(v -> mDialog.dismiss());
|
|
|
|
mDialog.findViewById(R.id.pOption1).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(mData.get(0)), M_DOWNLOAD_FILE_MANUAL);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pOption2).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(mData.get(0)), M_OPEN_LINK_CURRENT_TAB);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pOption3).setOnClickListener(v -> {
|
2021-02-25 15:26:43 +01:00
|
|
|
mEvent.invokeObserver(Collections.singletonList(mData.get(0)), M_OPEN_LINK_NEW_TAB);
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pOption3).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(mData.get(0)), M_COPY_LINK);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void openURLLongPress()
|
|
|
|
{
|
2021-01-28 11:22:41 +01:00
|
|
|
String title = mData.get(2).toString();
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_url_longpress, Gravity.CENTER);
|
2021-01-28 11:22:41 +01:00
|
|
|
((TextView) mDialog.findViewById(R.id.pDescription)).setText((title + mData.get(0)));
|
|
|
|
mDialog.findViewById(R.id.pDismiss).setOnClickListener(v -> mDialog.dismiss());
|
|
|
|
mDialog.findViewById(R.id.pOption1).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(mData.get(0)), M_OPEN_LINK_NEW_TAB);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pOption2).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(mData.get(0)), M_OPEN_LINK_CURRENT_TAB);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pOption3).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(mData.get(0)), M_COPY_LINK);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2020-02-28 19:10:00 +01:00
|
|
|
}
|
|
|
|
|
2020-01-24 16:23:31 +01:00
|
|
|
private void popupDownloadFull(){
|
2021-01-28 11:22:41 +01:00
|
|
|
String url = mData.get(0).toString();
|
|
|
|
String file = mData.get(2).toString();
|
|
|
|
String title = mData.get(3).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
|
|
|
|
2021-01-28 11:22:41 +01:00
|
|
|
if(!url.equals(strings.GENERIC_EMPTY_STR)){
|
|
|
|
data_local = title + url;
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
2021-01-28 11:22:41 +01:00
|
|
|
else if(!file.equals(strings.GENERIC_EMPTY_STR)){
|
|
|
|
data_local = file;
|
2020-11-11 13:11:13 +01:00
|
|
|
}
|
|
|
|
String mTitle = title;
|
|
|
|
if(mTitle.length()<=1){
|
2021-01-28 11:22:41 +01:00
|
|
|
mTitle = mData.get(0).toString();
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
|
2020-12-11 08:05:08 +01:00
|
|
|
initializeDialog(R.layout.popup_download_full, Gravity.CENTER);
|
2021-01-28 11:22:41 +01:00
|
|
|
((TextView) mDialog.findViewById(R.id.pHeader)).setText(mTitle);
|
|
|
|
((TextView) mDialog.findViewById(R.id.pDescription)).setText((data_local));
|
|
|
|
mDialog.findViewById(R.id.pOption1).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(url), M_OPEN_LINK_NEW_TAB);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pOption2).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(url), M_OPEN_LINK_CURRENT_TAB);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pOption3).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(url), M_COPY_LINK);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pOption4).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(file), M_OPEN_LINK_NEW_TAB);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pOption5).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(file), M_OPEN_LINK_CURRENT_TAB);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pOption6).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(file), M_COPY_LINK);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pOption7).setOnClickListener(v -> {
|
|
|
|
mEvent.invokeObserver(Collections.singletonList(file), M_DOWNLOAD_FILE_MANUAL);
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
});
|
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);
|
2021-01-28 11:22:41 +01:00
|
|
|
mDialog.findViewById(R.id.pDismiss).setOnClickListener(v -> mDialog.dismiss());
|
|
|
|
mDialog.findViewById(R.id.pNext).setOnClickListener(v -> {
|
|
|
|
mDialog.dismiss();
|
2020-10-20 16:55:08 +02:00
|
|
|
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){
|
2021-01-28 11:22:41 +01:00
|
|
|
onTrigger(Arrays.asList(mContext, mContext.getString(R.string.ALERT_NOT_SUPPORTED_MESSAGE)),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(){
|
2021-01-28 11:22:41 +01:00
|
|
|
if(mDialog !=null){
|
|
|
|
mDialog.dismiss();
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-28 11:22:41 +01:00
|
|
|
/*External Triggers*/
|
2020-01-24 16:23:31 +01:00
|
|
|
|
2021-01-28 11:22:41 +01:00
|
|
|
void onTrigger(List<Object> pData, pluginEnums.eMessageManager pEventType)
|
2020-01-24 16:23:31 +01:00
|
|
|
{
|
2021-01-28 11:22:41 +01:00
|
|
|
if(pEventType.equals(pluginEnums.eMessageManager.M_RESET)){
|
|
|
|
onReset();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.mContext = (AppCompatActivity) pData.get(pData.size()-1);
|
|
|
|
this.mData = pData;
|
|
|
|
|
|
|
|
switch (pEventType) {
|
|
|
|
case M_WELCOME:
|
|
|
|
/*VERIFIED*/
|
|
|
|
welcomeMessage();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case M_RATE_FAILURE:
|
|
|
|
/*VERIFIED*/
|
|
|
|
rateFailure();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case M_LANGUAGE_SUPPORT_FAILURE:
|
|
|
|
/*VERIFIED*/
|
|
|
|
languageSupportFailure();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case M_RATE_SUCCESS:
|
|
|
|
/*VERIFIED*/
|
|
|
|
reportedSuccessfully();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case M_BOOKMARK:
|
|
|
|
/*VERIFIED*/
|
|
|
|
bookmark();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case M_CLEAR_HISTORY:
|
|
|
|
/*VERIFIED*/
|
|
|
|
clearHistory();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case M_CLEAR_BOOKMARK:
|
|
|
|
/*VERIFIED*/
|
|
|
|
clearBookmark();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case M_REPORT_URL:
|
|
|
|
/*VERIFIED*/
|
|
|
|
reportURL();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case M_RATE_APP:
|
|
|
|
/*VERIFIED*/
|
|
|
|
rateApp();
|
|
|
|
break;
|
|
|
|
|
2021-03-04 11:09:23 +01:00
|
|
|
case M_DOWNLOAD_FILE :
|
|
|
|
/*VERIFIED*/
|
|
|
|
//downloadFileLongPress();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case M_LONG_PRESS_DOWNLOAD :
|
2021-01-28 11:22:41 +01:00
|
|
|
/*VERIFIED*/
|
|
|
|
downloadFileLongPress();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case M_LONG_PRESS_URL:
|
|
|
|
/*VERIFIED*/
|
|
|
|
openURLLongPress();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case M_LONG_PRESS_WITH_LINK:
|
|
|
|
/*VERIFIED*/
|
|
|
|
popupDownloadFull();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case M_BRIDGE_MAIL:
|
|
|
|
/*VERIFIED*/
|
|
|
|
sendBridgeMail();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case M_NOT_SUPPORTED:
|
|
|
|
/*VERIFIED*/
|
|
|
|
notSupportMessage();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case M_DATA_CLEARED:
|
|
|
|
/*VERIFIED*/
|
|
|
|
dataClearedSuccessfully();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case M_SECURE_CONNECTION:
|
|
|
|
/*VERIFIED*/
|
|
|
|
openSecureConnectionPopup();
|
|
|
|
break;
|
2021-02-03 11:54:19 +01:00
|
|
|
|
2021-03-06 19:55:24 +01:00
|
|
|
case M_DOWNLOAD_SINGLE:
|
|
|
|
/*VERIFIED*/
|
|
|
|
downloadSingle();
|
|
|
|
break;
|
|
|
|
|
2021-02-03 11:54:19 +01:00
|
|
|
case M_UPDATE_BRIDGES:
|
|
|
|
/*VERIFIED*/
|
|
|
|
onUpdateBridges();
|
|
|
|
break;
|
2021-03-23 12:52:22 +01:00
|
|
|
|
|
|
|
case M_NEW_IDENTITY:
|
|
|
|
/*VERIFIED*/
|
|
|
|
newIdentityCreated();
|
|
|
|
break;
|
2021-01-28 11:22:41 +01:00
|
|
|
}
|
2020-01-24 16:23:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|