mirror of
https://github.com/MatomoCamp/matomocamp-companion-android.git
synced 2024-09-19 16:13:46 +02:00
Enhanced list item layouts and make them RTL-compatible.
This commit is contained in:
parent
d6f1de2aae
commit
fd8a806236
6 changed files with 97 additions and 81 deletions
|
@ -3,10 +3,8 @@ package be.digitalia.fosdem.adapters;
|
|||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.support.v4.widget.CursorAdapter;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.support.v4.widget.TextViewCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.AbsoluteSizeSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -24,7 +22,6 @@ public class EventsAdapter extends CursorAdapter {
|
|||
|
||||
private final LayoutInflater inflater;
|
||||
private final DateFormat timeDateFormat;
|
||||
private final int titleTextSize;
|
||||
private final boolean showDay;
|
||||
|
||||
public EventsAdapter(Context context) {
|
||||
|
@ -35,7 +32,6 @@ public class EventsAdapter extends CursorAdapter {
|
|||
super(context, null, 0);
|
||||
inflater = LayoutInflater.from(context);
|
||||
timeDateFormat = DateUtils.getTimeDateFormat(context);
|
||||
titleTextSize = context.getResources().getDimensionPixelSize(R.dimen.list_item_title_text_size);
|
||||
this.showDay = showDay;
|
||||
}
|
||||
|
||||
|
@ -50,7 +46,7 @@ public class EventsAdapter extends CursorAdapter {
|
|||
|
||||
ViewHolder holder = new ViewHolder();
|
||||
holder.title = (TextView) view.findViewById(R.id.title);
|
||||
holder.titleSizeSpan = new AbsoluteSizeSpan(titleTextSize);
|
||||
holder.persons = (TextView) view.findViewById(R.id.persons);
|
||||
holder.trackName = (TextView) view.findViewById(R.id.track_name);
|
||||
holder.details = (TextView) view.findViewById(R.id.details);
|
||||
view.setTag(holder);
|
||||
|
@ -64,19 +60,12 @@ public class EventsAdapter extends CursorAdapter {
|
|||
Event event = DatabaseManager.toEvent(cursor, holder.event);
|
||||
holder.event = event;
|
||||
|
||||
String eventTitle = event.getTitle();
|
||||
SpannableString spannableString;
|
||||
String personsSummary = event.getPersonsSummary();
|
||||
if (TextUtils.isEmpty(personsSummary)) {
|
||||
spannableString = new SpannableString(eventTitle);
|
||||
} else {
|
||||
spannableString = new SpannableString(String.format("%1$s\n%2$s", eventTitle, event.getPersonsSummary()));
|
||||
}
|
||||
spannableString.setSpan(holder.titleSizeSpan, 0, eventTitle.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
holder.title.setText(spannableString);
|
||||
holder.title.setText(event.getTitle());
|
||||
int bookmarkDrawable = DatabaseManager.toBookmarkStatus(cursor) ? R.drawable.ic_bookmark_grey600_24dp : 0;
|
||||
holder.title.setCompoundDrawablesWithIntrinsicBounds(0, 0, bookmarkDrawable, 0);
|
||||
|
||||
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(holder.title, 0, 0, bookmarkDrawable, 0);
|
||||
String personsSummary = event.getPersonsSummary();
|
||||
holder.persons.setText(personsSummary);
|
||||
holder.persons.setVisibility(TextUtils.isEmpty(personsSummary) ? View.GONE : View.VISIBLE);
|
||||
holder.trackName.setText(event.getTrack().getName());
|
||||
|
||||
Date startTime = event.getStartTime();
|
||||
|
@ -94,7 +83,7 @@ public class EventsAdapter extends CursorAdapter {
|
|||
|
||||
private static class ViewHolder {
|
||||
TextView title;
|
||||
AbsoluteSizeSpan titleSizeSpan;
|
||||
TextView persons;
|
||||
TextView trackName;
|
||||
TextView details;
|
||||
Event event;
|
||||
|
|
|
@ -3,19 +3,16 @@ package be.digitalia.fosdem.fragments;
|
|||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.support.v4.widget.CursorAdapter;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.support.v4.widget.TextViewCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.AbsoluteSizeSpan;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -240,13 +237,15 @@ public class TrackScheduleListFragment extends SmoothListFragment implements Han
|
|||
|
||||
private static class TrackScheduleAdapter extends CursorAdapter {
|
||||
|
||||
private static final int[] PRIMARY_TEXT_COLORS
|
||||
= new int[]{android.R.attr.textColorPrimary, android.R.attr.textColorPrimaryInverse};
|
||||
|
||||
private final LayoutInflater inflater;
|
||||
private final DateFormat timeDateFormat;
|
||||
private final int timeBackgroundColor;
|
||||
private final int timeForegroundColor;
|
||||
private final int timeRunningBackgroundColor;
|
||||
private final int timeRunningForegroundColor;
|
||||
private final int titleTextSize;
|
||||
private long currentTime = -1L;
|
||||
|
||||
public TrackScheduleAdapter(Context context) {
|
||||
|
@ -255,10 +254,12 @@ public class TrackScheduleListFragment extends SmoothListFragment implements Han
|
|||
timeDateFormat = DateUtils.getTimeDateFormat(context);
|
||||
Resources res = context.getResources();
|
||||
timeBackgroundColor = res.getColor(R.color.schedule_time_background);
|
||||
timeForegroundColor = res.getColor(R.color.schedule_time_foreground);
|
||||
timeRunningBackgroundColor = res.getColor(R.color.schedule_time_running_background);
|
||||
timeRunningForegroundColor = res.getColor(R.color.schedule_time_running_foreground);
|
||||
titleTextSize = res.getDimensionPixelSize(R.dimen.list_item_title_text_size);
|
||||
|
||||
TypedArray a = context.getTheme().obtainStyledAttributes(PRIMARY_TEXT_COLORS);
|
||||
timeForegroundColor = a.getColor(0, 0);
|
||||
timeRunningForegroundColor = a.getColor(1, 0);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
public void setCurrentTime(long time) {
|
||||
|
@ -279,9 +280,9 @@ public class TrackScheduleListFragment extends SmoothListFragment implements Han
|
|||
|
||||
ViewHolder holder = new ViewHolder();
|
||||
holder.time = (TextView) view.findViewById(R.id.time);
|
||||
holder.text = (TextView) view.findViewById(R.id.text);
|
||||
holder.titleSizeSpan = new AbsoluteSizeSpan(titleTextSize);
|
||||
holder.boldStyleSpan = new StyleSpan(Typeface.BOLD);
|
||||
holder.title = (TextView) view.findViewById(R.id.title);
|
||||
holder.persons = (TextView) view.findViewById(R.id.persons);
|
||||
holder.room = (TextView) view.findViewById(R.id.room);
|
||||
view.setTag(holder);
|
||||
|
||||
return view;
|
||||
|
@ -304,27 +305,20 @@ public class TrackScheduleListFragment extends SmoothListFragment implements Han
|
|||
holder.time.setTextColor(timeForegroundColor);
|
||||
}
|
||||
|
||||
SpannableString spannableString;
|
||||
String eventTitle = event.getTitle();
|
||||
String personsSummary = event.getPersonsSummary();
|
||||
if (TextUtils.isEmpty(personsSummary)) {
|
||||
spannableString = new SpannableString(String.format("%1$s\n%2$s", eventTitle, event.getRoomName()));
|
||||
} else {
|
||||
spannableString = new SpannableString(String.format("%1$s\n%2$s\n%3$s", eventTitle, personsSummary, event.getRoomName()));
|
||||
}
|
||||
spannableString.setSpan(holder.titleSizeSpan, 0, eventTitle.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
spannableString.setSpan(holder.boldStyleSpan, 0, eventTitle.length() + personsSummary.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
||||
holder.text.setText(spannableString);
|
||||
holder.title.setText(event.getTitle());
|
||||
int bookmarkDrawable = DatabaseManager.toBookmarkStatus(cursor) ? R.drawable.ic_bookmark_grey600_24dp : 0;
|
||||
holder.text.setCompoundDrawablesWithIntrinsicBounds(0, 0, bookmarkDrawable, 0);
|
||||
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(holder.title, 0, 0, bookmarkDrawable, 0);
|
||||
String personsSummary = event.getPersonsSummary();
|
||||
holder.persons.setText(personsSummary);
|
||||
holder.persons.setVisibility(TextUtils.isEmpty(personsSummary) ? View.GONE : View.VISIBLE);
|
||||
holder.room.setText(event.getRoomName());
|
||||
}
|
||||
|
||||
private static class ViewHolder {
|
||||
TextView time;
|
||||
TextView text;
|
||||
AbsoluteSizeSpan titleSizeSpan;
|
||||
StyleSpan boldStyleSpan;
|
||||
TextView title;
|
||||
TextView persons;
|
||||
TextView room;
|
||||
Event event;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,34 +5,40 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="?attr/activatedBackgroundIndicator"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/list_item_padding">
|
||||
android:paddingBottom="@dimen/list_item_padding"
|
||||
android:paddingLeft="?attr/listPreferredItemPaddingLeft"
|
||||
android:paddingRight="?attr/listPreferredItemPaddingRight"
|
||||
android:paddingTop="@dimen/list_item_padding">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="8dp"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/list_item_small_text_size"
|
||||
android:textStyle="bold"
|
||||
tools:text="Welcome to FOSDEM 2015\nFOSDEM Staff"
|
||||
tools:textSize="@dimen/list_item_medium_text_size"/>
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Title"
|
||||
android:textSize="@dimen/abc_text_size_medium_material"
|
||||
tools:text="Welcome to FOSDEM 2015"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/persons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
|
||||
tools:text="FOSDEM Staff"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/track_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/list_item_small_text_size"
|
||||
android:textStyle="italic"
|
||||
android:layout_marginTop="4dp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
|
||||
tools:text="Keynotes"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/details"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/list_item_small_text_size"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
tools:text="Saturday, 09:30 - 09:55 | Janson"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -1,33 +1,65 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/activatedBackgroundIndicator"
|
||||
android:orientation="horizontal">
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/activatedBackgroundIndicator">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_alignBottom="@+id/room"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@color/schedule_time_background"
|
||||
android:padding="@dimen/list_item_padding"
|
||||
android:textColor="@color/schedule_time_foreground"
|
||||
android:textSize="@dimen/list_item_small_text_size"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:textStyle="bold"
|
||||
tools:text="09:30"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginLeft="@dimen/list_item_padding"
|
||||
android:layout_marginRight="@dimen/list_item_padding"
|
||||
android:layout_toEndOf="@+id/time"
|
||||
android:layout_toRightOf="@+id/time"
|
||||
android:drawablePadding="8dp"
|
||||
android:padding="@dimen/list_item_padding"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/list_item_small_text_size"
|
||||
tools:text="Welcome to FOSDEM 2015\nFOSDEM Staff"
|
||||
tools:textSize="@dimen/list_item_medium_text_size"
|
||||
tools:textStyle="bold"/>
|
||||
android:paddingTop="@dimen/list_item_padding"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Title"
|
||||
android:textSize="@dimen/abc_text_size_medium_material"
|
||||
tools:text="Welcome to FOSDEM 2015"/>
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/persons"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignEnd="@+id/title"
|
||||
android:layout_alignLeft="@+id/title"
|
||||
android:layout_alignRight="@+id/title"
|
||||
android:layout_alignStart="@+id/title"
|
||||
android:layout_below="@+id/title"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
|
||||
tools:text="FOSDEM Staff"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/room"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignEnd="@+id/title"
|
||||
android:layout_alignLeft="@+id/title"
|
||||
android:layout_alignRight="@+id/title"
|
||||
android:layout_alignStart="@+id/title"
|
||||
android:layout_below="@+id/persons"
|
||||
android:layout_marginTop="4dp"
|
||||
android:paddingBottom="@dimen/list_item_padding"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
tools:text="Janson"/>
|
||||
|
||||
</RelativeLayout>
|
|
@ -9,8 +9,6 @@
|
|||
<color name="main_menu_footer_background">#eaeaea</color>
|
||||
<color name="translucent_grey">#0c000000</color>
|
||||
<color name="schedule_time_background">#29000000</color>
|
||||
<color name="schedule_time_foreground">#000</color>
|
||||
<color name="schedule_time_running_background">#d6000000</color>
|
||||
<color name="schedule_time_running_foreground">#fff</color>
|
||||
|
||||
</resources>
|
|
@ -8,9 +8,6 @@
|
|||
<dimen name="main_menu_item_height">48dp</dimen>
|
||||
<dimen name="main_menu_footer_height">32dp</dimen>
|
||||
<dimen name="list_item_padding">8dp</dimen>
|
||||
<dimen name="list_item_title_text_size">18sp</dimen>
|
||||
<dimen name="list_item_medium_text_size">16sp</dimen>
|
||||
<dimen name="list_item_small_text_size">14sp</dimen>
|
||||
<dimen name="content_margin">16dp</dimen>
|
||||
<dimen name="toolbar_elevation">8dp</dimen>
|
||||
<dimen name="schedule_column_width">360dp</dimen>
|
||||
|
|
Loading…
Reference in a new issue