Fix Verify Identity screen on smaller devices.

fork-5.53.8
Lucio Maciel 2021-09-07 17:50:36 -03:00 zatwierdzone przez Greyson Parrelli
rodzic 4eb24c3303
commit 9cc1ae4a29
6 zmienionych plików z 320 dodań i 198 usunięć

Wyświetl plik

@ -378,6 +378,7 @@
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".VerifyIdentityActivity"
android:theme="@style/Signal.DayNight.NoActionBar"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".components.settings.app.AppSettingsActivity"

Wyświetl plik

@ -43,11 +43,13 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.animation.Animation;
import android.view.animation.AnticipateInterpolator;
import android.view.animation.ScaleAnimation;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextSwitcher;
import android.widget.TextView;
import android.widget.Toast;
@ -55,6 +57,8 @@ import android.widget.Toast;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.OneShotPreDrawListener;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
@ -81,6 +85,7 @@ import org.thoughtcrime.securesms.recipients.LiveRecipient;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.thoughtcrime.securesms.storage.StorageSyncHelper;
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.FeatureFlags;
import org.thoughtcrime.securesms.util.IdentityUtil;
@ -111,7 +116,7 @@ public class VerifyIdentityActivity extends PassphraseRequiredActivity implement
private static final String IDENTITY_EXTRA = "recipient_identity";
private static final String VERIFIED_EXTRA = "verified_state";
private final DynamicTheme dynamicTheme = new DynamicTheme();
private final DynamicTheme dynamicTheme = new DynamicNoActionBarTheme();
private final VerifyDisplayFragment displayFragment = new VerifyDisplayFragment();
private final VerifyScanFragment scanFragment = new VerifyScanFragment();
@ -156,9 +161,6 @@ public class VerifyIdentityActivity extends PassphraseRequiredActivity implement
@Override
protected void onCreate(Bundle state, boolean ready) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.AndroidManifest__verify_safety_number);
Bundle extras = new Bundle();
extras.putParcelable(VerifyDisplayFragment.RECIPIENT_ID, getIntent().getParcelableExtra(RECIPIENT_EXTRA));
extras.putParcelable(VerifyDisplayFragment.REMOTE_IDENTITY, getIntent().getParcelableExtra(IDENTITY_EXTRA));
@ -216,7 +218,7 @@ public class VerifyIdentityActivity extends PassphraseRequiredActivity implement
Permissions.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
}
public static class VerifyDisplayFragment extends Fragment {
public static class VerifyDisplayFragment extends Fragment implements ViewTreeObserver.OnScrollChangedListener {
public static final String RECIPIENT_ID = "recipient_id";
public static final String REMOTE_NUMBER = "remote_number";
@ -230,6 +232,8 @@ public class VerifyIdentityActivity extends PassphraseRequiredActivity implement
private IdentityKey remoteIdentity;
private Fingerprint fingerprint;
private Toolbar toolbar;
private ScrollView scrollView;
private View container;
private View numbersContainer;
private View loading;
@ -240,6 +244,8 @@ public class VerifyIdentityActivity extends PassphraseRequiredActivity implement
private TextView description;
private View.OnClickListener clickListener;
private Button verifyButton;
private View toolbarShadow;
private View bottomShadow;
private TextView[] codes = new TextView[12];
private boolean animateSuccessOnDraw = false;
@ -249,6 +255,8 @@ public class VerifyIdentityActivity extends PassphraseRequiredActivity implement
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) {
this.container = ViewUtil.inflate(inflater, viewGroup, R.layout.verify_display_fragment);
this.toolbar = container.findViewById(R.id.toolbar);
this.scrollView = container.findViewById(R.id.scroll_view);
this.numbersContainer = container.findViewById(R.id.number_table);
this.loading = container.findViewById(R.id.loading);
this.qrCodeContainer = container.findViewById(R.id.qr_code_container);
@ -257,6 +265,8 @@ public class VerifyIdentityActivity extends PassphraseRequiredActivity implement
this.qrVerified = container.findViewById(R.id.qr_verified);
this.description = container.findViewById(R.id.description);
this.tapLabel = container.findViewById(R.id.tap_label);
this.toolbarShadow = container.findViewById(R.id.toolbar_shadow);
this.bottomShadow = container.findViewById(R.id.verify_identity_bottom_shadow);
this.codes[0] = container.findViewById(R.id.code_first);
this.codes[1] = container.findViewById(R.id.code_second);
this.codes[2] = container.findViewById(R.id.code_third);
@ -276,9 +286,19 @@ public class VerifyIdentityActivity extends PassphraseRequiredActivity implement
updateVerifyButton(getArguments().getBoolean(VERIFIED_STATE, false), false);
this.verifyButton.setOnClickListener((button -> updateVerifyButton(!currentVerifiedState, true)));
this.scrollView.getViewTreeObserver().addOnScrollChangedListener(this);
((AppCompatActivity)requireActivity()).setSupportActionBar(toolbar);
((AppCompatActivity)requireActivity()).setTitle(R.string.AndroidManifest__verify_safety_number);
return container;
}
@Override public void onDestroyView() {
this.scrollView.getViewTreeObserver().removeOnScrollChangedListener(this);
super.onDestroyView();
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
@ -361,6 +381,8 @@ public class VerifyIdentityActivity extends PassphraseRequiredActivity implement
animateFailureOnDraw = false;
animateVerifiedFailure();
}
ThreadUtil.postToMain(this::onScrollChanged);
}
@Override
@ -418,9 +440,11 @@ public class VerifyIdentityActivity extends PassphraseRequiredActivity implement
} else {
Toast.makeText(getActivity(), R.string.VerifyIdentityActivity_your_contact_is_running_an_old_version_of_signal, Toast.LENGTH_LONG).show();
}
this.animateFailureOnDraw = true;
} catch (Exception e) {
Log.w(TAG, e);
Toast.makeText(getActivity(), R.string.VerifyIdentityActivity_the_scanned_qr_code_is_not_a_correctly_formatted_safety_number, Toast.LENGTH_LONG).show();
this.animateFailureOnDraw = true;
}
}
@ -664,6 +688,26 @@ public class VerifyIdentityActivity extends PassphraseRequiredActivity implement
}
}
@Override public void onScrollChanged() {
if (scrollView.canScrollVertically(-1)) {
if (toolbarShadow.getVisibility() != View.VISIBLE) {
ViewUtil.fadeIn(toolbarShadow, 250);
}
} else {
if (toolbarShadow.getVisibility() != View.GONE) {
ViewUtil.fadeOut(toolbarShadow, 250);
}
}
if (scrollView.canScrollVertically(1)) {
if (bottomShadow.getVisibility() != View.VISIBLE) {
ViewUtil.fadeIn(bottomShadow, 250);
}
} else {
ViewUtil.fadeOut(bottomShadow, 250);
}
}
}
public static class VerifyScanFragment extends Fragment {
@ -723,5 +767,4 @@ public class VerifyIdentityActivity extends PassphraseRequiredActivity implement
}
}
}

Wyświetl plik

@ -1,207 +1,281 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:fillViewport="true">
<org.thoughtcrime.securesms.util.views.DarkOverflowToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="56dp"
android:theme="?attr/settingsToolbarStyle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navigationIcon="@drawable/ic_arrow_left_24"
app:titleTextAppearance="@style/Signal.Text.Title"
app:navigationContentDescription="@string/DSLSettingsToolbar__navigate_up"
tools:title="@string/AndroidManifest__verify_safety_number" />
<ScrollView
android:id="@+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:fillViewport="true"
app:layout_constraintTop_toBottomOf="@id/toolbar"
app:layout_constraintBottom_toTopOf="@id/verify_button_container">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
android:layout_height="wrap_content"
android:background="@color/signal_background_primary"
android:gravity="center_horizontal"
android:orientation="vertical"
android:layout_marginStart="36dp"
android:layout_marginEnd="36dp">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="36dp"
android:gravity="center_horizontal"
android:background="@color/signal_background_primary"
android:orientation="vertical">
<LinearLayout
android:id="@+id/qr_code_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/verify_identity_vertical_margin"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
android:background="@drawable/qr_code_background"
android:orientation="vertical">
<LinearLayout android:id="@+id/qr_code_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
android:background="@drawable/qr_code_background">
<FrameLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="36dp"
android:layout_gravity="center">
<TextView android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/verify_display_fragment__loading"
android:textSize="20sp" />
<org.thoughtcrime.securesms.components.SquareImageView
android:id="@+id/qr_code"
android:layout_width="164dp"
android:layout_height="164dp"
android:layout_gravity="center_horizontal"
android:visibility="invisible"
tools:src="@drawable/ic_about_mc_80"
tools:visibility="visible" />
<org.thoughtcrime.securesms.components.SquareImageView
android:id="@+id/qr_verified"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/ic_check_white_48dp"
android:background="@drawable/circle_tintable"
android:backgroundTint="@color/green_500"
android:visibility="gone"
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:visibility="visible"/>
</FrameLayout>
android:layout_marginTop="36dp">
<TextSwitcher android:id="@+id/tap_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="27dp"
android:inAnimation="@android:anim/fade_in"
android:outAnimation="@android:anim/fade_out">
<TextView
android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/verify_display_fragment__loading"
android:textSize="20sp" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:textColor="@color/core_grey_50"
android:textSize="11sp"
android:text="@string/verify_display_fragment__tap_to_scan"
style="@style/Signal.Text.Preview" />
<org.thoughtcrime.securesms.components.SquareImageView
android:id="@+id/qr_code"
android:layout_width="164dp"
android:layout_height="164dp"
android:layout_gravity="center_horizontal"
android:visibility="invisible"
tools:src="@drawable/ic_about_mc_80"
tools:visibility="visible" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:textColor="@color/core_grey_50"
android:textSize="11sp"
android:text="@string/verify_display_fragment__successful_match"
style="@style/Signal.Text.Preview" />
<org.thoughtcrime.securesms.components.SquareImageView
android:id="@+id/qr_verified"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:background="@drawable/circle_tintable"
android:backgroundTint="@color/green_500"
android:src="@drawable/ic_check_white_48dp"
android:visibility="gone"
tools:visibility="visible" />
</FrameLayout>
</TextSwitcher>
<TextSwitcher
android:id="@+id/tap_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="27dp"
android:inAnimation="@android:anim/fade_in"
android:outAnimation="@android:anim/fade_out">
<TextView
style="@style/Signal.Text.Preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:text="@string/verify_display_fragment__tap_to_scan"
android:textColor="@color/core_grey_50"
android:textSize="11sp" />
<TextView
style="@style/Signal.Text.Preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:text="@string/verify_display_fragment__successful_match"
android:textColor="@color/core_grey_50"
android:textSize="11sp" />
</TextSwitcher>
</LinearLayout>
<TableLayout
android:id="@+id/number_table"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/verify_identity_vertical_margin"
android:clickable="true"
android:focusable="true">
<TableRow
android:clickable="false"
android:focusable="false"
android:gravity="center_horizontal">
<TextView
android:id="@+id/code_first"
style="@style/IdentityKey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="22934" />
<TextView
android:id="@+id/code_second"
style="@style/IdentityKey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
tools:text="56944" />
<TextView
android:id="@+id/code_third"
style="@style/IdentityKey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
tools:text="42738" />
<TextView
android:id="@+id/code_fourth"
style="@style/IdentityKey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
tools:text="20038" />
</TableRow>
<TableRow android:gravity="center_horizontal">
<TextView
android:id="@+id/code_fifth"
style="@style/IdentityKey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="34431" />
<TextView
android:id="@+id/code_sixth"
style="@style/IdentityKey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
tools:text="24922" />
<TextView
android:id="@+id/code_seventh"
style="@style/IdentityKey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
tools:text="58594" />
<TextView
android:id="@+id/code_eighth"
style="@style/IdentityKey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
tools:text="24109" />
</TableRow>
<TableRow android:gravity="center_horizontal">
<TextView
android:id="@+id/code_ninth"
style="@style/IdentityKey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="00257" />
<TextView
android:id="@+id/code_tenth"
style="@style/IdentityKey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
tools:text="34956" />
<TextView
android:id="@+id/code_eleventh"
style="@style/IdentityKey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
tools:text="32440" />
<TextView
android:id="@+id/code_twelth"
style="@style/IdentityKey"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
tools:text="15774" />
</TableRow>
</TableLayout>
<TextView
android:id="@+id/description"
style="@style/TextAppearance.Signal.Body2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginTop="@dimen/verify_identity_vertical_margin"
android:layout_marginEnd="30dp"
android:gravity="center"
android:lineSpacingExtra="3sp"
android:text="@string/verify_display_fragment__to_verify_the_security_of_your_end_to_end_encryption_with_s" />
</LinearLayout>
</ScrollView>
<TableLayout android:id="@+id/number_table"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="36dp"
android:clickable="true"
android:focusable="true">
<TableRow android:gravity="center_horizontal"
android:clickable="false"
android:focusable="false">
<TextView android:id="@+id/code_first"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/IdentityKey"
tools:text="22934"/>
<TextView android:id="@+id/code_second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
style="@style/IdentityKey"
tools:text="56944"/>
<TextView android:id="@+id/code_third"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
style="@style/IdentityKey"
tools:text="42738"/>
<TextView android:id="@+id/code_fourth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
style="@style/IdentityKey"
tools:text="20038"/>
</TableRow>
<TableRow android:gravity="center_horizontal">
<TextView android:id="@+id/code_fifth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/IdentityKey"
tools:text="34431"/>
<TextView android:id="@+id/code_sixth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
style="@style/IdentityKey"
tools:text="24922"/>
<TextView android:id="@+id/code_seventh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
style="@style/IdentityKey"
tools:text="58594"/>
<TextView android:id="@+id/code_eighth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
style="@style/IdentityKey"
tools:text="24109"/>
</TableRow>
<TableRow android:gravity="center_horizontal">
<TextView android:id="@+id/code_ninth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/IdentityKey"
tools:text="00257"/>
<TextView android:id="@+id/code_tenth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
style="@style/IdentityKey"
tools:text="34956"/>
<TextView android:id="@+id/code_eleventh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
style="@style/IdentityKey"
tools:text="32440"/>
<TextView android:id="@+id/code_twelth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
style="@style/IdentityKey"
tools:text="15774"/>
</TableRow>
</TableLayout>
<TextView android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="36dp"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
android:gravity="center"
android:lineSpacingExtra="3sp"
android:text="@string/verify_display_fragment__to_verify_the_security_of_your_end_to_end_encryption_with_s"
style="@style/TextAppearance.Signal.Body2" />
<View
android:id="@+id/toolbar_shadow"
android:layout_width="match_parent"
android:layout_height="5dp"
android:visibility="gone"
android:background="@drawable/toolbar_shadow"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar"
tools:visibility="visible" />
<View
android:id="@+id/verify_identity_bottom_shadow"
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/bottom_toolbar_shadow"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/verify_button_container" />
<FrameLayout
android:id="@+id/verify_button_container"
android:layout_width="match_parent"
android:layout_height="96dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="parent">
<com.google.android.material.button.MaterialButton
android:id="@+id/verify_button"
android:layout_width="match_parent"
android:layout_height="60dp"
android:textAllCaps="false"
android:layout_marginTop="43dp"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:text="@string/verify_display_fragment__mark_as_verified"
style="@style/Signal.Widget.Button.Large.Primary"
app:backgroundTint="@color/signal_inverse_transparent_10"
android:textColor="@color/signal_accent_primary"/>
</LinearLayout>
</ScrollView>
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginStart="48dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="48dp"
android:text="@string/verify_display_fragment__mark_as_verified"
android:textAllCaps="false"
android:textColor="@color/signal_accent_primary"
app:backgroundTint="@color/signal_inverse_transparent_10" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Wyświetl plik

@ -3,6 +3,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item android:id="@+id/verify_identity__share"
android:title="@string/verify_identity__share_safety_number"
android:icon="@drawable/ic_share_white_24dp"
android:icon="@drawable/ic_share_24_tinted"
app:showAsAction="ifRoom" />
</menu>

Wyświetl plik

@ -31,4 +31,6 @@
<dimen name="avatar_picker_image_width">160dp</dimen>
<dimen name="toolbar_avatar_margin">34dp</dimen>
<dimen name="verify_identity_vertical_margin">32dp</dimen>
</resources>

Wyświetl plik

@ -203,4 +203,6 @@
<dimen name="avatar_picker_image_width">100dp</dimen>
<dimen name="toolbar_avatar_margin">26dp</dimen>
<dimen name="verify_identity_vertical_margin">16dp</dimen>
</resources>