diff --git a/res/layout/add.xml b/res/layout/add.xml
index 22430f3..4ca4627 100644
--- a/res/layout/add.xml
+++ b/res/layout/add.xml
@@ -20,11 +20,4 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/watched_entry" />
-
-
diff --git a/res/layout/main.xml b/res/layout/main.xml
index 925b362..42e5b78 100644
--- a/res/layout/main.xml
+++ b/res/layout/main.xml
@@ -3,13 +3,6 @@
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
-
-
+
diff --git a/res/menu/main_activity.xml b/res/menu/main_activity.xml
new file mode 100644
index 0000000..ce1512b
--- /dev/null
+++ b/res/menu/main_activity.xml
@@ -0,0 +1,6 @@
+
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 40f4d6e..dc3e703 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4,6 +4,6 @@
Title...
On wishlist
Watched
- Add
- Save
+ Add
+ Save
diff --git a/src/ryuslash/org/dvdroid/AddDVDActivity.java b/src/ryuslash/org/dvdroid/AddDVDActivity.java
index f6612f7..d25affd 100644
--- a/src/ryuslash/org/dvdroid/AddDVDActivity.java
+++ b/src/ryuslash/org/dvdroid/AddDVDActivity.java
@@ -3,6 +3,9 @@ package ryuslash.org.dvdroid;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
@@ -21,7 +24,7 @@ public class AddDVDActivity extends Activity
datasource.open();
}
- public void saveDVD(View view)
+ public void createDVD()
{
EditText name_entry = (EditText)findViewById(R.id.name_entry);
CheckBox watched_entry =
@@ -32,8 +35,6 @@ public class AddDVDActivity extends Activity
datasource.createDVD(name_entry.getText().toString(),
watched_entry.isChecked() ? 1 : 0,
wishlist_entry.isChecked() ? 1 : 0);
-
- finish();
}
@Override
@@ -56,4 +57,25 @@ public class AddDVDActivity extends Activity
datasource.close();
super.onDestroy();
}
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu)
+ {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.add_activity, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+ switch (item.getItemId()) {
+ case R.id.add_menu_save:
+ createDVD();
+ finish();
+ return true;
+ }
+
+ return false;
+ }
}
diff --git a/src/ryuslash/org/dvdroid/DVDroidActivity.java b/src/ryuslash/org/dvdroid/DVDroidActivity.java
index 613620c..e510a7b 100644
--- a/src/ryuslash/org/dvdroid/DVDroidActivity.java
+++ b/src/ryuslash/org/dvdroid/DVDroidActivity.java
@@ -6,6 +6,9 @@ import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
@@ -15,14 +18,6 @@ public class DVDroidActivity extends ListActivity
{
private DVDDataSource datasource;
- public void addDVD(View view)
- {
- Intent intent = new Intent(this, AddDVDActivity.class);
-
- datasource.close();
- startActivityForResult(intent, 1);
- }
-
@Override
protected void onActivityResult(int requestCode,
int resultCode,
@@ -58,6 +53,26 @@ public class DVDroidActivity extends ListActivity
setListAdapter(adapter);
}
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu)
+ {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.main_activity, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+ switch (item.getItemId()) {
+ case R.id.main_menu_add:
+ showAddDVD();
+ return true;
+ }
+
+ return false;
+ }
+
@Override
protected void onPause()
{
@@ -71,4 +86,12 @@ public class DVDroidActivity extends ListActivity
datasource.open();
super.onResume();
}
+
+ public void showAddDVD()
+ {
+ Intent intent = new Intent(this, AddDVDActivity.class);
+
+ datasource.close();
+ startActivityForResult(intent, 1);
+ }
}