Example usage for android.content.res Resources getInteger

List of usage examples for android.content.res Resources getInteger

Introduction

In this page you can find the example usage for android.content.res Resources getInteger.

Prototype

public int getInteger(@IntegerRes int id) throws NotFoundException 

Source Link

Document

Return an integer associated with a particular resource ID.

Usage

From source file:com.android.leanlauncher.Workspace.java

/**
 * Used to inflate the Workspace from XML.
 *
 * @param context The application's context.
 * @param attrs The attributes set containing the Workspace's customization values.
 * @param defStyle Unused./*from   w w w.  j a  v a  2 s.c  o  m*/
 */
public Workspace(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    mOutlineHelper = HolographicOutlineHelper.obtain(context);

    mLauncher = (Launcher) context;
    final Resources res = getResources();
    mWallpaperManager = WallpaperManager.getInstance(context);

    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0);
    mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f;
    mOverviewModeShrinkFactor = grid.getOverviewModeScale();
    a.recycle();

    setOnHierarchyChangeListener(this);
    setHapticFeedbackEnabled(false);

    initWorkspace();

    // Disable multitouch across the workspace/all apps/customize tray
    setMotionEventSplittingEnabled(true);
    setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}

From source file:com.tct.mail.browse.ConversationItemViewCoordinates.java

private ConversationItemViewCoordinates(final Context context, final Config config,
        final CoordinatesCache cache) {
    Utils.traceBeginSection("CIV coordinates constructor");
    final Resources res = context.getResources();
    mMinListWidthForWide = res.getDimensionPixelSize(R.dimen.list_min_width_is_wide);

    mMode = calculateMode(res, config);//w  ww . j  a  v  a  2  s .c  o m

    final int layoutId = R.layout.conversation_item_view;

    ViewGroup view = (ViewGroup) cache.getView(layoutId);
    if (view == null) {
        view = (ViewGroup) LayoutInflater.from(context).inflate(layoutId, null);
        cache.put(layoutId, view);
    }

    // Show/hide optional views before measure/layout call
    final TextView folders = (TextView) view.findViewById(R.id.folders);
    folders.setVisibility(config.areFoldersVisible() ? View.VISIBLE : View.GONE);

    View contactImagesView = view.findViewById(R.id.contact_image);

    switch (config.getGadgetMode()) {
    case GADGET_CONTACT_PHOTO:
        contactImagesView.setVisibility(View.VISIBLE);
        break;
    case GADGET_CHECKBOX:
        contactImagesView.setVisibility(View.GONE);
        contactImagesView = null;
        break;
    default:
        contactImagesView.setVisibility(View.GONE);
        contactImagesView = null;
        break;
    }

    final View replyState = view.findViewById(R.id.reply_state);
    replyState.setVisibility(config.isReplyStateVisible() ? View.VISIBLE : View.GONE);

    final View personalIndicator = view.findViewById(R.id.personal_indicator);
    personalIndicator.setVisibility(config.isPersonalIndicatorVisible() ? View.VISIBLE : View.GONE);

    setFramePadding(context, view, config.useFullPadding());

    // Layout the appropriate view.
    ViewCompat.setLayoutDirection(view, config.getLayoutDirection());
    final int widthSpec = MeasureSpec.makeMeasureSpec(config.getWidth(), MeasureSpec.EXACTLY);
    final int heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);

    view.measure(widthSpec, heightSpec);
    view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());

    // Once the view is measured, let's calculate the dynamic width variables.
    folderLayoutWidth = (int) (view.getWidth() * res.getInteger(R.integer.folder_max_width_proportion) / 100.0);
    folderCellWidth = (int) (view.getWidth() * res.getInteger(R.integer.folder_cell_max_width_proportion)
            / 100.0);

    //        Utils.dumpViewTree((ViewGroup) view);

    // Records coordinates.

    // Contact images view
    if (contactImagesView != null) {
        contactImagesWidth = contactImagesView.getWidth();
        contactImagesHeight = contactImagesView.getHeight();
        contactImagesX = getX(contactImagesView);
        contactImagesY = getY(contactImagesView);
    } else {
        contactImagesX = contactImagesY = contactImagesWidth = contactImagesHeight = 0;
    }

    final boolean isRtl = ViewUtils.isViewRtl(view);

    final View star = view.findViewById(R.id.star);
    final int starPadding = res.getDimensionPixelSize(R.dimen.conv_list_star_padding_start);
    starX = getX(star) + (isRtl ? 0 : starPadding);
    starY = getY(star);
    starWidth = star.getWidth();

    final TextView senders = (TextView) view.findViewById(R.id.senders);
    final int sendersTopAdjust = getLatinTopAdjustment(senders);
    sendersX = getX(senders);
    sendersY = getY(senders) + sendersTopAdjust;
    sendersWidth = senders.getWidth();
    sendersHeight = senders.getHeight();
    sendersLineCount = SINGLE_LINE;
    sendersFontSize = senders.getTextSize();

    final TextView subject = (TextView) view.findViewById(R.id.subject);
    final int subjectTopAdjust = getLatinTopAdjustment(subject);
    subjectX = getX(subject);
    subjectY = getY(subject) + subjectTopAdjust;
    subjectWidth = subject.getWidth();
    subjectHeight = subject.getHeight();
    subjectFontSize = subject.getTextSize();
    // TS: chao.zhang 2015-09-14 EMAIL FEATURE-585337 ADD_S
    final TextView status = (TextView) view.findViewById(R.id.status);
    final int statusTopAdjust = getLatinTopAdjustment(status);
    statusX = getX(status);
    statusY = getY(status) + statusTopAdjust;
    statusWidth = status.getWidth();
    statusHeight = status.getHeight();
    statusFontSize = status.getTextSize();
    statusPaddingStart = ViewUtils.getPaddingStart(status);
    statusPanddingEnd = ViewUtils.getPaddingEnd(status);
    // TS: chao.zhang 2015-09-14 EMAIL FEATURE-585337 ADD_E
    final TextView snippet = (TextView) view.findViewById(R.id.snippet);
    final int snippetTopAdjust = getLatinTopAdjustment(snippet);
    snippetX = getX(snippet);
    snippetY = getY(snippet) + snippetTopAdjust;
    maxSnippetWidth = snippet.getWidth();
    snippetHeight = snippet.getHeight();
    snippetFontSize = snippet.getTextSize();

    if (config.areFoldersVisible()) {
        // vertically align folders min left edge with subject
        foldersLeft = getX(folders);
        foldersRight = foldersLeft + folders.getWidth();
        foldersY = getY(folders) + sendersTopAdjust;
        foldersHeight = folders.getHeight();
        foldersTypeface = folders.getTypeface();
        foldersTextBottomPadding = res.getDimensionPixelSize(R.dimen.folders_text_bottom_padding);
        foldersFontSize = folders.getTextSize();
    } else {
        foldersLeft = 0;
        foldersRight = 0;
        foldersY = 0;
        foldersHeight = 0;
        foldersTypeface = null;
        foldersTextBottomPadding = 0;
        foldersFontSize = 0;
    }

    final View colorBlock = view.findViewById(R.id.color_block);
    if (config.isColorBlockVisible() && colorBlock != null) {
        colorBlockX = getX(colorBlock);
        colorBlockY = getY(colorBlock);
        colorBlockWidth = colorBlock.getWidth();
        colorBlockHeight = colorBlock.getHeight();
    } else {
        colorBlockX = colorBlockY = colorBlockWidth = colorBlockHeight = 0;
    }

    if (config.isReplyStateVisible()) {
        replyStateX = getX(replyState);
        replyStateY = getY(replyState);
    } else {
        replyStateX = replyStateY = 0;
    }

    if (config.isPersonalIndicatorVisible()) {
        personalIndicatorX = getX(personalIndicator);
        personalIndicatorY = getY(personalIndicator);
    } else {
        personalIndicatorX = personalIndicatorY = 0;
    }

    final View infoIcon = view.findViewById(R.id.info_icon);
    infoIconX = getX(infoIcon);
    infoIconXRight = infoIconX + infoIcon.getWidth();
    infoIconY = getY(infoIcon);

    final TextView date = (TextView) view.findViewById(R.id.date);
    dateX = getX(date);
    dateXRight = dateX + date.getWidth();
    dateY = getY(date);
    datePaddingStart = ViewUtils.getPaddingStart(date);
    dateFontSize = date.getTextSize();
    dateYBaseline = dateY + getLatinTopAdjustment(date) + date.getBaseline();

    final View paperclip = view.findViewById(R.id.paperclip);
    paperclipY = getY(paperclip);
    paperclipPaddingStart = ViewUtils.getPaddingStart(paperclip);

    height = view.getHeight() + sendersTopAdjust;
    Utils.traceEndSection();
}

