tablet ui support for comments

This commit is contained in:
Ritvik Saraf 2018-12-09 03:21:55 +05:30
parent 1a62b9a161
commit 222c8fdb62
4 changed files with 186 additions and 161 deletions

View File

@ -16,6 +16,7 @@ import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout; import android.support.design.widget.AppBarLayout;
import android.support.design.widget.TabLayout; import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v4.view.animation.FastOutSlowInInterpolator; import android.support.v4.view.animation.FastOutSlowInInterpolator;
@ -152,7 +153,6 @@ public class VideoDetailFragment
private View videoTitleRoot; private View videoTitleRoot;
private TextView videoTitleTextView; private TextView videoTitleTextView;
@Nullable
private ImageView videoTitleToggleArrow; private ImageView videoTitleToggleArrow;
private TextView videoCountView; private TextView videoCountView;
@ -184,6 +184,7 @@ public class VideoDetailFragment
private ViewPager viewPager; private ViewPager viewPager;
private TabAdaptor pageAdapter; private TabAdaptor pageAdapter;
private TabLayout tabLayout; private TabLayout tabLayout;
private FrameLayout relatedStreamsLayout;
/*////////////////////////////////////////////////////////////////////////*/ /*////////////////////////////////////////////////////////////////////////*/
@ -419,16 +420,14 @@ public class VideoDetailFragment
} }
private void toggleTitleAndDescription() { private void toggleTitleAndDescription() {
if (videoTitleToggleArrow != null) { //it is null for tablets if (videoDescriptionRootLayout.getVisibility() == View.VISIBLE) {
if (videoDescriptionRootLayout.getVisibility() == View.VISIBLE) { videoTitleTextView.setMaxLines(1);
videoTitleTextView.setMaxLines(1); videoDescriptionRootLayout.setVisibility(View.GONE);
videoDescriptionRootLayout.setVisibility(View.GONE); videoTitleToggleArrow.setImageResource(R.drawable.arrow_down);
videoTitleToggleArrow.setImageResource(R.drawable.arrow_down); } else {
} else { videoTitleTextView.setMaxLines(10);
videoTitleTextView.setMaxLines(10); videoDescriptionRootLayout.setVisibility(View.VISIBLE);
videoDescriptionRootLayout.setVisibility(View.VISIBLE); videoTitleToggleArrow.setImageResource(R.drawable.arrow_up);
videoTitleToggleArrow.setImageResource(R.drawable.arrow_up);
}
} }
} }
@ -483,6 +482,8 @@ public class VideoDetailFragment
tabLayout = rootView.findViewById(R.id.tablayout); tabLayout = rootView.findViewById(R.id.tablayout);
tabLayout.setupWithViewPager(viewPager); tabLayout.setupWithViewPager(viewPager);
relatedStreamsLayout = rootView.findViewById(R.id.relatedStreamsLayout);
setHeightThumbnail(); setHeightThumbnail();
@ -809,7 +810,7 @@ public class VideoDetailFragment
pageAdapter.addFragment(CommentsFragment.getInstance(serviceId, url, name), COMMENTS_TAB_TAG); pageAdapter.addFragment(CommentsFragment.getInstance(serviceId, url, name), COMMENTS_TAB_TAG);
} }
if(showRelatedStreams){ if(showRelatedStreams && null == relatedStreamsLayout){
//temp empty fragment. will be updated in handleResult //temp empty fragment. will be updated in handleResult
pageAdapter.addFragment(new Fragment(), RELATED_TAB_TAG); pageAdapter.addFragment(new Fragment(), RELATED_TAB_TAG);
} }
@ -1033,14 +1034,18 @@ public class VideoDetailFragment
animateView(videoTitleTextView, true, 0); animateView(videoTitleTextView, true, 0);
videoDescriptionRootLayout.setVisibility(View.GONE); videoDescriptionRootLayout.setVisibility(View.GONE);
if (videoTitleToggleArrow != null) { //phone videoTitleToggleArrow.setImageResource(R.drawable.arrow_down);
videoTitleToggleArrow.setImageResource(R.drawable.arrow_down); videoTitleToggleArrow.setVisibility(View.GONE);
videoTitleToggleArrow.setVisibility(View.GONE);
} else { //tablet
//TODO make comments/related streams fragment invisible
}
videoTitleRoot.setClickable(false); videoTitleRoot.setClickable(false);
if(relatedStreamsLayout != null){
if(showRelatedStreams){
relatedStreamsLayout.setVisibility(View.INVISIBLE);
}else{
relatedStreamsLayout.setVisibility(View.GONE);
}
}
imageLoader.cancelDisplayTask(thumbnailImageView); imageLoader.cancelDisplayTask(thumbnailImageView);
imageLoader.cancelDisplayTask(uploaderThumb); imageLoader.cancelDisplayTask(uploaderThumb);
thumbnailImageView.setImageBitmap(null); thumbnailImageView.setImageBitmap(null);
@ -1054,8 +1059,15 @@ public class VideoDetailFragment
setInitialData(info.getServiceId(), info.getOriginalUrl(), info.getName()); setInitialData(info.getServiceId(), info.getOriginalUrl(), info.getName());
if(showRelatedStreams){ if(showRelatedStreams){
pageAdapter.updateItem(RELATED_TAB_TAG, RelatedVideosFragment.getInstance(currentInfo)); if(null == relatedStreamsLayout){ //phone
pageAdapter.notifyDataSetUpdate(); pageAdapter.updateItem(RELATED_TAB_TAG, RelatedVideosFragment.getInstance(currentInfo));
pageAdapter.notifyDataSetUpdate();
}else{ //tablet
getChildFragmentManager().beginTransaction()
.replace(R.id.relatedStreamsLayout, RelatedVideosFragment.getInstance(currentInfo))
.commitNow();
relatedStreamsLayout.setVisibility(View.VISIBLE);
}
} }
pushToStack(serviceId, url, name); pushToStack(serviceId, url, name);
@ -1120,14 +1132,10 @@ public class VideoDetailFragment
} }
videoDescriptionView.setVisibility(View.GONE); videoDescriptionView.setVisibility(View.GONE);
if (videoTitleToggleArrow != null) { videoTitleRoot.setClickable(true);
videoTitleRoot.setClickable(true); videoTitleToggleArrow.setVisibility(View.VISIBLE);
videoTitleToggleArrow.setVisibility(View.VISIBLE); videoTitleToggleArrow.setImageResource(R.drawable.arrow_down);
videoTitleToggleArrow.setImageResource(R.drawable.arrow_down); videoDescriptionRootLayout.setVisibility(View.GONE);
videoDescriptionRootLayout.setVisibility(View.GONE);
} else {
videoDescriptionRootLayout.setVisibility(View.VISIBLE);
}
if (!TextUtils.isEmpty(info.getUploadDate())) { if (!TextUtils.isEmpty(info.getUploadDate())) {
videoUploadDateView.setText(Localization.localizeDate(activity, info.getUploadDate())); videoUploadDateView.setText(Localization.localizeDate(activity, info.getUploadDate()));
} }

