Permalink
Browse files

Fixed thumbnail sizing problems

  • Loading branch information...
Deepwinter
Deepwinter committed Apr 13, 2012
1 parent 7c8d062 commit 35fe052d073f1b921352c39e58b2d48b86f68f1f
View
@@ -4,3 +4,4 @@ Couchbase/
*.DS_Store*
.metadata
src/net/winterroot/android/rhus/configuration/
+gen
@@ -54,6 +54,7 @@
}
public static final class id {
public static final int RelativeLayout2=0x7f050016;
+ public static final int backer_button=0x7f050014;
public static final int cameraButton=0x7f050012;
public static final int cancel_button=0x7f05001c;
public static final int closeDocumentDetail=0x7f050006;
@@ -68,7 +69,6 @@
public static final int fruit=0x7f050024;
public static final int gallery=0x7f050005;
public static final int icomposite=0x7f050022;
- public static final int imageButton1=0x7f050014;
public static final int imageView1=0x7f050000;
public static final int infoButton=0x7f05000f;
public static final int infoView=0x7f050007;
@@ -108,6 +108,7 @@
RelativeLayout mapOptionsBaloon;
boolean mapOptionsShowing = false;
boolean updatingMapPoints = false;
+ boolean lockInterface = false;
private class OverlayDelegate extends RhusMapItemizedOverlayDelegate{
@@ -266,6 +267,10 @@ public void onCreate(Bundle savedState) {
((ImageButton) findViewById(R.id.cameraButton)).setOnClickListener(
new OnClickListener(){
public void onClick(View arg0) {
+ if(lockInterface){
+ return;
+ }
+
//Check that we have a geo-fix
if(lastLocation == null){
Toast.makeText( getBaseContext(), "You do not currently have a geo-fix. Please make sure your phone can 'see' the GPS satellites (make sure you are outside) and retry.", Toast.LENGTH_SHORT ).show();
@@ -287,6 +292,7 @@ public void onClick(View arg0) {
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
captureTime = new Date().getTime();
+ lockInterface = true;
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
}
@@ -335,6 +341,16 @@ public void onClick(View arg0){
}
}
);
+
+ ( (ImageButton) findViewById(R.id.backer_button)).setOnClickListener(
+ new OnClickListener(){
+ public void onClick(View arg0) {
+ Intent intent = new Intent("net.winterroot.android.wildflowers.BACKER_LIST");
+ startActivity(intent);
+
+ }
+ }
+ );
( (ImageButton) noteBaloon.findViewById(R.id.close_button)).setOnClickListener(
new OnClickListener(){
@@ -618,7 +634,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Location loc = lastLocation;
if(loc == null){
- Log.i(TAG, "Lst known location returned NULL, not saving this datapoint");
+ Log.i(TAG, "Last known location returned NULL, not saving this datapoint");
//TODO: Handle this exception somehow, probably by kicking them to a map where they can enter their location manually
//or allowing them to try to get a geofix again.
//return;
@@ -682,6 +698,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
getContentResolver().insert(RhusDocument.CONTENT_URI, values);
+
/*TODO: Skipping for now
Intent intent = new Intent("net.winterroot.android.rhus.action.SUBMITFORM");
startActivity(intent);
@@ -694,6 +711,8 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Toast.makeText(this, "Picture was not taken", Toast.LENGTH_SHORT);
}
}
+ lockInterface = false;
+
}
@@ -57,7 +57,9 @@ public static Bitmap resizeBitMapImage1(String filePath, int targetWidth,
double sampleSize = 0;
// Only scale if we need to
// (16384 buffer for img processing)
- Boolean scaleByHeight = Math.abs(options.outHeight - targetHeight) >= Math
+
+ //Switched inequality to scale by opposite dimension
+ Boolean scaleByHeight = Math.abs(options.outHeight - targetHeight) <= Math
.abs(options.outWidth - targetWidth);
@@ -82,8 +84,7 @@ public static Bitmap resizeBitMapImage1(String filePath, int targetWidth,
matrix.postRotate(orientation);
bitMapImage = Bitmap.createBitmap(bitMapImage, 0, 0, bitMapImage.getWidth(),
- bitMapImage.getHeight(), matrix, true);
-
+ bitMapImage.getHeight(), matrix, true);
}
break;
@@ -96,6 +97,27 @@ public static Bitmap resizeBitMapImage1(String filePath, int targetWidth,
}
}
+ //and crop
+ int originx = 0;
+ int originy = 0;
+ int width = bitMapImage.getWidth() ;
+ int height = bitMapImage.getHeight() ;
+ int ratio = targetWidth / targetHeight;
+ int reverseRatio = targetHeight / targetWidth;
+ //use smaller dimension
+ if(width > height){
+ targetHeight = height;
+ targetWidth = targetHeight * ratio;
+ } else {
+ targetWidth = width;
+ targetHeight = targetWidth * reverseRatio;
+ }
+
+ originx = (bitMapImage.getWidth() - targetWidth) / 2;
+ originy = (bitMapImage.getHeight() - targetHeight) / 2;
+ bitMapImage = Bitmap.createBitmap(bitMapImage, originx, originy, targetWidth, targetHeight);
+
+
return bitMapImage;
}
@@ -1,22 +0,0 @@
-/*
-package net.winterroot.android.wildflowers;
-
-import android.database.Cursor;
-import android.os.Bundle;
-import android.util.Log;
-import net.winterroot.android.rhus.RhusActivity;
-import net.winterroot.android.rhus.provider.RhusDocument;
-
-
-public class WildflowersActivity extends RhusActivity {
-
- public static String TAG = "Wildflowers";
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
-
-
-}
-*/

0 comments on commit 35fe052

Please sign in to comment.