From source file:com.androzic.vnspeech.MapFragment.java

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    Resources resources = getResources();
    if (getString(R.string.pref_wakelock).equals(key)) {
        keepScreenOn = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_wakelock));
        map.setKeepScreenOn(keepScreenOn);
    } else if (getString(R.string.pref_showdistance_int).equals(key)) {
        showDistance = Integer.parseInt(sharedPreferences.getString(key, getString(R.string.def_showdistance)));
    } else if (getString(R.string.pref_hidemapinfo).equals(key)) {
        mapInfoHideDelay = Integer.parseInt(sharedPreferences.getString(key, "2147483647"));
    } else if (getString(R.string.pref_hidesatinfo).equals(key)) {
        satInfoHideDelay = Integer.parseInt(sharedPreferences.getString(key, "2147483647"));
    } else if (getString(R.string.pref_hidenavinfo).equals(key)) {
        navInfoHideDelay = Integer.parseInt(sharedPreferences.getString(key, "2147483647"));
    } else if (getString(R.string.pref_maprenderinterval).equals(key)) {
        updatePeriod = sharedPreferences.getInt(key, resources.getInteger(R.integer.def_maprenderinterval))
                * 100;/*from w  w  w . ja v a2 s .  co  m*/
    } else if (getString(R.string.pref_mapfollowonloc).equals(key)) {
        followOnLocation = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapfollowonloc));
    } else if (getString(R.string.pref_mapdiminterval).equals(key)) {
        dimInterval = sharedPreferences.getInt(key, resources.getInteger(R.integer.def_mapdiminterval)) * 1000;
    } else if (getString(R.string.pref_mapdimvalue).equals(key)) {
        dimValue = sharedPreferences.getInt(key, resources.getInteger(R.integer.def_mapdimvalue));
    } else if (getString(R.string.pref_mapdim).equals(key)) {
        autoDim = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapdim));
        dimScreen();
    } else if (getString(R.string.pref_unfollowontap).equals(key)) {
        map.setStrictUnfollow(
                !sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_unfollowontap)));
    } else if (getString(R.string.pref_lookahead).equals(key)) {
        map.setLookAhead(sharedPreferences.getInt(key, resources.getInteger(R.integer.def_lookahead)));
    } else if (getString(R.string.pref_mapbest).equals(key)) {
        map.setBestMapEnabled(sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapbest)));
    } else if (getString(R.string.pref_mapbestinterval).equals(key)) {
        map.setBestMapInterval(
                sharedPreferences.getInt(key, resources.getInteger(R.integer.def_mapbestinterval)) * 1000);
    } else if (getString(R.string.pref_mapforcezoom).equals(key)) {
        forceZoomMap = Integer.parseInt(sharedPreferences.getString(key, "1"));
    } else if (getString(R.string.pref_maprotation).equals(key)) {
        int rotation = Integer
                .parseInt(sharedPreferences.getString(key, resources.getString(R.string.def_maprotation)));
        map.setMapRotation(rotation);
    } else if (getString(R.string.pref_scalebarbg).equals(key)) {
        map.setDrawScaleBarBackground(
                sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_scalebarbg)));
    } else if (getString(R.string.pref_scalebarcolor).equals(key)) {
        map.setScaleBarColor(sharedPreferences.getInt(key, resources.getColor(R.color.scalebar)));
    } else if (getString(R.string.pref_scalebarbgcolor).equals(key)) {
        map.setScaleBarBackgroundColor(sharedPreferences.getInt(key, resources.getColor(R.color.scalebarbg)));
    } else if (getString(R.string.pref_hidemapcross).equals(key)) {
        int delay = Integer.parseInt(sharedPreferences.getString(key, "5"));
        map.setCrossCursorHideDelay(delay);
    } else if (getString(R.string.pref_mapcrosscolor).equals(key)) {
        map.setCrossColor(sharedPreferences.getInt(key, resources.getColor(R.color.mapcross)));
    } else if (getString(R.string.pref_cursorvector).equals(key)
            || getString(R.string.pref_cursorvectormlpr).equals(key)) {
        map.setCursorVector(
                Integer.parseInt(sharedPreferences.getString(getString(R.string.pref_cursorvector),
                        getString(R.string.def_cursorvector))),
                sharedPreferences.getInt(getString(R.string.pref_cursorvectormlpr),
                        resources.getInteger(R.integer.def_cursorvectormlpr)));
    } else if (getString(R.string.pref_cursorcolor).equals(key)) {
        map.setCursorColor(sharedPreferences.getInt(key, resources.getColor(R.color.cursor)));
    } else if (getString(R.string.pref_navigation_proximity).equals(key)) {
        map.setProximity(Integer
                .parseInt(sharedPreferences.getString(key, getString(R.string.def_navigation_proximity))));
    } else if (getString(R.string.pref_unitspeed).equals(key)) {
        speedUnit.setText(StringFormatter.speedAbbr);
    } else if (getString(R.string.pref_unitelevation).equals(key)) {
        elevationUnit.setText(StringFormatter.elevationAbbr);
    } else if (getString(R.string.pref_unitangle).equals(key)) {
        trackUnit.setText(StringFormatter.angleAbbr);
        bearingUnit.setText(StringFormatter.angleAbbr);
        turnUnit.setText(StringFormatter.angleAbbr);
    }
}

