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>
<activity <activity
android:name=".Introduction" android:name=".Introduction"
android:parentActivityName=".MainActivity"
android:label="@string/title_activity_introduction" > android:label="@string/title_activity_introduction" >
<meta-data <!--android:parentActivityName=".MainActivity"-->
android:name="android.support.PARENT_ACTIVITY" <!--<meta-data-->
android:value=".MainActivity" /> <!--android:name="android.support.PARENT_ACTIVITY"-->
<!--android:value=".MainActivity" />-->
</activity> </activity>
</application> </application>

View file

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

View file

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

View file

@ -252,8 +252,4 @@ public class Player {
public static int getModifier(int i) { public static int getModifier(int i) {
return i / 2 - 5; 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:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.ddns.kauron.com.kauron.dungeonmanager.Introduction"> tools:context=".Introduction">
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -15,20 +15,25 @@
<EditText <EditText
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="textPersonName" android:inputType="textPersonName|textCapWords"
android:ems="10"
android:layout_weight="0.5" android:layout_weight="0.5"
android:id="@+id/editNameIntro" android:id="@+id/editNameIntro"
android:hint="@string/adventurer_name"/> android:hint="@string/adventurer_name"
android:nextFocusDown="@+id/editPxIntro"
android:nextFocusForward="@+id/editPxIntro"/>
<EditText <EditText
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="number" android:inputType="number"
android:ems="10"
android:id="@+id/editPxIntro" android:id="@+id/editPxIntro"
android:hint="@string/px" 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>
<LinearLayout <LinearLayout
@ -48,8 +53,7 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:id="@+id/raceSpinner" android:id="@+id/raceSpinner"/>
android:layout_alignTop="@+id/classSpinner" />
</LinearLayout> </LinearLayout>
<GridLayout <GridLayout
@ -68,7 +72,8 @@
android:layout_column="0" android:layout_column="0"
android:id="@+id/FUE" android:id="@+id/FUE"
android:hint="@string/FUE" /> android:hint="@string/FUE"
android:nextFocusDown="@+id/DES"/>
<EditText <EditText
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -80,7 +85,8 @@
android:layout_column="0" android:layout_column="0"
android:id="@+id/CON" android:id="@+id/CON"
android:hint="@string/CON" /> android:hint="@string/CON"
android:nextFocusDown="@+id/INT" />
<EditText <EditText
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -92,7 +98,8 @@
android:layout_column="1" android:layout_column="1"
android:id="@+id/DES" android:id="@+id/DES"
android:hint="@string/DES" /> android:hint="@string/DES"
android:nextFocusDown="@+id/SAB"/>
<EditText <EditText
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -104,7 +111,8 @@
android:layout_column="1" android:layout_column="1"
android:id="@+id/INT" android:id="@+id/INT"
android:hint="@string/INT" /> android:hint="@string/INT"
android:nextFocusDown="@+id/CAR"/>
<EditText <EditText
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -116,19 +124,21 @@
android:layout_column="2" android:layout_column="2"
android:id="@+id/SAB" android:id="@+id/SAB"
android:hint="@string/SAB" /> android:hint="@string/SAB"
android:nextFocusDown="@+id/CON"/>
<EditText <EditText
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="number" android:inputType="number"
android:ems="3" android:ems="3"
android:imeOptions="actionDone"
android:layout_row="1" android:layout_row="1"
android:layout_column="2" android:layout_column="2"
android:id="@+id/CAR" android:id="@+id/CAR"
android:hint="@string/CAR" /> android:hint="@string/CAR"/>
</GridLayout> </GridLayout>
</RelativeLayout> </RelativeLayout>

View file

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

View file

@ -13,7 +13,6 @@
<string name="VOL">VOL</string> <string name="VOL">VOL</string>
<string name="defense">Defense</string> <string name="defense">Defense</string>
<string name="curative_efforts">Curative efforts</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="action_reset">Reset</string>
<string name="message_reset">All the data has been cleared</string> <string name="message_reset">All the data has been cleared</string>
<string name="reset_confirmation_title">Are you sure?</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_title">Alert</string>
<string name="dialog_resolve_max_pg_message">Couldn\'t compute your max PG based on your level</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="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> </resources>