Commit 379bf89c authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Animate search button appearence

parent 19f81da1
......@@ -7,8 +7,9 @@
<include layout="@layout/tab_layout" />
<include layout="@layout/button_search"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@+id/sliding_tabs"
android:layout_marginTop="@dimen/default_margin"
android:layout_marginLeft="@dimen/default_margin"
......
......@@ -2,7 +2,7 @@
<Button xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/searchButton"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:targetApi="11"
style="?android:attr/borderlessButtonStyle"
......
......@@ -21,7 +21,7 @@
android:layout_height="match_parent"
android:background="?attr/background_default" >
<include layout="@layout/button_search"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<org.videolan.vlc.gui.view.SwipeRefreshLayout
android:id="@+id/swipeLayout"
......@@ -9,24 +10,41 @@
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:background="?attr/background_default">
<android.support.v7.widget.RecyclerView
android:id="@android:id/list"
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="10dp"
android:paddingBottom="@dimen/listview_bottom_padding"
android:paddingLeft="@dimen/listview_side_padding"
android:paddingRight="@dimen/listview_side_padding" />
android:layout_height="match_parent">
<include layout="@layout/button_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.v7.widget.RecyclerView
android:id="@android:id/list"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/searchButton"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:clipToPadding="false"
android:paddingTop="10dp"
android:paddingBottom="@dimen/listview_bottom_padding"
android:paddingLeft="@dimen/listview_side_padding"
android:paddingRight="@dimen/listview_side_padding" />
<TextView
android:id="@+id/android:empty"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/searchButton"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:gravity="center"
android:paddingTop="30dip"
android:text="@string/nohistory"
android:textSize="20sp"
android:visibility="gone"/>
</android.support.constraint.ConstraintLayout>
</org.videolan.vlc.gui.view.SwipeRefreshLayout>
<TextView
android:id="@+id/android:empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:paddingTop="30dip"
android:text="@string/nohistory"
android:textSize="20sp"
android:visibility="gone"/>
</FrameLayout>
\ No newline at end of file
......@@ -3,7 +3,10 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/button_search" />
<include layout="@layout/button_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"/>
<org.videolan.vlc.gui.view.SwipeRefreshLayout
android:id="@+id/swipeLayout"
......
......@@ -248,7 +248,4 @@ public class HistoryFragment extends MediaBrowserFragment<HistoryProvider> imple
invalidateActionMode();
UiTools.updateSortTitles(this);
}
@Override
public void setSearchVisibility(boolean visible) {}
}
......@@ -142,7 +142,6 @@ public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeR
mSwipeRefreshLayout = v.findViewById(R.id.swipeLayout);
mSwipeRefreshLayout.setOnRefreshListener(this);
mSearchButtonView = v.findViewById(R.id.searchButton);
return v;
}
......
......@@ -132,7 +132,6 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements SwipeRefre
mFastScroller = view.findViewById(R.id.songs_fast_scroller);
mTabLayout = view.findViewById(R.id.sliding_tabs);
mSwipeRefreshLayout = view.findViewById(R.id.swipeLayout);
mSearchButtonView = view.findViewById(R.id.searchButton);
}
@Override
......
......@@ -138,7 +138,6 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment<BrowserPr
mRecyclerView = view.findViewById(R.id.network_list);
mEmptyView = view.findViewById(R.id.empty);
mSwipeRefreshLayout = view.findViewById(R.id.swipeLayout);
mSearchButtonView = view.findViewById(R.id.searchButton);
}
@Override
......
......@@ -28,7 +28,10 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.constraint.ConstraintLayout;
import android.support.constraint.ConstraintSet;
import android.support.design.widget.FloatingActionButton;
import android.support.transition.TransitionManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
......@@ -67,7 +70,7 @@ public abstract class MediaBrowserFragment<T extends BaseModel> extends Fragment
public final static String TAG = "VLC/MediaBrowserFragment";
public View mSearchButtonView;
private View mSearchButtonView;
protected SwipeRefreshLayout mSwipeRefreshLayout;
protected Medialibrary mMediaLibrary;
protected ActionMode mActionMode;
......@@ -88,6 +91,7 @@ public abstract class MediaBrowserFragment<T extends BaseModel> extends Fragment
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mSearchButtonView = view.findViewById(R.id.searchButton);
if (mSwipeRefreshLayout != null) mSwipeRefreshLayout.setColorSchemeResources(R.color.orange700);
mFabPlay = getActivity().findViewById(R.id.fab);
}
......@@ -320,6 +324,14 @@ public abstract class MediaBrowserFragment<T extends BaseModel> extends Fragment
@Override
public void setSearchVisibility(boolean visible) {
UiTools.setViewVisibility(mSearchButtonView, visible ? View.VISIBLE : View.GONE);
if ((mSearchButtonView.getVisibility() == View.VISIBLE) == visible) return;
if (mSearchButtonView.getParent() instanceof ConstraintLayout) {
final ConstraintLayout cl = (ConstraintLayout) mSearchButtonView.getParent();
final ConstraintSet cs = new ConstraintSet();
cs.clone(cl);
cs.setVisibility(R.id.searchButton, visible ? ConstraintSet.VISIBLE : ConstraintSet.GONE);
TransitionManager.beginDelayedTransition(cl);
cs.applyTo(cl);
} else UiTools.setViewVisibility(mSearchButtonView, visible ? View.VISIBLE : View.GONE);
}
}
......@@ -124,7 +124,6 @@ public class VideoGridFragment extends MediaBrowserFragment<VideosProvider> impl
mViewNomedia = v.findViewById(android.R.id.empty);
mGridView = v.findViewById(android.R.id.list);
mSwipeRefreshLayout = v.findViewById(R.id.swipeLayout);
mSearchButtonView = v.findViewById(R.id.searchButton);
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment