11
11
import android .view .ViewTreeObserver ;
12
12
import android .widget .FrameLayout ;
13
13
import android .widget .ImageButton ;
14
+ import android .widget .ImageView ;
14
15
import android .widget .ScrollView ;
15
16
import android .widget .TextView ;
16
17
18
+ import org .joinmastodon .android .GlobalUserPreferences ;
17
19
import org .joinmastodon .android .R ;
18
20
import org .joinmastodon .android .fragments .BaseStatusListFragment ;
19
21
import org .joinmastodon .android .model .Attachment ;
22
24
23
25
import me .grishka .appkit .imageloader .requests .UrlImageLoaderRequest ;
24
26
import me .grishka .appkit .utils .CubicBezierInterpolator ;
27
+ import me .grishka .appkit .utils .V ;
25
28
26
29
public class PhotoStatusDisplayItem extends ImageStatusDisplayItem {
27
30
public PhotoStatusDisplayItem (String parentID , Status status , Attachment photo , BaseStatusListFragment parentFragment , int index , int totalPhotos , PhotoLayoutHelper .TiledLayoutResult tiledLayout , PhotoLayoutHelper .TiledLayoutResult .Tile thisTile ){
@@ -37,46 +40,73 @@ public Type getType(){
37
40
public static class Holder extends ImageStatusDisplayItem .Holder <PhotoStatusDisplayItem >{
38
41
private final FrameLayout altTextWrapper ;
39
42
private final TextView altTextButton ;
43
+ private final ImageView noAltTextButton ;
40
44
private final View altTextScroller ;
41
45
private final ImageButton altTextClose ;
42
46
private final TextView altText ;
43
47
48
+ private View altOrNoAltButton ;
44
49
private boolean altTextShown ;
45
50
private AnimatorSet currentAnim ;
46
51
47
52
public Holder (Activity activity , ViewGroup parent ){
48
53
super (activity , R .layout .display_item_photo , parent );
49
54
altTextWrapper =findViewById (R .id .alt_text_wrapper );
50
55
altTextButton =findViewById (R .id .alt_button );
56
+ noAltTextButton =findViewById (R .id .no_alt_button );
51
57
altTextScroller =findViewById (R .id .alt_text_scroller );
52
58
altTextClose =findViewById (R .id .alt_text_close );
53
59
altText =findViewById (R .id .alt_text );
54
60
55
61
altTextButton .setOnClickListener (this ::onShowHideClick );
62
+ noAltTextButton .setOnClickListener (this ::onShowHideClick );
56
63
altTextClose .setOnClickListener (this ::onShowHideClick );
57
64
// altTextScroller.setNestedScrollingEnabled(true);
58
65
}
59
66
60
67
@ Override
61
68
public void onBind (ImageStatusDisplayItem item ){
62
69
super .onBind (item );
70
+ boolean altTextMissing = TextUtils .isEmpty (item .attachment .description );
71
+ altOrNoAltButton = altTextMissing ? noAltTextButton : altTextButton ;
63
72
altTextShown =false ;
64
73
if (currentAnim !=null )
65
74
currentAnim .cancel ();
75
+
66
76
altTextScroller .setVisibility (View .GONE );
67
77
altTextClose .setVisibility (View .GONE );
68
78
altTextButton .setVisibility (View .VISIBLE );
79
+ noAltTextButton .setVisibility (View .VISIBLE );
69
80
altTextButton .setAlpha (1f );
70
- if (TextUtils .isEmpty (item .attachment .description )){
71
- altTextWrapper .setVisibility (View .GONE );
81
+ noAltTextButton .setAlpha (1f );
82
+ altTextWrapper .setVisibility (View .VISIBLE );
83
+
84
+ if (altTextMissing ){
85
+ if (GlobalUserPreferences .showNoAltIndicator ) {
86
+ noAltTextButton .setVisibility (View .VISIBLE );
87
+ altTextWrapper .setBackgroundResource (R .drawable .bg_image_no_alt_overlay );
88
+ altTextButton .setVisibility (View .GONE );
89
+ altText .setText (R .string .sk_no_alt_text );
90
+ altText .setPadding (V .dp (8 ), 0 , 0 , 0 );
91
+ } else {
92
+ altTextWrapper .setVisibility (View .GONE );
93
+ }
72
94
}else {
73
- altTextWrapper .setVisibility (View .VISIBLE );
74
- altText .setText (item .attachment .description );
95
+ if (GlobalUserPreferences .showAltIndicator ) {
96
+ noAltTextButton .setVisibility (View .GONE );
97
+ altTextWrapper .setBackgroundResource (R .drawable .bg_image_alt_overlay );
98
+ altTextButton .setVisibility (View .VISIBLE );
99
+ altTextButton .setText (R .string .sk_alt_button );
100
+ altText .setText (item .attachment .description );
101
+ altText .setPadding (0 , 0 , 0 , 0 );
102
+ } else {
103
+ altTextWrapper .setVisibility (View .GONE );
104
+ }
75
105
}
76
106
}
77
107
78
108
private void onShowHideClick (View v ){
79
- boolean show =v .getId ()==R .id .alt_button ;
109
+ boolean show =v .getId ()==R .id .alt_button || v . getId ()== R . id . no_alt_button ;
80
110
81
111
if (altTextShown ==show )
82
112
return ;
@@ -88,7 +118,7 @@ private void onShowHideClick(View v){
88
118
altTextScroller .setVisibility (View .VISIBLE );
89
119
altTextClose .setVisibility (View .VISIBLE );
90
120
}else {
91
- altTextButton .setVisibility (View .VISIBLE );
121
+ altOrNoAltButton .setVisibility (View .VISIBLE );
92
122
// Hide these views temporarily so FrameLayout measures correctly
93
123
altTextScroller .setVisibility (View .GONE );
94
124
altTextClose .setVisibility (View .GONE );
@@ -115,7 +145,7 @@ public boolean onPreDraw(){
115
145
ObjectAnimator .ofInt (altTextWrapper , "left" , prevLeft , altTextWrapper .getLeft ()),
116
146
ObjectAnimator .ofInt (altTextWrapper , "right" , prevRight , altTextWrapper .getRight ()),
117
147
ObjectAnimator .ofInt (altTextWrapper , "top" , prevTop , altTextWrapper .getTop ()),
118
- ObjectAnimator .ofFloat (altTextButton , View .ALPHA , show ? 1f : 0f , show ? 0f : 1f ),
148
+ ObjectAnimator .ofFloat (altOrNoAltButton , View .ALPHA , show ? 1f : 0f , show ? 0f : 1f ),
119
149
ObjectAnimator .ofFloat (altTextScroller , View .ALPHA , show ? 0f : 1f , show ? 1f : 0f ),
120
150
ObjectAnimator .ofFloat (altTextClose , View .ALPHA , show ? 0f : 1f , show ? 1f : 0f )
121
151
);
@@ -125,7 +155,7 @@ public boolean onPreDraw(){
125
155
@ Override
126
156
public void onAnimationEnd (Animator animation ){
127
157
if (show ){
128
- altTextButton .setVisibility (View .GONE );
158
+ altOrNoAltButton .setVisibility (View .GONE );
129
159
}else {
130
160
altTextScroller .setVisibility (View .GONE );
131
161
altTextClose .setVisibility (View .GONE );
0 commit comments