diff --git a/app/src/main/java/awais/instagrabber/dialogs/ConfirmDialogFragment.java b/app/src/main/java/awais/instagrabber/dialogs/ConfirmDialogFragment.java
index 5b8eb3c9..f5b5bc81 100644
--- a/app/src/main/java/awais/instagrabber/dialogs/ConfirmDialogFragment.java
+++ b/app/src/main/java/awais/instagrabber/dialogs/ConfirmDialogFragment.java
@@ -3,6 +3,8 @@ package awais.instagrabber.dialogs;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
+import android.text.method.LinkMovementMethod;
+import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -24,17 +26,40 @@ public class ConfirmDialogFragment extends DialogFragment {
@NonNull
public static ConfirmDialogFragment newInstance(final int requestCode,
@StringRes final int title,
- @StringRes final int message,
+ @NonNull final CharSequence message,
@StringRes final int positiveText,
@StringRes final int negativeText,
@StringRes final int neutralText) {
+ return newInstance(requestCode, title, 0, message, positiveText, negativeText, neutralText);
+ }
+
+ @NonNull
+ public static ConfirmDialogFragment newInstance(final int requestCode,
+ @StringRes final int title,
+ @StringRes final int messageResId,
+ @StringRes final int positiveText,
+ @StringRes final int negativeText,
+ @StringRes final int neutralText) {
+ return newInstance(requestCode, title, messageResId, null, positiveText, negativeText, neutralText);
+ }
+
+ @NonNull
+ private static ConfirmDialogFragment newInstance(final int requestCode,
+ @StringRes final int title,
+ @StringRes final int messageResId,
+ @Nullable final CharSequence message,
+ @StringRes final int positiveText,
+ @StringRes final int negativeText,
+ @StringRes final int neutralText) {
Bundle args = new Bundle();
args.putInt("requestCode", requestCode);
if (title != 0) {
args.putInt("title", title);
}
- if (message != 0) {
- args.putInt("message", message);
+ if (messageResId != 0) {
+ args.putInt("messageResId", messageResId);
+ } else if (message != null) {
+ args.putCharSequence("message", message);
}
if (positiveText != 0) {
args.putInt("positive", positiveText);
@@ -67,7 +92,8 @@ public class ConfirmDialogFragment extends DialogFragment {
public Dialog onCreateDialog(@Nullable final Bundle savedInstanceState) {
final Bundle arguments = getArguments();
int title = 0;
- int message = 0;
+ int messageResId = 0;
+ CharSequence message = null;
int neutralButtonText = 0;
int negativeButtonText = 0;
@@ -75,7 +101,8 @@ public class ConfirmDialogFragment extends DialogFragment {
final int requestCode;
if (arguments != null) {
title = arguments.getInt("title", 0);
- message = arguments.getInt("message", 0);
+ messageResId = arguments.getInt("messageResId", 0);
+ message = arguments.getCharSequence("message", null);
positiveButtonText = arguments.getInt("positive", defaultPositiveButtonText);
negativeButtonText = arguments.getInt("negative", 0);
neutralButtonText = arguments.getInt("neutral", 0);
@@ -92,7 +119,9 @@ public class ConfirmDialogFragment extends DialogFragment {
if (title != 0) {
builder.setTitle(title);
}
- if (message != 0) {
+ if (messageResId != 0) {
+ builder.setMessage(messageResId);
+ } else if (message != null) {
builder.setMessage(message);
}
if (negativeButtonText != 0) {
@@ -110,6 +139,15 @@ public class ConfirmDialogFragment extends DialogFragment {
return builder.create();
}
+ @Override
+ public void onStart() {
+ super.onStart();
+ final Dialog dialog = getDialog();
+ if (dialog == null) return;
+ final TextView view = dialog.findViewById(android.R.id.message);
+ view.setMovementMethod(LinkMovementMethod.getInstance());
+ }
+
public interface ConfirmDialogFragmentCallback {
void onPositiveButtonClicked(int requestCode);
diff --git a/app/src/main/java/awais/instagrabber/webservices/interceptors/IgErrorsInterceptor.java b/app/src/main/java/awais/instagrabber/webservices/interceptors/IgErrorsInterceptor.java
index 7ad95782..cf08b9dc 100644
--- a/app/src/main/java/awais/instagrabber/webservices/interceptors/IgErrorsInterceptor.java
+++ b/app/src/main/java/awais/instagrabber/webservices/interceptors/IgErrorsInterceptor.java
@@ -1,5 +1,7 @@
package awais.instagrabber.webservices.interceptors;
+import android.text.Html;
+import android.text.Spanned;
import android.util.Log;
import android.widget.Toast;
@@ -57,7 +59,9 @@ public class IgErrorsInterceptor implements Interceptor {
final String location = response.header("location");
if (location != null && location.equals("https://www.instagram.com/accounts/login/")) {
// rate limited
- showErrorDialog(R.string.rate_limit);
+ final String message = MainActivity.getInstance().getString(R.string.rate_limit);
+ final Spanned spanned = Html.fromHtml(message);
+ showErrorDialog(spanned);
}
return;
}
@@ -121,16 +125,15 @@ public class IgErrorsInterceptor implements Interceptor {
return String.format("code: %s, internalMessage: %s", errorCode, message);
}
- private void showErrorDialog(@StringRes final int messageResId) {
+ private void showErrorDialog(@NonNull final CharSequence message) {
final MainActivity mainActivity = MainActivity.getInstance();
if (mainActivity == null) return;
final FragmentManager fragmentManager = mainActivity.getSupportFragmentManager();
if (fragmentManager.isStateSaved()) return;
- if (messageResId == 0) return;
final ConfirmDialogFragment dialogFragment = ConfirmDialogFragment.newInstance(
Constants.GLOBAL_NETWORK_ERROR_DIALOG_REQUEST_CODE,
R.string.error,
- messageResId,
+ message,
R.string.ok,
0,
0
@@ -138,6 +141,10 @@ public class IgErrorsInterceptor implements Interceptor {
dialogFragment.show(fragmentManager, "network_error_dialog");
}
+ private void showErrorDialog(@StringRes final int messageResId) {
+ showErrorDialog(MainActivity.getInstance().getString(messageResId));
+ }
+
public void destroy() {
// mainActivity = null;
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 89fb969d..358fbc74 100755
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -492,7 +492,7 @@
Barinsta Crash Report
Select an email app to send crash logs
Not found!
- Your IP has been rate limited by Instagram. Wait for an hour and try again.
+ Your IP has been rate limited by Instagram. Wait for an hour and try again. <a href=\"https://redd.it/msxlko\">Learn more.</a>
Skip this update
You\'re already on the latest version
Screen order