Search in sources :

Example 1 with DeskClock

use of org.omnirom.deskclock.DeskClock in project android_packages_apps_OmniClock by omnirom.

the class StopwatchFragment method onPageChanged.

@Override
public void onPageChanged(int page) {
    super.onPageChanged(page);
    final DeskClock activity = (DeskClock) getActivity();
    if (activity.isStopwatchTab() && mState == Stopwatches.STOPWATCH_RUNNING) {
        acquireWakeLock();
    } else {
        releaseWakeLock();
    }
}
Also used : DeskClock(org.omnirom.deskclock.DeskClock)

Example 2 with DeskClock

use of org.omnirom.deskclock.DeskClock in project android_packages_apps_OmniClock by omnirom.

the class StopwatchFragment method setFabAppearance.

@Override
public void setFabAppearance() {
    final DeskClock activity = (DeskClock) getActivity();
    if (mFab == null || !activity.isStopwatchTab()) {
        return;
    }
    if (mState == Stopwatches.STOPWATCH_RUNNING) {
        mFab.setImageResource(org.omnirom.deskclock.R.drawable.ic_fab_pause);
        mFab.setContentDescription(getString(org.omnirom.deskclock.R.string.sw_stop_button));
    } else {
        mFab.setImageResource(org.omnirom.deskclock.R.drawable.ic_fab_play);
        mFab.setContentDescription(getString(org.omnirom.deskclock.R.string.sw_start_button));
    }
    final AnimatorSet animatorSet = getFabButtonTransition(true);
    if (animatorSet != null) {
        animatorSet.start();
    }
}
Also used : AnimatorSet(android.animation.AnimatorSet) DeskClock(org.omnirom.deskclock.DeskClock)

Example 3 with DeskClock

use of org.omnirom.deskclock.DeskClock in project android_packages_apps_OmniClock by omnirom.

the class StopwatchFragment method setLeftRightButtonAppearance.

@Override
public void setLeftRightButtonAppearance() {
    final DeskClock activity = (DeskClock) getActivity();
    if (mLeftButton == null || mRightButton == null || !activity.isStopwatchTab()) {
        return;
    }
    boolean leftVisible = false;
    boolean rightVisible = false;
    switch(mState) {
        case Stopwatches.STOPWATCH_RESET:
            leftVisible = false;
            rightVisible = false;
            break;
        case Stopwatches.STOPWATCH_RUNNING:
            leftVisible = true;
            if (leftVisible) {
                mLeftButton.setImageResource(org.omnirom.deskclock.R.drawable.ic_lap);
                mLeftButton.setContentDescription(getString(org.omnirom.deskclock.R.string.sw_lap_button));
                mLeftButton.setEnabled(!reachedMaxLaps());
            }
            rightVisible = false;
            break;
        case Stopwatches.STOPWATCH_STOPPED:
            leftVisible = true;
            if (leftVisible) {
                mLeftButton.setImageResource(org.omnirom.deskclock.R.drawable.ic_reset);
                mLeftButton.setContentDescription(getString(org.omnirom.deskclock.R.string.sw_reset_button));
                mLeftButton.setEnabled(true);
            }
            rightVisible = true;
            if (rightVisible) {
                mRightButton.setImageResource(org.omnirom.deskclock.R.drawable.ic_share);
                mRightButton.setContentDescription(getString(org.omnirom.deskclock.R.string.sw_share_button));
            }
            break;
    }
    final AnimatorSet animatorSet = getButtonTransition(leftVisible, rightVisible);
    if (animatorSet != null) {
        animatorSet.start();
    }
}
Also used : AnimatorSet(android.animation.AnimatorSet) DeskClock(org.omnirom.deskclock.DeskClock)

Example 4 with DeskClock

use of org.omnirom.deskclock.DeskClock in project android_packages_apps_OmniClock by omnirom.

the class StopwatchFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
    prefs.registerOnSharedPreferenceChangeListener(this);
    readFromSharedPref(prefs);
    mTime.readFromSharedPref(prefs, "sw");
    mTime.postInvalidate();
    setFabAppearance();
    setLeftRightButtonAppearance();
    mTimeText.setTime(mAccumulatedTime, true, true);
    if (mState == Stopwatches.STOPWATCH_RUNNING) {
        acquireWakeLock();
        startUpdateThread();
    } else if (mState == Stopwatches.STOPWATCH_STOPPED && mAccumulatedTime != 0) {
        mTimeText.blinkTimeStr(true);
    }
    showLaps();
    ((DeskClock) getActivity()).registerPageChangedListener(this);
    // View was hidden in onPause, make sure it is visible now.
    View v = getView();
    if (v != null) {
        v.setVisibility(View.VISIBLE);
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) CountingTimerView(org.omnirom.deskclock.timer.CountingTimerView) View(android.view.View) CircleTimerView(org.omnirom.deskclock.CircleTimerView) TextView(android.widget.TextView) ListView(android.widget.ListView) DeskClock(org.omnirom.deskclock.DeskClock)

