com.android.inputmethod.latin.BinaryDictionaryFileDumper Java Examples

The following examples show how to use com.android.inputmethod.latin.BinaryDictionaryFileDumper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActionBatch.java    From Android-Keyboard with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(final Context context) {
    if (null == mWordListValues) {
        Log.e(TAG, "InstallAfterDownloadAction with a null parameter!");
        return;
    }
    final int status = mWordListValues.getAsInteger(MetadataDbHelper.STATUS_COLUMN);
    if (MetadataDbHelper.STATUS_DOWNLOADING != status) {
        final String id = mWordListValues.getAsString(MetadataDbHelper.WORDLISTID_COLUMN);
        Log.e(TAG, "Unexpected state of the word list '" + id + "' : " + status
                + " for an InstallAfterDownload action. Bailing out.");
        return;
    }

    DebugLogUtils.l("Setting word list as installed");
    final SQLiteDatabase db = MetadataDbHelper.getDb(context, mClientId);
    MetadataDbHelper.markEntryAsFinishedDownloadingAndInstalled(db, mWordListValues);

    // Install the downloaded file by un-compressing and moving it to the staging
    // directory. Ideally, we should do this before updating the DB, but the
    // installDictToStagingFromContentProvider() relies on the db being updated.
    final String localeString = mWordListValues.getAsString(MetadataDbHelper.LOCALE_COLUMN);
    BinaryDictionaryFileDumper.installDictToStagingFromContentProvider(
            LocaleUtils.constructLocaleFromString(localeString), context, false);
}
 
Example #2
Source File: DictionaryService.java    From Android-Keyboard with Apache License 2.0 6 votes vote down vote up
static void dispatchBroadcast(final Context context, final Intent intent) {
    final String action = intent.getAction();
    if (DATE_CHANGED_INTENT_ACTION.equals(action)) {
        // This happens when the date of the device changes. This normally happens
        // at midnight local time, but it may happen if the user changes the date
        // by hand or something similar happens.
        checkTimeAndMaybeSetupUpdateAlarm(context);
    } else if (DictionaryPackConstants.UPDATE_NOW_INTENT_ACTION.equals(action)) {
        // Intent to trigger an update now.
        UpdateHandler.tryUpdate(context);
    } else if (DictionaryPackConstants.INIT_AND_UPDATE_NOW_INTENT_ACTION.equals(action)) {
        // Initialize the client Db.
        final String mClientId = context.getString(R.string.dictionary_pack_client_id);
        BinaryDictionaryFileDumper.initializeClientRecordHelper(context, mClientId);

        // Updates the metadata and the download the dictionaries.
        UpdateHandler.tryUpdate(context);
    } else {
        UpdateHandler.downloadFinished(context, intent);
    }
}
 
Example #3
Source File: ActionBatch.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(final Context context) {
    if (null == mWordListValues) {
        Log.e(TAG, "InstallAfterDownloadAction with a null parameter!");
        return;
    }
    final int status = mWordListValues.getAsInteger(MetadataDbHelper.STATUS_COLUMN);
    if (MetadataDbHelper.STATUS_DOWNLOADING != status) {
        final String id = mWordListValues.getAsString(MetadataDbHelper.WORDLISTID_COLUMN);
        Log.e(TAG, "Unexpected state of the word list '" + id + "' : " + status
                + " for an InstallAfterDownload action. Bailing out.");
        return;
    }

    DebugLogUtils.l("Setting word list as installed");
    final SQLiteDatabase db = MetadataDbHelper.getDb(context, mClientId);
    MetadataDbHelper.markEntryAsFinishedDownloadingAndInstalled(db, mWordListValues);

    // Install the downloaded file by un-compressing and moving it to the staging
    // directory. Ideally, we should do this before updating the DB, but the
    // installDictToStagingFromContentProvider() relies on the db being updated.
    final String localeString = mWordListValues.getAsString(MetadataDbHelper.LOCALE_COLUMN);
    BinaryDictionaryFileDumper.installDictToStagingFromContentProvider(
            LocaleUtils.constructLocaleFromString(localeString), context, false);
}
 
Example #4
Source File: DictionaryService.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
static void dispatchBroadcast(final Context context, final Intent intent) {
    final String action = intent.getAction();
    if (DATE_CHANGED_INTENT_ACTION.equals(action)) {
        // This happens when the date of the device changes. This normally happens
        // at midnight local time, but it may happen if the user changes the date
        // by hand or something similar happens.
        checkTimeAndMaybeSetupUpdateAlarm(context);
    } else if (new DictionaryPackConstants(context).UPDATE_NOW_INTENT_ACTION.equals(action)) {
        // Intent to trigger an update now.
        UpdateHandler.tryUpdate(context);
    } else if (new DictionaryPackConstants(context).INIT_AND_UPDATE_NOW_INTENT_ACTION.equals(action)) {
        // Initialize the client Db.
        final String mClientId = context.getString(R.string.dictionary_pack_client_id);
        BinaryDictionaryFileDumper.initializeClientRecordHelper(context, mClientId);

        // Updates the metadata and the download the dictionaries.
        UpdateHandler.tryUpdate(context);
    } else {
        UpdateHandler.downloadFinished(context, intent);
    }
}
 
Example #5
Source File: ActionBatch.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(final Context context) {
    if (null == mWordListValues) {
        Log.e(TAG, "InstallAfterDownloadAction with a null parameter!");
        return;
    }
    final int status = mWordListValues.getAsInteger(MetadataDbHelper.STATUS_COLUMN);
    if (MetadataDbHelper.STATUS_DOWNLOADING != status) {
        final String id = mWordListValues.getAsString(MetadataDbHelper.WORDLISTID_COLUMN);
        Log.e(TAG, "Unexpected state of the word list '" + id + "' : " + status
                + " for an InstallAfterDownload action. Bailing out.");
        return;
    }

    DebugLogUtils.l("Setting word list as installed");
    final SQLiteDatabase db = MetadataDbHelper.getDb(context, mClientId);
    MetadataDbHelper.markEntryAsFinishedDownloadingAndInstalled(db, mWordListValues);

    // Install the downloaded file by un-compressing and moving it to the staging
    // directory. Ideally, we should do this before updating the DB, but the
    // installDictToStagingFromContentProvider() relies on the db being updated.
    final String localeString = mWordListValues.getAsString(MetadataDbHelper.LOCALE_COLUMN);
    BinaryDictionaryFileDumper.installDictToStagingFromContentProvider(
            LocaleUtils.constructLocaleFromString(localeString), context, false);
}
 
Example #6
Source File: DictionaryService.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
static void dispatchBroadcast(final Context context, final Intent intent) {
    final String action = intent.getAction();
    if (DATE_CHANGED_INTENT_ACTION.equals(action)) {
        // This happens when the date of the device changes. This normally happens
        // at midnight local time, but it may happen if the user changes the date
        // by hand or something similar happens.
        checkTimeAndMaybeSetupUpdateAlarm(context);
    } else if (DictionaryPackConstants.UPDATE_NOW_INTENT_ACTION.equals(action)) {
        // Intent to trigger an update now.
        UpdateHandler.tryUpdate(context);
    } else if (DictionaryPackConstants.INIT_AND_UPDATE_NOW_INTENT_ACTION.equals(action)) {
        // Initialize the client Db.
        final String mClientId = context.getString(R.string.dictionary_pack_client_id);
        BinaryDictionaryFileDumper.initializeClientRecordHelper(context, mClientId);

        // Updates the metadata and the download the dictionaries.
        UpdateHandler.tryUpdate(context);
    } else {
        UpdateHandler.downloadFinished(context, intent);
    }
}