FP2-1664: Launcher - Adapt layout for corrected dpi

The launcher and associated components must react
correctly to non-standard pixel density settings.

Change-Id: If29f11f2ff343c59d26c830e70056637022fdfa1
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index da1f2da..e309385 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -18,8 +18,8 @@
 -->
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.fairphone.fplauncher3"
-    android:versionCode="2"
-    android:versionName="2 (FP2 - 1.0)">
+    android:versionCode="3"
+    android:versionName="3 (FP2 - 1.1)">
 
     <uses-sdk
         android:minSdkVersion="17"
diff --git a/res/drawable-xxhdpi/wallpaper_xrayback.jpg b/res/drawable-xxhdpi/wallpaper_xrayback.jpg
new file mode 100644
index 0000000..97f9ceb
--- /dev/null
+++ b/res/drawable-xxhdpi/wallpaper_xrayback.jpg
Binary files differ
diff --git a/res/drawable-xxhdpi/wallpaper_xrayback_small.jpg b/res/drawable-xxhdpi/wallpaper_xrayback_small.jpg
new file mode 100644
index 0000000..cf4c308
--- /dev/null
+++ b/res/drawable-xxhdpi/wallpaper_xrayback_small.jpg
Binary files differ
diff --git a/res/layout/fp_app_switcher.xml b/res/layout/fp_app_switcher.xml
index a0b8c5e..a6ae353 100644
--- a/res/layout/fp_app_switcher.xml
+++ b/res/layout/fp_app_switcher.xml
@@ -4,11 +4,15 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:minHeight="500dp"
-    android:orientation="horizontal" >
+    android:orientation="horizontal"
+    android:layout_marginStart="16dp"
+    android:layout_marginEnd="16dp"
+    android:baselineAligned="false">
 
     <LinearLayout
-        android:layout_width="124dp"
+        android:layout_width="0px"
         android:layout_height="match_parent"
+        android:layout_weight="1"
         android:gravity="center_horizontal"
         android:layout_marginTop="30dp"
         android:orientation="vertical" >
@@ -18,15 +22,14 @@
             style="@style/AppSwitcherTitle"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:gravity="left"
+            android:gravity="center"
             android:text="@string/last_used" />
 
         <LinearLayout
             android:id="@+id/lastUsedApps"
             android:layout_width="match_parent"
-            android:layout_height="0dp"
+            android:layout_height="match_parent"
             android:layout_marginTop="14dp"
-            android:layout_weight="1"
             android:gravity="center_horizontal"
             android:orientation="vertical" />
     </LinearLayout>
@@ -35,16 +38,14 @@
         android:layout_width="1dp"
         android:layout_height="match_parent"
         android:layout_marginTop="30dp"
-        android:layout_marginBottom="25dp"
         android:background="@color/line_shadow" />
 
     <LinearLayout
-        android:layout_width="match_parent"
+        android:layout_width="0px"
         android:layout_height="match_parent"
-        android:layout_weight="1"
+        android:layout_weight="2"
         android:orientation="vertical"
-        android:layout_marginTop="30dp"
-        android:layout_marginLeft="8dp" >
+        android:layout_marginTop="30dp" >
 
         <TextView
             android:id="@+id/mostUsedAppsTitle"
@@ -72,4 +73,4 @@
             android:layout_marginTop="14dp"
             android:orientation="vertical" />
     </LinearLayout>
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/res/layout/fp_edit_favorites.xml b/res/layout/fp_edit_favorites.xml
index 8de24ee..bfba209 100644
--- a/res/layout/fp_edit_favorites.xml
+++ b/res/layout/fp_edit_favorites.xml
@@ -1,27 +1,24 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
     android:id="@+id/edit_favourites_menu_main"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:orientation="horizontal" >
+    android:orientation="horizontal">
 
-    <LinearLayout
+    <RelativeLayout
         android:id="@+id/favourites_group"
         android:layout_width="125dp"
         android:layout_height="match_parent"
-        android:background="@color/edit_favourites_background_white"
-        android:orientation="vertical"
-        android:paddingTop="38dp" >
+        android:background="@color/edit_favourites_background_white">
 
         <RadioGroup
             android:id="@+id/theme_radio_group"
             android:layout_width="match_parent"
             android:layout_height="34dp"
-            android:layout_marginBottom="46dp"
+            android:layout_marginTop="38dp"
+            android:alpha="0"
             android:background="@drawable/stripe_light_up_tile"
             android:orientation="horizontal"
