public ActionBarContextView(Context context, AttributeSet attributeSet, int i) {
   super(context, attributeSet, i);
   TypedArray obtainStyledAttributes =
       context.obtainStyledAttributes(attributeSet, R.ActionMode, i, 0);
   setBackgroundDrawable(obtainStyledAttributes.getDrawable(3));
   this.f1086n = obtainStyledAttributes.getResourceId(1, 0);
   this.f1087o = obtainStyledAttributes.getResourceId(2, 0);
   this.f = obtainStyledAttributes.getLayoutDimension(0, 0);
   this.f1088p = obtainStyledAttributes.getDrawable(4);
   obtainStyledAttributes.recycle();
 }
  @Override
  protected void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    // Action bar can change size on configuration changes.
    // Reread the desired height from the theme-specified style.
    TypedArray a =
        getContext()
            .obtainStyledAttributes(null, R.styleable.SherlockActionBar, R.attr.actionBarStyle, 0);
    setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0));
    a.recycle();
  }
Beispiel #3
0
 protected void onConfigurationChanged(Configuration configuration) {
   if (VERSION.SDK_INT >= 8) {
     super.onConfigurationChanged(configuration);
   }
   TypedArray obtainStyledAttributes =
       getContext().obtainStyledAttributes(null, nv.ActionBar, nl.actionBarStyle, 0);
   setContentHeight(obtainStyledAttributes.getLayoutDimension(nv.ActionBar_height, 0));
   obtainStyledAttributes.recycle();
   if (this.d != null) {
     this.d.a(configuration);
   }
 }
  public ScrollingTabContainerView(Context context) {
    super(context);
    setHorizontalScrollBarEnabled(false);

    TypedArray a =
        getContext()
            .obtainStyledAttributes(null, R.styleable.SherlockActionBar, R.attr.actionBarStyle, 0);
    setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0));
    a.recycle();

    mInflater = LayoutInflater.from(context);

    mTabLayout = createTabLayout();
    addView(
        mTabLayout,
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
  }
 public void onConfigurationChanged(Configuration paramConfiguration) {
   if (Build.VERSION.SDK_INT >= 8) super.onConfigurationChanged(paramConfiguration);
   while (true) {
     TypedArray localTypedArray =
         getContext()
             .obtainStyledAttributes(
                 null, R.styleable.SherlockActionBar, R.attr.actionBarStyle, 0);
     setContentHeight(localTypedArray.getLayoutDimension(4, 0));
     localTypedArray.recycle();
     if (this.mSplitWhenNarrow)
       setSplitActionBar(
           ResourcesCompat.getResources_getBoolean(
               getContext(), R.bool.abs__split_action_bar_is_narrow));
     if (this.mActionMenuPresenter != null)
       this.mActionMenuPresenter.onConfigurationChanged(paramConfiguration);
     return;
     if (this.mMenuView == null) continue;
     this.mMenuView.onConfigurationChanged(paramConfiguration);
   }
 }
  @Override
  protected void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    // Action bar can change size on configuration changes.
    // Reread the desired height from the theme-specified style.
    TypedArray a =
        getContext()
            .obtainStyledAttributes(
                null, R.styleable.ActionBar, com.android.internal.R.attr.actionBarStyle, 0);
    setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
    a.recycle();
    if (mSplitWhenNarrow) {
      setSplitActionBar(
          getContext()
              .getResources()
              .getBoolean(com.android.internal.R.bool.split_action_bar_is_narrow));
    }
    if (mActionMenuPresenter != null) {
      mActionMenuPresenter.onConfigurationChanged(newConfig);
    }
  }
