1
0
Fork 0

Changed Toasts per Snackbars

This commit is contained in:
Carlos Galindo 2015-03-25 11:27:50 +01:00
parent 06673bdcd0
commit 624766ad33
16 changed files with 524 additions and 446 deletions

View file

@ -86,9 +86,11 @@
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-22.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.0.0" level="project" />
<orderEntry type="library" exported="" name="snackbar-2.10.6" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.0.0" level="project" />
</component>
</module>

View file

@ -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'
}

View file

@ -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();
}

View file

@ -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()));

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -47,13 +47,15 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/classSpinner"/>
android:id="@+id/classSpinner"
android:spinnerMode="dropdown" />
<Spinner
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/raceSpinner"/>
android:id="@+id/raceSpinner"
android:spinnerMode="dialog" />
</LinearLayout>
<GridLayout
@ -141,4 +143,24 @@
android:hint="@string/CAR"/>
</GridLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/thirdLayout"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/new_attack"
android:id="@+id/new_attack_button" />
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listView" />
</LinearLayout>
</RelativeLayout>

View file

@ -1,13 +1,18 @@
<ScrollView
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
tools:context=".MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
@ -395,6 +400,6 @@
android:hint="@string/VOL" />
</GridLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</ScrollView>
</FrameLayout>

View file

@ -1,4 +1,4 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -9,26 +9,45 @@
tools:context="com.kauron.dungeonmanager.Welcome"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/new_character_warning"
android:id="@+id/newText" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/new_character"
android:id="@+id/newCharacter"
android:onClick="onNewClick" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/load_character"
android:id="@+id/loadCharacter"
android:onClick="onLoadClick" />
android:onClick="onLoadClick"
android:layout_below="@+id/relativeLayout"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:elevation="3dp"
android:id="@+id/relativeLayout"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/textView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/new_character"
android:id="@+id/newCharacter"
android:onClick="onNewClick"
android:layout_below="@+id/textView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</RelativeLayout>

View file

@ -2,6 +2,13 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.kauron.dungeonmanager.Welcome">
<item android:id="@+id/action_settings" android:title="@string/action_settings"
android:orderInCategory="100" app:showAsAction="never" />
<item
android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="100"
app:showAsAction="ifRoom"
android:icon="@drawable/ic_action_settings"
android:alpha="10"
android:enabled="false"/>
</menu>

View file

@ -75,4 +75,5 @@
<string name="title_activity_welcome">Bienvenido</string>
<string name="load_character">Cargar personaje</string>
<string name="new_character_warning">Esto borrará al personaje anterior</string>
<string name="new_attack">Nuevo ataque</string>
</resources>

View file

@ -1,5 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary">#5D4037</color>
<color name="primaryDark">#3E2723</color>
<color name="primary">#795548</color>
<color name="primary_dark">#5D4037</color>
<color name="primary_light">#D7CCC8</color>
<color name="accent">#FF5252</color>
<color name="primary_text">#212121</color>
<color name="secondary_text">#727272</color>
<color name="icons">#FFFFFF</color>
<color name="divider">#B6B6B6</color>
<!--<color name="primary">#5D4037</color>-->
<!--<color name="primaryDark">#3E2723</color>-->
</resources>

View file

@ -7,10 +7,10 @@
<string name="action_undo">Undo</string>
<string name="pg">PG</string>
<string name="die">Die</string>
<string name="CA">CA</string>
<string name="CA">AC</string>
<string name="FORT">FORT</string>
<string name="REF">REF</string>
<string name="VOL">VOL</string>
<string name="VOL">WILL</string>
<string name="defense">Defense</string>
<string name="curative_efforts">Curative efforts</string>
<string name="load_text">Load %1$s</string>
@ -30,7 +30,7 @@
<string name="action_time_encounter_end">Encounter ended</string>
<string name="adventurer_name">Adventurer name</string>
<string name="state_changed_malherido">You have less than half of your maximum health</string>
<string name="new_energies_message">Who is using a curative effort?</string>
<string name="new_energies_message">Who is using a surge?</string>
<string name="class_name">Class</string>
<string name="race_name">Race</string>
<string name="state_changed_debilitado">You have fainted. You can\'t do anything!</string>
@ -42,16 +42,16 @@
<string name="edit_PG_Title">Suffer damage</string>
<string name="message_death">You have died</string>
<string name="new_energies1">You have</string>
<string name="new_energies2">curative efforts</string>
<string name="new_energies">New energies</string>
<string name="new_energies2">surges</string>
<string name="new_energies">Surge</string>
<string name="title_activity_introduction">Edit character</string>
<string name="action_finish">Save</string>
<string name="level">Level</string>
<string name="max_curative_efforts">Max curative efforts</string>
<string name="max_curative_efforts">Max surges</string>
<string name="max_pg">Max PG</string>
<string name="missing_info_error">You need to fill all the information</string>
<string name="no_curative_efforts_error">You don\'t have any curative efforts left!</string>
<string name="no_curative_efforts_error">You don\'t have any surges left!</string>
<string name="maxed_curative">You have reached your maximum level of PG</string>
<string name="suffer_damage">Input the damage suffered</string>
<string name="suffer_damage_hint">PG lost</string>
@ -81,4 +81,5 @@
<string name="new_character">New character</string>
<string name="load_character">Load character</string>
<string name="new_character_warning">This will erase any previously existing data saved</string>
<string name="new_attack">New attack</string>
</resources>

View file

@ -3,8 +3,14 @@
<!-- Base application theme. -->
<style name="AppTheme" parent="Base.Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="colorPrimaryDark">@color/primaryDark</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorPrimary">@color/primary</item>
<!--<item name="colorAccent">@color/accent</item>-->
<!--<item name="colorprimaryLight">@color/primary_light</item>-->
<!--<item name="colorPrimaryText">@color/primary_text</item>-->
<!--<item name="colorSecondaryText">@color/secondary_text</item>-->
<!--<item name="colorIcons">@color/icons</item>-->
<!--<item name="colorDivider">@color/divider</item>-->
</style>
</resources>