From source file:com.aliyun.homeshell.Folder.java

/**
 * Used to inflate the Workspace from XML.
 *
 * @param context The application's context.
 * @param attrs The attribtues set containing the Workspace's customization values.
 *///from w w  w .ja  v  a  2  s  . co  m
public Folder(Context context, AttributeSet attrs) {
    super(context, attrs);
    setAlwaysDrawnWithCacheEnabled(false);
    mInflater = LayoutInflater.from(context);

    /* YUNOS BEGIN */
    //##date:2014/04/16 ##author:nater.wg ##BugID:110407
    // Enhance ConfigManager.
    /*
            Resources res = getResources();
            mMaxCountX = res.getInteger(R.integer.folder_max_count_x);
            mMaxCountY = res.getInteger(R.integer.folder_max_count_y);
            mMaxNumItems = res.getInteger(R.integer.folder_max_num_items);
            if (mMaxCountX < 0 || mMaxCountY < 0 || mMaxNumItems < 0) {
    mMaxCountX = LauncherModel.getCellCountX();
    mMaxCountY = LauncherModel.getCellCountY();
    mMaxNumItems = mMaxCountX * mMaxCountY;
            }
    */
    mLauncher = (Launcher) context;
    mIconManager = mLauncher.getIconManager();
    mMaxCountX = ConfigManager.getFolderMaxCountX();
    mMaxCountY = mIconManager.supprtCardIcon() ? ConfigManager.getCardFolderMaxCountY()
            : ConfigManager.getFolderMaxCountY();
    mMaxNumItems = mMaxCountX * mMaxCountY;
    /* YUNOS END */

    Resources res = getResources();
    mInputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

    mExpandDuration = res.getInteger(R.integer.config_folderAnimDuration);

    if (sDefaultFolderName == null) {
        sDefaultFolderName = res.getString(R.string.folder_name);
    }
    /*
     * if (sHintText == null) { sHintText =
     * res.getString(R.string.folder_hint_text); }
     */
    // We need this view to be focusable in touch mode so that when text editing of the folder
    // name is complete, we have something to focus on, thus hiding the cursor and giving
    // reliable behvior when clicking the text field (since it will always gain focus on click).
    setFocusableInTouchMode(true);

    mShortcutInfoCache = new ShortcutInfo();
    mIconManager = mLauncher.getIconManager();
    /* YUNOS BEGIN */
    //##date:2014/09/23 ##author:andy.zx ##BugID:5244732
    Display display = mLauncher.getWindowManager().getDefaultDisplay();
    display.getSize(mDisplaySize);
    /* YUNOS END */
}

From source file:com.zyk.launcher.AsyncTaskCallback.java

@Override
protected void init() {
    super.init();
    mCenterPagesVertically = false;//  w  w  w . jav  a  2 s  .  com

    Context context = getContext();
    Resources r = context.getResources();
    setDragSlopeThreshold(r.getInteger(R.integer.config_appsCustomizeDragSlopeThreshold) / 100f);

}

From source file:com.android.mail.browse.ConversationItemView.java

private static synchronized void getItemViewResources(Context context) {
    if (sConfigurationChangedReceiver == null) {
        sConfigurationChangedReceiver = new BroadcastReceiver() {
            @Override/*from w w w.  ja va2  s. c  o m*/
            public void onReceive(Context context, Intent intent) {
                STAR_OFF = null;
                getItemViewResources(context);
            }
        };
        context.registerReceiver(sConfigurationChangedReceiver,
                new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED));
    }
    if (STAR_OFF == null) {
        final Resources res = context.getResources();
        // Initialize static bitmaps.
        STAR_OFF = BitmapFactory.decodeResource(res, R.drawable.ic_star_outline_20dp);
        STAR_ON = BitmapFactory.decodeResource(res, R.drawable.ic_star_20dp);
        ATTACHMENT = BitmapFactory.decodeResource(res, R.drawable.ic_attach_file_18dp);
        ONLY_TO_ME = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_double);
        TO_ME_AND_OTHERS = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_single);
        IMPORTANT_ONLY_TO_ME = BitmapFactory.decodeResource(res,
                R.drawable.ic_email_caret_double_important_unread);
        IMPORTANT_TO_ME_AND_OTHERS = BitmapFactory.decodeResource(res,
                R.drawable.ic_email_caret_single_important_unread);
        IMPORTANT = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_none_important_unread);
        STATE_REPLIED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_reply_holo_light);
        STATE_FORWARDED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_forward_holo_light);
        STATE_REPLIED_AND_FORWARDED = BitmapFactory.decodeResource(res,
                R.drawable.ic_badge_reply_forward_holo_light);
        STATE_CALENDAR_INVITE = BitmapFactory.decodeResource(res, R.drawable.ic_badge_invite_holo_light);
        FOCUSED_CONVERSATION_HIGHLIGHT = res.getDrawable(R.drawable.visible_conversation_highlight);

        // Initialize colors.
        sActivatedTextSpan = CharacterStyle
                .wrap(new ForegroundColorSpan(res.getColor(R.color.senders_text_color)));
        sSendersTextColor = res.getColor(R.color.senders_text_color);
        sSubjectTextUnreadSpan = new TextAppearanceSpan(context, R.style.SubjectAppearanceUnreadStyle);
        sSubjectTextReadSpan = new TextAppearanceSpan(context, R.style.SubjectAppearanceReadStyle);

        sBadgeTextSpan = new TextAppearanceSpan(context, R.style.BadgeTextStyle);
        sBadgeBackgroundSpan = new BackgroundColorSpan(res.getColor(R.color.badge_background_color));
        sDateTextColorRead = res.getColor(R.color.date_text_color_read);
        sDateTextColorUnread = res.getColor(R.color.date_text_color_unread);
        sStarTouchSlop = res.getDimensionPixelSize(R.dimen.star_touch_slop);
        sSenderImageTouchSlop = res.getDimensionPixelSize(R.dimen.sender_image_touch_slop);
        sShrinkAnimationDuration = res.getInteger(R.integer.shrink_animation_duration);
        sSlideAnimationDuration = res.getInteger(R.integer.slide_animation_duration);
        // Initialize static color.
        sSendersSplitToken = res.getString(R.string.senders_split_token);
        sElidedPaddingToken = res.getString(R.string.elided_padding_token);
        sScrollSlop = res.getInteger(R.integer.swipeScrollSlop);
        sFoldersMaxCount = res.getInteger(R.integer.conversation_list_max_folder_count);
        sCabAnimationDuration = res.getInteger(R.integer.conv_item_view_cab_anim_duration);
        sBadgePaddingExtraWidth = res.getDimensionPixelSize(R.dimen.badge_padding_extra_width);
        sBadgeRoundedCornerRadius = res.getDimensionPixelSize(R.dimen.badge_rounded_corner_radius);
        sDividerPaint.setColor(res.getColor(R.color.divider_color));
        sDividerHeight = res.getDimensionPixelSize(R.dimen.divider_height);
    }
}

