From 624766ad33486e5168bcf55b9352e255d341c3ec Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Wed, 25 Mar 2015 11:27:50 +0100 Subject: [PATCH] Changed Toasts per Snackbars --- app/app.iml | 6 +- app/build.gradle | 1 + .../kauron/dungeonmanager/Introduction.java | 2 +- .../kauron/dungeonmanager/MainActivity.java | 110 +-- .../res/drawable-hdpi/ic_action_settings.png | Bin 0 -> 757 bytes .../res/drawable-mdpi/ic_action_settings.png | Bin 0 -> 492 bytes .../res/drawable-xhdpi/ic_action_settings.png | Bin 0 -> 1032 bytes .../drawable-xxhdpi/ic_action_settings.png | Bin 0 -> 1680 bytes .../main/res/layout/activity_introduction.xml | 26 +- app/src/main/res/layout/activity_main.xml | 725 +++++++++--------- app/src/main/res/layout/activity_welcome.xml | 53 +- app/src/main/res/menu/menu_welcome.xml | 11 +- app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values/colors.xml | 12 +- app/src/main/res/values/strings.xml | 15 +- app/src/main/res/values/styles.xml | 8 +- 16 files changed, 524 insertions(+), 446 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_action_settings.png create mode 100644 app/src/main/res/drawable-mdpi/ic_action_settings.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_action_settings.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_action_settings.png diff --git a/app/app.iml b/app/app.iml index 21fada5..699ce6f 100644 --- a/app/app.iml +++ b/app/app.iml @@ -86,9 +86,11 @@ - - + + + + diff --git a/app/build.gradle b/app/build.gradle index 21a7ee6..87ad834 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -24,4 +24,5 @@ dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:appcompat-v7:21.0.3' compile 'com.android.support:cardview-v7:21.0.3' + compile 'com.nispok:snackbar:2.10.6' } diff --git a/app/src/main/java/com/kauron/dungeonmanager/Introduction.java b/app/src/main/java/com/kauron/dungeonmanager/Introduction.java index 363c7bc..db05457 100644 --- a/app/src/main/java/com/kauron/dungeonmanager/Introduction.java +++ b/app/src/main/java/com/kauron/dungeonmanager/Introduction.java @@ -68,7 +68,7 @@ public class Introduction extends ActionBarActivity { Toast.makeText( getApplicationContext(), R.string.message_no_back_button_intro, - Toast.LENGTH_LONG + Toast.LENGTH_SHORT ).show(); } diff --git a/app/src/main/java/com/kauron/dungeonmanager/MainActivity.java b/app/src/main/java/com/kauron/dungeonmanager/MainActivity.java index 8622e67..8321c0d 100644 --- a/app/src/main/java/com/kauron/dungeonmanager/MainActivity.java +++ b/app/src/main/java/com/kauron/dungeonmanager/MainActivity.java @@ -18,7 +18,9 @@ import android.widget.Button; import android.widget.EditText; import android.widget.ProgressBar; import android.widget.TextView; -import android.widget.Toast; + +import com.nispok.snackbar.Snackbar; +import com.nispok.snackbar.SnackbarManager; public class MainActivity extends ActionBarActivity{ @@ -94,11 +96,11 @@ public class MainActivity extends ActionBarActivity{ //noinspection SimplifiableIfStatement if (id == R.id.action_cure) { if(player.getMaxPg() <= player.getPg()){ - Toast.makeText( - getApplicationContext(), - R.string.maxed_curative, - Toast.LENGTH_LONG - ).show(); + SnackbarManager.show( + Snackbar + .with(getApplicationContext()) + .text(R.string.maxed_curative) + ); } else { healDialog(); } @@ -143,11 +145,11 @@ public class MainActivity extends ActionBarActivity{ // true, player.getPx() - Player.LEVEL_PX[player.getLevel() - 1] // ); } catch(Exception e) { - Toast.makeText( - getApplicationContext(), - R.string.message_no_px, - Toast.LENGTH_LONG - ).show(); + SnackbarManager.show( + Snackbar + .with(getApplicationContext()) + .text(R.string.message_no_px) + ); } } }); @@ -156,9 +158,11 @@ public class MainActivity extends ActionBarActivity{ return true; } else if (id == R.id.action_time_long_rest) { player.rest(true); - Toast.makeText( - getApplicationContext(), R.string.long_rest_done, Toast.LENGTH_LONG - ).show(); + SnackbarManager.show( + Snackbar + .with(getApplicationContext()) + .text(R.string.long_rest_done) + ); p.edit() .putInt("pg", player.getPg()) .putInt("curativeEfforts", player.getCurativeEfforts()) @@ -167,9 +171,11 @@ public class MainActivity extends ActionBarActivity{ ceUpdate(); } else if (id == R.id.action_time_rest) { player.rest(false); - Toast.makeText( - getApplicationContext(), R.string.rest_done, Toast.LENGTH_LONG - ).show(); + SnackbarManager.show( + Snackbar + .with(getApplicationContext()) + .text(R.string.rest_done) + ); pgUpdate(); ceUpdate(); } @@ -189,18 +195,18 @@ public class MainActivity extends ActionBarActivity{ public void heal(boolean usesEffort) { int hasCured = player.recoverPg(Player.USE_CURATIVE_EFFORT, usesEffort); if (hasCured == Player.NOT_CURED) { - Toast.makeText( - getApplicationContext(), - R.string.no_curative_efforts_error, - Toast.LENGTH_LONG - ).show(); + SnackbarManager.show( + Snackbar + .with(getApplicationContext()) + .text(R.string.no_curative_efforts_error) + ); } else { if(hasCured == Player.MAXED){ - Toast.makeText( - getApplicationContext(), - R.string.maxed_curative, - Toast.LENGTH_LONG - ).show(); + SnackbarManager.show( + Snackbar + .with(getApplicationContext()) + .text(R.string.maxed_curative) + ); } SharedPreferences.Editor e = p.edit(); e.putInt("pg", player.getPg()); @@ -321,11 +327,11 @@ public class MainActivity extends ActionBarActivity{ alert.setNegativeButton(R.string.die, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { - Toast.makeText( - getApplicationContext(), - R.string.message_death, - Toast.LENGTH_LONG - ).show(); + SnackbarManager.show( + Snackbar + .with(getApplicationContext()) + .text(R.string.message_death) + ); p.edit().clear().apply(); restoreData(); } @@ -338,11 +344,11 @@ public class MainActivity extends ActionBarActivity{ pgBar.getProgressDrawable().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN); negPgBar.getProgressDrawable().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN); if(lastState != Player.SAME) { - Toast.makeText( - getApplicationContext(), - R.string.state_changed_debilitado, - Toast.LENGTH_LONG - ).show(); + SnackbarManager.show( + Snackbar + .with(getApplicationContext()) + .text(R.string.state_changed_debilitado) + ); } } else if (status == Player.MALHERIDO) { pgCurrent.setBackgroundColor(android.R.drawable.btn_default); @@ -350,11 +356,11 @@ public class MainActivity extends ActionBarActivity{ pgBar.getProgressDrawable().setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_IN); negPgBar.getProgressDrawable().setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_IN); if(lastState != Player.SAME) { - Toast.makeText( - getApplicationContext(), - R.string.state_changed_malherido, - Toast.LENGTH_LONG - ).show(); + SnackbarManager.show( + Snackbar + .with(getApplicationContext()) + .text(R.string.state_changed_malherido) + ); } } else { pgCurrent.setTextColor(Color.GREEN); @@ -499,11 +505,11 @@ public class MainActivity extends ActionBarActivity{ message = getString(R.string.action_undo_current_pg); } if (!message.isEmpty()) { - Toast.makeText( - getApplicationContext(), - message, - Toast.LENGTH_LONG - ).show(); + SnackbarManager.show( + Snackbar + .with(getApplicationContext()) + .text(message) + ); } pgUpdate(); undo = false; @@ -525,11 +531,11 @@ public class MainActivity extends ActionBarActivity{ @Override public void onClick(DialogInterface dialog, int which) { if (input.getText().toString().isEmpty()) { - Toast.makeText( - getApplicationContext(), - R.string.empty_field, - Toast.LENGTH_LONG - ).show(); + SnackbarManager.show( + Snackbar + .with(getApplicationContext()) + .text(R.string.empty_field) + ); pgDialog(); } else { player.setMaxPg(Integer.parseInt(input.getText().toString())); diff --git a/app/src/main/res/drawable-hdpi/ic_action_settings.png b/app/src/main/res/drawable-hdpi/ic_action_settings.png new file mode 100644 index 0000000000000000000000000000000000000000..a04af7e7422095bd1d486571e0fb4e684b67a5fb GIT binary patch literal 757 zcmV=7a@ei@IkkJ=$9fWE=6h@(GMX)1!@*4DD{_?g|rh?E_(%|tHs2wz#^-Kkz&C-$Dxw4&F*K_wYD!Fh)V$_2zOrDSa|!hc z{6G`5+tOD?&OE3Lnkt8?Xv54NKqAwiRGNGz_+mLi z9H%4${FQ>!mct?a?U<+^;G${a05(JO3)rX*JoLGj@yaELXP{gnV7Kas(!)wtRj#bV zNKV(KU5=9D5s%X|qSg0^s8cH#Me?-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