-            android:padding="3.6dp"
-            android:alpha="0" >
+            android:padding="3.6dp">
 
             <RadioButton
                 android:id="@+id/theme_radio_button_dark"
@@ -31,7 +28,7 @@
                 android:layout_weight="1"
                 android:button="@null"
                 android:text="@string/fp_theme_dark"
-                android:visibility="gone"/>
+                android:visibility="gone" />
 
             <RadioButton
                 android:id="@+id/theme_radio_button_light"
@@ -45,34 +42,42 @@
                 android:visibility="gone" />
         </RadioGroup>
 
-        <include
-            android:id="@+id/favourite_group_1"
-            layout="@layout/fp_edit_favorites_favourite_item" />
-
-        <include
-            android:id="@+id/favourite_group_2"
-            layout="@layout/fp_edit_favorites_favourite_item" />
-
-        <ImageView
-            android:id="@+id/all_apps_image_view"
+        <LinearLayout
             android:layout_width="match_parent"
-            android:layout_height="76.6dp"
-            android:padding="14dp"
-            android:src="@drawable/icon_allapps_grey" />
+            android:layout_height="wrap_content"
+            android:layout_alignParentStart="true"
+            android:layout_centerVertical="true"
+            android:orientation="vertical">
 
-        <include
-            android:id="@+id/favourite_group_3"
-            layout="@layout/fp_edit_favorites_favourite_item" />
+            <include
+                android:id="@+id/favourite_group_1"
+                layout="@layout/fp_edit_favorites_favourite_item" />
 
-        <include
-            android:id="@+id/favourite_group_4"
-            layout="@layout/fp_edit_favorites_favourite_item" />
-    </LinearLayout>
+            <include
+                android:id="@+id/favourite_group_2"
+                layout="@layout/fp_edit_favorites_favourite_item" />
+
+            <ImageView
+                android:id="@+id/all_apps_image_view"
+                android:layout_width="match_parent"
+                android:layout_height="76.6dp"
+                android:padding="14dp"
+                android:src="@drawable/icon_allapps_grey" />
+
+            <include
+                android:id="@+id/favourite_group_3"
+                layout="@layout/fp_edit_favorites_favourite_item" />
+
+            <include
+                android:id="@+id/favourite_group_4"
+                layout="@layout/fp_edit_favorites_favourite_item" />
+        </LinearLayout>
+    </RelativeLayout>
 
     <FrameLayout
         android:id="@+id/all_apps_group"
         android:layout_width="wrap_content"
-        android:layout_height="match_parent" >
+        android:layout_height="match_parent">
 
         <com.fairphone.fplauncher3.edgeswipe.editor.ui.EditFavoritesGridView
             android:id="@+id/all_apps_gridview"
@@ -115,4 +120,4 @@
             android:visibility="gone" />
     </FrameLayout>
 
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/res/layout/fp_last_used_item.xml b/res/layout/fp_last_used_item.xml
index bcaf2c9..fbcc2ae 100644
--- a/res/layout/fp_last_used_item.xml
+++ b/res/layout/fp_last_used_item.xml
@@ -1,8 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/recentRow"
-    android:layout_width="112dp"
-    android:layout_height="88dp"
+    android:layout_width="match_parent"
+    android:layout_height="0px"
+    android:gravity="center_vertical"
+    android:layout_weight="1"
     android:clickable="true"
     android:paddingTop="3dp"
     android:paddingBottom="3dp"
@@ -10,7 +12,7 @@
     android:orientation="vertical">
 
     <ImageView
-        android:id="@android:id/background"
+        android:id="@+id/recent_app_logo"
         android:layout_width="@dimen/edit_favorites_icon_size"
         android:layout_height="@dimen/edit_favorites_icon_size"
         android:scaleType="fitCenter"
@@ -25,4 +27,4 @@
         android:clickable="false"/>
 
 
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/res/layout/fp_most_used_item.xml b/res/layout/fp_most_used_item.xml
index 6e12a84..1542a1a 100644
--- a/res/layout/fp_most_used_item.xml
+++ b/res/layout/fp_most_used_item.xml
@@ -1,36 +1,44 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/mostUsedRow"
-    android:layout_width="200dp"
-    android:layout_height="73dp"
-    android:clickable="true"
-    android:background="@drawable/button_last_used_app" >
+    android:layout_width="match_parent"
+    android:layout_height="0px"
+    android:layout_weight="1"
+    android:gravity="center_vertical"
+    android:background="@drawable/button_last_used_app"
+    android:clickable="true">
 
