Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aa00e775 authored by Annie Chin's avatar Annie Chin Committed by Android Git Automerger
Browse files

am 62ff2ac2: Cherry-pick ag/725002

* commit '62ff2ac2':
  Cherry-pick ag/725002
parents 09de6476 62ff2ac2
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -382,7 +382,8 @@ public class HandleApiCalls extends Activity {
        } else {
            startActivity(new Intent(this, DeskClock.class)
                    .putExtra(DeskClock.SELECT_TAB_INTENT_EXTRA, DeskClock.TIMER_TAB_INDEX)
                    .putExtra(Timers.FIRST_LAUNCH_FROM_API_CALL, true));
                    .putExtra(Timers.FIRST_LAUNCH_FROM_API_CALL, true)
                    .putExtra(Timers.SCROLL_TO_TIMER_ID, timer.mTimerId));
        }
        Voice.notifySuccess(this, getString(R.string.timer_created));
        LogUtils.i("HandleApiCalls timer created: %s", timer);
+6 −2
Original line number Diff line number Diff line
@@ -228,9 +228,13 @@ public class TimerFragment extends DeskClockFragment implements OnSharedPreferen
            // and b. this fragment is resumed for the first time. If both are true,
            // we should show the timer view instead of setup view.
            goToSetUpView = false;
            // Show the first timer because that's the newly created one
            highlightPageIndicator(0);
            mViewPager.setCurrentItem(0);
            // Find the id of the timer to scroll to. Timers are loaded from SharedPrefs using a
            // HashSet as an intermediary, so we need to find the position in this specific
            // Adapter instance instead of just passing the position through the intent.
            final int timerPosition = ((TimerFragmentAdapter) mViewPager.getAdapter())
                    .getTimerPosition(newIntent.getIntExtra(Timers.SCROLL_TO_TIMER_ID, 0));
            mViewPager.setCurrentItem(timerPosition);

            // Reset the extra to false to ensure when next time the fragment resume,
            // we no longer care if it's from api call or not.
+12 −0
Original line number Diff line number Diff line
@@ -94,4 +94,16 @@ public class TimerFragmentAdapter extends FragmentStatePagerAdapter2 {
        notifyDataSetChanged();
        return;
    }

    // Return position of the timer with the given timerId. If the timer is not in the list,
    // return 0 so we get the position of the newest timer.
    public int getTimerPosition(int id) {
        for (int i = 0; i < mTimerList.size(); i++) {
            TimerObj timer = mTimerList.get(i);
            if (timer.mTimerId == id) {
                return i;
            }
        }
        return 0;
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ public class Timers {
    public static final String NOTIF_TIMES_UP_SHOW = "notif_times_up_show";
    public static final String NOTIF_TIMES_UP_CANCEL = "notif_times_up_cancel";
    public static final String FIRST_LAUNCH_FROM_API_CALL = "first_launch_from_api_call";
    public static final String SCROLL_TO_TIMER_ID = "scroll_to_timer_id";

    public static final String TIMESUP_MODE = "times_up";