Browse Source

Ask before opening links, with the option to edit the link

main
M66B 6 years ago
parent
commit
9a6e56cf16
7 changed files with 63 additions and 23 deletions
  1. +1
    -2
      app/src/main/java/eu/faircode/email/ActivityView.java
  2. +3
    -3
      app/src/main/java/eu/faircode/email/FragmentAccount.java
  3. +3
    -3
      app/src/main/java/eu/faircode/email/FragmentCompose.java
  4. +3
    -3
      app/src/main/java/eu/faircode/email/FragmentIdentity.java
  5. +27
    -12
      app/src/main/java/eu/faircode/email/FragmentMessage.java
  6. +25
    -0
      app/src/main/res/layout/dialog_link.xml
  7. +1
    -0
      app/src/main/res/values/strings.xml

+ 1
- 2
app/src/main/java/eu/faircode/email/ActivityView.java View File

@ -637,8 +637,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
if (faq.resolveActivity(getPackageManager()) == null)
startActivity(getIntentRate());
else {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder
new AlertDialog.Builder(this)
.setMessage(R.string.title_issue)
.setPositiveButton(R.string.title_yes, new DialogInterface.OnClickListener() {
@Override


+ 3
- 3
app/src/main/java/eu/faircode/email/FragmentAccount.java View File

@ -699,8 +699,7 @@ public class FragmentAccount extends FragmentEx {
ibDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder
new AlertDialog.Builder(getContext())
.setMessage(R.string.title_account_delete)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
@ -735,7 +734,8 @@ public class FragmentAccount extends FragmentEx {
}.load(FragmentAccount.this, args);
}
})
.setNegativeButton(android.R.string.cancel, null).show();
.setNegativeButton(android.R.string.cancel, null)
.show();
}
});


+ 3
- 3
app/src/main/java/eu/faircode/email/FragmentCompose.java View File

@ -235,8 +235,7 @@ public class FragmentCompose extends FragmentEx {
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
int action = item.getItemId();
if (action == R.id.action_delete) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder
new AlertDialog.Builder(getContext())
.setMessage(R.string.title_ask_delete)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
@ -244,7 +243,8 @@ public class FragmentCompose extends FragmentEx {
onAction(R.id.action_delete);
}
})
.setNegativeButton(android.R.string.cancel, null).show();
.setNegativeButton(android.R.string.cancel, null)
.show();
} else
onAction(action);


+ 3
- 3
app/src/main/java/eu/faircode/email/FragmentIdentity.java View File

@ -347,8 +347,7 @@ public class FragmentIdentity extends FragmentEx {
ibDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder
new AlertDialog.Builder(getContext())
.setMessage(R.string.title_identity_delete)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
@ -381,7 +380,8 @@ public class FragmentIdentity extends FragmentEx {
}.load(FragmentIdentity.this, args);
}
})
.setNegativeButton(android.R.string.cancel, null).show();
.setNegativeButton(android.R.string.cancel, null)
.show();
}
});


+ 27
- 12
app/src/main/java/eu/faircode/email/FragmentMessage.java View File

@ -52,6 +52,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
@ -247,12 +248,26 @@ public class FragmentMessage extends FragmentEx {
.putExtra("uri", uri));
} else {
// https://developer.chrome.com/multidevice/android/customtabs
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(Helper.resolveColor(getContext(), R.attr.colorPrimary));
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(getContext(), Uri.parse(url));
View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_link, null);
final EditText etLink = view.findViewById(R.id.etLink);
etLink.setText(url);
new AlertDialog.Builder(getContext())
.setView(view)
.setPositiveButton(R.string.title_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Uri uri = Uri.parse(etLink.getText().toString());
// https://developer.chrome.com/multidevice/android/customtabs
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setToolbarColor(Helper.resolveColor(getContext(), R.attr.colorPrimary));
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(getContext(), uri);
}
})
.setNegativeButton(R.string.title_no, null)
.show();
}
}
@ -712,8 +727,7 @@ public class FragmentMessage extends FragmentEx {
}
private void onActionSpam() {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder
new AlertDialog.Builder(getContext())
.setMessage(R.string.title_ask_spam)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
@ -761,15 +775,15 @@ public class FragmentMessage extends FragmentEx {
}.load(FragmentMessage.this, args);
}
})
.setNegativeButton(android.R.string.cancel, null).show();
.setNegativeButton(android.R.string.cancel, null)
.show();
}
private void onActionDelete() {
boolean delete = (Boolean) bottom_navigation.getTag();
if (delete) {
// No trash or is trash
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder
new AlertDialog.Builder(getContext())
.setMessage(R.string.title_ask_delete)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
@ -819,7 +833,8 @@ public class FragmentMessage extends FragmentEx {
}.load(FragmentMessage.this, args);
}
})
.setNegativeButton(android.R.string.cancel, null).show();
.setNegativeButton(android.R.string.cancel, null)
.show();
} else {
Helper.setViewsEnabled(view, false);


+ 25
- 0
app/src/main/res/layout/dialog_link.xml View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="12dp">
<TextView
android:id="@+id/tvOpenLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_open_link"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/etLink"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="https://email.faircode.eu/"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOpenLink" />
</androidx.constraintlayout.widget.ConstraintLayout>

+ 1
- 0
app/src/main/res/values/strings.xml View File

@ -222,6 +222,7 @@
<string name="title_hint_folder_actions">Long press for options</string>
<string name="title_hint_message_actions">Swipe left to trash; swipe right to archive (if available); long press to mark read/unread or to add/remove star</string>
<string name="title_open_link">Open link</string>
<string name="title_updated">There is an update to version %1$s available</string>
<string name="title_issue">Do you have a question or problem?</string>
<string name="title_yes">Yes</string>


Loading…
Cancel
Save