1212import android .view .LayoutInflater ;
1313import android .view .View ;
1414import android .view .ViewGroup ;
15+ import android .view .animation .AnimationUtils ;
1516import android .widget .Toast ;
1617
1718import androidx .annotation .NonNull ;
@@ -75,22 +76,63 @@ public View onCreateView(@NonNull LayoutInflater inflater,
7576 checkStateWpp (requireActivity ());
7677
7778 binding .rebootBtn .setOnClickListener (view -> {
79+ animateClick (view );
7880 App .getInstance ().restartApp (FeatureLoader .PACKAGE_WPP );
7981 disableWpp (requireActivity ());
8082 });
8183
8284 binding .rebootBtn2 .setOnClickListener (view -> {
85+ animateClick (view );
8386 App .getInstance ().restartApp (FeatureLoader .PACKAGE_BUSINESS );
8487 disableBusiness (requireActivity ());
8588 });
8689
87- binding .exportBtn .setOnClickListener (view -> saveConfigs (this .getContext ()));
88- binding .importBtn .setOnClickListener (view -> importConfigs (this .getContext ()));
89- binding .resetBtn .setOnClickListener (view -> resetConfigs (this .getContext ()));
90+ binding .exportBtn .setOnClickListener (view -> {
91+ animateClick (view );
92+ saveConfigs (this .getContext ());
93+ });
94+
95+ binding .importBtn .setOnClickListener (view -> {
96+ animateClick (view );
97+ importConfigs (this .getContext ());
98+ });
99+
100+ binding .resetBtn .setOnClickListener (view -> {
101+ animateClick (view );
102+ resetConfigs (this .getContext ());
103+ });
104+
105+ startCardAnimations ();
90106
91107 return binding .getRoot ();
92108 }
93109
110+ private void startCardAnimations () {
111+ var slideUp = AnimationUtils .loadAnimation (getContext (), R .anim .slide_up );
112+ var fadeIn = AnimationUtils .loadAnimation (getContext (), R .anim .fade_in );
113+
114+ binding .status .startAnimation (slideUp );
115+
116+ binding .status2 .postDelayed (() -> {
117+ var anim = AnimationUtils .loadAnimation (getContext (), R .anim .slide_up );
118+ binding .status2 .startAnimation (anim );
119+ }, 100 );
120+
121+ binding .status3 .postDelayed (() -> {
122+ var anim = AnimationUtils .loadAnimation (getContext (), R .anim .slide_up );
123+ binding .status3 .startAnimation (anim );
124+ }, 200 );
125+
126+ binding .infoCard .postDelayed (() -> {
127+ binding .infoCard .startAnimation (fadeIn );
128+ }, 300 );
129+ }
130+
131+ private void animateClick (View view ) {
132+ var scaleIn = AnimationUtils .loadAnimation (getContext (), R .anim .scale_in );
133+ view .startAnimation (scaleIn );
134+ }
135+
94136 @ Override
95137 public void onResume () {
96138 super .onResume ();
@@ -104,10 +146,10 @@ private void receiverBroadcastBusiness(Context context, Intent intent) {
104146 var supported_list = Arrays .asList (context .getResources ().getStringArray (R .array .supported_versions_business ));
105147 if (version != null && supported_list .stream ().anyMatch (s -> version .startsWith (s .replace (".xx" , "" )))) {
106148 binding .statusSummary3 .setText (getString (R .string .version_s , version ));
107- binding .status3 .setCardBackgroundColor ( context . getColor (R .color . material_state_green ) );
149+ binding .status3 .getChildAt ( 0 ). setBackgroundResource (R .drawable . gradient_success );
108150 } else {
109151 binding .statusSummary3 .setText (getString (R .string .version_s_not_listed , version ));
110- binding .status3 .setCardBackgroundColor ( context . getColor (R .color . material_state_yellow ) );
152+ binding .status3 .getChildAt ( 0 ). setBackgroundResource (R .drawable . gradient_warning );
111153 }
112154 binding .rebootBtn2 .setVisibility (View .VISIBLE );
113155 binding .statusSummary3 .setVisibility (View .VISIBLE );
@@ -122,10 +164,10 @@ private void receiverBroadcastWpp(Context context, Intent intent) {
122164
123165 if (version != null && supported_list .stream ().anyMatch (s -> version .startsWith (s .replace (".xx" , "" )))) {
124166 binding .statusSummary1 .setText (getString (R .string .version_s , version ));
125- binding .status2 .setCardBackgroundColor ( context . getColor (R .color . material_state_green ) );
167+ binding .status2 .getChildAt ( 0 ). setBackgroundResource (R .drawable . gradient_success );
126168 } else {
127169 binding .statusSummary1 .setText (getString (R .string .version_s_not_listed , version ));
128- binding .status2 .setCardBackgroundColor ( context . getColor (R .color . material_state_yellow ) );
170+ binding .status2 .getChildAt ( 0 ). setBackgroundResource (R .drawable . gradient_warning );
129171 }
130172 binding .rebootBtn .setVisibility (View .VISIBLE );
131173 binding .statusSummary1 .setVisibility (View .VISIBLE );
@@ -232,11 +274,11 @@ private void checkStateWpp(FragmentActivity activity) {
232274 binding .statusIcon .setImageResource (R .drawable .ic_round_check_circle_24 );
233275 binding .statusTitle .setText (R .string .module_enabled );
234276 binding .statusSummary .setText (String .format (getString (R .string .version_s ), BuildConfig .VERSION_NAME ));
235- binding .status .setCardBackgroundColor ( activity . getColor (R .color . material_state_green ) );
277+ binding .status .getChildAt ( 0 ). setBackgroundResource (R .drawable . gradient_success );
236278 } else {
237279 binding .statusIcon .setImageResource (R .drawable .ic_round_error_outline_24 );
238280 binding .statusTitle .setText (R .string .module_disabled );
239- binding .status .setCardBackgroundColor ( activity . getColor (R .color . material_state_red ) );
281+ binding .status .getChildAt ( 0 ). setBackgroundResource (R .drawable . gradient_error );
240282 binding .statusSummary .setVisibility (View .GONE );
241283 }
242284 if (isInstalled (FeatureLoader .PACKAGE_WPP ) && App .isOriginalPackage ()) {
@@ -275,15 +317,15 @@ private boolean isInstalled(String packageWpp) {
275317 private void disableBusiness (FragmentActivity activity ) {
276318 binding .statusIcon3 .setImageResource (R .drawable .ic_round_error_outline_24 );
277319 binding .statusTitle3 .setText (R .string .business_is_not_running_or_has_not_been_activated_in_lsposed );
278- binding .status3 .setCardBackgroundColor ( activity . getColor (R .color . material_state_red ) );
320+ binding .status3 .getChildAt ( 0 ). setBackgroundResource (R .drawable . gradient_error );
279321 binding .statusSummary3 .setVisibility (View .GONE );
280322 binding .rebootBtn2 .setVisibility (View .GONE );
281323 }
282324
283325 private void disableWpp (FragmentActivity activity ) {
284326 binding .statusIcon2 .setImageResource (R .drawable .ic_round_error_outline_24 );
285327 binding .statusTitle2 .setText (R .string .whatsapp_is_not_running_or_has_not_been_activated_in_lsposed );
286- binding .status2 .setCardBackgroundColor ( activity . getColor (R .color . material_state_red ) );
328+ binding .status2 .getChildAt ( 0 ). setBackgroundResource (R .drawable . gradient_error );
287329 binding .statusSummary1 .setVisibility (View .GONE );
288330 binding .rebootBtn .setVisibility (View .GONE );
289331 }
0 commit comments