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

Commit 5ae1f396 authored by James Lemieux's avatar James Lemieux Committed by Android (Google) Code Review
Browse files

Merge "Add uniform event tracking to DeskClockGoogle" into ub-deskclock-army

parents 49dd9ca3 50ab55f5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

    <application android:label="@string/app_label"
                 android:name=".DeskClockApplication"
                 android:icon="@mipmap/ic_launcher_alarmclock"
                 android:requiredForAllUsers="true"
                 android:supportsRtl="true">
+42 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2015 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<resources xmlns:tools="https://schemas.android.com/tools" tools:ignore="TypographyDashes">
    <!-- Category names for events describe the type of object that was manipulated. -->
    <string name="category_alarm">Alarm</string>
    <string name="category_clock">Clock</string>
    <string name="category_timer">Timer</string>
    <string name="category_stopwatch">Stopwatch</string>

    <!-- Action names for events describe what type of manipulation was performed. -->
    <string name="action_dismiss">Dismiss</string>
    <string name="action_snooze">Snooze</string>
    <string name="action_create">Create</string>
    <string name="action_delete">Delete</string>
    <string name="action_update">Update</string>
    <string name="action_start">Start</string>
    <string name="action_stop">Stop</string>
    <string name="action_fire">Fire</string>
    <string name="action_reset">Reset</string>
    <string name="action_show">Show</string>
    <string name="action_add_minute">Add Minute</string>
    <string name="action_lap">Lap</string>

    <!-- Label names for events describe the entity responsible for the event. -->
    <string name="label_deskclock">DeskClock</string>
    <string name="label_notification">Notification</string>
    <string name="label_intent">Intent</string>
    <string name="label_voice">Voice</string>
</resources>
+5 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ import android.widget.TextView;
import android.widget.Toast;

import com.android.deskclock.alarms.AlarmStateManager;
import com.android.deskclock.events.Events;
import com.android.deskclock.provider.Alarm;
import com.android.deskclock.provider.AlarmInstance;
import com.android.deskclock.provider.DaysOfWeek;
@@ -1387,6 +1388,8 @@ public abstract class AlarmClockFragment extends DeskClockFragment implements
            protected Void doInBackground(Void... parameters) {
                // Activity may be closed at this point , make sure data is still valid
                if (context != null && alarm != null) {
                    Events.sendAlarmEvent(R.string.action_delete, R.string.label_deskclock);

                    ContentResolver cr = context.getContentResolver();
                    AlarmStateManager.deleteAllInstances(context, alarm.id);
                    Alarm.deleteAlarm(cr, alarm.id);
@@ -1405,6 +1408,7 @@ public abstract class AlarmClockFragment extends DeskClockFragment implements
            @Override
            protected AlarmInstance doInBackground(Void... parameters) {
                if (context != null && alarm != null) {
                    Events.sendAlarmEvent(R.string.action_create, R.string.label_deskclock);
                    ContentResolver cr = context.getContentResolver();

                    // Add alarm to db
@@ -1435,6 +1439,7 @@ public abstract class AlarmClockFragment extends DeskClockFragment implements
                new AsyncTask<Void, Void, AlarmInstance>() {
            @Override
            protected AlarmInstance doInBackground(Void ... parameters) {
                Events.sendAlarmEvent(R.string.action_update, R.string.label_deskclock);
                ContentResolver cr = context.getContentResolver();

                // Dismiss all old instances
+21 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import android.widget.ImageButton;
import android.widget.TextView;

import com.android.deskclock.alarms.AlarmStateManager;
import com.android.deskclock.events.Events;
import com.android.deskclock.provider.Alarm;
import com.android.deskclock.stopwatch.StopwatchFragment;
import com.android.deskclock.stopwatch.StopwatchService;
@@ -96,6 +97,7 @@ public class DeskClock extends BaseActivity implements

    private TabsAdapter mTabsAdapter;
    private int mSelectedTab;
    private boolean mActivityResumed;

    @Override
    public void onNewIntent(Intent newIntent) {
@@ -244,10 +246,12 @@ public class DeskClock extends BaseActivity implements
        Intent timerIntent = new Intent();
        timerIntent.setAction(Timers.NOTIF_IN_USE_CANCEL);
        sendBroadcast(timerIntent);
        mActivityResumed = true;
    }

    @Override
    public void onPause() {
        mActivityResumed = false;
        Intent intent = new Intent(getApplicationContext(), StopwatchService.class);
        intent.setAction(Stopwatches.SHOW_NOTIF);
        startService(intent);
@@ -496,6 +500,23 @@ public class DeskClock extends BaseActivity implements
            final int rtlSafePosition = getRtlPosition(position);
            mSelectedTab = position;

            if (mActivityResumed) {
                switch (mSelectedTab) {
                    case ALARM_TAB_INDEX:
                        Events.sendAlarmEvent(R.string.action_show, R.string.label_deskclock);
                        break;
                    case CLOCK_TAB_INDEX:
                        Events.sendClockEvent(R.string.action_show, R.string.label_deskclock);
                        break;
                    case TIMER_TAB_INDEX:
                        Events.sendTimerEvent(R.string.action_show, R.string.label_deskclock);
                        break;
                    case STOPWATCH_TAB_INDEX:
                        Events.sendStopwatchEvent(R.string.action_show, R.string.label_deskclock);
                        break;
                }
            }

            final DeskClockFragment f = (DeskClockFragment) getItem(rtlSafePosition);
            if (f != null) {
                f.setFabAppearance();
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.deskclock;

import android.app.Application;

import com.android.deskclock.events.Events;
import com.android.deskclock.events.LogEventTracker;

public class DeskClockApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        Events.addEventTracker(new LogEventTracker(getApplicationContext()));
    }
}
Loading