package com.quicklyric.romanizer;

import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;

/**
 * This file is part of QuickLyricRomanizer
 * Created by geecko on 1/07/17.
 * <p>
 * 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
 * <p>
 * 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.
 */
public class RomanisationBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String[] inputs = intent.getExtras().getStringArray("input");
        String caller = intent.getExtras().getString("caller_package");
        String callerClass = intent.getExtras().getString("caller_class");

        if (inputs != null) {
            String[] outputs = new String[inputs.length];
            for (int i = 0; i < inputs.length; i++) {
                outputs[i] = RomanizerUtil.romanize(inputs[i]);
            }
            broadcast(context, outputs, caller, callerClass);
        }
        broadcast(context, null, caller, callerClass);
    }

    private void broadcast(Context context, String[] output, String caller, String callerClass) {
        Intent romanizedIntent = new Intent();
        romanizedIntent.setComponent(new ComponentName(caller, callerClass));
        romanizedIntent.setAction("com.geecko.QuickLyric.ROMANIZED_OUTPUT");
        romanizedIntent.putExtra("output", output);
        context.sendBroadcast(romanizedIntent);
    }
}

@@ -74,46 +74,8 @@
 er;%0A
-import android.content.ComponentName;%0A
 impo
@@ -993,154 +993,8 @@
 nput
-%22);%0A        String caller = intent.getExtras().getString(%22caller_package%22);%0A        String callerClass = intent.getExtras().getString(%22caller_clas
 s%22);
@@ -1253,37 +1253,16 @@
  outputs
-, caller, callerClass
 );%0A     
@@ -1301,29 +1301,8 @@
 null
-, caller, callerClass
 );%0A 
@@ -1370,43 +1370,8 @@
 tput
-, String caller, String callerClass
 ) %7B%0A
@@ -1387,25 +1387,25 @@
 ntent romani
-z
+s
 edIntent = n
@@ -1435,87 +1435,9 @@
 mani
-zedIntent.setComponent(new ComponentName(caller, callerClass));%0A        romaniz
+s
 edIn
@@ -1504,25 +1504,25 @@
       romani
-z
+s
 edIntent.put
@@ -1582,17 +1582,17 @@
 t(romani
-z
+s
 edIntent
@@ -1590,20 +1590,44 @@
 sedIntent);%0A
+        System.exit(0);%0A
     %7D%0A%7D%0A

Change input name and exit when finished