Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added a action bar.
  • Loading branch information
johannilsson committed Dec 21, 2010
1 parent 2d2961e commit 22ae891
Show file tree
Hide file tree
Showing 21 changed files with 183 additions and 24 deletions.
3 changes: 2 additions & 1 deletion .classpath
Expand Up @@ -4,6 +4,7 @@
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="lib/android-integration.jar"/>
<classpathentry kind="lib" path="lib/imageloader.jar"/>
<classpathentry kind="lib" path="lib/imageloader.jar"/>
<classpathentry kind="src" path="actionbar-widget_src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
7 changes: 7 additions & 0 deletions .project
Expand Up @@ -30,4 +30,11 @@
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<linkedResources>
<link>
<name>actionbar-widget_src</name>
<type>2</type>
<locationURI>_android_actionbar_widget/src</locationURI>
</link>
</linkedResources>
</projectDescription>
10 changes: 5 additions & 5 deletions AndroidManifest.xml
Expand Up @@ -13,7 +13,7 @@
android:value=".activity.SearchResultActivity" />
<activity android:label="@string/app_name"
android:name=".activity.StartActivity"
android:theme="@android:style/Theme.Light"
android:theme="@android:style/Theme.Light.NoTitleBar"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -22,7 +22,7 @@
</activity>
<activity android:label="@string/search_results"
android:name=".activity.SearchResultActivity"
android:theme="@android:style/Theme.Light">
android:theme="@android:style/Theme.Light.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="com.markupartist.iglaset.action.USER_RECOMMENDATIONS" />
Expand All @@ -45,15 +45,15 @@
android:authorities="com.markupartist.iglaset.activity.SuggestionProvider" />

<activity android:name=".activity.DrinkDetailActivity"
android:theme="@android:style/Theme.Light">
android:theme="@android:style/Theme.Light.NoTitleBar">
</activity>

<activity android:name=".activity.CategoryActivity"
android:theme="@android:style/Theme.Light">
android:theme="@android:style/Theme.Light.NoTitleBar">
</activity>

<activity android:name=".activity.TagActivity"
android:theme="@android:style/Theme.Light">
android:theme="@android:style/Theme.Light.NoTitleBar">
</activity>

<activity android:name=".activity.BasicPreferenceActivity"
Expand Down
1 change: 1 addition & 0 deletions default.properties
Expand Up @@ -11,3 +11,4 @@
split.density=false
# Project target.
target=android-8
android.library.reference.1=../../projects/actionbarwidget/actionbar/
Binary file added res/drawable-hdpi/ic_actionbar_home_default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/ic_actionbar_search_default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/logo_top.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions res/drawable/header_background.xml
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 Johan Nilsson <http://markupartist.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#E3E3E3"
android:endColor="#FFFFFF"
android:angle="-90" />
</shape>
4 changes: 4 additions & 0 deletions res/layout/category_list.xml
Expand Up @@ -4,6 +4,10 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.markupartist.android.widget.ActionBar
android:id="@+id/actionbar"
style="@style/ActionBar"
/>
<ListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
Expand Down
5 changes: 4 additions & 1 deletion res/layout/drink_details.xml
Expand Up @@ -3,7 +3,6 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
Expand All @@ -12,6 +11,10 @@
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:id="@+id/drink_detail_layout">
<com.markupartist.android.widget.ActionBar
android:id="@+id/actionbar"
style="@style/ActionBar"
/>
<include layout="@layout/drink_detail" />
</LinearLayout>
<ListView
Expand Down
8 changes: 6 additions & 2 deletions res/layout/header.xml
Expand Up @@ -2,6 +2,10 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="3dip"
android:padding="5dip"
android:textStyle="bold"
android:background="@color/header_background" />
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="sdsds"
android:background="@color/header_background"
/>
<!-- android:background="@drawable/header_background" -->
15 changes: 15 additions & 0 deletions res/layout/search_result.xml
Expand Up @@ -4,6 +4,21 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.markupartist.android.widget.ActionBar
android:id="@+id/actionbar"
style="@style/ActionBar"
/>
<TextView
android:layout_height="wrap_content"
android:id="@+id/tagSearchSelectedText"
android:background="#FEF5CA"
android:textColor="?android:attr/textColorPrimary"
android:textAppearance="?android:attr/textAppearanceSmall"
android:padding="5dip"
android:layout_width="fill_parent"
android:text="@string/no_selected_tags"
android:visibility="gone"
/>
<include layout="@layout/progress_bar" />
<ListView
android:id="@+id/android:list"
Expand Down
12 changes: 11 additions & 1 deletion res/layout/start.xml
@@ -1,6 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.markupartist.android.widget.ActionBar
android:id="@+id/actionbar"
style="@style/ActionBar"
/>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/start_bg"
Expand Down Expand Up @@ -170,3 +179,4 @@
</TableLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
5 changes: 4 additions & 1 deletion res/layout/tag_list.xml
Expand Up @@ -3,7 +3,10 @@
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<com.markupartist.android.widget.ActionBar
android:id="@+id/actionbar"
style="@style/ActionBar"
/>
<RelativeLayout
android:layout_height="wrap_content"
android:orientation="vertical"
Expand Down
3 changes: 3 additions & 0 deletions res/values/color.xml
Expand Up @@ -3,4 +3,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<color name="list_divider">#DBDBDB</color>
<color name="header_background">#CFCFCF</color>
<color name="actionbar_separator">#B3B3B3</color>
<color name="actionbar_background_start">#4D4D4D</color>
<color name="actionbar_background_end">#525252</color>
</resources>
20 changes: 19 additions & 1 deletion src/com/markupartist/iglaset/activity/CategoryActivity.java
Expand Up @@ -9,7 +9,10 @@
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.markupartist.android.widget.ActionBar;
import com.markupartist.android.widget.ActionBar.IntentAction;
import com.markupartist.iglaset.R;
import com.markupartist.iglaset.widget.SearchAction;

