comment #330 - Add stories timeline

This commit is contained in:
tom79 2019-11-02 11:44:27 +01:00
parent 941ed792ed
commit 97c0512f14
10 changed files with 853 additions and 2 deletions

View File

@ -110,6 +110,7 @@ import app.fedilab.android.fragments.DisplayNotificationsFragment;
import app.fedilab.android.fragments.DisplayPeertubeNotificationsFragment;
import app.fedilab.android.fragments.DisplayPlaylistsFragment;
import app.fedilab.android.fragments.DisplayStatusFragment;
import app.fedilab.android.fragments.DisplayStoriesFragment;
import app.fedilab.android.fragments.SettingsPeertubeFragment;
import app.fedilab.android.fragments.TabLayoutNotificationsFragment;
import app.fedilab.android.fragments.TabLayoutScheduleFragment;
@ -584,12 +585,14 @@ public abstract class BaseMainActivity extends BaseActivity
TabLayout.Tab pfTabHome = tabLayout.newTab();
TabLayout.Tab pfTabLocal = tabLayout.newTab();
TabLayout.Tab pfTabNotification = tabLayout.newTab();
TabLayout.Tab pfTabStories = tabLayout.newTab();
//TabLayout.Tab pfTabDiscover = tabLayout.newTab();
pfTabHome.setCustomView(R.layout.tab_badge);
pfTabLocal.setCustomView(R.layout.tab_badge);
pfTabNotification.setCustomView(R.layout.tab_badge);
pfTabStories.setCustomView(R.layout.tab_badge);
//pfTabDiscover.setCustomView(R.layout.tab_badge);
@ -613,6 +616,11 @@ public abstract class BaseMainActivity extends BaseActivity
ImageView iconNotif = pfTabNotification.getCustomView().findViewById(R.id.tab_icon);
iconNotif.setImageResource(R.drawable.ic_notifications);
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
ImageView iconStories = pfTabStories.getCustomView().findViewById(R.id.tab_icon);
iconStories.setImageResource(R.drawable.ic_story);
/*@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
ImageView iconDiscover = pfTabDiscover.getCustomView().findViewById(R.id.tab_icon);
iconDiscover.setImageResource(R.drawable.ic_people);*/
@ -622,23 +630,27 @@ public abstract class BaseMainActivity extends BaseActivity
// iconDiscover.setContentDescription(getString(R.string.overview));
iconLocal.setContentDescription(getString(R.string.local));
iconNotif.setContentDescription(getString(R.string.notifications));
iconStories.setContentDescription(getString(R.string.stories));
if (theme == Helper.THEME_LIGHT) {
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
// iconDiscover.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
iconLocal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
iconNotif.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
iconStories.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
} else {
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
// iconDiscover.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
iconLocal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
iconNotif.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
iconStories.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
}
tabLayout.addTab(pfTabHome);
tabLayout.addTab(pfTabLocal);
tabLayout.addTab(pfTabNotification);
tabLayout.addTab(pfTabStories);
// tabLayout.addTab(pfTabDiscover);
tabLayout.setTabMode(TabLayout.MODE_FIXED);
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
@ -2523,6 +2535,8 @@ public abstract class BaseMainActivity extends BaseActivity
bundle.putSerializable("type", DisplayNotificationsFragment.Type.ALL);
fragment.setArguments(bundle);
return fragment;
}else if (position == 3) {
return new DisplayStoriesFragment();
}
/*else if( position == 3) {
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PF_DISCOVER);

View File

@ -0,0 +1,58 @@
/* 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>. */
package app.fedilab.android.asynctasks;
import android.content.Context;
import android.os.AsyncTask;
import java.lang.ref.WeakReference;
import app.fedilab.android.client.APIResponse;
import app.fedilab.android.client.PixelfedAPI;
import app.fedilab.android.interfaces.OnRetrieveStoriesInterface;
/**
* Created by Thomas on 02/11/2019.
* Retrieves stories on the instance
*/
public class RetrieveStoriesAsyncTask extends AsyncTask<Void, Void, Void> {
private APIResponse apiResponse;
private String max_id;
private OnRetrieveStoriesInterface listener;
private WeakReference<Context> contextReference;
public RetrieveStoriesAsyncTask(Context context, String max_id, OnRetrieveStoriesInterface onRetrieveStoriesInterface) {
this.contextReference = new WeakReference<>(context);
this.max_id = max_id;
this.listener = onRetrieveStoriesInterface;
}
@Override
protected Void doInBackground(Void... params) {
PixelfedAPI pixelfedAPI = new PixelfedAPI(this.contextReference.get());
apiResponse = pixelfedAPI.getFriendStories(max_id);
return null;
}
@Override
protected void onPostExecute(Void result) {
listener.onRetrieveStories(apiResponse);
}
}

