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();
}
}
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();
}
}
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();
}
}
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);
}
}
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);
}
});
}
Aggregations