public class CategoryActivity extends ListActivity {
/** Called when the activity is first created. */
Expand All @@ -18,14 +21,29 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.category_list);
setTitle(getText(R.string.categories));

ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
actionBar.setHomeAction(new IntentAction(this, StartActivity.createIntent(this), R.drawable.ic_actionbar_home_default));
actionBar.setTitle(R.string.categories);
actionBar.addAction(new SearchAction() {
@Override
public void performAction() {
onSearchRequested();
}
});

ArrayAdapter<Category> categoryAdapter = new ArrayAdapter<Category>(
this, R.layout.category_list_row, createCategories());

this.setListAdapter(categoryAdapter);
}

@Override
public boolean onSearchRequested() {
startSearch(null, false, null, false);
return true;
}

/** Called when the list is clicked. */
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
Expand Down
16 changes: 13 additions & 3 deletions src/com/markupartist/iglaset/activity/DrinkDetailActivity.java
Expand Up @@ -55,6 +55,8 @@

import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import com.markupartist.android.widget.ActionBar;
import com.markupartist.android.widget.ActionBar.IntentAction;
import com.markupartist.iglaset.IglasetApplication;
import com.markupartist.iglaset.R;
import com.markupartist.iglaset.provider.AuthStore;
Expand All @@ -70,6 +72,7 @@
import com.markupartist.iglaset.util.ListUtils;
import com.markupartist.iglaset.util.MultiHashMap;
import com.markupartist.iglaset.widget.DrinkDescriptionAdapter;
import com.markupartist.iglaset.widget.SearchAction;
import com.markupartist.iglaset.widget.SectionedAdapter;
import com.markupartist.iglaset.widget.SectionedAdapter.Section;
import com.markupartist.iglaset.widget.VolumeAdapter;
Expand Down Expand Up @@ -131,16 +134,23 @@ public class DrinkDetailActivity extends ListActivity implements View.OnClickLis
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.drink_details);

mAuthentication = getAuthentication();

Bundle extras = getIntent().getExtras();
final Drink drink = extras.getParcelable(Intents.EXTRA_DRINK);
sDrink = drink;

ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
actionBar.setHomeAction(new IntentAction(this, StartActivity.createIntent(this), R.drawable.ic_actionbar_home_default));
actionBar.setTitle(sDrink.getName());
actionBar.addAction(new SearchAction() {
@Override
public void performAction() {
onSearchRequested();
}
});

// Populate drink details
View detailsLayout = this.findViewById(R.id.drink_detail_layout);
Expand Down
34 changes: 27 additions & 7 deletions src/com/markupartist/iglaset/activity/SearchResultActivity.java
Expand Up @@ -32,6 +32,8 @@
import android.widget.ListView;
import android.widget.TextView;

