ActionBarContextView.java 14.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520
package android.support.v7.widget;

import android.content.Context;
import android.os.Build.VERSION;
import android.support.annotation.RestrictTo;
import android.support.v4.view.ViewCompat;
import android.support.v7.appcompat.R.attr;
import android.support.v7.appcompat.R.id;
import android.support.v7.appcompat.R.layout;
import android.support.v7.appcompat.R.styleable;
import android.support.v7.view.ActionMode;
import android.support.v7.view.menu.MenuBuilder;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewGroup.MarginLayoutParams;
import android.view.accessibility.AccessibilityEvent;
import android.widget.LinearLayout;
import android.widget.TextView;

@RestrictTo({android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP})
public class ActionBarContextView
  extends AbsActionBarView
{
  private CharSequence a;
  private CharSequence b;
  private View c;
  private View d;
  private LinearLayout e;
  private TextView f;
  private TextView g;
  private int h;
  private int i;
  private boolean j;
  private int k;
  
  public ActionBarContextView(Context paramContext)
  {
    this(paramContext, null);
  }
  
  public ActionBarContextView(Context paramContext, AttributeSet paramAttributeSet)
  {
    this(paramContext, paramAttributeSet, R.attr.actionModeStyle);
  }
  
  public ActionBarContextView(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
  {
    super(paramContext, paramAttributeSet, paramInt);
    paramContext = TintTypedArray.obtainStyledAttributes(paramContext, paramAttributeSet, R.styleable.ActionMode, paramInt, 0);
    ViewCompat.setBackground(this, paramContext.getDrawable(R.styleable.ActionMode_background));
    this.h = paramContext.getResourceId(R.styleable.ActionMode_titleTextStyle, 0);
    this.i = paramContext.getResourceId(R.styleable.ActionMode_subtitleTextStyle, 0);
    this.mContentHeight = paramContext.getLayoutDimension(R.styleable.ActionMode_height, 0);
    this.k = paramContext.getResourceId(R.styleable.ActionMode_closeItemLayout, R.layout.abc_action_mode_close_item_material);
    paramContext.recycle();
  }
  
  private void a()
  {
    int i2 = 8;
    int n = 1;
    if (this.e == null)
    {
      LayoutInflater.from(getContext()).inflate(R.layout.abc_action_bar_title_item, this);
      this.e = ((LinearLayout)getChildAt(getChildCount() - 1));
      this.f = ((TextView)this.e.findViewById(R.id.action_bar_title));
      this.g = ((TextView)this.e.findViewById(R.id.action_bar_subtitle));
      if (this.h != 0) {
        this.f.setTextAppearance(getContext(), this.h);
      }
      if (this.i != 0) {
        this.g.setTextAppearance(getContext(), this.i);
      }
    }
    this.f.setText(this.a);
    this.g.setText(this.b);
    int m;
    label167:
    Object localObject;
    if (!TextUtils.isEmpty(this.a))
    {
      m = 1;
      if (TextUtils.isEmpty(this.b)) {
        break label234;
      }
      localObject = this.g;
      if (n == 0) {
        break label239;
      }
    }
    label234:
    label239:
    for (int i1 = 0;; i1 = 8)
    {
      ((TextView)localObject).setVisibility(i1);
      localObject = this.e;
      if (m == 0)
      {
        m = i2;
        if (n == 0) {}
      }
      else
      {
        m = 0;
      }
      ((LinearLayout)localObject).setVisibility(m);
      if (this.e.getParent() == null) {
        addView(this.e);
      }
      return;
      m = 0;
      break;
      n = 0;
      break label167;
    }
  }
  
  public void closeMode()
  {
    if (this.c == null) {
      killMode();
    }
  }
  
  protected ViewGroup.LayoutParams generateDefaultLayoutParams()
  {
    return new ViewGroup.MarginLayoutParams(-1, -2);
  }
  
  public ViewGroup.LayoutParams generateLayoutParams(AttributeSet paramAttributeSet)
  {
    return new ViewGroup.MarginLayoutParams(getContext(), paramAttributeSet);
  }
  
  public CharSequence getSubtitle()
  {
    return this.b;
  }
  
  public CharSequence getTitle()
  {
    return this.a;
  }
  
  public boolean hideOverflowMenu()
  {
    if (this.mActionMenuPresenter != null) {
      return this.mActionMenuPresenter.d();
    }
    return false;
  }
  
  public void initForMode(final ActionMode paramActionMode)
  {
    if (this.c == null)
    {
      this.c = LayoutInflater.from(getContext()).inflate(this.k, this, false);
      addView(this.c);
    }
    for (;;)
    {
      this.c.findViewById(R.id.action_mode_close_button).setOnClickListener(new View.OnClickListener()
      {
        public final void onClick(View paramAnonymousView)
        {
          paramActionMode.finish();
        }
      });
      paramActionMode = (MenuBuilder)paramActionMode.getMenu();
      if (this.mActionMenuPresenter != null) {
        this.mActionMenuPresenter.e();
      }
      this.mActionMenuPresenter = new ActionMenuPresenter(getContext());
      this.mActionMenuPresenter.b();
      ViewGroup.LayoutParams localLayoutParams = new ViewGroup.LayoutParams(-2, -1);
      paramActionMode.addMenuPresenter(this.mActionMenuPresenter, this.mPopupContext);
      this.mMenuView = ((ActionMenuView)this.mActionMenuPresenter.getMenuView(this));
      ViewCompat.setBackground(this.mMenuView, null);
      addView(this.mMenuView, localLayoutParams);
      return;
      if (this.c.getParent() == null) {
        addView(this.c);
      }
    }
  }
  
  public boolean isOverflowMenuShowing()
  {
    if (this.mActionMenuPresenter != null) {
      return this.mActionMenuPresenter.g();
    }
    return false;
  }
  
  public boolean isTitleOptional()
  {
    return this.j;
  }
  
  public void killMode()
  {
    removeAllViews();
    this.d = null;
    this.mMenuView = null;
  }
  
  public void onDetachedFromWindow()
  {
    super.onDetachedFromWindow();
    if (this.mActionMenuPresenter != null)
    {
      this.mActionMenuPresenter.d();
      this.mActionMenuPresenter.f();
    }
  }
  
  public void onInitializeAccessibilityEvent(AccessibilityEvent paramAccessibilityEvent)
  {
    if (Build.VERSION.SDK_INT >= 14)
    {
      if (paramAccessibilityEvent.getEventType() == 32)
      {
        paramAccessibilityEvent.setSource(this);
        paramAccessibilityEvent.setClassName(getClass().getName());
        paramAccessibilityEvent.setPackageName(getContext().getPackageName());
        paramAccessibilityEvent.setContentDescription(this.a);
      }
    }
    else {
      return;
    }
    super.onInitializeAccessibilityEvent(paramAccessibilityEvent);
  }
  
  protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    paramBoolean = ViewUtils.isLayoutRtl(this);
    int m;
    int n;
    int i1;
    Object localObject;
    if (paramBoolean)
    {
      m = paramInt3 - paramInt1 - getPaddingRight();
      n = getPaddingTop();
      i1 = paramInt4 - paramInt2 - getPaddingTop() - getPaddingBottom();
      if ((this.c == null) || (this.c.getVisibility() == 8)) {
        break label289;
      }
      localObject = (ViewGroup.MarginLayoutParams)this.c.getLayoutParams();
      if (!paramBoolean) {
        break label252;
      }
      paramInt2 = ((ViewGroup.MarginLayoutParams)localObject).rightMargin;
      label83:
      if (!paramBoolean) {
        break label261;
      }
      paramInt4 = ((ViewGroup.MarginLayoutParams)localObject).leftMargin;
      label94:
      paramInt2 = next(m, paramInt2, paramBoolean);
    }
    label210:
    label252:
    label261:
    label284:
    label289:
    for (paramInt2 = next(positionChild(this.c, paramInt2, n, i1, paramBoolean) + paramInt2, paramInt4, paramBoolean);; paramInt2 = m)
    {
      paramInt4 = paramInt2;
      if (this.e != null)
      {
        paramInt4 = paramInt2;
        if (this.d == null)
        {
          paramInt4 = paramInt2;
          if (this.e.getVisibility() != 8) {
            paramInt4 = paramInt2 + positionChild(this.e, paramInt2, n, i1, paramBoolean);
          }
        }
      }
      if (this.d != null) {
        positionChild(this.d, paramInt4, n, i1, paramBoolean);
      }
      if (paramBoolean)
      {
        paramInt1 = getPaddingLeft();
        if (this.mMenuView != null)
        {
          localObject = this.mMenuView;
          if (paramBoolean) {
            break label284;
          }
        }
      }
      for (paramBoolean = true;; paramBoolean = false)
      {
        positionChild((View)localObject, paramInt1, n, i1, paramBoolean);
        return;
        m = getPaddingLeft();
        break;
        paramInt2 = ((ViewGroup.MarginLayoutParams)localObject).leftMargin;
        break label83;
        paramInt4 = ((ViewGroup.MarginLayoutParams)localObject).rightMargin;
        break label94;
        paramInt1 = paramInt3 - paramInt1 - getPaddingRight();
        break label210;
      }
    }
  }
  
  protected void onMeasure(int paramInt1, int paramInt2)
  {
    int i1 = 1073741824;
    int i2 = 0;
    if (View.MeasureSpec.getMode(paramInt1) != 1073741824) {
      throw new IllegalStateException(getClass().getSimpleName() + " can only be used with android:layout_width=\"match_parent\" (or fill_parent)");
    }
    if (View.MeasureSpec.getMode(paramInt2) == 0) {
      throw new IllegalStateException(getClass().getSimpleName() + " can only be used with android:layout_height=\"wrap_content\"");
    }
    int i4 = View.MeasureSpec.getSize(paramInt1);
    int m;
    int i3;
    int n;
    if (this.mContentHeight > 0)
    {
      m = this.mContentHeight;
      int i5 = getPaddingTop() + getPaddingBottom();
      paramInt1 = i4 - getPaddingLeft() - getPaddingRight();
      i3 = m - i5;
      n = View.MeasureSpec.makeMeasureSpec(i3, Integer.MIN_VALUE);
      paramInt2 = paramInt1;
      Object localObject;
      if (this.c != null)
      {
        paramInt1 = measureChildView(this.c, paramInt1, n, 0);
        localObject = (ViewGroup.MarginLayoutParams)this.c.getLayoutParams();
        paramInt2 = ((ViewGroup.MarginLayoutParams)localObject).leftMargin;
        paramInt2 = paramInt1 - (((ViewGroup.MarginLayoutParams)localObject).rightMargin + paramInt2);
      }
      paramInt1 = paramInt2;
      if (this.mMenuView != null)
      {
        paramInt1 = paramInt2;
        if (this.mMenuView.getParent() == this) {
          paramInt1 = measureChildView(this.mMenuView, paramInt2, n, 0);
        }
      }
      paramInt2 = paramInt1;
      if (this.e != null)
      {
        paramInt2 = paramInt1;
        if (this.d == null)
        {
          if (!this.j) {
            break label500;
          }
          paramInt2 = View.MeasureSpec.makeMeasureSpec(0, 0);
          this.e.measure(paramInt2, n);
          int i6 = this.e.getMeasuredWidth();
          if (i6 > paramInt1) {
            break label488;
          }
          n = 1;
          label295:
          paramInt2 = paramInt1;
          if (n != 0) {
            paramInt2 = paramInt1 - i6;
          }
          localObject = this.e;
          if (n == 0) {
            break label494;
          }
          paramInt1 = 0;
          label320:
          ((LinearLayout)localObject).setVisibility(paramInt1);
        }
      }
      label326:
      if (this.d != null)
      {
        localObject = this.d.getLayoutParams();
        if (((ViewGroup.LayoutParams)localObject).width == -2) {
          break label516;
        }
        paramInt1 = 1073741824;
        label356:
        n = paramInt2;
        if (((ViewGroup.LayoutParams)localObject).width >= 0) {
          n = Math.min(((ViewGroup.LayoutParams)localObject).width, paramInt2);
        }
        if (((ViewGroup.LayoutParams)localObject).height == -2) {
          break label523;
        }
        paramInt2 = i1;
        label391:
        if (((ViewGroup.LayoutParams)localObject).height < 0) {
          break label530;
        }
        i1 = Math.min(((ViewGroup.LayoutParams)localObject).height, i3);
        label411:
        this.d.measure(View.MeasureSpec.makeMeasureSpec(n, paramInt1), View.MeasureSpec.makeMeasureSpec(i1, paramInt2));
      }
      if (this.mContentHeight > 0) {
        break label545;
      }
      n = getChildCount();
      paramInt1 = 0;
      paramInt2 = i2;
      label448:
      if (paramInt2 >= n) {
        break label537;
      }
      m = getChildAt(paramInt2).getMeasuredHeight() + i5;
      if (m <= paramInt1) {
        break label553;
      }
      paramInt1 = m;
    }
    label488:
    label494:
    label500:
    label516:
    label523:
    label530:
    label537:
    label545:
    label553:
    for (;;)
    {
      paramInt2 += 1;
      break label448;
      m = View.MeasureSpec.getSize(paramInt2);
      break;
      n = 0;
      break label295;
      paramInt1 = 8;
      break label320;
      paramInt2 = measureChildView(this.e, paramInt1, n, 0);
      break label326;
      paramInt1 = Integer.MIN_VALUE;
      break label356;
      paramInt2 = Integer.MIN_VALUE;
      break label391;
      i1 = i3;
      break label411;
      setMeasuredDimension(i4, paramInt1);
      return;
      setMeasuredDimension(i4, m);
      return;
    }
  }
  
  public void setContentHeight(int paramInt)
  {
    this.mContentHeight = paramInt;
  }
  
  public void setCustomView(View paramView)
  {
    if (this.d != null) {
      removeView(this.d);
    }
    this.d = paramView;
    if ((paramView != null) && (this.e != null))
    {
      removeView(this.e);
      this.e = null;
    }
    if (paramView != null) {
      addView(paramView);
    }
    requestLayout();
  }
  
  public void setSubtitle(CharSequence paramCharSequence)
  {
    this.b = paramCharSequence;
    a();
  }
  
  public void setTitle(CharSequence paramCharSequence)
  {
    this.a = paramCharSequence;
    a();
  }
  
  public void setTitleOptional(boolean paramBoolean)
  {
    if (paramBoolean != this.j) {
      requestLayout();
    }
    this.j = paramBoolean;
  }
  
  public boolean shouldDelayChildPressedState()
  {
    return false;
  }
  
  public boolean showOverflowMenu()
  {
    if (this.mActionMenuPresenter != null) {
      return this.mActionMenuPresenter.c();
    }
    return false;
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/android/support/v7/widget/ActionBarContextView.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */