Merge "minui: adapt backlight blanking commit to TWRP" into android-4.4
diff --git a/gui/fileselector.cpp b/gui/fileselector.cpp
index 0f8d903..b7804fd 100644
--- a/gui/fileselector.cpp
+++ b/gui/fileselector.cpp
@@ -659,7 +659,7 @@
 
 int GUIFileSelector::NotifyTouch(TOUCH_STATE state, int x, int y)
 {
-	static int lastY = 0, last2Y = 0;
+	static int lastY = 0, last2Y = 0, fastScroll = 0;
 	int selection = 0;
 
 	switch (state)
@@ -674,6 +674,9 @@
 			mUpdate = 1;
 		startY = lastY = last2Y = y;
 		scrollingSpeed = 0;
+
+		if(mFastScrollRectX != -1 && x >= mRenderX + mRenderW - mFastScrollW)
+			fastScroll = 1;
 		break;
 	case TOUCH_DRAG:
 		// Check if we dragged out of the selection window
@@ -687,7 +690,7 @@
 		}
 
 		// Fast scroll
-		if(mFastScrollRectX != -1 && x >= mRenderX + mRenderW - mFastScrollW)
+		if(fastScroll)
 		{
 			int pct = ((y-mRenderY-mHeaderH)*100)/(mRenderH-mHeaderH);
 			int totalSize = (mShowFolders ? mFolderList.size() : 0) + (mShowFiles ? mFileList.size() : 0);
@@ -761,6 +764,7 @@
 
 	case TOUCH_RELEASE:
 		isHighlighted = false;
+		fastScroll = 0;
 		if (startSelection >= 0)
 		{
 			// We've selected an item!
diff --git a/gui/listbox.cpp b/gui/listbox.cpp
index a4976f4..6709664 100644
--- a/gui/listbox.cpp
+++ b/gui/listbox.cpp
@@ -602,7 +602,7 @@
 
 int GUIListBox::NotifyTouch(TOUCH_STATE state, int x, int y)
 {
-	static int lastY = 0, last2Y = 0;
+	static int lastY = 0, last2Y = 0, fastScroll = 0;
 	int selection = 0;
 
 	switch (state)
@@ -617,6 +617,9 @@
 			mUpdate = 1;
 		startY = lastY = last2Y = y;
 		scrollingSpeed = 0;
+
+		if(mFastScrollRectX != -1 && x >= mRenderX + mRenderW - mFastScrollW)
+			fastScroll = 1;
 		break;
 
 	case TOUCH_DRAG:
@@ -631,7 +634,7 @@
 		}
 
 		// Fast scroll
-		if(mFastScrollRectX != -1 && x >= mRenderX + mRenderW - mFastScrollW)
+		if(fastScroll)
 		{
 			int pct = ((y-mRenderY-mHeaderH)*100)/(mRenderH-mHeaderH);
 			int totalSize = mList.size();
@@ -705,6 +708,7 @@
 
 	case TOUCH_RELEASE:
 		isHighlighted = false;
+		fastScroll = 0;
 		if (startSelection >= 0)
 		{
 			// We've selected an item!
diff --git a/minuitwrp/graphics.c b/minuitwrp/graphics.c
index fc34b6b..99f5841 100644
--- a/minuitwrp/graphics.c
+++ b/minuitwrp/graphics.c
@@ -69,6 +69,7 @@
 static GGLSurface gr_mem_surface;
 static unsigned gr_active_fb = 0;
 static unsigned double_buffering = 0;
+static int gr_is_curr_clr_opaque = 0;
 
 static int gr_fb_fd = -1;
 static int gr_vt_fd = -1;
@@ -288,6 +289,8 @@
     color[2] = ((b << 8) | b) + 1;
     color[3] = ((a << 8) | a) + 1;
     gl->color4xv(gl, color);
+
+    gr_is_curr_clr_opaque = (a == 255);
 }
 
 int gr_measureEx(const char *s, void* font)
@@ -463,8 +466,15 @@
 void gr_fill(int x, int y, int w, int h)
 {
     GGLContext *gl = gr_context;
+
+    if(gr_is_curr_clr_opaque)
+        gl->disable(gl, GGL_BLEND);
+
     gl->disable(gl, GGL_TEXTURE_2D);
     gl->recti(gl, x, y, x + w, y + h);
+
+    if(gr_is_curr_clr_opaque)
+        gl->enable(gl, GGL_BLEND);
 }
 
 void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy) {
diff --git a/partition.cpp b/partition.cpp
index b79e774..95f6bca 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -361,10 +361,6 @@
 			Is_Storage = true;
 			Removable = true;
 			Wipe_Available_in_GUI = true;
-#ifndef RECOVERY_SDCARD_ON_DATA
-			Setup_AndSec();
-			Mount_Storage_Retry();
-#endif
 #endif
 		}
 #ifdef TW_INTERNAL_STORAGE_PATH
@@ -373,20 +369,12 @@
 			Is_Settings_Storage = true;
 			Storage_Path = EXPAND(TW_INTERNAL_STORAGE_PATH);
 			Wipe_Available_in_GUI = true;
-#ifndef RECOVERY_SDCARD_ON_DATA
-			Setup_AndSec();
-			Mount_Storage_Retry();
-#endif
 		}
 #else
 		if (Mount_Point == "/emmc" || Mount_Point == "/internal_sd" || Mount_Point == "/internal_sdcard") {
 			Is_Storage = true;
 			Is_Settings_Storage = true;
 			Wipe_Available_in_GUI = true;
-#ifndef RECOVERY_SDCARD_ON_DATA
-			Setup_AndSec();
-			Mount_Storage_Retry();
-#endif
 		}
 #endif
 	} else if (Is_Image(Fstab_File_System)) {
@@ -663,6 +651,7 @@
 	Backup_Path = Symlink_Mount_Point;
 	Make_Dir("/and-sec", true);
 	Recreate_AndSec_Folder();
+	Mount_Storage_Retry();
 }
 
 void TWPartition::Find_Real_Block_Device(string& Block, bool Display_Error) {
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 091ae32..04dbee9 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -96,6 +96,9 @@
 		for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
 			if ((*iter)->Is_Storage) {
 				(*iter)->Is_Settings_Storage = true;
+#ifndef RECOVERY_SDCARD_ON_DATA
+				(*iter)->Setup_AndSec();
+#endif
 				Found_Settings_Storage = true;
 				DataManager::SetValue("tw_settings_path", (*iter)->Storage_Path);
 				DataManager::SetValue("tw_storage_path", (*iter)->Storage_Path);