View File

@ -0,0 +1,231 @@
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.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
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 androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.FitCenter;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.smarteist.autoimageslider.IndicatorAnimations;
import com.smarteist.autoimageslider.SliderAnimations;
import com.smarteist.autoimageslider.SliderView;
import com.varunest.sparkbutton.SparkButton;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import app.fedilab.android.R;
import app.fedilab.android.activities.SlideMediaActivity;
import app.fedilab.android.client.Entities.Attachment;
import app.fedilab.android.client.Entities.PixelFedStory;
import app.fedilab.android.client.Entities.PixelFedStoryItem;
import app.fedilab.android.helper.Helper;
;
/**
* Created by Thomas on 02/11/2019.
* Adapter for pixelfed stories drawer
*/
public class PixelfedStoriesListAdapter extends RecyclerView.Adapter {
private Context context;
private List<PixelFedStory> stories;
private static final int DISPLAYED_STATUS = 1;
private ArrayList<Attachment> attachments;
public PixelfedStoriesListAdapter(List<PixelFedStory> stories) {
super();
this.stories = stories;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public int getItemCount() {
return stories.size();
}
private class ViewHolderPixelfed extends RecyclerView.ViewHolder {
SliderView imageSlider;
ImageView art_media, art_media_play, pf_pp;
SparkButton pf_share;
TextView pf_username, pf_date;
CardView pf_cardview;
ViewHolderPixelfed(View itemView) {
super(itemView);
art_media = itemView.findViewById(R.id.art_media);
art_media_play = itemView.findViewById(R.id.art_media_play);
imageSlider = itemView.findViewById(R.id.imageSlider);
pf_pp = itemView.findViewById(R.id.pf_pp);
pf_username = itemView.findViewById(R.id.pf_username);
pf_date = itemView.findViewById(R.id.pf_date);
pf_share = itemView.findViewById(R.id.pf_share);
pf_cardview = itemView.findViewById(R.id.pf_cardview);
}
}
public PixelFedStory getItem(int position) {
if (stories.size() > position && position >= 0)
return stories.get(position);
else return null;
}
@Override
public int getItemViewType(int position) {
return DISPLAYED_STATUS;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
context = parent.getContext();
LayoutInflater layoutInflater = LayoutInflater.from(this.context);
return new ViewHolderPixelfed(layoutInflater.inflate(R.layout.drawer_pixelfed_story, parent, false));
}
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
final ViewHolderPixelfed holder = (ViewHolderPixelfed) viewHolder;
final PixelFedStory pixelFedStory = stories.get(viewHolder.getAdapterPosition());
attachments = new ArrayList<>();
for(PixelFedStoryItem pixelFedStoryItem: pixelFedStory.getPixelFedStoryItems()){
Attachment attachment = new Attachment();
if( pixelFedStoryItem.getPreview() != null){
attachment.setPreview_url(pixelFedStoryItem.getPreview());
}else{
attachment.setPreview_url(pixelFedStoryItem.getSrc());
}
attachment.setUrl(pixelFedStoryItem.getSrc());
attachment.setId(pixelFedStoryItem.getId());
attachment.setId(pixelFedStoryItem.getId());
attachment.setDescription(pixelFedStoryItem.getLinkText());
attachment.setType(pixelFedStoryItem.getType());
}
Glide.with(context)
.load(pixelFedStory.getPhoto())
.apply(new RequestOptions().transforms(new FitCenter(), new RoundedCorners(270)))
.into(holder.pf_pp);
holder.art_media.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, SlideMediaActivity.class);
Bundle b = new Bundle();
intent.putParcelableArrayListExtra("mediaArray", attachments);
b.putInt("position", 1);
intent.putExtras(b);
context.startActivity(intent);
}
});
holder.art_media_play.setVisibility(View.GONE);
if (attachments != null && attachments.size() > 1){
SliderAdapter sliderAdapter = new SliderAdapter(new WeakReference<>((Activity)context), false, attachments);
holder.imageSlider.setSliderAdapter(sliderAdapter);
holder.imageSlider.setIndicatorAnimation(IndicatorAnimations.WORM);
holder.imageSlider.setSliderTransformAnimation(SliderAnimations.SIMPLETRANSFORMATION);
holder.art_media.setVisibility(View.GONE);
holder.imageSlider.setVisibility(View.VISIBLE);
}else if(attachments != null ){
holder.art_media.setVisibility(View.VISIBLE);
holder.imageSlider.setVisibility(View.GONE);
if( attachments.get(0).getType().toLowerCase().equals("video")){
holder.art_media_play.setVisibility(View.VISIBLE);
}
String url;
if(attachments.get(0).getPreview_url().endsWith("no-preview.png") ){
url = attachments.get(0).getUrl();
}else{
url = attachments.get(0).getPreview_url();
}
Glide.with(holder.itemView.getContext())
.asBitmap()
.load(url)
.thumbnail(0.1f)
.into(holder.art_media);
}
holder.pf_date.setText(Helper.longDateToString(pixelFedStory.getLastUpdated()));
holder.pf_username.setText(pixelFedStory.getName());
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
if (theme == Helper.THEME_BLACK) {
holder.pf_share.setInActiveImageTint(R.color.action_black);
Helper.changeDrawableColor(context, R.drawable.ic_share_media, R.color.action_black);
holder.pf_cardview.setCardBackgroundColor(ContextCompat.getColor(context, R.color.black_3));
} else if (theme == Helper.THEME_DARK) {
holder.pf_share.setInActiveImageTint(R.color.action_dark);
Helper.changeDrawableColor(context, R.drawable.ic_share_media, R.color.action_black);
holder.pf_cardview.setCardBackgroundColor(ContextCompat.getColor(context, R.color.mastodonC1_));
} else {
holder.pf_share.setInActiveImageTint(R.color.action_light);
Helper.changeDrawableColor(context, R.drawable.ic_share_media, R.color.action_black);
holder.pf_cardview.setCardBackgroundColor(ContextCompat.getColor(context, R.color.white));
}
}
}

