PowerEditor: rearranged screen and moved Save button to ActionBar
This commit is contained in:
parent
34b6e52b9f
commit
172d969370
3 changed files with 61 additions and 41 deletions
|
@ -7,7 +7,8 @@ import android.graphics.drawable.Drawable;
|
|||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
|
@ -52,6 +53,7 @@ public class PowerEditor extends ActionBarActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_power_editor);
|
||||
//identify toolbar, set it as ActionBar and add the back button to the last activity
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true);
|
||||
|
@ -123,7 +125,7 @@ public class PowerEditor extends ActionBarActivity {
|
|||
|
||||
}
|
||||
|
||||
public void saveClick(View view) {
|
||||
public void save() {
|
||||
boolean readyToSave = true;
|
||||
|
||||
for ( int i = 0; i < edits.length; i++ ) {
|
||||
|
@ -175,4 +177,22 @@ public class PowerEditor extends ActionBarActivity {
|
|||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.action_save) {
|
||||
save();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_power_editor, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,23 +81,35 @@
|
|||
android:layout_marginRight="10dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/keywordsEdit"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:id="@+id/spinnersLayout">
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/spinnersLayout"
|
||||
android:layout_below="@+id/keywordsEdit">
|
||||
|
||||
<Spinner
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/freqSpinner"
|
||||
android:layout_weight="1"
|
||||
android:spinnerMode="dropdown" />
|
||||
<Spinner
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/actionSpinner"
|
||||
android:layout_weight="1"
|
||||
android:spinnerMode="dropdown" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/distanceLayout"
|
||||
android:layout_below="@+id/spinnersLayout">
|
||||
|
||||
<Spinner
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/rangeSpinner"
|
||||
android:layout_weight="1"
|
||||
|
@ -109,7 +121,7 @@
|
|||
android:inputType="textCapSentences"
|
||||
android:ems="10"
|
||||
android:id="@+id/distanceNumEdit"
|
||||
android:layout_weight="0.75"
|
||||
android:layout_weight="1"
|
||||
android:hint="@string/number10"
|
||||
android:focusableInTouchMode="true" />
|
||||
</LinearLayout>
|
||||
|
@ -117,28 +129,32 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/spinnersLayout"
|
||||
android:layout_below="@+id/objectiveEdit"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center"
|
||||
android:id="@+id/vsLayout">
|
||||
<Spinner
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/atkSpinner"
|
||||
android:spinnerMode="dropdown" />
|
||||
android:spinnerMode="dropdown"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/vs"
|
||||
android:id="@+id/vsText" />
|
||||
android:id="@+id/vsText"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center" />
|
||||
|
||||
<Spinner
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/defSpinner"
|
||||
android:spinnerMode="dropdown" />
|
||||
android:spinnerMode="dropdown"
|
||||
android:layout_weight="1" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -170,15 +186,6 @@
|
|||
android:layout_alignBottom="@+id/impactEdit"
|
||||
android:layout_marginRight="10dp" />
|
||||
|
||||
<Spinner
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/actionSpinner"
|
||||
android:layout_below="@+id/impactEdit"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:spinnerMode="dropdown" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -186,7 +193,7 @@
|
|||
android:text="@string/objective"
|
||||
android:id="@+id/objectiveText"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_below="@+id/actionSpinner"
|
||||
android:layout_below="@+id/distanceLayout"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginRight="10dp"
|
||||
|
@ -197,25 +204,14 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:id="@+id/objectiveEdit"
|
||||
android:hint="@string/objectiveHint"
|
||||
android:layout_below="@+id/actionSpinner"
|
||||
android:layout_below="@+id/distanceLayout"
|
||||
android:layout_alignParentRight="true"
|
||||
android:capitalize="sentences"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_toRightOf="@+id/objectiveText"
|
||||
android:layout_toEndOf="@+id/objectiveText" />
|
||||
|
||||
<Button
|
||||
style="?android:attr/buttonStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/save"
|
||||
android:id="@+id/saveButton"
|
||||
android:layout_below="@+id/objectiveEdit"
|
||||
android:layout_alignRight="@+id/impactEdit"
|
||||
android:layout_alignEnd="@+id/impactEdit"
|
||||
android:background="@android:color/transparent"
|
||||
android:onClick="saveClick"
|
||||
android:textColor="@color/primary_dark"/>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
</ScrollView>
|
||||
|
|
|
@ -2,4 +2,8 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.kauron.dungeonmanager.PowerEditor">
|
||||
<item
|
||||
android:id="@+id/action_save"
|
||||
android:title="@string/save"
|
||||
app:showAsAction="always"/>
|
||||
</menu>
|
||||
|
|
Reference in a new issue