mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
some improvements
This commit is contained in:
parent
7119c12467
commit
98385aa706
4 changed files with 82 additions and 69 deletions
|
@ -15,6 +15,7 @@ package app.fedilab.android.peertube.activities;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import static com.google.android.exoplayer2.Player.MEDIA_ITEM_TRANSITION_REASON_AUTO;
|
||||
import static app.fedilab.android.BaseMainActivity.currentAccount;
|
||||
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN;
|
||||
import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.ADD_COMMENT;
|
||||
import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.ActionType.RATEVIDEO;
|
||||
|
@ -126,6 +127,7 @@ import java.util.regex.Pattern;
|
|||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.BasePeertubeActivity;
|
||||
import app.fedilab.android.databinding.ActivityPeertubeBinding;
|
||||
import app.fedilab.android.databinding.PopupVideoInfoPeertubeBinding;
|
||||
import app.fedilab.android.mastodon.client.entities.app.BaseAccount;
|
||||
import app.fedilab.android.mastodon.exception.DBException;
|
||||
import app.fedilab.android.mastodon.helper.CacheDataSourceFactory;
|
||||
|
@ -266,7 +268,9 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
sepiaSearch = b.getBoolean("sepia_search", false);
|
||||
peertube = (VideoData.Video) b.getSerializable("video");
|
||||
}
|
||||
|
||||
if (currentAccount != null && currentAccount.peertube_account != null) {
|
||||
binding.myAcct.setText(String.format("@%s@%s", currentAccount.peertube_account.getUsername(), currentAccount.instance));
|
||||
}
|
||||
|
||||
willPlayFromIntent = manageIntentUrl(intent);
|
||||
|
||||
|
@ -876,35 +880,28 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
|
||||
binding.videoInformation.setOnClickListener(v -> {
|
||||
AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(PeertubeActivity.this, app.fedilab.android.mastodon.helper.Helper.dialogStyle());
|
||||
LayoutInflater inflater = getLayoutInflater();
|
||||
View dialogView = inflater.inflate(R.layout.popup_video_info_peertube, new LinearLayout(PeertubeActivity.this), false);
|
||||
TextView info_privacy = dialogView.findViewById(R.id.info_privacy);
|
||||
TextView info_published_at = dialogView.findViewById(R.id.info_published_at);
|
||||
TextView info_category = dialogView.findViewById(R.id.info_category);
|
||||
TextView info_license = dialogView.findViewById(R.id.info_license);
|
||||
TextView info_language = dialogView.findViewById(R.id.info_language);
|
||||
TextView info_duration = dialogView.findViewById(R.id.info_duration);
|
||||
TextView info_tags = dialogView.findViewById(R.id.info_tags);
|
||||
|
||||
PopupVideoInfoPeertubeBinding videoInfo = PopupVideoInfoPeertubeBinding.inflate(getLayoutInflater());
|
||||
|
||||
LinkedHashMap<Integer, String> privaciesInit = new LinkedHashMap<>(peertubeInformation.getPrivacies());
|
||||
info_privacy.setText(privaciesInit.get(peertube.getPrivacy().getId()));
|
||||
videoInfo.infoPrivacy.setText(privaciesInit.get(peertube.getPrivacy().getId()));
|
||||
LinkedHashMap<Integer, String> licenseInit = new LinkedHashMap<>(peertubeInformation.getLicences());
|
||||
info_license.setText(licenseInit.get(peertube.getLicence().getId()));
|
||||
videoInfo.infoLicense.setText(licenseInit.get(peertube.getLicence().getId()));
|
||||
LinkedHashMap<String, String> languageStr = new LinkedHashMap<>(peertubeInformation.getLanguages());
|
||||
info_language.setText(languageStr.get(peertube.getLanguage().getId()));
|
||||
videoInfo.infoLanguage.setText(languageStr.get(peertube.getLanguage().getId()));
|
||||
LinkedHashMap<Integer, String> categoryInit = new LinkedHashMap<>(peertubeInformation.getCategories());
|
||||
info_category.setText(categoryInit.get(peertube.getCategory().getId()));
|
||||
videoInfo.infoCategory.setText(categoryInit.get(peertube.getCategory().getId()));
|
||||
|
||||
if (peertube.isLive()) {
|
||||
info_duration.setText(R.string.live);
|
||||
info_duration.setBackgroundResource(R.drawable.rounded_live);
|
||||
info_duration.setBackgroundResource(R.drawable.rounded_live);
|
||||
videoInfo.infoDuration.setText(R.string.live);
|
||||
videoInfo.infoDuration.setBackgroundResource(R.drawable.rounded_live);
|
||||
videoInfo.infoDuration.setBackgroundResource(R.drawable.rounded_live);
|
||||
} else {
|
||||
info_duration.setText(Helper.secondsToString(peertube.getDuration()));
|
||||
videoInfo.infoDuration.setText(Helper.secondsToString(peertube.getDuration()));
|
||||
}
|
||||
|
||||
String format = DateFormat.getDateInstance(DateFormat.LONG).format(peertube.getPublishedAt());
|
||||
info_published_at.setText(format);
|
||||
videoInfo.infoPublishedAt.setText(format);
|
||||
List<String> tags = peertube.getTags();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String tag : tags) {
|
||||
|
@ -942,9 +939,9 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis
|
|||
}
|
||||
}
|
||||
}
|
||||
info_tags.setText(spannableString, TextView.BufferType.SPANNABLE);
|
||||
info_tags.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
dialogBuilder.setView(dialogView);
|
||||
videoInfo.infoTags.setText(spannableString, TextView.BufferType.SPANNABLE);
|
||||
videoInfo.infoTags.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
dialogBuilder.setView(videoInfo.getRoot());
|
||||
dialogBuilder.setNeutralButton(R.string.close, (dialog, id) -> dialog.dismiss());
|
||||
AlertDialog alertDialog = dialogBuilder.create();
|
||||
alertDialog.show();
|
||||
|
|
|
@ -635,7 +635,7 @@ public class Helper {
|
|||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String userId = sharedpreferences.getString(PREF_USER_ID, "");
|
||||
String instance = sharedpreferences.getString(PREF_USER_INSTANCE, "");
|
||||
return account.getUserId().compareTo(userId) == 0 && account.getHost().compareTo(instance) == 0;
|
||||
return account.getId().compareTo(userId) == 0 && account.getHost().compareTo(instance) == 0;
|
||||
}
|
||||
|
||||
public static boolean isVideoOwner(Context context, VideoData.Video video) {
|
||||
|
@ -650,10 +650,10 @@ public class Helper {
|
|||
}
|
||||
AccountData.PeertubeAccount account = video.getAccount();
|
||||
ChannelData.Channel channel = video.getChannel();
|
||||
if (account != null && account.getUserId() != null && account.getHost() != null) {
|
||||
return account.getUserId().compareTo(userId) == 0 && account.getHost().compareTo(instance) == 0;
|
||||
} else if (channel != null && channel.getOwnerAccount() != null && channel.getOwnerAccount().getUserId() != null && channel.getOwnerAccount().getHost() != null) {
|
||||
return channel.getOwnerAccount().getUserId().compareTo(userId) == 0 && channel.getHost().compareTo(instance) == 0;
|
||||
if (account != null && account.getId() != null && account.getHost() != null) {
|
||||
return account.getId().compareTo(userId) == 0 && account.getHost().compareTo(instance) == 0;
|
||||
} else if (channel != null && channel.getOwnerAccount() != null && channel.getOwnerAccount().getId() != null && channel.getOwnerAccount().getHost() != null) {
|
||||
return channel.getOwnerAccount().getId().compareTo(userId) == 0 && channel.getHost().compareTo(instance) == 0;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
android:keepScreenOn="true"
|
||||
tools:context=".peertube.activities.PeertubeActivity">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
|
@ -67,7 +67,7 @@
|
|||
android:visibility="invisible"
|
||||
app:yt_playerView="@+id/doubleTapPlayerView" />
|
||||
|
||||
<ImageView
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/watermark"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="40dp"
|
||||
|
@ -107,33 +107,37 @@
|
|||
android:id="@+id/bottom_video"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="@dimen/fab_margin"
|
||||
android:layout_marginEnd="@dimen/fab_margin"
|
||||
android:paddingStart="@dimen/fab_margin"
|
||||
android:paddingEnd="@dimen/fab_margin"
|
||||
android:layout_weight="2">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/peertube_information_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:colorBackground"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
app:cardElevation="1dp"
|
||||
app:strokeWidth="0dp">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -141,7 +145,7 @@
|
|||
android:orientation="horizontal"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/peertube_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -179,7 +183,7 @@
|
|||
android:layout_marginRight="10dp"
|
||||
android:contentDescription="@string/profile_picture" />
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/peertube_view_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -194,7 +198,7 @@
|
|||
app:drawableTopCompat="@drawable/ic_baseline_visibility_24"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/peertube_like_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -209,7 +213,7 @@
|
|||
app:drawableTopCompat="@drawable/ic_baseline_thumb_up_alt_24"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/peertube_dislike_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -260,7 +264,7 @@
|
|||
tools:ignore="UselessLeaf" />
|
||||
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/more_actions"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -276,7 +280,7 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/peertube_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -284,24 +288,17 @@
|
|||
android:autoLink="web"
|
||||
android:textIsSelectable="true" />
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/peertube_description_more"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:text="@string/show_more"
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:textColor="?attr/colorPrimary"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/post_comment_button"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/add_public_comment" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/peertube_comments"
|
||||
|
@ -309,13 +306,21 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/post_comment_button"
|
||||
style="@style/Widget.Material3.Button.OutlinedButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/add_public_comment" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/no_action"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/no_action_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -325,7 +330,8 @@
|
|||
android:text="@string/no_comments"
|
||||
android:textSize="20sp" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
|
@ -334,6 +340,7 @@
|
|||
android:layout_height="match_parent"
|
||||
android:background="?android:colorBackground"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
@ -375,7 +382,7 @@
|
|||
android:layout_height="match_parent"
|
||||
android:background="@android:color/black"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/video_params"
|
||||
|
@ -432,7 +439,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/comment_account_profile"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
|
@ -441,7 +448,7 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/comment_account_displayname"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -452,7 +459,7 @@
|
|||
app:layout_constraintStart_toEndOf="@+id/comment_account_profile"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/comment_account_username"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -464,7 +471,7 @@
|
|||
app:layout_constraintStart_toEndOf="@+id/comment_account_profile"
|
||||
app:layout_constraintTop_toBottomOf="@+id/comment_account_displayname" />
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/comment_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -477,7 +484,7 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/comment_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -513,7 +520,7 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/separator_top">
|
||||
|
||||
<ImageView
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/my_pp"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
|
@ -521,13 +528,21 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/my_acct"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
app:layout_constraintStart_toEndOf="@+id/my_pp"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/text_field_boxes"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/my_pp"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/my_pp">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/add_comment_write"
|
||||
|
@ -540,9 +555,9 @@
|
|||
android:minLines="4" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<Button
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/send"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
style="@style/Widget.Material3.Button.OutlinedButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/send_comment"
|
||||
|
@ -582,7 +597,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/subMenuTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -15,8 +15,9 @@
|
|||
see <http://www.gnu.org/licenses>.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="10dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
|
|
Loading…
Reference in a new issue