// Path: app/src/main/java/ee/ioc/phon/android/speak/adapter/RecServiceAdapter.java
// public class RecServiceAdapter extends ArrayAdapter<RecService> {
// 
//     private final List<RecService> list;
//     private final Activity context;
// 
//     public RecServiceAdapter(K6neleListFragment context, List<RecService> list) {
//         super(context.getActivity(), R.layout.list_item_recservice, list);
//         this.context = context.getActivity();
//         this.list = list;
//     }
// 
//     private static class ViewHolder {
//         private ImageView icon;
//         private TextView service;
//         private TextView desc;
//     }
// 
//     @NonNull
//     @Override
//     public View getView(int position, View convertView, @NonNull ViewGroup parent) {
//         View view;
//         if (convertView == null) {
//             view = context.getLayoutInflater().inflate(R.layout.list_item_recservice, null);
//             final ViewHolder viewHolder = new ViewHolder();
//             viewHolder.icon = view.findViewById(R.id.serviceIcon);
//             viewHolder.service = view.findViewById(R.id.service);
//             viewHolder.desc = view.findViewById(R.id.desc);
//             view.setTag(viewHolder);
//         } else {
//             view = convertView;
//         }
//         ViewHolder holder = (ViewHolder) view.getTag();
//         RecService item = list.get(position);
//         holder.icon.setImageDrawable(item.getIcon(this.context));
//         holder.service.setText(item.getService());
//         String desc = item.getDesc();
//         if (desc == null || desc.isEmpty()) {
//             holder.desc.setText(R.string.dash);
//         } else {
//             holder.desc.setText(desc);
//         }
//         return view;
//     }
// }
// 
// Path: app/src/main/java/ee/ioc/phon/android/speak/fragment/K6neleListFragment.java
// public abstract class K6neleListFragment extends ListFragment {
// 
//     protected void toast(String message) {
//         Toast.makeText(getActivity(), message, Toast.LENGTH_LONG).show();
//     }
// 
//     protected void setEmptyView(String text) {
//         ListView lv = getListView();
//         TextView emptyView = (TextView) getActivity().getLayoutInflater().inflate(R.layout.empty_list, null);
//         emptyView.setText(text);
//         emptyView.setVisibility(View.GONE);
//         ((ViewGroup) lv.getParent()).addView(emptyView);
//         lv.setEmptyView(emptyView);
//     }
// }
// 
// Path: app/src/main/java/ee/ioc/phon/android/speak/model/RecService.java
// public class RecService {
// 
//     private final String mLabel;
//     private final String mDesc;
//     private String mSettingsActivity;
//     private final ComponentName mComponentName;
// 
//     public RecService(Context context, String id) {
//         String mDesc1 = "";
//         // Can return <null, "">
//         Pair<ComponentName, String> pair = RecognitionServiceManager.unflattenFromString(id);
//         mComponentName = pair.first;
// 
//         mLabel = RecognitionServiceManager.getServiceLabel(context, mComponentName);
//         ServiceInfo si = RecognitionServiceManager.getServiceInfo(context, mComponentName);
//         int resId = si.descriptionRes;
//         if (resId != 0) {
//             try {
//                 PackageManager manager = context.getPackageManager();
//                 mDesc1 = manager.getResourcesForApplication(mComponentName.getPackageName()).getString(resId);
//             } catch (PackageManager.NameNotFoundException e) {
//                 // Should not happen
//             }
//         }
//         mDesc = mDesc1;
//         try {
//             mSettingsActivity = RecognitionServiceManager.getSettingsActivity(context, si);
//             Log.i(mSettingsActivity);
//         } catch (XmlPullParserException | IOException e) {
//             mSettingsActivity = null;
//         }
//     }
// 
//     public String getService() {
//         return mLabel;
//     }
// 
//     public String getDesc() {
//         return mDesc;
//     }
// 
//     public Drawable getIcon(Context context) {
//         return RecognitionServiceManager.getServiceIcon(context, mComponentName);
//     }
// 
//     public ComponentName getComponentName() {
//         return mComponentName;
//     }
// 
//     public Intent getSettingsIntent() {
//         if (mSettingsActivity == null) {
//             return null;
//         }
//         Intent intent = new Intent();
//         intent.setClassName(mComponentName.getPackageName(), mSettingsActivity);
//         return intent;
//     }
// }


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList;
import java.util.List;
import ee.ioc.phon.android.speak.R;
import ee.ioc.phon.android.speak.adapter.RecServiceAdapter;
import ee.ioc.phon.android.speak.fragment.K6neleListFragment;
import ee.ioc.phon.android.speak.model.RecService;
import ee.ioc.phon.android.speechutils.RecognitionServiceManager;
import ee.ioc.phon.android.speechutils.utils.IntentUtils;
package ee.ioc.phon.android.speak.activity;