Example 5 with DeskClock

use of org.omnirom.deskclock.DeskClock in project android_packages_apps_OmniClock by omnirom.

the class TimerFullScreenFragment method onResume.

@Override
public void onResume() {
    Intent newIntent = null;
    if (getActivity() instanceof DeskClock) {
        DeskClock activity = (DeskClock) getActivity();
        activity.registerPageChangedListener(this);
        newIntent = activity.getIntent();
    }
    super.onResume();
    mPrefs.registerOnSharedPreferenceChangeListener(this);
    mAdapter = createAdapter(getActivity(), mPrefs);
    mAdapter.onRestoreInstanceState(null);
    LayoutParams params;
    float dividerHeight = getResources().getDimension(org.omnirom.deskclock.R.dimen.timer_divider_height);
    if (getActivity() instanceof DeskClock) {
        // If this is a DeskClock fragment (i.e. not a FullScreenTimerAlert), add a footer to
        // the bottom of the list so that it can scroll underneath the bottom button bar.
        // StaggeredGridView doesn't support a footer view, but GridAdapter does, so this
        // can't happen until the Adapter itself is instantiated.
        View footerView = getActivity().getLayoutInflater().inflate(org.omnirom.deskclock.R.layout.blank_footer_view, mTimersList, false);
        params = footerView.getLayoutParams();
        params.height -= dividerHeight;
        footerView.setLayoutParams(params);
        mAdapter.setFooterView(footerView);
    }
    if (mPrefs.getBoolean(Timers.FROM_NOTIFICATION, false)) {
        // Clear the flag set in the notification because the adapter was just
        // created and is thus in sync with the database
        SharedPreferences.Editor editor = mPrefs.edit();
        editor.putBoolean(Timers.FROM_NOTIFICATION, false);
        editor.apply();
    }
    if (mPrefs.getBoolean(Timers.FROM_ALERT, false)) {
        // Clear the flag set in the alert because the adapter was just
        // created and is thus in sync with the database
        SharedPreferences.Editor editor = mPrefs.edit();
        editor.putBoolean(Timers.FROM_ALERT, false);
        editor.apply();
    }
    mTimersList.setAdapter(mAdapter);
    // Force a non animation setting of the view
    mLastVisibleView = null;
    setPage();
    // View was hidden in onPause, make sure it is visible now.
    View v = getView();
    if (v != null) {
        getView().setVisibility(View.VISIBLE);
    }
    if (newIntent != null) {
        processIntent(newIntent);
    }
    mFab.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            revealAnimation(mFab, getActivity().getResources().getColor(org.omnirom.deskclock.R.color.white));
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    updateAllTimesUpTimers(true);
                }
            }, TimerFragment.ANIMATION_TIME_MILLIS);
        }
    });
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) SharedPreferences(android.content.SharedPreferences) OnClickListener(android.view.View.OnClickListener) Handler(android.os.Handler) Intent(android.content.Intent) StaggeredGridView(org.omnirom.deskclock.widget.sgv.StaggeredGridView) TimerSetupView(org.omnirom.deskclock.TimerSetupView) View(android.view.View) TextView(android.widget.TextView) DeskClock(org.omnirom.deskclock.DeskClock)

Aggregations

DeskClock (org.omnirom.deskclock.DeskClock)10 View (android.view.View)5 TextView (android.widget.TextView)5 SharedPreferences (android.content.SharedPreferences)4 AnimatorSet (android.animation.AnimatorSet)3 Intent (android.content.Intent)2 OnClickListener (android.view.View.OnClickListener)2 ListView (android.widget.ListView)2 CircleTimerView (org.omnirom.deskclock.CircleTimerView)2 TimerSetupView (org.omnirom.deskclock.TimerSetupView)2 CountingTimerView (org.omnirom.deskclock.timer.CountingTimerView)2 StaggeredGridView (org.omnirom.deskclock.widget.sgv.StaggeredGridView)2 Activity (android.app.Activity)1 Handler (android.os.Handler)1 LayoutParams (android.view.ViewGroup.LayoutParams)1 FrameLayout (android.widget.FrameLayout)1