import com.markupartist.android.widget.ActionBar;
import com.markupartist.android.widget.ActionBar.IntentAction;
import com.markupartist.iglaset.R;
import com.markupartist.iglaset.activity.SearchDrinksTask.SearchDrinkCompletedListener;
import com.markupartist.iglaset.activity.SearchDrinksTask.SearchDrinkErrorListener;
Expand All @@ -42,6 +44,7 @@
import com.markupartist.iglaset.provider.RatingSearchCriteria;
import com.markupartist.iglaset.provider.RecommendationSearchCriteria;
import com.markupartist.iglaset.provider.SearchCriteria;
import com.markupartist.iglaset.widget.SearchAction;
import com.markupartist.iglaset.IglasetApplication;

public class SearchResultActivity extends ListActivity implements
Expand Down Expand Up @@ -77,6 +80,8 @@ private static class ConfigurationData {
"com.markupartist.iglaset.search.categoryId";
static final String EXTRA_SEARCH_TAGS =
"com.markupartist.iglaset.search.tags";
static final String EXTRA_SEARCH_TAGS_SELECTED =
"com.markupartist.iglaset.search.tagsString";
static final String EXTRA_CLICKED_DRINK =
"com.markupartist.iglaset.search.clickedDrink";

Expand Down Expand Up @@ -121,6 +126,16 @@ public void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.search_result);

ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
actionBar.setTitle(R.string.search_results);
actionBar.setHomeAction(new IntentAction(this, StartActivity.createIntent(this), R.drawable.ic_actionbar_home_default));
actionBar.addAction(new SearchAction() {
@Override
public void performAction() {
onSearchRequested();
}
});

try {
mAuthentication = AuthStore.getInstance().getAuthentication(this);
} catch (AuthenticationException e) {
Expand Down Expand Up @@ -163,19 +178,19 @@ public void onClick(View v) {
final TextView searchText = (TextView) findViewById(R.id.search_progress_text);
String searchingText = searchText.getText() + " \"" + queryString + "\"";
searchText.setText(searchingText);
setTitle(searchingText);
actionBar.setTitle(searchingText);

mSearchCriteria = new SearchCriteria();
mSearchCriteria.setQuery(queryString);

} else if (ACTION_USER_RECOMMENDATIONS.equals(queryAction)) {
setTitle(R.string.recommendations_label);
actionBar.setTitle(R.string.recommendations_label);

mSearchCriteria = new RecommendationSearchCriteria();
((RecommendationSearchCriteria) mSearchCriteria).setUserId(
mAuthentication.v2.userId);
} else if (ACTION_USER_RATINGS.equals(queryAction)) {
setTitle(R.string.rated_articles_label);
actionBar.setTitle(R.string.rated_articles_label);

mSearchCriteria = new RatingSearchCriteria();
((RatingSearchCriteria) mSearchCriteria).setUserId(mAuthentication.v2.userId);
Expand All @@ -188,20 +203,25 @@ public void onClick(View v) {
final int category = queryIntent.getExtras()
.getInt(EXTRA_SEARCH_CATEGORY_ID);

setTitle(R.string.search_results);
actionBar.setTitle(R.string.search_results);
mSearchCriteria.setCategory(category);
}

if (queryIntent.hasExtra(EXTRA_SEARCH_BARCODE)) {
String barcode = queryIntent.getStringExtra(EXTRA_SEARCH_BARCODE);

setTitle(R.string.search_results);
actionBar.setTitle(R.string.search_results);
mSearchCriteria.setBarcode(barcode);
}

if (queryIntent.hasExtra(EXTRA_SEARCH_TAGS)) {
setTitle(R.string.search_results);
actionBar.setTitle(R.string.search_results);
ArrayList<Integer> tags = queryIntent.getIntegerArrayListExtra(EXTRA_SEARCH_TAGS);

TextView selectedTags = (TextView) findViewById(R.id.tagSearchSelectedText);
selectedTags.setText(queryIntent.getStringExtra(EXTRA_SEARCH_TAGS_SELECTED));
selectedTags.setVisibility(View.VISIBLE);

mSearchCriteria.setTags(tags);
}

Expand All @@ -215,7 +235,7 @@ public void onClick(View v) {

this.registerReceiver(mBroadcastReceiver, new IntentFilter(Intents.ACTION_PUBLISH_DRINK));
}

private IglasetApplication getApp() {
return (IglasetApplication) getApplication();
}
Expand Down

0 comments on commit 22ae891

Please sign in to comment.