diff options
author | Robert Burns <burnsra@gmail.com> | 2012-09-12 20:17:08 -0400 |
---|---|---|
committer | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2012-11-19 01:26:17 +0000 |
commit | 4a06d4f28caf3415d843a0646a15f3ebdd909738 (patch) | |
tree | 967c570893dcb135b696a1323ffd4ef3975ed56b /src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java | |
parent | 25ee0f5d90d04da37aca79e59a68a51d44424493 (diff) | |
download | packages_apps_trebuchet-4a06d4f28caf3415d843a0646a15f3ebdd909738.zip packages_apps_trebuchet-4a06d4f28caf3415d843a0646a15f3ebdd909738.tar.gz packages_apps_trebuchet-4a06d4f28caf3415d843a0646a15f3ebdd909738.tar.bz2 |
Fix shortcut intent when using less than 3 homescreens
This patch fixes issue 6192 as outlined at the URL below:
http://code.google.com/p/cyanogenmod/issues/detail?id=6192
To reproduce the issue set the number of home screens to 2 or less and try to add a shortcut as follows:
- open "People" application
- select a contact
- using context menu, choose "Place on Home screen"
- go to home screen to see crash
Change-Id: Ib1c7f6b1cf5055714b4d9e57c637c8a7fa05e9d8
Diffstat (limited to 'src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java')
-rw-r--r-- | src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java b/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java index 9b9418a..847189c 100644 --- a/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java +++ b/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java @@ -25,6 +25,7 @@ import android.content.pm.PackageManager; import android.widget.Toast; import com.cyanogenmod.trebuchet.R; +import com.cyanogenmod.trebuchet.preference.PreferencesProvider; import java.util.ArrayList; import java.util.HashSet; @@ -136,7 +137,10 @@ public class InstallShortcutReceiver extends BroadcastReceiver { // Try adding to the workspace screens incrementally, starting at the default or center // screen and alternating between +1, -1, +2, -2, etc. (using ~ ceil(i/2f)*(-1)^(i-1)) - final int screen = Launcher.DEFAULT_SCREEN; + final int screenCount = PreferencesProvider.Interface.Homescreen.getNumberHomescreens(context); + final int screenDefault = PreferencesProvider.Interface.Homescreen.getDefaultHomescreen(context, screenCount / 2); + final int screen = (screenDefault >= screenCount) ? screenCount / 2 : screenDefault; + for (int i = 0; i < (2 * Launcher.MAX_SCREEN_COUNT) + 1 && !found; ++i) { int si = screen + (int) ((i / 2f) + 0.5f) * ((i % 2 == 1) ? 1 : -1); if (0 <= si && si < Launcher.MAX_SCREEN_COUNT) { |