aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-07-08 01:00:49 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-07-08 01:00:49 +0000
commit61d907308cd0944e99ef61cf6d2abe77f988e357 (patch)
tree4975b061684c31ab922b44bb75bce0926bb49c47 /app/src
parent6eecaaccfa358d0dfd9ef3b514db5faad9c96edd (diff)
downloadinfinity-for-reddit-61d907308cd0944e99ef61cf6d2abe77f988e357.tar
infinity-for-reddit-61d907308cd0944e99ef61cf6d2abe77f988e357.tar.gz
infinity-for-reddit-61d907308cd0944e99ef61cf6d2abe77f988e357.tar.bz2
infinity-for-reddit-61d907308cd0944e99ef61cf6d2abe77f988e357.tar.lz
infinity-for-reddit-61d907308cd0944e99ef61cf6d2abe77f988e357.tar.xz
infinity-for-reddit-61d907308cd0944e99ef61cf6d2abe77f988e357.tar.zst
infinity-for-reddit-61d907308cd0944e99ef61cf6d2abe77f988e357.zip
Share rpan post url and rpan url. Show rpan post title in ViewRPANBroadcastFragment.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/RPANBroadcast.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java46
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java5
-rw-r--r--app/src/main/res/layout/exo_rpan_broadcast_playback_control_view.xml11
-rw-r--r--app/src/main/res/layout/item_rpan_comment.xml2
-rw-r--r--app/src/main/res/menu/rpan_activity.xml15
-rw-r--r--app/src/main/res/values/strings.xml2
7 files changed, 90 insertions, 3 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RPANBroadcast.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RPANBroadcast.java
index 1d317e2d..d7c936c2 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/RPANBroadcast.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RPANBroadcast.java
@@ -3,6 +3,8 @@ package ml.docilealligator.infinityforreddit;
import android.os.Parcel;
import android.os.Parcelable;
+import ml.docilealligator.infinityforreddit.utils.APIUtils;
+
public class RPANBroadcast implements Parcelable {
public int upvotes;
@@ -76,7 +78,7 @@ public class RPANBroadcast implements Parcelable {
parcel.writeParcelable(rpanStream, i);
}
- public static class RPANPost implements Parcelable{
+ public static class RPANPost implements Parcelable {
public String fullname;
public String title;
public String subredditName;
@@ -86,6 +88,7 @@ public class RPANBroadcast implements Parcelable {
public String voteState;
public double upvoteRatio;
public String postPermalink;
+ public String rpanUrl;
public boolean isNsfw;
public boolean isLocked;
public boolean isArchived;
@@ -105,7 +108,8 @@ public class RPANBroadcast implements Parcelable {
this.postScore = postScore;
this.voteState = voteState;
this.upvoteRatio = upvoteRatio;
- this.postPermalink = postPermalink;
+ this.postPermalink = APIUtils.API_BASE_URI + postPermalink;
+ this.rpanUrl = rpanUrl;
this.isNsfw = isNsfw;
this.isLocked = isLocked;
this.isArchived = isArchived;
@@ -115,6 +119,7 @@ public class RPANBroadcast implements Parcelable {
}
protected RPANPost(Parcel in) {
+ fullname = in.readString();
title = in.readString();
subredditName = in.readString();
subredditIconUrl = in.readString();
@@ -123,6 +128,7 @@ public class RPANBroadcast implements Parcelable {
voteState = in.readString();
upvoteRatio = in.readDouble();
postPermalink = in.readString();
+ rpanUrl = in.readString();
isNsfw = in.readByte() != 0;
isLocked = in.readByte() != 0;
isArchived = in.readByte() != 0;
@@ -150,6 +156,7 @@ public class RPANBroadcast implements Parcelable {
@Override
public void writeToParcel(Parcel parcel, int i) {
+ parcel.writeString(fullname);
parcel.writeString(title);
parcel.writeString(subredditName);
parcel.writeString(subredditIconUrl);
@@ -158,6 +165,7 @@ public class RPANBroadcast implements Parcelable {
parcel.writeString(voteState);
parcel.writeDouble(upvoteRatio);
parcel.writeString(postPermalink);
+ parcel.writeString(rpanUrl);
parcel.writeByte((byte) (isNsfw ? 1 : 0));
parcel.writeByte((byte) (isLocked ? 1 : 0));
parcel.writeByte((byte) (isArchived ? 1 : 0));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java
index cc4c83ef..8f681676 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java
@@ -1,5 +1,7 @@
package ml.docilealligator.infinityforreddit.activities;
+import android.content.ActivityNotFoundException;
+import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
@@ -7,6 +9,8 @@ import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.Handler;
+import android.view.Menu;
+import android.view.MenuItem;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.Toast;
@@ -241,6 +245,48 @@ public class RPANActivity extends AppCompatActivity {
} 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 {
public SectionsPagerAdapter(FragmentActivity fa) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java
index 09aa6ee7..400de425 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRPANBroadcastFragment.java
@@ -12,6 +12,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
+import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
@@ -70,6 +71,8 @@ public class ViewRPANBroadcastFragment extends Fragment {
ConstraintLayout constraintLayout;
@BindView(R.id.player_view_view_rpan_broadcast_fragment)
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)
RecyclerView recyclerView;
@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() {
float x1;
float x2;
diff --git a/app/src/main/res/layout/exo_rpan_broadcast_playback_control_view.xml b/app/src/main/res/layout/exo_rpan_broadcast_playback_control_view.xml
index 9ee2582f..e0d11e64 100644
--- a/app/src/main/res/layout/exo_rpan_broadcast_playback_control_view.xml
+++ b/app/src/main/res/layout/exo_rpan_broadcast_playback_control_view.xml
@@ -7,6 +7,17 @@
android:focusableInTouchMode="true"
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
android:id="@+id/control_linear_layout"
android:layout_width="match_parent"
diff --git a/app/src/main/res/layout/item_rpan_comment.xml b/app/src/main/res/layout/item_rpan_comment.xml
index 97f8969f..54ace9c5 100644
--- a/app/src/main/res/layout/item_rpan_comment.xml
+++ b/app/src/main/res/layout/item_rpan_comment.xml
@@ -3,7 +3,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
- android:paddingBottom="8dp">
+ android:layout_marginBottom="8dp">
<ImageView
android:id="@+id/icon_image_view_item_rpan_comment"
diff --git a/app/src/main/res/menu/rpan_activity.xml b/app/src/main/res/menu/rpan_activity.xml
new file mode 100644
index 00000000..bb165fd4
--- /dev/null
+++ b/app/src/main/res/menu/rpan_activity.xml
@@ -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> \ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 1d6753ba..c095dfc0 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -84,6 +84,8 @@
<string name="action_copy_link">Copy Link</string>
<string name="action_add_to_post_filter">Add to Post Filter</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="retrieve_token_error">Error Retrieving the token</string>