From 8ff47c20051e4be9b947fea2c0e36819752168a1 Mon Sep 17 00:00:00 2001 From: MadelynTav Date: Tue, 9 Jun 2015 15:57:55 -0400 Subject: [PATCH 01/10] Homework Submission --- app/src/main/AndroidManifest.xml | 21 +- .../c4q/nyc/meme_project/ChooseMemeStyle.java | 10 +- .../DemotivationalMemeActivity.java | 194 ++++++--------- .../c4q/nyc/meme_project/SplashScreen.java | 4 +- .../c4q/nyc/meme_project/VanillaMeme.java | 225 ++++++++---------- .../meme5/c4q/nyc/meme_project/add_text.java | 108 --------- .../res/layout-land/activity_add_text.xml | 112 --------- .../activity_choose_meme_style.xml | 142 ----------- .../main/res/layout-land/activity_main.xml | 130 ---------- .../res/layout-land/activity_vanilla_meme.xml | 99 -------- app/src/main/res/layout/activity_add_text.xml | 100 -------- .../layout/activity_demotivational_meme.xml | 83 ++++--- app/src/main/res/layout/activity_main.xml | 23 +- .../main/res/layout/activity_vanilla_meme.xml | 129 +++++++--- 14 files changed, 348 insertions(+), 1032 deletions(-) delete mode 100644 app/src/main/java/meme5/c4q/nyc/meme_project/add_text.java delete mode 100644 app/src/main/res/layout-land/activity_add_text.xml delete mode 100644 app/src/main/res/layout-land/activity_choose_meme_style.xml delete mode 100644 app/src/main/res/layout-land/activity_main.xml delete mode 100644 app/src/main/res/layout-land/activity_vanilla_meme.xml delete mode 100644 app/src/main/res/layout/activity_add_text.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3939b4f..5b68858 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -14,34 +14,41 @@ android:largeHeap="true"> + android:label="@string/app_name" + android:screenOrientation="portrait" + > + + android:label="@string/title_activity_choose_meme_style" + android:screenOrientation="portrait"> + android:label="@string/title_activity_vanilla_test" + android:screenOrientation="portrait"> + android:label="@string/title_activity_add_text" + android:screenOrientation="portrait"> + android:label="@string/title_activity_demotivational_meme" + android:screenOrientation="portrait"> + android:label="@string/title_activity_splash_screen" + android:screenOrientation="portrait"> - diff --git a/app/src/main/java/meme5/c4q/nyc/meme_project/ChooseMemeStyle.java b/app/src/main/java/meme5/c4q/nyc/meme_project/ChooseMemeStyle.java index e89f9ae..e4d99a2 100644 --- a/app/src/main/java/meme5/c4q/nyc/meme_project/ChooseMemeStyle.java +++ b/app/src/main/java/meme5/c4q/nyc/meme_project/ChooseMemeStyle.java @@ -25,8 +25,7 @@ public class ChooseMemeStyle extends Activity { public static final String TAG = "MEME_ACTIVITY"; - protected RadioGroup styleGroup; - protected RadioButton styleButton; + Button small, medium, large; protected Button nextButton; protected boolean vanilla; protected Random slideShow; @@ -55,7 +54,10 @@ protected void onCreate(Bundle savedInstanceState) { TextView step2 = (TextView) findViewById(R.id.step2); TextView step3 = (TextView) findViewById(R.id.step3); TextView title = (TextView) findViewById(R.id.title); - TextView vanillaRadio = (TextView) findViewById(R.id.chooseVanilla); + small=(Button) findViewById(R.id.small); + medium=(Button) findViewById(R.id.medium); + large=(Button) findViewById(R.id.large); + TextView demotivationalRadio = (TextView) findViewById(R.id.chooseDemotivational); Typeface tf = Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/ubuntu.ttf"); @@ -63,7 +65,7 @@ protected void onCreate(Bundle savedInstanceState) { step2.setTypeface(tf); step3.setTypeface(tf); title.setTypeface(tf); - vanillaRadio.setTypeface(tf); + demotivationalRadio.setTypeface(tf); RadioGroup group = (RadioGroup) findViewById(R.id.styleGroup); diff --git a/app/src/main/java/meme5/c4q/nyc/meme_project/DemotivationalMemeActivity.java b/app/src/main/java/meme5/c4q/nyc/meme_project/DemotivationalMemeActivity.java index 0f8ad99..4b3d872 100644 --- a/app/src/main/java/meme5/c4q/nyc/meme_project/DemotivationalMemeActivity.java +++ b/app/src/main/java/meme5/c4q/nyc/meme_project/DemotivationalMemeActivity.java @@ -9,24 +9,39 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; +import android.graphics.Typeface; +import android.graphics.drawable.Drawable; +import android.net.Uri; import android.os.Bundle; +import android.os.Environment; +import android.provider.MediaStore; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; +import android.widget.Toast; +import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; /** * Created by c4q-anthonyf on 6/5/15. */ public class DemotivationalMemeActivity extends Activity { - Bitmap image; - Bitmap memeImage; - ImageView preview; - EditText largeText; - EditText smallText; + ImageView image; + EditText line1; + EditText line2; + Bitmap bmp2; + String imgFilePath; + Button share; + Button save; + RelativeLayout memeLayout; + @Override @@ -34,139 +49,70 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_demotivational_meme); - preview = (ImageView) findViewById(R.id.preview); - String imgFilePath = ""; + //get image path from previous activity Bundle bundle = getIntent().getExtras(); - if(bundle.getString("imgFilePath") != null) - { - imgFilePath = bundle.getString("imgFilePath"); - decodeFile(imgFilePath); - } - - largeText = (EditText) findViewById(R.id.large); - smallText = (EditText) findViewById(R.id.small); - Button previewText = (Button) findViewById(R.id.previewText); - previewText.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - memeImage = drawTextToBitmap(image.copy(image.getConfig(),true),largeText.getText().toString(),true); - memeImage = drawTextToBitmap(memeImage,smallText.getText().toString(),false); - preview.setImageBitmap(memeImage); - } - }); - } - public void launchLastActivity(View view){ - - if(memeImage != null) { - try { - //Write file - String filename = "meme.png"; - FileOutputStream stream = this.openFileOutput(filename, Context.MODE_PRIVATE); - memeImage.compress(Bitmap.CompressFormat.PNG, 100, stream); - - //Cleanup - stream.close(); - memeImage.recycle(); - - //Pop intent - Intent lastActivity = new Intent(this, add_text.class); - lastActivity.putExtra("memeImage", filename); - startActivity(lastActivity); - } catch (Exception e) { - e.printStackTrace(); + try { + if (bundle.getString("imgFilePath") != null) { + imgFilePath = bundle.getString("imgFilePath"); + image = (ImageView) findViewById(R.id.image); + bmp2 = BitmapFactory.decodeFile(imgFilePath); + image.setImageBitmap(bmp2); } + } catch (NullPointerException e) { + Toast.makeText(this, "No Image Found", Toast.LENGTH_LONG).show(); } - } - private Bitmap addBorder(Bitmap bmp,int color, int borderSize) { - return addBorder(bmp, color,borderSize, borderSize, borderSize, borderSize); + save = (Button) findViewById(R.id.saveButton); + share = (Button) findViewById(R.id.shareButton); + line1 = (EditText) findViewById(R.id.title); + line2 = (EditText) findViewById(R.id.description); + image = (ImageView) findViewById(R.id.image); + memeLayout = (RelativeLayout) findViewById(R.id.memeLayout); } - private Bitmap addBorder(Bitmap bmp, int color, int left, int top, int right, int bottom){ - Bitmap bmpWithBorder = Bitmap.createBitmap(bmp.getWidth() + left + right, bmp.getHeight() + top + bottom, bmp.getConfig()); - Canvas canvas = new Canvas(bmpWithBorder); - canvas.drawColor(color); - canvas.drawBitmap(bmp, left, top, null); - - return bmpWithBorder; + //Method to create a bitmap from a view, in our case from a linearLayout + public Bitmap getBitmapFromView(View view) { + Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(returnedBitmap); + + Drawable bgDrawable = view.getBackground(); + if (bgDrawable != null) + bgDrawable.draw(canvas); + else + canvas.drawColor(Color.WHITE); + view.draw(canvas); + return returnedBitmap; } - private void decodeFile(String filePath) { - - // Decode image size - BitmapFactory.Options o = new BitmapFactory.Options(); - o.inJustDecodeBounds = true; - BitmapFactory.decodeFile(filePath, o); - - // The new size we want to scale to - final int REQUIRED_SIZE = 1024; - - // Find the correct scale value. It should be the power of 2. - int width_tmp = o.outWidth, height_tmp = o.outHeight; - int scale = 1; - while (true) { - if (width_tmp < REQUIRED_SIZE && height_tmp < REQUIRED_SIZE) - break; - width_tmp /= 2; - height_tmp /= 2; - scale *= 2; - } - - // Decode with inSampleSize - BitmapFactory.Options o2 = new BitmapFactory.Options(); - o2.inSampleSize = scale; - Bitmap b1 = BitmapFactory.decodeFile(filePath, o2); - image= ExifUtils.rotateBitmap(filePath, b1); + //Method to share the meme + public void sharingM(View view) { - image = addBorder(image, Color.BLACK, 5); - image = addBorder(image,Color.WHITE, 5); - image = addBorder(image, Color.BLACK, 100, 150, 100, 300); - preview.setImageBitmap(image); - } + bmp2 = getBitmapFromView(memeLayout); - public Bitmap drawTextToBitmap(Bitmap bitmapImage, String mText1, boolean largeText) { + Intent share = new Intent(Intent.ACTION_SEND); + share.setType("image/jpeg"); + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + bmp2.compress(Bitmap.CompressFormat.JPEG, 100, bytes); + File f = new File(Environment.getExternalStorageDirectory() + File.separator + "temporary_file.jpg"); try { - - Canvas newCanvas = new Canvas(bitmapImage); - - newCanvas.drawBitmap(bitmapImage, 0, 0, null); - int textSize; - int heightOffset; - if(largeText) { - textSize = 80; - heightOffset = 30; - mText1 = mText1.toUpperCase(); - }else{ - textSize = 40; - heightOffset = 140; - } - - if(mText1 != null) { - - Paint paintText = new Paint(Paint.ANTI_ALIAS_FLAG); - paintText.setColor(Color.WHITE); - paintText.setTextSize(textSize); - paintText.setStyle(Paint.Style.FILL); - paintText.setShadowLayer(10f, 10f, 10f, Color.BLACK); - - Rect rectText = new Rect(); - paintText.getTextBounds(mText1, 0, mText1.length(), rectText); - - newCanvas.drawText(mText1, - newCanvas.getWidth() /2 - rectText.width() /2, newCanvas.getHeight() - 299 + rectText.height() + heightOffset, paintText); - } - - return bitmapImage; - } catch (Exception e) { - // TODO: handle exception - - - return null; + f.createNewFile(); + FileOutputStream fo = new FileOutputStream(f); + fo.write(bytes.toByteArray()); + } catch (IOException e) { + e.printStackTrace(); } - + share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/temporary_file.jpg")); + startActivity(Intent.createChooser(share, "Share Image")); } + //Method to Save the Meme into the camera roll + public void savingM(View view) { + bmp2 = getBitmapFromView(memeLayout); + + MediaStore.Images.Media.insertImage(DemotivationalMemeActivity.this.getContentResolver(), bmp2, "title.jpg", "some description"); + Toast.makeText(this, "Meme saved!", Toast.LENGTH_LONG).show(); + } -} +} \ No newline at end of file diff --git a/app/src/main/java/meme5/c4q/nyc/meme_project/SplashScreen.java b/app/src/main/java/meme5/c4q/nyc/meme_project/SplashScreen.java index 3d1beab..3f5a254 100644 --- a/app/src/main/java/meme5/c4q/nyc/meme_project/SplashScreen.java +++ b/app/src/main/java/meme5/c4q/nyc/meme_project/SplashScreen.java @@ -2,6 +2,7 @@ /** * Created by c4q-tashasmith on 6/7/15. + * This activity will display a screen when the app is initially opened for 2.5 seconds */ import android.app.Activity; import android.content.Intent; @@ -15,8 +16,9 @@ public class SplashScreen extends Activity { + /** Duration of wait **/ - private final int SPLASH_DISPLAY_LENGTH = 2500; + private final int SPLASH_DISPLAY_LENGTH = 100;//Time which activity will be displayed for in ms ImageView img; AnimationDrawable frameAnimation; diff --git a/app/src/main/java/meme5/c4q/nyc/meme_project/VanillaMeme.java b/app/src/main/java/meme5/c4q/nyc/meme_project/VanillaMeme.java index b3ff942..e09d68c 100644 --- a/app/src/main/java/meme5/c4q/nyc/meme_project/VanillaMeme.java +++ b/app/src/main/java/meme5/c4q/nyc/meme_project/VanillaMeme.java @@ -10,7 +10,12 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.Typeface; +import android.graphics.drawable.Drawable; +import android.net.Uri; import android.os.Bundle; +import android.os.Environment; +import android.provider.ContactsContract; +import android.provider.MediaStore; import android.text.Layout; import android.text.StaticLayout; import android.text.TextPaint; @@ -19,184 +24,140 @@ import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.RadioButton; import android.widget.RadioGroup; +import android.widget.RelativeLayout; import android.widget.TextView; +import android.widget.Toast; import org.w3c.dom.Text; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.IOException; public class VanillaMeme extends Activity { ImageView image; EditText line1; - Bitmap bmp, bmp2; - String line1Text; + EditText line2; + Bitmap bmp2; String imgFilePath; - Button nextButton; TextView title; - RadioButton small, medium, large; + Button share; + Button save; + RelativeLayout memeLayout; + Button small, medium, large; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_vanilla_meme); + //get image path from previous activity Bundle bundle = getIntent().getExtras(); - if (bundle.getString("imgFilePath") != null) { - imgFilePath = bundle.getString("imgFilePath"); - decodeFile(imgFilePath); + + try { + if (bundle.getString("imgFilePath") != null) { + imgFilePath = bundle.getString("imgFilePath"); + image = (ImageView) findViewById(R.id.testImage); + bmp2 = BitmapFactory.decodeFile(imgFilePath); + image.setImageBitmap(bmp2); + } + } catch (NullPointerException e) { + Toast.makeText(this, "No Image Found", Toast.LENGTH_LONG).show(); } + + save = (Button) findViewById(R.id.saveButton); + share = (Button) findViewById(R.id.shareButton); line1 = (EditText) findViewById(R.id.top); + line2 = (EditText) findViewById(R.id.bottom); image = (ImageView) findViewById(R.id.testImage); - nextButton = (Button) findViewById(R.id.next); title = (TextView) findViewById(R.id.title); - small = (RadioButton) findViewById(R.id.small); - medium = (RadioButton) findViewById(R.id.medium); - large = (RadioButton) findViewById(R.id.large); + small = (Button) findViewById(R.id.small); + medium = (Button) findViewById(R.id.medium); + large = (Button) findViewById(R.id.large); + memeLayout = (RelativeLayout) findViewById(R.id.memeLayout); - //apply font + //apply Font Typeface Typeface tf = Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/ubuntu.ttf"); title.setTypeface(tf); small.setTypeface(tf); medium.setTypeface(tf); large.setTypeface(tf); line1.setTypeface(tf); - nextButton.setTypeface(tf); - - //create on check listener to see which size is chosen - RadioGroup group = (RadioGroup) findViewById(R.id.textSizes); - group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(RadioGroup radioGroup, int checkedId) { - - line1Text = line1.getText().toString(); - - switch (checkedId) { - case R.id.small: - bmp = drawTextToBitmap(bmp2, line1Text, 40, 2); - image.setImageBitmap(bmp); - break; - case R.id.medium: - bmp = drawTextToBitmap(bmp2, line1Text, 55, 3); - image.setImageBitmap(bmp); - break; - case R.id.large: - bmp = drawTextToBitmap(bmp2, line1Text, 80, 4); - image.setImageBitmap(bmp); - break; - } - } - }); + line2.setTypeface(tf); + + } - //method used to write text on image - public Bitmap drawTextToBitmap(Bitmap bitmap, String mText1, int textSize, int strokeSize) { - try { - android.graphics.Bitmap.Config bitmapConfig = bitmap.getConfig(); + //following three methods will change the font size for the textViews + public void textSizeSmall(View v) { + line1.setTextSize(15); + line2.setTextSize(15); + } - // set default bitmap config if none - if (bitmapConfig == null) { - bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888; - } - // resource bitmaps are imutable, - // so we need to convert it to mutable one - bitmap = bitmap.copy(bitmapConfig, true); - Canvas canvas = new Canvas(bitmap); - // new antialised Paint - TextPaint paint = new TextPaint(Paint.ANTI_ALIAS_FLAG); - paint.setColor(Color.rgb(255, 255, 255)); - // text size in pixels - paint.setTextSize(textSize); - // text shadow - paint.setShadowLayer(1f, 0f, 1f, Color.DKGRAY); - // make text font impact - Typeface tf = Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/impact.ttf"); - paint.setTypeface(tf); - paint.setTextAlign(Paint.Align.CENTER); - // center text - int xPos = (bitmap.getWidth() / 2) - 2; //-2 is for regulating the x position offset - - // create a static layout for word wrapping - StaticLayout mTextLayout = new StaticLayout(mText1, paint, canvas.getWidth(), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - canvas.translate(xPos, 10); //position the text - //draw text without stroke first - mTextLayout.draw(canvas); - - //set options on paint for stroke - paint.setColor(Color.BLACK); - paint.setStyle(Paint.Style.STROKE); - paint.setStrokeWidth(strokeSize); - - //then redraw text for stroke - mTextLayout.draw(canvas); - - return bitmap; - } catch (Exception e) { - // TODO: handle exception - - - return null; - } + public void textSizeMed(View v) { + line1.setTextSize(25); + line2.setTextSize(25); + } + public void textSizeLg(View v) { + line1.setTextSize(35); + line2.setTextSize(35); } - //method used to resize, rotate and set up bitmap - private void decodeFile(String filePath) { - - // Decode image size - BitmapFactory.Options o = new BitmapFactory.Options(); - o.inJustDecodeBounds = true; - BitmapFactory.decodeFile(filePath, o); - - // The new size we want to scale to - final int REQUIRED_SIZE = 1024; - - // Find the correct scale value. It should be the power of 2. - int width_tmp = o.outWidth, height_tmp = o.outHeight; - int scale = 1; - while (true) { - if (width_tmp < REQUIRED_SIZE && height_tmp < REQUIRED_SIZE) - break; - width_tmp /= 2; - height_tmp /= 2; - scale *= 2; - } - // Decode with inSampleSize - BitmapFactory.Options o2 = new BitmapFactory.Options(); - o2.inSampleSize = scale; - Bitmap b1 = BitmapFactory.decodeFile(filePath, o2); - bmp2= ExifUtils.rotateBitmap(filePath, b1); +//Method to create a bitmap from a view, in our case from a linearLayout + public Bitmap getBitmapFromView(View view) { + Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(returnedBitmap); + + Drawable bgDrawable = view.getBackground(); + if (bgDrawable != null) + bgDrawable.draw(canvas); + else + canvas.drawColor(Color.WHITE); + view.draw(canvas); + return returnedBitmap; } - public void launchLastActivity(View view){ - - if(bmp != null) { - try { - //Write file - String filename = "meme.png"; - FileOutputStream stream = this.openFileOutput(filename, Context.MODE_PRIVATE); - bmp.compress(Bitmap.CompressFormat.PNG, 100, stream); - - //Cleanup - stream.close(); - bmp.recycle(); - - //Pop intent - Intent lastActivity = new Intent(VanillaMeme.this, add_text.class); - lastActivity.putExtra("memeImage", filename); - startActivity(lastActivity); - } catch (Exception e) { - e.printStackTrace(); - } +//Method to share the meme + public void sharingM(View view) { + + bmp2 = getBitmapFromView(memeLayout); + + Intent share = new Intent(Intent.ACTION_SEND); + share.setType("image/jpeg"); + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + bmp2.compress(Bitmap.CompressFormat.JPEG, 100, bytes); + File f = new File(Environment.getExternalStorageDirectory() + File.separator + "temporary_file.jpg"); + try { + f.createNewFile(); + FileOutputStream fo = new FileOutputStream(f); + fo.write(bytes.toByteArray()); + } catch (IOException e) { + e.printStackTrace(); } + share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/temporary_file.jpg")); + startActivity(Intent.createChooser(share, "Share Image")); } +//Method to Save the Meme into the camera roll + public void savingM(View view) { + bmp2 = getBitmapFromView(memeLayout); + + MediaStore.Images.Media.insertImage(VanillaMeme.this.getContentResolver(), bmp2, "title.jpg", "some description"); + Toast.makeText(this, "Meme saved!", Toast.LENGTH_LONG).show(); + } -} +} \ No newline at end of file diff --git a/app/src/main/java/meme5/c4q/nyc/meme_project/add_text.java b/app/src/main/java/meme5/c4q/nyc/meme_project/add_text.java deleted file mode 100644 index cffe1fc..0000000 --- a/app/src/main/java/meme5/c4q/nyc/meme_project/add_text.java +++ /dev/null @@ -1,108 +0,0 @@ -package meme5.c4q.nyc.meme_project; - -import android.content.Intent; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.media.Image; -import android.net.Uri; -import android.os.Environment; -import android.support.v7.app.ActionBarActivity; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.EditText; -import android.widget.ImageView; -import android.provider.MediaStore; -import android.widget.Toast; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; - - -public class add_text extends ActionBarActivity { - - Bitmap memeImage; - ImageView share; - ImageView save; - ImageView preview; - Bitmap previewMeme; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_add_text); - - - - String filename = getIntent().getStringExtra("memeImage"); - try { - FileInputStream is = this.openFileInput(filename); - memeImage = BitmapFactory.decodeStream(is); - is.close(); - } catch (Exception e) { - e.printStackTrace(); - } - - ImageView previewMeme = (ImageView) findViewById(R.id.previewMeme); - if(memeImage != null) { - previewMeme.setImageBitmap(memeImage); - } - - share = (ImageView) findViewById(R.id.shareButton); - share.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - - Intent share = new Intent(Intent.ACTION_SEND); - share.setType("image/jpeg"); - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - memeImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes); - File f = new File(Environment.getExternalStorageDirectory() + File.separator + "temporary_file.jpg"); - try { - f.createNewFile(); - FileOutputStream fo = new FileOutputStream(f); - fo.write(bytes.toByteArray()); - } catch (IOException e) { - e.printStackTrace(); - } - share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/temporary_file.jpg")); - startActivity(Intent.createChooser(share, "Share Image")); - - - } - }); - - } - - public void saveImage(View view) { - MediaStore.Images.Media.insertImage(add_text.this.getContentResolver(), memeImage, "title.jpg", "some description"); - Toast.makeText(this, "Meme saved!", Toast.LENGTH_LONG).show(); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.menu_add_text, menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. - int id = item.getItemId(); - - //noinspection SimplifiableIfStatement - if (id == R.id.action_settings) { - return true; - } - - return super.onOptionsItemSelected(item); - } - -} diff --git a/app/src/main/res/layout-land/activity_add_text.xml b/app/src/main/res/layout-land/activity_add_text.xml deleted file mode 100644 index e4be82f..0000000 --- a/app/src/main/res/layout-land/activity_add_text.xml +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout-land/activity_choose_meme_style.xml b/app/src/main/res/layout-land/activity_choose_meme_style.xml deleted file mode 100644 index 5cd25d3..0000000 --- a/app/src/main/res/layout-land/activity_choose_meme_style.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -