Cooler amazon ui look

pull/14/head
Tim Su 13 years ago
parent a27e44f8e7
commit c3514ea2d0

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.timsu.astrid" package="com.timsu.astrid"
android:versionName="4.0-beta-6" android:versionName="4.0-beta-6-ads"
android:versionCode="250"> android:versionCode="250">
<!-- widgets, alarms, and services will break if Astrid is installed on SD card --> <!-- widgets, alarms, and services will break if Astrid is installed on SD card -->

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- See the file "LICENSE" for the full license governing this code. -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:astrid="http://schemas.android.com/apk/res/com.timsu.astrid"
android:layout_width="fill_parent"
android:layout_height="100dip"
android:background="@android:drawable/list_selector_background">
<!-- imageview -->
<greendroid.widget.AsyncImageView android:id="@+id/image"
android:layout_width="70dip"
android:layout_height="100dip"
android:layout_marginLeft="5dip"
android:scaleType="fitCenter"
astrid:defaultSrc="@drawable/ic_contact_picture_2" />
<!-- title -->
<TextView android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/image"
android:layout_marginLeft="5dip"
android:layout_marginTop="5dip"
android:layout_marginBottom="3dip"
android:paddingRight="30dp"
android:lines="2"
android:singleLine="false"
android:textSize="12sp"
android:textStyle="bold"
android:gravity="center_vertical"
android:text="7-feet Xx-large Rust Cozy Sac Foof Bean Bag Chair"
android:ellipsize="end" />
<!-- subtitle -->
<TextView android:id="@+id/subtitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:layout_toRightOf="@id/image"
android:layout_marginLeft="5dip"
android:layout_marginBottom="3dip"
android:paddingRight="30dp"
android:singleLine="true"
android:textSize="12sp"
android:text="The Cozy Sac"
android:gravity="center_vertical" />
<!-- price -->
<TextView android:id="@+id/price"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/subtitle"
android:layout_toRightOf="@id/image"
android:layout_marginLeft="5dip"
android:layout_marginBottom="3dip"
android:paddingRight="30dp"
android:singleLine="true"
android:textSize="12sp"
android:textStyle="bold"
android:textColor="#990000"
android:text="$259.00"
android:gravity="center_vertical" />
<!-- new and used -->
<TextView android:id="@+id/new_and_used"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/price"
android:layout_toRightOf="@id/image"
android:layout_marginLeft="5dip"
android:layout_marginBottom="3dip"
android:paddingRight="30dp"
android:singleLine="true"
android:textSize="12sp"
android:text="2 New &amp; Used from $224"
android:gravity="center_vertical" />
<!-- arrow -->
<ImageView
android:layout_width="10dip"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_marginRight="5dip"
android:src="@drawable/icn_arrow_right"
android:scaleType="centerInside" />
</RelativeLayout>

@ -1,43 +1,55 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- See the file "LICENSE" for the full license governing this code. --> <!-- See the file "LICENSE" for the full license governing this code. -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:astrid="http://schemas.android.com/apk/res/com.timsu.astrid"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="100dip"
android:background="#9ee5ff"> android:background="@android:drawable/list_selector_background">
<!-- imageview -->
<greendroid.widget.AsyncImageView android:id="@+id/image"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_marginLeft="5dip"
android:scaleType="fitCenter"
astrid:defaultSrc="@drawable/ic_contact_picture_2" />
<!-- title --> <!-- title -->
<TextView android:id="@+id/title" <TextView android:id="@+id/title"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="70dip" android:layout_height="70dip"
android:layout_marginLeft="5dip" android:layout_marginLeft="5dip"
android:layout_toRightOf="@id/image"
android:paddingRight="30dp" android:paddingRight="30dp"
android:lines="2" android:lines="2"
android:singleLine="false" android:singleLine="false"
android:textSize="20sp" android:textSize="20sp"
android:textStyle="bold" android:textStyle="bold"
android:gravity="center_vertical" /> android:gravity="center_vertical"
android:text="Probiotic - Wikepedia, the free encyclopedia"
android:ellipsize="end" />
<!-- url --> <!-- url -->
<TextView android:id="@+id/url" <TextView android:id="@+id/subtitle"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="35dip" android:layout_height="35dip"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_toRightOf="@id/image"
android:layout_marginLeft="5dip" android:layout_marginLeft="5dip"
android:paddingRight="30dp" android:paddingRight="30dp"
android:singleLine="true" android:singleLine="true"
android:textSize="16sp" android:textSize="16sp"
android:text="en.wikipedia.org"
android:gravity="center_vertical" /> android:gravity="center_vertical" />
<!-- arrow --> <!-- arrow -->
<ImageView
android:layout_width="wrap_content" <ImageView
android:layout_height="wrap_content" android:layout_width="10dip"
android:layout_height="fill_parent"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:background="@drawable/icn_arrow_right"
android:layout_marginRight="5dip" android:layout_marginRight="5dip"
android:layout_marginTop="15dip" android:src="@drawable/icn_arrow_right"
android:paddingLeft="7dip" android:scaleType="centerInside" />
android:paddingRight="7dip"
android:scaleType="center" />
</RelativeLayout> </RelativeLayout>

@ -417,6 +417,7 @@ public final class TaskEditFragment extends Fragment implements
webServices = new WebServicesView(getActivity()); webServices = new WebServicesView(getActivity());
webServices.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, webServices.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT)); LayoutParams.WRAP_CONTENT));
webServices.setPadding(10, 5, 10, 10);
webServices.setTask(model); webServices.setTask(model);
} else { } else {
webServices.refresh(); webServices.refresh();
@ -429,9 +430,6 @@ public final class TaskEditFragment extends Fragment implements
mPager = (NestableViewPager) getView().findViewById(R.id.pager); mPager = (NestableViewPager) getView().findViewById(R.id.pager);
mPager.setAdapter(mAdapter); mPager.setAdapter(mAdapter);
mPager.setScrollabelViews(webServices.getScrollableViews());
((NestableScrollView)getView().findViewById(R.id.edit_scroll)).
setScrollabelViews(webServices.getScrollableViews());
mIndicator = (TabPageIndicator) getView().findViewById( mIndicator = (TabPageIndicator) getView().findViewById(
R.id.indicator); R.id.indicator);
@ -1151,6 +1149,7 @@ public final class TaskEditFragment extends Fragment implements
* in the horizontal scroll view * in the horizontal scroll view
*/ */
@SuppressWarnings("nls")
public View getPageView(int position) { public View getPageView(int position) {
if ((tabStyle == TAB_STYLE_WEB && position == 0) || if ((tabStyle == TAB_STYLE_WEB && position == 0) ||
(tabStyle != TAB_STYLE_WEB && position == 1)) { (tabStyle != TAB_STYLE_WEB && position == 1)) {
@ -1220,6 +1219,15 @@ public final class TaskEditFragment extends Fragment implements
@Override @Override
public void onPageSelected(int position) { public void onPageSelected(int position) {
this.setPagerHeightForPosition(position); this.setPagerHeightForPosition(position);
NestableScrollView scrollView = (NestableScrollView)getView().findViewById(R.id.edit_scroll);
if((tabStyle == TAB_STYLE_WEB && position == 1) ||
(tabStyle == TAB_STYLE_ACTIVITY_WEB && position == 2))
scrollView.
setScrollabelViews(webServices.getScrollableViews());
else
scrollView.setScrollabelViews(null);
} }
@Override @Override

@ -48,12 +48,8 @@ public class TaskEditViewPager extends PagerAdapter implements TitleProvider {
@Override @Override
public Object instantiateItem(View pager, int position) { public Object instantiateItem(View pager, int position) {
System.err.println("adding view for " + position + ", tab style " + tabStyle);
View pageView = parent.getPageView(position); View pageView = parent.getPageView(position);
System.err.println("got pager " + pageView);
((ViewPager) pager).addView(pageView, 0); ((ViewPager) pager).addView(pageView, 0);
return pageView; return pageView;
} }

@ -1,10 +1,10 @@
package com.todoroo.astrid.ui; package com.todoroo.astrid.ui;
import android.content.Context; import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewParent;
import android.widget.ScrollView; import android.widget.ScrollView;
public class NestableScrollView extends ScrollView { public class NestableScrollView extends ScrollView {
@ -13,13 +13,21 @@ public class NestableScrollView extends ScrollView {
public NestableScrollView(Context context, AttributeSet attrs) { public NestableScrollView(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
} }
@Override
@Override
public boolean onInterceptTouchEvent(MotionEvent event) { public boolean onInterceptTouchEvent(MotionEvent event) {
for(int i = 0; i < scrollableViews.length; i++) { if (scrollableViews != null) {
View view = findViewById(scrollableViews[i]); for (int i = 0; i < scrollableViews.length; i++) {
if (view instanceof ViewParent) View view = findViewById(scrollableViews[i]);
((ViewParent)view).requestDisallowInterceptTouchEvent(true); if (view != null) {
} Rect rect = new Rect();
view.getHitRect(rect);
if (rect.contains((int) event.getX(), (int) event.getY())) {
return false;
}
}
}
}
return super.onInterceptTouchEvent(event); return super.onInterceptTouchEvent(event);
} }

@ -4,26 +4,19 @@ import android.content.Context;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View;
import android.view.ViewParent;
public class NestableViewPager extends ViewPager { public class NestableViewPager extends ViewPager {
private int[] scrollableViews = new int[0];
public NestableViewPager(Context context, AttributeSet attrs) { public NestableViewPager(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
} }
/**
* Prevent horizontal scrolling
*/
@Override @Override
public boolean onInterceptTouchEvent(MotionEvent event) { public boolean onInterceptTouchEvent(MotionEvent event) {
for(int i = 0; i < scrollableViews.length; i++) { return false;
View view = findViewById(scrollableViews[i]);
if (view instanceof ViewParent)
((ViewParent)view).requestDisallowInterceptTouchEvent(true);
}
return super.onInterceptTouchEvent(event);
} }
public void setScrollabelViews(int[] views) {
this.scrollableViews = views;
}
} }

@ -4,6 +4,7 @@ import greendroid.widget.AsyncImageView;
import java.io.StringReader; import java.io.StringReader;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -27,7 +28,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.HorizontalScrollView; import android.widget.HorizontalScrollView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
@ -59,6 +59,10 @@ public class WebServicesView extends LinearLayout {
private LayoutInflater inflater; private LayoutInflater inflater;
private Activity activity; private Activity activity;
private LinearLayout.LayoutParams rowParams;
@Autowired RestClient restClient; @Autowired RestClient restClient;
@Autowired ExceptionService exceptionService; @Autowired ExceptionService exceptionService;
@ -95,6 +99,11 @@ public class WebServicesView extends LinearLayout {
inflater = (LayoutInflater) getContext().getSystemService( inflater = (LayoutInflater) getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE); Context.LAYOUT_INFLATER_SERVICE);
rowParams = new LinearLayout.LayoutParams(
Math.round(metrics.widthPixels * 0.8f),
Math.round(ROW_HEIGHT * metrics.density));
rowParams.rightMargin = Math.round(10 * metrics.density);
refresh(); refresh();
} }
@ -129,7 +138,7 @@ public class WebServicesView extends LinearLayout {
params.put("Version", "2011-08-01"); params.put("Version", "2011-08-01");
params.put("Operation", "ItemSearch"); params.put("Operation", "ItemSearch");
params.put("Availability", "Available"); params.put("Availability", "Available");
params.put("ResponseGroup", "Images"); params.put("ResponseGroup", "Medium");
params.put("Keywords", task.getValue(Task.TITLE)); params.put("Keywords", task.getValue(Task.TITLE));
params.put("SearchIndex", "All"); params.put("SearchIndex", "All");
params.put("AssociateTag", ASSOCIATE_TAG); params.put("AssociateTag", ASSOCIATE_TAG);
@ -151,16 +160,11 @@ public class WebServicesView extends LinearLayout {
private final LinearLayout body; private final LinearLayout body;
private final String searchResults; private final String searchResults;
private final MarginLayoutParams params;
public AmazonSearchResultsProcessor(LinearLayout body, public AmazonSearchResultsProcessor(LinearLayout body,
String searchResults) { String searchResults) {
this.body = body; this.body = body;
this.searchResults = searchResults; this.searchResults = searchResults;
params = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
params.rightMargin = Math.round(10 * metrics.density);
} }
@Override @Override
@ -176,22 +180,52 @@ public class WebServicesView extends LinearLayout {
xpp.setInput(new StringReader(searchResults)); xpp.setInput(new StringReader(searchResults));
int eventType = xpp.getEventType(); int eventType = xpp.getEventType();
String asin = null, image = null; HashMap<String, String> attributes = new HashMap<String, String>();
ArrayList<String> authors = new ArrayList<String>();
while (eventType != XmlPullParser.END_DOCUMENT) { while (eventType != XmlPullParser.END_DOCUMENT) {
if(eventType == XmlPullParser.START_TAG) { if(eventType == XmlPullParser.START_TAG) {
if("ASIN".equals(xpp.getName())) if("Title".equals(xpp.getName()))
asin = xpp.nextText(); attributes.put("title", xpp.nextText());
else if("FormattedPrice".equals(xpp.getName()))
attributes.put("price", xpp.nextText());
else if("DetailPageURL".equals(xpp.getName()))
attributes.put("url", xpp.nextText());
else if("Brand".equals(xpp.getName()) ||
"Studio".equals(xpp.getName()) ||
"Label".equals(xpp.getName()))
attributes.put("subtitle", xpp.nextText());
else if("Author".equals(xpp.getName()) ||
"Director".equals(xpp.getName()) ||
"Artist".equals(xpp.getName()))
authors.add(xpp.nextText());
else if("MediumImage".equals(xpp.getName())) { else if("MediumImage".equals(xpp.getName())) {
xpp.next(); xpp.next();
image = xpp.nextText(); attributes.put("image", xpp.nextText());
} else if("Error".equals(xpp.getName())) { }
else if("LowestNewPrice".equals(xpp.getName())) {
xpp.next();
attributes.put("lowestNew", xpp.nextText());
}
else if("LowestUsedPrice".equals(xpp.getName())) {
xpp.next();
attributes.put("lowestUsed", xpp.nextText());
}
else if("TotalNew".equals(xpp.getName()))
attributes.put("totalNew", xpp.nextText());
else if("TotalUsed".equals(xpp.getName()))
attributes.put("totalUsed", xpp.nextText());
else if("Error".equals(xpp.getName())) {
while(!"Message".equals(xpp.getName())) while(!"Message".equals(xpp.getName()))
xpp.next(); xpp.next();
throw new AmazonException(xpp.nextText()); throw new AmazonException(xpp.nextText());
} }
} else if(eventType == XmlPullParser.END_TAG) { } else if(eventType == XmlPullParser.END_TAG) {
if("Item".equals(xpp.getName())) if("Item".equals(xpp.getName())) {
renderItem(asin, image); renderItem(attributes, authors);
attributes.clear();
authors.clear();
}
} }
eventType = xpp.next(); eventType = xpp.next();
} }
@ -200,8 +234,7 @@ public class WebServicesView extends LinearLayout {
String url = String.format("http://www.amazon.com/s/?field-keywords=%s&tag=%s", String url = String.format("http://www.amazon.com/s/?field-keywords=%s&tag=%s",
URLEncoder.encode(task.getValue(Task.TITLE), "UTF-8"), ASSOCIATE_TAG); URLEncoder.encode(task.getValue(Task.TITLE), "UTF-8"), ASSOCIATE_TAG);
View view = inflateTextRow(body, moreLabel, "", url); View view = inflateRow(body, null, moreLabel, "", url);
view.setLayoutParams(params);
view.setBackgroundColor(Color.rgb(200, 200, 200)); view.setBackgroundColor(Color.rgb(200, 200, 200));
} catch (Exception e) { } catch (Exception e) {
@ -209,17 +242,66 @@ public class WebServicesView extends LinearLayout {
} }
} }
private void renderItem(String asin, String image) { private void renderItem(HashMap<String, String> attributes,
AsyncImageView imageView = new AsyncImageView(activity); ArrayList<String> authors) {
imageView.setDefaultImageResource(R.drawable.ic_contact_picture_2); View view = inflater.inflate(R.layout.web_service_amazon_row, body, false);
imageView.setUrl(image);
imageView.setLayoutParams(params); ((AsyncImageView)view.findViewById(R.id.image)).setUrl(
imageView.setScaleType(ScaleType.FIT_CENTER); attributes.get("image"));
imageView.setTag(String.format("http://www.amazon.com/dp/%s/?tag=%s", asin, ASSOCIATE_TAG)); ((TextView)view.findViewById(R.id.title)).setText(
imageView.setOnClickListener(linkClickListener); attributes.get("title"));
((TextView)view.findViewById(R.id.price)).setText(
attributes.get("price"));
view.setTag(attributes.get("url"));
String subtitle = attributes.get("subtitle");
if(authors.size() > 0) {
StringBuilder sb = new StringBuilder();
for(String author : authors) {
System.err.println("AUTHOR " + author);
sb.append(author).append(", ");
}
subtitle = sb.toString().substring(0, sb.length() - 2);
}
((TextView)view.findViewById(R.id.subtitle)).setText(subtitle);
String newAndUsed = null;
if(attributes.containsKey("lowestNew") || attributes.containsKey("lowestUsed")) {
int lowestNew = Integer.MAX_VALUE;
try {
lowestNew = attributes.containsKey("lowestNew") ?
Integer.parseInt(attributes.get("lowestNew")) : Integer.MAX_VALUE;
} catch (NumberFormatException e) {
// text, i.e. "too low to display"
}
int lowestUsed = Integer.MAX_VALUE;
try {
lowestUsed = attributes.containsKey("lowestUsed") ?
Integer.parseInt(attributes.get("lowestUsed")) : Integer.MAX_VALUE;
} catch (NumberFormatException e) {
// text, i.e. "too low to display"
}
int lowest = Math.min(lowestNew, lowestUsed);
int total = 0;
if(attributes.containsKey("totalNew"))
total += Integer.parseInt(attributes.get("totalNew"));
if(attributes.containsKey("totalUsed"))
total += Integer.parseInt(attributes.get("totalUsed"));
String price = String.format("$%.2f", lowest / 100f);
if(!price.equals(attributes.get("price")))
newAndUsed = String.format("%d New & Used from %s", total, price);
}
((TextView)view.findViewById(R.id.new_and_used)).setText(newAndUsed);
body.addView(imageView); view.setOnClickListener(linkClickListener);
view.setLayoutParams(rowParams);
body.addView(view);
} }
} }
private class AmazonException extends Exception { private class AmazonException extends Exception {
@ -275,25 +357,19 @@ public class WebServicesView extends LinearLayout {
try { try {
JSONArray results = searchResults.getJSONArray("results"); JSONArray results = searchResults.getJSONArray("results");
LayoutParams params = new LinearLayout.LayoutParams(
Math.round(metrics.widthPixels * 0.8f),
Math.round(ROW_HEIGHT * metrics.density));
params.rightMargin = Math.round(10 * metrics.density);
for(int i = 0; i < results.length(); i++) { for(int i = 0; i < results.length(); i++) {
JSONObject result = results.getJSONObject(i); JSONObject result = results.getJSONObject(i);
String title = StringEscapeUtils.unescapeHtml(result.getString("titleNoFormatting")); String title = StringEscapeUtils.unescapeHtml(result.getString("titleNoFormatting"));
View view = inflateTextRow(body, title, inflateRow(body, null, title,
result.getString("visibleUrl"), result.getString("url")); result.getString("visibleUrl"), result.getString("url"));
view.setLayoutParams(params);
} }
JSONObject cursor = searchResults.getJSONObject("cursor"); JSONObject cursor = searchResults.getJSONObject("cursor");
String moreLabel = "Show moreresults"; String moreLabel = "Show more results";
String url = cursor.getString("moreResultsUrl"); String url = cursor.getString("moreResultsUrl");
View view = inflateTextRow(body, moreLabel, "", url); View view = inflateRow(body, null, moreLabel, "", url);
view.setLayoutParams(params);
view.setBackgroundColor(Color.rgb(200, 200, 200)); view.setBackgroundColor(Color.rgb(200, 200, 200));
} catch (JSONException e) { } catch (JSONException e) {
@ -302,13 +378,22 @@ public class WebServicesView extends LinearLayout {
} }
} }
protected View inflateTextRow(ViewGroup body, String title, String subtitle, protected View inflateRow(ViewGroup body, String imageUrl, String title, String subtitle,
String tag) { String tag) {
View view = inflater.inflate(R.layout.web_service_text_row, body, false); View view = inflater.inflate(R.layout.web_service_row, body, false);
AsyncImageView imageView = (AsyncImageView)view.findViewById(R.id.image);
if(imageUrl == null)
imageView.setVisibility(View.GONE);
else
imageView.setUrl(imageUrl);
((TextView)view.findViewById(R.id.title)).setText(title); ((TextView)view.findViewById(R.id.title)).setText(title);
((TextView)view.findViewById(R.id.url)).setText(subtitle); ((TextView)view.findViewById(R.id.subtitle)).setText(subtitle);
view.setOnClickListener(linkClickListener); view.setOnClickListener(linkClickListener);
view.setTag(tag); view.setTag(tag);
view.setLayoutParams(rowParams);
body.addView(view); body.addView(view);
return view; return view;
} }
@ -346,6 +431,7 @@ public class WebServicesView extends LinearLayout {
scroll.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, scroll.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT)); LayoutParams.WRAP_CONTENT));
scroll.setId(id); scroll.setId(id);
scroll.setScrollbarFadingEnabled(false);
addView(scroll); addView(scroll);
LinearLayout body = new LinearLayout(getContext()); LinearLayout body = new LinearLayout(getContext());
@ -355,10 +441,12 @@ public class WebServicesView extends LinearLayout {
ProgressBar progressBar = new ProgressBar(getContext()); ProgressBar progressBar = new ProgressBar(getContext());
progressBar.setIndeterminate(true); progressBar.setIndeterminate(true);
LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams layoutParams = new LinearLayout.LayoutParams(metrics.widthPixels,
LayoutParams.FILL_PARENT); Math.round(30 * metrics.density));
layoutParams.gravity = Gravity.CENTER; layoutParams.gravity = Gravity.CENTER;
progressBar.setLayoutParams(layoutParams); progressBar.setLayoutParams(layoutParams);
progressBar.setIndeterminateDrawable(getResources().getDrawable(
android.R.drawable.progress_indeterminate_horizontal));
body.addView(progressBar); body.addView(progressBar);
return body; return body;
@ -370,14 +458,13 @@ public class WebServicesView extends LinearLayout {
LayoutParams mlp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 1); LayoutParams mlp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 1);
mlp.setMargins(10, 20, 10, 20); mlp.setMargins(10, 20, 10, 20);
view.setLayoutParams(mlp); view.setLayoutParams(mlp);
view.setBackgroundResource(R.drawable.black_white_gradient);
addView(view); addView(view);
} }
private void addSectionHeader(String string) { private void addSectionHeader(String string) {
TextView textView = new TextView(getContext()); TextView textView = new TextView(getContext());
textView.setText(string); textView.setText(string);
textView.setTextAppearance(getContext(), R.style.TextAppearance_Medium); textView.setTextAppearance(getContext(), R.style.TextAppearance_GEN_EditLabel);
addView(textView); addView(textView);
} }

Loading…
Cancel
Save