diff options
author | Roman Birg <roman@cyngn.com> | 2016-02-11 08:47:41 -0800 |
---|---|---|
committer | Roman Birg <roman@cyngn.com> | 2016-02-19 11:40:44 -0800 |
commit | 60a4ebcb43276691a4ac2c7b8065d0c87d2c4eec (patch) | |
tree | a9015e35bf9f7093e6fdde0684cd68eb4f92bef8 /packages/CMSettingsProvider/src | |
parent | ccce2924981e38358e710359fee0a9a132eb6047 (diff) | |
download | vendor_cmsdk-60a4ebcb43276691a4ac2c7b8065d0c87d2c4eec.zip vendor_cmsdk-60a4ebcb43276691a4ac2c7b8065d0c87d2c4eec.tar.gz vendor_cmsdk-60a4ebcb43276691a4ac2c7b8065d0c87d2c4eec.tar.bz2 |
cmsdk: insert dnd & edit tiles for 12.1 -> 13.0 upgrade
Ref: CYNGNOS-1924
Change-Id: I6d221e143dc91ec3dbc1c9a1877754f2b98b732e
Signed-off-by: Roman Birg <roman@cyngn.com>
Diffstat (limited to 'packages/CMSettingsProvider/src')
-rw-r--r-- | packages/CMSettingsProvider/src/org/cyanogenmod/cmsettings/CMSettingsProvider.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/packages/CMSettingsProvider/src/org/cyanogenmod/cmsettings/CMSettingsProvider.java b/packages/CMSettingsProvider/src/org/cyanogenmod/cmsettings/CMSettingsProvider.java index 2f91e1e..bd011b7 100644 --- a/packages/CMSettingsProvider/src/org/cyanogenmod/cmsettings/CMSettingsProvider.java +++ b/packages/CMSettingsProvider/src/org/cyanogenmod/cmsettings/CMSettingsProvider.java @@ -45,9 +45,13 @@ import android.text.TextUtils; import android.util.Log; import android.util.SparseArray; +import org.cyanogenmod.internal.util.QSConstants; +import org.cyanogenmod.internal.util.QSUtils; + import cyanogenmod.providers.CMSettings; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; @@ -204,6 +208,41 @@ public class CMSettingsProvider extends ContentProvider { else if (tableName.equals(CMDatabaseHelper.CMTableNames.TABLE_SECURE)) { settingsValue = Settings.Secure.getStringForUser(contentResolver, settingsKey, userId); + + // insert dnd, edit tiles for upgrade from 12.1 -> 13.0 + if (CMSettings.Secure.QS_TILES.equals(settingsKey) && (settingsValue != null + && (!settingsValue.contains(QSConstants.TILE_DND) + || !settingsValue.contains(QSConstants.TILE_EDIT)))) { + if (LOCAL_LOGV) { + Log.d(TAG, "Need to insert DND or Edit tile for upgrade, currentValue: " + + settingsValue); + } + + final List<String> tiles = Settings.Secure.getDelimitedStringAsList( + contentResolver, settingsKey, ","); + + if (!tiles.contains(QSConstants.TILE_DND)) { + tiles.add(QSConstants.TILE_DND); + } + if (!tiles.contains(QSConstants.TILE_EDIT)) { + // we need to insert edit tile to the last tile on the first page! + // ensure edit tile is present + + // use value in old database + boolean nineTilesPerPage = Settings.Secure.getInt(contentResolver, + CMSettings.Secure.QS_USE_MAIN_TILES, 0) == 1; + + final int TILES_PER_PAGE = nineTilesPerPage ? 9 : 8; + + if (tiles.size() > TILES_PER_PAGE) { + tiles.add((TILES_PER_PAGE - 1), QSConstants.TILE_EDIT); + } else { + tiles.add(QSConstants.TILE_EDIT); + } + } + + settingsValue = TextUtils.join(",", tiles); + } } else if (tableName.equals(CMDatabaseHelper.CMTableNames.TABLE_GLOBAL)) { settingsValue = Settings.Global.getStringForUser(contentResolver, settingsKey, |