package org.wikipedia.editactionfeed;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;

import org.wikipedia.Constants;
import org.wikipedia.activity.SingleFragmentActivity;
import org.wikipedia.analytics.SuggestedEditsFunnel;

public class EditTasksActivity extends SingleFragmentActivity<EditTasksFragment> {
    public static Intent newIntent(@NonNull Context context, Constants.InvokeSource invokeSource) {
        return new Intent(context, EditTasksActivity.class)
                .putExtra(Constants.INTENT_EXTRA_INVOKE_SOURCE, invokeSource);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getIntent().hasExtra(Constants.INTENT_EXTRA_INVOKE_SOURCE)) {
            Constants.InvokeSource source = (Constants.InvokeSource) getIntent().getSerializableExtra(Constants.INTENT_EXTRA_INVOKE_SOURCE);
            SuggestedEditsFunnel.get(source);

            if (source == Constants.InvokeSource.EDIT_FEED_TITLE_DESC
                    || source == Constants.InvokeSource.EDIT_FEED_TRANSLATE_TITLE_DESC) {
                startActivity(AddTitleDescriptionsActivity.Companion.newIntent(this, source));
            }

        } else {
            SuggestedEditsFunnel.get();
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        SuggestedEditsFunnel.get().pause();
    }

    @Override
    public void onResume() {
        super.onResume();
        SuggestedEditsFunnel.get().resume();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        SuggestedEditsFunnel.get().log();
        SuggestedEditsFunnel.reset();
    }

    @Override
    protected EditTasksFragment createFragment() {
        return EditTasksFragment.newInstance();
    }
}

@@ -388,16 +388,133 @@
 ment%3E %7B%0A
+    private static final String EXTRA_START_IMMEDIATELY = %22startImmediately%22;%0A    private boolean startImmediately;%0A%0A
     publ
@@ -613,22 +613,31 @@
         
-return
+Intent intent =
  new Int
@@ -761,122 +761,593 @@
     
-%7D%0A%0A    @Override%0A    public void onCreate(Bundle savedInstanceState) %7B%0A        super.onCreate(savedInstanceState);
+    if (invokeSource == Constants.InvokeSource.EDIT_FEED_TITLE_DESC%0A                %7C%7C invokeSource == Constants.InvokeSource.EDIT_FEED_TRANSLATE_TITLE_DESC) %7B%0A            intent.putExtra(EXTRA_START_IMMEDIATELY, true);%0A        %7D%0A        return intent;%0A    %7D%0A%0A    @Override%0A    public void onCreate(Bundle savedInstanceState) %7B%0A        super.onCreate(savedInstanceState);%0A        startImmediately = savedInstanceState == null%0A                ? getIntent().getBooleanExtra(EXTRA_START_IMMEDIATELY, false)%0A                : savedInstanceState.getBoolean(EXTRA_START_IMMEDIATELY, false);%0A
 %0A   
@@ -1619,16 +1619,57 @@
       if
+ (startImmediately%0A                    &&
  (source
@@ -1795,35 +1795,78 @@
 LATE_TITLE_DESC)
+)
  %7B%0A
+                startImmediately = false;%0A
                 
@@ -2025,32 +2025,230 @@
        %7D%0A    %7D%0A%0A
+    @Override public void onSaveInstanceState(@NonNull Bundle outState) %7B%0A        super.onSaveInstanceState(outState);%0A        outState.putBoolean(EXTRA_START_IMMEDIATELY, startImmediately);%0A    %7D%0A%0A
     @Override%0A  

Fix correct auto-launching of suggested editing subtasks.