Beispiel #7
0
  /*
   * Must be public so we can dispatch pre-2.2 via ActionBarImpl.
   */
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
      super.onConfigurationChanged(newConfig);
    } else if (mMenuView != null) {
      mMenuView.onConfigurationChanged(newConfig);
    }

    // Action bar can change size on configuration changes.
    // Reread the desired height from the theme-specified style.
    TypedArray a =
        getContext()
            .obtainStyledAttributes(null, R.styleable.SherlockActionBar, R.attr.actionBarStyle, 0);
    setContentHeight(a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0));
    a.recycle();
    if (mSplitWhenNarrow) {
      setSplitActionBar(
          getResources_getBoolean(getContext(), R.bool.abs__split_action_bar_is_narrow));
    }
    if (mActionMenuPresenter != null) {
      mActionMenuPresenter.onConfigurationChanged(newConfig);
    }
  }
 public static void fetchWidthAndHeight(
     LayoutParams params, TypedArray array, int widthAttr, int heightAttr) {
   params.width = array.getLayoutDimension(widthAttr, 0);
   params.height = array.getLayoutDimension(heightAttr, 0);
 }
  public SmartTabLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Disable the Scroll Bar
    setHorizontalScrollBarEnabled(false);

    final DisplayMetrics dm = getResources().getDisplayMetrics();
    final float density = dm.density;

    int tabBackgroundResId = NO_ID;
    boolean textAllCaps = TAB_VIEW_TEXT_ALL_CAPS;
    ColorStateList textColors;
    float textSize =
        TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP, dm);
    int textHorizontalPadding = (int) (TAB_VIEW_PADDING_DIPS * density);
    int textMinWidth = (int) (TAB_VIEW_TEXT_MIN_WIDTH * density);
    boolean distributeEvenly = DEFAULT_DISTRIBUTE_EVENLY;
    int customTabLayoutId = NO_ID;
    int customTabTextViewId = NO_ID;
    boolean clickable = TAB_CLICKABLE;
    int titleOffset = (int) (TITLE_OFFSET_DIPS * density);

    TypedArray a =
        context.obtainStyledAttributes(attrs, R.styleable.stl_SmartTabLayout, defStyle, 0);
    tabBackgroundResId =
        a.getResourceId(
            R.styleable.stl_SmartTabLayout_stl_defaultTabBackground, tabBackgroundResId);
    textAllCaps =
        a.getBoolean(R.styleable.stl_SmartTabLayout_stl_defaultTabTextAllCaps, textAllCaps);
    textColors = a.getColorStateList(R.styleable.stl_SmartTabLayout_stl_defaultTabTextColor);
    textSize = a.getDimension(R.styleable.stl_SmartTabLayout_stl_defaultTabTextSize, textSize);
    textHorizontalPadding =
        a.getDimensionPixelSize(
            R.styleable.stl_SmartTabLayout_stl_defaultTabTextHorizontalPadding,
            textHorizontalPadding);
    textMinWidth =
        a.getDimensionPixelSize(
            R.styleable.stl_SmartTabLayout_stl_defaultTabTextMinWidth, textMinWidth);
    customTabLayoutId =
        a.getResourceId(
            R.styleable.stl_SmartTabLayout_stl_customTabTextLayoutId, customTabLayoutId);
    customTabTextViewId =
        a.getResourceId(
            R.styleable.stl_SmartTabLayout_stl_customTabTextViewId, customTabTextViewId);
    distributeEvenly =
        a.getBoolean(R.styleable.stl_SmartTabLayout_stl_distributeEvenly, distributeEvenly);
    clickable = a.getBoolean(R.styleable.stl_SmartTabLayout_stl_clickable, clickable);
    titleOffset = a.getLayoutDimension(R.styleable.stl_SmartTabLayout_stl_titleOffset, titleOffset);
    a.recycle();

    this.titleOffset = titleOffset;
    this.tabViewBackgroundResId = tabBackgroundResId;
    this.tabViewTextAllCaps = textAllCaps;
    this.tabViewTextColors =
        (textColors != null) ? textColors : ColorStateList.valueOf(TAB_VIEW_TEXT_COLOR);
    this.tabViewTextSize = textSize;
    this.tabViewTextHorizontalPadding = textHorizontalPadding;
    this.tabViewTextMinWidth = textMinWidth;
    this.internalTabClickListener = clickable ? new InternalTabClickListener() : null;
    this.distributeEvenly = distributeEvenly;

    if (customTabLayoutId != NO_ID) {
      setCustomTabView(customTabLayoutId, customTabTextViewId);
    }

    this.tabStrip = new SmartTabStrip(context, attrs);

    if (distributeEvenly && tabStrip.isIndicatorAlwaysInCenter()) {
      throw new UnsupportedOperationException(
          "'distributeEvenly' and 'indicatorAlwaysInCenter' both use does not support");
    }

    // Make sure that the Tab Strips fills this View
    setFillViewport(!tabStrip.isIndicatorAlwaysInCenter());

    addView(tabStrip, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
  }
