New layouts
This commit is contained in:
parent
bff5b7852c
commit
e50cb8a403
|
@ -124,7 +124,7 @@ dependencies {
|
||||||
implementation 'com.github.penfeizhou.android.animation:gif:1.1.0'
|
implementation 'com.github.penfeizhou.android.animation:gif:1.1.0'
|
||||||
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
|
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
|
||||||
implementation "me.leolin:ShortcutBadger:1.1.22@aar"
|
implementation "me.leolin:ShortcutBadger:1.1.22@aar"
|
||||||
|
implementation 'com.github.smarteist:autoimageslider:1.3.2'
|
||||||
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-2'
|
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-2'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
|
@ -56,8 +56,12 @@ import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||||
import com.bumptech.glide.request.RequestListener;
|
import com.bumptech.glide.request.RequestListener;
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
|
import com.smarteist.autoimageslider.IndicatorAnimations;
|
||||||
|
import com.smarteist.autoimageslider.SliderAnimations;
|
||||||
|
import com.smarteist.autoimageslider.SliderView;
|
||||||
import com.varunest.sparkbutton.SparkButton;
|
import com.varunest.sparkbutton.SparkButton;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -339,7 +343,8 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
||||||
|
|
||||||
|
|
||||||
private class ViewHolderPixelfed extends RecyclerView.ViewHolder {
|
private class ViewHolderPixelfed extends RecyclerView.ViewHolder {
|
||||||
ImageView art_media, pf_pp, pf_comment;
|
SliderView imageSlider;
|
||||||
|
ImageView pf_pp, pf_comment;
|
||||||
SparkButton pf_fav, pf_share;
|
SparkButton pf_fav, pf_share;
|
||||||
TextView pf_username, pf_likes, pf_description, pf_date;
|
TextView pf_username, pf_likes, pf_description, pf_date;
|
||||||
CardView pf_cardview;
|
CardView pf_cardview;
|
||||||
|
@ -357,7 +362,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
||||||
|
|
||||||
ViewHolderPixelfed(View itemView) {
|
ViewHolderPixelfed(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
art_media = itemView.findViewById(R.id.art_media);
|
imageSlider = itemView.findViewById(R.id.imageSlider);
|
||||||
pf_pp = itemView.findViewById(R.id.pf_pp);
|
pf_pp = itemView.findViewById(R.id.pf_pp);
|
||||||
pf_username = itemView.findViewById(R.id.pf_username);
|
pf_username = itemView.findViewById(R.id.pf_username);
|
||||||
pf_likes = itemView.findViewById(R.id.pf_likes);
|
pf_likes = itemView.findViewById(R.id.pf_likes);
|
||||||
|
@ -441,25 +446,13 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
||||||
}else{
|
}else{
|
||||||
holder.pixelfed_comments.setVisibility(View.GONE);
|
holder.pixelfed_comments.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
boolean expand_media = sharedpreferences.getBoolean(Helper.SET_EXPAND_MEDIA, false);
|
if (status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0){
|
||||||
if (status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0)
|
SliderAdapter sliderAdapter = new SliderAdapter(new WeakReference<>(context), status.getMedia_attachments());
|
||||||
GlideApp.with(context)
|
holder.imageSlider.setSliderAdapter(sliderAdapter);
|
||||||
.asBitmap()
|
holder.imageSlider.setIndicatorAnimation(IndicatorAnimations.WORM);
|
||||||
.load(status.getMedia_attachments().get(0).getPreview_url())
|
holder.imageSlider.setSliderTransformAnimation(SliderAnimations.SIMPLETRANSFORMATION);
|
||||||
.listener(new RequestListener<Bitmap>() {
|
|
||||||
@Override
|
|
||||||
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
|
|
||||||
if (status.isSensitive())
|
|
||||||
notifyStatusChanged(status);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.into(holder.art_media);
|
|
||||||
|
|
||||||
holder.pf_likes.setText(context.getResources().getQuantityString(R.plurals.likes, status.getFavourites_count(), status.getFavourites_count()));
|
holder.pf_likes.setText(context.getResources().getQuantityString(R.plurals.likes, status.getFavourites_count(), status.getFavourites_count()));
|
||||||
holder.pf_pp.setOnClickListener(new View.OnClickListener() {
|
holder.pf_pp.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -477,22 +470,6 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
holder.art_media.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
Intent intent = new Intent(context, MediaActivity.class);
|
|
||||||
Bundle b = new Bundle();
|
|
||||||
ArrayList<Attachment> attachments = new ArrayList<>();
|
|
||||||
if (status.getArt_attachment() != null)
|
|
||||||
attachments.add(status.getArt_attachment());
|
|
||||||
else if (status.getMedia_attachments() != null && status.getMedia_attachments().size() > 0)
|
|
||||||
attachments.add(status.getMedia_attachments().get(0));
|
|
||||||
intent.putParcelableArrayListExtra("mediaArray", attachments);
|
|
||||||
b.putInt("position", 0);
|
|
||||||
intent.putExtras(b);
|
|
||||||
context.startActivity(intent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
holder.quick_reply_switch_to_full.setVisibility(View.GONE);
|
holder.quick_reply_switch_to_full.setVisibility(View.GONE);
|
||||||
|
@ -504,6 +481,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
||||||
sendToot(null);
|
sendToot(null);
|
||||||
status.setShortReply(false);
|
status.setShortReply(false);
|
||||||
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||||
|
assert imm != null;
|
||||||
imm.hideSoftInputFromWindow(holder.quick_reply_button.getWindowToken(), 0);
|
imm.hideSoftInputFromWindow(holder.quick_reply_button.getWindowToken(), 0);
|
||||||
});
|
});
|
||||||
theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
package app.fedilab.android.drawers;
|
||||||
|
/* Copyright 2019 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of Fedilab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.smarteist.autoimageslider.SliderViewAdapter;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import app.fedilab.android.R;
|
||||||
|
import app.fedilab.android.activities.MediaActivity;
|
||||||
|
import app.fedilab.android.client.Entities.Attachment;
|
||||||
|
|
||||||
|
|
||||||
|
public class SliderAdapter extends SliderViewAdapter<SliderAdapter.SliderAdapterVH> {
|
||||||
|
|
||||||
|
private ArrayList<Attachment> attachments;
|
||||||
|
private WeakReference<Context> contextWeakReference;
|
||||||
|
|
||||||
|
SliderAdapter(WeakReference<Context> contextWeakReference, ArrayList<Attachment> attachments) {
|
||||||
|
this.attachments = attachments;
|
||||||
|
this.contextWeakReference = contextWeakReference;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SliderAdapterVH onCreateViewHolder(ViewGroup parent) {
|
||||||
|
View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.image_slider_layout_item, parent, false);
|
||||||
|
return new SliderAdapterVH(inflate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(SliderAdapterVH viewHolder, int position) {
|
||||||
|
|
||||||
|
if( attachments.size() > 1) {
|
||||||
|
viewHolder.textViewDescription.setText(String.format("%s/%s", (position + 1), attachments.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Glide.with(viewHolder.imageViewBackground.getContext())
|
||||||
|
.load(attachments.get(position).getPreview_url())
|
||||||
|
.into(viewHolder.imageViewBackground);
|
||||||
|
viewHolder.imageViewBackground.setContentDescription(attachments.get(position).getDescription());
|
||||||
|
viewHolder.imageViewBackground.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(contextWeakReference.get(), MediaActivity.class);
|
||||||
|
Bundle b = new Bundle();
|
||||||
|
|
||||||
|
intent.putParcelableArrayListExtra("mediaArray", attachments);
|
||||||
|
b.putInt("position", (position+1));
|
||||||
|
intent.putExtras(b);
|
||||||
|
contextWeakReference.get().startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
//slider view count could be dynamic size
|
||||||
|
return attachments.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
class SliderAdapterVH extends SliderViewAdapter.ViewHolder {
|
||||||
|
|
||||||
|
ImageView imageViewBackground;
|
||||||
|
TextView textViewDescription;
|
||||||
|
|
||||||
|
SliderAdapterVH(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
imageViewBackground = itemView.findViewById(R.id.iv_auto_image_slider);
|
||||||
|
textViewDescription = itemView.findViewById(R.id.tv_auto_image_slider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,6 +15,7 @@
|
||||||
see <http://www.gnu.org/licenses>.
|
see <http://www.gnu.org/licenses>.
|
||||||
-->
|
-->
|
||||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/pf_cardview"
|
android:id="@+id/pf_cardview"
|
||||||
|
@ -50,15 +51,27 @@
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
tools:ignore="RtlHardcoded" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
<com.smarteist.autoimageslider.SliderView
|
||||||
<ImageView
|
android:id="@+id/imageSlider"
|
||||||
android:id="@+id/art_media"
|
|
||||||
android:scaleType="fitCenter"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="300dp"
|
||||||
|
app:sliderAnimationDuration="1000"
|
||||||
|
app:sliderAutoCycleDirection="back_and_forth"
|
||||||
|
app:sliderAutoCycleEnabled="true"
|
||||||
|
app:sliderCircularHandlerEnabled="true"
|
||||||
|
app:sliderIndicatorAnimationDuration="600"
|
||||||
|
app:sliderIndicatorGravity="center_horizontal|bottom"
|
||||||
|
app:sliderIndicatorMargin="15dp"
|
||||||
|
app:sliderIndicatorOrientation="horizontal"
|
||||||
|
app:sliderIndicatorPadding="3dp"
|
||||||
|
app:sliderIndicatorRadius="2dp"
|
||||||
|
app:sliderIndicatorSelectedColor="#5A5A5A"
|
||||||
|
app:sliderIndicatorUnselectedColor="#FFF"
|
||||||
|
app:sliderScrollTimeInSec="1"
|
||||||
|
app:sliderStartAutoCycle="false" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright 2019 Thomas Schneider
|
||||||
|
|
||||||
|
This file is a part of Fedilab
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||||
|
see <http://www.gnu.org/licenses>.
|
||||||
|
-->
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_auto_image_slider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:adjustViewBounds="true" />
|
||||||
|
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_gif_container"
|
||||||
|
android:layout_width="80dp"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
android:layout_gravity="bottom|start"
|
||||||
|
android:layout_margin="50dp" />
|
||||||
|
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/fl_shadow_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_auto_image_slider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginBottom="25dp"
|
||||||
|
android:padding="6dp"
|
||||||
|
android:textColor="#FFF"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
Loading…
Reference in New Issue