View File

@ -184,4 +184,9 @@ public class CommentsFragment extends BaseListInfoFragment<CommentsInfo> {
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
return; return;
} }
@Override
protected boolean isGridLayout() {
return false;
}
} }

View File

@ -193,4 +193,9 @@ public class RelatedVideosFragment extends BaseListInfoFragment<RelatedStreamInf
Boolean autoplay = pref.getBoolean(getString(R.string.auto_queue_key), false); Boolean autoplay = pref.getBoolean(getString(R.string.auto_queue_key), false);
aSwitch.setChecked(autoplay); aSwitch.setChecked(autoplay);
} }
@Override
protected boolean isGridLayout() {
return false;
}
} }

View File

@ -8,107 +8,121 @@
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
android:orientation="horizontal"> android:orientation="horizontal">
<com.nirhart.parallaxscroll.views.ParallaxScrollView <android.support.design.widget.CoordinatorLayout
android:id="@+id/detail_main_content" android:id="@+id/detail_main_content"
app:parallax_factor="1.9"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_weight="5"> android:layout_weight="5"
android:fitsSystemWindows="true">
<!--WRAPPER--> <android.support.design.widget.AppBarLayout
<LinearLayout android:id="@+id/appbarlayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:fitsSystemWindows="true"
app:elevation="0dp"
app:layout_behavior="android.support.design.widget.FlingBehavior">
<!-- THUMBNAIL --> <android.support.design.widget.CollapsingToolbarLayout
<FrameLayout
android:id="@+id/detail_thumbnail_root_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@android:color/black" app:layout_scrollFlags="scroll">
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground">
<ImageView <!-- THUMBNAIL -->
android:id="@+id/detail_thumbnail_image_view" <FrameLayout
android:id="@+id/detail_thumbnail_root_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@android:color/transparent" android:background="@android:color/black"
android:contentDescription="@string/detail_thumbnail_view_description" android:clickable="true"
android:scaleType="fitCenter" android:focusable="true"
tools:ignore="RtlHardcoded" android:foreground="?attr/selectableItemBackground"
tools:layout_height="200dp" app:layout_collapseMode="parallax">
tools:src="@drawable/dummy_thumbnail" />
<ImageView <ImageView
android:id="@+id/detail_thumbnail_play_button" android:id="@+id/detail_thumbnail_image_view"
android:layout_width="64dp" android:layout_width="match_parent"
android:layout_height="64dp" android:layout_height="wrap_content"
android:layout_gravity="center" android:background="@android:color/transparent"
android:background="@android:color/transparent" android:contentDescription="@string/detail_thumbnail_view_description"
android:src="@drawable/new_play_arrow" android:scaleType="fitCenter"
android:visibility="invisible" tools:ignore="RtlHardcoded"
tools:ignore="ContentDescription" tools:layout_height="200dp"
tools:visibility="visible" /> tools:src="@drawable/dummy_thumbnail" />
<TextView <ImageView
android:id="@+id/touch_append_detail" android:id="@+id/detail_thumbnail_play_button"
android:layout_width="wrap_content" android:layout_width="64dp"
android:layout_height="wrap_content" android:layout_height="64dp"
android:layout_gravity="center" android:layout_gravity="center"
android:background="#64000000" android:background="@android:color/transparent"
android:paddingBottom="10dp" android:src="@drawable/new_play_arrow"
android:paddingLeft="30dp" android:visibility="invisible"
android:paddingRight="30dp" tools:ignore="ContentDescription"
android:paddingTop="10dp" tools:visibility="visible" />
android:text="@string/hold_to_append"
android:textColor="@android:color/white"
android:textSize="20sp"
android:textStyle="bold"
android:visibility="gone"
tools:ignore="RtlHardcoded"
tools:visibility="visible" />
<TextView <TextView
android:id="@+id/detail_duration_view" android:id="@+id/touch_append_detail"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|right" android:layout_gravity="center"
android:layout_marginBottom="8dp" android:background="#64000000"
android:layout_marginLeft="12dp" android:paddingBottom="10dp"
android:layout_marginRight="12dp" android:paddingLeft="30dp"
android:layout_marginTop="8dp" android:paddingRight="30dp"
android:alpha=".6" android:paddingTop="10dp"
android:background="#23000000" android:text="@string/hold_to_append"
android:gravity="center" android:textColor="@android:color/white"
android:paddingBottom="2dp" android:textSize="20sp"
android:paddingLeft="6dp" android:textStyle="bold"
android:paddingRight="6dp" android:visibility="gone"
android:paddingTop="2dp" tools:ignore="RtlHardcoded"
android:textAllCaps="true" tools:visibility="visible" />
android:textColor="@android:color/white"
android:textSize="12sp" <TextView
android:textStyle="bold" android:id="@+id/detail_duration_view"
android:visibility="gone" android:layout_width="wrap_content"
tools:ignore="RtlHardcoded" android:layout_height="wrap_content"
tools:text="12:38" android:layout_gravity="bottom|right"
tools:visibility="visible" /> android:layout_marginBottom="8dp"
</FrameLayout> android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="8dp"
android:alpha=".6"
android:background="#23000000"
android:gravity="center"
android:paddingBottom="2dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:paddingTop="2dp"
android:textAllCaps="true"
android:textColor="@android:color/white"
android:textSize="12sp"
android:textStyle="bold"
android:visibility="gone"
tools:ignore="RtlHardcoded"
tools:text="12:38"
tools:visibility="visible" />
</FrameLayout>
</android.support.design.widget.CollapsingToolbarLayout>
<!-- CONTENT --> <!-- CONTENT -->
<RelativeLayout <RelativeLayout
android:id="@+id/detail_content_root_layout" android:id="@+id/detail_content_root_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:background="?android:windowBackground"> android:background="?android:windowBackground"
app:layout_scrollFlags="scroll">
<!-- TITLE --> <!-- TITLE -->
<FrameLayout <FrameLayout
android:id="@+id/detail_title_root_layout" android:id="@+id/detail_title_root_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:paddingLeft="12dp" android:paddingLeft="12dp"
android:paddingRight="12dp"> android:paddingRight="12dp">
@ -126,6 +140,15 @@
tools:ignore="RtlHardcoded" tools:ignore="RtlHardcoded"
tools:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed a ultricies ex. Integer sit amet sodales risus. Duis non mi et urna pretium bibendum. Nunc eleifend est quis ipsum porttitor egestas. Sed facilisis, nisl quis eleifend pellentesque, orci metus egestas dolor, at accumsan eros metus quis libero." /> tools:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed a ultricies ex. Integer sit amet sodales risus. Duis non mi et urna pretium bibendum. Nunc eleifend est quis ipsum porttitor egestas. Sed facilisis, nisl quis eleifend pellentesque, orci metus egestas dolor, at accumsan eros metus quis libero." />
<ImageView
android:id="@+id/detail_toggle_description_view"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="center_vertical|right"
android:layout_marginLeft="5dp"
android:src="@drawable/arrow_down"
tools:ignore="ContentDescription,RtlHardcoded" />
</FrameLayout> </FrameLayout>
<!-- LOADING INDICATOR--> <!-- LOADING INDICATOR-->
@ -209,17 +232,17 @@
tools:text="Uploader" /> tools:text="Uploader" />
<!--<Button <!--<Button
android:id="@+id/detail_uploader_subscribe" android:id="@+id/detail_uploader_subscribe"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right" android:layout_gravity="center_vertical|right"
android:layout_marginRight="12dp" android:layout_marginRight="12dp"
android:text="@string/rss_button_title" android:text="@string/rss_button_title"
android:textSize="12sp" android:textSize="12sp"
android:theme="@style/RedButton" android:theme="@style/RedButton"
android:drawableLeft="@drawable/ic_rss_feed_white_24dp" android:drawableLeft="@drawable/ic_rss_feed_white_24dp"
tools:ignore="RtlHardcoded" tools:ignore="RtlHardcoded"
android:visibility="gone"/>--> android:visibility="gone"/>-->
</LinearLayout> </LinearLayout>
<!-- VIEW & THUMBS --> <!-- VIEW & THUMBS -->
@ -401,7 +424,9 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:orientation="vertical"> android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible">
<TextView <TextView
android:id="@+id/detail_upload_date_view" android:id="@+id/detail_upload_date_view"
@ -435,57 +460,39 @@
android:background="?attr/separator_color" /> android:background="?attr/separator_color" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
</LinearLayout>
</com.nirhart.parallaxscroll.views.ParallaxScrollView> </android.support.design.widget.AppBarLayout>
<ScrollView
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.TabLayout
android:id="@+id/tablayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:background="@color/transparent_background_color"
app:tabBackground="@drawable/tab_selector"
app:tabGravity="center"
app:tabIndicatorHeight="0dp">
</android.support.design.widget.TabLayout>
</android.support.design.widget.CoordinatorLayout>
<FrameLayout
android:id="@+id/relatedStreamsLayout"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="3"> android:layout_weight="3">
<!--NEXT AND RELATED VIDEOS--> </FrameLayout>
<LinearLayout
android:id="@+id/detail_related_streams_root_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingTop="14dp"
android:paddingBottom="8dp"
android:orientation="vertical">
<TextView
android:id="@+id/detail_next_stream_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:text="@string/next_video_title"
android:textAllCaps="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="@dimen/video_item_detail_next_text_size"
tools:ignore="RtlHardcoded" />
<LinearLayout
android:id="@+id/detail_related_streams_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="2dp"
android:orientation="vertical"
tools:minHeight="50dp" />
<ImageButton
android:id="@+id/detail_related_streams_expand"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:paddingBottom="10dp"
android:paddingTop="4dp"
android:src="?attr/expand"
android:textAlignment="center"
android:textAllCaps="true"
tools:ignore="ContentDescription" />
</LinearLayout>
</ScrollView>
</LinearLayout> </LinearLayout>