Beispiel #10
0
  public ActionBarView(Context context, AttributeSet attrs) {
    super(context, attrs);

    // Background is always provided by the container.
    setBackgroundResource(0);

    TypedArray a =
        context.obtainStyledAttributes(
            attrs, R.styleable.SherlockActionBar, R.attr.actionBarStyleABS, 0);

    ApplicationInfo appInfo = context.getApplicationInfo();
    PackageManager pm = context.getPackageManager();
    mNavigationMode =
        a.getInt(
            R.styleable.SherlockActionBar_navigationModeABS, ActionBar.NAVIGATION_MODE_STANDARD);
    mTitle = a.getText(R.styleable.SherlockActionBar_titleABS);
    mSubtitle = a.getText(R.styleable.SherlockActionBar_subtitleABS);

    mLogo = a.getDrawable(R.styleable.SherlockActionBar_logoABS);
    if (mLogo == null) {
      if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        if (context instanceof Activity) {
          // Even though native methods existed in API 9 and 10 they don't work
          // so just parse the manifest to look for the logo pre-Honeycomb
          final int resId = ResourcesCompat.loadLogoFromManifest((Activity) context);
          if (resId != 0) {
            mLogo = context.getResources().getDrawable(resId);
          }
        }
      } else {
        if (context instanceof Activity) {
          try {
            mLogo = pm.getActivityLogo(((Activity) context).getComponentName());
          } catch (NameNotFoundException e) {
            Log.e(TAG, "Activity component name not found!", e);
          }
        }
        if (mLogo == null) {
          mLogo = appInfo.loadLogo(pm);
        }
      }
    }

    mIcon = a.getDrawable(R.styleable.SherlockActionBar_iconABS);
    if (mIcon == null) {
      if (context instanceof Activity) {
        try {
          mIcon = pm.getActivityIcon(((Activity) context).getComponentName());
        } catch (NameNotFoundException e) {
          Log.e(TAG, "Activity component name not found!", e);
        }
      }
      if (mIcon == null) {
        mIcon = appInfo.loadIcon(pm);
      }
    }

    final LayoutInflater inflater = LayoutInflater.from(context);

    final int homeResId =
        a.getResourceId(R.styleable.SherlockActionBar_homeLayoutABS, R.layout.abs__action_bar_home);

    mHomeLayout = (HomeView) inflater.inflate(homeResId, this, false);

    mExpandedHomeLayout = (HomeView) inflater.inflate(homeResId, this, false);
    mExpandedHomeLayout.setUp(true);
    mExpandedHomeLayout.setOnClickListener(mExpandedActionViewUpListener);
    mExpandedHomeLayout.setContentDescription(
        getResources().getText(R.string.abs__action_bar_up_description));

    mTitleStyleRes = a.getResourceId(R.styleable.SherlockActionBar_titleTextStyleABS, 0);
    mSubtitleStyleRes = a.getResourceId(R.styleable.SherlockActionBar_subtitleTextStyleABS, 0);
    mProgressStyle = a.getResourceId(R.styleable.SherlockActionBar_progressBarStyleABS, 0);
    mIndeterminateProgressStyle =
        a.getResourceId(R.styleable.SherlockActionBar_indeterminateProgressStyleABS, 0);

    mProgressBarPadding =
        a.getDimensionPixelOffset(R.styleable.SherlockActionBar_progressBarPaddingABS, 0);
    mItemPadding = a.getDimensionPixelOffset(R.styleable.SherlockActionBar_itemPaddingABS, 0);

    setDisplayOptions(a.getInt(R.styleable.SherlockActionBar_displayOptionsABS, DISPLAY_DEFAULT));

    final int customNavId =
        a.getResourceId(R.styleable.SherlockActionBar_customNavigationLayoutABS, 0);
    if (customNavId != 0) {
      mCustomNavView = inflater.inflate(customNavId, this, false);
      mNavigationMode = ActionBar.NAVIGATION_MODE_STANDARD;
      setDisplayOptions(mDisplayOptions | ActionBar.DISPLAY_SHOW_CUSTOM);
    }

    mContentHeight = a.getLayoutDimension(R.styleable.SherlockActionBar_heightABS, 0);

    a.recycle();

    mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle);
    mHomeLayout.setOnClickListener(mUpClickListener);
    mHomeLayout.setClickable(true);
    mHomeLayout.setFocusable(true);
  }