summaryrefslogtreecommitdiff
path: root/src/com/android/contacts/vcard
diff options
context:
space:
mode:
authorChiao Cheng <chiaocheng@google.com>2012-12-03 14:48:50 -0800
committerChiao Cheng <chiaocheng@google.com>2012-12-03 15:44:07 -0800
commita2a35d2022ec64716c6c4985900b55d1c15fe018 (patch)
tree0f9e9553c7ab53db0134a298ad73eb6b6f12eb38 /src/com/android/contacts/vcard
parent8a80ff8561d27aed9998c3076e27d6d5f9fa1ed2 (diff)
downloadContacts-a2a35d2022ec64716c6c4985900b55d1c15fe018.tar.gz
Remove hard coded PeopleActivity.class from VCard UI.
The PeopleActivity was hard coded as the target activity when clicking on a vcard processed notification. Since the vcard export can be triggered from both the dialtacts UI and the people UI, it's strange to always go back to the people UI. Change vcard UI classes to accept the calling activity. This way we can send the user back to the activity that originally triggered the vcard export. Bug: 6993891 Change-Id: I9a1fb67e40d5966370922c9c77fbd6f23947dca0
Diffstat (limited to 'src/com/android/contacts/vcard')
-rw-r--r--src/com/android/contacts/vcard/ExportProcessor.java10
-rw-r--r--src/com/android/contacts/vcard/ExportVCardActivity.java3
-rw-r--r--src/com/android/contacts/vcard/VCardCommonArguments.java27
-rw-r--r--src/com/android/contacts/vcard/VCardService.java6
4 files changed, 42 insertions, 4 deletions
diff --git a/src/com/android/contacts/vcard/ExportProcessor.java b/src/com/android/contacts/vcard/ExportProcessor.java
index 12f9e24b0..60636296e 100644
--- a/src/com/android/contacts/vcard/ExportProcessor.java
+++ b/src/com/android/contacts/vcard/ExportProcessor.java
@@ -28,7 +28,6 @@ import android.text.TextUtils;
import android.util.Log;
import com.android.contacts.R;
-import com.android.contacts.activities.PeopleActivity;
import com.android.vcard.VCardComposer;
import com.android.vcard.VCardConfig;
@@ -52,17 +51,21 @@ public class ExportProcessor extends ProcessorBase {
private final NotificationManager mNotificationManager;
private final ExportRequest mExportRequest;
private final int mJobId;
+ private final String mCallingActivity;
+
private volatile boolean mCanceled;
private volatile boolean mDone;
- public ExportProcessor(VCardService service, ExportRequest exportRequest, int jobId) {
+ public ExportProcessor(VCardService service, ExportRequest exportRequest, int jobId,
+ String callingActivity) {
mService = service;
mResolver = service.getContentResolver();
mNotificationManager =
(NotificationManager)mService.getSystemService(Context.NOTIFICATION_SERVICE);
mExportRequest = exportRequest;
mJobId = jobId;
+ mCallingActivity = callingActivity;
}
@Override
@@ -254,7 +257,8 @@ public class ExportProcessor extends ProcessorBase {
private void doFinishNotification(final String title, final String description) {
if (DEBUG) Log.d(LOG_TAG, "send finish notification: " + title + ", " + description);
- final Intent intent = new Intent(mService, PeopleActivity.class);
+ final Intent intent = new Intent();
+ intent.setClassName(mService, mCallingActivity);
final Notification notification =
NotificationImportExportListener.constructFinishNotification(mService, title,
description, intent);
diff --git a/src/com/android/contacts/vcard/ExportVCardActivity.java b/src/com/android/contacts/vcard/ExportVCardActivity.java
index 6bed577f9..29ffc4c99 100644
--- a/src/com/android/contacts/vcard/ExportVCardActivity.java
+++ b/src/com/android/contacts/vcard/ExportVCardActivity.java
@@ -165,7 +165,10 @@ public class ExportVCardActivity extends Activity implements ServiceConnection,
return;
}
+ final String callingActivity = getIntent().getExtras()
+ .getString(VCardCommonArguments.ARG_CALLING_ACTIVITY);
Intent intent = new Intent(this, VCardService.class);
+ intent.putExtra(VCardCommonArguments.ARG_CALLING_ACTIVITY, callingActivity);
if (startService(intent) == null) {
Log.e(LOG_TAG, "Failed to start vCard service");
diff --git a/src/com/android/contacts/vcard/VCardCommonArguments.java b/src/com/android/contacts/vcard/VCardCommonArguments.java
new file mode 100644
index 000000000..06b49a213
--- /dev/null
+++ b/src/com/android/contacts/vcard/VCardCommonArguments.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2012 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.contacts.vcard;
+
+/**
+ * Argument constants used by many activities and services.
+ */
+public class VCardCommonArguments {
+
+ // Argument used to pass calling activities to the target activity or service.
+ // The value should be a string class name (e.g. com.android.contacts.vcard.VCardCommonArgs)
+ public static final String ARG_CALLING_ACTIVITY = "CALLING_ACTIVITY";
+}
diff --git a/src/com/android/contacts/vcard/VCardService.java b/src/com/android/contacts/vcard/VCardService.java
index 74ce69c83..056f89af8 100644
--- a/src/com/android/contacts/vcard/VCardService.java
+++ b/src/com/android/contacts/vcard/VCardService.java
@@ -128,6 +128,8 @@ public class VCardService extends Service {
private String mErrorReason;
private MyBinder mBinder;
+ private String mCallingActivity;
+
// File names currently reserved by some export job.
private final Set<String> mReservedDestination = new HashSet<String>();
/* ** end of vCard exporter params ** */
@@ -173,6 +175,8 @@ public class VCardService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int id) {
+ mCallingActivity = intent.getExtras().getString(
+ VCardCommonArguments.ARG_CALLING_ACTIVITY);
return START_STICKY;
}
@@ -223,7 +227,7 @@ public class VCardService extends Service {
public synchronized void handleExportRequest(ExportRequest request,
VCardImportExportListener listener) {
- if (tryExecute(new ExportProcessor(this, request, mCurrentJobId))) {
+ if (tryExecute(new ExportProcessor(this, request, mCurrentJobId, mCallingActivity))) {
final String path = request.destUri.getEncodedPath();
if (DEBUG) Log.d(LOG_TAG, "Reserve the path " + path);
if (!mReservedDestination.add(path)) {