-    <ImageView
-        android:id="@android:id/content"
-        android:layout_width="@dimen/edit_favorites_icon_size"
-        android:layout_height="@dimen/edit_favorites_icon_size"
-        android:layout_centerVertical="true"
-        android:clickable="false"
-        android:layout_marginLeft="7dp"/>
-
-    <TextView
-        android:id="@+id/mostUsedButton"
+    <LinearLayout
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:clickable="false"
-        android:layout_toRightOf="@android:id/content"
-        android:layout_marginLeft="9dp"
-        android:fontFamily="sans-serif-medium"
-        android:gravity="center_vertical|left"
-        android:includeFontPadding="false"
-        android:maxLines="2"
-        android:ellipsize="end"
-        android:textAllCaps="false"
-        android:textColor="@color/white"
-        android:textSize="16sp"
-        android:shadowColor="@color/black"
-        android:shadowDx="0"
-        android:shadowDy="0"
-        android:shadowRadius="0" />
-</RelativeLayout>
\ No newline at end of file
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="8dp"
+        android:layout_marginRight="8dp">
+
+        <ImageView
+            android:id="@+id/most_app_logo"
+            android:layout_width="@dimen/edit_favorites_icon_size"
+            android:layout_height="@dimen/edit_favorites_icon_size"
+            android:layout_marginLeft="7dp"
+            android:clickable="false" />
+
+        <TextView
+            android:id="@+id/mostUsedButton"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginLeft="9dp"
+            android:layout_toRightOf="@id/most_app_logo"
+            android:clickable="false"
+            android:ellipsize="end"
+            android:fontFamily="sans-serif-medium"
+            android:gravity="center_vertical|left"
+            android:includeFontPadding="false"
+            android:maxLines="2"
+            android:shadowColor="@color/black"
+            android:shadowDx="0"
+            android:shadowDy="0"
+            android:shadowRadius="0"
+            android:textAllCaps="false"
+            android:textColor="@color/white"
+            android:textSize="16sp" />
+    </LinearLayout>
+</RelativeLayout>
diff --git a/res/layout/fp_oobe_texts.xml b/res/layout/fp_oobe_texts.xml
index 96f3b40..f7166f9 100644
--- a/res/layout/fp_oobe_texts.xml
+++ b/res/layout/fp_oobe_texts.xml
@@ -77,6 +77,8 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginTop="56dp"
+            android:layout_marginStart="8dp"
+            android:layout_marginEnd="8dp"
             android:text="@string/workspace_cling_longpress_title" />
 
         <TextView
@@ -84,6 +86,8 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginTop="16dp"
+            android:layout_marginStart="16dp"
+            android:layout_marginEnd="16dp"
             android:text="@string/workspace_cling_longpress_description" />
 
         <Button
@@ -108,11 +112,10 @@
             android:layout_marginTop="37dp"/>
 </LinearLayout>
 
-    <LinearLayout
+    <RelativeLayout
         android:id="@+id/oobeTextGroup4"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:orientation="vertical"
         android:visibility="gone">
 
    <!--     <TextView
@@ -131,14 +134,15 @@
             android:id="@+id/got_it_button_4"
             android:layout_width="220dp"
             android:layout_height="48dp"
-            android:layout_gravity="center_horizontal"
-            android:layout_marginTop="515dp"
+            android:layout_alignParentBottom="true"
+            android:layout_centerHorizontal="true"
+            android:layout_marginBottom="15.7dp"
             android:background="@drawable/button_border"
             android:text="@string/workspace_cling_longpress_dismiss"
             android:textAllCaps="true"
             android:textColor="@color/oobe_blue_light" />
 
-    </LinearLayout>
+    </RelativeLayout>
 
     <LinearLayout
         android:id="@+id/oobeTextGroup5"
@@ -271,11 +275,10 @@
             android:text="@string/oobe_edit_drag_trade_text" />
     </LinearLayout>
 
-    <LinearLayout
+    <RelativeLayout
         android:id="@+id/oobeTextGroup10"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:orientation="vertical"
         android:paddingLeft="40dp"
         android:paddingRight="40dp"
 
