Improves appBar in media

This commit is contained in:
stom79 2017-12-22 16:48:37 +01:00
parent 6acceedf90
commit db2a0647b0
2 changed files with 97 additions and 80 deletions

View File

@ -27,6 +27,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
@ -89,7 +90,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
private File fileVideo;
private TextView progress;
private boolean canSwipe;
private AppBarLayout appBar;
@ -167,7 +168,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
public void run() {
// DO DELAYED STUFF
if(canSwipe)
getSupportActionBar().hide();
appBar.setExpanded(false);
}
}, 2000);
}
@ -177,6 +178,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
loader = findViewById(R.id.loader);
imageView = findViewById(R.id.media_picture);
videoView = findViewById(R.id.media_video);
appBar = findViewById(R.id.appBar);
prev = findViewById(R.id.media_prev);
next = findViewById(R.id.media_next);
changeDrawableColor(getApplicationContext(), prev,R.color.mastodonC4);
@ -200,7 +202,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
public void onMatrixChanged(RectF rect) {
canSwipe = (imageView.getScale() == 1 );
if( !canSwipe && getSupportActionBar() != null && getSupportActionBar().isShowing()){
getSupportActionBar().hide();
appBar.setExpanded(false);
}
}
});
@ -224,13 +226,13 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
public boolean dispatchTouchEvent(MotionEvent event) {
if( event.getAction() == MotionEvent.ACTION_DOWN){
if( getSupportActionBar() != null && !getSupportActionBar().isShowing() && canSwipe) {
getSupportActionBar().show();
if( getSupportActionBar() != null && canSwipe) {
appBar.setExpanded(true);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
getSupportActionBar().hide();
appBar.setExpanded(false);
}
}, 2000);
}

View File

@ -15,84 +15,99 @@
You should have received a copy of the GNU General Public License along with Mastalab; if not,
see <http://www.gnu.org/licenses>.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_container_media">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:fitsSystemWindows="true"
>
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="match_parent"
tools:context="fr.gouv.etalab.mastodon.activities.HashTagActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="@style/AppThemeDark_NoActionBar"
app:popupTheme="?attr/popupOverlay"/>
</android.support.design.widget.AppBarLayout>
<com.github.chrisbanes.photoview.PhotoView
android:visibility="gone"
android:layout_below="@+id/appBar"
android:layout_centerInParent="true"
android:id="@+id/media_picture"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="ContentDescription" />
<VideoView
android:layout_centerInParent="true"
android:visibility="gone"
android:id="@+id/media_video"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:theme="@style/AppTheme.AppBarOverlay"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
android:theme="@style/AppThemeDark_NoActionBar"
app:popupTheme="?attr/popupOverlay"/>
</android.support.design.widget.AppBarLayout>
<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="match_parent"
android:id="@+id/main_container_media">
<com.github.chrisbanes.photoview.PhotoView
android:visibility="gone"
android:layout_centerInParent="true"
android:id="@+id/media_picture"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="ContentDescription" />
<VideoView
android:layout_centerInParent="true"
android:visibility="gone"
android:id="@+id/media_video"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageView
android:visibility="gone"
android:layout_margin="5dp"
android:src="@drawable/ic_first_page"
android:id="@+id/media_prev"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_width="20dp"
android:layout_height="20dp"
tools:ignore="ContentDescription" />
<ImageView
android:visibility="gone"
android:layout_margin="5dp"
android:id="@+id/media_next"
android:src="@drawable/ic_last_page"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_width="20dp"
android:layout_height="20dp"
tools:ignore="ContentDescription" />
<!-- Main Loader -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<ProgressBar
android:id="@+id/pbar_inf"
android:layout_width="50dp"
android:layout_height="50dp"
android:indeterminate="true" />
<TextView
android:id="@+id/loader_progress"
android:textSize="12sp"
android:visibility="gone"
android:layout_marginTop="10dp"
android:textColor="?attr/colorAccent"
android:layout_below="@+id/pbar_inf"
android:layout_width="50dp"
android:gravity="center"
android:layout_height="wrap_content" />
</RelativeLayout>
</RelativeLayout>
<ImageView
android:visibility="gone"
android:layout_margin="5dp"
android:src="@drawable/ic_first_page"
android:id="@+id/media_prev"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_width="20dp"
android:layout_height="20dp"
tools:ignore="ContentDescription" />
<ImageView
android:visibility="gone"
android:layout_margin="5dp"
android:id="@+id/media_next"
android:src="@drawable/ic_last_page"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_width="20dp"
android:layout_height="20dp"
tools:ignore="ContentDescription" />
<!-- Main Loader -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<ProgressBar
android:id="@+id/pbar_inf"
android:layout_width="50dp"
android:layout_height="50dp"
android:indeterminate="true" />
<TextView
android:id="@+id/loader_progress"
android:textSize="12sp"
android:visibility="gone"
android:layout_marginTop="10dp"
android:textColor="?attr/colorAccent"
android:layout_below="@+id/pbar_inf"
android:layout_width="50dp"
android:gravity="center"
android:layout_height="wrap_content" />
</RelativeLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.DrawerLayout>