-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Match Livestreaming UX flow to odysee.com
UX flow: - Clicking the Upload button shows menu to pick Upload or Go Live - Create livestreams with form like publishing - Choose New Livestream or Upload Replay Replays shown in pages of 4 like on odysee.com - Choose Anytime or Scheduled Time stream - Clicking the Create button goes to livestreams dashboard (also accessible from user menu) - Livestreams dashboard shows stream server and stream key, with button to copy - Dashboard waits for created claim to finish confirming then enables Start Streaming button - Clicking Start Streaming goes to activity that streams with HaishinKit - Streaming activity sets FLAG_KEEP_SCREEN_ON in onCreate instead of when streaming starts. Also removes flag only onDestroy. Changes of note: - There are now 3 publish tasks: - PublishClaimTask uses the LBRY API - ReplayPublishTask uses the v1 Odysee Publish API - TusPublishTask uses the v2 Odysee Publish API (uses Tus for upload) - Add buildPublishOptions function in Helper to create options map from Claim. Fix: #93 Fix: #94 Fix (partial): #232 (app reloading after accepting permissions to camera/audio when trying to go live)
- Loading branch information
1 parent
6295915
commit 6289456
Showing
47 changed files
with
3,477 additions
and
866 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
app/src/main/java/com/odysee/app/adapter/ReplaysPagerAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package com.odysee.app.adapter; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.fragment.app.Fragment; | ||
import androidx.fragment.app.FragmentActivity; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
import androidx.viewpager2.adapter.FragmentStateAdapter; | ||
|
||
import com.odysee.app.model.LivestreamReplay; | ||
import com.odysee.app.ui.publish.ReplaysPageFragment; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.IntStream; | ||
|
||
public class ReplaysPagerAdapter extends FragmentStateAdapter { | ||
private static final int PAGE_SIZE = 4; | ||
|
||
private final List<LivestreamReplay> replays; | ||
private final SelectedReplayManager manager; | ||
|
||
// Needed because default getItemId() uses position so fragments | ||
// don't get changed when calling notifyDataSetChanged(). | ||
private long idCounter = 0; | ||
private List<Long> itemIds; | ||
|
||
public ReplaysPagerAdapter(FragmentActivity activity, List<LivestreamReplay> replays, SelectedReplayManager manager) { | ||
super(activity); | ||
this.replays = replays; | ||
this.manager = manager; | ||
|
||
LivestreamReplay selectedReplay = manager.getSelectedReplay(); | ||
if (selectedReplay != null) { | ||
for (LivestreamReplay replay : replays) { | ||
if (replay.getUrl().equals(selectedReplay.getUrl())) { | ||
replay.setSelected(true); | ||
} | ||
} | ||
} | ||
|
||
this.itemIds = generateItemIds(); | ||
RecyclerView.AdapterDataObserver observer = new RecyclerView.AdapterDataObserver() { | ||
@Override | ||
public void onChanged() { | ||
itemIds = generateItemIds(); | ||
} | ||
}; | ||
registerAdapterDataObserver(observer); | ||
} | ||
|
||
private List<Long> generateItemIds() { | ||
return IntStream.range(0, getItemCount()) | ||
.mapToObj(unused -> idCounter++) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public Fragment createFragment(int position) { | ||
ReplaysPageFragment fragment = new ReplaysPageFragment(); | ||
fragment.setReplays(replays.subList( | ||
position * 4, Math.min((position * 4) + 4, replays.size()))); | ||
fragment.setListener(new ReplaysPageFragment.ReplaySelectedListener() { | ||
@Override | ||
public void onReplaySelected(LivestreamReplay replay) { | ||
LivestreamReplay selectedReplay = manager.getSelectedReplay(); | ||
if (selectedReplay != null) { | ||
selectedReplay.setSelected(false); | ||
} | ||
replay.setSelected(true); | ||
manager.setSelectedReplay(replay); | ||
notifyDataSetChanged(); | ||
} | ||
}); | ||
return fragment; | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return (int) Math.ceil(replays.size() / (double) PAGE_SIZE); | ||
} | ||
|
||
@Override | ||
public long getItemId(int position) { | ||
return itemIds.get(position); | ||
} | ||
|
||
@Override | ||
public boolean containsItem(long itemId) { | ||
return itemIds.contains(itemId); | ||
} | ||
|
||
public interface SelectedReplayManager { | ||
LivestreamReplay getSelectedReplay(); | ||
void setSelectedReplay(LivestreamReplay replay); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
app/src/main/java/com/odysee/app/model/LivestreamReplay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.odysee.app.model; | ||
|
||
import com.google.gson.FieldNamingPolicy; | ||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
import com.google.gson.annotations.SerializedName; | ||
|
||
import org.json.JSONObject; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class LivestreamReplay { | ||
private String status; | ||
private String percentComplete; | ||
@SerializedName("URL") | ||
private String url; | ||
@SerializedName("ThumbnailURLs") | ||
private List<String> thumbnailUrls; | ||
private long duration; | ||
private Date created; | ||
|
||
public boolean selected; | ||
|
||
public static LivestreamReplay fromJSONObject(JSONObject replayObject) { | ||
String replayJson = replayObject.toString(); | ||
|
||
Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE).create(); | ||
|
||
return gson.fromJson(replayJson, LivestreamReplay.class); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/odysee/app/tasks/LivestreamReplaysResultHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.odysee.app.tasks; | ||
|
||
import com.odysee.app.model.LivestreamReplay; | ||
|
||
import java.util.List; | ||
|
||
public interface LivestreamReplaysResultHandler { | ||
void onSuccess(List<LivestreamReplay> replays); | ||
void onError(Exception error); | ||
} |
Oops, something went wrong.