diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 238aeb3..64d128c 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -12,8 +12,10 @@
+
-
+
+
@@ -73,23 +75,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -102,7 +88,7 @@
-
+
@@ -123,10 +109,14 @@
-
+
-
-
+
+
+
+
+
+
@@ -147,10 +137,13 @@
-
+
-
-
+
+
+
+
+
@@ -159,7 +152,7 @@
-
+
@@ -595,11 +588,11 @@
+
+
-
-
@@ -607,7 +600,7 @@
-
+
@@ -764,6 +757,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1142,7 +1165,7 @@
-
+
@@ -1151,13 +1174,13 @@
-
+
-
+
@@ -1197,7 +1220,7 @@
-
+
@@ -1229,7 +1252,7 @@
-
+
@@ -1261,7 +1284,7 @@
-
+
@@ -1476,17 +1499,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -1497,16 +1509,9 @@
-
-
-
-
-
-
-
-
+
-
+
@@ -1520,44 +1525,67 @@
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
-
-
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
+
+
+
+
+
-
+
diff --git a/gallery4glass/src/main/java/com/w9jds/gallery4glass/MainActivity.java b/gallery4glass/src/main/java/com/w9jds/gallery4glass/MainActivity.java
index 4fadd4f..a66aef2 100644
--- a/gallery4glass/src/main/java/com/w9jds/gallery4glass/MainActivity.java
+++ b/gallery4glass/src/main/java/com/w9jds/gallery4glass/MainActivity.java
@@ -146,30 +146,6 @@ protected void onPause()
super.onPause();
}
- /***
- * Sort the file paths so that the images are in order from most resent first
- */
-// private void sortPaths(ArrayList lsPaths)
-// {
-// ArrayList fPics = new ArrayList();
-//
-// for (String x : lsPaths)
-// fPics.add(new java.io.File(x));
-//
-// lsPaths.clear();
-//
-// Collections.sort(fPics, new Comparator(){
-// @Override
-// public int compare(java.io.File o1, java.io.File o2)
-// {
-// return Long.valueOf(o1.lastModified()).compareTo(o2.lastModified());
-// }
-// });
-//
-// for (java.io.File x : fPics)
-// lsPaths.add(x.getAbsolutePath());
-// }
-
public String getBucketId(String path)
{
return String.valueOf(path.toLowerCase().hashCode());
@@ -237,7 +213,7 @@ public boolean onOptionsItemSelected(android.view.MenuItem iItem)
//set the text as deleting
setContentView(R.layout.menu_layout);
((ImageView)findViewById(R.id.icon)).setImageResource(R.drawable.ic_delete_50);
- ((TextView)findViewById(R.id.label)).setText("Deleting");
+ ((TextView)findViewById(R.id.label)).setText(getString(R.string.deleting_label));
svProgress = (SliderView)findViewById(R.id.slider);
svProgress.startProgress(1000, new Animator.AnimatorListener()
@@ -265,7 +241,7 @@ public void onAnimationEnd(Animator animation)
setContentView(R.layout.menu_layout);
((ImageView)findViewById(R.id.icon)).setImageResource(R.drawable.ic_done_50);
- ((TextView)findViewById(R.id.label)).setText("Deleted");
+ ((TextView)findViewById(R.id.label)).setText(getString(R.string.deleted_label));
maManager.playSoundEffect(Sounds.SUCCESS);
@@ -327,7 +303,7 @@ public void onAnimationRepeat(Animator animation)
svProgress.startIndeterminate();
((ImageView)findViewById(R.id.icon)).setImageResource(R.drawable.ic_mobile_phone_50);
- ((TextView)findViewById(R.id.label)).setText("Uploading");
+ ((TextView)findViewById(R.id.label)).setText(getString(R.string.uploading_label));
String sContainer = "";
String[] saImage = mcpPaths.getCurrentPositionPath().split("/|\\.");
@@ -401,31 +377,22 @@ protected Boolean doInBackground(Void... params)
fisStream.read(byteArray);
// Post our image data (byte array) to the server
- Log.d("ImageUpload", "Byte Array Finished " + byteArray.length);
URL url = new URL(mUrl.replace("\"", ""));
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("PUT");
urlConnection.addRequestProperty("Content-Type", "image/jpeg");
urlConnection.setRequestProperty("Content-Length", ""+ byteArray.length);
- Log.d("ImageUpload", "Connection Created");
// Write image data to server
DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream());
wr.write(byteArray);
- Log.d("ImageUpload", "Writing of byte array finished.");
wr.flush();
wr.close();
- Log.d("ImageUpload", "DataOutputStream Closed");
int response = urlConnection.getResponseCode();
- Log.d("ImageUpload", "Got response code " + response);
urlConnection.disconnect();
- Log.d("ImageUpload", "Disconnected Connection");
//If we successfully uploaded, return true
if (response == 201 && urlConnection.getResponseMessage().equals("Created"))
- {
- Log.d("ImageUpload", "Image uploaded");
return true;
- }
}
@@ -441,10 +408,9 @@ protected void onPostExecute(Boolean uploaded)
{
if (uploaded)
{
-
setContentView(R.layout.menu_layout);
((ImageView)findViewById(R.id.icon)).setImageResource(R.drawable.ic_done_50);
- ((TextView)findViewById(R.id.label)).setText("Uploaded");
+ ((TextView)findViewById(R.id.label)).setText(getString(R.string.uploaded_label));
maManager.playSoundEffect(Sounds.SUCCESS);
}
diff --git a/gallery4glass/src/main/java/com/w9jds/gallery4glass/VignetteActivity.java b/gallery4glass/src/main/java/com/w9jds/gallery4glass/VignetteActivity.java
index fa8d8b3..4bff1a5 100644
--- a/gallery4glass/src/main/java/com/w9jds/gallery4glass/VignetteActivity.java
+++ b/gallery4glass/src/main/java/com/w9jds/gallery4glass/VignetteActivity.java
@@ -20,6 +20,7 @@
import android.speech.RecognizerIntent;
import android.util.Log;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.TextView;
@@ -94,7 +95,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data)
//set the icon to the vignette icon
((ImageView)findViewById(R.id.icon)).setImageResource(R.drawable.ic_vignette_medium);
//and set the label
- ((TextView)findViewById(R.id.label)).setText("Making Vignette");
+ ((TextView)findViewById(R.id.label)).setText(getString(R.string.making_vignette_label));
//make sure it has the slider view in it
SliderView svProgress = (SliderView)findViewById(R.id.slider);
@@ -151,7 +152,7 @@ public void onItemClick(AdapterView> parent, View view, int position, long id)
//set the icon to the vignette icon
((ImageView)findViewById(R.id.icon)).setImageResource(R.drawable.ic_vignette_medium);
//and set the label
- ((TextView)findViewById(R.id.label)).setText("Making Vignette");
+ ((TextView)findViewById(R.id.label)).setText(getString(R.string.making_vignette_label));
//make sure it has the slider view in it
SliderView svProgress = (SliderView)findViewById(R.id.slider);
@@ -204,6 +205,7 @@ protected Boolean doInBackground(Void... params)
Bitmap bitWhole = Bitmap.createBitmap(sWhole.Width, sWhole.Height, Bitmap.Config.ARGB_8888);
Canvas cBuild = new Canvas(bitWhole);
+ //calculate the position to start into the top of the image so that the aspect ratio is preserved
int i = (int)((sWhole.Height - bitMain.getHeight() * sWhole.Width / bitMain.getWidth()) / 2.0F);
cBuild.drawBitmap(bitMain, null, new Rect(0, i, sWhole.Width, sWhole.Height - i), SCALE_PAINT);
@@ -212,19 +214,18 @@ protected Boolean doInBackground(Void... params)
//if user selected the text option
if (miVignettePosition == 1)
+ {
+ //resize the bitmap to 640 x 360
+ Bitmap bView = resizeBitmap(loadBitmapFromView());
+
//turn the view into a bitmap and draw it in the top right hand corner
- cBuild.drawBitmap(loadBitmapFromView(), null, new Rect(Math.round(SCREEN_POSITION.left * sWhole.Width), Math.round(SCREEN_POSITION.top * sWhole.Height), Math.round(SCREEN_POSITION.right * sWhole.Width), Math.round(SCREEN_POSITION.bottom * sWhole.Height)), SCREEN_PAINT);
+ cBuild.drawBitmap(bView, null, new Rect(Math.round(SCREEN_POSITION.left * sWhole.Width), Math.round(SCREEN_POSITION.top * sWhole.Height), Math.round(SCREEN_POSITION.right * sWhole.Width), Math.round(SCREEN_POSITION.bottom * sWhole.Height)), SCREEN_PAINT);
+ }
//otherwise
else
{
- Bitmap bVig = BitmapFactory.decodeFile(mcpPaths.getImagePathsIndex(miVignettePosition));
-
- Bitmap bMini = Bitmap.createBitmap(640, 360, Bitmap.Config.ARGB_8888);
- Canvas cMini = new Canvas(bMini);
-
- i = (int)((360 - bVig.getHeight() * 640 / bVig.getWidth()) / 2.0F);
-
- cMini.drawBitmap(bVig, null, new Rect(0, i, 640, 360 - i), SCALE_PAINT);
+ //resize the bitmap to 640 x 360
+ Bitmap bMini = resizeBitmap(BitmapFactory.decodeFile(mcpPaths.getImagePathsIndex(miVignettePosition)));
//take the second image and draw it in the top right hand corner
cBuild.drawBitmap(bMini, null, new Rect(Math.round(SCREEN_POSITION.left * sWhole.Width), Math.round(SCREEN_POSITION.top * sWhole.Height), Math.round(SCREEN_POSITION.right * sWhole.Width), Math.round(SCREEN_POSITION.bottom * sWhole.Height)), SCREEN_PAINT);
@@ -260,51 +261,49 @@ protected Boolean doInBackground(Void... params)
return false;
}
+ public Bitmap resizeBitmap(Bitmap bVig)
+ {
+ //make a new bitmap for the aspect ratio resize
+ Bitmap bMini = Bitmap.createBitmap(640, 360, Bitmap.Config.ARGB_8888);
+ Canvas cMini = new Canvas(bMini);
+
+ //calculate the position to start into the top of the image so that the aspect ratio is preserved
+ int i = (int)((360 - bVig.getHeight() * 640 / bVig.getWidth()) / 2.0F);
+ //draw the new version of this image
+ cMini.drawBitmap(bVig, null, new Rect(0, i, 640, 360 - i), SCALE_PAINT);
+
+ return bMini;
+ }
+
public Bitmap loadBitmapFromView()
{
+ //create a new card and place the input text in it
Card txtCard = new Card(mcContext);
txtCard.setText(msSpoken);
+ //change the card into a view
View vCard = txtCard.toView();
- Bitmap bView = Bitmap.createBitmap(vCard.getWidth(), vCard.getHeight(), Bitmap.Config.RGB_565);
+ //get the measurements for the view (since it hasn't been displayed)
+ vCard.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+ //create a new bitmap matching the size of the view
+ Bitmap bView = Bitmap.createBitmap(vCard.getMeasuredWidth(), vCard.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
+ //create a new canvas for the bitmap
+ Canvas cView = new Canvas(bView);
+ //set up the layout for the view
+ vCard.layout(0, 0, vCard.getMeasuredWidth(), vCard.getMeasuredHeight());
+ //and draw it
+ vCard.draw(cView);
- vCard.draw(new Canvas(bView));
return bView;
}
- public int calculateInSampleSize(BitmapFactory.Options bfoOptions, int iReqWidth, int iReqHeight)
- {
- //pull out the images height
- final int height = bfoOptions.outHeight;
- //pull out the images width
- final int width = bfoOptions.outWidth;
- //set the samle size to 1 for initialization
- int inSampleSize = 1;
-
- //if te height or the width of the image is greater than the requested sizes
- if (height > iReqHeight || width > iReqWidth)
- {
- //set the half dimensions for the image
- final int iHalfHeight = height / 2;
- final int iHalfWidth = width / 2;
-
- //white both half dimensions divided by the sample size are still greater than the requested dimensions
- while ((iHalfHeight / inSampleSize) > iReqHeight && (iHalfWidth / inSampleSize) > iReqWidth)
- //multiply the sample size by 2
- inSampleSize *= 2;
- }
-
- //once the loop is done return the sample size
- return inSampleSize;
- }
-
@Override
protected void onPostExecute(Boolean uploaded)
{
setContentView(R.layout.menu_layout);
((ImageView)findViewById(R.id.icon)).setImageResource(R.drawable.ic_done_50);
- ((TextView)findViewById(R.id.label)).setText("Made Vignette");
+ ((TextView)findViewById(R.id.label)).setText(getString(R.string.made_vignette_label));
maManager.playSoundEffect(Sounds.SUCCESS);
diff --git a/gallery4glass/src/main/res/menu/main.xml b/gallery4glass/src/main/res/menu/main.xml
index 1ed39b8..fb07d57 100644
--- a/gallery4glass/src/main/res/menu/main.xml
+++ b/gallery4glass/src/main/res/menu/main.xml
@@ -17,12 +17,12 @@
-
+
-
- GlassShare
+ Gallery for Glass
+
Delete
Deleted
Deleting
- Push to Drive
- Upload Image
+
+ Push to Drive
+
+ Upload Image
+ Uploading
+ Uploaded
+
Make Vignette
+ Making Vignette
+ Made Vignette
4132500
@@ -15,9 +23,8 @@
Select what to use for the second image.
551585648263023
+
Pictures
VignetteActivity
- Hello world!
- Settings
\ No newline at end of file