Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 55 additions & 59 deletions app/src/main/java/meme5/c4q/nyc/meme_project/ChooseMemeStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,16 @@
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import java.util.Random;


//user chooses either demotivational meme style or vanilla meme style
public class ChooseMemeStyle extends Activity {


public static final String TAG = "MEME_ACTIVITY";
protected RadioGroup styleGroup;
protected RadioButton styleButton;
protected Button nextButton;
protected boolean vanilla;
protected Random slideShow;
ImageView img, thumbnail;
AnimationDrawable frameAnimation;
String imgFilePath;
Expand All @@ -40,6 +28,17 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_choose_meme_style);

getMeme();

applyCustomFont();

RadioGroup group = (RadioGroup) findViewById(R.id.styleGroup);
group.setOnCheckedChangeListener(radioGroupChangeListener);
group.check(R.id.chooseDemotivational);

}

public void getMeme() {
Bundle bundle = getIntent().getExtras();
if(bundle.getString("imgFilePath") != null)
{
Expand All @@ -48,7 +47,9 @@ protected void onCreate(Bundle savedInstanceState) {
thumbnail = (ImageView) findViewById(R.id.thumbnail);
Bitmap bmp2 = BitmapFactory.decodeFile(imgFilePath);
thumbnail.setImageBitmap(bmp2);
}

public void applyCustomFont(){
//apply fonts -
//TODO: need to find a way to add this font globally through style!
TextView step1 = (TextView) findViewById(R.id.step1);
Expand All @@ -65,64 +66,59 @@ protected void onCreate(Bundle savedInstanceState) {
title.setTypeface(tf);
vanillaRadio.setTypeface(tf);
demotivationalRadio.setTypeface(tf);
}

RadioGroup group = (RadioGroup) findViewById(R.id.styleGroup);
group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
Log.d(TAG, "onCheckedChanged()");
// Is the button now checked?
public RadioGroup.OnCheckedChangeListener radioGroupChangeListener = new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
Log.d(TAG, "onCheckedChanged()");
// Is the button now checked?
// boolean checked = ((RadioButton) view).isChecked();

// Check which radio button was clicked
switch (checkedId) {
case R.id.chooseVanilla:
// Check which radio button was clicked
switch (checkedId) {
case R.id.chooseVanilla:

Log.d(TAG, "onCheckedChanged() -- chooseVanilla");
//determine if user chose vanilla or demotivational
Log.d(TAG, "onCheckedChanged() -- chooseVanilla");
//determine if user chose vanilla or demotivational

vanilla = true;
img = (ImageView) findViewById(R.id.sampleImageHolder);
img.setImageResource(R.drawable.vanilla_animation);
vanilla = true;
img = (ImageView) findViewById(R.id.sampleImageHolder);
img.setImageResource(R.drawable.vanilla_animation);

frameAnimation = (AnimationDrawable) img.getDrawable();
frameAnimation = (AnimationDrawable) img.getDrawable();

frameAnimation.start();
break;
case R.id.chooseDemotivational:
frameAnimation.start();
break;
case R.id.chooseDemotivational:

Log.d(TAG, "onCheckedChanged() -- chooseDemotivational");
//determine if user chose vanilla or demotivational
vanilla = false;
img = (ImageView) findViewById(R.id.sampleImageHolder);
img.setImageResource(R.drawable.demotivational_animation);
Log.d(TAG, "onCheckedChanged() -- chooseDemotivational");
//determine if user chose vanilla or demotivational
vanilla = false;
img = (ImageView) findViewById(R.id.sampleImageHolder);
img.setImageResource(R.drawable.demotivational_animation);

frameAnimation = (AnimationDrawable) img.getDrawable();
frameAnimation = (AnimationDrawable) img.getDrawable();

frameAnimation.start();
break;
}
frameAnimation.start();
break;
}
});

group.check(R.id.chooseDemotivational);
}
};

