11package org .thoughtcrime .securesms .groups .ui .creategroup ;
22
3+ import android .animation .ValueAnimator ;
34import android .content .Context ;
45import android .content .Intent ;
56import android .os .Bundle ;
67import android .util .Pair ;
78import android .view .MenuItem ;
8- import android .view .View ;
99
1010import androidx .annotation .NonNull ;
1111import androidx .annotation .Nullable ;
1212import androidx .appcompat .app .AlertDialog ;
1313
1414import com .annimon .stream .Stream ;
15+ import com .google .android .material .button .MaterialButton ;
16+ import com .google .android .material .floatingactionbutton .ExtendedFloatingActionButton ;
1517
1618import org .signal .core .util .logging .Log ;
1719import org .thoughtcrime .securesms .ContactSelectionActivity ;
2830import org .thoughtcrime .securesms .util .FeatureFlags ;
2931import org .thoughtcrime .securesms .util .Stopwatch ;
3032import org .thoughtcrime .securesms .util .TextSecurePreferences ;
33+ import org .thoughtcrime .securesms .util .ViewUtil ;
3134import org .thoughtcrime .securesms .util .concurrent .SimpleTask ;
3235import org .thoughtcrime .securesms .util .views .SimpleProgressDialog ;
3336import org .whispersystems .libsignal .util .guava .Optional ;
@@ -43,7 +46,9 @@ public class CreateGroupActivity extends ContactSelectionActivity {
4346
4447 private static final short REQUEST_CODE_ADD_DETAILS = 17275 ;
4548
46- private View next ;
49+ private ExtendedFloatingActionButton next ;
50+ private ValueAnimator padStart ;
51+ private ValueAnimator padEnd ;
4752
4853 public static Intent newIntent (@ NonNull Context context ) {
4954 Intent intent = new Intent (context , CreateGroupActivity .class );
@@ -67,6 +72,7 @@ public void onCreate(Bundle bundle, boolean ready) {
6772 getSupportActionBar ().setDisplayHomeAsUpEnabled (true );
6873
6974 next = findViewById (R .id .next );
75+ extendSkip ();
7076
7177 next .setOnClickListener (v -> handleNextPressed ());
7278 }
@@ -96,7 +102,7 @@ public boolean onBeforeContactSelected(Optional<RecipientId> recipientId, String
96102 getToolbar ().clear ();
97103 }
98104
99- enableNext ();
105+ shrinkSkip ();
100106
101107 return true ;
102108 }
@@ -106,16 +112,40 @@ public void onContactDeselected(Optional<RecipientId> recipientId, String number
106112 if (contactsFragment .hasQueryFilter ()) {
107113 getToolbar ().clear ();
108114 }
115+
116+ if (contactsFragment .getSelectedContactsCount () == 0 ) {
117+ extendSkip ();
118+ }
109119 }
110120
111- private void enableNext () {
112- next .setEnabled (true );
113- next .animate ().alpha (1f );
121+ private void extendSkip () {
122+ next .setIconGravity (MaterialButton .ICON_GRAVITY_END );
123+ next .extend ();
124+ animatePadding (24 , 18 );
114125 }
115126
116- private void disableNext () {
117- next .setEnabled (false );
118- next .animate ().alpha (0.5f );
127+ private void shrinkSkip () {
128+ next .setIconGravity (MaterialButton .ICON_GRAVITY_START );
129+ next .shrink ();
130+ animatePadding (16 , 16 );
131+ }
132+
133+ private void animatePadding (int startDp , int endDp ) {
134+ if (padStart != null ) padStart .cancel ();
135+
136+ padStart = ValueAnimator .ofInt (next .getPaddingStart (), ViewUtil .dpToPx (startDp )).setDuration (200 );
137+ padStart .addUpdateListener (animation -> {
138+ ViewUtil .setPaddingStart (next , (Integer ) animation .getAnimatedValue ());
139+ });
140+ padStart .start ();
141+
142+ if (padEnd != null ) padEnd .cancel ();
143+
144+ padEnd = ValueAnimator .ofInt (next .getPaddingEnd (), ViewUtil .dpToPx (endDp )).setDuration (200 );
145+ padEnd .addUpdateListener (animation -> {
146+ ViewUtil .setPaddingEnd (next , (Integer ) animation .getAnimatedValue ());
147+ });
148+ padEnd .start ();
119149 }
120150
121151 private void handleNextPressed () {
0 commit comments