From source file:com.xandy.calendar.AllInOneActivity.java

@Override
protected void onCreate(Bundle icicle) {
    if (Utils.getSharedPreference(this, OtherPreferences.KEY_OTHER_1, false)) {
        setTheme(R.style.CalendarTheme_WithActionBarWallpaper);
    }/*from   www  .  j  av a 2  s.c  om*/
    super.onCreate(icicle);

    if (icicle != null && icicle.containsKey(BUNDLE_KEY_CHECK_ACCOUNTS)) {
        mCheckForAccounts = icicle.getBoolean(BUNDLE_KEY_CHECK_ACCOUNTS);
    }
    // Launch add google account if this is first time and there are no
    // accounts yet
    if (mCheckForAccounts && !Utils.getSharedPreference(this, GeneralPreferences.KEY_SKIP_SETUP, false)) {

        mHandler = new QueryHandler(this.getContentResolver());
        mHandler.startQuery(0, null, Calendars.CONTENT_URI, new String[] { Calendars._ID }, null,
                null /* selection args */, null /* sort order */);
    }

    // This needs to be created before setContentView
    mController = CalendarController.getInstance(this);

    // Get time from intent or icicle
    long timeMillis = -1;
    int viewType = -1;
    final Intent intent = getIntent();
    if (icicle != null) {
        timeMillis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME);
        viewType = icicle.getInt(BUNDLE_KEY_RESTORE_VIEW, -1);
    } else {
        String action = intent.getAction();
        if (Intent.ACTION_VIEW.equals(action)) {
            // Open EventInfo later
            timeMillis = parseViewAction(intent);
        }

        if (timeMillis == -1) {
            timeMillis = Utils.timeFromIntentInMillis(intent);
        }
    }

    if (viewType == -1 || viewType > ViewType.MAX_VALUE) {
        viewType = Utils.getViewTypeFromIntentAndSharedPref(this);
    }
    mTimeZone = Utils.getTimeZone(this, mHomeTimeUpdater);
    Time t = new Time(mTimeZone);
    t.set(timeMillis);

    if (DEBUG) {
        if (icicle != null && intent != null) {
            Log.d(TAG, "both, icicle:" + icicle.toString() + "  intent:" + intent.toString());
        } else {
            Log.d(TAG, "not both, icicle:" + icicle + " intent:" + intent);
        }
    }

    Resources res = getResources();
    mHideString = res.getString(R.string.hide_controls);
    mShowString = res.getString(R.string.show_controls);
    mOrientation = res.getConfiguration().orientation;
    if (mOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        mControlsAnimateWidth = (int) res.getDimension(R.dimen.calendar_controls_width);
        if (mControlsParams == null) {
            mControlsParams = new LayoutParams(mControlsAnimateWidth, 0);
        }
        mControlsParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    } else {
        // Make sure width is in between allowed min and max width values
        mControlsAnimateWidth = Math.max(res.getDisplayMetrics().widthPixels * 45 / 100,
                (int) res.getDimension(R.dimen.min_portrait_calendar_controls_width));
        mControlsAnimateWidth = Math.min(mControlsAnimateWidth,
                (int) res.getDimension(R.dimen.max_portrait_calendar_controls_width));
    }

    mControlsAnimateHeight = (int) res.getDimension(R.dimen.calendar_controls_height);

    mHideControls = !Utils.getSharedPreference(this, GeneralPreferences.KEY_SHOW_CONTROLS, true);
    mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config);
    mIsTabletConfig = Utils.getConfigBool(this, R.bool.tablet_config);
    mShowAgendaWithMonth = Utils.getConfigBool(this, R.bool.show_agenda_with_month);
    mShowCalendarControls = Utils.getConfigBool(this, R.bool.show_calendar_controls);
    mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda);
    mShowEventInfoFullScreenAgenda = Utils.getConfigBool(this, R.bool.agenda_show_event_info_full_screen);
    mShowEventInfoFullScreen = Utils.getConfigBool(this, R.bool.show_event_info_full_screen);
    mCalendarControlsAnimationTime = res.getInteger(R.integer.calendar_controls_animation_time);
    Utils.setAllowWeekForDetailView(mIsMultipane);

    // setContentView must be called before configureActionBar
    setContentView(R.layout.all_in_one);

    if (mIsTabletConfig) {
        mDateRange = (TextView) findViewById(R.id.date_bar);
        mWeekTextView = (TextView) findViewById(R.id.week_num);
    } else {
        mDateRange = (TextView) getLayoutInflater().inflate(R.layout.date_range_title, null);
    }

    // configureActionBar auto-selects the first tab you add, so we need to
    // call it before we set up our own fragments to make sure it doesn't
    // overwrite us
    configureActionBar(viewType);

    mHomeTime = (TextView) findViewById(R.id.home_time);
    mMiniMonth = findViewById(R.id.mini_month);
    if (mIsTabletConfig && mOrientation == Configuration.ORIENTATION_PORTRAIT) {
        mMiniMonth.setLayoutParams(
                new RelativeLayout.LayoutParams(mControlsAnimateWidth, mControlsAnimateHeight));
    }
    mCalendarsList = findViewById(R.id.calendar_list);
    mMiniMonthContainer = findViewById(R.id.mini_month_container);
    mSecondaryPane = findViewById(R.id.secondary_pane);

    // Must register as the first activity because this activity can modify
    // the list of event handlers in it's handle method. This affects who
    // the rest of the handlers the controller dispatches to are.
    mController.registerFirstEventHandler(HANDLER_KEY, this);

    initFragments(timeMillis, viewType, icicle);

    // Listen for changes that would require this to be refreshed
    SharedPreferences prefs = GeneralPreferences.getSharedPreferences(this);
    prefs.registerOnSharedPreferenceChangeListener(this);

    mContentResolver = getContentResolver();
}

