Open link more options

pull/199/head
M66B 4 years ago
parent 3b3e392deb
commit f9eff3b5d6

@ -100,6 +100,16 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
"story_fbid", "fbid", "id", "comment_id"
));
private ImageButton ibMore;
private TextView tvMore;
private Button btnOwner;
private ContentLoadingProgressBar pbWait;
private TextView tvOwnerRemark;
private TextView tvHost;
private TextView tvOwner;
private Group grpOwner;
private Button btnSettings;
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
@ -147,15 +157,21 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
final ImageButton ibCopy = dview.findViewById(R.id.ibCopy);
final CheckBox cbSecure = dview.findViewById(R.id.cbSecure);
final CheckBox cbSanitize = dview.findViewById(R.id.cbSanitize);
final Button btnOwner = dview.findViewById(R.id.btnOwner);
final TextView tvOwnerRemark = dview.findViewById(R.id.tvOwnerRemark);
final ContentLoadingProgressBar pbWait = dview.findViewById(R.id.pbWait);
final TextView tvHost = dview.findViewById(R.id.tvHost);
final TextView tvOwner = dview.findViewById(R.id.tvOwner);
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
final Button btnMore = dview.findViewById(R.id.btnMore);
ibMore = dview.findViewById(R.id.ibMore);
tvMore = dview.findViewById(R.id.tvMore);
btnOwner = dview.findViewById(R.id.btnOwner);
pbWait = dview.findViewById(R.id.pbWait);
tvOwnerRemark = dview.findViewById(R.id.tvOwnerRemark);
tvHost = dview.findViewById(R.id.tvHost);
tvOwner = dview.findViewById(R.id.tvOwner);
grpOwner = dview.findViewById(R.id.grpOwner);
btnSettings = dview.findViewById(R.id.btnSettings);
final Group grpDifferent = dview.findViewById(R.id.grpDifferent);
final Group grpOwner = dview.findViewById(R.id.grpOwner);
// Wire
ibInfo.setOnClickListener(new View.OnClickListener() {
@Override
@ -272,24 +288,15 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
}
});
btnMore.setOnClickListener(new View.OnClickListener() {
View.OnClickListener onMore = new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent privacy = new Intent(v.getContext(), ActivitySetup.class)
.setAction("privacy")
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra("tab", "privacy");
v.getContext().startActivity(privacy);
setMore(btnOwner.getVisibility() == View.GONE);
}
});
};
tvOwnerRemark.setMovementMethod(LinkMovementMethod.getInstance());
cbNotAgain.setText(context.getString(R.string.title_no_ask_for_again, uri.getHost()));
cbNotAgain.setVisibility(
"https".equals(uri.getScheme()) && !TextUtils.isEmpty(uri.getHost())
? View.VISIBLE : View.GONE);
pbWait.setVisibility(View.GONE);
grpOwner.setVisibility(View.GONE);
ibMore.setOnClickListener(onMore);
tvMore.setOnClickListener(onMore);
btnOwner.setOnClickListener(new View.OnClickListener() {
@Override
@ -300,6 +307,8 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
new SimpleTask<Pair<InetAddress, IPInfo.Organization>>() {
@Override
protected void onPreExecute(Bundle args) {
ibMore.setEnabled(false);
tvMore.setEnabled(false);
btnOwner.setEnabled(false);
pbWait.setVisibility(View.VISIBLE);
grpOwner.setVisibility(View.GONE);
@ -307,6 +316,8 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
@Override
protected void onPostExecute(Bundle args) {
ibMore.setEnabled(true);
tvMore.setEnabled(true);
btnOwner.setEnabled(true);
pbWait.setVisibility(View.GONE);
grpOwner.setVisibility(View.VISIBLE);
@ -339,6 +350,21 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
}
});
tvOwnerRemark.setMovementMethod(LinkMovementMethod.getInstance());
btnSettings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent privacy = new Intent(v.getContext(), ActivitySetup.class)
.setAction("privacy")
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra("tab", "privacy");
v.getContext().startActivity(privacy);
}
});
// Initialize
tvTitle.setText(title);
tvTitle.setVisibility(TextUtils.isEmpty(title) ? View.GONE : View.VISIBLE);
@ -374,8 +400,17 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
categories = DisconnectBlacklist.getCategories(uri.getHost());
if (categories != null)
tvDisconnectCategories.setText(TextUtils.join(", ", categories));
tvDisconnect.setVisibility(categories == null ? View.GONE : View.VISIBLE);
tvDisconnectCategories.setVisibility(categories == null ? View.GONE : View.VISIBLE);
tvDisconnect.setVisibility(
categories == null ? View.GONE : View.VISIBLE);
tvDisconnectCategories.setVisibility(
categories == null || !BuildConfig.DEBUG ? View.GONE : View.VISIBLE);
cbNotAgain.setText(context.getString(R.string.title_no_ask_for_again, uri.getHost()));
cbNotAgain.setVisibility(
"https".equals(uri.getScheme()) && !TextUtils.isEmpty(uri.getHost())
? View.VISIBLE : View.GONE);
setMore(false);
return new AlertDialog.Builder(context)
.setView(dview)
@ -405,6 +440,15 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
.create();
}
private void setMore(boolean show) {
ibMore.setImageLevel(show ? 0 : 1);
btnOwner.setVisibility(show ? View.VISIBLE : View.GONE);
pbWait.setVisibility(View.GONE);
tvOwnerRemark.setVisibility(show ? View.VISIBLE : View.GONE);
grpOwner.setVisibility(View.GONE);
btnSettings.setVisibility(show ? View.VISIBLE : View.GONE);
}
private static Uri sanitize(Uri uri) {
boolean changed = false;

@ -174,6 +174,40 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbSecure" />
<CheckBox
android:id="@+id/cbNotAgain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_no_ask_for_again"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbSanitize" />
<ImageButton
android:id="@+id/ibMore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:padding="3dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotAgain"
app:srcCompat="@drawable/expander" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvMore"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center_vertical"
android:paddingStart="6dp"
android:text="@string/title_search_more"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintBottom_toBottomOf="@+id/ibMore"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/ibMore"
app:layout_constraintTop_toTopOf="@+id/ibMore" />
<Button
android:id="@+id/btnOwner"
style="?android:attr/buttonStyleSmall"
@ -184,7 +218,7 @@
android:drawablePadding="6dp"
android:text="@string/title_check_owner"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbSanitize" />
app:layout_constraintTop_toBottomOf="@id/ibMore" />
<eu.faircode.email.ContentLoadingProgressBar
android:id="@+id/pbWait"
@ -239,27 +273,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHost" />
<CheckBox
android:id="@+id/cbNotAgain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_no_ask_for_again"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOwner" />
<Button
android:id="@+id/btnMore"
android:id="@+id/btnSettings"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:drawableEnd="@drawable/twotone_more_horiz_24"
android:drawableEnd="@drawable/twotone_settings_24"
android:drawablePadding="6dp"
android:text="@string/title_advanced_more"
android:text="@string/title_setup"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotAgain" />
app:layout_constraintTop_toBottomOf="@id/tvOwner" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpDifferent"

Loading…
Cancel
Save