public class RecServiceSelectorActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        SelectorFragment fragment = new SelectorFragment();
        fragment.setArguments(getIntent().getExtras());
        getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
    }

    public static class SelectorFragment extends K6neleListFragment {

        public void onCreate(Bundle icicle) {
            super.onCreate(icicle);
            Activity activity = getActivity();
            RecognitionServiceManager mngr = new RecognitionServiceManager();
// Path: app/src/main/java/ee/ioc/phon/android/speak/adapter/RecServiceAdapter.java
// public class RecServiceAdapter extends ArrayAdapter<RecService> {
// 
//     private final List<RecService> list;
//     private final Activity context;
// 
//     public RecServiceAdapter(K6neleListFragment context, List<RecService> list) {
//         super(context.getActivity(), R.layout.list_item_recservice, list);
//         this.context = context.getActivity();
//         this.list = list;
//     }
// 
//     private static class ViewHolder {
//         private ImageView icon;
//         private TextView service;
//         private TextView desc;
//     }
// 
//     @NonNull
//     @Override
//     public View getView(int position, View convertView, @NonNull ViewGroup parent) {
//         View view;
//         if (convertView == null) {
//             view = context.getLayoutInflater().inflate(R.layout.list_item_recservice, null);
//             final ViewHolder viewHolder = new ViewHolder();
//             viewHolder.icon = view.findViewById(R.id.serviceIcon);
//             viewHolder.service = view.findViewById(R.id.service);
//             viewHolder.desc = view.findViewById(R.id.desc);
//             view.setTag(viewHolder);
//         } else {
//             view = convertView;
//         }
//         ViewHolder holder = (ViewHolder) view.getTag();
//         RecService item = list.get(position);
//         holder.icon.setImageDrawable(item.getIcon(this.context));
//         holder.service.setText(item.getService());
//         String desc = item.getDesc();
//         if (desc == null || desc.isEmpty()) {
//             holder.desc.setText(R.string.dash);
//         } else {
//             holder.desc.setText(desc);
//         }
//         return view;
//     }
// }
// 
// Path: app/src/main/java/ee/ioc/phon/android/speak/fragment/K6neleListFragment.java
// public abstract class K6neleListFragment extends ListFragment {
// 
//     protected void toast(String message) {
//         Toast.makeText(getActivity(), message, Toast.LENGTH_LONG).show();
//     }
// 
//     protected void setEmptyView(String text) {
//         ListView lv = getListView();
//         TextView emptyView = (TextView) getActivity().getLayoutInflater().inflate(R.layout.empty_list, null);
//         emptyView.setText(text);
//         emptyView.setVisibility(View.GONE);
//         ((ViewGroup) lv.getParent()).addView(emptyView);
//         lv.setEmptyView(emptyView);
//     }
// }
// 
// Path: app/src/main/java/ee/ioc/phon/android/speak/model/RecService.java
// public class RecService {
// 
//     private final String mLabel;
//     private final String mDesc;
//     private String mSettingsActivity;
//     private final ComponentName mComponentName;
// 
//     public RecService(Context context, String id) {
//         String mDesc1 = "";
//         // Can return <null, "">
//         Pair<ComponentName, String> pair = RecognitionServiceManager.unflattenFromString(id);
//         mComponentName = pair.first;
// 
//         mLabel = RecognitionServiceManager.getServiceLabel(context, mComponentName);
//         ServiceInfo si = RecognitionServiceManager.getServiceInfo(context, mComponentName);
//         int resId = si.descriptionRes;
//         if (resId != 0) {
//             try {
//                 PackageManager manager = context.getPackageManager();
//                 mDesc1 = manager.getResourcesForApplication(mComponentName.getPackageName()).getString(resId);
//             } catch (PackageManager.NameNotFoundException e) {
//                 // Should not happen
//             }
//         }
//         mDesc = mDesc1;
//         try {
//             mSettingsActivity = RecognitionServiceManager.getSettingsActivity(context, si);
//             Log.i(mSettingsActivity);
//         } catch (XmlPullParserException | IOException e) {
//             mSettingsActivity = null;
//         }
//     }
// 
//     public String getService() {
//         return mLabel;
//     }
// 
//     public String getDesc() {
//         return mDesc;
//     }
// 
//     public Drawable getIcon(Context context) {
//         return RecognitionServiceManager.getServiceIcon(context, mComponentName);
//     }
// 
//     public ComponentName getComponentName() {
//         return mComponentName;
//     }
// 
//     public Intent getSettingsIntent() {
//         if (mSettingsActivity == null) {
//             return null;
//         }
//         Intent intent = new Intent();
//         intent.setClassName(mComponentName.getPackageName(), mSettingsActivity);
//         return intent;
//     }
// }


// Path: app/src/main/java/ee/ioc/phon/android/speak/activity/RecServiceSelectorActivity.java
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList;
import java.util.List;
import ee.ioc.phon.android.speak.R;
import ee.ioc.phon.android.speak.adapter.RecServiceAdapter;
import ee.ioc.phon.android.speak.fragment.K6neleListFragment;
import ee.ioc.phon.android.speak.model.RecService;
import ee.ioc.phon.android.speechutils.RecognitionServiceManager;
import ee.ioc.phon.android.speechutils.utils.IntentUtils;

package ee.ioc.phon.android.speak.activity;





public class RecServiceSelectorActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        SelectorFragment fragment = new SelectorFragment();
        fragment.setArguments(getIntent().getExtras());
        getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
    }

    public static class SelectorFragment extends K6neleListFragment {

        public void onCreate(Bundle icicle) {
            super.onCreate(icicle);
            Activity activity = getActivity();
            RecognitionServiceManager mngr = new RecognitionServiceManager();
            List<RecService> list = new ArrayList<>();