View File

@ -0,0 +1,295 @@
package app.fedilab.android.fragments;
/* 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.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import app.fedilab.android.R;
import app.fedilab.android.asynctasks.RetrieveStoriesAsyncTask;
import app.fedilab.android.client.APIResponse;
import app.fedilab.android.client.Entities.PixelFedStory;
import app.fedilab.android.drawers.PixelfedStoriesListAdapter;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.interfaces.OnRetrieveStoriesInterface;
import es.dmoral.toasty.Toasty;
/**
* Created by Thomas on 02/11/2019.
* Fragment to display PixelfFed Stories
*/
public class DisplayStoriesFragment extends Fragment implements OnRetrieveStoriesInterface {
private boolean flag_loading;
private Context context;
private AsyncTask<Void, Void, Void> asyncTask;
private PixelfedStoriesListAdapter pixelfedStoriesListAdapter;
private String max_id;
private List<PixelFedStory> pixelFedStories;
private RelativeLayout mainLoader, nextElementLoader, textviewNoAction;
private boolean firstLoad;
private SwipeRefreshLayout swipeRefreshLayout;
private boolean swiped;
private RecyclerView lv_stories;
LinearLayoutManager mLayoutManager;
public DisplayStoriesFragment() {
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_stories, container, false);
max_id = null;
context = getContext();
firstLoad = true;
flag_loading = true;
pixelFedStories = new ArrayList<>();
swiped = false;
swipeRefreshLayout = rootView.findViewById(R.id.swipeContainer);
lv_stories = rootView.findViewById(R.id.lv_stories);
mainLoader = rootView.findViewById(R.id.loader);
nextElementLoader = rootView.findViewById(R.id.loading_next_stories);
textviewNoAction = rootView.findViewById(R.id.no_action);
mainLoader.setVisibility(View.VISIBLE);
nextElementLoader.setVisibility(View.GONE);
pixelfedStoriesListAdapter = new PixelfedStoriesListAdapter(this.pixelFedStories);
lv_stories.setAdapter(pixelfedStoriesListAdapter);
mLayoutManager = new LinearLayoutManager(context);
lv_stories.setLayoutManager(mLayoutManager);
lv_stories.addOnScrollListener(new RecyclerView.OnScrollListener() {
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (dy > 0) {
int visibleItemCount = mLayoutManager.getChildCount();
int totalItemCount = mLayoutManager.getItemCount();
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
if (firstVisibleItem + visibleItemCount == totalItemCount && context != null) {
if (!flag_loading) {
flag_loading = true;
asyncTask = new RetrieveStoriesAsyncTask(context, max_id, DisplayStoriesFragment.this).execute();
nextElementLoader.setVisibility(View.VISIBLE);
}
} else {
nextElementLoader.setVisibility(View.GONE);
}
}
}
});
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
flag_loading = true;
swiped = true;
String sinceId = null;
if (pixelFedStories != null && pixelFedStories.size() > 0)
sinceId = pixelFedStories.get(0).getId();
if (context != null)
asyncTask = new RetrieveStoriesAsyncTask(context, null, DisplayStoriesFragment.this).execute();
}
});
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
switch (theme) {
case Helper.THEME_LIGHT:
swipeRefreshLayout.setColorSchemeResources(R.color.mastodonC4,
R.color.mastodonC2,
R.color.mastodonC3);
swipeRefreshLayout.setProgressBackgroundColorSchemeColor(ContextCompat.getColor(context, R.color.white));
break;
case Helper.THEME_DARK:
swipeRefreshLayout.setColorSchemeResources(R.color.mastodonC4__,
R.color.mastodonC4,
R.color.mastodonC4);
swipeRefreshLayout.setProgressBackgroundColorSchemeColor(ContextCompat.getColor(context, R.color.mastodonC1_));
break;
case Helper.THEME_BLACK:
swipeRefreshLayout.setColorSchemeResources(R.color.dark_icon,
R.color.mastodonC2,
R.color.mastodonC3);
swipeRefreshLayout.setProgressBackgroundColorSchemeColor(ContextCompat.getColor(context, R.color.black_3));
break;
}
if (context != null)
asyncTask = new RetrieveStoriesAsyncTask(context, max_id, DisplayStoriesFragment.this).execute();
else
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
if (context != null)
asyncTask = new RetrieveStoriesAsyncTask(context, max_id, DisplayStoriesFragment.this).execute();
}
}, 500);
return rootView;
}
@Override
public void onRetrieveStories(APIResponse apiResponse) {
mainLoader.setVisibility(View.GONE);
nextElementLoader.setVisibility(View.GONE);
if (apiResponse.getError() != null) {
if(apiResponse.getError().getError().length() < 100) {
Toasty.error(context, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
}else{
Toasty.error(context, getString(R.string.long_api_error,"\ud83d\ude05"), Toast.LENGTH_LONG).show();
}
flag_loading = false;
swipeRefreshLayout.setRefreshing(false);
swiped = false;
return;
}
int previousPosition = pixelFedStories.size();
max_id = apiResponse.getMax_id();
List<PixelFedStory> pixelFedStories = apiResponse.getPixelFedStories();
if (!swiped && firstLoad && (pixelFedStories == null || pixelFedStories.size() == 0))
textviewNoAction.setVisibility(View.VISIBLE);
else
textviewNoAction.setVisibility(View.GONE);
if (swiped) {
if (previousPosition > 0) {
for (int i = 0; i < previousPosition; i++) {
this.pixelFedStories.remove(0);
}
pixelfedStoriesListAdapter.notifyItemRangeRemoved(0, previousPosition);
}
swiped = false;
}
if (pixelFedStories != null && pixelFedStories.size() > 0) {
this.pixelFedStories.addAll(pixelFedStories);
pixelfedStoriesListAdapter.notifyItemRangeInserted(previousPosition, pixelFedStories.size());
} else {
if (firstLoad)
textviewNoAction.setVisibility(View.VISIBLE);
}
swipeRefreshLayout.setRefreshing(false);
firstLoad = false;
//The initial call comes from a classic tab refresh
flag_loading = (max_id == null);
}
@Override
public void onCreate(Bundle saveInstance) {
super.onCreate(saveInstance);
}
@Override
public void onAttach(@NotNull Context context) {
super.onAttach(context);
this.context = context;
}
@Override
public void onDestroy() {
super.onDestroy();
if (asyncTask != null && asyncTask.getStatus() == AsyncTask.Status.RUNNING)
asyncTask.cancel(true);
}
@Override
public void onDestroyView() {
if (lv_stories != null) {
lv_stories.setAdapter(null);
}
super.onDestroyView();
}
@Override
public void onResume() {
super.onResume();
swipeRefreshLayout.setEnabled(true);
if (context == null)
return;
if (getUserVisibleHint() && pixelFedStories != null && pixelFedStories.size() > 0) {
retrieveMissingNotifications(pixelFedStories.get(0).getId());
}
}
@Override
public void onPause() {
super.onPause();
if (swipeRefreshLayout != null) {
swipeRefreshLayout.setEnabled(false);
swipeRefreshLayout.setRefreshing(false);
swipeRefreshLayout.clearAnimation();
}
}
/**
* Called from main activity in onResume to retrieve missing notifications
*
* @param sinceId String
*/
void retrieveMissingNotifications(String sinceId) {
asyncTask = new RetrieveStoriesAsyncTask(context, null, DisplayStoriesFragment.this).execute();
}
@Override
public void setMenuVisibility(final boolean visible) {
super.setMenuVisibility(visible);
if (context == null)
return;
//Store last notification id to avoid to notify for those that have been already seen
if (visible && pixelFedStories != null && pixelFedStories.size() > 0) {
retrieveMissingNotifications(pixelFedStories.get(0).getId());
}
}
public void scrollToTop() {
if (lv_stories != null)
lv_stories.setAdapter(pixelfedStoriesListAdapter);
}
}