@@ -301,11 +304,13 @@
             android:layout_width="220dp"
             android:layout_height="48dp"
             android:layout_gravity="center_horizontal"
-            android:layout_marginTop="525dp"
+            android:layout_alignParentBottom="true"
+            android:layout_centerHorizontal="true"
+            android:layout_marginBottom="15.7dp"
             android:background="@drawable/button_border"
             android:text="@string/workspace_cling_longpress_dismiss"
             android:textAllCaps="true"
             android:textColor="@color/oobe_blue_light" />
-    </LinearLayout>
+    </RelativeLayout>
 
 </merge>
diff --git a/res/layout/tutorial_edge_swipe_layout.xml b/res/layout/tutorial_edge_swipe_layout.xml
index 2c28019..950b065 100644
--- a/res/layout/tutorial_edge_swipe_layout.xml
+++ b/res/layout/tutorial_edge_swipe_layout.xml
@@ -15,6 +15,8 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginTop="77dp"
+            android:layout_marginStart="16dp"
+            android:layout_marginEnd="16dp"
             android:fontFamily="sans-serif-light"
             android:text="@string/oobe_edge_swipe_title"
             />
@@ -25,6 +27,8 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginTop="125dp"
+            android:layout_marginStart="8dp"
+            android:layout_marginEnd="8dp"
             android:fontFamily="sans-serif-light"
             android:text="@string/oobe_edge_swipe_text"
             />
@@ -33,8 +37,9 @@
             android:id="@+id/swipeAnimationEditText"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_marginTop="340dp"
+            android:layout_marginTop="320dp"
             android:layout_marginLeft="70dp"
+            android:includeFontPadding="false"
             android:fontFamily="sans-serif"
             android:textSize="14sp"
             android:textColor="#2aa8e0"
diff --git a/src/com/fairphone/fplauncher3/DynamicGrid.java b/src/com/fairphone/fplauncher3/DynamicGrid.java
index 1cf7644..ba7af05 100644
--- a/src/com/fairphone/fplauncher3/DynamicGrid.java
+++ b/src/com/fairphone/fplauncher3/DynamicGrid.java
@@ -20,7 +20,7 @@
 import android.content.res.Resources;
 import android.util.DisplayMetrics;
 import android.util.TypedValue;
-import com.fairphone.fplauncher3.R;
+
 import java.util.ArrayList;
 
 
@@ -98,6 +98,9 @@
         deviceProfiles.add(new DeviceProfile("FP1",
                 334.66666f, 614.667f, 5, 4,  DEFAULT_ICON_SIZE_DP, 13, R.xml.default_workspace_4x4,
                 R.xml.default_workspace_4x4_no_all_apps));
+        deviceProfiles.add(new DeviceProfile("FP2",
+                392.72726f, 650.1818f, 5, 4, DEFAULT_ICON_SIZE_DP, 13, R.xml.default_workspace_4x4,
+                R.xml.default_workspace_4x4_no_all_apps));
         
         mMinWidth = dpiFromPx(minWidthPx, dm);
         mMinHeight = dpiFromPx(minHeightPx, dm);
