Skip to content

Commit

Permalink
Get rid of those gad-awful buttons, replace with ActionBar
Browse files Browse the repository at this point in the history
Fixes #21
Adresses #16
  • Loading branch information
DerekV committed Oct 25, 2013
1 parent 7bf01c7 commit 82918f2
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 79 deletions.
3 changes: 2 additions & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

<application
android:icon="@drawable/logo"
android:label="@string/app_name" >
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo">
<activity
android:name=".BookmarkListActivity"
android:label="@string/app_name">
Expand Down
51 changes: 5 additions & 46 deletions res/layout/main.xml
Original file line number Diff line number Diff line change
@@ -1,47 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.97" >
</ListView>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/TabbishButtonHeight"
android:gravity="right" >

<Button
android:id="@+id/newestGlobalButton"
android:layout_width="wrap_content"
android:layout_height="@dimen/TabbishButtonHeight"
android:layout_margin="@dimen/TabbishButtonMargin"
android:minWidth="@dimen/TabbishButtonMinWidth"
android:textSize="@dimen/TabbishButtonFontSize"
android:text="@string/button_newest_global_text"/>

<Button
android:id="@+id/newestUserButton"
android:layout_width="wrap_content"
android:layout_height="@dimen/TabbishButtonHeight"
android:layout_margin="@dimen/TabbishButtonMargin"
android:minWidth="@dimen/TabbishButtonMinWidth"
android:textSize="@dimen/TabbishButtonFontSize"
android:text="@string/button_newest_user_text" />

<Button
android:id="@+id/settingsButton"
android:layout_width="wrap_content"
android:layout_height="@dimen/TabbishButtonHeight"
android:layout_margin="@dimen/TabbishButtonMargin"
android:minWidth="@dimen/TabbishButtonMinWidth"
android:textSize="@dimen/TabbishButtonFontSize"
android:text="@string/button_settings_text" />
</LinearLayout>

</LinearLayout>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
12 changes: 12 additions & 0 deletions res/menu/main_activity_actions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>

<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/action_everyones_recent"
android:title="@string/button_newest_global_text"
android:showAsAction="ifRoom"/>
<item android:id="@+id/action_recent"
android:title="@string/button_newest_user_text"
android:showAsAction="ifRoom"/>
<item android:id="@+id/action_settings"
android:title="@string/button_settings_text" />
</menu>
60 changes: 28 additions & 32 deletions src/main/java/us/bmark/android/BookmarkListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
Expand All @@ -39,6 +40,7 @@ public class BookmarkListActivity extends ListActivity {

private BookieService service;
private UserSettings settings;
private ListView listView;

private class BookmarkArrayAdapter extends ArrayAdapter<Bookmark> {

Expand Down Expand Up @@ -74,13 +76,18 @@ public void onCreate(Bundle savedInstanceState) {
settings = new SharedPrefsBackedUserSettings(this);
setUpService();
setContentView(R.layout.main);
setUpSettingsButton();
setUpNewestGlobalButton();
setUpNewestUserButton();
refreshWithNewestGlobal();
setUpListView();
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_activity_actions, menu);
return super.onCreateOptionsMenu(menu);
}

private void setUpService() {
String serverUrl = settings.getBaseUrl();
RestAdapter adapter = new RestAdapter.Builder()
Expand Down Expand Up @@ -177,41 +184,30 @@ public boolean onItemLongClick(AdapterView<?> parent, View view,
});
}

private void setUpSettingsButton() {
Button settingsButton = (Button) findViewById(R.id.settingsButton);

settingsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch( item.getItemId() ) {
case R.id.action_everyones_recent:
Log.v("bmark", "glabal bttn clicked");
refreshWithNewestGlobal();
return true;
case R.id.action_recent:
Log.v("bmark", "user bttn clicked");
refreshWithNewestUser();
return true;
case R.id.action_settings:
Intent settingsIntent =
new Intent(BookmarkListActivity.this, SettingsActivity.class);
BookmarkListActivity.this.startActivity(settingsIntent);
}
});
}
return true;
default:
return super.onOptionsItemSelected(item);
}

private void setUpNewestGlobalButton() {
Button newestGlobalButton = (Button) findViewById(R.id.newestGlobalButton);
newestGlobalButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {

Log.v("bmark", "glabal bttn clicked");
refreshWithNewestGlobal();
}
});
}

private void setUpNewestUserButton() {
Button newestUserButton = (Button) findViewById(R.id.newestUserButton);
newestUserButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.v("bmark", "user bttn clicked");
refreshWithNewestUser();
}
});
}


}

0 comments on commit 82918f2

Please sign in to comment.