| 
									
										
										
										
											2015-06-26 20:14:51 -07:00
										 |  |  | package org.thoughtcrime.securesms.components;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import android.annotation.TargetApi;
 | 
					
						
							|  |  |  | import android.content.Context;
 | 
					
						
							| 
									
										
										
										
											2016-11-25 22:37:23 -08:00
										 |  |  | import android.content.res.TypedArray;
 | 
					
						
							|  |  |  | import android.graphics.BitmapFactory;
 | 
					
						
							| 
									
										
										
										
											2015-06-26 20:14:51 -07:00
										 |  |  | import android.os.Build.VERSION_CODES;
 | 
					
						
							|  |  |  | import android.util.AttributeSet;
 | 
					
						
							|  |  |  | import android.widget.FrameLayout;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-25 22:37:23 -08:00
										 |  |  | import org.thoughtcrime.securesms.R;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-26 20:14:51 -07:00
										 |  |  | public class SquareFrameLayout extends FrameLayout {
 | 
					
						
							| 
									
										
										
										
											2016-11-25 22:37:23 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   private final boolean squareHeight;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-26 20:14:51 -07:00
										 |  |  |   @SuppressWarnings("unused")
 | 
					
						
							|  |  |  |   public SquareFrameLayout(Context context) {
 | 
					
						
							| 
									
										
										
										
											2016-11-25 22:37:23 -08:00
										 |  |  |     this(context, null);
 | 
					
						
							| 
									
										
										
										
											2015-06-26 20:14:51 -07:00
										 |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @SuppressWarnings("unused")
 | 
					
						
							|  |  |  |   public SquareFrameLayout(Context context, AttributeSet attrs) {
 | 
					
						
							| 
									
										
										
										
											2016-11-25 22:37:23 -08:00
										 |  |  |     this(context, attrs, 0);
 | 
					
						
							| 
									
										
										
										
											2015-06-26 20:14:51 -07:00
										 |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @TargetApi(VERSION_CODES.HONEYCOMB) @SuppressWarnings("unused")
 | 
					
						
							|  |  |  |   public SquareFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
 | 
					
						
							|  |  |  |     super(context, attrs, defStyleAttr);
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-25 22:37:23 -08:00
										 |  |  |     if (attrs != null) {
 | 
					
						
							|  |  |  |       TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.SquareFrameLayout, 0, 0);
 | 
					
						
							|  |  |  |       this.squareHeight = typedArray.getBoolean(R.styleable.SquareFrameLayout_square_height, false);
 | 
					
						
							|  |  |  |       typedArray.recycle();
 | 
					
						
							|  |  |  |     } else {
 | 
					
						
							|  |  |  |       this.squareHeight = false;
 | 
					
						
							|  |  |  |     }
 | 
					
						
							| 
									
										
										
										
											2015-06-26 20:14:51 -07:00
										 |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @Override
 | 
					
						
							|  |  |  |   protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
 | 
					
						
							|  |  |  |     //noinspection SuspiciousNameCombination
 | 
					
						
							| 
									
										
										
										
											2016-11-25 22:37:23 -08:00
										 |  |  |     if (squareHeight) super.onMeasure(heightMeasureSpec, heightMeasureSpec);
 | 
					
						
							|  |  |  |     else              super.onMeasure(widthMeasureSpec, widthMeasureSpec);
 | 
					
						
							| 
									
										
										
										
											2015-06-26 20:14:51 -07:00
										 |  |  |   }
 | 
					
						
							|  |  |  | }
 |