/*
 * Copyright 2012 Google Inc.
 *
 * 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.google.android.apps.mytracks.io.fusiontables;

import com.google.android.apps.mytracks.io.docs.SendDocsActivity;
import com.google.android.apps.mytracks.io.sendtogoogle.AbstractSendActivity;
import com.google.android.apps.mytracks.io.sendtogoogle.AbstractSendAsyncTask;
import com.google.android.apps.mytracks.io.sendtogoogle.SendRequest;
import com.google.android.apps.mytracks.io.sendtogoogle.UploadResultActivity;
import com.google.android.apps.mytracks.util.IntentUtils;
import com.google.android.maps.mytracks.R;
import com.google.common.annotations.VisibleForTesting;

import android.content.Intent;

/**
 * An activity to send a track to Google Fusion Tables.
 *
 * @author Jimmy Shih
 */
public class SendFusionTablesActivity extends AbstractSendActivity {

  @Override
  protected AbstractSendAsyncTask createAsyncTask() {
    return new SendFusionTablesAsyncTask(this, sendRequest.getTrackId(), sendRequest.getAccount());
  }

  @Override
  protected String getServiceName() {
    return getString(R.string.send_google_fusion_tables);
  }

  @Override
  protected void startNextActivity(boolean success, boolean isCancel) {
    sendRequest.setFusionTablesSuccess(success);
    Class<?> next = getNextClass(sendRequest, isCancel);
    Intent intent = IntentUtils.newIntent(this, next)
        .putExtra(SendRequest.SEND_REQUEST_KEY, sendRequest);
    startActivity(intent);
    finish();
  }
  
  @VisibleForTesting
  Class<?> getNextClass(SendRequest request, boolean isCancel) {
  if (isCancel) {
        return UploadResultActivity.class;
      } else {
        if (request.isSendDocs()) {
          return SendDocsActivity.class;
        } else {
          return UploadResultActivity.class;
        }
      }
  }
}

@@ -584,16 +584,17 @@
 se.%0A */%0A
+%0A
 package 
@@ -1262,24 +1262,25 @@
 n Tables.%0A *
+ 
 %0A * @author 
@@ -1999,18 +1999,16 @@
 ();%0A  %7D%0A
-  
 %0A  @Visi
@@ -2086,16 +2086,18 @@
 ncel) %7B%0A
+  
   if (is
@@ -2102,26 +2102,24 @@
 isCancel) %7B%0A
-  
       return
@@ -2147,26 +2147,24 @@
 .class;%0A    
- 
- 
 %7D else %7B%0A   
@@ -2156,26 +2156,24 @@
    %7D else %7B%0A
-  
       if (re
@@ -2198,26 +2198,24 @@
 ) %7B%0A        
- 
- 
 return SendD
@@ -2239,18 +2239,16 @@
 ;%0A      
-  
 %7D else %7B
@@ -2244,26 +2244,24 @@
    %7D else %7B%0A
-  
         retu
@@ -2297,22 +2297,18 @@
 ;%0A      
-  %7D%0A  
+%7D%0A
     %7D%0A  

Fix style in SendFusionTablesActivity.java