diff options
author | cyberta <cyberta@riseup.net> | 2022-12-02 02:18:48 +0100 |
---|---|---|
committer | cyberta <cyberta@riseup.net> | 2022-12-02 20:25:19 +0100 |
commit | 33bae6bada5aadc3ab3919fa04233d2d916e5721 (patch) | |
tree | 06e999d0b8be3286a10e8c4e920674972c4ab734 /app | |
parent | 5afe57ab868ee9e2e27f5b26b9b14de3519c0402 (diff) |
implement connecting animation for riseup
Diffstat (limited to 'app')
-rw-r--r-- | app/src/custom/res/animator/alpha1.xml | 11 | ||||
-rw-r--r-- | app/src/custom/res/animator/alpha2.xml | 16 | ||||
-rw-r--r-- | app/src/custom/res/animator/alpha3.xml | 11 | ||||
-rw-r--r-- | app/src/custom/res/drawable/ravens.xml | 6 | ||||
-rw-r--r-- | app/src/custom/res/drawable/state_connecting.xml | 17 | ||||
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java | 54 |
6 files changed, 85 insertions, 30 deletions
diff --git a/app/src/custom/res/animator/alpha1.xml b/app/src/custom/res/animator/alpha1.xml new file mode 100644 index 00000000..94192a0b --- /dev/null +++ b/app/src/custom/res/animator/alpha1.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<set xmlns:android="http://schemas.android.com/apk/res/android"> + <objectAnimator + android:duration="1000" + android:propertyName="fillColor" + android:valueFrom="#00000000" + android:valueTo="#000000" + android:valueType="colorType" + /> +</set> + diff --git a/app/src/custom/res/animator/alpha2.xml b/app/src/custom/res/animator/alpha2.xml index bf997dea..b66ef59c 100644 --- a/app/src/custom/res/animator/alpha2.xml +++ b/app/src/custom/res/animator/alpha2.xml @@ -1,10 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <objectAnimator - android:propertyName="fillAlpha" - android:valueFrom="0" - android:valueTo="1" - android:startOffset="200" - android:duration="250" - android:interpolator="@android:interpolator/linear" /> -</set>
\ No newline at end of file + android:duration="1000" + android:propertyName="fillColor" + android:valueFrom="#00000000" + android:valueTo="#000000" + android:startOffset="1000" + android:valueType="colorType" + /> +</set> + diff --git a/app/src/custom/res/animator/alpha3.xml b/app/src/custom/res/animator/alpha3.xml index d05f36c2..2a1e0ba4 100644 --- a/app/src/custom/res/animator/alpha3.xml +++ b/app/src/custom/res/animator/alpha3.xml @@ -1,4 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> - -</set>
\ No newline at end of file + <objectAnimator + android:duration="1000" + android:propertyName="fillColor" + android:valueFrom="#00000000" + android:valueTo="#000000" + android:valueType="colorType" + android:startOffset="2000" + /> +</set> diff --git a/app/src/custom/res/drawable/ravens.xml b/app/src/custom/res/drawable/ravens.xml index f97a3532..788aef84 100644 --- a/app/src/custom/res/drawable/ravens.xml +++ b/app/src/custom/res/drawable/ravens.xml @@ -4,29 +4,35 @@ android:width="342dp" android:height="206dp"> <group + android:name="raven1" android:scaleX="0.8" android:scaleY="0.8" android:translateX="-224.2934" android:translateY="11.72371"> <path + android:name="raven1path" android:pathData="M385.13834 197.43106c-0.72897 -1.36208 -0.61597 -2.15071 0.51401 -3.58724l1.0109 -1.28515 -2.7045 -3.53096c-1.67306 -2.18432 -3.16903 -3.64755 -3.92253 -3.83667 -0.78962 -0.19818 -1.46242 -0.8906 -1.91284 -1.96862 -0.78944 -1.88939 -0.68998 -1.87306 -7.21616 -1.18532 -3.17774 0.33487 -5.21281 0.85767 -7.44 1.9113 -3.28857 1.55574 -5.44061 1.80404 -6.78577 0.78292 -1.02537 -0.77836 -1.06491 -1.42761 -0.13401 -2.20019 0.38829 -0.32225 0.65829 -1.03611 0.6 -1.58634 -0.0805 -0.75951 0.24078 -1.07485 1.33401 -1.3095 0.792 -0.17 1.87322 -0.54195 2.40272 -0.82656 0.66764 -0.35886 1.7028 -0.37114 3.37723 -0.0401 3.1702 0.62683 7.16506 -0.46946 9.11061 -2.50018 0.98579 -1.02893 1.81957 -1.42897 2.97837 -1.42897 0.88512 0 2.4561 -0.432 3.49107 -0.96 1.03497 -0.528 2.21436 -0.96 2.62088 -0.96 0.40651 0 0.73912 -0.30839 0.73912 -0.68532 0 -0.54071 -0.53763 -0.62982 -2.54805 -0.42233 -3.2514 0.33557 -4.17195 -0.44353 -4.17195 -3.53092 0 -1.44319 -0.32154 -2.57878 -0.96 -3.39045 -0.528 -0.67124 -0.96 -1.49047 -0.96 -1.8205 0 -0.33004 -0.54 -0.95389 -1.2 -1.38634 -0.7646 -0.50098 -1.2 -1.23373 -1.2 -2.01949 0 -0.67827 -0.432 -1.78243 -0.96 -2.45367 -0.528 -0.67124 -0.96 -1.5865 -0.96 -2.03391 0 -0.44741 -1.15388 -2.09228 -2.56419 -3.65527 -2.97648 -3.29873 -3.67581 -4.47263 -3.67581 -6.17024 0 -1.04577 -0.21517 -1.23156 -1.42631 -1.23156 -0.78448 0 -2.67448 -0.56194 -4.2 -1.24877 -3.87341 -1.74389 -9.21645 -3.55123 -10.49851 -3.55123 -1.57962 0 -2.59518 -0.491 -2.59518 -1.2547 0 -0.53914 0.68803 -0.61839 3.48 -0.40086 3.2635 0.25428 3.40535 0.22572 2.28 -0.45912 -0.66 -0.40165 -2.226 -0.87399 -3.48 -1.04964 -2.96604 -0.41545 -2.93747 -1.15568 0.0446 -1.15568 1.92868 0 9.64234 2.10373 13.15539 3.58785 0.50332 0.21263 0.84 0.14513 0.84 -0.16841 0 -0.28779 -1.13158 -1.09668 -2.51463 -1.79753 -2.92533 -1.48238 -12.13912 -7.58751 -12.61637 -8.35971 -1.35099 -2.18595 3.01241 -0.0675 12.14639 5.89721 3.24247 2.1174 6.04388 3.70133 6.22536 3.51984 0.18149 -0.18148 -0.38708 -0.89116 -1.26349 -1.57704 -2.20209 -1.7234 -10.13726 -10.73208 -10.13726 -11.50869 0 -1.14242 0.85579 -0.66795 2.72266 1.5095 2.27855 2.65762 9.24491 8.66726 13.01433 11.22703 2.8929 1.96453 11.64578 6.78995 12.31636 6.78995 0.20542 0 0.23167 -0.756 0.0583 -1.68 -0.22647 -1.20719 -0.14019 -1.69436 0.30658 -1.73102 0.34197 -0.0281 1.03481 -0.0821 1.53965 -0.12 1.86068 -0.13982 1.16626 -1.06327 -1.60872 -2.13929 -1.56874 -0.6083 -3.78307 -1.85532 -4.92072 -2.77115 -1.13765 -0.91584 -3.09446 -2.43544 -4.34846 -3.37688 -4.34658 -3.2632 -1.75366 -4.17202 3.18156 -1.11514 2.26983 1.40594 3.91431 1.53202 1.97844 0.15169 -6.31808 -4.50497 -6.96 -5.05256 -6.96 -5.93721 0 -0.52855 0.11494 -0.961 0.25542 -0.961 0.78964 0 4.15067 1.74166 8.39825 4.35188 2.65524 1.63171 4.93892 2.85554 5.07483 2.71963 0.13591 -0.13592 -1.94842 -2.37661 -4.63184 -4.97931 -5.53891 -5.37229 -7.03228 -7.22857 -6.35791 -7.90295 0.56718 -0.56718 1.61175 0.22173 8.939 6.7512 3.12276 2.78275 5.93076 5.14466 6.24 5.24868 0.30924 0.10402 -1.50978 -1.95528 -4.04226 -4.57623 -4.62994 -4.79166 -7.54368 -8.5847 -7.00693 -9.12146 0.15897 -0.15897 2.25393 1.41143 4.65545 3.48976 4.14801 3.58979 5.79244 4.76276 5.09498 3.63424 -0.17306 -0.28001 -0.11466 -0.6327 0.12976 -0.78376 0.64416 -0.39811 17.86024 17.63295 19.07981 19.98301 1.60753 3.09765 1.75025 5.81492 0.61158 11.64343 -0.65753 3.36572 -0.90221 5.90827 -0.699 7.26344 0.29317 1.95498 0.42327 2.10307 2.08577 2.37409 0.9752 0.15898 2.42109 0.39924 3.21309 0.5339 5.1256 0.87155 13.65736 4.80211 12.94067 5.96174 -0.15253 0.24679 -1.93858 0.44985 -3.969 0.45124 -3.88293 0.003 -3.90932 0.0128 -8.39867 3.23101 -1.6107 1.15463 -3.37986 1.81494 -6.89008 2.5716 -4.81503 1.03793 -7.97908 2.51326 -12.88292 6.00704 -4.80978 3.42677 -4.95621 3.84823 -2.4 6.90782 2.66507 3.18989 2.14762 5.66217 -1.51355 7.23153 -2.68358 1.15032 -2.89394 1.15032 -3.50956 0.00003zm4.78311 -5.20219c0 -0.57904 -2.89719 -3.94937 -3.39495 -3.94937 -0.77051 0 -0.49203 0.68428 1.0299 2.53064 1.38291 1.67772 2.36505 2.26687 2.36505 1.41873z" android:fillColor="#000000" /> </group> <group + android:name="raven3" android:scaleX="0.8" android:scaleY="0.8" android:translateX="-77.92102" android:translateY="-54.82651"> <path + android:name="raven3path" android:pathData="M447.80204 216.9559c-0.72269 -0.39213 -1.64623 -1.35548 -2.05233 -2.14078 -0.92258 -1.78409 -1.47725 -1.82526 -1.45263 -0.10784 0.0256 1.78611 -1.56103 1.9993 -3.05379 0.41034 -0.92579 -0.98546 -1.26967 -1.09461 -2.00395 -0.63604 -0.71993 0.4496 -1.15887 0.3521 -2.33731 -0.51916 -1.20317 -0.88954 -1.60809 -0.97455 -2.37139 -0.49787 -0.73689 0.4602 -1.14575 0.42723 -2.0501 -0.16532 -0.64725 -0.42409 -1.74409 -0.64998 -2.56857 -0.52897 -1.09407 0.16058 -1.71749 -0.0853 -2.60113 -1.02589 -0.6392 -0.6804 -1.5772 -1.23709 -2.08445 -1.23709 -0.50725 0 -1.49559 -0.32252 -2.19633 -0.71671 -0.70073 -0.39419 -1.81406 -0.93368 -2.47406 -1.19885 -0.66 -0.26518 -1.524 -0.66225 -1.92 -0.88239 -2.1004 -1.1676 -3.9862 -2.00205 -4.5245 -2.00205 -0.33369 0 -0.99766 -0.432 -1.4755 -0.96 -0.47783 -0.528 -1.16856 -0.96 -1.53495 -0.96 -0.77161 0 -6.74173 -3.13454 -7.86284 -4.12828 -0.89689 -0.79501 -2.53748 -0.86858 -3.83877 -0.17215 -0.51341 0.27477 -1.88229 2.38077 -3.04196 4.68 -1.15968 2.29924 -2.72649 4.76604 -3.4818 5.48179 -1.40184 1.32842 -5.12659 2.93173 -5.63342 2.4249 -0.1543 -0.15429 -1.70398 -0.32663 -3.44374 -0.38296 -2.32752 -0.0754 -3.51734 -0.36424 -4.50361 -1.09342 -0.81562 -0.60301 -1.73721 -0.88722 -2.35394 -0.72594 -1.35459 0.35423 -3.92189 -0.18553 -5.09262 -1.0707 -0.66178 -0.50036 -0.98915 -1.4008 -1.08522 -2.98487 -0.0757 -1.2476 -0.25951 -4.04558 -0.40856 -6.21772 -0.25931 -3.77896 -0.21836 -3.99814 0.94896 -5.07999 1.35121 -1.25225 4.13171 -1.97137 10.61247 -2.74472 5.3395 -0.63715 6.25903 -0.85126 8.52 -1.98381 1.76578 -0.8845 2.45969 -2.32213 1.12084 -2.32213 -0.37355 0 -1.5596 -1.134 -2.63568 -2.52 -2.13022 -2.74373 -2.50653 -3.16958 -3.62217 -4.09893 -0.40864 -0.3404 -0.74299 -1.12556 -0.74299 -1.74479 0 -0.67126 -0.48454 -1.44336 -1.2 -1.91214 -0.66 -0.43245 -1.2 -1.23621 -1.2 -1.78612 0 -0.54992 -0.54 -1.42462 -1.2 -1.94378 -0.66 -0.51916 -1.2 -1.34367 -1.2 -1.83225 0 -0.48859 -0.54 -1.53009 -1.2 -2.31445 -0.66 -0.78437 -1.2 -1.85934 -1.2 -2.38883 0 -0.52949 -0.756 -1.71871 -1.68 -2.64271 -0.924 -0.924 -1.68 -2.09595 -1.68 -2.60433 0 -0.50838 -0.55232 -1.44321 -1.22738 -2.07739 -0.81219 -0.76302 -1.14213 -1.47902 -0.97538 -2.11669 0.17148 -0.65575 -0.2374 -1.46856 -1.27973 -2.54398 -1.31288 -1.35454 -1.4494 -1.71218 -0.95549 -2.50306 0.48388 -0.77482 0.38564 -1.14926 -0.61288 -2.33593 -1.29697 -1.54136 -1.48117 -2.47059 -0.65374 -3.29802 0.39386 -0.39386 0.19307 -0.98422 -0.75958 -2.2332 -0.88414 -1.15917 -1.19604 -2.00954 -0.98311 -2.68042 0.2246 -0.70765 -0.16728 -1.56735 -1.40042 -3.07223 -2.52054 -3.076 -2.28628 -3.69399 0.92771 -2.44729 0.528 0.20481 -0.498 -1.15368 -2.28 -3.01887 -2.97172 -3.11045 -3.98593 -4.92459 -2.75312 -4.92459 0.26778 0 2.38692 1.48253 4.7092 3.29452 6.33422 4.94234 8.3162 5.80749 3.95158 1.7249 -4.36141 -4.07959 -8.0677 -9.81942 -6.34054 -9.81942 0.28116 0 2.49842 2.05416 4.92723 4.5648 2.42882 2.51065 4.49954 4.48131 4.60161 4.37925 0.10205 -0.10206 -0.98133 -1.73668 -2.40752 -3.63249 -1.42619 -1.89581 -2.85494 -4.32096 -3.17499 -5.38921 -0.32005 -1.06825 -0.69762 -2.24379 -0.83904 -2.61231 -0.72243 -1.88264 1.03187 -0.1508 4.3051 4.24996 2.01269 2.706 4.67913 5.892 5.92543 7.08l2.266 2.16 -1.79464 -2.4c-2.2233 -2.97326 -4.5686 -7.73418 -4.94128 -10.03072 -0.44513 -2.74301 0.50313 -2.04466 2.37988 1.75269 1.66581 3.37055 8.26211 12.81454 9.47338 13.56314 0.32795 0.20269 0.50635 0.17645 0.39644 -0.0583 -0.1099 -0.23474 -1.00191 -2.04072 -1.98227 -4.01327 -0.98034 -1.97255 -1.78245 -3.86255 -1.78245 -4.2 0 -1.51072 0.98617 -0.31134 2.75157 3.34646 2.25366 4.66945 5.11203 8.56401 10.59899 14.44126 4.9305 5.28122 8.54604 10.06515 10.94256 14.47874 6.17495 11.37222 8.31949 13.01948 14.29789 10.98244 2.27587 -0.77547 3.24479 -0.75419 9.27398 0.20364 2.25404 0.35809 4.45501 1.59731 4.45501 2.50832 0 0.19008 -0.60035 0.46567 -1.3341 0.61242 -0.73377 0.14675 -1.86777 0.78823 -2.52 1.42549 -1.81377 1.77213 -5.26658 5.9971 -5.26039 6.43677 0.006 0.39975 0.80419 0.80728 7.34031 3.74603 4.42236 1.98837 8.73868 4.82625 10.41418 6.84709 2.22226 2.68029 9.70388 8.73695 12.42297 10.05689 2.10404 1.02137 2.46767 1.34537 1.65388 1.47363 -0.57373 0.0904 -1.97773 -0.30571 -3.12 -0.88029l-2.07685 -1.04469 1.3513 1.43507c0.74321 0.78928 2.79521 2.15598 4.56 3.03711 2.62921 1.31274 3.00331 1.63456 2.07139 1.78197 -0.62552 0.099 -2.40778 -0.44981 -3.96059 -1.21945 -2.26132 -1.12081 -2.65597 -1.21281 -1.9827 -0.4622 0.46233 0.51543 1.9746 1.57936 3.3606 2.36428 1.386 0.78492 2.52 1.65077 2.52 1.92411 0 0.83627 -3.35317 0.0235 -5.34728 -1.29618 -2.37621 -1.5725 -2.35309 -0.95606 0.0673 1.79363 2.28368 2.59439 2.44317 3.37594 0.6 2.94004 -1.49775 -0.3542 -4.44 -2.40221 -4.44 -3.09054 0 -0.25057 -0.23446 -0.45558 -0.52103 -0.45558 -0.28658 0 0.0374 0.99921 0.72 2.22046 0.68257 1.22125 1.24103 2.40925 1.24103 2.64 0 0.63619 -1.52046 0.46767 -2.99396 -0.33184z" android:fillColor="#000000" /> </group> <group + android:name="raven2" android:scaleX="0.8" android:scaleY="0.8" android:translateX="-14.21506" android:translateY="22.70211"> <path + android:name="raven2path" android:pathData="M242.17687 151.65225c-1.74028 -2.28162 -2.178 -4.03768 -2.178 -8.73776 0 -2.17974 -0.18432 -3.96317 -0.4096 -3.96317 -0.22529 0 -0.71129 2.81516 -1.08 6.25591 -0.36872 3.44074 -0.8864 6.28072 -1.1504 6.31105 -1.04841 0.12049 -2.28619 -3.10071 -2.57984 -6.71376l-0.30016 -3.6932 -1.07056 1.81145c-2.08936 3.5353 -3.47008 2.84679 -3.48209 -1.73638 -0.006 -2.37601 -0.1508 -2.84246 -0.94546 -3.05027 -0.61539 -0.16092 -1.21919 -1.09153 -1.75512 -2.70506 -0.44935 -1.35286 -1.32319 -2.85792 -1.94188 -3.34458 -0.78894 -0.62057 -1.12489 -1.37616 -1.12489 -2.53 0 -2.06355 -0.60376 -2.09129 -1.85358 -0.0852 -1.18439 1.90109 -2.71192 2.89912 -3.87313 2.53057 -0.64166 -0.20366 -1.0246 0.1062 -1.47495 1.19345 -0.7302 1.76286 -2.63143 3.35598 -4.00504 3.35598 -0.54848 0 -1.46581 0.58765 -2.03851 1.30588 -0.89827 1.12654 -1.14794 1.21735 -1.81803 0.66123 -0.42722 -0.35456 -0.77543 -1.32021 -0.7738 -2.14588 0.003 -1.54988 0.31834 -2.30174 2.59201 -6.18123 2.37785 -4.05724 0.51183 -2.41446 -2.48575 2.18836 -3.12365 4.79641 -4.09991 5.87182 -4.88819 5.38464 -1.17655 -0.72715 -0.0446 -4.77763 2.18334 -7.813 1.22554 -1.66965 0.0938 -1.27585 -1.72437 0.6 -2.65534 2.73963 -4.34104 1.74204 -2.45575 -1.4533 0.93339 -1.58198 0.94531 -1.72299 0.1698 -2.00903 -1.26447 -0.4664 -1.46738 -1.03369 -1.04291 -2.91573 0.30278 -1.34248 0.21909 -1.84412 -0.38085 -2.28281 -0.75536 -0.55233 -0.9059 -1.41732 -1.24948 -7.17913 -0.20592 -3.45317 -1.35998 -10.32002 -1.73441 -10.31993 -0.14652 0.00003 -3.1824 0.88931 -6.7464 1.97616 -3.564 1.08684 -6.8656 2.086 -7.33688 2.22033 -0.47128 0.13433 -2.09128 -0.15192 -3.6 -0.63611 -1.50872 -0.48419 -3.01312 -0.8259 -3.34312 -0.75935 -1.2262 0.24726 -0.53956 -1.304 1.32139 -2.98524 1.05676 -0.95472 2.08554 -1.73586 2.28617 -1.73586 0.20064 0 0.57802 -0.486 0.83862 -1.08 0.54254 -1.23661 2.67944 -1.701199 8.15382 -1.772749 5.57725 -0.0729 9.57243 -1.17346 13.90516 -3.83049 4.52997 -2.77799 15.85234 -6.751008 22.57484 -7.921507 2.65339 -0.462 7.19029 -0.754493 11.76 -0.758165 7.33879 -0.0059 7.50857 0.01795 12.48 1.754669 4.64388 1.622275 7.89361 3.607435 7.55725 4.616496 -0.0759 0.227717 -1.8631 0.454018 -3.97155 0.502891 -3.40039 0.07882 -4.27825 0.305799 -7.76936 2.008856 -2.16469 1.056 -3.93825 2.136 -3.94123 2.4 -0.003 0.264 0.9368 1.1895 2.0884 2.056649 1.1516 0.86716 2.32074 2.16316 2.59809 2.88 0.61481 1.58903 2.47015 14.53738 2.49976 17.44571 0.0373 3.66931 1.70932 11.11002 3.22173 14.33764 1.81937 3.88271 1.28959 4.93466 -1.08652 2.15745 -0.90229 -1.05459 -1.64863 -1.65817 -1.65854 -1.34126 -0.0271 0.86542 3.28286 9.82211 4.07847 11.03636 0.38106 0.58156 0.50275 1.17487 0.27043 1.31845 -0.59625 0.3685 -3.42187 -2.90311 -4.8461 -5.611 -0.65955 -1.254 -1.36566 -2.28 -1.56915 -2.28 -0.40909 0 -0.35407 0.31827 1.09899 6.35685 1.05557 4.3867 0.95137 5.67912 -0.36978 4.58646 -0.90254 -0.74644 -2.98958 -5.08951 -2.9962 -6.23498 -0.002 -0.44642 -0.2554 -0.96662 -0.56182 -1.156 -0.41664 -0.2575 -0.47655 0.88529 -0.23759 4.53167 0.18049 2.75413 0.13441 4.876 -0.1059 4.876 -0.23399 0 -1.00861 -0.76458 -1.72138 -1.69907z" android:fillColor="#000000" /> </group> diff --git a/app/src/custom/res/drawable/state_connecting.xml b/app/src/custom/res/drawable/state_connecting.xml index 3ef89983..267ba791 100644 --- a/app/src/custom/res/drawable/state_connecting.xml +++ b/app/src/custom/res/drawable/state_connecting.xml @@ -1,4 +1,15 @@ <?xml version="1.0" encoding="utf-8"?> -<selector xmlns:android="http://schemas.android.com/apk/res/android"> - -</selector>
\ No newline at end of file +<animated-vector xmlns:android="http://schemas.android.com/apk/res/android" + android:drawable="@drawable/ravens" + > + <target + android:animation="@animator/alpha1" + android:name="raven1path"/> + <target + android:animation="@animator/alpha2" + android:name="raven2path"/> + <target + android:animation="@animator/alpha3" + android:name="raven3path"/> + +</animated-vector>
\ No newline at end of file diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java index 0210077c..81a9f9eb 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java @@ -41,6 +41,7 @@ import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.content.SharedPreferences; +import android.graphics.drawable.Animatable; import android.os.Bundle; import android.os.IBinder; import android.text.Spannable; @@ -53,11 +54,11 @@ import android.view.View; import android.view.ViewGroup; import androidx.annotation.ColorRes; +import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.AppCompatImageView; import androidx.appcompat.widget.AppCompatTextView; -import androidx.core.content.ContextCompat; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; @@ -468,8 +469,8 @@ public class EipFragment extends Fragment implements Observer { } else { subDescription.setText(getString(R.string.updating_certificate_message)); } - background.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.bg_connecting)); - stateView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.yellow_mask)); + background.setImageResource(R.drawable.bg_connecting); + animateState(R.drawable.state_connecting); mainButton.updateState(false, true, false); setActivityBarColor(R.color.bg_connecting_top, R.color.bg_connecting_top_light_transparent); } else if (eipStatus.isConnecting()) { @@ -484,8 +485,8 @@ public class EipFragment extends Fragment implements Observer { locationButton.showRecommendedIndicator(false); mainDescription.setText(R.string.eip_status_connecting); subDescription.setText(null); - background.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.bg_connecting)); - stateView.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.yellow_mask)); + background.setImageResource(R.drawable.bg_connecting); + animateState(R.drawable.state_connecting); mainButton.updateState(false, true, false); setActivityBarColor(R.color.bg_connecting_top, R.color.bg_connecting_top_light_transparent); } else if (eipStatus.isConnected()) { @@ -498,8 +499,8 @@ public class EipFragment extends Fragment implements Observer { locationButton.showRecommendedIndicator(getPreferredCity(getContext()) == null); mainDescription.setText(R.string.eip_status_secured); subDescription.setText(null); - background.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.bg_connected)); - stateView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.green_mask)); + background.setImageResource(R.drawable.bg_connected); + animateState(R.drawable.state_connected); setActivityBarColor(R.color.bg_running_top, R.color.bg_running_top_light_transparent); } else if(isOpenVpnRunningWithoutNetwork()) { Log.d(TAG, "eip fragment eipStatus - isOpenVpnRunningWithoutNetwork"); @@ -511,8 +512,8 @@ public class EipFragment extends Fragment implements Observer { locationButton.showRecommendedIndicator(getPreferredCity(getContext())== null); mainDescription.setText(R.string.eip_state_connected); subDescription.setText(R.string.eip_state_no_network); - background.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.bg_connecting)); - stateView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.yellow_mask)); + background.setImageResource(R.drawable.bg_connecting); + animateState(R.drawable.state_connecting); setActivityBarColor(R.color.bg_connecting_top, R.color.bg_connecting_top_light_transparent); } else if (eipStatus.isDisconnected() && reconnectingWithDifferentGateway()) { locationButton.setText(VpnStatus.getCurrentlyConnectingVpnName()); @@ -521,16 +522,15 @@ public class EipFragment extends Fragment implements Observer { locationButton.showRecommendedIndicator(false); mainDescription.setText(R.string.eip_status_connecting); subDescription.setText(R.string.reconnecting); - background.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.bg_connecting)); - stateView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.yellow_mask)); + background.setImageResource(R.drawable.bg_connecting); + animateState(R.drawable.state_connecting); setActivityBarColor(R.color.bg_connecting_top, R.color.bg_connecting_top_light_transparent); - } else if (eipStatus.isDisconnecting()) { setMainButtonEnabled(false); - background.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.bg_disconnected)); - stateView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.red_mask)); mainButton.updateState(false, false, false); mainDescription.setText(R.string.eip_status_unsecured); + background.setImageResource(R.drawable.bg_disconnected); + animateState(R.drawable.state_disconnected); setActivityBarColor(R.color.bg_disconnected_top, R.color.bg_disconnected_top_light_transparent); } else if (eipStatus.isBlocking()) { setMainButtonEnabled(true); @@ -541,8 +541,8 @@ public class EipFragment extends Fragment implements Observer { locationButton.showRecommendedIndicator(false); mainDescription.setText(R.string.eip_state_connected); subDescription.setText(getString(R.string.eip_state_blocking, getString(R.string.app_name))); - background.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.bg_disconnected)); - stateView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.red_mask)); + background.setImageResource(R.drawable.bg_disconnected); + animateState(R.drawable.state_disconnected); setActivityBarColor(R.color.bg_disconnected_top, R.color.bg_disconnected_top_light_transparent); } else { locationButton.setText(getContext().getString(R.string.vpn_button_turn_on)); @@ -555,12 +555,30 @@ public class EipFragment extends Fragment implements Observer { locationButton.showRecommendedIndicator(false); mainDescription.setText(R.string.eip_status_unsecured); subDescription.setText(null); - background.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.bg_disconnected)); - stateView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.red_mask)); + background.setImageResource(R.drawable.bg_disconnected); + animateState(R.drawable.state_disconnected); setActivityBarColor(R.color.bg_disconnected_top, R.color.bg_disconnected_top_light_transparent); } } + private void animateState(@DrawableRes int drawableRes) { + try { + int lastDrawableId = (int) stateView.getTag(); + if (lastDrawableId == drawableRes) { + return; + } + } catch (NullPointerException | ClassCastException e) { + // eat me + } + + stateView.setImageResource(drawableRes); + stateView.setTag(drawableRes); + if (stateView.getDrawable() instanceof Animatable) { + Animatable animatedDrawable = (Animatable) stateView.getDrawable(); + animatedDrawable.start(); + } + } + private boolean isOpenVpnRunningWithoutNetwork() { boolean isRunning = false; try { |