Search in sources :

Example 31 with FragmentManager

use of android.app.FragmentManager in project Etar-Calendar by Etar-Group.

the class GeneralPreferences method showTimezoneDialog.

private void showTimezoneDialog() {
    final Activity activity = getActivity();
    if (activity == null) {
        return;
    }
    Bundle b = new Bundle();
    b.putLong(TimeZonePickerDialog.BUNDLE_START_TIME_MILLIS, System.currentTimeMillis());
    b.putString(TimeZonePickerDialog.BUNDLE_TIME_ZONE, Utils.getTimeZone(activity, null));
    FragmentManager fm = getActivity().getFragmentManager();
    TimeZonePickerDialog tzpd = (TimeZonePickerDialog) fm.findFragmentByTag(FRAG_TAG_TIME_ZONE_PICKER);
    if (tzpd != null) {
        tzpd.dismiss();
    }
    tzpd = new TimeZonePickerDialog();
    tzpd.setArguments(b);
    tzpd.setOnTimeZoneSetListener(this);
    tzpd.show(fm, FRAG_TAG_TIME_ZONE_PICKER);
}
Also used : FragmentManager(android.app.FragmentManager) Bundle(android.os.Bundle) Activity(android.app.Activity) TimeZonePickerDialog(com.android.timezonepicker.TimeZonePickerDialog)

Example 32 with FragmentManager

use of android.app.FragmentManager in project Etar-Calendar by Etar-Group.

the class SearchActivity method deleteEvent.

private void deleteEvent(long eventId, long startMillis, long endMillis) {
    mDeleteEventHelper.delete(startMillis, endMillis, eventId, -1);
    if (mIsMultipane && mEventInfoFragment != null && eventId == mCurrentEventId) {
        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction ft = fragmentManager.beginTransaction();
        ft.remove(mEventInfoFragment);
        ft.commit();
        mEventInfoFragment = null;
        mCurrentEventId = -1;
    }
}
Also used : FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction)

Example 33 with FragmentManager

use of android.app.FragmentManager in project Etar-Calendar by Etar-Group.

the class AgendaFragment method showEventInfo.

// Shows the selected event in the Agenda view
private void showEventInfo(EventInfo event, boolean allDay, boolean replaceFragment) {
    // Ignore unknown events
    if (event.id == -1) {
        Log.e(TAG, "showEventInfo, event ID = " + event.id);
        return;
    }
    mLastShownEventId = event.id;
    // Create a fragment to show the event to the side of the agenda list
    if (mShowEventDetailsWithAgenda) {
        FragmentManager fragmentManager = getFragmentManager();
        if (fragmentManager == null) {
            // Got a goto event before the fragment finished attaching,
            // stash the event and handle it later.
            mOnAttachedInfo = event;
            mOnAttachAllDay = allDay;
            return;
        }
        FragmentTransaction ft = fragmentManager.beginTransaction();
        if (allDay) {
            event.startTime.timezone = Time.TIMEZONE_UTC;
            event.endTime.timezone = Time.TIMEZONE_UTC;
        }
        if (DEBUG) {
            Log.d(TAG, "***");
            Log.d(TAG, "showEventInfo: start: " + new Date(event.startTime.toMillis(true)));
            Log.d(TAG, "showEventInfo: end: " + new Date(event.endTime.toMillis(true)));
            Log.d(TAG, "showEventInfo: all day: " + allDay);
            Log.d(TAG, "***");
        }
        long startMillis = event.startTime.toMillis(true);
        long endMillis = event.endTime.toMillis(true);
        EventInfoFragment fOld = (EventInfoFragment) fragmentManager.findFragmentById(R.id.agenda_event_info);
        if (fOld == null || replaceFragment || fOld.getStartMillis() != startMillis || fOld.getEndMillis() != endMillis || fOld.getEventId() != event.id) {
            mEventFragment = new EventInfoFragment(mActivity, event.id, startMillis, endMillis, Attendees.ATTENDEE_STATUS_NONE, false, EventInfoFragment.DIALOG_WINDOW_STYLE, null);
            ft.replace(R.id.agenda_event_info, mEventFragment);
            ft.commit();
        } else {
            fOld.reloadEvents();
        }
    }
}
Also used : FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction) EventInfoFragment(com.android.calendar.EventInfoFragment) Date(java.util.Date)