nextButton = (Button) findViewById(R.id.nextButton);
nextButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {

if (vanilla) {
Intent vanillameme = new Intent(ChooseMemeStyle.this,VanillaMeme.class);
vanillameme.putExtra("imgFilePath",imgFilePath);
startActivity(vanillameme);
}
else {
Intent demotivationalMeme = new Intent(ChooseMemeStyle.this, DemotivationalMemeActivity.class);
demotivationalMeme.putExtra("imgFilePath",imgFilePath);
startActivity(demotivationalMeme);
}
}
});
public void nextButtonOnClick (View view) {
if (vanilla) {
Intent vanillameme = new Intent(ChooseMemeStyle.this,VanillaMeme.class);
vanillameme.putExtra("imgFilePath",imgFilePath);
startActivity(vanillameme);
}
else {
Intent demotivationalMeme = new Intent(ChooseMemeStyle.this, DemotivationalMemeActivity.class);
demotivationalMeme.putExtra("imgFilePath",imgFilePath);
startActivity(demotivationalMeme);
}
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

Expand All @@ -36,25 +35,27 @@ protected void onCreate(Bundle savedInstanceState) {

preview = (ImageView) findViewById(R.id.preview);

getMeme();

largeText = (EditText) findViewById(R.id.large);
smallText = (EditText) findViewById(R.id.small);

}

public void getMeme() {
String imgFilePath = "";
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 previewTextOnClick (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){
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/java/meme5/c4q/nyc/meme_project/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package meme5.c4q.nyc.meme_project;

import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import android.os.Bundle;
import android.widget.Toast;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Toast;


//user chooses whether to take picture from gallery, or camera for meme
//todo: create option where user can choose a meme type image.
public class MainActivity extends Activity {
private static final int RESULT_LOAD_IMG = 1;
private static final int REQUEST_IMAGE_CAPTURE = 1;
Expand All @@ -23,6 +23,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);

}

private void launchChooseMeme(){
Intent chooseMeme = new Intent(this,ChooseMemeStyle.class);
chooseMeme.putExtra("imgFilePath",imgFilePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
*/
import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.widget.ImageView;
import android.widget.TextView;

//intro to app screen
public class SplashScreen extends Activity {

/** Duration of wait **/
Expand Down
74 changes: 40 additions & 34 deletions app/src/main/java/meme5/c4q/nyc/meme_project/VanillaMeme.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
Expand All @@ -15,16 +14,13 @@
import android.text.StaticLayout;
import android.text.TextPaint;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import org.w3c.dom.Text;

import java.io.FileOutputStream;


Expand All @@ -44,12 +40,7 @@ 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);
}
getMeme();

line1 = (EditText) findViewById(R.id.top);
image = (ImageView) findViewById(R.id.testImage);
Expand All @@ -59,7 +50,25 @@ protected void onCreate(Bundle savedInstanceState) {
medium = (RadioButton) findViewById(R.id.medium);
large = (RadioButton) findViewById(R.id.large);

applyFont();

//create on check listener to see which size is chosen
RadioGroup group = (RadioGroup) findViewById(R.id.textSizes);
group.setOnCheckedChangeListener(radioGroupChangeListener);
group.check(R.id.small);

}

public void getMeme(){
//get image path from previous activity
Bundle bundle = getIntent().getExtras();
if (bundle.getString("imgFilePath") != null) {
imgFilePath = bundle.getString("imgFilePath");
decodeFile(imgFilePath);
}
}

public void applyFont(){
//apply font
Typeface tf = Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/ubuntu.ttf");
title.setTypeface(tf);
Expand All @@ -68,32 +77,29 @@ protected void onCreate(Bundle savedInstanceState) {
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;
}
public RadioGroup.OnCheckedChangeListener radioGroupChangeListener = 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;
}
});
}
}
};

//method used to write text on image
public Bitmap drawTextToBitmap(Bitmap bitmap, String mText1, int textSize, int strokeSize) {
Expand Down
Loading