diff options
author | Sai Cheemalapati <saicheems@google.com> | 2014-07-30 17:25:59 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-07-30 17:25:59 +0000 |
commit | a462c5d5a6a6c3f2aca1c914ffb05d280cb36d08 (patch) | |
tree | 74da1af8171884d9494c28170f561aa00c13ea41 | |
parent | 714d8151a58d2519d52eba32e726b13150684807 (diff) | |
parent | 2645127c3c271e37665b8f970d49cf41a6904c15 (diff) |
am 2645127c: am b7a27036: am 7687a1c0: Merge "Changing Activities to implement Analytics (1/2)." into lmp-dev
* commit '2645127c3c271e37665b8f970d49cf41a6904c15':
Changing Activities to implement Analytics (1/2).
11 files changed, 129 insertions, 11 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index e44ff83bc..e716719f4 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -16,7 +16,6 @@ package com.android.dialer; -import android.app.Activity; import android.content.ComponentName; import android.content.ContentResolver; import android.content.ContentUris; @@ -68,6 +67,7 @@ import com.android.dialer.voicemail.VoicemailPlaybackFragment; import com.android.dialer.voicemail.VoicemailStatusHelper; import com.android.dialer.voicemail.VoicemailStatusHelper.StatusMessage; import com.android.dialer.voicemail.VoicemailStatusHelperImpl; +import com.android.dialerbind.analytics.AnalyticsActivity; import java.util.List; @@ -77,7 +77,7 @@ import java.util.List; * This activity can be either started with the URI of a single call log entry, or with the * {@link #EXTRA_CALL_LOG_IDS} extra to specify a group of call log entries. */ -public class CallDetailActivity extends Activity implements ProximitySensorAware { +public class CallDetailActivity extends AnalyticsActivity implements ProximitySensorAware { private static final String TAG = "CallDetail"; private static final int LOADER_ID = 0; diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 53627f698..7d4e2d0aa 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -63,11 +63,11 @@ import android.widget.PopupMenu; import android.widget.Toast; import com.android.contacts.common.CallUtil; -import com.android.contacts.common.activity.TransactionSafeActivity; import com.android.contacts.common.dialog.ClearFrequentsDialog; import com.android.contacts.common.interactions.ImportExportDialogFragment; import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; import com.android.contacts.common.widget.FloatingActionButtonController; +import com.android.dialer.activity.TransactionSafeActivity; import com.android.dialer.calllog.CallLogActivity; import com.android.dialer.database.DialerDatabaseHelper; import com.android.dialer.dialpad.DialpadFragment; diff --git a/src/com/android/dialer/activity/TransactionSafeActivity.java b/src/com/android/dialer/activity/TransactionSafeActivity.java new file mode 100644 index 000000000..d7a212021 --- /dev/null +++ b/src/com/android/dialer/activity/TransactionSafeActivity.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2014 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.dialer.activity; + +import android.app.Activity; +import android.os.Bundle; + +import com.android.dialerbind.analytics.AnalyticsActivity; + +/** + * A common superclass that keeps track of whether an {@link Activity} has saved its state yet or + * not. + */ +public abstract class TransactionSafeActivity extends AnalyticsActivity { + + private boolean mIsSafeToCommitTransactions; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + mIsSafeToCommitTransactions = true; + } + + @Override + protected void onStart() { + super.onStart(); + mIsSafeToCommitTransactions = true; + } + + @Override + protected void onResume() { + super.onResume(); + mIsSafeToCommitTransactions = true; + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + mIsSafeToCommitTransactions = false; + } + + /** + * Returns true if it is safe to commit {@link FragmentTransaction}s at this time, based on + * whether {@link Activity#onSaveInstanceState} has been called or not. + * + * Make sure that the current activity calls into + * {@link super.onSaveInstanceState(Bundle outState)} (if that method is overridden), + * so the flag is properly set. + */ + public boolean isSafeToCommitTransactions() { + return mIsSafeToCommitTransactions; + } +} diff --git a/src/com/android/dialer/calllog/CallLogActivity.java b/src/com/android/dialer/calllog/CallLogActivity.java index 3eb4b6ba7..0054ac08c 100644 --- a/src/com/android/dialer/calllog/CallLogActivity.java +++ b/src/com/android/dialer/calllog/CallLogActivity.java @@ -16,7 +16,6 @@ package com.android.dialer.calllog; import android.app.ActionBar; -import android.app.Activity; import android.app.Fragment; import android.app.FragmentManager; import android.content.Intent; @@ -36,8 +35,9 @@ import com.android.dialer.DialtactsActivity; import com.android.dialer.R; import com.android.dialer.voicemail.VoicemailStatusHelper; import com.android.dialer.voicemail.VoicemailStatusHelperImpl; +import com.android.dialerbind.analytics.AnalyticsActivity; -public class CallLogActivity extends Activity implements CallLogQueryHandler.Listener { +public class CallLogActivity extends AnalyticsActivity implements CallLogQueryHandler.Listener { private Handler mHandler; private ViewPager mViewPager; private ViewPagerTabs mViewPagerTabs; diff --git a/src/com/android/dialer/interactions/PhoneNumberInteraction.java b/src/com/android/dialer/interactions/PhoneNumberInteraction.java index a0f0c8010..dc35b0611 100644 --- a/src/com/android/dialer/interactions/PhoneNumberInteraction.java +++ b/src/com/android/dialer/interactions/PhoneNumberInteraction.java @@ -49,9 +49,9 @@ import com.android.contacts.common.CallUtil; import com.android.contacts.common.Collapser; import com.android.contacts.common.Collapser.Collapsible; import com.android.contacts.common.MoreContactUtils; -import com.android.contacts.common.activity.TransactionSafeActivity; import com.android.contacts.common.util.ContactDisplayUtils; import com.android.dialer.R; +import com.android.dialer.activity.TransactionSafeActivity; import com.android.dialer.contact.ContactUpdateService; import com.android.dialer.util.DialerUtils; diff --git a/src/com/android/dialer/settings/DialerSettingsActivity.java b/src/com/android/dialer/settings/DialerSettingsActivity.java index 6d21db0db..8d41d775e 100644 --- a/src/com/android/dialer/settings/DialerSettingsActivity.java +++ b/src/com/android/dialer/settings/DialerSettingsActivity.java @@ -5,7 +5,6 @@ import com.google.common.collect.Lists; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; -import android.preference.PreferenceActivity; import android.preference.PreferenceManager; import android.preference.PreferenceActivity.Header; import android.text.TextUtils; @@ -21,10 +20,11 @@ import android.widget.TextView; import com.android.contacts.common.preference.DisplayOptionsPreferenceFragment; import com.android.dialer.DialtactsActivity; import com.android.dialer.R; +import com.android.dialerbind.analytics.AnalyticsPreferenceActivity; import java.util.List; -public class DialerSettingsActivity extends PreferenceActivity { +public class DialerSettingsActivity extends AnalyticsPreferenceActivity { protected SharedPreferences mPreferences; private HeaderAdapter mHeaderAdapter; diff --git a/src/com/android/dialerbind/analytics/AnalyticsActivity.java b/src/com/android/dialerbind/analytics/AnalyticsActivity.java index 7c031f499..9abe1ab3e 100644 --- a/src/com/android/dialerbind/analytics/AnalyticsActivity.java +++ b/src/com/android/dialerbind/analytics/AnalyticsActivity.java @@ -18,5 +18,7 @@ package com.android.dialerbind.analytics; import android.app.Activity; -public class AnalyticsActivity extends Activity { +public class AnalyticsActivity extends Activity implements AnalyticsInterface { + public void sendHitEvent(String categoryId, String actionId, String labelId) { + } } diff --git a/src/com/android/dialerbind/analytics/AnalyticsFragment.java b/src/com/android/dialerbind/analytics/AnalyticsFragment.java index 222509d46..8ebe7ce18 100644 --- a/src/com/android/dialerbind/analytics/AnalyticsFragment.java +++ b/src/com/android/dialerbind/analytics/AnalyticsFragment.java @@ -18,5 +18,7 @@ package com.android.dialerbind.analytics; import android.app.Fragment; -public class AnalyticsFragment extends Fragment { +public class AnalyticsFragment extends Fragment implements AnalyticsInterface { + public void sendHitEvent(String categoryId, String actionId, String labelId) { + } } diff --git a/src/com/android/dialerbind/analytics/AnalyticsInterface.java b/src/com/android/dialerbind/analytics/AnalyticsInterface.java new file mode 100644 index 000000000..ddc1b3fed --- /dev/null +++ b/src/com/android/dialerbind/analytics/AnalyticsInterface.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2014 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.dialerbind.analytics; + +public interface AnalyticsInterface { + public void sendHitEvent(String categoryId, String actionId, String labelId); +} diff --git a/src/com/android/dialerbind/analytics/AnalyticsListFragment.java b/src/com/android/dialerbind/analytics/AnalyticsListFragment.java index aaeb5f140..bc668aa7a 100644 --- a/src/com/android/dialerbind/analytics/AnalyticsListFragment.java +++ b/src/com/android/dialerbind/analytics/AnalyticsListFragment.java @@ -18,5 +18,7 @@ package com.android.dialerbind.analytics; import android.app.ListFragment; -public class AnalyticsListFragment extends ListFragment { +public class AnalyticsListFragment extends ListFragment implements AnalyticsInterface { + public void sendHitEvent(String categoryId, String actionId, String labelId) { + } } diff --git a/src/com/android/dialerbind/analytics/AnalyticsPreferenceActivity.java b/src/com/android/dialerbind/analytics/AnalyticsPreferenceActivity.java new file mode 100644 index 000000000..c411387f5 --- /dev/null +++ b/src/com/android/dialerbind/analytics/AnalyticsPreferenceActivity.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2014 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.dialerbind.analytics; + +import android.preference.PreferenceActivity; + +public class AnalyticsPreferenceActivity extends PreferenceActivity implements AnalyticsInterface { + public void sendHitEvent(String categoryId, String actionId, String labelId) { + } +} |