From source file:com.android.leanlauncher.LauncherTransitionable.java

private void showAppsCustomizeHelper(final boolean animated, final boolean springLoaded,
        final AppsCustomizePagedView.ContentType contentType) {
    if (mStateAnimation != null) {
        mStateAnimation.setDuration(0);/*  www .  ja v a  2  s .  co  m*/
        mStateAnimation.cancel();
        mStateAnimation = null;
    }

    boolean material = Utilities.isLmpOrAbove();

    final Resources res = getResources();

    final int revealDuration = res.getInteger(R.integer.config_appsCustomizeRevealTime);
    final int itemsAlphaStagger = res.getInteger(R.integer.config_appsCustomizeItemsAlphaStagger);

    final View fromView = mWorkspace;
    final AppsCustomizeTabHost toView = mAppsCustomizeTabHost;

    final ArrayList<View> layerViews = new ArrayList<View>();

    Workspace.State workspaceState = contentType == AppsCustomizePagedView.ContentType.Widgets
            ? Workspace.State.OVERVIEW_HIDDEN
            : Workspace.State.NORMAL_HIDDEN;
    Animator workspaceAnim = mWorkspace.getChangeStateAnimation(workspaceState, animated, layerViews);
    // Set the content type for the all apps/widgets space
    mAppsCustomizeTabHost.setContentTypeImmediate(contentType);

    // If for some reason our views aren't initialized, don't animate
    boolean initialized = getAllAppsButton() != null;

    if (animated && initialized) {
        mStateAnimation = LauncherAnimUtils.createAnimatorSet();
        final AppsCustomizePagedView content = (AppsCustomizePagedView) toView
                .findViewById(R.id.apps_customize_pane_content);

        final View page = content.getPageAt(content.getCurrentPage());
        final View revealView = toView.findViewById(R.id.fake_page);

        final boolean isWidgetTray = contentType == AppsCustomizePagedView.ContentType.Widgets;
        revealView.setBackgroundColor(getResources().getColor(R.color.widget_text_panel));

        // Hide the real page background, and swap in the fake one
        content.setPageBackgroundsVisible(false);
        revealView.setVisibility(View.VISIBLE);
        // We need to hide this view as the animation start will be posted.
        revealView.setAlpha(0);

        int width = revealView.getMeasuredWidth();
        int height = revealView.getMeasuredHeight();
        float revealRadius = (float) Math.sqrt((width * width) / 4 + (height * height) / 4);

        revealView.setTranslationY(0);
        revealView.setTranslationX(0);

        // Get the y delta between the center of the page and the center of the all apps button
        int[] allAppsToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView, getAllAppsButton(), null);

        float alpha = 0;
        float xDrift = 0;
        float yDrift = 0;
        if (material) {
            alpha = isWidgetTray ? 0.3f : 1f;
            yDrift = isWidgetTray ? height / 2 : allAppsToPanelDelta[1];
            xDrift = isWidgetTray ? 0 : allAppsToPanelDelta[0];
        } else {
            yDrift = 2 * height / 3;
            xDrift = 0;
        }
        final float initAlpha = alpha;

        revealView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        layerViews.add(revealView);
        PropertyValuesHolder panelAlpha = PropertyValuesHolder.ofFloat("alpha", initAlpha, 1f);
        PropertyValuesHolder panelDriftY = PropertyValuesHolder.ofFloat("translationY", yDrift, 0);
        PropertyValuesHolder panelDriftX = PropertyValuesHolder.ofFloat("translationX", xDrift, 0);

        ObjectAnimator panelAlphaAndDrift = ObjectAnimator.ofPropertyValuesHolder(revealView, panelAlpha,
                panelDriftY, panelDriftX);

        panelAlphaAndDrift.setDuration(revealDuration);
        panelAlphaAndDrift.setInterpolator(new LogDecelerateInterpolator(100, 0));

        mStateAnimation.play(panelAlphaAndDrift);

        if (page != null) {
            page.setVisibility(View.VISIBLE);
            page.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            layerViews.add(page);

            ObjectAnimator pageDrift = ObjectAnimator.ofFloat(page, "translationY", yDrift, 0);
            page.setTranslationY(yDrift);
            pageDrift.setDuration(revealDuration);
            pageDrift.setInterpolator(new LogDecelerateInterpolator(100, 0));
            pageDrift.setStartDelay(itemsAlphaStagger);
            mStateAnimation.play(pageDrift);

            page.setAlpha(0f);
            ObjectAnimator itemsAlpha = ObjectAnimator.ofFloat(page, "alpha", 0f, 1f);
            itemsAlpha.setDuration(revealDuration);
            itemsAlpha.setInterpolator(new AccelerateInterpolator(1.5f));
            itemsAlpha.setStartDelay(itemsAlphaStagger);
            mStateAnimation.play(itemsAlpha);
        }

        View pageIndicators = toView.findViewById(R.id.apps_customize_page_indicator);
        pageIndicators.setAlpha(0.01f);
        ObjectAnimator indicatorsAlpha = ObjectAnimator.ofFloat(pageIndicators, "alpha", 1f);
        indicatorsAlpha.setDuration(revealDuration);
        mStateAnimation.play(indicatorsAlpha);

        if (material) {
            final View allApps = getAllAppsButton();
            int allAppsButtonSize = LauncherAppState.getInstance().getDynamicGrid()
                    .getDeviceProfile().allAppsButtonVisualSize;
            float startRadius = isWidgetTray ? 0 : allAppsButtonSize / 2;
            Animator reveal = ViewAnimationUtils.createCircularReveal(revealView, width / 2, height / 2,
                    startRadius, revealRadius);
            reveal.setDuration(revealDuration);
            reveal.setInterpolator(new LogDecelerateInterpolator(100, 0));

            reveal.addListener(new AnimatorListenerAdapter() {
                public void onAnimationStart(Animator animation) {
                    if (!isWidgetTray) {
                        allApps.setVisibility(View.INVISIBLE);
                    }
                }

                public void onAnimationEnd(Animator animation) {
                    if (!isWidgetTray) {
                        allApps.setVisibility(View.VISIBLE);
                    }
                }
            });
            mStateAnimation.play(reveal);
        }

        mStateAnimation.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                dispatchOnLauncherTransitionEnd(fromView, animated, false);
                dispatchOnLauncherTransitionEnd(toView, animated, false);

                revealView.setVisibility(View.INVISIBLE);
                revealView.setLayerType(View.LAYER_TYPE_NONE, null);
                if (page != null) {
                    page.setLayerType(View.LAYER_TYPE_NONE, null);
                }
                content.setPageBackgroundsVisible(true);

                // This can hold unnecessary references to views.
                mStateAnimation = null;
            }

        });

        if (workspaceAnim != null) {
            mStateAnimation.play(workspaceAnim);
        }

        dispatchOnLauncherTransitionPrepare(fromView, animated, false);
        dispatchOnLauncherTransitionPrepare(toView, animated, false);
        final AnimatorSet stateAnimation = mStateAnimation;
        final Runnable startAnimRunnable = new Runnable() {
            public void run() {
                // Check that mStateAnimation hasn't changed while
                // we waited for a layout/draw pass
                if (mStateAnimation != stateAnimation)
                    return;
                dispatchOnLauncherTransitionStart(fromView, animated, false);
                dispatchOnLauncherTransitionStart(toView, animated, false);

                revealView.setAlpha(initAlpha);
                if (Utilities.isLmpOrAbove()) {
                    for (int i = 0; i < layerViews.size(); i++) {
                        View v = layerViews.get(i);
                        if (v != null) {
                            if (Utilities.isViewAttachedToWindow(v))
                                v.buildLayer();
                        }
                    }
                }
                mStateAnimation.start();
            }
        };
        toView.bringToFront();
        toView.setVisibility(View.VISIBLE);
        toView.post(startAnimRunnable);
    } else {
        toView.setTranslationX(0.0f);
        toView.setTranslationY(0.0f);
        toView.setScaleX(1.0f);
        toView.setScaleY(1.0f);
        toView.setVisibility(View.VISIBLE);
        toView.bringToFront();

        dispatchOnLauncherTransitionPrepare(fromView, animated, false);
        dispatchOnLauncherTransitionStart(fromView, animated, false);
        dispatchOnLauncherTransitionEnd(fromView, animated, false);
        dispatchOnLauncherTransitionPrepare(toView, animated, false);
        dispatchOnLauncherTransitionStart(toView, animated, false);
        dispatchOnLauncherTransitionEnd(toView, animated, false);
    }
}

