Skip to content

Commit

Permalink
removed preview buttons from vanilla, replaced with textwatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
alizinha committed Jun 11, 2015
1 parent 0c63ced commit 983b733
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,7 @@ protected void onCreate(Bundle savedInstanceState) {

imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);

//TODO: Delete this commented out stuff
// Button titleEditTxtPreviewBtn = (Button) findViewById(R.id.title_editText_preview_btn);
// titleEditTxtPreviewBtn.setOnClickListener(titlePreviewBtnListener);

// Button phraseEditTxtPreviewBtn = (Button) findViewById(R.id.phrase_editText_preview_btn);
// phraseEditTxtPreviewBtn.setOnClickListener(phrasePreviewBtnListener);

//Moved these next 2 lines here because they're better placed in onCreate()
//Moved these next 4 lines here because they're better placed in onCreate()
titleEditText = (EditText) findViewById(R.id.title_editText);
titleTextView = (TextView) findViewById(R.id.title_textView);
phraseEditText = (EditText) findViewById(R.id.phrase_editText);
Expand Down Expand Up @@ -120,11 +113,6 @@ public void onClick(View view) {
private View.OnClickListener phrasePreviewBtnListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
//moving these into onCreate()--TODO: delete this when it works
// phraseEditText = (EditText) findViewById(R.id.phrase_editText);
// phraseTextView = (TextView) findViewById(R.id.phrase_textView);
phraseTextView.setText(phraseEditText.getText().toString());

imm.hideSoftInputFromWindow(phraseTextView.getWindowToken(), 0);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected void onCreate(Bundle savedInstanceState) {
Log.d(MainActivity.TAG, "VanillaMemeEdit.onCreate()");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_vanilla_meme_edit);

imageUri = getIntent().getData();

//setting Image from filepath to ImageView source
Expand All @@ -65,23 +66,60 @@ protected void onCreate(Bundle savedInstanceState) {

imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);

Button topEditTxtPreviewBtn = (Button) findViewById(R.id.top_editText_preview_btn);
topEditTxtPreviewBtn.setOnClickListener(topPreviewBtnListener);
topEditText = (EditText) findViewById(R.id.top_editText);
topTextView = (TextView) findViewById(R.id.top_textView);
topTextView.setText(topEditText.getText().toString());

midEditText = (EditText) findViewById(R.id.mid_editText);
midTextView = (TextView) findViewById(R.id.mid_textView);
midTextView.setText(midEditText.getText().toString());

btmEditText = (EditText) findViewById(R.id.btm_editText);
btmTextView = (TextView) findViewById(R.id.btm_textView);
btmTextView.setText(btmEditText.getText().toString());

//TODO: what's up with the underlining of text?? low priority
topEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
topTextView.setText(s);
}

@Override
public void afterTextChanged(Editable s) {}
});
midEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

Button midEditTxtPreviewBtn = (Button) findViewById(R.id.mid_editText_preview_btn);
midEditTxtPreviewBtn.setOnClickListener(midPreviewBtnListener);
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
midTextView.setText(s);
}

@Override
public void afterTextChanged(Editable s) {}
});
btmEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
btmTextView.setText(s);
}

Button btmEditTxtPreviewBtn = (Button) findViewById(R.id.btm_editText_preview_btn);
btmEditTxtPreviewBtn.setOnClickListener(btmPreviewBtnListener);
@Override
public void afterTextChanged(Editable s) {}
});
}

private View.OnClickListener topPreviewBtnListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
topEditText = (EditText) findViewById(R.id.top_editText);
topTextView = (TextView) findViewById(R.id.top_textView);
topTextView.setText(topEditText.getText().toString());

imm.hideSoftInputFromWindow(topEditText.getWindowToken(), 0);

}
Expand All @@ -90,10 +128,6 @@ public void onClick(View view) {
private View.OnClickListener midPreviewBtnListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
midEditText = (EditText) findViewById(R.id.mid_editText);
midTextView = (TextView) findViewById(R.id.mid_textView);
midTextView.setText(midEditText.getText().toString());

imm.hideSoftInputFromWindow(midEditText.getWindowToken(), 0);

}
Expand All @@ -102,10 +136,6 @@ public void onClick(View view) {
private View.OnClickListener btmPreviewBtnListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
btmEditText = (EditText) findViewById(R.id.btm_editText);
btmTextView = (TextView) findViewById(R.id.btm_textView);
btmTextView.setText(btmEditText.getText().toString());

imm.hideSoftInputFromWindow(btmEditText.getWindowToken(), 0);

}
Expand Down
24 changes: 0 additions & 24 deletions Meme-ify-Me/app/src/main/res/layout/activity_vanilla_meme_edit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,6 @@
android:layout_height="match_parent"
android:hint="top text" />

<Button
android:id="@+id/top_editText_preview_btn"
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/edit_button_background"
android:text="Preview" />

</LinearLayout>

<!-- mid edit text and preview button -->
Expand All @@ -129,14 +121,6 @@
android:layout_height="match_parent"
android:hint="mid text" />

<Button
android:id="@+id/mid_editText_preview_btn"
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/edit_button_background"
android:text="Preview" />

</LinearLayout>

<!-- bottom edit text and preview button -->
Expand All @@ -154,14 +138,6 @@
android:layout_height="match_parent"
android:hint="bottom text" />

<Button
android:id="@+id/btm_editText_preview_btn"
android:layout_weight="2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/edit_button_background"
android:text="Preview" />

</LinearLayout>

</LinearLayout>
Expand Down

0 comments on commit 983b733

Please sign in to comment.