Example 34 with FragmentManager

use of android.app.FragmentManager in project Etar-Calendar by Etar-Group.

the class AllInOneActivity method handleEvent.

@Override
public void handleEvent(EventInfo event) {
    long displayTime = -1;
    if (event.eventType == EventType.GO_TO) {
        if ((event.extraLong & CalendarController.EXTRA_GOTO_BACK_TO_PREVIOUS) != 0) {
            mBackToPreviousView = true;
        } else if (event.viewType != mController.getPreviousViewType() && event.viewType != ViewType.EDIT) {
            // Clear the flag is change to a different view type
            mBackToPreviousView = false;
        }
        setMainPane(null, R.id.main_pane, event.viewType, event.startTime.toMillis(false), false);
        if (mSearchView != null) {
            mSearchView.clearFocus();
        }
        if (mShowCalendarControls) {
            int animationSize = (mOrientation == Configuration.ORIENTATION_LANDSCAPE) ? mControlsAnimateWidth : mControlsAnimateHeight;
            boolean noControlsView = event.viewType == ViewType.MONTH || event.viewType == ViewType.AGENDA;
            if (mControlsMenu != null) {
                mControlsMenu.setVisible(!noControlsView);
                mControlsMenu.setEnabled(!noControlsView);
            }
            if (noControlsView || mHideControls) {
                // hide minimonth and calendar frag
                mShowSideViews = false;
                if (!mHideControls) {
                    final ObjectAnimator slideAnimation = ObjectAnimator.ofInt(this, "controlsOffset", 0, animationSize);
                    slideAnimation.addListener(mSlideAnimationDoneListener);
                    slideAnimation.setDuration(mCalendarControlsAnimationTime);
                    ObjectAnimator.setFrameDelay(0);
                    slideAnimation.start();
                } else {
                    mMiniMonth.setVisibility(View.GONE);
                    mCalendarsList.setVisibility(View.GONE);
                    mMiniMonthContainer.setVisibility(View.GONE);
                }
            } else {
                // show minimonth and calendar frag
                mShowSideViews = true;
                mMiniMonth.setVisibility(View.VISIBLE);
                mCalendarsList.setVisibility(View.VISIBLE);
                mMiniMonthContainer.setVisibility(View.VISIBLE);
                if (!mHideControls && (mController.getPreviousViewType() == ViewType.MONTH || mController.getPreviousViewType() == ViewType.AGENDA)) {
                    final ObjectAnimator slideAnimation = ObjectAnimator.ofInt(this, "controlsOffset", animationSize, 0);
                    slideAnimation.setDuration(mCalendarControlsAnimationTime);
                    ObjectAnimator.setFrameDelay(0);
                    slideAnimation.start();
                }
            }
        }
        displayTime = event.selectedTime != null ? event.selectedTime.toMillis(true) : event.startTime.toMillis(true);
        if (!mIsTabletConfig) {
            refreshActionbarTitle(displayTime);
        }
    } else if (event.eventType == EventType.VIEW_EVENT) {
        if (mCurrentView == ViewType.AGENDA && mShowEventDetailsWithAgenda) {
            if (event.startTime != null && event.endTime != null) {
                // Event is all day , adjust the goto time to local time
                if (event.isAllDay()) {
                    Utils.convertAlldayUtcToLocal(event.startTime, event.startTime.toMillis(false), mTimeZone);
                    Utils.convertAlldayUtcToLocal(event.endTime, event.endTime.toMillis(false), mTimeZone);
                }
                mController.sendEvent(this, EventType.GO_TO, event.startTime, event.endTime, event.selectedTime, event.id, ViewType.AGENDA, CalendarController.EXTRA_GOTO_TIME, null, null);
            } else if (event.selectedTime != null) {
                mController.sendEvent(this, EventType.GO_TO, event.selectedTime, event.selectedTime, event.id, ViewType.AGENDA);
            }
        } else {
            // ViewType.AGENDA
            if (event.selectedTime != null && mCurrentView != ViewType.AGENDA) {
                mController.sendEvent(this, EventType.GO_TO, event.selectedTime, event.selectedTime, -1, ViewType.CURRENT);
            }
            int response = event.getResponse();
            if ((mCurrentView == ViewType.AGENDA && mShowEventInfoFullScreenAgenda) || ((mCurrentView == ViewType.DAY || (mCurrentView == ViewType.WEEK) || mCurrentView == ViewType.MONTH) && mShowEventInfoFullScreen)) {
                // start event info as activity
                Intent intent = new Intent(Intent.ACTION_VIEW);
                Uri eventUri = ContentUris.withAppendedId(Events.CONTENT_URI, event.id);
                intent.setData(eventUri);
                intent.setClass(this, EventInfoActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                intent.putExtra(EXTRA_EVENT_BEGIN_TIME, event.startTime.toMillis(false));
                intent.putExtra(EXTRA_EVENT_END_TIME, event.endTime.toMillis(false));
                intent.putExtra(ATTENDEE_STATUS, response);
                startActivity(intent);
            } else {
                // start event info as a dialog
                EventInfoFragment fragment = new EventInfoFragment(this, event.id, event.startTime.toMillis(false), event.endTime.toMillis(false), response, true, EventInfoFragment.DIALOG_WINDOW_STYLE, null);
                fragment.setDialogParams(event.x, event.y, mActionBar.getHeight());
                FragmentManager fm = getFragmentManager();
                FragmentTransaction ft = fm.beginTransaction();
                // if we have an old popup replace it
                Fragment fOld = fm.findFragmentByTag(EVENT_INFO_FRAGMENT_TAG);
                if (fOld != null && fOld.isAdded()) {
                    ft.remove(fOld);
                }
                ft.add(fragment, EVENT_INFO_FRAGMENT_TAG);
                ft.commit();
            }
        }
        displayTime = event.startTime.toMillis(true);
    } else if (event.eventType == EventType.UPDATE_TITLE) {
        setTitleInActionBar(event);
        if (!mIsTabletConfig) {
            refreshActionbarTitle(mController.getTime());
        }
    }
    updateSecondaryTitleFields(displayTime);
}
Also used : FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction) ObjectAnimator(android.animation.ObjectAnimator) Intent(android.content.Intent) Uri(android.net.Uri) SelectVisibleCalendarsFragment(com.android.calendar.selectcalendars.SelectVisibleCalendarsFragment) AgendaFragment(com.android.calendar.agenda.AgendaFragment) Fragment(android.app.Fragment) MonthByWeekFragment(com.android.calendar.month.MonthByWeekFragment)