From source file:com.android.leanlauncher.LauncherTransitionable.java

/**
 * Zoom the camera back into the workspace, hiding 'fromView'.
 * This is the opposite of showAppsCustomizeHelper.
 *
 * @param animated If true, the transition will be animated.
 */// ww  w .ja v  a  2 s.  c  o m
private void hideAppsCustomizeHelper(Workspace.State toState, final boolean animated,
        final boolean springLoaded, final Runnable onCompleteRunnable) {

    if (mStateAnimation != null) {
        mStateAnimation.setDuration(0);
        mStateAnimation.cancel();
        mStateAnimation = null;
    }

    boolean material = Utilities.isLmpOrAbove();
    Resources res = getResources();

    final int revealDuration = res.getInteger(R.integer.config_appsCustomizeConcealTime);
    final int itemsAlphaStagger = res.getInteger(R.integer.config_appsCustomizeItemsAlphaStagger);

    final View fromView = mAppsCustomizeTabHost;
    final View toView = mWorkspace;
    Animator workspaceAnim = null;
    final ArrayList<View> layerViews = new ArrayList<View>();

    if (toState == Workspace.State.NORMAL) {
        workspaceAnim = mWorkspace.getChangeStateAnimation(toState, animated, layerViews);
    } else if (toState == Workspace.State.SPRING_LOADED || toState == Workspace.State.OVERVIEW) {
        workspaceAnim = mWorkspace.getChangeStateAnimation(toState, animated, layerViews);
    }

    // If for some reason our views aren't initialized, don't animate
    boolean initialized = getAllAppsButton() != null;

    if (animated && initialized) {
        mStateAnimation = LauncherAnimUtils.createAnimatorSet();
        if (workspaceAnim != null) {
            mStateAnimation.play(workspaceAnim);
        }

        final AppsCustomizePagedView content = (AppsCustomizePagedView) fromView
                .findViewById(R.id.apps_customize_pane_content);

        final View page = content.getPageAt(content.getNextPage());

        // We need to hide side pages of the Apps / Widget tray to avoid some ugly edge cases
        int count = content.getChildCount();
        for (int i = 0; i < count; i++) {
            View child = content.getChildAt(i);
            if (child != page) {
                child.setVisibility(View.INVISIBLE);
            }
        }
        final View revealView = fromView.findViewById(R.id.fake_page);

        // hideAppsCustomizeHelper is called in some cases when it is already hidden
        // don't perform all these no-op animations. In particularly, this was causing
        // the all-apps button to pop in and out.
        if (fromView.getVisibility() == View.VISIBLE) {
            AppsCustomizePagedView.ContentType contentType = content.getContentType();
            final boolean isWidgetTray = contentType == AppsCustomizePagedView.ContentType.Widgets;

            revealView.setBackgroundColor(getResources().getColor(R.color.widget_text_panel));

            int width = revealView.getMeasuredWidth();
            int height = revealView.getMeasuredHeight();
            float revealRadius = (float) Math.sqrt((width * width) / 4 + (height * height) / 4);

            // Hide the real page background, and swap in the fake one
            revealView.setVisibility(View.VISIBLE);
            content.setPageBackgroundsVisible(false);

            final View allAppsButton = getAllAppsButton();
            revealView.setTranslationY(0);
            int[] allAppsToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView, allAppsButton, null);

            float xDrift = 0;
            float yDrift = 0;
            if (material) {
                yDrift = isWidgetTray ? height / 2 : allAppsToPanelDelta[1];
                xDrift = isWidgetTray ? 0 : allAppsToPanelDelta[0];
            } else {
                yDrift = 2 * height / 3;
                xDrift = 0;
            }

            revealView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            TimeInterpolator decelerateInterpolator = material ? new LogDecelerateInterpolator(100, 0)
                    : new DecelerateInterpolator(1f);

            // The vertical motion of the apps panel should be delayed by one frame
            // from the conceal animation in order to give the right feel. We correpsondingly
            // shorten the duration so that the slide and conceal end at the same time.
            ObjectAnimator panelDriftY = LauncherAnimUtils.ofFloat(revealView, "translationY", 0, yDrift);
            panelDriftY.setDuration(revealDuration - SINGLE_FRAME_DELAY);
            panelDriftY.setStartDelay(itemsAlphaStagger + SINGLE_FRAME_DELAY);
            panelDriftY.setInterpolator(decelerateInterpolator);
            mStateAnimation.play(panelDriftY);

            ObjectAnimator panelDriftX = LauncherAnimUtils.ofFloat(revealView, "translationX", 0, xDrift);
            panelDriftX.setDuration(revealDuration - SINGLE_FRAME_DELAY);
            panelDriftX.setStartDelay(itemsAlphaStagger + SINGLE_FRAME_DELAY);
            panelDriftX.setInterpolator(decelerateInterpolator);
            mStateAnimation.play(panelDriftX);

            if (isWidgetTray || !material) {
                float finalAlpha = material ? 0.4f : 0f;
                revealView.setAlpha(1f);
                ObjectAnimator panelAlpha = LauncherAnimUtils.ofFloat(revealView, "alpha", 1f, finalAlpha);
                panelAlpha.setDuration(material ? revealDuration : 150);
                panelAlpha.setInterpolator(decelerateInterpolator);
                panelAlpha.setStartDelay(material ? 0 : itemsAlphaStagger + SINGLE_FRAME_DELAY);
                mStateAnimation.play(panelAlpha);
            }

            if (page != null) {
                page.setLayerType(View.LAYER_TYPE_HARDWARE, null);

                ObjectAnimator pageDrift = LauncherAnimUtils.ofFloat(page, "translationY", 0, yDrift);
                page.setTranslationY(0);
                pageDrift.setDuration(revealDuration - SINGLE_FRAME_DELAY);
                pageDrift.setInterpolator(decelerateInterpolator);
                pageDrift.setStartDelay(itemsAlphaStagger + SINGLE_FRAME_DELAY);
                mStateAnimation.play(pageDrift);

                page.setAlpha(1f);
                ObjectAnimator itemsAlpha = LauncherAnimUtils.ofFloat(page, "alpha", 1f, 0f);
                itemsAlpha.setDuration(100);
                itemsAlpha.setInterpolator(decelerateInterpolator);
                mStateAnimation.play(itemsAlpha);
            }

            View pageIndicators = fromView.findViewById(R.id.apps_customize_page_indicator);
            pageIndicators.setAlpha(1f);
            ObjectAnimator indicatorsAlpha = LauncherAnimUtils.ofFloat(pageIndicators, "alpha", 0f);
            indicatorsAlpha.setDuration(revealDuration);
            indicatorsAlpha.setInterpolator(new DecelerateInterpolator(1.5f));
            mStateAnimation.play(indicatorsAlpha);

            width = revealView.getMeasuredWidth();

            if (material) {
                if (!isWidgetTray) {
                    allAppsButton.setVisibility(View.INVISIBLE);
                }
                int allAppsButtonSize = LauncherAppState.getInstance().getDynamicGrid()
                        .getDeviceProfile().allAppsButtonVisualSize;
                float finalRadius = isWidgetTray ? 0 : allAppsButtonSize / 2;
                Animator reveal = LauncherAnimUtils.createCircularReveal(revealView, width / 2, height / 2,
                        revealRadius, finalRadius);
                reveal.setInterpolator(new LogDecelerateInterpolator(100, 0));
                reveal.setDuration(revealDuration);
                reveal.setStartDelay(itemsAlphaStagger);

                reveal.addListener(new AnimatorListenerAdapter() {
                    public void onAnimationEnd(Animator animation) {
                        revealView.setVisibility(View.INVISIBLE);
                        if (!isWidgetTray) {
                            allAppsButton.setVisibility(View.VISIBLE);
                        }
                    }
                });

                mStateAnimation.play(reveal);
            }

            dispatchOnLauncherTransitionPrepare(fromView, animated, true);
            dispatchOnLauncherTransitionPrepare(toView, animated, true);
            mAppsCustomizeContent.stopScrolling();
        }

        mStateAnimation.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                fromView.setVisibility(View.GONE);
                dispatchOnLauncherTransitionEnd(fromView, animated, true);
                dispatchOnLauncherTransitionEnd(toView, animated, true);
                if (onCompleteRunnable != null) {
                    onCompleteRunnable.run();
                }

                revealView.setLayerType(View.LAYER_TYPE_NONE, null);
                if (page != null) {
                    page.setLayerType(View.LAYER_TYPE_NONE, null);
                }
                content.setPageBackgroundsVisible(true);
                // Unhide side pages
                int count = content.getChildCount();
                for (int i = 0; i < count; i++) {
                    View child = content.getChildAt(i);
                    child.setVisibility(View.VISIBLE);
                }

                // Reset page transforms
                if (page != null) {
                    page.setTranslationX(0);
                    page.setTranslationY(0);
                    page.setAlpha(1);
                }
                content.setCurrentPage(content.getNextPage());

                mAppsCustomizeContent.updateCurrentPageScroll();

                // This can hold unnecessary references to views.
                mStateAnimation = null;
            }
        });

        final AnimatorSet stateAnimation = mStateAnimation;
        final Runnable startAnimRunnable = new Runnable() {
            public void run() {
                // Check that mStateAnimation hasn't changed while
                // we waited for a layout/draw pass
                if (mStateAnimation != stateAnimation)
                    return;
                dispatchOnLauncherTransitionStart(fromView, animated, false);
                dispatchOnLauncherTransitionStart(toView, animated, false);

                if (Utilities.isLmpOrAbove()) {
                    for (int i = 0; i < layerViews.size(); i++) {
                        View v = layerViews.get(i);
                        if (v != null) {
                            if (Utilities.isViewAttachedToWindow(v))
                                v.buildLayer();
                        }
                    }
                }
                mStateAnimation.start();
            }
        };
        fromView.post(startAnimRunnable);
    } else {
        fromView.setVisibility(View.GONE);
        dispatchOnLauncherTransitionPrepare(fromView, animated, true);
        dispatchOnLauncherTransitionStart(fromView, animated, true);
        dispatchOnLauncherTransitionEnd(fromView, animated, true);
        dispatchOnLauncherTransitionPrepare(toView, animated, true);
        dispatchOnLauncherTransitionStart(toView, animated, true);
        dispatchOnLauncherTransitionEnd(toView, animated, true);
    }
}

