Search in sources :

Example 1 with EngineInfo

use of android.speech.tts.TextToSpeech.EngineInfo in project android_frameworks_base by ResurrectionRemix.

the class TtsEngines method getEngineInfo.

private EngineInfo getEngineInfo(ResolveInfo resolve, PackageManager pm) {
    ServiceInfo service = resolve.serviceInfo;
    if (service != null) {
        EngineInfo engine = new EngineInfo();
        // Using just the package name isn't great, since it disallows having
        // multiple engines in the same package, but that's what the existing API does.
        engine.name = service.packageName;
        CharSequence label = service.loadLabel(pm);
        engine.label = TextUtils.isEmpty(label) ? engine.name : label.toString();
        engine.icon = service.getIconResource();
        engine.priority = resolve.priority;
        engine.system = isSystemEngine(service);
        return engine;
    }
    return null;
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) EngineInfo(android.speech.tts.TextToSpeech.EngineInfo)

Example 2 with EngineInfo

use of android.speech.tts.TextToSpeech.EngineInfo in project android_frameworks_base by ResurrectionRemix.

the class TtsEngines method getEngines.

/**
     * Gets a list of all installed TTS engines.
     *
     * @return A list of engine info objects. The list can be empty, but never {@code null}.
     */
public List<EngineInfo> getEngines() {
    PackageManager pm = mContext.getPackageManager();
    Intent intent = new Intent(Engine.INTENT_ACTION_TTS_SERVICE);
    List<ResolveInfo> resolveInfos = pm.queryIntentServices(intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (resolveInfos == null)
        return Collections.emptyList();
    List<EngineInfo> engines = new ArrayList<EngineInfo>(resolveInfos.size());
    for (ResolveInfo resolveInfo : resolveInfos) {
        EngineInfo engine = getEngineInfo(resolveInfo, pm);
        if (engine != null) {
            engines.add(engine);
        }
    }
    Collections.sort(engines, EngineInfoComparator.INSTANCE);
    return engines;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) EngineInfo(android.speech.tts.TextToSpeech.EngineInfo) PackageManager(android.content.pm.PackageManager) ArrayList(java.util.ArrayList) Intent(android.content.Intent)

Example 3 with EngineInfo

use of android.speech.tts.TextToSpeech.EngineInfo in project android_frameworks_base by DirtyUnicorns.

the class TtsEngines method getEngines.

/**
     * Gets a list of all installed TTS engines.
     *
     * @return A list of engine info objects. The list can be empty, but never {@code null}.
     */
public List<EngineInfo> getEngines() {
    PackageManager pm = mContext.getPackageManager();
    Intent intent = new Intent(Engine.INTENT_ACTION_TTS_SERVICE);
    List<ResolveInfo> resolveInfos = pm.queryIntentServices(intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (resolveInfos == null)
        return Collections.emptyList();
    List<EngineInfo> engines = new ArrayList<EngineInfo>(resolveInfos.size());
    for (ResolveInfo resolveInfo : resolveInfos) {
        EngineInfo engine = getEngineInfo(resolveInfo, pm);
        if (engine != null) {
            engines.add(engine);
        }
    }
    Collections.sort(engines, EngineInfoComparator.INSTANCE);
    return engines;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) EngineInfo(android.speech.tts.TextToSpeech.EngineInfo) PackageManager(android.content.pm.PackageManager) ArrayList(java.util.ArrayList) Intent(android.content.Intent)

Example 4 with EngineInfo

use of android.speech.tts.TextToSpeech.EngineInfo in project android_frameworks_base by AOSPA.

the class TtsEngines method getEngines.

/**
     * Gets a list of all installed TTS engines.
     *
     * @return A list of engine info objects. The list can be empty, but never {@code null}.
     */
public List<EngineInfo> getEngines() {
    PackageManager pm = mContext.getPackageManager();
    Intent intent = new Intent(Engine.INTENT_ACTION_TTS_SERVICE);
    List<ResolveInfo> resolveInfos = pm.queryIntentServices(intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (resolveInfos == null)
        return Collections.emptyList();
    List<EngineInfo> engines = new ArrayList<EngineInfo>(resolveInfos.size());
    for (ResolveInfo resolveInfo : resolveInfos) {
        EngineInfo engine = getEngineInfo(resolveInfo, pm);
        if (engine != null) {
            engines.add(engine);
        }
    }
    Collections.sort(engines, EngineInfoComparator.INSTANCE);
    return engines;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) EngineInfo(android.speech.tts.TextToSpeech.EngineInfo) PackageManager(android.content.pm.PackageManager) ArrayList(java.util.ArrayList) Intent(android.content.Intent)

Example 5 with EngineInfo

use of android.speech.tts.TextToSpeech.EngineInfo in project XobotOS by xamarin.

the class TtsEngines method getEngineInfo.

private EngineInfo getEngineInfo(ResolveInfo resolve, PackageManager pm) {
    ServiceInfo service = resolve.serviceInfo;
    if (service != null) {
        EngineInfo engine = new EngineInfo();
        // Using just the package name isn't great, since it disallows having
        // multiple engines in the same package, but that's what the existing API does.
        engine.name = service.packageName;
        CharSequence label = service.loadLabel(pm);
        engine.label = TextUtils.isEmpty(label) ? engine.name : label.toString();
        engine.icon = service.getIconResource();
        engine.priority = resolve.priority;
        engine.system = isSystemEngine(service);
        return engine;
    }
    return null;
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) EngineInfo(android.speech.tts.TextToSpeech.EngineInfo)

Aggregations

EngineInfo (android.speech.tts.TextToSpeech.EngineInfo)37 Intent (android.content.Intent)15 SettingsActivity (com.android.settings.SettingsActivity)13 ArrayList (java.util.ArrayList)8 ContentResolver (android.content.ContentResolver)7 PackageManager (android.content.pm.PackageManager)7 ResolveInfo (android.content.pm.ResolveInfo)7 ServiceInfo (android.content.pm.ServiceInfo)7 GearPreference (com.android.settings.widget.GearPreference)7 SeekBarPreference (com.android.settings.widget.SeekBarPreference)7 ListPreference (android.support.v7.preference.ListPreference)6 Preference (android.support.v7.preference.Preference)6 LayoutPreference (com.android.settings.applications.LayoutPreference)6 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 AlertDialog (android.app.AlertDialog)1 Dialog (android.app.Dialog)1 ProgressDialog (android.app.ProgressDialog)1 ComponentName (android.content.ComponentName)1 DialogInterface (android.content.DialogInterface)1