diff --git a/src/com/fairphone/fplauncher3/Launcher.java b/src/com/fairphone/fplauncher3/Launcher.java
index 0052753..221a8cf 100644
--- a/src/com/fairphone/fplauncher3/Launcher.java
+++ b/src/com/fairphone/fplauncher3/Launcher.java
@@ -5130,7 +5130,7 @@
                                                 int oobeTutorial) {
         boolean result = false;
 
-       // if (true || mSharedPrefs.getBoolean(oobeToShow, true)) { //Uncomment to loop the animation
+        //if (true || mSharedPrefs.getBoolean(oobeToShow, true)) { //Uncomment to loop the animation
         if (mSharedPrefs.getBoolean(oobeToShow, true)) {
             startOOBEActivity(oobeTutorial);
             SharedPreferences.Editor editor = mSharedPrefs.edit();
diff --git a/src/com/fairphone/fplauncher3/edgeswipe/editor/EditFavoritesActivity.java b/src/com/fairphone/fplauncher3/edgeswipe/editor/EditFavoritesActivity.java
index 8f4368c..1aa42f4 100644
--- a/src/com/fairphone/fplauncher3/edgeswipe/editor/EditFavoritesActivity.java
+++ b/src/com/fairphone/fplauncher3/edgeswipe/editor/EditFavoritesActivity.java
@@ -85,7 +85,7 @@
     private RadioGroup mThemeRadioGroup;
     private RadioButton mThemeRadioButtonLight;
     private RadioButton mThemeRadioButtonDark;
-    private LinearLayout mFavouritesGroup;
+    private View mFavouritesGroup;
     private SharedPreferences mSharedPrefs;
     private Themes mCurrentTheme;
 
@@ -116,7 +116,7 @@
         mThemeRadioButtonLight = (RadioButton) findViewById(R.id.theme_radio_button_light);
         mThemeRadioButtonDark = (RadioButton) findViewById(R.id.theme_radio_button_dark);
 
-        mFavouritesGroup = (LinearLayout) findViewById(R.id.favourites_group);
+        mFavouritesGroup = findViewById(R.id.favourites_group);
 
         mSharedPrefs = getSharedPreferences(PREFS_EDGE_SWIPE_MENU, Context.MODE_PRIVATE);
 
diff --git a/src/com/fairphone/fplauncher3/oobe/OOBEActivity.java b/src/com/fairphone/fplauncher3/oobe/OOBEActivity.java
index f1fc92b..47ae8fb 100644
--- a/src/com/fairphone/fplauncher3/oobe/OOBEActivity.java
+++ b/src/com/fairphone/fplauncher3/oobe/OOBEActivity.java
@@ -21,6 +21,7 @@
 import android.graphics.drawable.AnimationDrawable;
 import android.media.MediaPlayer;
 import android.net.Uri;
+import android.os.Build;
 import android.os.Bundle;
 import android.provider.Settings;
 import android.util.Log;
@@ -130,7 +131,7 @@
             mTutorialToShow = OOBE_FULL_TUTORIAL;
         }
 
-        mAnimationSteps = new ArrayList<OOBEActivity.OOBESteps>();
+        mAnimationSteps = new ArrayList<>();
 
         mCurrentStep = 0;
 
@@ -409,7 +410,7 @@
             mOOBEGotItButton4.setOnClickListener(new OnClickListener() {
                 @Override
                 public void onClick(View v) {
-                    if (mCurrentStep < 2 && (mTutorialToShow == OOBE_DEVICE_TUTORIAL)) {
+                    if (mCurrentStep < 2 && (mTutorialToShow == OOBE_DEVICE_TUTORIAL) && Build.MODEL.equals("FP2")) {
                         jumpToNextSlide();
                     } else {
                         endOOBEActivity();
diff --git a/src/com/fairphone/fplauncher3/oobe/animation/CameraTutorialAnimationView.java b/src/com/fairphone/fplauncher3/oobe/animation/CameraTutorialAnimationView.java
index 644a570..6213c23 100644
--- a/src/com/fairphone/fplauncher3/oobe/animation/CameraTutorialAnimationView.java
+++ b/src/com/fairphone/fplauncher3/oobe/animation/CameraTutorialAnimationView.java
@@ -27,9 +27,6 @@
  */
 public class CameraTutorialAnimationView extends FrameLayout {
 
-    private int mArrowStopPointXinDP;
-    private int mArrowMiddlePointXinDP;
-
     public interface CameraTutorialAnimationViewListener {
         public void OnAnimationFinished(CameraTutorialAnimationView view);
     }
@@ -117,9 +114,6 @@
         animationGroupCircle = new KWAnimationGroup(animationManager);
         animationGroupArrowPoint = new KWAnimationGroup(animationManager);
 
-        mArrowMiddlePointXinDP = SCREEN_WIDTH - DynamicGrid.pxFromDp(120, mDisplayMetrics);
-        mArrowStopPointXinDP = SCREEN_WIDTH - DynamicGrid.pxFromDp(100,mDisplayMetrics);
-
         setupCircleAnimation();
         setupArrowAnimation();
     }
@@ -204,7 +198,7 @@
                 spriteCameraIcon.alpha = 0;
 
                 spriteArrow.y = (SCREEN_HEIGHT - 650);
-                spriteArrow.x = SCREEN_WIDTH - DynamicGrid.pxFromDp(110,mDisplayMetrics);
+                spriteArrow.x = (SCREEN_WIDTH / 2) + (spriteCircle.drawable.getIntrinsicWidth()/2);
                 spriteArrow.pivotY = 0.5f;
 
                 spriteCircle.y = (SCREEN_HEIGHT - 650);
@@ -244,7 +238,7 @@
             public void onAnimationGroupStarted(KWAnimationGroup group) {
 
                 spriteArrow.y = (SCREEN_HEIGHT - 650);
-                spriteArrow.x = SCREEN_WIDTH - DynamicGrid.pxFromDp(110, mDisplayMetrics);
+                spriteArrow.x = (SCREEN_WIDTH / 2) + (spriteCircle.drawable.getIntrinsicWidth()/2);// - DynamicGrid.pxFromDp(110, mDisplayMetrics);
                 spriteArrow.pivotY = 0.5f;
             }
 
diff --git a/src/com/fairphone/fplauncher3/oobe/animation/EdgeSwipeTutorialAnimationHelper.java b/src/com/fairphone/fplauncher3/oobe/animation/EdgeSwipeTutorialAnimationHelper.java
index 323f64f..4cc89e6 100644
--- a/src/com/fairphone/fplauncher3/oobe/animation/EdgeSwipeTutorialAnimationHelper.java
+++ b/src/com/fairphone/fplauncher3/oobe/animation/EdgeSwipeTutorialAnimationHelper.java
@@ -16,14 +16,19 @@
 package com.fairphone.fplauncher3.oobe.animation;
 
 import android.content.Context;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.ViewGroup;
 import android.view.animation.AccelerateInterpolator;
 import android.view.animation.AlphaAnimation;
 import android.view.animation.Animation;
 import android.view.animation.Animation.AnimationListener;
 import android.view.animation.AnimationSet;
 import android.view.animation.AnimationUtils;
+import android.view.animation.LinearInterpolator;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import com.fairphone.fplauncher3.R;
@@ -47,6 +52,14 @@
         TextView titleView = (TextView) animView.findViewById(R.id.swipeAnimationTitle);
         TextView textView = (TextView) animView.findViewById(R.id.swipeAnimationText);
         editView = (TextView) animView.findViewById(R.id.swipeAnimationEditText);
+        LinearLayout.MarginLayoutParams params = (LinearLayout.MarginLayoutParams) editView.getLayoutParams();
+        params.setMargins(
+                params.leftMargin,
+                Math.round((animView.SCREEN_HEIGHT / 2) + animView.mMarginTop - ((animView.spriteAllAppsIcon.height-editView.getLineHeight())/2)),
+                params.rightMargin,
+                params.bottomMargin
+        );
+        editView.setLayoutParams(params);
 
         Animation titleAnimation = new AlphaAnimation(0.0f, 1.0f);
         titleAnimation.setDuration(500);
diff --git a/src/com/fairphone/fplauncher3/oobe/animation/EdgeSwipeTutorialAnimationView.java b/src/com/fairphone/fplauncher3/oobe/animation/EdgeSwipeTutorialAnimationView.java
index dc87075..1fb8532 100644
--- a/src/com/fairphone/fplauncher3/oobe/animation/EdgeSwipeTutorialAnimationView.java
+++ b/src/com/fairphone/fplauncher3/oobe/animation/EdgeSwipeTutorialAnimationView.java
@@ -33,15 +33,15 @@
 
     private int mHandStopPointXinDP;
     private int mArrowStopPointXinDP;
-    private int mMarginTop;
+    int mMarginTop;
 
 
     public interface EdgeSwipeTutorialAnimationViewListener {
         public void OnAnimationFinished(EdgeSwipeTutorialAnimationView view);
     }
 
-    private int SCREEN_WIDTH = 540;
-    private int SCREEN_HEIGHT = 960;
+    int SCREEN_WIDTH = 540;
+    int SCREEN_HEIGHT = 960;
 
     KWSprite spriteRoot;
 
@@ -135,6 +135,7 @@
         spriteAppIconWithName4.applySizeFromDrawable();
         spriteAppSelectionShadow.drawable = ContextCompat.getDrawable(getContext(), R.drawable.tutorial_app_selection_shader);
         spriteAppSelectionShadow.applySizeFromDrawable();
+        spriteAppSelectionShadow.width = SCREEN_WIDTH;
 
         spriteRoot.addChild(spriteArrow);
         spriteRoot.addChild(spriteAllAppsIcon);
diff --git a/src/com/fairphone/fplauncher3/widgets/appswitcher/AppSwitcherWidget.java b/src/com/fairphone/fplauncher3/widgets/appswitcher/AppSwitcherWidget.java
index e7dafac..7f52b7e 100644
--- a/src/com/fairphone/fplauncher3/widgets/appswitcher/AppSwitcherWidget.java
+++ b/src/com/fairphone/fplauncher3/widgets/appswitcher/AppSwitcherWidget.java
@@ -108,6 +108,8 @@
 
     private static void updateMostUsedAppsList(Context context, int code, RemoteViews widget, List<ApplicationRunInformation> mostUsed)
     {
+        int slot_count = ApplicationRunInfoManager.MOST_APP_MAX_COUNT_LIMIT;
+
         for (ApplicationRunInformation mostUsedInfo : mostUsed)
         {
             RemoteViews view;
@@ -137,10 +139,18 @@
         {
             widget.addView(R.id.mostUsedApps, allAppsView);
         }
+
+        for (int i = mostUsed.size(); i < slot_count; i++) {
+            RemoteViews emptyMostRow = new RemoteViews(context.getPackageName(), R.layout.fp_most_used_item);
+            emptyMostRow.setViewVisibility(R.id.mostUsedRow, View.INVISIBLE);
+            widget.addView(R.id.mostUsedApps, emptyMostRow);
+        }
     }
 
     private static int updateLastUsedAppsList(Context context, int code, RemoteViews widget, List<ApplicationRunInformation> mostRecent)
     {
+        int slot_count = ApplicationRunInfoManager.RECENT_APP_MAX_COUNT_LIMIT;
+
         for (ApplicationRunInformation appRunInfo : mostRecent)
         {
             RemoteViews view;
@@ -163,6 +173,11 @@
             // update the code
             code++;
         }
+        for (int i = mostRecent.size(); i < slot_count; i++) {
+            RemoteViews emptyRecentRow = new RemoteViews(context.getPackageName(), R.layout.fp_last_used_item);
+            emptyRecentRow.setViewVisibility(R.id.recentRow, View.INVISIBLE);
+            widget.addView(R.id.lastUsedApps, emptyRecentRow);
+        }
         return code;
     }
 
@@ -189,7 +204,7 @@
         // debug String with app count
         @SuppressWarnings("UnusedAssignment") String fullAppLabel = info.getCount() + "# " + appLabel;
 
-        mostUsedRow.setImageViewBitmap(android.R.id.content, iconBitmap);
+        mostUsedRow.setImageViewBitmap(R.id.most_app_logo, iconBitmap);
 
         mostUsedRow.setTextViewText(R.id.mostUsedButton, APP_SWITCHER_DEBUG_MODE ? fullAppLabel : appLabel);
 
@@ -208,7 +223,7 @@
 
         Drawable draw = context.getResources().getDrawable(R.drawable.icon_allapps_white_widget);
         Bitmap icon = ((BitmapDrawable) draw).getBitmap();
-        allAppsButton.setImageViewBitmap(android.R.id.content, icon);
+        allAppsButton.setImageViewBitmap(R.id.most_app_logo, icon);
 
         allAppsButton.setTextViewText(R.id.mostUsedButton, context.getResources().getString(R.string.edge_swipe_all_apps).toUpperCase());
 
@@ -243,7 +258,6 @@
 
         // get application icon and label
         Drawable icon = pm.getActivityIcon(info.getComponentName());
-        Bitmap iconBitmap = ((BitmapDrawable) icon).getBitmap();
         CharSequence appLabel = pm.getActivityInfo(info.getComponentName(), 0).loadLabel(pm);
 
         // debug String with app count
@@ -251,7 +265,12 @@
 
 
         recentRow.setTextViewText(R.id.recentButton, APP_SWITCHER_DEBUG_MODE ? fullAppLabel : appLabel);
-        recentRow.setImageViewBitmap(android.R.id.background, iconBitmap);
+        try {
+            Bitmap iconBitmap = ((BitmapDrawable) icon).getBitmap();
+            recentRow.setImageViewBitmap(R.id.recent_app_logo, iconBitmap);
+        } catch (ClassCastException e) {
+            Log.e(TAG, "Failed to load bitmap drawable for "+fullAppLabel, e);
+        }
 
         // create the intent for this app
         Intent launchIntent = generateLaunchIntent(info, appLabel.toString());
@@ -292,4 +311,4 @@
         appWidgetManager.updateAppWidget(appWidgetIds, updateUI(context));
     }
 
-}
\ No newline at end of file
+}