first commit
[bylock.git] / sources / android / support / v7 / internal / widget / ActionBarContextView.java
blob0c27b221bbf2eebcbaeb3440c6a506bb49cf4583
1 package android.support.v7.internal.widget;
3 import android.content.Context;
4 import android.content.res.TypedArray;
5 import android.graphics.drawable.Drawable;
6 import android.support.v7.b.c;
7 import android.support.v7.b.f;
8 import android.support.v7.b.h;
9 import android.support.v7.b.k;
10 import android.support.v7.c.a;
11 import android.support.v7.internal.view.menu.ActionMenuPresenter;
12 import android.support.v7.internal.view.menu.ActionMenuView;
13 import android.support.v7.internal.view.menu.q;
14 import android.text.TextUtils;
15 import android.util.AttributeSet;
16 import android.view.LayoutInflater;
17 import android.view.View;
18 import android.view.ViewGroup;
19 import android.widget.LinearLayout;
20 import android.widget.TextView;
22 /* compiled from: MyApp */
23 public class ActionBarContextView extends a {
24 private CharSequence g;
25 private CharSequence h;
26 private View i;
27 private View j;
28 private LinearLayout k;
29 private TextView l;
30 private TextView m;
31 private int n;
32 private int o;
33 private Drawable p;
34 private boolean q;
36 @Override // android.support.v7.internal.widget.a
37 public /* bridge */ /* synthetic */ void a(int i2) {
38 super.a(i2);
41 @Override // android.support.v7.internal.widget.a
42 public /* bridge */ /* synthetic */ void b() {
43 super.b();
46 @Override // android.support.v7.internal.widget.a
47 public /* bridge */ /* synthetic */ boolean e() {
48 return super.e();
51 @Override // android.support.v7.internal.widget.a
52 public /* bridge */ /* synthetic */ void f() {
53 super.f();
56 @Override // android.support.v7.internal.widget.a
57 public /* bridge */ /* synthetic */ int getAnimatedVisibility() {
58 return super.getAnimatedVisibility();
61 @Override // android.support.v7.internal.widget.a
62 public /* bridge */ /* synthetic */ int getContentHeight() {
63 return super.getContentHeight();
66 @Override // android.support.v7.internal.widget.a
67 public /* bridge */ /* synthetic */ void setSplitView(ActionBarContainer actionBarContainer) {
68 super.setSplitView(actionBarContainer);
71 @Override // android.support.v7.internal.widget.a
72 public /* bridge */ /* synthetic */ void setSplitWhenNarrow(boolean z) {
73 super.setSplitWhenNarrow(z);
76 @Override // android.support.v7.internal.widget.a
77 public /* bridge */ /* synthetic */ void setVisibility(int i2) {
78 super.setVisibility(i2);
81 public ActionBarContextView(Context context) {
82 this(context, null);
85 public ActionBarContextView(Context context, AttributeSet attributeSet) {
86 this(context, attributeSet, c.actionModeStyle);
89 public ActionBarContextView(Context context, AttributeSet attributeSet, int i2) {
90 super(context, attributeSet, i2);
91 TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, k.ActionMode, i2, 0);
92 setBackgroundDrawable(obtainStyledAttributes.getDrawable(3));
93 this.n = obtainStyledAttributes.getResourceId(1, 0);
94 this.o = obtainStyledAttributes.getResourceId(2, 0);
95 this.f = obtainStyledAttributes.getLayoutDimension(0, 0);
96 this.p = obtainStyledAttributes.getDrawable(4);
97 obtainStyledAttributes.recycle();
100 public void onDetachedFromWindow() {
101 super.onDetachedFromWindow();
102 if (this.b != null) {
103 this.b.b();
104 this.b.d();
108 @Override // android.support.v7.internal.widget.a
109 public void setSplitActionBar(boolean z) {
110 if (this.d != z) {
111 if (this.b != null) {
112 ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(-2, -1);
113 if (!z) {
114 this.a = (ActionMenuView) this.b.a(this);
115 this.a.setBackgroundDrawable(null);
116 ViewGroup viewGroup = (ViewGroup) this.a.getParent();
117 if (viewGroup != null) {
118 viewGroup.removeView(this.a);
120 addView(this.a, layoutParams);
121 } else {
122 this.b.a(getContext().getResources().getDisplayMetrics().widthPixels, true);
123 this.b.a(Integer.MAX_VALUE);
124 layoutParams.width = -1;
125 layoutParams.height = this.f;
126 this.a = (ActionMenuView) this.b.a(this);
127 this.a.setBackgroundDrawable(this.p);
128 ViewGroup viewGroup2 = (ViewGroup) this.a.getParent();
129 if (viewGroup2 != null) {
130 viewGroup2.removeView(this.a);
132 this.c.addView(this.a, layoutParams);
135 super.setSplitActionBar(z);
139 @Override // android.support.v7.internal.widget.a
140 public void setContentHeight(int i2) {
141 this.f = i2;
144 public void setCustomView(View view) {
145 if (this.j != null) {
146 removeView(this.j);
148 this.j = view;
149 if (this.k != null) {
150 removeView(this.k);
151 this.k = null;
153 if (view != null) {
154 addView(view);
156 requestLayout();
159 public void setTitle(CharSequence charSequence) {
160 this.g = charSequence;
161 i();
164 public void setSubtitle(CharSequence charSequence) {
165 this.h = charSequence;
166 i();
169 public CharSequence getTitle() {
170 return this.g;
173 public CharSequence getSubtitle() {
174 return this.h;
177 private void i() {
178 int i2;
179 int i3 = 8;
180 boolean z = true;
181 if (this.k == null) {
182 LayoutInflater.from(getContext()).inflate(h.abc_action_bar_title_item, this);
183 this.k = (LinearLayout) getChildAt(getChildCount() - 1);
184 this.l = (TextView) this.k.findViewById(f.action_bar_title);
185 this.m = (TextView) this.k.findViewById(f.action_bar_subtitle);
186 if (this.n != 0) {
187 this.l.setTextAppearance(getContext(), this.n);
189 if (this.o != 0) {
190 this.m.setTextAppearance(getContext(), this.o);
193 this.l.setText(this.g);
194 this.m.setText(this.h);
195 boolean z2 = !TextUtils.isEmpty(this.g);
196 if (TextUtils.isEmpty(this.h)) {
197 z = false;
199 TextView textView = this.m;
200 if (z) {
201 i2 = 0;
202 } else {
203 i2 = 8;
205 textView.setVisibility(i2);
206 LinearLayout linearLayout = this.k;
207 if (z2 || z) {
208 i3 = 0;
210 linearLayout.setVisibility(i3);
211 if (this.k.getParent() == null) {
212 addView(this.k);
216 public void a(a aVar) {
217 if (this.i == null) {
218 this.i = LayoutInflater.from(getContext()).inflate(h.abc_action_mode_close_item, (ViewGroup) this, false);
219 addView(this.i);
220 } else if (this.i.getParent() == null) {
221 addView(this.i);
223 this.i.findViewById(f.action_mode_close_button).setOnClickListener(new f(this, aVar));
224 q qVar = (q) aVar.a();
225 if (this.b != null) {
226 this.b.c();
228 this.b = new ActionMenuPresenter(getContext());
229 this.b.a(true);
230 ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(-2, -1);
231 if (!this.d) {
232 qVar.a(this.b);
233 this.a = (ActionMenuView) this.b.a(this);
234 this.a.setBackgroundDrawable(null);
235 addView(this.a, layoutParams);
236 return;
238 this.b.a(getContext().getResources().getDisplayMetrics().widthPixels, true);
239 this.b.a(Integer.MAX_VALUE);
240 layoutParams.width = -1;
241 layoutParams.height = this.f;
242 qVar.a(this.b);
243 this.a = (ActionMenuView) this.b.a(this);
244 this.a.setBackgroundDrawable(this.p);
245 this.c.addView(this.a, layoutParams);
248 public void g() {
249 if (this.i == null) {
250 h();
254 public void h() {
255 removeAllViews();
256 if (this.c != null) {
257 this.c.removeView(this.a);
259 this.j = null;
260 this.a = null;
263 @Override // android.support.v7.internal.widget.a
264 public boolean a() {
265 if (this.b != null) {
266 return this.b.a();
268 return false;
271 @Override // android.support.v7.internal.widget.a
272 public boolean c() {
273 if (this.b != null) {
274 return this.b.b();
276 return false;
279 @Override // android.support.v7.internal.widget.a
280 public boolean d() {
281 if (this.b != null) {
282 return this.b.e();
284 return false;
287 /* access modifiers changed from: protected */
288 public ViewGroup.LayoutParams generateDefaultLayoutParams() {
289 return new ViewGroup.MarginLayoutParams(-1, -2);
292 @Override // android.view.ViewGroup
293 public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
294 return new ViewGroup.MarginLayoutParams(getContext(), attributeSet);
297 /* access modifiers changed from: protected */
298 public void onMeasure(int i2, int i3) {
299 int i4;
300 int i5;
301 int i6 = 1073741824;
302 int i7 = 0;
303 if (View.MeasureSpec.getMode(i2) != 1073741824) {
304 throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + "with android:layout_width=\"FILL_PARENT\" (or fill_parent)");
305 } else if (View.MeasureSpec.getMode(i3) == 0) {
306 throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + "with android:layout_height=\"wrap_content\"");
307 } else {
308 int size = View.MeasureSpec.getSize(i2);
309 int size2 = this.f > 0 ? this.f : View.MeasureSpec.getSize(i3);
310 int paddingTop = getPaddingTop() + getPaddingBottom();
311 int paddingLeft = (size - getPaddingLeft()) - getPaddingRight();
312 int i8 = size2 - paddingTop;
313 int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(i8, Integer.MIN_VALUE);
314 if (this.i != null) {
315 int a = a(this.i, paddingLeft, makeMeasureSpec, 0);
316 ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) this.i.getLayoutParams();
317 paddingLeft = a - (marginLayoutParams.rightMargin + marginLayoutParams.leftMargin);
319 if (this.a != null && this.a.getParent() == this) {
320 paddingLeft = a(this.a, paddingLeft, makeMeasureSpec, 0);
322 if (this.k != null && this.j == null) {
323 if (this.q) {
324 this.k.measure(View.MeasureSpec.makeMeasureSpec(0, 0), makeMeasureSpec);
325 int measuredWidth = this.k.getMeasuredWidth();
326 boolean z = measuredWidth <= paddingLeft;
327 if (z) {
328 paddingLeft -= measuredWidth;
330 this.k.setVisibility(z ? 0 : 8);
331 } else {
332 paddingLeft = a(this.k, paddingLeft, makeMeasureSpec, 0);
335 if (this.j != null) {
336 ViewGroup.LayoutParams layoutParams = this.j.getLayoutParams();
337 if (layoutParams.width != -2) {
338 i4 = 1073741824;
339 } else {
340 i4 = Integer.MIN_VALUE;
342 if (layoutParams.width >= 0) {
343 paddingLeft = Math.min(layoutParams.width, paddingLeft);
345 if (layoutParams.height == -2) {
346 i6 = Integer.MIN_VALUE;
348 if (layoutParams.height >= 0) {
349 i5 = Math.min(layoutParams.height, i8);
350 } else {
351 i5 = i8;
353 this.j.measure(View.MeasureSpec.makeMeasureSpec(paddingLeft, i4), View.MeasureSpec.makeMeasureSpec(i5, i6));
355 if (this.f <= 0) {
356 int childCount = getChildCount();
357 int i9 = 0;
358 while (i7 < childCount) {
359 int measuredHeight = getChildAt(i7).getMeasuredHeight() + paddingTop;
360 if (measuredHeight <= i9) {
361 measuredHeight = i9;
363 i7++;
364 i9 = measuredHeight;
366 setMeasuredDimension(size, i9);
367 return;
369 setMeasuredDimension(size, size2);
373 /* access modifiers changed from: protected */
374 public void onLayout(boolean z, int i2, int i3, int i4, int i5) {
375 int i6;
376 int paddingLeft = getPaddingLeft();
377 int paddingTop = getPaddingTop();
378 int paddingTop2 = ((i5 - i3) - getPaddingTop()) - getPaddingBottom();
379 if (this.i == null || this.i.getVisibility() == 8) {
380 i6 = paddingLeft;
381 } else {
382 ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) this.i.getLayoutParams();
383 int i7 = paddingLeft + marginLayoutParams.leftMargin;
384 i6 = marginLayoutParams.rightMargin + i7 + b(this.i, i7, paddingTop, paddingTop2);
386 if (!(this.k == null || this.j != null || this.k.getVisibility() == 8)) {
387 i6 += b(this.k, i6, paddingTop, paddingTop2);
389 if (this.j != null) {
390 int b = i6 + b(this.j, i6, paddingTop, paddingTop2);
392 int paddingRight = (i4 - i2) - getPaddingRight();
393 if (this.a != null) {
394 int c = paddingRight - c(this.a, paddingRight, paddingTop, paddingTop2);
398 public void setTitleOptional(boolean z) {
399 if (z != this.q) {
400 requestLayout();
402 this.q = z;