use of ai.saiy.android.localisation.SupportedLanguage in project Saiy-PS by brandall76.
the class CustomCommandHelper method commandExists.
/**
* Check if the keyphrase for the custom command already exists
*
* @param ctx the application context
* @param customCommand the prepared {@link CustomCommand}
* @return true if the keyphrase exists, false otherwise
*/
public boolean commandExists(@NonNull final Context ctx, @NonNull final CustomCommand customCommand) {
final ArrayList<CustomCommandContainer> customCommandContainerArray = getCustomCommands(ctx);
if (UtilsList.notNaked(customCommandContainerArray)) {
if (DEBUG) {
MyLog.i(CLS_NAME, "have commands");
}
final SupportedLanguage sl = SupportedLanguage.getSupportedLanguage(UtilsLocale.stringToLocale(customCommand.getVRLocale()));
final Locale loc = sl.getLocale();
for (final CustomCommandContainer ccc : customCommandContainerArray) {
if (ccc.getKeyphrase().toLowerCase(loc).trim().matches(customCommand.getKeyphrase().toLowerCase(loc).trim())) {
if (DEBUG) {
MyLog.i(CLS_NAME, "keyphrase matched: " + ccc.getKeyphrase() + " ~ " + customCommand.getKeyphrase());
}
return true;
}
}
if (DEBUG) {
MyLog.i(CLS_NAME, "command is not a duplicate");
}
} else {
if (DEBUG) {
MyLog.i(CLS_NAME, "no commands");
}
}
return false;
}
use of ai.saiy.android.localisation.SupportedLanguage in project Saiy-PS by brandall76.
the class MemoryHelper method getUnknown.
/**
* No {@link Memory} was stored, so we need to let the user know. We get the utterance we will
* announce from the {@link PersonalityResponse} class.
*
* @param ctx the application context
* @return a constructed {@link Memory} object
*/
private static Memory getUnknown(@NonNull final Context ctx) {
final String vrLanguage = SPH.getVRLocale(ctx).toString();
final String ttsLanguage = SPH.getTTSLocale(ctx).toString();
final ArrayList<String> utteranceArray = new ArrayList<>();
final int action = LocalRequest.ACTION_SPEAK_ONLY;
final CC command = CC.COMMAND_UNKNOWN;
final int condition = Condition.CONDITION_NONE;
final SupportedLanguage sl = SupportedLanguage.getSupportedLanguage(SPH.getVRLocale(ctx));
final String utterance = PersonalityResponse.getNoMemory(ctx, sl);
return new Memory(action, vrLanguage, ttsLanguage, utterance, utteranceArray, command, condition, sl);
}
Aggregations