From source file:com.android.calendar.AllInOneActivity.java

@Override
protected void onCreate(Bundle icicle) {
    if (Utils.getSharedPreference(this, OtherPreferences.KEY_OTHER_1, false)) {
        setTheme(R.style.CalendarTheme_WithActionBarWallpaper);
    }/*  www . ja  v  a 2 s.  c  o  m*/
    super.onCreate(icicle);
    dynamicTheme.onCreate(this);

    if (icicle != null && icicle.containsKey(BUNDLE_KEY_CHECK_ACCOUNTS)) {
        mCheckForAccounts = icicle.getBoolean(BUNDLE_KEY_CHECK_ACCOUNTS);
    }
    // Launch add google account if this is first time and there are no
    // accounts yet
    if (mCheckForAccounts && !Utils.getSharedPreference(this, GeneralPreferences.KEY_SKIP_SETUP, false)) {

        mHandler = new QueryHandler(this.getContentResolver());
        mHandler.startQuery(0, null, Calendars.CONTENT_URI, new String[] { Calendars._ID }, null,
                null /* selection args */, null /* sort order */);
    }

    // This needs to be created before setContentView
    mController = CalendarController.getInstance(this);

    // Check and ask for most needed permissions
    checkAppPermissions();

    // Get time from intent or icicle
    long timeMillis = -1;
    int viewType = -1;
    final Intent intent = getIntent();
    if (icicle != null) {
        timeMillis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME);
        viewType = icicle.getInt(BUNDLE_KEY_RESTORE_VIEW, -1);
    } else {
        String action = intent.getAction();
        if (Intent.ACTION_VIEW.equals(action)) {
            // Open EventInfo later
            timeMillis = parseViewAction(intent);
        }

        if (timeMillis == -1) {
            timeMillis = Utils.timeFromIntentInMillis(intent);
        }
    }

    if (viewType == -1 || viewType > ViewType.MAX_VALUE) {
        viewType = Utils.getViewTypeFromIntentAndSharedPref(this);
    }
    mTimeZone = Utils.getTimeZone(this, mHomeTimeUpdater);
    Time t = new Time(mTimeZone);
    t.set(timeMillis);

    if (DEBUG) {
        if (icicle != null && intent != null) {
            Log.d(TAG, "both, icicle:" + icicle.toString() + "  intent:" + intent.toString());
        } else {
            Log.d(TAG, "not both, icicle:" + icicle + " intent:" + intent);
        }
    }

    Resources res = getResources();
    mHideString = res.getString(R.string.hide_controls);
    mShowString = res.getString(R.string.show_controls);
    mOrientation = res.getConfiguration().orientation;
    if (mOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        mControlsAnimateWidth = (int) res.getDimension(R.dimen.calendar_controls_width);
        if (mControlsParams == null) {
            mControlsParams = new LayoutParams(mControlsAnimateWidth, 0);
        }
        mControlsParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    } else {
        // Make sure width is in between allowed min and max width values
        mControlsAnimateWidth = Math.max(res.getDisplayMetrics().widthPixels * 45 / 100,
                (int) res.getDimension(R.dimen.min_portrait_calendar_controls_width));
        mControlsAnimateWidth = Math.min(mControlsAnimateWidth,
                (int) res.getDimension(R.dimen.max_portrait_calendar_controls_width));
    }

    mControlsAnimateHeight = (int) res.getDimension(R.dimen.calendar_controls_height);

    mHideControls = !Utils.getSharedPreference(this, GeneralPreferences.KEY_SHOW_CONTROLS, true);
    mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config);
    mIsTabletConfig = Utils.getConfigBool(this, R.bool.tablet_config);
    mShowAgendaWithMonth = Utils.getConfigBool(this, R.bool.show_agenda_with_month);
    mShowCalendarControls = Utils.getConfigBool(this, R.bool.show_calendar_controls);
    mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda);
    mShowEventInfoFullScreenAgenda = Utils.getConfigBool(this, R.bool.agenda_show_event_info_full_screen);
    mShowEventInfoFullScreen = Utils.getConfigBool(this, R.bool.show_event_info_full_screen);
    mCalendarControlsAnimationTime = res.getInteger(R.integer.calendar_controls_animation_time);
    Utils.setAllowWeekForDetailView(mIsMultipane);

    // setContentView must be called before configureActionBar
    setContentView(R.layout.all_in_one_material);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mNavigationView = (NavigationView) findViewById(R.id.navigation_view);

    mFab = (FloatingActionButton) findViewById(R.id.floating_action_button);

    if (mIsTabletConfig) {
        mDateRange = (TextView) findViewById(R.id.date_bar);
        mWeekTextView = (TextView) findViewById(R.id.week_num);
    } else {
        mDateRange = (TextView) getLayoutInflater().inflate(R.layout.date_range_title, null);
    }

    setupToolbar(viewType);
    setupNavDrawer();
    setupFloatingActionButton();

    mHomeTime = (TextView) findViewById(R.id.home_time);
    mMiniMonth = findViewById(R.id.mini_month);
    if (mIsTabletConfig && mOrientation == Configuration.ORIENTATION_PORTRAIT) {
        mMiniMonth.setLayoutParams(
                new RelativeLayout.LayoutParams(mControlsAnimateWidth, mControlsAnimateHeight));
    }
    mCalendarsList = findViewById(R.id.calendar_list);
    mMiniMonthContainer = findViewById(R.id.mini_month_container);
    mSecondaryPane = findViewById(R.id.secondary_pane);

    // Must register as the first activity because this activity can modify
    // the list of event handlers in it's handle method. This affects who
    // the rest of the handlers the controller dispatches to are.
    mController.registerFirstEventHandler(HANDLER_KEY, this);

    initFragments(timeMillis, viewType, icicle);

    // Listen for changes that would require this to be refreshed
    SharedPreferences prefs = GeneralPreferences.getSharedPreferences(this);
    prefs.registerOnSharedPreferenceChangeListener(this);

    mContentResolver = getContentResolver();
}