Better colors display, edition and deletion
This commit is contained in:
parent
2fc2ff61ba
commit
943d98f867
11 changed files with 191 additions and 115 deletions
|
@ -4,6 +4,7 @@ import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -36,6 +37,8 @@ class AttackAdapter extends ArrayAdapter<Power> {
|
||||||
((TextView) mView.findViewById(R.id.keywords)).setText(attack.getKeywords());
|
((TextView) mView.findViewById(R.id.keywords)).setText(attack.getKeywords());
|
||||||
((TextView) mView.findViewById(R.id.frequency)).setText(attack.getFrequencyString());
|
((TextView) mView.findViewById(R.id.frequency)).setText(attack.getFrequencyString());
|
||||||
((TextView) mView.findViewById(R.id.extra)).setText(attack.getRangeString() + " " + attack.getDistance());
|
((TextView) mView.findViewById(R.id.extra)).setText(attack.getRangeString() + " " + attack.getDistance());
|
||||||
|
mView.setBackgroundColor(attack.getFreqColor(getContext()));
|
||||||
|
mView.getBackground().setAlpha((position % 2) * 127 + 128);
|
||||||
}
|
}
|
||||||
return mView;
|
return mView;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.kauron.dungeonmanager;
|
package com.kauron.dungeonmanager;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@ -236,4 +237,15 @@ class Player implements Serializable {
|
||||||
static int getModifier(int i) {
|
static int getModifier(int i) {
|
||||||
return i / 2 - 5;
|
return i / 2 - 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getStatusColor(Context context) {
|
||||||
|
if (pg > maxPg / 2)
|
||||||
|
return context.getResources().getColor(R.color.green);
|
||||||
|
else if (pg > 0)
|
||||||
|
return context.getResources().getColor(R.color.yellow);
|
||||||
|
else if (pg > - maxPg / 2)
|
||||||
|
return context.getResources().getColor(R.color.red);
|
||||||
|
else
|
||||||
|
return context.getResources().getColor(R.color.black);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -42,16 +42,9 @@ class PlayerAdapter extends ArrayAdapter<Player> {
|
||||||
neg.setProgress(pg < 0 ? -pg : 0);
|
neg.setProgress(pg < 0 ? -pg : 0);
|
||||||
pos.setProgress(pg > 0 ? pg : 0);
|
pos.setProgress(pg > 0 ? pg : 0);
|
||||||
|
|
||||||
int c;
|
int color = player.getStatusColor(getContext());
|
||||||
if ( pg <= 0 )
|
neg.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||||
c = getContext().getResources().getColor(R.color.red);
|
pos.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||||
else if ( pg <= maxPg / 2 )
|
|
||||||
c = getContext().getResources().getColor(R.color.yellow);
|
|
||||||
else
|
|
||||||
c = getContext().getResources().getColor(R.color.green);
|
|
||||||
|
|
||||||
neg.getProgressDrawable().setColorFilter(c, PorterDuff.Mode.SRC_IN);
|
|
||||||
pos.getProgressDrawable().setColorFilter(c, PorterDuff.Mode.SRC_IN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mView;
|
return mView;
|
||||||
|
|
|
@ -136,7 +136,8 @@ public class PlayerEditor extends ActionBarActivity {
|
||||||
int i = p.getInt("players", 0);
|
int i = p.getInt("players", 0);
|
||||||
String saveName = nameString;
|
String saveName = nameString;
|
||||||
for (int j = 0; j < i; j++) {
|
for (int j = 0; j < i; j++) {
|
||||||
saveName += p.getString("player" + j, "").equals(saveName) ? "2" : "";
|
if (p.getString("player" + j, "").equals(saveName))
|
||||||
|
saveName += "2";
|
||||||
}
|
}
|
||||||
p.edit().putString("player" + i, saveName).putInt("players", i + 1).apply();
|
p.edit().putString("player" + i, saveName).putInt("players", i + 1).apply();
|
||||||
SharedPreferences.Editor ed = getSharedPreferences(saveName, MODE_PRIVATE).edit();
|
SharedPreferences.Editor ed = getSharedPreferences(saveName, MODE_PRIVATE).edit();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.kauron.dungeonmanager;
|
package com.kauron.dungeonmanager;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
|
||||||
|
@ -77,4 +78,17 @@ class Power implements Serializable{
|
||||||
void recover(int type){
|
void recover(int type){
|
||||||
if(this.freq <= type) used = false;
|
if(this.freq <= type) used = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getFreqColor(Context context) {
|
||||||
|
switch (freq) {
|
||||||
|
case DIARIO:
|
||||||
|
return context.getResources().getColor(R.color.daily);
|
||||||
|
case ENCUENTRO:
|
||||||
|
return context.getResources().getColor(R.color.encounter);
|
||||||
|
case A_VOLUNTAD:
|
||||||
|
return context.getResources().getColor(R.color.at_will);
|
||||||
|
default:
|
||||||
|
return context.getResources().getColor(R.color.green); //TODO: find other color
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package com.kauron.dungeonmanager;
|
package com.kauron.dungeonmanager;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
|
@ -20,13 +21,19 @@ public class PowerEditor extends ActionBarActivity {
|
||||||
private String[] strings = new String[5];
|
private String[] strings = new String[5];
|
||||||
private int[] ints = new int[5];
|
private int[] ints = new int[5];
|
||||||
|
|
||||||
|
private String originalName;
|
||||||
|
private int power;
|
||||||
|
private SharedPreferences p;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_power_editor);
|
setContentView(R.layout.activity_power_editor);
|
||||||
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
|
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
|
||||||
|
|
||||||
|
power = getIntent().getIntExtra("power", -1);
|
||||||
|
|
||||||
|
p = getSharedPreferences(getIntent().getStringExtra("player"), MODE_PRIVATE);
|
||||||
|
|
||||||
//EditText
|
//EditText
|
||||||
edits[0] = (EditText) findViewById(R.id.nameEdit);
|
edits[0] = (EditText) findViewById(R.id.nameEdit);
|
||||||
|
@ -78,6 +85,16 @@ public class PowerEditor extends ActionBarActivity {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
if (power != -1) {
|
||||||
|
SharedPreferences pp = getSharedPreferences(p.getString("power" + power, ""), MODE_PRIVATE);
|
||||||
|
for ( int i = 0; i < spinners.length; i++ )
|
||||||
|
spinners[i].setSelection(pp.getInt("i" + i, 0));
|
||||||
|
for ( int i = 0; i < edits.length; i++ )
|
||||||
|
edits[i].setText(pp.getString("s" + i, ""));
|
||||||
|
originalName = edits[0].getText().toString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,42 +102,45 @@ public class PowerEditor extends ActionBarActivity {
|
||||||
//TODO: change strings per resources
|
//TODO: change strings per resources
|
||||||
boolean readyToSave = true;
|
boolean readyToSave = true;
|
||||||
|
|
||||||
for ( int i = 0; i < edits.length; i++ )
|
for ( int i = 0; i < edits.length; i++ ) {
|
||||||
if ( edits[i].getText().toString().trim().length() == 0 ) {
|
String s = edits[i].getText().toString().trim();
|
||||||
|
if (s.length() == 0) {
|
||||||
edits[i].setError("This field is required");
|
edits[i].setError("This field is required");
|
||||||
readyToSave = false;
|
readyToSave = false;
|
||||||
} else {
|
} else {
|
||||||
strings[i] = edits[i].getText().toString().trim();
|
strings[i] = s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for ( int i = 0; i < spinners.length; i++) {
|
||||||
for ( int i = 0; i < spinners.length; i++)
|
int n = spinners[i].getSelectedItemPosition();
|
||||||
if ( spinners[i].getSelectedItemPosition() == 0 ) {
|
if ( n == 0) {
|
||||||
spinners[i].setBackgroundColor(getResources().getColor(R.color.red));
|
spinners[i].setBackgroundColor(getResources().getColor(R.color.red));
|
||||||
readyToSave = false;
|
readyToSave = false;
|
||||||
|
//TODO: remove the color when the user has made a choice
|
||||||
} else {
|
} else {
|
||||||
ints[i] = spinners[i].getSelectedItemPosition();
|
ints[i] = n;
|
||||||
spinners[i].setBackgroundColor(getResources().getColor(R.color.green));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( readyToSave ) {
|
if ( readyToSave ) {
|
||||||
String player = getIntent().getStringExtra("player");
|
|
||||||
SharedPreferences p = getSharedPreferences(player, MODE_PRIVATE);
|
|
||||||
|
|
||||||
int powers = p.getInt("powers", 0);
|
int powers = p.getInt("powers", 0);
|
||||||
|
|
||||||
|
String saveName;
|
||||||
|
if ( originalName == null ) {
|
||||||
|
saveName = strings[0];
|
||||||
for (int i = 0; i < powers; i++) {
|
for (int i = 0; i < powers; i++) {
|
||||||
if ( p.getString("power" + i, "") == strings[0] ) {
|
if (p.getString("power" + power, "").equals(saveName)) saveName += "2";
|
||||||
edits[0].setError("This power has already been defined. Use another name.");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
saveName = originalName;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.edit().putString("power" + powers, strings[0])
|
p.edit().putString("power" + powers, saveName)
|
||||||
.putInt("powers", powers + 1)
|
.putInt("powers", powers + 1)
|
||||||
.apply();
|
.apply();
|
||||||
|
|
||||||
SharedPreferences.Editor ed = getSharedPreferences(strings[0], MODE_PRIVATE).edit();
|
SharedPreferences.Editor ed = getSharedPreferences( saveName, MODE_PRIVATE).edit();
|
||||||
|
|
||||||
for (int i = 0; i < strings.length; i++)
|
for (int i = 0; i < strings.length; i++)
|
||||||
ed.putString("s" + i, strings[i]);
|
ed.putString("s" + i, strings[i]);
|
||||||
|
|
|
@ -7,17 +7,19 @@ import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
@ -28,6 +30,8 @@ import com.nispok.snackbar.Snackbar;
|
||||||
import com.nispok.snackbar.SnackbarManager;
|
import com.nispok.snackbar.SnackbarManager;
|
||||||
import com.nispok.snackbar.listeners.ActionClickListener;
|
import com.nispok.snackbar.listeners.ActionClickListener;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
public class ShowPlayer extends ActionBarActivity {
|
public class ShowPlayer extends ActionBarActivity {
|
||||||
|
|
||||||
public static final int CURRENT_PG = 1, NULL = 0;
|
public static final int CURRENT_PG = 1, NULL = 0;
|
||||||
|
@ -37,7 +41,7 @@ public class ShowPlayer extends ActionBarActivity {
|
||||||
//TODO: fix undo (show snackbar with button in each case, without timing).
|
//TODO: fix undo (show snackbar with button in each case, without timing).
|
||||||
private int undoObject, undoPreviousValue;
|
private int undoObject, undoPreviousValue;
|
||||||
|
|
||||||
private ProgressBar pgBar, negPgBar, xpBar, curativeEffortsBar;
|
private ProgressBar posPgBar, negPgBar, xpBar, curativeEffortsBar;
|
||||||
private TextView currentPg, currentXp, currentCurativeEfforts;
|
private TextView currentPg, currentXp, currentCurativeEfforts;
|
||||||
private SharedPreferences p;
|
private SharedPreferences p;
|
||||||
private Toolbar toolbar;
|
private Toolbar toolbar;
|
||||||
|
@ -64,7 +68,7 @@ public class ShowPlayer extends ActionBarActivity {
|
||||||
//Performing all the findViewById commands
|
//Performing all the findViewById commands
|
||||||
xpBar = (ProgressBar) findViewById(R.id.xpBar);
|
xpBar = (ProgressBar) findViewById(R.id.xpBar);
|
||||||
curativeEffortsBar = (ProgressBar) findViewById(R.id.curativeEffortsBar);
|
curativeEffortsBar = (ProgressBar) findViewById(R.id.curativeEffortsBar);
|
||||||
pgBar = (ProgressBar) findViewById(R.id.pgBar);
|
posPgBar = (ProgressBar) findViewById(R.id.pgBar);
|
||||||
negPgBar = (ProgressBar) findViewById(R.id.negPgBar);
|
negPgBar = (ProgressBar) findViewById(R.id.negPgBar);
|
||||||
|
|
||||||
currentPg = (TextView) findViewById(R.id.currentPg);
|
currentPg = (TextView) findViewById(R.id.currentPg);
|
||||||
|
@ -151,7 +155,8 @@ public class ShowPlayer extends ActionBarActivity {
|
||||||
alert.show();
|
alert.show();
|
||||||
input.requestFocus();
|
input.requestFocus();
|
||||||
return true;
|
return true;
|
||||||
//TODO: the player no longer contains the powers, therefore the
|
//TODO: the player no longer contains the powers, therefore the resting action affects the array of powers
|
||||||
|
//TODO: fix restoring powers
|
||||||
// } else if (id == R.id.action_time_long_rest) {
|
// } else if (id == R.id.action_time_long_rest) {
|
||||||
// player.rest(true);
|
// player.rest(true);
|
||||||
// SnackbarManager.show(
|
// SnackbarManager.show(
|
||||||
|
@ -299,31 +304,14 @@ public class ShowPlayer extends ActionBarActivity {
|
||||||
private void pgUpdate() {
|
private void pgUpdate() {
|
||||||
int status = player.getState();
|
int status = player.getState();
|
||||||
int pg = player.getPg();
|
int pg = player.getPg();
|
||||||
if (pg < 0) {
|
negPgBar.setProgress(pg < 0 ? -pg : 0);
|
||||||
if (status == Player.MUERTO)
|
posPgBar.setProgress(pg > 0 ? pg : 0);
|
||||||
negPgBar.setProgress(negPgBar.getMax());
|
|
||||||
else
|
|
||||||
negPgBar.setProgress(-pg);
|
|
||||||
pgBar.setProgress(0);
|
|
||||||
} else {
|
|
||||||
pgBar.setProgress(pg);
|
|
||||||
negPgBar.setProgress(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
currentPg.setText(player.getPg() + " / " + player.getMaxPg());
|
currentPg.setText(player.getPg() + " / " + player.getMaxPg());
|
||||||
|
|
||||||
if (status == Player.MUERTO) {
|
int color = player.getStatusColor(getApplicationContext());
|
||||||
pgBar.getProgressDrawable().setColorFilter(getResources().getColor(R.color.black), PorterDuff.Mode.SRC_IN);
|
posPgBar.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||||
} else if (status == Player.DEBILITADO) {
|
negPgBar.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||||
pgBar.getProgressDrawable().setColorFilter(getResources().getColor(R.color.red), PorterDuff.Mode.SRC_IN);
|
|
||||||
negPgBar.getProgressDrawable().setColorFilter(getResources().getColor(R.color.red), PorterDuff.Mode.SRC_IN);
|
|
||||||
} else if (status == Player.MALHERIDO) {
|
|
||||||
pgBar.getProgressDrawable().setColorFilter(getResources().getColor(R.color.yellow), PorterDuff.Mode.SRC_IN);
|
|
||||||
negPgBar.getProgressDrawable().setColorFilter(getResources().getColor(R.color.yellow), PorterDuff.Mode.SRC_IN);
|
|
||||||
} else {
|
|
||||||
pgBar.getProgressDrawable().setColorFilter(getResources().getColor(R.color.green), PorterDuff.Mode.SRC_IN);
|
|
||||||
negPgBar.getProgressDrawable().setColorFilter(getResources().getColor(R.color.green), PorterDuff.Mode.SRC_IN);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreData(){
|
private void restoreData(){
|
||||||
|
@ -343,7 +331,7 @@ public class ShowPlayer extends ActionBarActivity {
|
||||||
player.setCurativeEffort(p.getInt("curativeEfforts", player.getMaxCurativeEfforts()));
|
player.setCurativeEffort(p.getInt("curativeEfforts", player.getMaxCurativeEfforts()));
|
||||||
player.setPg(p.getInt("pg", player.getMaxPg()));
|
player.setPg(p.getInt("pg", player.getMaxPg()));
|
||||||
|
|
||||||
pgBar.setMax(player.getMaxPg());
|
posPgBar.setMax(player.getMaxPg());
|
||||||
negPgBar.setMax(player.getMaxPg() / 2);
|
negPgBar.setMax(player.getMaxPg() / 2);
|
||||||
curativeEffortsBar.setMax(player.getMaxCurativeEfforts());
|
curativeEffortsBar.setMax(player.getMaxCurativeEfforts());
|
||||||
pgUpdate();
|
pgUpdate();
|
||||||
|
@ -455,7 +443,16 @@ public class ShowPlayer extends ActionBarActivity {
|
||||||
input.requestFocus();
|
input.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToList (View view) { startActivity(new Intent(this, PowerEditor.class).putExtra("player", player.getName())); }
|
public void addToList (View view) {
|
||||||
|
startActivity(
|
||||||
|
new Intent(
|
||||||
|
this,
|
||||||
|
PowerEditor.class
|
||||||
|
)
|
||||||
|
.putExtra("player", player.getName())
|
||||||
|
.putExtra("power", -1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private void refreshList() {
|
private void refreshList() {
|
||||||
//TODO: check which is active (now there is only a power list), so there is only one possibility
|
//TODO: check which is active (now there is only a power list), so there is only one possibility
|
||||||
|
@ -480,12 +477,12 @@ public class ShowPlayer extends ActionBarActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
attackList.setAdapter(new AttackAdapter(this, powers));
|
attackList.setAdapter(new AttackAdapter(this, powers));
|
||||||
final Activity thisActivity = this;
|
|
||||||
attackList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
attackList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
|
||||||
final Dialog dialog = new Dialog(ShowPlayer.this);
|
final Dialog dialog = new Dialog(ShowPlayer.this);
|
||||||
|
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
dialog.setContentView(R.layout.attack_display);
|
dialog.setContentView(R.layout.attack_display);
|
||||||
// set the custom dialog components - text, image and button
|
// set the custom dialog components - text, image and button
|
||||||
// Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
|
// Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
|
||||||
|
@ -498,21 +495,10 @@ public class ShowPlayer extends ActionBarActivity {
|
||||||
// });
|
// });
|
||||||
|
|
||||||
//identify all the elements from the VIEW and then add LISTENERS
|
//identify all the elements from the VIEW and then add LISTENERS
|
||||||
Power power = (Power) parent.getItemAtPosition(position);
|
final Power power = (Power) parent.getItemAtPosition(position);
|
||||||
View nameText = dialog.findViewById(R.id.nameText);
|
View nameText = dialog.findViewById(R.id.nameText);
|
||||||
switch(power.getFreq()){
|
int color = power.getFreqColor(getApplicationContext());
|
||||||
case Power.A_VOLUNTAD:
|
nameText.setBackgroundColor(color);
|
||||||
nameText.setBackgroundColor(getResources().getColor(R.color.at_will));
|
|
||||||
break;
|
|
||||||
case Power.ENCUENTRO:
|
|
||||||
nameText.setBackgroundColor(getResources().getColor(R.color.encounter));
|
|
||||||
break;
|
|
||||||
case Power.DIARIO:
|
|
||||||
nameText.setBackgroundColor(getResources().getColor(R.color.daily));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
nameText.setBackgroundColor(getResources().getColor(R.color.green));
|
|
||||||
}
|
|
||||||
//TODO: fix the title gap
|
//TODO: fix the title gap
|
||||||
((TextView) nameText) .setText(power.getName());
|
((TextView) nameText) .setText(power.getName());
|
||||||
((TextView) dialog.findViewById(R.id.typeText)) .setText(power.getTypeString());
|
((TextView) dialog.findViewById(R.id.typeText)) .setText(power.getTypeString());
|
||||||
|
@ -521,43 +507,75 @@ public class ShowPlayer extends ActionBarActivity {
|
||||||
((TextView) dialog.findViewById(R.id.keywordsText)) .setText(power.getKeywords());
|
((TextView) dialog.findViewById(R.id.keywordsText)) .setText(power.getKeywords());
|
||||||
((TextView) dialog.findViewById(R.id.distanceText)) .setText(String.valueOf(power.getDistance()));
|
((TextView) dialog.findViewById(R.id.distanceText)) .setText(String.valueOf(power.getDistance()));
|
||||||
((TextView) dialog.findViewById(R.id.objectiveText)).setText(power.getObjective());
|
((TextView) dialog.findViewById(R.id.objectiveText)).setText(power.getObjective());
|
||||||
((TextView) dialog.findViewById(R.id.impactText)) .setText(power.getImpact());
|
((TextView) dialog.findViewById(R.id.impactText)).setText(power.getImpact());
|
||||||
((TextView) dialog.findViewById(R.id.otherText)) .setText(power.getOther());
|
((TextView) dialog.findViewById(R.id.otherText)) .setText(power.getOther());
|
||||||
|
|
||||||
String[] attack = getResources().getStringArray(R.array.attack_array);
|
String[] attack = getResources().getStringArray(R.array.attack_array);
|
||||||
String[] defense = getResources().getStringArray(R.array.defense_array);
|
String[] defense = getResources().getStringArray(R.array.defense_array);
|
||||||
//TODO: add attack and defense array
|
((TextView) dialog.findViewById(R.id.attackText)).setText(attack[power.getAtk()]
|
||||||
((TextView) dialog.findViewById(R.id.attackText)) .setText(attack[power.getAtk()]
|
|
||||||
+ " " + getResources().getString(R.string.vs)
|
+ " " + getResources().getString(R.string.vs)
|
||||||
+ " " + defense[power.getDef()]);
|
+ " " + defense[power.getDef()]);
|
||||||
|
|
||||||
dialog.findViewById(R.id.useButton).setOnClickListener(new View.OnClickListener() {
|
Button useButton = (Button) dialog.findViewById(R.id.useButton);
|
||||||
|
useButton.setBackgroundColor(color);
|
||||||
|
useButton.setTextColor(getResources().getColor(R.color.white));
|
||||||
|
useButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
//TODO: use power
|
//TODO: use power
|
||||||
Toast.makeText(getApplicationContext(), "Use it", Toast.LENGTH_LONG).show();
|
Toast.makeText(getApplicationContext(), "Power used!", Toast.LENGTH_LONG).show();
|
||||||
|
power.use();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.findViewById(R.id.deleteButton).setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
//TODO: delete power
|
|
||||||
Toast.makeText(getApplicationContext(), "Delete it", Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
dialog.findViewById(R.id.editButton).setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
//TODO: edit power
|
//TODO: edit power
|
||||||
Toast.makeText(getApplicationContext(), "Edit it", Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
final Activity thisActivity = this;
|
||||||
|
|
||||||
|
attackList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onItemLongClick(final AdapterView<?> parent, View view, final int position, long id) {
|
||||||
|
AlertDialog.Builder alert = new AlertDialog.Builder(thisActivity);
|
||||||
|
alert.setItems(new String[]{"Delete", "Edit"}, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
if ( which == 0 ) {
|
||||||
|
//delete the item
|
||||||
|
String name = p.getString("power" + position, "");
|
||||||
|
if (name != null && !name.isEmpty()) {
|
||||||
|
getSharedPreferences(name, MODE_PRIVATE).edit().clear().apply();
|
||||||
|
Log.d("Tag", thisActivity.getApplicationContext().getFilesDir().getParent()
|
||||||
|
+ File.separator + "shared_prefs" + File.separator + name + ".xml");
|
||||||
|
try {
|
||||||
|
if(!new File(thisActivity.getApplicationContext().getFilesDir().getParent()
|
||||||
|
+ File.separator + "shared_prefs" + File.separator + name + ".xml").delete())
|
||||||
|
throw new Exception();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Toast.makeText(getApplicationContext(), "Error deleting attack files", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
int max = p.getInt("powers", 0);
|
||||||
|
SharedPreferences.Editor ed = p.edit();
|
||||||
|
for (int i = position; i < max - 1; i++)
|
||||||
|
ed.putString("power" + i, p.getString("power" + (i + 1), "max"));
|
||||||
|
ed.putInt("powers", max - 1).apply();
|
||||||
|
refreshList();
|
||||||
|
ed.remove("power" + (max - 1)).apply();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//edit the item
|
||||||
|
startActivity(
|
||||||
|
new Intent(getApplicationContext(), PowerEditor.class)
|
||||||
|
.putExtra("power", position)
|
||||||
|
.putExtra("player", player.getName())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
alert.show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,6 +5,8 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<!--TODO: organize the input similarly to the output-->
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<android.support.v7.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:minHeight="?attr/actionBarSize"
|
android:minHeight="?attr/actionBarSize"
|
||||||
|
@ -28,7 +30,6 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/nameEdit"
|
android:id="@+id/nameEdit"
|
||||||
android:capitalize="words"
|
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
|
@ -40,7 +41,6 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/keywordsEdit"
|
android:id="@+id/keywordsEdit"
|
||||||
android:capitalize="words"
|
|
||||||
android:layout_below="@+id/nameEdit"
|
android:layout_below="@+id/nameEdit"
|
||||||
android:layout_alignRight="@+id/nameEdit"
|
android:layout_alignRight="@+id/nameEdit"
|
||||||
android:layout_alignEnd="@+id/nameEdit"
|
android:layout_alignEnd="@+id/nameEdit"
|
||||||
|
@ -190,7 +190,6 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/objectiveEdit"
|
android:id="@+id/objectiveEdit"
|
||||||
android:capitalize="words"
|
|
||||||
android:hint="@string/objectiveHint"
|
android:hint="@string/objectiveHint"
|
||||||
android:layout_below="@+id/actionTypeSpinner"
|
android:layout_below="@+id/actionTypeSpinner"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
|
|
|
@ -192,7 +192,7 @@
|
||||||
android:id="@+id/listSelectButton"
|
android:id="@+id/listSelectButton"
|
||||||
android:textColor="@color/primary"
|
android:textColor="@color/primary"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
tools:text="Go to abilities"/>
|
android:text="Go to abilities"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/at_will"
|
android:background="@color/encounter"
|
||||||
android:paddingTop="5dp"
|
android:paddingTop="5dp"
|
||||||
android:paddingBottom="5dp"
|
android:paddingBottom="5dp"
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
|
@ -160,34 +160,44 @@
|
||||||
android:layout_below="@+id/impact"
|
android:layout_below="@+id/impact"
|
||||||
tools:text="If you are reading this the description has been displayed"
|
tools:text="If you are reading this the description has been displayed"
|
||||||
android:layout_alignParentLeft="true"/>
|
android:layout_alignParentLeft="true"/>
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/otherText">
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Use"
|
android:text="Use"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:layout_weight="1"
|
android:textStyle="bold"
|
||||||
android:id="@+id/useButton" />
|
android:id="@+id/useButton"
|
||||||
|
android:layout_below="@+id/linearLayout"
|
||||||
<Button
|
android:layout_alignParentRight="true"
|
||||||
android:layout_width="wrap_content"
|
android:layout_alignParentEnd="true" />
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/delete"
|
android:layout_below="@+id/otherText"
|
||||||
android:layout_weight="1"
|
android:id="@+id/linearLayout">
|
||||||
android:background="@android:color/transparent"
|
|
||||||
android:id="@+id/deleteButton" />
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/edit"
|
android:text="@string/edit"
|
||||||
|
android:visibility="gone"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:textStyle="bold"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:id="@+id/editButton" />
|
android:id="@+id/editButton" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/delete"
|
||||||
|
android:textColor="#ff0000"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:id="@+id/deleteButton" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -1,14 +1,17 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout 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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
tools:background="@color/at_will">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
tools:text="Happiness"
|
tools:text="Happiness"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
android:id="@+id/name" />
|
android:id="@+id/name" />
|
||||||
|
|
||||||
|
@ -18,6 +21,7 @@
|
||||||
tools:text="Melee 1"
|
tools:text="Melee 1"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:id="@+id/extra"
|
android:id="@+id/extra"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
android:layout_below="@+id/name"
|
android:layout_below="@+id/name"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_alignParentStart="true" />
|
android:layout_alignParentStart="true" />
|
||||||
|
@ -28,6 +32,7 @@
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:id="@+id/keywords"
|
android:id="@+id/keywords"
|
||||||
tools:text="(fire, explosion)"
|
tools:text="(fire, explosion)"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:layout_alignBottom="@id/extra"
|
android:layout_alignBottom="@id/extra"
|
||||||
android:layout_toRightOf="@+id/extra"
|
android:layout_toRightOf="@+id/extra"
|
||||||
|
@ -38,6 +43,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:id="@+id/frequency"
|
android:id="@+id/frequency"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
android:layout_alignBottom="@+id/name"
|
android:layout_alignBottom="@+id/name"
|
||||||
android:layout_toRightOf="@+id/name"
|
android:layout_toRightOf="@+id/name"
|
||||||
android:layout_toEndOf="@+id/name"
|
android:layout_toEndOf="@+id/name"
|
||||||
|
|
Reference in a new issue