1
0
Fork 0

Improved layouts

This commit is contained in:
Carlos Galindo 2015-02-26 22:09:08 +01:00
commit 35c8db2c10
7 changed files with 146 additions and 111 deletions

View file

@ -20,19 +20,19 @@ public class Introduction extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(com.kauron.dungeonmanager.R.layout.activity_introduction);
name = (EditText) findViewById(com.kauron.dungeonmanager.R.id.editNameIntro);
level = (EditText) findViewById(com.kauron.dungeonmanager.R.id.editPxIntro);
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.activity_introduction);
name = (EditText) findViewById(R.id.editNameIntro);
name.requestFocus();
level = (EditText) findViewById(R.id.editPxIntro);
fue = (EditText) findViewById(R.id.FUE);
con = (EditText) findViewById(R.id.CON);
des = (EditText) findViewById(R.id.DES);
sab = (EditText) findViewById(R.id.SAB);
intel = (EditText) findViewById(R.id.INT);
car = (EditText) findViewById(R.id.CAR);
fue = (EditText) findViewById(com.kauron.dungeonmanager.R.id.FUE);
con = (EditText) findViewById(com.kauron.dungeonmanager.R.id.CON);
des = (EditText) findViewById(com.kauron.dungeonmanager.R.id.DES);
sab = (EditText) findViewById(com.kauron.dungeonmanager.R.id.SAB);
intel = (EditText) findViewById(com.kauron.dungeonmanager.R.id.INT);
car = (EditText) findViewById(com.kauron.dungeonmanager.R.id.CAR);
classSpinner = (Spinner) findViewById(com.kauron.dungeonmanager.R.id.classSpinner);
classSpinner = (Spinner) findViewById(R.id.classSpinner);
classSpinner.setAdapter(
new ArrayAdapter<>(
this,
@ -41,7 +41,7 @@ public class Introduction extends ActionBarActivity {
)
);
raceSpinner = (Spinner) findViewById(com.kauron.dungeonmanager.R.id.raceSpinner);
raceSpinner = (Spinner) findViewById(R.id.raceSpinner);
raceSpinner.setAdapter(
new ArrayAdapter<>(
this,
@ -55,10 +55,19 @@ public class Introduction extends ActionBarActivity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(com.kauron.dungeonmanager.R.menu.menu_introduction, menu);
getMenuInflater().inflate(R.menu.menu_introduction, menu);
return true;
}
@Override
public void onBackPressed() {
Toast.makeText(
getApplicationContext(),
R.string.message_no_back_button_intro,
Toast.LENGTH_LONG
).show();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
@ -67,13 +76,13 @@ public class Introduction extends ActionBarActivity {
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == com.kauron.dungeonmanager.R.id.action_save) {
if (id == R.id.action_save) {
if(finished()) {
this.finish();
} else {
Toast.makeText(
getApplicationContext(),
com.kauron.dungeonmanager.R.string.missing_info_error,
R.string.missing_info_error,
Toast.LENGTH_LONG
).show();
}

View file

@ -9,7 +9,6 @@ import android.graphics.PorterDuff;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.text.InputType;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@ -100,6 +99,7 @@ public class MainActivity extends ActionBarActivity{
Toast.LENGTH_LONG
).show();
getSharedPreferences("basics", MODE_PRIVATE).edit().clear().apply();
player = null;
restoreData();
}
});
@ -155,6 +155,7 @@ public class MainActivity extends ActionBarActivity{
}
});
alert.show();
input.requestFocus();
return true;
} else if (id == R.id.action_download) {
//TODO: create self-updater
@ -395,8 +396,8 @@ public class MainActivity extends ActionBarActivity{
((ProgressBar) findViewById(R.id.xpBar))
.setProgress(player.getPx() - Player.LEVEL_PX[player.getLevel() - 1]);
ProgressBar curativeEffortsBar = (ProgressBar) findViewById(R.id.curativeEffortsBar);
curativeEffortsBar.setProgress(player.getCurativeEfforts());
curativeEffortsBar.setMax(player.getMaxCurativeEfforts());
curativeEffortsBar.setProgress(player.getCurativeEfforts());
healthStatusCheck();
updateCurativeString();
//set restored values to the respective fields
@ -443,12 +444,9 @@ public class MainActivity extends ActionBarActivity{
}
private void updateCurativeString() {
((TextView) findViewById(R.id.curativeEffortsText)).setText(
getString(
R.string.curative_display_text,
player.getCurativeEfforts(),
player.getMaxCurativeEfforts()
)
((TextView) findViewById(R.id.currentCurativeEfforts)).setText(
player.getCurativeEfforts() + " / " +
player.getMaxCurativeEfforts()
);
}
@ -480,24 +478,6 @@ public class MainActivity extends ActionBarActivity{
input.setHint(R.string.dialog_resolve_max_pg_hint);
input.setInputType(InputType.TYPE_CLASS_NUMBER);
input.setImeOptions(EditorInfo.IME_ACTION_DONE);
input.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.FLAG_EDITOR_ACTION) {
if (input.getText().toString().isEmpty()){
Toast.makeText(
getApplicationContext(),
R.string.empty_field,
Toast.LENGTH_LONG
).show();
pgDialog();
} else {
player.setMaxPg(Integer.parseInt(input.getText().toString()));
}
}
return false;
}
});
dialog
.setView(input)
.setCancelable(false)
@ -519,10 +499,11 @@ public class MainActivity extends ActionBarActivity{
}
});
dialog.show();
input.requestFocus();
}
//TODO: show on screen the max pg's
//TODO: show in the bars the max and current values
//TODO: create secondary thread to move slower the value of the
//TODO: show the current px and progress bar
//TODO: create secondary thread to move slower the value of the progressBar
}

View file

@ -252,8 +252,4 @@ public class Player {
public static int getModifier(int i) {
return i / 2 - 5;
}
public int getTotalModifier(int i) {
return getModifier(i) + level / 2;
}
}