Some fixes
This commit is contained in:
parent
38f73a5d60
commit
8ff3b81112
|
@ -233,7 +233,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
binding = ActivityPeertubeBinding.inflate(getLayoutInflater());
|
||||
View view = binding.getRoot();
|
||||
setContentView(view);
|
||||
|
@ -407,7 +406,17 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
if (autoFullscreen && autoPlay) {
|
||||
openFullscreenDialog();
|
||||
}
|
||||
binding.postCommentButton.setOnClickListener(v -> openPostComment(null, 0));
|
||||
binding.postCommentButton.setOnClickListener(v -> {
|
||||
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
|
||||
openPostComment(null, 0);
|
||||
} else {
|
||||
if (sepiaSearch) {
|
||||
Toasty.info(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@ -591,6 +600,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
VideoData.Description description = api.getVideoDescription(videoUuid);
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Runnable myRunnable = () -> {
|
||||
if (!isFinishing()) {
|
||||
if (description == null) {
|
||||
binding.peertubeDescriptionMore.setVisibility(View.GONE);
|
||||
show_more_content = null;
|
||||
|
@ -605,7 +615,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
mainHandler.post(myRunnable);
|
||||
} catch (Exception e) {
|
||||
|
@ -614,6 +624,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
}).start();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
|
@ -768,7 +779,13 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
binding.peertubeDislikeCount.setText(Helper.withSuffix(peertube.getDislikes()));
|
||||
binding.peertubeLikeCount.setText(Helper.withSuffix(peertube.getLikes()));
|
||||
binding.peertubeViewCount.setText(Helper.withSuffix(peertube.getViews()));
|
||||
loadGiF(PeertubeActivity.this, peertube.getChannel().getAvatar() != null ? peertube.getChannel().getAvatar().getPath() : null, binding.ppChannel);
|
||||
String ppChannelURL;
|
||||
if (sepiaSearch) {
|
||||
ppChannelURL = peertube.getChannel().getAvatar() != null ? "https://" + peertubeInstance + peertube.getChannel().getAvatar().getPath() : null;
|
||||
} else {
|
||||
ppChannelURL = peertube.getChannel().getAvatar() != null ? peertube.getChannel().getAvatar().getPath() : null;
|
||||
}
|
||||
loadGiF(PeertubeActivity.this, ppChannelURL, binding.ppChannel);
|
||||
binding.ppChannel.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(PeertubeActivity.this, ShowChannelActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
|
@ -1194,7 +1211,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
|
||||
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
||||
binding.peertubeReply.setVisibility(View.GONE);
|
||||
commentViewModel.getRepliesComment(videoUuid, comment.getId()).observe(PeertubeActivity.this, apiResponse -> manageVIewCommentReply(comment, apiResponse));
|
||||
commentViewModel.getRepliesComment(sepiaSearch ? peertubeInstance : null, videoUuid, comment.getId()).observe(PeertubeActivity.this, apiResponse -> manageVIewCommentReply(comment, apiResponse));
|
||||
|
||||
binding.replyThread.setVisibility(View.VISIBLE);
|
||||
TranslateAnimation animate = new TranslateAnimation(
|
||||
|
@ -1225,7 +1242,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
int height = displayMetrics.heightPixels;
|
||||
|
||||
binding.doubleTapPlayerView.hideController();
|
||||
List<MenuItemVideo> menuItemVideos = new ArrayList<>();
|
||||
if (peertube.getFiles() != null && peertube.getFiles().size() > 0) {
|
||||
MenuItemVideo resolutionItem = new MenuItemVideo();
|
||||
|
|
|
@ -28,11 +28,6 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
@ -65,13 +60,13 @@ import app.fedilab.fedilabtube.client.data.VideoData.Video;
|
|||
import app.fedilab.fedilabtube.client.entities.Item;
|
||||
import app.fedilab.fedilabtube.client.entities.ItemStr;
|
||||
import app.fedilab.fedilabtube.client.entities.VideoParams;
|
||||
import app.fedilab.fedilabtube.databinding.ActivityPeertubeEditBinding;
|
||||
import app.fedilab.fedilabtube.helper.Helper;
|
||||
import app.fedilab.fedilabtube.viewmodel.ChannelsVM;
|
||||
import app.fedilab.fedilabtube.viewmodel.MyVideoVM;
|
||||
import app.fedilab.fedilabtube.viewmodel.PostActionsVM;
|
||||
import app.fedilab.fedilabtube.viewmodel.TimelineVM;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
import mabbas007.tagsedittext.TagsEditText;
|
||||
|
||||
import static app.fedilab.fedilabtube.MainActivity.peertubeInformation;
|
||||
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.PEERTUBEDELETEVIDEO;
|
||||
|
@ -85,23 +80,20 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
private final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 724;
|
||||
Item licenseToSend, privacyToSend, categoryToSend;
|
||||
ItemStr languageToSend;
|
||||
private Button set_upload_submit;
|
||||
private Spinner set_upload_privacy, set_upload_categories, set_upload_licenses, set_upload_languages, set_upload_channel;
|
||||
private EditText p_video_title, p_video_description;
|
||||
private TagsEditText p_video_tags;
|
||||
private CheckBox set_upload_nsfw, set_upload_enable_comments;
|
||||
private LinkedHashMap<String, String> channels;
|
||||
private String videoId;
|
||||
private Channel channel;
|
||||
private ImageView p_video_preview;
|
||||
private Button set_preview;
|
||||
private VideoParams videoParams;
|
||||
private Video video;
|
||||
private String channelToSendId;
|
||||
private ActivityPeertubeEditBinding binding;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityPeertubeEditBinding.inflate(getLayoutInflater());
|
||||
View view = binding.getRoot();
|
||||
setContentView(view);
|
||||
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
|
||||
|
@ -116,23 +108,8 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
}
|
||||
if (getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(R.layout.activity_peertube_edit);
|
||||
set_upload_submit = findViewById(R.id.set_upload_submit);
|
||||
Button set_upload_delete = findViewById(R.id.set_upload_delete);
|
||||
set_upload_privacy = findViewById(R.id.set_upload_privacy);
|
||||
set_upload_channel = findViewById(R.id.set_upload_channel);
|
||||
set_upload_categories = findViewById(R.id.set_upload_categories);
|
||||
set_upload_licenses = findViewById(R.id.set_upload_licenses);
|
||||
set_upload_languages = findViewById(R.id.set_upload_languages);
|
||||
p_video_title = findViewById(R.id.p_video_title);
|
||||
p_video_description = findViewById(R.id.p_video_description);
|
||||
p_video_tags = findViewById(R.id.p_video_tags);
|
||||
p_video_preview = findViewById(R.id.p_video_preview);
|
||||
set_upload_nsfw = findViewById(R.id.set_upload_nsfw);
|
||||
set_upload_enable_comments = findViewById(R.id.set_upload_enable_comments);
|
||||
set_preview = findViewById(R.id.set_preview);
|
||||
|
||||
set_upload_delete.setOnClickListener(v -> {
|
||||
binding.setUploadDelete.setOnClickListener(v -> {
|
||||
AlertDialog.Builder builderInner;
|
||||
builderInner = new AlertDialog.Builder(PeertubeEditUploadActivity.this);
|
||||
builderInner.setMessage(getString(R.string.delete_video_confirmation));
|
||||
|
@ -168,7 +145,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
}
|
||||
ArrayAdapter<String> adapterCatgories = new ArrayAdapter<>(PeertubeEditUploadActivity.this,
|
||||
android.R.layout.simple_spinner_dropdown_item, categoriesA);
|
||||
set_upload_categories.setAdapter(adapterCatgories);
|
||||
binding.setUploadCategories.setAdapter(adapterCatgories);
|
||||
|
||||
|
||||
//Populate licenses
|
||||
|
@ -186,7 +163,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
}
|
||||
ArrayAdapter<String> adapterLicenses = new ArrayAdapter<>(PeertubeEditUploadActivity.this,
|
||||
android.R.layout.simple_spinner_dropdown_item, licensesA);
|
||||
set_upload_licenses.setAdapter(adapterLicenses);
|
||||
binding.setUploadLicenses.setAdapter(adapterLicenses);
|
||||
|
||||
|
||||
//Populate languages
|
||||
|
@ -204,7 +181,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
}
|
||||
ArrayAdapter<String> adapterLanguages = new ArrayAdapter<>(PeertubeEditUploadActivity.this,
|
||||
android.R.layout.simple_spinner_dropdown_item, languagesA);
|
||||
set_upload_languages.setAdapter(adapterLanguages);
|
||||
binding.setUploadLanguages.setAdapter(adapterLanguages);
|
||||
|
||||
|
||||
//Populate languages
|
||||
|
@ -223,7 +200,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
|
||||
ArrayAdapter<String> adapterPrivacies = new ArrayAdapter<>(PeertubeEditUploadActivity.this,
|
||||
android.R.layout.simple_spinner_dropdown_item, privaciesA);
|
||||
set_upload_privacy.setAdapter(adapterPrivacies);
|
||||
binding.setUploadPrivacy.setAdapter(adapterPrivacies);
|
||||
|
||||
|
||||
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeEditUploadActivity.this).get(TimelineVM.class);
|
||||
|
@ -235,7 +212,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
public void manageUpdate(APIResponse apiResponse) {
|
||||
set_upload_submit.setEnabled(true);
|
||||
binding.setUploadSubmit.setEnabled(true);
|
||||
if (apiResponse.getError() != null) {
|
||||
if (apiResponse.getError() != null && apiResponse.getError().getError() != null)
|
||||
Toasty.error(PeertubeEditUploadActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||
|
@ -251,7 +228,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
Toasty.error(PeertubeEditUploadActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Toasty.error(PeertubeEditUploadActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
set_upload_submit.setEnabled(true);
|
||||
binding.setUploadSubmit.setEnabled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -267,11 +244,11 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
categoryToSend = video.getCategory();
|
||||
|
||||
if (video.getThumbnailPath() != null) {
|
||||
Helper.loadGiF(PeertubeEditUploadActivity.this, video.getThumbnailPath(), p_video_preview);
|
||||
Helper.loadGiF(PeertubeEditUploadActivity.this, video.getThumbnailPath(), binding.pVideoPreview);
|
||||
}
|
||||
|
||||
|
||||
set_preview.setOnClickListener(v -> {
|
||||
binding.setPreview.setOnClickListener(v -> {
|
||||
if (ContextCompat.checkSelfPermission(PeertubeEditUploadActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
|
||||
PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(PeertubeEditUploadActivity.this,
|
||||
|
@ -328,11 +305,11 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
boolean commentEnabled = video.isCommentsEnabled();
|
||||
boolean isNSFW = video.isNsfw();
|
||||
|
||||
set_upload_enable_comments.setChecked(commentEnabled);
|
||||
set_upload_nsfw.setChecked(isNSFW);
|
||||
binding.setUploadEnableComments.setChecked(commentEnabled);
|
||||
binding.setUploadNsfw.setChecked(isNSFW);
|
||||
|
||||
p_video_title.setText(title);
|
||||
p_video_description.setText(video.getDescription());
|
||||
binding.pVideoTitle.setText(title);
|
||||
binding.pVideoDescription.setText(video.getDescription());
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
|
@ -341,8 +318,8 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
VideoData.Description description = api.getVideoDescription(video.getUuid());
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Runnable myRunnable = () -> {
|
||||
if (description == null) {
|
||||
p_video_description.setText(description.getDescription());
|
||||
if (description != null) {
|
||||
binding.pVideoDescription.setText(description.getDescription());
|
||||
}
|
||||
};
|
||||
mainHandler.post(myRunnable);
|
||||
|
@ -403,7 +380,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
//Manage privacies
|
||||
set_upload_privacy.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
binding.setUploadPrivacy.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
updatePrivacyPosition(position);
|
||||
|
@ -414,7 +391,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
|
||||
}
|
||||
});
|
||||
set_upload_licenses.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
binding.setUploadLicenses.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
updateLicensePosition(position);
|
||||
|
@ -426,7 +403,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
//Manage categories
|
||||
set_upload_categories.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
binding.setUploadCategories.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
updateCategoryPosition(position);
|
||||
|
@ -439,7 +416,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
});
|
||||
|
||||
//Manage languages
|
||||
set_upload_languages.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
binding.setUploadLanguages.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
updateLanguagesPosition(position);
|
||||
|
@ -451,7 +428,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
//Manage languages
|
||||
set_upload_channel.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
binding.setUploadChannel.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
|
||||
|
@ -468,11 +445,11 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
Item finalLicenseToSend = licenseToSend;
|
||||
ItemStr finalLanguageToSend = languageToSend;
|
||||
Item finalPrivacyToSend = privacyToSend;
|
||||
set_upload_submit.setOnClickListener(v -> {
|
||||
String title1 = p_video_title.getText().toString().trim();
|
||||
String description = p_video_description.getText().toString().trim();
|
||||
boolean isNSFW1 = set_upload_nsfw.isChecked();
|
||||
boolean commentEnabled1 = set_upload_enable_comments.isChecked();
|
||||
binding.setUploadSubmit.setOnClickListener(v -> {
|
||||
String title1 = binding.pVideoTitle.getText().toString().trim();
|
||||
String description = binding.pVideoDescription.getText().toString().trim();
|
||||
boolean isNSFW1 = binding.setUploadNsfw.isChecked();
|
||||
boolean commentEnabled1 = binding.setUploadEnableComments.isChecked();
|
||||
videoParams = new VideoParams();
|
||||
videoParams.setName(title1);
|
||||
videoParams.setDescription(description);
|
||||
|
@ -484,25 +461,25 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
|
||||
videoParams.setChannelId(channelToSendId);
|
||||
videoParams.setPrivacy(finalPrivacyToSend.getId());
|
||||
List<String> tags = p_video_tags.getTags();
|
||||
List<String> tags = binding.pVideoTags.getTags();
|
||||
videoParams.setTags(tags);
|
||||
set_upload_submit.setEnabled(false);
|
||||
binding.setUploadSubmit.setEnabled(false);
|
||||
MyVideoVM myVideoVM = new ViewModelProvider(PeertubeEditUploadActivity.this).get(MyVideoVM.class);
|
||||
myVideoVM.updateVideo(videoId, videoParams, null, null).observe(PeertubeEditUploadActivity.this, this::manageUpdate);
|
||||
});
|
||||
|
||||
set_upload_privacy.setSelection(privacyPosition, false);
|
||||
binding.setUploadPrivacy.setSelection(privacyPosition, false);
|
||||
updatePrivacyPosition(privacyPosition);
|
||||
set_upload_languages.setSelection(languagePosition, false);
|
||||
binding.setUploadLanguages.setSelection(languagePosition, false);
|
||||
updateLanguagesPosition(languagePosition);
|
||||
set_upload_licenses.setSelection(licensePosition, false);
|
||||
binding.setUploadLicenses.setSelection(licensePosition, false);
|
||||
updateLicensePosition(licensePosition);
|
||||
set_upload_categories.setSelection(categoryPosition, false);
|
||||
binding.setUploadCategories.setSelection(categoryPosition, false);
|
||||
updateCategoryPosition(categoryPosition);
|
||||
|
||||
List<String> tags = video.getTags();
|
||||
if (tags != null && tags.size() > 0) {
|
||||
p_video_tags.setTags(tags.toArray(new String[0]));
|
||||
binding.pVideoTags.setTags(tags.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -623,7 +600,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
public void onCompleted(Context context, UploadInfo uploadInfo, ServerResponse serverResponse) {
|
||||
Glide.with(PeertubeEditUploadActivity.this)
|
||||
.load(uri)
|
||||
.into(p_video_preview);
|
||||
.into(binding.pVideoPreview);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -672,7 +649,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
}
|
||||
ArrayAdapter<String> adapterChannel = new ArrayAdapter<>(PeertubeEditUploadActivity.this,
|
||||
android.R.layout.simple_spinner_dropdown_item, channelName);
|
||||
set_upload_channel.setAdapter(adapterChannel);
|
||||
binding.setUploadChannel.setAdapter(adapterChannel);
|
||||
int channelPosition = 0;
|
||||
if (channels.containsKey(channel.getName())) {
|
||||
LinkedHashMap<String, String> channelsIterator = new LinkedHashMap<>(channels);
|
||||
|
@ -687,9 +664,15 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||
channelPosition++;
|
||||
}
|
||||
}
|
||||
set_upload_channel.setSelection(channelPosition, false);
|
||||
binding.setUploadChannel.setSelection(channelPosition, false);
|
||||
updateUploadChannel(channelPosition);
|
||||
set_upload_submit.setEnabled(true);
|
||||
binding.setUploadSubmit.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
finish();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unused", "RedundantSuppression"})
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.List;
|
|||
import app.fedilab.fedilabtube.client.MenuItemVideo;
|
||||
import app.fedilab.fedilabtube.client.entities.MenuItemView;
|
||||
import app.fedilab.fedilabtube.databinding.DrawerMenuItemBinding;
|
||||
import app.fedilab.fedilabtube.helper.Helper;
|
||||
|
||||
|
||||
public class MenuItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
@ -68,11 +67,8 @@ public class MenuItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
|
||||
holder.binding.title.setText(item.getLabel());
|
||||
holder.binding.radio.setChecked(item.isSelected());
|
||||
holder.binding.itemMenuContainer.setOnClickListener(v -> {
|
||||
itemAction.which(actionType, item);
|
||||
|
||||
});
|
||||
|
||||
holder.binding.itemMenuContainer.setOnClickListener(v -> itemAction.which(actionType, item));
|
||||
holder.binding.radio.setOnClickListener(v -> itemAction.which(actionType, item));
|
||||
}
|
||||
|
||||
public interface ItemAction {
|
||||
|
|
|
@ -14,10 +14,12 @@ package app.fedilab.fedilabtube.drawer;
|
|||
* You should have received a copy of the GNU General Public License along with TubeLab; 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.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -25,17 +27,24 @@ import android.view.ViewGroup;
|
|||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.lifecycle.ViewModelStoreOwner;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestBuilder;
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -50,11 +59,13 @@ import app.fedilab.fedilabtube.client.data.PlaylistData;
|
|||
import app.fedilab.fedilabtube.client.data.VideoData;
|
||||
import app.fedilab.fedilabtube.client.entities.PlaylistExist;
|
||||
import app.fedilab.fedilabtube.client.entities.Report;
|
||||
import app.fedilab.fedilabtube.databinding.DrawerPeertubeBinding;
|
||||
import app.fedilab.fedilabtube.helper.Helper;
|
||||
import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
|
||||
import app.fedilab.fedilabtube.viewmodel.PostActionsVM;
|
||||
import app.fedilab.fedilabtube.viewmodel.TimelineVM;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
import jp.wasabeef.glide.transformations.BlurTransformation;
|
||||
|
||||
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.FOLLOW;
|
||||
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.UNFOLLOW;
|
||||
|
@ -87,8 +98,8 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
context = parent.getContext();
|
||||
LayoutInflater layoutInflater = LayoutInflater.from(context);
|
||||
return new ViewHolder(layoutInflater.inflate(R.layout.drawer_peertube, parent, false));
|
||||
DrawerPeertubeBinding itemBinding = DrawerPeertubeBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
return new ViewHolder(itemBinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -120,43 +131,43 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
instance = video.getAccount().getHost();
|
||||
}
|
||||
|
||||
holder.peertube_account_name.setText(video.getChannel().getAcct());
|
||||
Helper.loadGiF(context, instance, video.getChannel().getAvatar() != null ? video.getChannel().getAvatar().getPath() : null, holder.peertube_profile);
|
||||
holder.binding.peertubeAccountName.setText(video.getChannel().getAcct());
|
||||
Helper.loadGiF(context, instance, video.getChannel().getAvatar() != null ? video.getChannel().getAvatar().getPath() : null, holder.binding.peertubeProfile);
|
||||
|
||||
holder.peertube_title.setText(video.getName());
|
||||
holder.peertube_duration.setText(Helper.secondsToString(video.getDuration()));
|
||||
holder.peertube_date.setText(String.format(" - %s", Helper.dateDiff(context, video.getCreatedAt())));
|
||||
holder.peertube_views.setText(context.getString(R.string.number_view_video, Helper.withSuffix(video.getViews())));
|
||||
holder.binding.peertubeTitle.setText(video.getName());
|
||||
holder.binding.peertubeDuration.setText(Helper.secondsToString(video.getDuration()));
|
||||
holder.binding.peertubeDate.setText(String.format(" - %s", Helper.dateDiff(context, video.getCreatedAt())));
|
||||
holder.binding.peertubeViews.setText(context.getString(R.string.number_view_video, Helper.withSuffix(video.getViews())));
|
||||
|
||||
boolean blur = sharedpreferences.getString(context.getString(R.string.set_video_sensitive_choice), Helper.BLUR).compareTo("blur") == 0 && video.isNsfw();
|
||||
if (videoInList) {
|
||||
Helper.loadGiF(context, instance, video.getThumbnailPath(), holder.peertube_video_image_small, blur);
|
||||
holder.peertube_video_image_small.setVisibility(View.VISIBLE);
|
||||
holder.preview_container.setVisibility(View.GONE);
|
||||
Helper.loadGiF(context, instance, video.getThumbnailPath(), holder.binding.peertubeVideoImageSmall, blur);
|
||||
holder.binding.peertubeVideoImageSmall.setVisibility(View.VISIBLE);
|
||||
holder.binding.previewContainer.setVisibility(View.GONE);
|
||||
} else {
|
||||
Helper.loadGiF(context, instance, video.getThumbnailPath(), holder.peertube_video_image, blur);
|
||||
holder.peertube_video_image_small.setVisibility(View.GONE);
|
||||
holder.preview_container.setVisibility(View.VISIBLE);
|
||||
loadImage(holder.binding.peertubeVideoImage, instance, video.getPreviewPath(), video.getThumbnailPath(), blur);
|
||||
holder.binding.peertubeVideoImageSmall.setVisibility(View.GONE);
|
||||
holder.binding.previewContainer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
//For Overview Videos: boolean values for displaying title is managed in the fragment
|
||||
if (video.isHasTitle()) {
|
||||
holder.header_title.setVisibility(View.VISIBLE);
|
||||
holder.binding.headerTitle.setVisibility(View.VISIBLE);
|
||||
switch (video.getTitleType()) {
|
||||
case TAG:
|
||||
holder.header_title.setText(String.format("#%s", video.getTitle()));
|
||||
holder.binding.headerTitle.setText(String.format("#%s", video.getTitle()));
|
||||
break;
|
||||
case CHANNEL:
|
||||
case CATEGORY:
|
||||
holder.header_title.setText(String.format("%s", video.getTitle()));
|
||||
holder.binding.headerTitle.setText(String.format("%s", video.getTitle()));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
holder.header_title.setVisibility(View.GONE);
|
||||
holder.binding.headerTitle.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (!ownVideos) {
|
||||
holder.peertube_profile.setOnClickListener(v -> {
|
||||
holder.binding.peertubeProfile.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, ShowChannelActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putParcelable("channel", video.getChannel());
|
||||
|
@ -170,8 +181,8 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
}
|
||||
|
||||
|
||||
holder.more_actions.setOnClickListener(view -> {
|
||||
PopupMenu popup = new PopupMenu(context, holder.more_actions);
|
||||
holder.binding.moreActions.setOnClickListener(view -> {
|
||||
PopupMenu popup = new PopupMenu(context, holder.binding.moreActions);
|
||||
popup.getMenuInflater()
|
||||
.inflate(R.menu.video_drawer_menu, popup.getMenu());
|
||||
if (timelineType == MY_VIDEOS) {
|
||||
|
@ -256,7 +267,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
});
|
||||
popup.show();
|
||||
});
|
||||
holder.bottom_container.setOnClickListener(v -> {
|
||||
holder.binding.bottomContainer.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, PeertubeActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("video_id", video.getId());
|
||||
|
@ -270,7 +281,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
holder.peertube_video_image.setOnClickListener(v -> {
|
||||
holder.binding.peertubeVideoImage.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, PeertubeActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("video_id", video.getId());
|
||||
|
@ -385,29 +396,74 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
Map<String, List<PlaylistExist>> getPlaylist();
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void loadImage(ImageView target, String instance, String urlPreview, String thumbnail, boolean blur) {
|
||||
if (urlPreview == null || urlPreview.startsWith("null")) {
|
||||
urlPreview = thumbnail;
|
||||
}
|
||||
if (instance != null) {
|
||||
urlPreview = "https://" + instance + urlPreview;
|
||||
thumbnail = "https://" + instance + thumbnail;
|
||||
} else {
|
||||
urlPreview = "https://" + Helper.getLiveInstance(context) + urlPreview;
|
||||
thumbnail = "https://" + Helper.getLiveInstance(context) + thumbnail;
|
||||
}
|
||||
RequestBuilder<Drawable> requestBuilder = Glide.with(context)
|
||||
.asDrawable();
|
||||
if (blur) {
|
||||
requestBuilder.apply(new RequestOptions().transform(new BlurTransformation(50, 3), new CenterCrop(), new RoundedCorners(10)));
|
||||
} else {
|
||||
requestBuilder.apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10)));
|
||||
}
|
||||
final Drawable[] initialResource = new Drawable[1];
|
||||
String finalUrlPreview = urlPreview;
|
||||
requestBuilder.load(thumbnail).into(
|
||||
new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull final Drawable resource, Transition<? super Drawable> transition) {
|
||||
target.setImageDrawable(resource);
|
||||
initialResource[0] = resource;
|
||||
RequestBuilder<Drawable> requestBuilder = Glide.with(context)
|
||||
.asDrawable();
|
||||
if (blur) {
|
||||
requestBuilder.apply(new RequestOptions().transform(new BlurTransformation(50, 3), new CenterCrop(), new RoundedCorners(10)));
|
||||
} else {
|
||||
requestBuilder.apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10)));
|
||||
}
|
||||
requestBuilder.load(finalUrlPreview).into(
|
||||
new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull final Drawable resource, Transition<? super Drawable> transition) {
|
||||
target.setImageDrawable(resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
||||
target.setImageDrawable(initialResource[0]);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
LinearLayout main_container, bottom_container;
|
||||
ImageView peertube_profile, peertube_video_image, peertube_video_image_small;
|
||||
TextView peertube_account_name, peertube_views, peertube_duration;
|
||||
TextView peertube_title, peertube_date, header_title, more_actions;
|
||||
ConstraintLayout preview_container;
|
||||
DrawerPeertubeBinding binding;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
peertube_account_name = itemView.findViewById(R.id.peertube_account_name);
|
||||
peertube_video_image_small = itemView.findViewById(R.id.peertube_video_image_small);
|
||||
peertube_title = itemView.findViewById(R.id.peertube_title);
|
||||
peertube_video_image = itemView.findViewById(R.id.peertube_video_image);
|
||||
peertube_profile = itemView.findViewById(R.id.peertube_profile);
|
||||
peertube_date = itemView.findViewById(R.id.peertube_date);
|
||||
peertube_views = itemView.findViewById(R.id.peertube_views);
|
||||
peertube_duration = itemView.findViewById(R.id.peertube_duration);
|
||||
main_container = itemView.findViewById(R.id.main_container);
|
||||
header_title = itemView.findViewById(R.id.header_title);
|
||||
bottom_container = itemView.findViewById(R.id.bottom_container);
|
||||
more_actions = itemView.findViewById(R.id.more_actions);
|
||||
preview_container = itemView.findViewById(R.id.preview_container);
|
||||
ViewHolder(DrawerPeertubeBinding itemView) {
|
||||
super(itemView.getRoot());
|
||||
binding = itemView;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,9 +41,9 @@ public class CommentVM extends AndroidViewModel {
|
|||
return apiResponseMutableLiveData;
|
||||
}
|
||||
|
||||
public LiveData<APIResponse> getRepliesComment(String videoId, String commentId) {
|
||||
public LiveData<APIResponse> getRepliesComment(String instance, String videoId, String commentId) {
|
||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||
getThreadRepliesComments(videoId, commentId);
|
||||
getThreadRepliesComments(instance, videoId, commentId);
|
||||
return apiResponseMutableLiveData;
|
||||
}
|
||||
|
||||
|
@ -69,12 +69,17 @@ public class CommentVM extends AndroidViewModel {
|
|||
}
|
||||
|
||||
|
||||
private void getThreadRepliesComments(String videoId, String commentId) {
|
||||
private void getThreadRepliesComments(String instance, String videoId, String commentId) {
|
||||
Context _mContext = getApplication().getApplicationContext();
|
||||
new Thread(() -> {
|
||||
try {
|
||||
RetrofitPeertubeAPI api = new RetrofitPeertubeAPI(_mContext);
|
||||
APIResponse apiResponse = api.getComments(action.GET_REPLIES, videoId, commentId, null);
|
||||
RetrofitPeertubeAPI retrofitPeertubeAPI;
|
||||
if (instance == null) {
|
||||
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
|
||||
} else {
|
||||
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext, instance, null);
|
||||
}
|
||||
APIResponse apiResponse = retrofitPeertubeAPI.getComments(action.GET_REPLIES, videoId, commentId, null);
|
||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
|
||||
mainHandler.post(myRunnable);
|
||||
|
|
|
@ -110,12 +110,18 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/peertube_title"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -129,15 +135,15 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/pp_channel"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:id="@+id/pp_channel"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:contentDescription="@string/profile_picture"
|
||||
/>
|
||||
android:contentDescription="@string/profile_picture" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/peertube_view_count"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -237,19 +243,22 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/peertube_description"
|
||||
android:textIsSelectable="true"
|
||||
android:autoLink="web"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp" />
|
||||
android:layout_marginTop="10dp"
|
||||
android:autoLink="web"
|
||||
android:textIsSelectable="true" />
|
||||
|
||||
<TextView
|
||||
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:visibility="gone"
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:layout_marginTop="2dp" />
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<Button
|
||||
android:layout_gravity="center"
|
||||
|
@ -259,6 +268,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:text="@string/add_public_comment"/>
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_marginStart="10dp"
|
||||
android:id="@+id/peertube_comments"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
@ -293,17 +303,13 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_margin="10dp"
|
||||
android:id="@+id/main_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:divider="?android:dividerHorizontal"
|
||||
android:orientation="vertical"
|
||||
android:showDividers="end">
|
||||
|
||||
<ImageView
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:id="@+id/close_reply"
|
||||
|
@ -332,10 +338,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_margin="10dp"
|
||||
android:id="@+id/post_main_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -119,6 +119,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textMultiLine"
|
||||
android:gravity="top"
|
||||
android:lines="5"
|
||||
android:maxLines="5"
|
||||
android:scrollbars="vertical" />
|
||||
|
|
Loading…
Reference in New Issue