Merge branch 'left-padding' into 'master'

Add left padding on first screenshot to match header

See merge request fdroid/fdroidclient!851
This commit is contained in:
Hans-Christoph Steiner 2019-10-30 11:29:07 +00:00
commit 7c0cb2064e
3 changed files with 34 additions and 18 deletions

View File

@ -6,6 +6,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Build;
import android.support.annotation.DrawableRes;
@ -719,11 +720,13 @@ public class AppDetailsRecyclerViewAdapter
private class ScreenShotsViewHolder extends AppDetailsViewHolder
implements ScreenShotsRecyclerViewAdapter.Listener {
final RecyclerView recyclerView;
LinearLayoutManagerSnapHelper snapHelper;
ItemDecorator itemDecorator;
ScreenShotsViewHolder(View view) {
super(view);
recyclerView = (RecyclerView) view.findViewById(R.id.screenshots);
recyclerView = view.findViewById(R.id.screenshots);
itemDecorator = new ItemDecorator(context);
recyclerView.addItemDecoration(itemDecorator);
}
@Override
@ -734,17 +737,31 @@ public class AppDetailsRecyclerViewAdapter
recyclerView.setAdapter(adapter);
recyclerView.setHasFixedSize(true);
recyclerView.setNestedScrollingEnabled(false);
if (snapHelper != null) {
snapHelper.attachToRecyclerView(null);
}
snapHelper = new LinearLayoutManagerSnapHelper(lm);
snapHelper.attachToRecyclerView(recyclerView);
}
@Override
public void onScreenshotClick(int position) {
context.startActivity(ScreenShotsActivity.getStartIntent(context, app.packageName, position));
}
private class ItemDecorator extends RecyclerView.ItemDecoration {
private final Context context;
ItemDecorator(Context context) {
this.context = context.getApplicationContext();
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int position = parent.getChildAdapterPosition(view);
int padding = (int) context.getResources().getDimension(R.dimen.details_activity_padding_screenshot);
if (position == 0) {
outRect.set(padding, view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom());
} else {
outRect.set(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom());
}
}
}
}
private class DonateViewHolder extends AppDetailsViewHolder {

View File

@ -41,12 +41,10 @@
app:popupTheme="@style/AppThemeLight.PopupOverlay" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
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/rvDetails"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@ -5,6 +5,7 @@
<dimen name="material_listitem_height">48dp</dimen>
<dimen name="app_bar_height">180dp</dimen>
<dimen name="details_activity_padding">16dp</dimen>
<dimen name="details_activity_padding_screenshot">14dp</dimen>
<dimen name="details_activity__collapsable_lists__padding__vertical">3dp</dimen>
<!-- This is in addition to the padding that almost all items in the app details screen have