Use ExpandableTextView on Text views that expand on clicking them
This commit is contained in:
parent
b01e3c8ddc
commit
6245a9c7d5
|
@ -33,6 +33,7 @@ Credits
|
|||
- [JmDNS](http://jmdns.sourceforge.net/)
|
||||
- [PagerSlidingTabStrip](https://github.com/astuetz/PagerSlidingTabStrip)
|
||||
- [FloatingActionButton](https://github.com/makovkastar/FloatingActionButton)
|
||||
- [ExpandableTextView](https://github.com/Blogcat/Android-ExpandableTextView)
|
||||
|
||||
**Translations**
|
||||
- French - Kowalski
|
||||
|
|
|
@ -117,6 +117,7 @@ dependencies {
|
|||
compile 'javax.jmdns:jmdns:3.4.1'
|
||||
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
|
||||
compile 'com.melnykov:floatingactionbutton:1.3.0'
|
||||
compile 'at.blogc:expandabletextview:1.0.3'
|
||||
|
||||
androidTestCompile 'com.android.support.test:runner:0.5'
|
||||
androidTestCompile 'com.android.support.test:rules:0.5'
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
package org.xbmc.kore.ui;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.database.Cursor;
|
||||
|
@ -65,10 +63,10 @@ import org.xbmc.kore.utils.LogUtils;
|
|||
import org.xbmc.kore.utils.UIUtils;
|
||||
import org.xbmc.kore.utils.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import at.blogc.android.views.ExpandableTextView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
import butterknife.OnClick;
|
||||
|
@ -126,10 +124,9 @@ public class AlbumDetailsFragment extends AbstractDetailsFragment
|
|||
@InjectView(R.id.rating) TextView mediaRating;
|
||||
@InjectView(R.id.max_rating) TextView mediaMaxRating;
|
||||
@InjectView(R.id.year) TextView mediaYear;
|
||||
// @InjectView(R.id.genres) TextView mediaGenres;
|
||||
|
||||
@InjectView(R.id.media_description_container) LinearLayout mediaDescriptionContainer;
|
||||
@InjectView(R.id.media_description) TextView mediaDescription;
|
||||
@InjectView(R.id.media_description) ExpandableTextView mediaDescription;
|
||||
@InjectView(R.id.show_all) ImageView mediaShowAll;
|
||||
|
||||
@InjectView(R.id.song_list) LinearLayout songListView;
|
||||
|
@ -346,7 +343,6 @@ public class AlbumDetailsFragment extends AbstractDetailsFragment
|
|||
|
||||
}
|
||||
|
||||
private boolean isDescriptionExpanded = false;
|
||||
/**
|
||||
* Display the album details
|
||||
*
|
||||
|
@ -377,7 +373,7 @@ public class AlbumDetailsFragment extends AbstractDetailsFragment
|
|||
if (!TextUtils.isEmpty(description)) {
|
||||
mediaDescription.setVisibility(View.VISIBLE);
|
||||
mediaDescription.setText(description);
|
||||
final int maxLines = resources.getInteger(R.integer.description_max_lines);
|
||||
|
||||
Resources.Theme theme = getActivity().getTheme();
|
||||
TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] {
|
||||
R.attr.iconExpand,
|
||||
|
@ -388,18 +384,11 @@ public class AlbumDetailsFragment extends AbstractDetailsFragment
|
|||
final int iconExpandResId =
|
||||
styledAttributes.getResourceId(styledAttributes.getIndex(1), R.drawable.ic_expand_more_white_24dp);
|
||||
styledAttributes.recycle();
|
||||
|
||||
mediaDescriptionContainer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!isDescriptionExpanded) {
|
||||
mediaDescription.setMaxLines(Integer.MAX_VALUE);
|
||||
mediaShowAll.setImageResource(iconExpandResId);
|
||||
} else {
|
||||
mediaDescription.setMaxLines(maxLines);
|
||||
mediaShowAll.setImageResource(iconCollapseResId);
|
||||
}
|
||||
isDescriptionExpanded = !isDescriptionExpanded;
|
||||
mediaDescription.toggle();
|
||||
mediaShowAll.setImageResource(mediaDescription.isExpanded() ? iconCollapseResId: iconExpandResId);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -426,7 +415,7 @@ public class AlbumDetailsFragment extends AbstractDetailsFragment
|
|||
}
|
||||
|
||||
private void setMediaRating(double rating) {
|
||||
mediaRating.setText(String.format("%01.01f", rating));
|
||||
mediaRating.setText(String.format(Locale.getDefault(), "%01.01f", rating));
|
||||
mediaMaxRating.setText(getString(R.string.max_rating_music));
|
||||
}
|
||||
|
||||
|
@ -560,7 +549,7 @@ public class AlbumDetailsFragment extends AbstractDetailsFragment
|
|||
*/
|
||||
private void displaySongsList(Cursor cursor) {
|
||||
if (cursor.moveToFirst()) {
|
||||
songInfoList = new ArrayList<FileDownloadHelper.SongInfo>(cursor.getCount());
|
||||
songInfoList = new ArrayList<>(cursor.getCount());
|
||||
do {
|
||||
View songView = LayoutInflater.from(getActivity())
|
||||
.inflate(R.layout.list_item_song, songListView, false);
|
||||
|
@ -646,16 +635,16 @@ public class AlbumDetailsFragment extends AbstractDetailsFragment
|
|||
MediaContract.Albums.RATING,
|
||||
};
|
||||
|
||||
final int ID = 0;
|
||||
final int TITLE = 1;
|
||||
final int DISPLAYARTIST = 2;
|
||||
final int THUMBNAIL = 3;
|
||||
final int FANART = 4;
|
||||
final int YEAR = 5;
|
||||
final int GENRE = 6;
|
||||
final int ALBUMLABEL = 7;
|
||||
final int DESCRIPTION = 8;
|
||||
final int RATING = 9;
|
||||
int ID = 0;
|
||||
int TITLE = 1;
|
||||
int DISPLAYARTIST = 2;
|
||||
int THUMBNAIL = 3;
|
||||
int FANART = 4;
|
||||
int YEAR = 5;
|
||||
int GENRE = 6;
|
||||
int ALBUMLABEL = 7;
|
||||
int DESCRIPTION = 8;
|
||||
int RATING = 9;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,6 +56,7 @@ import org.xbmc.kore.utils.Utils;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import at.blogc.android.views.ExpandableTextView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
|
||||
|
@ -119,7 +120,7 @@ public class TVShowDetailsFragment extends AbstractDetailsFragment
|
|||
@InjectView(R.id.premiered) TextView mediaPremiered;
|
||||
@InjectView(R.id.genres) TextView mediaGenres;
|
||||
|
||||
@InjectView(R.id.media_description) TextView mediaDescription;
|
||||
@InjectView(R.id.media_description) ExpandableTextView mediaDescription;
|
||||
@InjectView(R.id.cast_list) GridLayout videoCastList;
|
||||
|
||||
@InjectView(R.id.next_episode_title) TextView nextEpisodeTitle;
|
||||
|
@ -131,8 +132,6 @@ public class TVShowDetailsFragment extends AbstractDetailsFragment
|
|||
@InjectView(R.id.media_description_container) LinearLayout mediaDescriptionContainer;
|
||||
@InjectView(R.id.show_all) ImageView mediaShowAll;
|
||||
|
||||
private boolean isDescriptionExpanded = false;
|
||||
|
||||
/**
|
||||
* Create a new instance of this, initialized to show tvshowId
|
||||
*/
|
||||
|
@ -363,7 +362,6 @@ public class TVShowDetailsFragment extends AbstractDetailsFragment
|
|||
mediaDescription.setText(cursor.getString(TVShowDetailsQuery.PLOT));
|
||||
|
||||
Resources resources = getActivity().getResources();
|
||||
final int maxLines = resources.getInteger(R.integer.description_max_lines);
|
||||
TypedArray styledAttributes = getActivity().getTheme().obtainStyledAttributes(new int[] {
|
||||
R.attr.iconExpand,
|
||||
R.attr.iconCollapse
|
||||
|
@ -376,14 +374,8 @@ public class TVShowDetailsFragment extends AbstractDetailsFragment
|
|||
mediaDescriptionContainer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!isDescriptionExpanded) {
|
||||
mediaDescription.setMaxLines(Integer.MAX_VALUE);
|
||||
mediaShowAll.setImageResource(iconExpandResId);
|
||||
} else {
|
||||
mediaDescription.setMaxLines(maxLines);
|
||||
mediaShowAll.setImageResource(iconCollapseResId);
|
||||
}
|
||||
isDescriptionExpanded = !isDescriptionExpanded;
|
||||
mediaDescription.toggle();
|
||||
mediaShowAll.setImageResource(mediaDescription.isExpanded() ? iconCollapseResId: iconExpandResId);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -436,7 +428,7 @@ public class TVShowDetailsFragment extends AbstractDetailsFragment
|
|||
private void displayCastList(Cursor cursor) {
|
||||
// Transform the cursor into a List<VideoType.Cast>
|
||||
if (cursor.moveToFirst()) {
|
||||
ArrayList<VideoType.Cast> castArrayList = new ArrayList<VideoType.Cast>(cursor.getCount());
|
||||
ArrayList<VideoType.Cast> castArrayList = new ArrayList<>(cursor.getCount());
|
||||
do {
|
||||
castArrayList.add(new VideoType.Cast(cursor.getString(TVShowCastListQuery.NAME),
|
||||
cursor.getInt(TVShowCastListQuery.ORDER),
|
||||
|
|
|
@ -177,7 +177,7 @@
|
|||
android:layout_below="@id/media_details"
|
||||
android:orientation="vertical"
|
||||
android:background="?attr/contentBackgroundColor">
|
||||
<TextView
|
||||
<at.blogc.android.views.ExpandableTextView
|
||||
android:id="@+id/media_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -186,7 +186,8 @@
|
|||
android:paddingRight="@dimen/default_padding"
|
||||
android:paddingBottom="0dp"
|
||||
android:maxLines="@integer/description_max_lines"
|
||||
android:ellipsize="@null"/>
|
||||
android:ellipsize="end"
|
||||
app:animation_duration="@integer/expandable_textview_animation_duration"/>
|
||||
<ImageView
|
||||
android:id="@+id/show_all"
|
||||
android:layout_width="@dimen/small_icon_size"
|
||||
|
@ -195,8 +196,7 @@
|
|||
android:layout_marginBottom="@dimen/small_padding"
|
||||
android:layout_marginRight="@dimen/small_padding"
|
||||
android:layout_marginEnd="@dimen/small_padding"
|
||||
android:src="?attr/iconExpand"
|
||||
android:background="?android:attr/selectableItemBackground"/>
|
||||
android:src="?attr/iconExpand"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
limitations under the License.
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
@ -143,7 +145,7 @@
|
|||
android:layout_below="@id/media_details"
|
||||
android:orientation="vertical"
|
||||
android:background="?attr/contentBackgroundColor">
|
||||
<TextView
|
||||
<at.blogc.android.views.ExpandableTextView
|
||||
android:id="@+id/media_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -152,7 +154,8 @@
|
|||
android:paddingRight="@dimen/default_padding"
|
||||
android:paddingBottom="0dp"
|
||||
android:maxLines="@integer/description_max_lines"
|
||||
android:ellipsize="@null"/>
|
||||
android:ellipsize="end"
|
||||
app:animation_duration="@integer/expandable_textview_animation_duration"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/show_all"
|
||||
|
@ -161,8 +164,7 @@
|
|||
android:layout_gravity="end"
|
||||
android:layout_marginRight="@dimen/small_padding"
|
||||
android:layout_marginEnd="@dimen/small_padding"
|
||||
android:src="?attr/iconExpand"
|
||||
android:background="?android:attr/selectableItemBackground"/>
|
||||
android:src="?attr/iconExpand"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
|
|
|
@ -28,4 +28,5 @@
|
|||
<integer name="seasons_grid_view_columns">1</integer>
|
||||
|
||||
<integer name="fab_animation_start_delay">100</integer>
|
||||
<integer name="expandable_textview_animation_duration">200</integer>
|
||||
</resources>
|
Loading…
Reference in New Issue