1
0
Fork 0

Improved layouts

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

View file

@ -18,11 +18,11 @@
</activity>
<activity
android:name=".Introduction"
android:parentActivityName=".MainActivity"
android:label="@string/title_activity_introduction" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
<!--android:parentActivityName=".MainActivity"-->
<!--<meta-data-->
<!--android:name="android.support.PARENT_ACTIVITY"-->
<!--android:value=".MainActivity" />-->
</activity>
</application>

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

View file

@ -4,7 +4,7 @@
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.ddns.kauron.com.kauron.dungeonmanager.Introduction">
tools:context=".Introduction">
<LinearLayout
android:layout_width="fill_parent"
@ -15,20 +15,25 @@
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:inputType="textPersonName|textCapWords"
android:layout_weight="0.5"
android:id="@+id/editNameIntro"
android:hint="@string/adventurer_name"/>
android:hint="@string/adventurer_name"
android:nextFocusDown="@+id/editPxIntro"
android:nextFocusForward="@+id/editPxIntro"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="@+id/editPxIntro"
android:hint="@string/px"
android:layout_weight="1"/>
android:layout_weight="1"
android:nextFocusDown="@+id/FUE"
android:nextFocusForward="@+id/FUE"
android:nextFocusLeft="@+id/FUE"
android:nextFocusRight="@+id/FUE"
android:nextFocusUp="@+id/FUE"/>
</LinearLayout>
<LinearLayout
@ -48,8 +53,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/raceSpinner"
android:layout_alignTop="@+id/classSpinner" />
android:id="@+id/raceSpinner"/>
</LinearLayout>
<GridLayout
@ -68,7 +72,8 @@
android:layout_column="0"
android:id="@+id/FUE"
android:hint="@string/FUE" />
android:hint="@string/FUE"
android:nextFocusDown="@+id/DES"/>
<EditText
android:layout_width="wrap_content"
@ -80,7 +85,8 @@
android:layout_column="0"
android:id="@+id/CON"
android:hint="@string/CON" />
android:hint="@string/CON"
android:nextFocusDown="@+id/INT" />
<EditText
android:layout_width="wrap_content"
@ -92,7 +98,8 @@
android:layout_column="1"
android:id="@+id/DES"
android:hint="@string/DES" />
android:hint="@string/DES"
android:nextFocusDown="@+id/SAB"/>
<EditText
android:layout_width="wrap_content"
@ -104,7 +111,8 @@
android:layout_column="1"
android:id="@+id/INT"
android:hint="@string/INT" />
android:hint="@string/INT"
android:nextFocusDown="@+id/CAR"/>
<EditText
android:layout_width="wrap_content"
@ -116,13 +124,15 @@
android:layout_column="2"
android:id="@+id/SAB"
android:hint="@string/SAB" />
android:hint="@string/SAB"
android:nextFocusDown="@+id/CON"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="3"
android:imeOptions="actionDone"
android:layout_row="1"
android:layout_column="2"

View file

@ -93,20 +93,36 @@
</HorizontalScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/titlePgBar"
android:text="@string/pg"
android:textAllCaps="true"
android:drawableBottom="?android:attr/listChoiceBackgroundIndicator"
android:layout_marginBottom="5dp"
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
android:gravity="center_vertical"
android:paddingLeft="8dip"
android:paddingRight="8dip"/>
android:paddingRight="8dip"
android:layout_weight="1"/>
<!--TODO: USE this-->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:id="@+id/currentPg"
android:textSize="14sp"
android:textStyle="bold"
android:textAllCaps="true"
android:layout_weight="1"/>
</LinearLayout>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
@ -114,26 +130,33 @@
android:layout_height="wrap_content"
android:id="@+id/pgBar"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/titleCurativeEffortsBar"
android:text="@string/curative_efforts"
android:textAllCaps="true"
android:drawableBottom="?android:attr/listChoiceBackgroundIndicator"
android:layout_marginBottom="5dp"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
android:gravity="center_vertical"
android:paddingLeft="8dip"
android:paddingRight="8dip"/>
<TextView
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/curativeEffortsText"/>
android:textSize="14sp"
android:textStyle="bold"
android:gravity="right"
android:id="@+id/currentCurativeEfforts"
android:textAllCaps="true"/>
</LinearLayout>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
@ -141,20 +164,36 @@
android:layout_height="wrap_content"
android:id="@+id/curativeEffortsBar"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/titleXpBar"
android:text="@string/px"
android:textAllCaps="true"
android:drawableBottom="?android:attr/listChoiceBackgroundIndicator"
android:layout_marginBottom="5dp"
android:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
android:gravity="center_vertical"
android:paddingLeft="8dip"
android:paddingRight="8dip"/>
android:paddingRight="8dip"
android:layout_weight="1"/>
<!--TODO: USE this-->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:id="@+id/currentXp"
android:textSize="14sp"
android:textStyle="bold"
android:textAllCaps="true"
android:layout_weight="1"/>
</LinearLayout>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"

View file

@ -13,7 +13,6 @@
<string name="VOL">VOL</string>
<string name="defense">Defense</string>
<string name="curative_efforts">Curative efforts</string>
<string name="curative_display_text">You have %1$d out of %2$d curative efforts</string>
<string name="action_reset">Reset</string>
<string name="message_reset">All the data has been cleared</string>
<string name="reset_confirmation_title">Are you sure?</string>
@ -72,4 +71,5 @@
<string name="dialog_resolve_max_pg_title">Alert</string>
<string name="dialog_resolve_max_pg_message">Couldn\'t compute your max PG based on your level</string>
<string name="action_download">Update app</string>
<string name="message_no_back_button_intro">You can\'t go back. Fill the information and press the save button.</string>
</resources>