Example 35 with FragmentManager

use of android.app.FragmentManager in project Etar-Calendar by Etar-Group.

the class AllInOneActivity method setMainPane.

private void setMainPane(FragmentTransaction ft, int viewId, int viewType, long timeMillis, boolean force) {
    if (mOnSaveInstanceStateCalled) {
        return;
    }
    if (!force && mCurrentView == viewType) {
        return;
    }
    // Remove this when transition to and from month view looks fine.
    boolean doTransition = viewType != ViewType.MONTH && mCurrentView != ViewType.MONTH;
    FragmentManager fragmentManager = getFragmentManager();
    // TODO remove this if framework ever supports nested fragments
    if (mCurrentView == ViewType.AGENDA) {
        // If it was, we need to do some cleanup on it to prevent the
        // edit/delete buttons from coming back on a rotation.
        Fragment oldFrag = fragmentManager.findFragmentById(viewId);
        if (oldFrag instanceof AgendaFragment) {
            ((AgendaFragment) oldFrag).removeFragments(fragmentManager);
        }
    }
    if (viewType != mCurrentView) {
        // controller's and are used for intercepting the back button.
        if (mCurrentView != ViewType.EDIT && mCurrentView > 0) {
            mPreviousView = mCurrentView;
        }
        mCurrentView = viewType;
    }
    // Create new fragment
    Fragment frag = null;
    Fragment secFrag = null;
    switch(viewType) {
        case ViewType.AGENDA:
            mNavigationView.getMenu().findItem(R.id.agenda_menu_item).setChecked(true);
            frag = new AgendaFragment(timeMillis, false);
            if (mIsTabletConfig) {
                mToolbar.setTitle(R.string.agenda_view);
            }
            break;
        case ViewType.DAY:
            mNavigationView.getMenu().findItem(R.id.day_menu_item).setChecked(true);
            frag = new DayFragment(timeMillis, 1);
            if (mIsTabletConfig) {
                mToolbar.setTitle(R.string.day_view);
            }
            break;
        case ViewType.MONTH:
            mNavigationView.getMenu().findItem(R.id.month_menu_item).setChecked(true);
            frag = new MonthByWeekFragment(timeMillis, false);
            if (mShowAgendaWithMonth) {
                secFrag = new AgendaFragment(timeMillis, false);
            }
            if (mIsTabletConfig) {
                mToolbar.setTitle(R.string.month_view);
            }
            break;
        case ViewType.WEEK:
        default:
            mNavigationView.getMenu().findItem(R.id.week_menu_item).setChecked(true);
            frag = new DayFragment(timeMillis, Utils.getDaysPerWeek(this));
            if (mIsTabletConfig) {
                mToolbar.setTitle(R.string.week_view);
            }
            break;
    }
    // current view.
    if (mCalendarToolbarHandler != null) {
        mCalendarToolbarHandler.setCurrentMainView(viewType);
    }
    if (!mIsTabletConfig) {
        refreshActionbarTitle(timeMillis);
    }
    // Show date only on tablet configurations in views different than Agenda
    if (!mIsTabletConfig) {
        mDateRange.setVisibility(View.GONE);
    } else if (viewType != ViewType.AGENDA) {
        mDateRange.setVisibility(View.VISIBLE);
    } else {
        mDateRange.setVisibility(View.GONE);
    }
    // Clear unnecessary buttons from the option menu when switching from the agenda view
    if (viewType != ViewType.AGENDA) {
        clearOptionsMenu();
    }
    boolean doCommit = false;
    if (ft == null) {
        doCommit = true;
        ft = fragmentManager.beginTransaction();
    }
    if (doTransition) {
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    }
    ft.replace(viewId, frag);
    if (mShowAgendaWithMonth) {
        if (secFrag != null) {
            ft.replace(R.id.secondary_pane, secFrag);
            mSecondaryPane.setVisibility(View.VISIBLE);
        } else {
            mSecondaryPane.setVisibility(View.GONE);
            Fragment f = fragmentManager.findFragmentById(R.id.secondary_pane);
            if (f != null) {
                ft.remove(f);
            }
            mController.deregisterEventHandler(R.id.secondary_pane);
        }
    }
    if (DEBUG) {
        Log.d(TAG, "Adding handler with viewId " + viewId + " and type " + viewType);
    }
    // If the key is already registered this will replace it
    mController.registerEventHandler(viewId, (EventHandler) frag);
    if (secFrag != null) {
        mController.registerEventHandler(viewId, (EventHandler) secFrag);
    }
    if (doCommit) {
        if (DEBUG) {
            Log.d(TAG, "setMainPane AllInOne=" + this + " finishing:" + this.isFinishing());
        }
        ft.commit();
    }
}
Also used : FragmentManager(android.app.FragmentManager) AgendaFragment(com.android.calendar.agenda.AgendaFragment) MonthByWeekFragment(com.android.calendar.month.MonthByWeekFragment) SelectVisibleCalendarsFragment(com.android.calendar.selectcalendars.SelectVisibleCalendarsFragment) AgendaFragment(com.android.calendar.agenda.AgendaFragment) Fragment(android.app.Fragment) MonthByWeekFragment(com.android.calendar.month.MonthByWeekFragment)

Aggregations

FragmentManager (android.app.FragmentManager)177 FragmentTransaction (android.app.FragmentTransaction)84 Fragment (android.app.Fragment)51 Bundle (android.os.Bundle)22 DocumentInfo (com.android.documentsui.model.DocumentInfo)20 DialogFragment (android.app.DialogFragment)15 RootInfo (com.android.documentsui.model.RootInfo)15 ActionBar (android.support.v7.app.ActionBar)12 Intent (android.content.Intent)11 File (java.io.File)6 MediaRouter (android.media.MediaRouter)5 Uri (android.net.Uri)5 StorageManager (android.os.storage.StorageManager)5 VolumeInfo (android.os.storage.VolumeInfo)5 MenuItem (android.view.MenuItem)5 IOException (java.io.IOException)5 Toolbar (android.support.v7.widget.Toolbar)4 View (android.view.View)4 DialogInterface (android.content.DialogInterface)3 ViewGroup (android.view.ViewGroup)3