View File

@ -4970,11 +4970,15 @@ public class Helper {
switch (liveNotifications){
case Helper.NOTIF_LIVE:
Intent streamingIntent = new Intent(context, LiveNotificationService.class);
context.startService(streamingIntent);
try {
context.startService(streamingIntent);
}catch (Exception ignored){}
break;
case Helper.NOTIF_DELAYED:
streamingIntent = new Intent(context, LiveNotificationDelayedService.class);
context.startService(streamingIntent);
try {
context.startService(streamingIntent);
}catch (Exception ignored){}
break;
}
}

View File

@ -0,0 +1,25 @@
/* 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>. */
package app.fedilab.android.interfaces;
import app.fedilab.android.client.APIResponse;
/**
* Created by Thomas on 02/11/2019.
* Interface when stories have been retrieved
*/
public interface OnRetrieveStoriesInterface {
void onRetrieveStories(APIResponse apiResponse);
}

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M22,16L22,4c0,-1.1 -0.9,-2 -2,-2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2zM11,12l2.03,2.71L16,11l4,5L8,16l3,-4zM2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6L2,6z"/>
</vector>

View File

@ -0,0 +1,136 @@
<?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>.
-->
<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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/pf_cardview"
android:layout_marginBottom="20dp"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:layout_gravity="center"
android:gravity="center"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/pf_pp"
android:layout_gravity="center"
android:layout_width="40dp"
android:layout_height="40dp" />
<TextView
android:layout_marginLeft="15dp"
android:layout_marginStart="15dp"
android:id="@+id/pf_username"
android:textSize="16sp"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="RtlHardcoded" />
</LinearLayout>
<com.smarteist.autoimageslider.SliderView
android:id="@+id/imageSlider"
android:visibility="gone"
android:layout_width="match_parent"
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" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:visibility="gone"
android:id="@+id/art_media"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/art_media_play"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:contentDescription="@string/play_video"
android:src="@drawable/ic_play_arrow"
android:visibility="gone" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:paddingBottom="5dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.varunest.sparkbutton.SparkButton
android:layout_marginStart="15dp"
android:id="@+id/pf_share"
app:sparkbutton_activeImage="@drawable/ic_share_media"
app:sparkbutton_inActiveImage="@drawable/ic_share_media"
android:contentDescription="@string/share"
android:layout_width="30dp"
android:layout_height="30dp"
app:sparkbutton_iconSize="30dp" />
<TextView
android:layout_marginTop="5dp"
android:id="@+id/pf_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>

View File

@ -0,0 +1,81 @@
<?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>.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingLeft="@dimen/fab_margin"
android:paddingRight="@dimen/fab_margin"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Listview Notifications -->
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:id="@+id/swipeContainer"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/lv_stories"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<RelativeLayout
android:id="@+id/no_action"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:padding="10dp"
android:gravity="center"
android:textSize="25sp"
android:layout_gravity="center"
android:textStyle="italic|bold"
android:typeface="serif"
android:text="@string/no_stories"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
<!-- Main Loader -->
<RelativeLayout
android:id="@+id/loader"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true" />
</RelativeLayout>
<!-- Loader for next notifications -->
<RelativeLayout
android:id="@+id/loading_next_stories"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom|center_horizontal"
android:gravity="bottom|center_horizontal"
android:layout_height="20dp">
<ProgressBar
android:layout_width="match_parent"
android:layout_height="match_parent"
android:indeterminate="true" />
</RelativeLayout>
</RelativeLayout>

View File

@ -1244,4 +1244,6 @@
<string name="fetch_conversation">Fetching conversation</string>
<string name="order_by">Order by</string>
<string name="title_video_peertube">Title for the video</string>
<string name="stories">Stories</string>
<string name="no_stories">No stories to display!</string>
</resources>