package com.aragaer.jtt.wadokei;

import android.content.Context;
import android.util.TypedValue;
import android.widget.TextView;

public class AutoresizeTextView extends TextView {
	public AutoresizeTextView(Context context) {
		super(context);
	}

	protected void onMeasure(int wms, int hms) {
		super.onMeasure(wms, hms);
		float measured_width = getPaint().measureText(getText().toString());
		int allowed = MeasureSpec.getSize(wms);
		if (measured_width > allowed) {
			setTextSize(TypedValue.COMPLEX_UNIT_PX, (getTextSize() * allowed)
					/ measured_width);
			super.onMeasure(wms, hms);
		}
	}
}

@@ -1,8 +1,107 @@
+// -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; -*-%0A// vim: et ts=4 sts=4 sw=4 syntax=java%0A
 package 
@@ -274,17 +274,20 @@
 tView %7B%0A
-%09
+    
 public A
@@ -319,26 +319,32 @@
  context) %7B%0A
-%09%09
+        
 super(contex
@@ -351,13 +351,19 @@
 t);%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 prot
@@ -403,18 +403,24 @@
  hms) %7B%0A
-%09%09
+        
 super.on
@@ -438,18 +438,24 @@
 , hms);%0A
-%09%09
+        
 float me
@@ -515,18 +515,24 @@
 ing());%0A
-%09%09
+        
 int allo
@@ -563,18 +563,24 @@
 e(wms);%0A
-%09%09
+        
 if (meas
@@ -603,19 +603,28 @@
 owed) %7B%0A
-%09%09%09
+            
 setTextS
@@ -685,13 +685,32 @@
 ed)%0A
-%09%09%09%09%09
+                        
 / me
@@ -728,11 +728,20 @@
 h);%0A
-%09%09%09
+            
 supe
@@ -767,13 +767,22 @@
 s);%0A
-%09%09%7D%0A%09
+        %7D%0A    
 %7D%0A%7D%0A

Fix AutoresizeTextView formatting