mirror of
				https://github.com/SimpleMobileTools/Simple-Gallery.git
				synced 2025-06-05 21:59:19 +02:00 
			
		
		
		
	move Undo button to the top
This commit is contained in:
		| @@ -6,6 +6,7 @@ import android.content.pm.PackageManager; | ||||
| import android.content.res.Resources; | ||||
| import android.support.v4.content.ContextCompat; | ||||
| import android.support.v7.app.ActionBar; | ||||
| import android.util.TypedValue; | ||||
| import android.view.View; | ||||
| import android.view.Window; | ||||
| import android.widget.Toast; | ||||
| @@ -19,12 +20,28 @@ public class Utils { | ||||
|         Toast.makeText(context, context.getResources().getString(resId), Toast.LENGTH_SHORT).show(); | ||||
|     } | ||||
|  | ||||
|     public static int getActionBarHeight(Context context, Resources res) { | ||||
|         final TypedValue tv = new TypedValue(); | ||||
|         int height = 0; | ||||
|         if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { | ||||
|             height = TypedValue.complexToDimensionPixelSize(tv.data, res.getDisplayMetrics()); | ||||
|         } | ||||
|         return height; | ||||
|     } | ||||
|  | ||||
|     public static int getStatusBarHeight(Resources res) { | ||||
|         int id = res.getIdentifier("status_bar_height", "dimen", "android"); | ||||
|         if (id > 0) { | ||||
|             return res.getDimensionPixelSize(id); | ||||
|         } | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
|     public static int getNavBarHeight(Resources res) { | ||||
|         int id = res.getIdentifier("navigation_bar_height", "dimen", "android"); | ||||
|         if (id > 0) { | ||||
|             return res.getDimensionPixelSize(id); | ||||
|         } | ||||
|  | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -343,18 +343,15 @@ public class ViewPagerActivity extends AppCompatActivity | ||||
|  | ||||
|     private void addUndoMargin() { | ||||
|         final Resources res = getResources(); | ||||
|         final int height = Utils.getNavBarHeight(res); | ||||
|         final RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) undoBtn.getLayoutParams(); | ||||
|         final int topMargin = Utils.getStatusBarHeight(res) + Utils.getActionBarHeight(getApplicationContext(), res); | ||||
|         int rightMargin = params.rightMargin; | ||||
|         int bottomMargin = params.bottomMargin; | ||||
|  | ||||
|         if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { | ||||
|             bottomMargin = height; | ||||
|         } else { | ||||
|             rightMargin = height; | ||||
|         if (getResources().getConfiguration().orientation != Configuration.ORIENTATION_PORTRAIT) { | ||||
|             rightMargin += Utils.getNavBarHeight(res); | ||||
|         } | ||||
|  | ||||
|         params.setMargins(params.leftMargin, params.topMargin, rightMargin, bottomMargin); | ||||
|         params.setMargins(params.leftMargin, topMargin, rightMargin, params.bottomMargin); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -13,10 +13,10 @@ | ||||
|  | ||||
|     <ImageView | ||||
|         android:id="@+id/undo_delete" | ||||
|         android:layout_width="64dp" | ||||
|         android:layout_height="64dp" | ||||
|         android:layout_alignParentBottom="true" | ||||
|         android:layout_width="56dp" | ||||
|         android:layout_height="56dp" | ||||
|         android:layout_alignParentRight="true" | ||||
|         android:layout_alignParentTop="true" | ||||
|         android:padding="@dimen/undo_padding" | ||||
|         android:src="@mipmap/undo" | ||||
|         android:visibility="gone"/> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user