Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3bc3bc79 authored by Mohammadinamul Sheik's avatar Mohammadinamul Sheik
Browse files

Force download the dictionaries after the apk package is updated.

- Also display the notification when the dictionaries are auto updated


Bug: 19808828
Change-Id: If5c4efb73d8bb554d812afcf7deafec3ac40a462
parent e1b91d41
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -62,4 +62,11 @@ public class DictionaryPackConstants {
     */
     */
    public static final String UPDATE_NOW_INTENT_ACTION = DICTIONARY_DOMAIN
    public static final String UPDATE_NOW_INTENT_ACTION = DICTIONARY_DOMAIN
            + ".UPDATE_NOW";
            + ".UPDATE_NOW";

    /**
     * The intent action to inform the dictionary provider to initialize the db
     * and update now.
     */
    public static final String INIT_AND_UPDATE_NOW_INTENT_ACTION = DICTIONARY_DOMAIN
            + ".INIT_AND_UPDATE_NOW";
}
}
+1 −0
Original line number Original line Diff line number Diff line
@@ -144,6 +144,7 @@
                <action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
                <action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
                <action android:name="android.intent.action.DATE_CHANGED" />
                <action android:name="android.intent.action.DATE_CHANGED" />
                <action android:name="com.android.inputmethod.dictionarypack.aosp.UPDATE_NOW" />
                <action android:name="com.android.inputmethod.dictionarypack.aosp.UPDATE_NOW" />
                <action android:name="com.android.inputmethod.dictionarypack.aosp.INIT_AND_UPDATE_NOW" />
            </intent-filter>
            </intent-filter>
        </receiver>
        </receiver>


+2 −2
Original line number Original line Diff line number Diff line
@@ -25,6 +25,6 @@
    <bool name="allow_over_roaming">false</bool>
    <bool name="allow_over_roaming">false</bool>
    <bool name="dict_downloads_visible_in_download_UI">false</bool>
    <bool name="dict_downloads_visible_in_download_UI">false</bool>
    <bool name="metadata_downloads_visible_in_download_UI">false</bool>
    <bool name="metadata_downloads_visible_in_download_UI">false</bool>
    <bool name="display_notification_for_auto_update">false</bool>
    <bool name="display_notification_for_auto_update">true</bool>
    <bool name="display_notification_for_user_requested_update">false</bool>
    <bool name="display_notification_for_user_requested_update">true</bool>
</resources>
</resources>
+1 −1
Original line number Original line Diff line number Diff line
@@ -173,7 +173,7 @@ public final class ActionBatch {
            final long downloadId = UpdateHandler.registerDownloadRequest(manager, request, db,
            final long downloadId = UpdateHandler.registerDownloadRequest(manager, request, db,
                    mWordList.mId, mWordList.mVersion);
                    mWordList.mId, mWordList.mVersion);
            Log.i(TAG, String.format("Starting the dictionary download with version:"
            Log.i(TAG, String.format("Starting the dictionary download with version:"
                            + " %d and Url: %s" + mWordList.mVersion, uri));
                            + " %d and Url: %s", mWordList.mVersion, uri));
            DebugLogUtils.l("Starting download of", uri, "with id", downloadId);
            DebugLogUtils.l("Starting download of", uri, "with id", downloadId);
            PrivateLog.log("Starting download of " + uri + ", id : " + downloadId);
            PrivateLog.log("Starting download of " + uri + ", id : " + downloadId);
        }
        }
+12 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,8 @@ import android.content.SharedPreferences;
public final class CommonPreferences {
public final class CommonPreferences {
    private static final String COMMON_PREFERENCES_NAME = "LatinImeDictPrefs";
    private static final String COMMON_PREFERENCES_NAME = "LatinImeDictPrefs";


    public static final String PREF_FORCE_DOWNLOAD_DICT = "pref_key_force_download_dict";

    public static SharedPreferences getCommonPreferences(final Context context) {
    public static SharedPreferences getCommonPreferences(final Context context) {
        return context.getSharedPreferences(COMMON_PREFERENCES_NAME, 0);
        return context.getSharedPreferences(COMMON_PREFERENCES_NAME, 0);
    }
    }
@@ -37,4 +39,14 @@ public final class CommonPreferences {
        editor.putBoolean(id, false);
        editor.putBoolean(id, false);
        editor.apply();
        editor.apply();
    }
    }

    public static boolean isForceDownloadDict(Context context) {
        return getCommonPreferences(context).getBoolean(PREF_FORCE_DOWNLOAD_DICT, false);
    }

    public static void setForceDownloadDict(Context context, boolean forceDownload) {
        SharedPreferences.Editor editor = getCommonPreferences(context).edit();
        editor.putBoolean(PREF_FORCE_DOWNLOAD_DICT, forceDownload);
        editor.apply();
    }
}
}
Loading