mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-13 05:52:48 +01:00
Share rpan post url and rpan url. Show rpan post title in ViewRPANBroadcastFragment.
This commit is contained in:
parent
6eecaaccfa
commit
61d907308c
@ -3,6 +3,8 @@ package ml.docilealligator.infinityforreddit;
|
|||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.utils.APIUtils;
|
||||||
|
|
||||||
public class RPANBroadcast implements Parcelable {
|
public class RPANBroadcast implements Parcelable {
|
||||||
|
|
||||||
public int upvotes;
|
public int upvotes;
|
||||||
@ -76,7 +78,7 @@ public class RPANBroadcast implements Parcelable {
|
|||||||
parcel.writeParcelable(rpanStream, i);
|
parcel.writeParcelable(rpanStream, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RPANPost implements Parcelable{
|
public static class RPANPost implements Parcelable {
|
||||||
public String fullname;
|
public String fullname;
|
||||||
public String title;
|
public String title;
|
||||||
public String subredditName;
|
public String subredditName;
|
||||||
@ -86,6 +88,7 @@ public class RPANBroadcast implements Parcelable {
|
|||||||
public String voteState;
|
public String voteState;
|
||||||
public double upvoteRatio;
|
public double upvoteRatio;
|
||||||
public String postPermalink;
|
public String postPermalink;
|
||||||
|
public String rpanUrl;
|
||||||
public boolean isNsfw;
|
public boolean isNsfw;
|
||||||
public boolean isLocked;
|
public boolean isLocked;
|
||||||
public boolean isArchived;
|
public boolean isArchived;
|
||||||
@ -105,7 +108,8 @@ public class RPANBroadcast implements Parcelable {
|
|||||||
this.postScore = postScore;
|
this.postScore = postScore;
|
||||||
this.voteState = voteState;
|
this.voteState = voteState;
|
||||||
this.upvoteRatio = upvoteRatio;
|
this.upvoteRatio = upvoteRatio;
|
||||||
this.postPermalink = postPermalink;
|
this.postPermalink = APIUtils.API_BASE_URI + postPermalink;
|
||||||
|
this.rpanUrl = rpanUrl;
|
||||||
this.isNsfw = isNsfw;
|
this.isNsfw = isNsfw;
|
||||||
this.isLocked = isLocked;
|
this.isLocked = isLocked;
|
||||||
this.isArchived = isArchived;
|
this.isArchived = isArchived;
|
||||||
@ -115,6 +119,7 @@ public class RPANBroadcast implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected RPANPost(Parcel in) {
|
protected RPANPost(Parcel in) {
|
||||||
|
fullname = in.readString();
|
||||||
title = in.readString();
|
title = in.readString();
|
||||||
subredditName = in.readString();
|
subredditName = in.readString();
|
||||||
subredditIconUrl = in.readString();
|
subredditIconUrl = in.readString();
|
||||||
@ -123,6 +128,7 @@ public class RPANBroadcast implements Parcelable {
|
|||||||
voteState = in.readString();
|
voteState = in.readString();
|
||||||
upvoteRatio = in.readDouble();
|
upvoteRatio = in.readDouble();
|
||||||
postPermalink = in.readString();
|
postPermalink = in.readString();
|
||||||
|
rpanUrl = in.readString();
|
||||||
isNsfw = in.readByte() != 0;
|
isNsfw = in.readByte() != 0;
|
||||||
isLocked = in.readByte() != 0;
|
isLocked = in.readByte() != 0;
|
||||||
isArchived = in.readByte() != 0;
|
isArchived = in.readByte() != 0;
|
||||||
@ -150,6 +156,7 @@ public class RPANBroadcast implements Parcelable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel parcel, int i) {
|
public void writeToParcel(Parcel parcel, int i) {
|
||||||
|
parcel.writeString(fullname);
|
||||||
parcel.writeString(title);
|
parcel.writeString(title);
|
||||||
parcel.writeString(subredditName);
|
parcel.writeString(subredditName);
|
||||||
parcel.writeString(subredditIconUrl);
|
parcel.writeString(subredditIconUrl);
|
||||||
@ -158,6 +165,7 @@ public class RPANBroadcast implements Parcelable {
|
|||||||
parcel.writeString(voteState);
|
parcel.writeString(voteState);
|
||||||
parcel.writeDouble(upvoteRatio);
|
parcel.writeDouble(upvoteRatio);
|
||||||
parcel.writeString(postPermalink);
|
parcel.writeString(postPermalink);
|
||||||
|
parcel.writeString(rpanUrl);
|
||||||
parcel.writeByte((byte) (isNsfw ? 1 : 0));
|
parcel.writeByte((byte) (isNsfw ? 1 : 0));
|
||||||
parcel.writeByte((byte) (isLocked ? 1 : 0));
|
parcel.writeByte((byte) (isLocked ? 1 : 0));
|
||||||
parcel.writeByte((byte) (isArchived ? 1 : 0));
|
parcel.writeByte((byte) (isArchived ? 1 : 0));
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package ml.docilealligator.infinityforreddit.activities;
|
package ml.docilealligator.infinityforreddit.activities;
|
||||||
|
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
@ -7,6 +9,8 @@ import android.graphics.drawable.Drawable;
|
|||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@ -241,6 +245,48 @@ public class RPANActivity extends AppCompatActivity {
|
|||||||
} catch (NoSuchFieldException | IllegalAccessException ignore) {}
|
} catch (NoSuchFieldException | IllegalAccessException ignore) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.rpan_activity, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
if (item.getItemId() == android.R.id.home) {
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.action_share_rpan_link_rpan_activity) {
|
||||||
|
if (rpanBroadcasts != null) {
|
||||||
|
int position = viewPager2.getCurrentItem();
|
||||||
|
if (position >= 0 && position < rpanBroadcasts.size()) {
|
||||||
|
shareLink(rpanBroadcasts.get(position).rpanPost.rpanUrl);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (item.getItemId() == R.id.action_share_post_link_rpan_activity) {
|
||||||
|
if (rpanBroadcasts != null) {
|
||||||
|
int position = viewPager2.getCurrentItem();
|
||||||
|
if (position >= 0 && position < rpanBroadcasts.size()) {
|
||||||
|
shareLink(rpanBroadcasts.get(position).rpanPost.postPermalink);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shareLink(String link) {
|
||||||
|
try {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||||
|
intent.setType("text/plain");
|
||||||
|
intent.putExtra(Intent.EXTRA_TEXT, link);
|
||||||
|
startActivity(Intent.createChooser(intent, getString(R.string.share)));
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(this, R.string.no_activity_found_for_share, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class SectionsPagerAdapter extends FragmentStateAdapter {
|
private class SectionsPagerAdapter extends FragmentStateAdapter {
|
||||||
|
|
||||||
public SectionsPagerAdapter(FragmentActivity fa) {
|
public SectionsPagerAdapter(FragmentActivity fa) {
|
||||||
|
@ -12,6 +12,7 @@ import android.view.MotionEvent;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@ -70,6 +71,8 @@ public class ViewRPANBroadcastFragment extends Fragment {
|
|||||||
ConstraintLayout constraintLayout;
|
ConstraintLayout constraintLayout;
|
||||||
@BindView(R.id.player_view_view_rpan_broadcast_fragment)
|
@BindView(R.id.player_view_view_rpan_broadcast_fragment)
|
||||||
PlayerView playerView;
|
PlayerView playerView;
|
||||||
|
@BindView(R.id.title_text_view_exo_rpan_broadcast_playback_control_view)
|
||||||
|
TextView titleTextView;
|
||||||
@BindView(R.id.recycler_view_exo_rpan_broadcast_playback_control_view)
|
@BindView(R.id.recycler_view_exo_rpan_broadcast_playback_control_view)
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
@BindView(R.id.mute_exo_rpan_broadcast_playback_control_view)
|
@BindView(R.id.mute_exo_rpan_broadcast_playback_control_view)
|
||||||
@ -226,6 +229,8 @@ public class ViewRPANBroadcastFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
titleTextView.setText(rpanBroadcast.rpanPost.title);
|
||||||
|
|
||||||
recyclerView.setOnTouchListener(new View.OnTouchListener() {
|
recyclerView.setOnTouchListener(new View.OnTouchListener() {
|
||||||
float x1;
|
float x1;
|
||||||
float x2;
|
float x2;
|
||||||
|
@ -7,6 +7,17 @@
|
|||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title_text_view_exo_rpan_broadcast_playback_control_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:textColor="#FFFFFF"
|
||||||
|
android:textSize="20sp"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/control_linear_layout"
|
||||||
|
app:layout_constraintVertical_bias="1" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/control_linear_layout"
|
android:id="@+id/control_linear_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:paddingBottom="8dp">
|
android:layout_marginBottom="8dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/icon_image_view_item_rpan_comment"
|
android:id="@+id/icon_image_view_item_rpan_comment"
|
||||||
|
15
app/src/main/res/menu/rpan_activity.xml
Normal file
15
app/src/main/res/menu/rpan_activity.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_share_rpan_link_rpan_activity"
|
||||||
|
android:orderInCategory="1"
|
||||||
|
android:title="@string/action_share_rpan_link"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_share_post_link_rpan_activity"
|
||||||
|
android:orderInCategory="1"
|
||||||
|
android:title="@string/action_share_post_link"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
</menu>
|
@ -84,6 +84,8 @@
|
|||||||
<string name="action_copy_link">Copy Link</string>
|
<string name="action_copy_link">Copy Link</string>
|
||||||
<string name="action_add_to_post_filter">Add to Post Filter</string>
|
<string name="action_add_to_post_filter">Add to Post Filter</string>
|
||||||
<string name="action_delete_logs">Delete Logs</string>
|
<string name="action_delete_logs">Delete Logs</string>
|
||||||
|
<string name="action_share_rpan_link">Share RPAN Link</string>
|
||||||
|
<string name="action_share_post_link">Share Post Link</string>
|
||||||
|
|
||||||
<string name="parse_json_response_error">Error occurred when parsing the JSON response</string>
|
<string name="parse_json_response_error">Error occurred when parsing the JSON response</string>
|
||||||
<string name="retrieve_token_error">Error Retrieving the token</string>
|
<string name="retrieve_token_error">Error Retrieving the token</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user