Release 1.5.1

This commit is contained in:
Thomas 2020-10-17 18:50:20 +02:00
parent e17c7fb01d
commit 74feb7e8f0
42 changed files with 410 additions and 414 deletions

View File

@ -11,8 +11,8 @@ android {
minSdkVersion 21
targetSdkVersion 30
versionCode 19
versionName "1.5.0"
versionCode 20
versionName "1.5.1"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -39,6 +39,4 @@ public class FedilabTube extends MultiDexApplication {
}
}

View File

@ -94,6 +94,11 @@ public class LoginActivity extends AppCompatActivity {
login_passwd = findViewById(R.id.login_passwd);
if (Helper.isTablet(LoginActivity.this)) {
ViewGroup.LayoutParams layoutParamsI = login_instance_container.getLayoutParams();
layoutParamsI.width = (int) Helper.convertDpToPixel(300, LoginActivity.this);
login_instance_container.setLayoutParams(layoutParamsI);
TextInputLayout login_uid_container = findViewById(R.id.login_uid_container);
ViewGroup.LayoutParams layoutParamsU = login_uid_container.getLayoutParams();
layoutParamsU.width = (int) Helper.convertDpToPixel(300, LoginActivity.this);

View File

@ -121,19 +121,19 @@ public class MainActivity extends AppCompatActivity {
navView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
Fragment fragment = getSupportFragmentManager().findFragmentByTag("5");
if(fragment != null)
if (fragment != null)
getSupportFragmentManager().beginTransaction().remove(fragment).commit();
fragment = getSupportFragmentManager().findFragmentByTag("4");
if(fragment != null)
if (fragment != null)
getSupportFragmentManager().beginTransaction().remove(fragment).commit();
fragment = getSupportFragmentManager().findFragmentByTag("3");
if(fragment != null)
if (fragment != null)
getSupportFragmentManager().beginTransaction().remove(fragment).commit();
fragment = getSupportFragmentManager().findFragmentByTag("2");
if(fragment != null)
if (fragment != null)
getSupportFragmentManager().beginTransaction().remove(fragment).commit();
fragment = getSupportFragmentManager().findFragmentByTag("1");
if(fragment != null)
if (fragment != null)
getSupportFragmentManager().beginTransaction().remove(fragment).commit();
recentFragment = new DisplayVideosFragment();
@ -163,7 +163,7 @@ public class MainActivity extends AppCompatActivity {
overviewFragment = new DisplayOverviewFragment();
if( active == null) {
if (active == null) {
active = overviewFragment;
}
fm.beginTransaction().add(R.id.nav_host_fragment, locaFragment, "5").hide(locaFragment).commit();
@ -174,10 +174,10 @@ public class MainActivity extends AppCompatActivity {
fm.beginTransaction().add(R.id.nav_host_fragment, trendingFragment, "2").hide(trendingFragment).commit();
fm.beginTransaction().add(R.id.nav_host_fragment, overviewFragment, "1").commit();
}
toolbar.setOnClickListener(v->{
if(active instanceof DisplayVideosFragment) {
toolbar.setOnClickListener(v -> {
if (active instanceof DisplayVideosFragment) {
((DisplayVideosFragment) active).scrollToTop();
}else if(active instanceof DisplayOverviewFragment) {
} else if (active instanceof DisplayOverviewFragment) {
((DisplayOverviewFragment) active).scrollToTop();
}
});
@ -225,7 +225,7 @@ public class MainActivity extends AppCompatActivity {
editor.putString(Helper.PREF_KEY_NAME, account.getUsername());
//Sync languages from server
List<String> videoLanguageServer = userMe.getVideoLanguages();
if( videoLanguageServer != null) {
if (videoLanguageServer != null) {
Set<String> videoLanguageServerSet = new TreeSet<>(videoLanguageServer);
videoLanguageServerSet.addAll(videoLanguageServer);
Set<String> videoLanguageLocal = sharedpreferences.getStringSet(getString(R.string.set_video_language_choice), null);
@ -237,6 +237,7 @@ public class MainActivity extends AppCompatActivity {
}
}
} catch (Error error) {
runOnUiThread(() -> Helper.logoutCurrentUser(MainActivity.this, account));
error.printStackTrace();
}
}).start();
@ -247,7 +248,7 @@ public class MainActivity extends AppCompatActivity {
}
startInForeground();
if(BuildConfig.google_restriction && BuildConfig.full_instances) {
if (BuildConfig.google_restriction && BuildConfig.full_instances) {
RateThisApp.onCreate(this);
RateThisApp.showRateDialogIfNeeded(this);
}
@ -315,7 +316,7 @@ public class MainActivity extends AppCompatActivity {
settingsItem.setVisible(true);
mostLikedItem.setVisible(false);
}
if( !BuildConfig.full_instances) {
if (!BuildConfig.full_instances) {
sepiaSearchItem.setVisible(false);
}
return true;
@ -372,11 +373,11 @@ public class MainActivity extends AppCompatActivity {
Intent intent = new Intent(MainActivity.this, AllPlaylistsActivity.class);
startActivity(intent);
return true;
}else if(item.getItemId() == R.id.action_sepia_search) {
} else if (item.getItemId() == R.id.action_sepia_search) {
Intent intent = new Intent(MainActivity.this, SepiaSearchActivity.class);
startActivity(intent);
return true;
}else if (item.getItemId() == R.id.action_about) {
} else if (item.getItemId() == R.id.action_about) {
Intent intent = new Intent(MainActivity.this, AboutActivity.class);
startActivity(intent);
return true;
@ -384,7 +385,7 @@ public class MainActivity extends AppCompatActivity {
return super.onOptionsItemSelected(item);
}
public void setActive(DisplayVideosFragment displayVideosFragment){
public void setActive(DisplayVideosFragment displayVideosFragment) {
this.active = displayVideosFragment;
}

View File

@ -158,6 +158,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
private ActivityPeertubeBinding binding;
private List<Comment> commentsThread;
private BroadcastReceiver mPowerKeyReceiver = null;
private boolean isPlayInMinimized;
public static void hideKeyboard(Activity activity) {
if (activity != null && activity.getWindow() != null) {
@ -167,7 +168,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
imm.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(), 0);
}
}
private boolean isPlayInMinimized;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -209,13 +209,13 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
if (b != null) {
peertubeInstance = b.getString("peertube_instance", Helper.getLiveInstance(PeertubeActivity.this));
videoUuid = b.getString("video_uuid", null);
isMyVideo = b.getBoolean("isMyVideo", false);
sepiaSearch = b.getBoolean("sepia_search", false);
isMyVideo = b.getBoolean("isMyVideo", false);
sepiaSearch = b.getBoolean("sepia_search", false);
peertube = b.getParcelable("video");
}
if( !Helper.isLoggedIn(PeertubeActivity.this) || sepiaSearch) {
if (!Helper.isLoggedIn(PeertubeActivity.this) || sepiaSearch) {
binding.writeCommentContainerReply.setVisibility(View.GONE);
binding.writeCommentContainer.setVisibility(View.GONE);
}
@ -274,7 +274,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
flag_loading = true;
comments = new ArrayList<>();
binding.closeReply.setOnClickListener(v->closeCommentThread());
binding.closeReply.setOnClickListener(v -> closeCommentThread());
commentListAdapter = new CommentListAdapter(comments, isMyVideo || Helper.isVideoOwner(PeertubeActivity.this, peertube));
commentListAdapter.allCommentRemoved = PeertubeActivity.this;
@ -291,25 +291,24 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
if (firstVisibleItem + visibleItemCount == totalItemCount) {
if (!flag_loading) {
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
commentViewModel.getThread(sepiaSearch?peertubeInstance:null, videoUuid, max_id).observe(PeertubeActivity.this, apiresponse -> manageVIewComment(apiresponse));
commentViewModel.getThread(sepiaSearch ? peertubeInstance : null, videoUuid, max_id).observe(PeertubeActivity.this, apiresponse -> manageVIewComment(apiresponse));
}
}
}
}
});
if( peertube != null && sepiaSearch && peertube.getEmbedUrl() != null && Helper.isLoggedIn(PeertubeActivity.this)) {
if (peertube != null && sepiaSearch && peertube.getEmbedUrl() != null && Helper.isLoggedIn(PeertubeActivity.this)) {
SearchVM viewModelSearch = new ViewModelProvider(PeertubeActivity.this).get(SearchVM.class);
viewModelSearch.getVideos("0", peertube.getEmbedUrl()).observe(PeertubeActivity.this, this::manageVIewVideos);
}else {
} else {
playVideo();
}
registBroadcastReceiver();
}
private void manageVIewVideos(APIResponse apiResponse) {
if( apiResponse == null || apiResponse.getPeertubes() == null || apiResponse.getPeertubes().size() == 0) {
if (apiResponse == null || apiResponse.getPeertubes() == null || apiResponse.getPeertubes().size() == 0) {
playVideo();
return;
}
@ -369,7 +368,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
commentThreadData.getComment().setReply(true);
comments.add(commentThreadData.getComment());
}
if( commentThreadData.getChildren() != null && commentThreadData.getChildren().size() >0) {
if (commentThreadData.getChildren() != null && commentThreadData.getChildren().size() > 0) {
generateCommentReply(commentThreadData.getChildren(), comments);
}
}
@ -404,9 +403,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
binding.peertubePlaylist.setVisibility(View.VISIBLE);
binding.peertubeBookmark.setVisibility(View.GONE);
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeActivity.this).get(TimelineVM.class);
feedsViewModel.getVideo(sepiaSearch?peertubeInstance:null, videoUuid, isMyVideo).observe(PeertubeActivity.this, this::manageVIewVideo);
feedsViewModel.getVideo(sepiaSearch ? peertubeInstance : null, videoUuid, isMyVideo).observe(PeertubeActivity.this, this::manageVIewVideo);
CaptionsVM captionsViewModel = new ViewModelProvider(PeertubeActivity.this).get(CaptionsVM.class);
captionsViewModel.getCaptions(sepiaSearch?peertubeInstance:null, videoUuid).observe(PeertubeActivity.this, this::manageCaptions);
captionsViewModel.getCaptions(sepiaSearch ? peertubeInstance : null, videoUuid).observe(PeertubeActivity.this, this::manageCaptions);
}
public void change() {
@ -455,7 +454,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
videoReport.setId(peertube.getId());
report.setVideo(videoReport);
report.setReason(report_content.getText().toString());
viewModel.report(report).observe(PeertubeActivity.this, apiResponse -> manageVIewPostActions(RetrofitPeertubeAPI.ActionType.REPORT_VIDEO,0, apiResponse));
viewModel.report(report).observe(PeertubeActivity.this, apiResponse -> manageVIewPostActions(RetrofitPeertubeAPI.ActionType.REPORT_VIDEO, 0, apiResponse));
alertDialog.dismiss();
dialog.dismiss();
} else if (type == RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT) {
@ -464,7 +463,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
accountReport.setId(peertube.getAccount().getId());
report.setAccount(accountReport);
report.setReason(report_content.getText().toString());
viewModel.report(report).observe(PeertubeActivity.this, apiResponse -> manageVIewPostActions(RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT, 0,apiResponse));
viewModel.report(report).observe(PeertubeActivity.this, apiResponse -> manageVIewPostActions(RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT, 0, apiResponse));
alertDialog.dismiss();
dialog.dismiss();
}
@ -507,7 +506,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
peertube = apiResponse.getPeertubes().get(0);
if( sepiaSearch) {
if (sepiaSearch) {
peertubeInstance = peertube.getAccount().getHost();
}
List<String> videoIds = new ArrayList<>();
@ -515,22 +514,22 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
PlaylistsVM viewModel = new ViewModelProvider(this).get(PlaylistsVM.class);
viewModel.videoExists(videoIds).observe(this, this::manageVIewPlaylist);
if( !Helper.isLoggedIn(PeertubeActivity.this) || sepiaSearch) {
if (!Helper.isLoggedIn(PeertubeActivity.this) || sepiaSearch) {
binding.writeCommentContainer.setVisibility(View.GONE);
binding.writeCommentContainerReply.setVisibility(View.GONE);
}
binding.send.setOnClickListener(v -> {
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
String comment = binding.addCommentWrite.getText().toString();
String comment = binding.addCommentWrite.getText().toString();
if (comment.trim().length() > 0) {
PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
viewModelComment.comment(ADD_COMMENT, peertube.getId(), null, comment).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(ADD_COMMENT, 0, apiResponse1));
binding.addCommentWrite.setText("");
binding.addCommentWrite.setText("");
}
} else {
if( sepiaSearch) {
if (sepiaSearch) {
Toasty.info(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_SHORT).show();
}else {
} else {
Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
}
}
@ -543,8 +542,8 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
if (peertube.isCommentsEnabled()) {
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
commentViewModel.getThread(sepiaSearch?peertubeInstance:null, videoUuid, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
if( Helper.isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
commentViewModel.getThread(sepiaSearch ? peertubeInstance : null, videoUuid, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
if (Helper.isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
binding.writeCommentContainerReply.setVisibility(View.VISIBLE);
binding.writeCommentContainer.setVisibility(View.VISIBLE);
}
@ -589,9 +588,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
binding.peertubeLikeCount.setText(String.valueOf(count));
changeColor();
} else {
if( sepiaSearch) {
if (sepiaSearch) {
Toasty.info(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_SHORT).show();
}else {
} else {
Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
}
}
@ -600,7 +599,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
String newState = peertube.getMyRating().equals("dislike") ? "none" : "dislike";
PostActionsVM viewModelLike = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
viewModelLike.post(RATEVIDEO, peertube.getId(), newState).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(RATEVIDEO,0, apiResponse1));
viewModelLike.post(RATEVIDEO, peertube.getId(), newState).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(RATEVIDEO, 0, apiResponse1));
peertube.setMyRating(newState);
int count = Integer.parseInt(binding.peertubeDislikeCount.getText().toString());
if (newState.compareTo("none") == 0) {
@ -614,9 +613,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
binding.peertubeDislikeCount.setText(String.valueOf(count));
changeColor();
} else {
if( sepiaSearch) {
if (sepiaSearch) {
Toasty.info(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_SHORT).show();
}else {
} else {
Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
}
}
@ -661,6 +660,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
if (captions == null) {
popup.getMenu().findItem(R.id.action_captions).setEnabled(false);
}
if (!isMyVideo) {
popup.getMenu().findItem(R.id.action_edit).setVisible(false);
}
popup.setOnMenuItemClickListener(item -> {
int itemId = item.getItemId();
if (itemId == R.id.action_download) {
@ -700,7 +702,17 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text);
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getString(R.string.share_with)));
try {
startActivity(Intent.createChooser(sendIntent, getString(R.string.share_with)));
} catch (Exception e) {
Toasty.error(PeertubeActivity.this, getString(R.string.toast_error), Toasty.LENGTH_LONG).show();
}
} else if (itemId == R.id.action_edit) {
Intent intent = new Intent(PeertubeActivity.this, PeertubeEditUploadActivity.class);
Bundle b = new Bundle();
b.putString("video_id", peertube.getUuid());
intent.putExtras(b);
startActivity(intent);
} else if (itemId == R.id.action_captions) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PeertubeActivity.this);
if (captions == null) {
@ -876,12 +888,10 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
if (apiLevel >= 7) {
try {
getApplicationContext().unregisterReceiver(mPowerKeyReceiver);
}
catch (IllegalArgumentException e) {
} catch (IllegalArgumentException e) {
mPowerKeyReceiver = null;
}
}
else {
} else {
getApplicationContext().unregisterReceiver(mPowerKeyReceiver);
mPowerKeyReceiver = null;
}
@ -911,9 +921,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
@Override
public void onBackPressed() {
if( binding.replyThread.getVisibility() == View.VISIBLE) {
if (binding.replyThread.getVisibility() == View.VISIBLE) {
closeCommentThread();
}else {
} else {
if (playInMinimized && player != null) {
enterVideoMode();
} else {
@ -1003,7 +1013,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
private void initFullscreenDialog() {
fullScreenDialog = new Dialog(this, android.R.style.Theme_Black_NoTitleBar_Fullscreen) {
@ -1026,7 +1035,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
fullScreenDialog.show();
}
public void openCommentThread(Comment comment, int position){
public void openCommentThread(Comment comment, int position) {
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
@ -1052,13 +1061,17 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
0);
animate.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
binding.peertubeInformationContainer.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(Animation animation) {}
public void onAnimationRepeat(Animation animation) {
}
});
animate.setDuration(500);
binding.addCommentWriteReply.setText(String.format("@%s ", comment.getAccount().getAcct()));
@ -1067,23 +1080,23 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
binding.sendReply.setOnClickListener(null);
binding.sendReply.setOnClickListener(v -> {
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
String commentView = binding.addCommentWriteReply.getText().toString();
String commentView = binding.addCommentWriteReply.getText().toString();
if (commentView.trim().length() > 0) {
PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
viewModelComment.comment(REPLY, peertube.getId(), comment.getId(), commentView).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(REPLY, position, apiResponse1));
binding.addCommentWriteReply.setText("");
}
} else {
if( sepiaSearch) {
if (sepiaSearch) {
Toasty.info(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_SHORT).show();
}else {
} else {
Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
}
}
});
}
private void closeCommentThread(){
private void closeCommentThread() {
binding.peertubeInformationContainer.setVisibility(View.VISIBLE);
TranslateAnimation animate = new TranslateAnimation(
0,
@ -1092,13 +1105,17 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
0);
animate.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
binding.replyThread.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(Animation animation) {}
public void onAnimationRepeat(Animation animation) {
}
});
animate.setDuration(500);
binding.replyThread.startAnimation(animate);
@ -1108,12 +1125,12 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, int position, APIResponse apiResponse) {
if (peertube.isCommentsEnabled() && statusAction == ADD_COMMENT) {
if( apiResponse.getComments() != null && apiResponse.getComments().size() > 0 ) {
if (apiResponse.getComments() != null && apiResponse.getComments().size() > 0) {
comments.add(0, apiResponse.getComments().get(0));
commentListAdapter.notifyItemInserted(0);
}
} else if (peertube.isCommentsEnabled() && statusAction == REPLY) {
if( apiResponse.getComments() != null && apiResponse.getComments().size() > 0 ) {
if (apiResponse.getComments() != null && apiResponse.getComments().size() > 0) {
commentsThread.add(position, apiResponse.getComments().get(0));
commentReplyListAdapter.notifyItemInserted(position);
}
@ -1201,7 +1218,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
builder.setTitle(R.string.modify_playlists);
List<PlaylistData.Playlist> ownerPlaylists = apiResponse.getPlaylists();
if( ownerPlaylists == null){
if (ownerPlaylists == null) {
return;
}
String[] label = new String[ownerPlaylists.size()];
@ -1244,6 +1261,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
dialog.show();
}
}
public void manageVIewPlaylist(APIResponse apiResponse) {
if (apiResponse.getError() != null || apiResponse.getVideoExistPlaylist() == null) {
return;

View File

@ -177,6 +177,9 @@ public class PeertubeRegisterActivity extends AppCompatActivity {
String host = emailArray[1];
instance = Helper.getPeertubeUrl(host);
}
if (instance != null) {
instance = instance.toLowerCase().trim();
}
AccountCreation accountCreation = new AccountCreation();
accountCreation.setEmail(email.getText().toString().trim());

View File

@ -55,7 +55,7 @@ public class SepiaSearchActivity extends AppCompatActivity {
private SepiaSearch sepiaSearchVideo, sepiaSearchChannel;
private TagsEditText sepia_element_all_of_tags, sepia_element_one_of_tags;
private MaterialSearchBar searchBar;
private MaterialSearchBar searchBar;
private ConstraintLayout filter_elements;
@Override
@ -79,9 +79,9 @@ public class SepiaSearchActivity extends AppCompatActivity {
Button filter = findViewById(R.id.filter);
filter_elements = findViewById(R.id.filter_elements);
filter.setOnClickListener(view -> {
if( filter_elements.getVisibility() == View.VISIBLE) {
if (filter_elements.getVisibility() == View.VISIBLE) {
filter_elements.setVisibility(View.GONE);
}else{
} else {
filter_elements.setVisibility(View.VISIBLE);
}
});
@ -140,7 +140,6 @@ public class SepiaSearchActivity extends AppCompatActivity {
});
Spinner sort_by = findViewById(R.id.sort_by);
ArrayAdapter<String> adapterSortBy = new ArrayAdapter<>(SepiaSearchActivity.this,
android.R.layout.simple_spinner_dropdown_item, getResources().getStringArray(R.array.sort_by_array));
@ -149,7 +148,7 @@ public class SepiaSearchActivity extends AppCompatActivity {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String orderby, channelOrderBy;
switch (position){
switch (position) {
case 1:
orderby = "-publishedAt";
channelOrderBy = "-createdAt";
@ -184,12 +183,12 @@ public class SepiaSearchActivity extends AppCompatActivity {
LinkedHashMap<String, String> languages = new LinkedHashMap<>(peertubeInformation.getLanguages());
LinkedHashMap<String, String> translations = null;
if( peertubeInformation.getTranslations() != null) {
if (peertubeInformation.getTranslations() != null) {
translations = new LinkedHashMap<>(peertubeInformation.getTranslations());
}
//Populate catgories
String[] categoriesA = new String[categories.size()+1];
String[] categoriesA = new String[categories.size() + 1];
categoriesA[0] = getString(R.string.display_all_categories);
Iterator<Map.Entry<Integer, String>> it = categories.entrySet().iterator();
int i = 1;
@ -208,7 +207,7 @@ public class SepiaSearchActivity extends AppCompatActivity {
//Populate licenses
String[] licensesA = new String[licences.size()+1];
String[] licensesA = new String[licences.size() + 1];
licensesA[0] = getString(R.string.display_all_licenses);
it = licences.entrySet().iterator();
i = 1;
@ -226,7 +225,7 @@ public class SepiaSearchActivity extends AppCompatActivity {
sepia_element_license.setAdapter(adapterLicenses);
//Populate languages
String[] languagesA = new String[languages.size()+1];
String[] languagesA = new String[languages.size() + 1];
languagesA[0] = getString(R.string.display_all_languages);
Iterator<Map.Entry<String, String>> itl = languages.entrySet().iterator();
i = 1;
@ -282,7 +281,6 @@ public class SepiaSearchActivity extends AppCompatActivity {
});
searchBar = findViewById(R.id.searchBar);
searchBar.setOnSearchActionListener(new MaterialSearchBar.OnSearchActionListener() {
@ -302,27 +300,27 @@ public class SepiaSearchActivity extends AppCompatActivity {
}
});
Button apply_filter = findViewById(R.id.apply_filter);
apply_filter.setOnClickListener(v-> makeSearch());
apply_filter.setOnClickListener(v -> makeSearch());
searchBar.openSearch();
}
private void makeSearch(){
private void makeSearch() {
hideKeyboard(SepiaSearchActivity.this);
sepiaSearchVideo.setStart("0");
if( sepia_element_one_of_tags.getTags().size() > 0 ) {
if (sepia_element_one_of_tags.getTags().size() > 0) {
sepiaSearchVideo.setTagsOneOf(sepia_element_one_of_tags.getTags());
}else{
} else {
sepiaSearchVideo.setTagsOneOf(null);
}
if( sepia_element_all_of_tags.getTags().size() > 0 ) {
if (sepia_element_all_of_tags.getTags().size() > 0) {
sepiaSearchVideo.setTagsAllOf(sepia_element_all_of_tags.getTags());
}else{
} else {
sepiaSearchVideo.setTagsAllOf(null);
}
Fragment fragment = getSupportFragmentManager().findFragmentByTag("SEPIA_SEARCH");
if(fragment != null)
if (fragment != null)
getSupportFragmentManager().beginTransaction().remove(fragment).commit();
filter_elements.setVisibility(View.GONE);
sepiaSearchVideo.setSearch(searchBar.getText());
@ -331,7 +329,7 @@ public class SepiaSearchActivity extends AppCompatActivity {
bundle.putParcelable("sepiaSearchVideo", sepiaSearchVideo);
displaySepiaSearchFragment.setArguments(bundle);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.add(R.id.container, displaySepiaSearchFragment,"SEPIA_SEARCH").commit();
ft.add(R.id.container, displaySepiaSearchFragment, "SEPIA_SEARCH").commit();
}
@Override
@ -354,7 +352,7 @@ public class SepiaSearchActivity extends AppCompatActivity {
languages.add(pair.getKey());
sepiaSearchVideo.setBoostLanguages(languages);
break;
}else {
} else {
sepiaSearchVideo.setBoostLanguages(null);
}
it.remove();
@ -368,12 +366,12 @@ public class SepiaSearchActivity extends AppCompatActivity {
int i = 0;
while (it.hasNext()) {
Map.Entry<Integer, String> pair = it.next();
if (i == position && position > 0 ) {
if (i == position && position > 0) {
List<Integer> categories = new ArrayList<>();
categories.add(pair.getKey());
sepiaSearchVideo.setCategoryOneOf(categories);
break;
}else {
} else {
sepiaSearchVideo.setCategoryOneOf(null);
}
it.remove();
@ -392,7 +390,7 @@ public class SepiaSearchActivity extends AppCompatActivity {
licenses.add(pair.getKey());
sepiaSearchVideo.setLicenceOneOf(licenses);
break;
}else {
} else {
sepiaSearchVideo.setLicenceOneOf(null);
}
it.remove();

View File

@ -42,11 +42,9 @@ import com.google.android.material.tabs.TabLayout;
import org.jetbrains.annotations.NotNull;
import app.fedilab.fedilabtube.client.APIResponse;
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
import app.fedilab.fedilabtube.client.data.AccountData;
import app.fedilab.fedilabtube.fragment.DisplayAccountsFragment;
import app.fedilab.fedilabtube.fragment.DisplayChannelsFragment;
import app.fedilab.fedilabtube.fragment.DisplayVideosFragment;
import app.fedilab.fedilabtube.helper.Helper;

View File

@ -120,7 +120,7 @@ public class ShowChannelActivity extends AppCompatActivity {
ChannelsVM viewModel = new ViewModelProvider(ShowChannelActivity.this).get(ChannelsVM.class);
viewModel.get(sepiaSearch?peertubeInstance:null, CHANNEL, channelAcct == null ? channel.getAcct() : channelAcct).observe(ShowChannelActivity.this, this::manageViewAccounts);
viewModel.get(sepiaSearch ? peertubeInstance : null, CHANNEL, channelAcct == null ? channel.getAcct() : channelAcct).observe(ShowChannelActivity.this, this::manageViewAccounts);
manageChannel();
}
@ -243,7 +243,7 @@ public class ShowChannelActivity extends AppCompatActivity {
manageNotes(channel);
Helper.loadGiF(ShowChannelActivity.this, sepiaSearch?peertubeInstance:null, channel.getAvatar() != null ? channel.getAvatar().getPath() : null, account_pp);
Helper.loadGiF(ShowChannelActivity.this, sepiaSearch ? peertubeInstance : null, channel.getAvatar() != null ? channel.getAvatar().getPath() : null, account_pp);
//Follow button
String target = channel.getAcct();

View File

@ -17,7 +17,6 @@ package app.fedilab.fedilabtube.client;
import java.util.List;
import java.util.Map;
import app.fedilab.fedilabtube.client.data.AccountData;
import app.fedilab.fedilabtube.client.data.BlockData;
import app.fedilab.fedilabtube.client.data.CaptionData;

View File

@ -85,9 +85,9 @@ public class RetrofitPeertubeAPI {
private final String finalUrl;
private final Context _context;
private final String instance;
private final String count;
private String token;
private Set<String> selection;
private final String count;
public RetrofitPeertubeAPI(Context context) {
_context = context;
@ -565,7 +565,7 @@ public class RetrofitPeertubeAPI {
lang = lang.split("-")[0] + "-" + lang.split("-")[1].toUpperCase();
}
}
if( lang == null || lang.trim().length() == 0) {
if (lang == null || lang.trim().length() == 0) {
lang = "en";
}
Call<Map<String, String>> translations = initTranslation().getTranslations(lang);

View File

@ -21,7 +21,6 @@ import java.util.Locale;
import app.fedilab.fedilabtube.client.data.VideoData;
import app.fedilab.fedilabtube.client.entities.SepiaSearch;
import app.fedilab.fedilabtube.helper.Helper;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
@ -30,7 +29,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class RetrofitSepiaSearchAPI {
private String finalUrl;
private final String finalUrl;
public RetrofitSepiaSearchAPI() {
@ -47,6 +46,7 @@ public class RetrofitSepiaSearchAPI {
/**
* Return videos for a sepia search
*
* @param sepiaSearch SepiaSearch
* @return VideoData
*/
@ -54,7 +54,7 @@ public class RetrofitSepiaSearchAPI {
SepiaSearchService sepiaSearchService = init();
SimpleDateFormat fmtOut = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH);
String startDate = null;
if(sepiaSearch.getStartDate() != null) {
if (sepiaSearch.getStartDate() != null) {
startDate = fmtOut.format(sepiaSearch.getStartDate());
}
Call<VideoData> videoDataCall = sepiaSearchService.getVideos(
@ -75,7 +75,7 @@ public class RetrofitSepiaSearchAPI {
try {
Response<VideoData> response = videoDataCall.execute();
if (response.isSuccessful() && response.body() != null) {
return response.body();
return response.body();
}
} catch (IOException e) {
e.printStackTrace();

View File

@ -14,7 +14,6 @@ package app.fedilab.fedilabtube.client;
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
import java.util.Date;
import java.util.List;
import app.fedilab.fedilabtube.client.data.ChannelData;

View File

@ -206,7 +206,7 @@ public class CommentData {
}
}
public static class CommentPosted{
public static class CommentPosted {
@SerializedName("comment")
private Comment comment;

View File

@ -26,6 +26,17 @@ import java.util.List;
@SuppressWarnings("unused")
public class SepiaSearch implements Parcelable {
public static final Creator<SepiaSearch> CREATOR = new Creator<SepiaSearch>() {
@Override
public SepiaSearch createFromParcel(Parcel source) {
return new SepiaSearch(source);
}
@Override
public SepiaSearch[] newArray(int size) {
return new SepiaSearch[size];
}
};
@SerializedName("start")
private String start;
@SerializedName("count")
@ -53,7 +64,27 @@ public class SepiaSearch implements Parcelable {
@SerializedName("sort")
private String sort;
public SepiaSearch() {
}
protected SepiaSearch(Parcel in) {
this.start = in.readString();
this.count = in.readString();
this.search = in.readString();
this.durationMax = in.readInt();
this.durationMin = in.readInt();
long tmpStartDate = in.readLong();
this.startDate = tmpStartDate == -1 ? null : new Date(tmpStartDate);
this.boostLanguages = in.createStringArrayList();
this.categoryOneOf = new ArrayList<>();
in.readList(this.categoryOneOf, Integer.class.getClassLoader());
this.licenceOneOf = new ArrayList<>();
in.readList(this.licenceOneOf, Integer.class.getClassLoader());
this.tagsOneOf = in.createStringArrayList();
this.tagsAllOf = in.createStringArrayList();
this.nsfw = in.readByte() != 0;
this.sort = in.readString();
}
public String getStart() {
return start;
@ -180,38 +211,4 @@ public class SepiaSearch implements Parcelable {
dest.writeByte(this.nsfw ? (byte) 1 : (byte) 0);
dest.writeString(this.sort);
}
public SepiaSearch() {
}
protected SepiaSearch(Parcel in) {
this.start = in.readString();
this.count = in.readString();
this.search = in.readString();
this.durationMax = in.readInt();
this.durationMin = in.readInt();
long tmpStartDate = in.readLong();
this.startDate = tmpStartDate == -1 ? null : new Date(tmpStartDate);
this.boostLanguages = in.createStringArrayList();
this.categoryOneOf = new ArrayList<>();
in.readList(this.categoryOneOf, Integer.class.getClassLoader());
this.licenceOneOf = new ArrayList<>();
in.readList(this.licenceOneOf, Integer.class.getClassLoader());
this.tagsOneOf = in.createStringArrayList();
this.tagsAllOf = in.createStringArrayList();
this.nsfw = in.readByte() != 0;
this.sort = in.readString();
}
public static final Creator<SepiaSearch> CREATOR = new Creator<SepiaSearch>() {
@Override
public SepiaSearch createFromParcel(Parcel source) {
return new SepiaSearch(source);
}
@Override
public SepiaSearch[] newArray(int size) {
return new SepiaSearch[size];
}
};
}

View File

@ -44,7 +44,7 @@ public class VideoAbuse {
}
public static class Abuse{
public static class Abuse {
@SerializedName("comment")
private CommentData.Comment comment;
@SerializedName("threadId")

View File

@ -37,8 +37,8 @@ import app.fedilab.fedilabtube.helper.Helper;
public class AccountsHorizontalListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final List<ChannelData.Channel> channels;
EventListener listener;
private List<ChannelData.Channel> channels;
private Context context;
public AccountsHorizontalListAdapter(List<ChannelData.Channel> channels, EventListener listener) {
@ -109,11 +109,7 @@ public class AccountsHorizontalListAdapter extends RecyclerView.Adapter<Recycler
ChannelData.Channel channel = channels.get(getAdapterPosition());
listener.click(channel.getAcct());
for (ChannelData.Channel acc : channels) {
if (acc.getId().compareTo(channel.getId()) == 0) {
acc.setSelected(true);
} else {
acc.setSelected(false);
}
acc.setSelected(acc.getId().compareTo(channel.getId()) == 0);
}
notifyItemRangeChanged(0, channels.size());
}

View File

@ -47,11 +47,11 @@ import es.dmoral.toasty.Toasty;
public class AccountsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
public AllAccountsRemoved allAccountsRemoved;
private final List<Account> accounts;
private Context context;
private final AccountsListAdapter accountsListAdapter;
private final RetrofitPeertubeAPI.DataType type;
public AllAccountsRemoved allAccountsRemoved;
private Context context;
public AccountsListAdapter(RetrofitPeertubeAPI.DataType type, List<Account> accounts) {
this.accounts = accounts;

View File

@ -44,11 +44,11 @@ import app.fedilab.fedilabtube.helper.Helper;
public class ChannelListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final List<Channel> channels;
private final boolean myChannel;
public AllChannelRemoved allChannelRemoved;
public EditAlertDialog editAlertDialog;
private final List<Channel> channels;
private Context context;
private final boolean myChannel;
public ChannelListAdapter(List<Channel> channels, boolean myChannel) {
@ -77,7 +77,7 @@ public class ChannelListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
//Profile picture
Helper.loadGiF(context, channel.getAvatar() != null ? channel.getAvatar().getPath() : null, holder.account_pp);
if( !this.myChannel) {
if (!this.myChannel) {
holder.more_actions.setVisibility(View.GONE);
}
holder.more_actions.setOnClickListener(view -> {

View File

@ -55,7 +55,6 @@ import java.util.regex.Pattern;
import app.fedilab.fedilabtube.PeertubeActivity;
import app.fedilab.fedilabtube.R;
import app.fedilab.fedilabtube.ShowAccountActivity;
import app.fedilab.fedilabtube.ShowChannelActivity;
import app.fedilab.fedilabtube.client.APIResponse;
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
import app.fedilab.fedilabtube.client.data.CommentData.Comment;
@ -74,11 +73,11 @@ import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn;
public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
public AllCommentRemoved allCommentRemoved;
private Context context;
private final List<Comment> comments;
private final CommentListAdapter commentListAdapter;
public AllCommentRemoved allCommentRemoved;
boolean isVideoOwner;
private Context context;
public CommentListAdapter(List<Comment> comments, boolean isVideoOwner) {
this.comments = comments;
@ -127,15 +126,15 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
.inflate(R.menu.comment_menu, popup.getMenu());
if (!Helper.isOwner(context, comment.getAccount())) {
popup.getMenu().findItem(R.id.action_delete).setVisible(false);
}else {
} else {
popup.getMenu().findItem(R.id.action_mute).setVisible(false);
popup.getMenu().findItem(R.id.action_remove_comments).setVisible(false);
popup.getMenu().findItem(R.id.action_report).setVisible(false);
}
if( !isVideoOwner) {
if (!isVideoOwner) {
popup.getMenu().findItem(R.id.action_remove_comments).setVisible(false);
}
if( !Helper.isLoggedIn(context)) {
if (!Helper.isLoggedIn(context)) {
popup.getMenu().findItem(R.id.action_mute).setVisible(false);
popup.getMenu().findItem(R.id.action_remove_comments).setVisible(false);
popup.getMenu().findItem(R.id.action_delete).setVisible(false);
@ -225,11 +224,11 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
holder.comment_account_displayname.setText(comment.getAccount().getDisplayName());
if( context instanceof PeertubeActivity && !comment.isReply()) {
if (context instanceof PeertubeActivity && !comment.isReply()) {
holder.main_container.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment, i));
holder.comment_content.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment, i));
}
if( comment.getTotalReplies() > 0) {
if (comment.getTotalReplies() > 0) {
holder.number_of_replies.setVisibility(View.VISIBLE);
holder.number_of_replies.setText(context.getResources().getQuantityString(R.plurals.number_of_replies, comment.getTotalReplies(), comment.getTotalReplies()));
} else {
@ -257,7 +256,7 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
Helper.loadGiF(context, comment.getAccount().getAvatar() != null ? comment.getAccount().getAvatar().getPath() : null, holder.comment_account_profile);
holder.comment_account_profile.setOnClickListener(v->{
holder.comment_account_profile.setOnClickListener(v -> {
Bundle b = new Bundle();
Intent intent = new Intent(context, ShowAccountActivity.class);
b.putParcelable("account", comment.getAccount());
@ -265,21 +264,21 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
intent.putExtras(b);
context.startActivity(intent);
});
if(comment.isReply()) {
if (comment.isReply()) {
holder.replyButton.setVisibility(View.VISIBLE);
}else{
} else {
holder.replyButton.setVisibility(View.GONE);
}
if( comment.isReply() && comment.isReplyViewOpen()) {
if (comment.isReply() && comment.isReplyViewOpen()) {
holder.write_comment_container_reply.setVisibility(View.VISIBLE);
}else{
} else {
holder.write_comment_container_reply.setVisibility(View.GONE);
}
if( holder.add_comment_write_reply.getText() == null || holder.add_comment_write_reply.getText().toString().trim().length() == 0) {
if (holder.add_comment_write_reply.getText() == null || holder.add_comment_write_reply.getText().toString().trim().length() == 0) {
holder.add_comment_write_reply.setText(String.format("@%s ", comment.getAccount().getAcct()));
holder.add_comment_write_reply.setSelection(holder.add_comment_write_reply.getText().length());
}
holder.replyButton.setOnClickListener(v->{
holder.replyButton.setOnClickListener(v -> {
comment.setReplyViewOpen(!comment.isReplyViewOpen());
notifyItemChanged(i);
});
@ -287,10 +286,10 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
holder.send_reply.setOnClickListener(null);
holder.send_reply.setOnClickListener(v -> {
if (isLoggedIn(context)) {
String commentView = holder.add_comment_write_reply.getText().toString();
String commentView = holder.add_comment_write_reply.getText().toString();
if (commentView.trim().length() > 0) {
PostActionsVM viewModelComment = new ViewModelProvider((ViewModelStoreOwner) context).get(PostActionsVM.class);
viewModelComment.comment(REPLY, comment.getVideoId(), comment.getId(), commentView).observe((LifecycleOwner) context, apiResponse1 -> manageVIewPostActions(REPLY, (int)holder.main_container.getTag(), apiResponse1));
viewModelComment.comment(REPLY, comment.getVideoId(), comment.getId(), commentView).observe((LifecycleOwner) context, apiResponse1 -> manageVIewPostActions(REPLY, (int) holder.main_container.getTag(), apiResponse1));
holder.add_comment_write_reply.setText("");
comment.setReplyViewOpen(false);
notifyItemChanged(i);
@ -316,13 +315,13 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
position++;
}
} else if (statusAction == REPLY) {
if( apiResponse.getComments() != null && apiResponse.getComments().size() > 0 ) {
comments.add(i+1, apiResponse.getComments().get(0));
notifyItemInserted(i+1);
if (apiResponse.getComments() != null && apiResponse.getComments().size() > 0) {
comments.add(i + 1, apiResponse.getComments().get(0));
notifyItemInserted(i + 1);
}
}else if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_COMMENT) {
} else if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_COMMENT) {
Toasty.success(context, context.getString(R.string.successful_report_comment), Toasty.LENGTH_LONG).show();
}else if (statusAction == MUTE) {
} else if (statusAction == MUTE) {
Toasty.info(context, context.getString(R.string.muted_done), Toast.LENGTH_LONG).show();
}
}

View File

@ -43,7 +43,7 @@ import static app.fedilab.fedilabtube.MainActivity.peertubeInformation;
public class InstanceAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private List<Instance> instances;
private final List<Instance> instances;
private Context context;

View File

@ -34,8 +34,8 @@ import app.fedilab.fedilabtube.helper.Helper;
public class OwnAccountsAdapter extends ArrayAdapter<Account> {
private List<Account> accounts;
private LayoutInflater layoutInflater;
private final List<Account> accounts;
private final LayoutInflater layoutInflater;
public OwnAccountsAdapter(Context context, List<Account> accounts) {
super(context, android.R.layout.simple_list_item_1, accounts);

View File

@ -63,9 +63,9 @@ import static app.fedilab.fedilabtube.viewmodel.TimelineVM.TimelineType.SEPIA_SE
public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final List<VideoData.Video> videos;
public RelationShipListener relationShipListener;
public PlaylistListener playlistListener;
private List<VideoData.Video> videos;
private Context context;
private TimelineVM.TimelineType timelineType;
private boolean sepiaSearch;
@ -78,7 +78,6 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
}
public PeertubeAdapter(List<VideoData.Video> videos) {
this.videos = videos;
}
@ -98,7 +97,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
final PeertubeAdapter.ViewHolder holder = (PeertubeAdapter.ViewHolder) viewHolder;
final VideoData.Video video = videos.get(position);
if( video == null) {
if (video == null) {
return;
}
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
@ -115,7 +114,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
}
String instance = null;
if( sepiaSearch) {
if (sepiaSearch) {
instance = video.getAccount().getHost();
}
@ -151,7 +150,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
Bundle b = new Bundle();
b.putParcelable("channel", video.getChannel());
b.putBoolean("sepia_search", sepiaSearch);
if( sepiaSearch) {
if (sepiaSearch) {
b.putString("peertube_instance", video.getAccount().getHost());
}
intent.putExtras(b);
@ -180,76 +179,67 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
}
}
}
if (playlistListener == null || playlistListener.getPlaylist() == null || playlistListener.getPlaylist().size() == 0) {
popup.getMenu().findItem(R.id.action_playlist).setVisible(false);
} else {
popup.getMenu().findItem(R.id.action_playlist).setVisible(true);
}
popup.getMenu().findItem(R.id.action_playlist).setVisible(playlistListener != null && playlistListener.getPlaylist() != null && playlistListener.getPlaylist().size() != 0);
popup.setOnMenuItemClickListener(item -> {
switch (item.getItemId()) {
case R.id.action_follow:
if (relationShipListener.getRelationShip().containsKey(video.getChannel().getAcct()) && relationShipListener.getRelationShip().get(video.getChannel().getAcct())) {
relationShipListener.getRelationShip().put(video.getChannel().getAcct(), false);
popup.getMenu().findItem(R.id.action_follow).setTitle(context.getString(R.string.action_follow));
boolean confirm_unfollow = sharedpreferences.getBoolean(Helper.SET_UNFOLLOW_VALIDATION, true);
if (confirm_unfollow) {
AlertDialog.Builder unfollowConfirm = new AlertDialog.Builder(context);
unfollowConfirm.setTitle(context.getString(R.string.unfollow_confirm));
unfollowConfirm.setMessage(video.getChannel().getAcct());
unfollowConfirm.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
unfollowConfirm.setPositiveButton(R.string.yes, (dialog, which) -> {
PostActionsVM viewModel = new ViewModelProvider((ViewModelStoreOwner) context).get(PostActionsVM.class);
viewModel.post(UNFOLLOW, video.getChannel().getAcct(), null).observe((LifecycleOwner) context, apiResponse -> manageVIewPostActions(UNFOLLOW, apiResponse));
dialog.dismiss();
});
unfollowConfirm.show();
} else {
int itemId = item.getItemId();
if (itemId == R.id.action_follow) {
if (relationShipListener.getRelationShip().containsKey(video.getChannel().getAcct()) && relationShipListener.getRelationShip().get(video.getChannel().getAcct())) {
relationShipListener.getRelationShip().put(video.getChannel().getAcct(), false);
popup.getMenu().findItem(R.id.action_follow).setTitle(context.getString(R.string.action_follow));
boolean confirm_unfollow = sharedpreferences.getBoolean(Helper.SET_UNFOLLOW_VALIDATION, true);
if (confirm_unfollow) {
AlertDialog.Builder unfollowConfirm = new AlertDialog.Builder(context);
unfollowConfirm.setTitle(context.getString(R.string.unfollow_confirm));
unfollowConfirm.setMessage(video.getChannel().getAcct());
unfollowConfirm.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
unfollowConfirm.setPositiveButton(R.string.yes, (dialog, which) -> {
PostActionsVM viewModel = new ViewModelProvider((ViewModelStoreOwner) context).get(PostActionsVM.class);
viewModel.post(UNFOLLOW, video.getChannel().getAcct(), null).observe((LifecycleOwner) context, apiResponse -> manageVIewPostActions(UNFOLLOW, apiResponse));
}
dialog.dismiss();
});
unfollowConfirm.show();
} else {
relationShipListener.getRelationShip().put(video.getChannel().getAcct(), true);
popup.getMenu().findItem(R.id.action_follow).setTitle(context.getString(R.string.action_unfollow));
PostActionsVM viewModel = new ViewModelProvider((ViewModelStoreOwner) context).get(PostActionsVM.class);
viewModel.post(FOLLOW, video.getChannel().getAcct(), null).observe((LifecycleOwner) context, apiResponse -> manageVIewPostActions(FOLLOW, apiResponse));
viewModel.post(UNFOLLOW, video.getChannel().getAcct(), null).observe((LifecycleOwner) context, apiResponse -> manageVIewPostActions(UNFOLLOW, apiResponse));
}
break;
case R.id.action_playlist:
PlaylistsVM viewModelOwnerPlaylist = new ViewModelProvider((ViewModelStoreOwner) context).get(PlaylistsVM.class);
viewModelOwnerPlaylist.manage(PlaylistsVM.action.GET_PLAYLISTS, null, null).observe((LifecycleOwner) context, apiResponse -> manageVIewPlaylists(video, apiResponse));
break;
case R.id.action_edit:
Intent intent = new Intent(context, PeertubeEditUploadActivity.class);
Bundle b = new Bundle();
b.putString("video_id", video.getUuid());
intent.putExtras(b);
context.startActivity(intent);
break;
case R.id.action_report:
androidx.appcompat.app.AlertDialog.Builder dialogBuilder = new androidx.appcompat.app.AlertDialog.Builder(context);
LayoutInflater inflater1 = ((Activity) context).getLayoutInflater();
View dialogView = inflater1.inflate(R.layout.popup_report, new LinearLayout(context), false);
dialogBuilder.setView(dialogView);
EditText report_content = dialogView.findViewById(R.id.report_content);
dialogBuilder.setNeutralButton(R.string.cancel, (dialog2, id) -> dialog2.dismiss());
dialogBuilder.setPositiveButton(R.string.report, (dialog2, id) -> {
if (report_content.getText().toString().trim().length() == 0) {
Toasty.info(context, context.getString(R.string.report_comment_size), Toasty.LENGTH_LONG).show();
} else {
PostActionsVM viewModel = new ViewModelProvider((ViewModelStoreOwner) context).get(PostActionsVM.class);
Report report = new Report();
Report.VideoReport videoReport = new Report.VideoReport();
videoReport.setId(video.getId());
report.setVideo(videoReport);
report.setReason(report_content.getText().toString());
viewModel.report(report).observe((LifecycleOwner) context, apiResponse -> manageVIewPostActions(RetrofitPeertubeAPI.ActionType.REPORT_VIDEO, apiResponse));
dialog2.dismiss();
}
});
androidx.appcompat.app.AlertDialog alertDialog2 = dialogBuilder.create();
alertDialog2.show();
break;
} else {
relationShipListener.getRelationShip().put(video.getChannel().getAcct(), true);
popup.getMenu().findItem(R.id.action_follow).setTitle(context.getString(R.string.action_unfollow));
PostActionsVM viewModel = new ViewModelProvider((ViewModelStoreOwner) context).get(PostActionsVM.class);
viewModel.post(FOLLOW, video.getChannel().getAcct(), null).observe((LifecycleOwner) context, apiResponse -> manageVIewPostActions(FOLLOW, apiResponse));
}
} else if (itemId == R.id.action_playlist) {
PlaylistsVM viewModelOwnerPlaylist = new ViewModelProvider((ViewModelStoreOwner) context).get(PlaylistsVM.class);
viewModelOwnerPlaylist.manage(PlaylistsVM.action.GET_PLAYLISTS, null, null).observe((LifecycleOwner) context, apiResponse -> manageVIewPlaylists(video, apiResponse));
} else if (itemId == R.id.action_edit) {
Intent intent = new Intent(context, PeertubeEditUploadActivity.class);
Bundle b = new Bundle();
b.putString("video_id", video.getUuid());
intent.putExtras(b);
context.startActivity(intent);
} else if (itemId == R.id.action_report) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
LayoutInflater inflater1 = ((Activity) context).getLayoutInflater();
View dialogView = inflater1.inflate(R.layout.popup_report, new LinearLayout(context), false);
dialogBuilder.setView(dialogView);
EditText report_content = dialogView.findViewById(R.id.report_content);
dialogBuilder.setNeutralButton(R.string.cancel, (dialog2, id) -> dialog2.dismiss());
dialogBuilder.setPositiveButton(R.string.report, (dialog2, id) -> {
if (report_content.getText().toString().trim().length() == 0) {
Toasty.info(context, context.getString(R.string.report_comment_size), Toasty.LENGTH_LONG).show();
} else {
PostActionsVM viewModel = new ViewModelProvider((ViewModelStoreOwner) context).get(PostActionsVM.class);
Report report = new Report();
Report.VideoReport videoReport = new Report.VideoReport();
videoReport.setId(video.getId());
report.setVideo(videoReport);
report.setReason(report_content.getText().toString());
viewModel.report(report).observe((LifecycleOwner) context, apiResponse -> manageVIewPostActions(RetrofitPeertubeAPI.ActionType.REPORT_VIDEO, apiResponse));
dialog2.dismiss();
}
});
AlertDialog alertDialog2 = dialogBuilder.create();
alertDialog2.show();
}
return true;
});
@ -263,7 +253,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
b.putBoolean("isMyVideo", ownVideos);
b.putBoolean("sepia_search", sepiaSearch);
b.putParcelable("video", video);
if( sepiaSearch) {
if (sepiaSearch) {
b.putString("peertube_instance", video.getAccount().getHost());
}
intent.putExtras(b);
@ -277,7 +267,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
b.putString("video_uuid", video.getUuid());
b.putBoolean("isMyVideo", ownVideos);
b.putBoolean("sepia_search", sepiaSearch);
if( sepiaSearch) {
if (sepiaSearch) {
b.putString("peertube_instance", video.getAccount().getHost());
}
intent.putExtras(b);
@ -296,7 +286,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
builder.setTitle(R.string.modify_playlists);
List<PlaylistData.Playlist> ownerPlaylists = apiResponse.getPlaylists();
if( ownerPlaylists == null){
if (ownerPlaylists == null) {
return;
}
String[] label = new String[ownerPlaylists.size()];
@ -385,7 +375,6 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
}
static class ViewHolder extends RecyclerView.ViewHolder {
LinearLayout main_container, bottom_container;
ImageView peertube_profile, peertube_video_image;

View File

@ -45,8 +45,8 @@ import app.fedilab.fedilabtube.helper.Helper;
public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
private final List<Notification> notifications;
private Context context;
public PeertubeNotificationsListAdapter(List<Notification> notifications) {
this.notifications = notifications;
@ -161,7 +161,7 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
holder.peertube_notif_message.setText(Html.fromHtml(message, Html.FROM_HTML_MODE_LEGACY));
else
holder.peertube_notif_message.setText(Html.fromHtml(message));
}else if (notification.getAbuse() != null){
} else if (notification.getAbuse() != null) {
if (notification.getType() == DisplayNotificationsFragment.MY_VIDEO_REPPORT_SUCCESS) {
message = context.getString(R.string.peertube_video_report_success, notification.getAbuse().getId());
}
@ -180,7 +180,7 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
if (finalAccountAction != null) {
intent = new Intent(context, ShowAccountActivity.class);
b.putParcelable("account", finalAccountAction);
b.putString("accountAcct", finalAccountAction.getUsername()+"@"+finalAccountAction.getHost());
b.putString("accountAcct", finalAccountAction.getUsername() + "@" + finalAccountAction.getHost());
} else if (finalChannelAction != null) {
intent = new Intent(context, ShowChannelActivity.class);
b.putParcelable("channel", finalChannelAction);

View File

@ -46,10 +46,10 @@ import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
public class PlaylistAdapter extends BaseAdapter {
private List<Playlist> playlists;
private LayoutInflater layoutInflater;
private Context context;
private RelativeLayout textviewNoAction;
private final List<Playlist> playlists;
private final LayoutInflater layoutInflater;
private final Context context;
private final RelativeLayout textviewNoAction;
public PlaylistAdapter(Context context, List<Playlist> lists, RelativeLayout textviewNoAction) {
this.playlists = lists;
@ -123,30 +123,28 @@ public class PlaylistAdapter extends BaseAdapter {
popup.getMenuInflater()
.inflate(R.menu.playlist_menu, popup.getMenu());
popup.setOnMenuItemClickListener(item -> {
switch (item.getItemId()) {
case R.id.action_delete:
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(context.getString(R.string.action_lists_delete) + ": " + playlist.getDisplayName());
builder.setMessage(context.getString(R.string.action_lists_confirm_delete));
builder.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(R.string.yes, (dialog, which) -> {
playlists.remove(playlist);
notifyDataSetChanged();
PlaylistsVM viewModel = new ViewModelProvider((ViewModelStoreOwner) context).get(PlaylistsVM.class);
viewModel.manage(PlaylistsVM.action.DELETE_PLAYLIST, playlist, null).observe((LifecycleOwner) context, apiResponse -> manageVIewPlaylists(PlaylistsVM.action.DELETE_PLAYLIST, apiResponse));
int itemId = item.getItemId();
if (itemId == R.id.action_delete) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(context.getString(R.string.action_lists_delete) + ": " + playlist.getDisplayName());
builder.setMessage(context.getString(R.string.action_lists_confirm_delete));
builder.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(R.string.yes, (dialog, which) -> {
playlists.remove(playlist);
notifyDataSetChanged();
PlaylistsVM viewModel = new ViewModelProvider((ViewModelStoreOwner) context).get(PlaylistsVM.class);
viewModel.manage(PlaylistsVM.action.DELETE_PLAYLIST, playlist, null).observe((LifecycleOwner) context, apiResponse -> manageVIewPlaylists(PlaylistsVM.action.DELETE_PLAYLIST, apiResponse));
if (playlists.size() == 0 && textviewNoAction != null && textviewNoAction.getVisibility() == View.GONE)
textviewNoAction.setVisibility(View.VISIBLE);
dialog.dismiss();
})
.setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss())
.show();
break;
case R.id.action_edit:
if (context instanceof AllPlaylistsActivity) {
((AllPlaylistsActivity) context).manageAlert(playlist);
}
break;
if (playlists.size() == 0 && textviewNoAction != null && textviewNoAction.getVisibility() == View.GONE)
textviewNoAction.setVisibility(View.VISIBLE);
dialog.dismiss();
})
.setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss())
.show();
} else if (itemId == R.id.action_edit) {
if (context instanceof AllPlaylistsActivity) {
((AllPlaylistsActivity) context).manageAlert(playlist);
}
}
return true;
});

View File

@ -89,7 +89,7 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
if (getActivity() != null) {
action_button = getActivity().findViewById(R.id.action_button);
if( action_button != null) {
if (action_button != null) {
action_button.setVisibility(View.VISIBLE);
action_button.setOnClickListener(view -> manageAlert(null));
}
@ -272,14 +272,14 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap
}
channelListAdapter.notifyItemChanged(position);
}
if( action_button != null) {
if (action_button != null) {
action_button.setEnabled(true);
}
};
mainHandler.post(myRunnable);
}).start();
alertDialog.dismiss();
if( action_button != null) {
if (action_button != null) {
action_button.setEnabled(false);
}
} else {

View File

@ -38,7 +38,6 @@ import app.fedilab.fedilabtube.R;
import app.fedilab.fedilabtube.client.APIResponse;
import app.fedilab.fedilabtube.client.data.NotificationData.Notification;
import app.fedilab.fedilabtube.drawer.PeertubeNotificationsListAdapter;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.viewmodel.NotificationsVM;
import es.dmoral.toasty.Toasty;

View File

@ -370,11 +370,45 @@ public class DisplayOverviewFragment extends Fragment implements PeertubeAdapter
viewModelFeeds.getOverviewVideos(String.valueOf(page)).observe(DisplayOverviewFragment.this.requireActivity(), this::manageVIewVideos);
}
public void manageVIewPlaylist(APIResponse apiResponse) {
if (apiResponse.getError() != null || apiResponse.getVideoExistPlaylist() == null) {
return;
}
if (playlists == null) {
playlists = new HashMap<>();
}
playlists.putAll(apiResponse.getVideoExistPlaylist());
for (VideoData.Video video : peertubes) {
video.setPlaylistExists(playlists.get(video.getId()));
}
}
public void manageVIewRelationship(APIResponse apiResponse) {
if (apiResponse.getError() != null) {
return;
}
if (relationship == null) {
relationship = new HashMap<>();
}
relationship.putAll(apiResponse.getRelationships());
}
@Override
public Map<String, Boolean> getRelationShip() {
return relationship;
}
@Override
public Map<String, List<PlaylistExist>> getPlaylist() {
return playlists;
}
static class GridSpacingItemDecoration extends RecyclerView.ItemDecoration {
private int spanCount;
private int spacing;
private boolean includeEdge;
private final int spanCount;
private final int spacing;
private final boolean includeEdge;
public GridSpacingItemDecoration(int spanCount, int spacing, boolean includeEdge) {
this.spanCount = spanCount;
@ -405,40 +439,4 @@ public class DisplayOverviewFragment extends Fragment implements PeertubeAdapter
}
}
public void manageVIewPlaylist(APIResponse apiResponse) {
if (apiResponse.getError() != null || apiResponse.getVideoExistPlaylist() == null) {
return;
}
if (playlists == null) {
playlists = new HashMap<>();
}
playlists.putAll(apiResponse.getVideoExistPlaylist());
for (VideoData.Video video : peertubes) {
video.setPlaylistExists(playlists.get(video.getId()));
}
}
public void manageVIewRelationship(APIResponse apiResponse) {
if (apiResponse.getError() != null) {
return;
}
if (relationship == null) {
relationship = new HashMap<>();
}
relationship.putAll(apiResponse.getRelationships());
}
@Override
public Map<String, Boolean> getRelationShip() {
return relationship;
}
@Override
public Map<String, List<PlaylistExist>> getPlaylist() {
return playlists;
}
}

View File

@ -69,12 +69,11 @@ public class DisplaySepiaSearchFragment extends Fragment implements AccountsHori
private View rootView;
private RecyclerView lv_status;
private SepiaSearchVM viewModelSearch;
private SepiaSearch sepiaSearchVideo;
public DisplaySepiaSearchFragment() {
}
private SepiaSearch sepiaSearchVideo;
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_video, container, false);
@ -119,7 +118,6 @@ public class DisplaySepiaSearchFragment extends Fragment implements AccountsHori
swipeRefreshLayout.setOnRefreshListener(this::pullToRefresh);
lv_status.addOnScrollListener(new RecyclerView.OnScrollListener() {
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
if (mLayoutManager != null) {
@ -160,7 +158,6 @@ public class DisplaySepiaSearchFragment extends Fragment implements AccountsHori
}
@Override
public void onPause() {
super.onPause();
@ -215,13 +212,13 @@ public class DisplaySepiaSearchFragment extends Fragment implements AccountsHori
}
int previousPosition = this.peertubes.size();
int videoPerPage = sharedpreferences.getInt(Helper.SET_VIDEOS_PER_PAGE, Helper.VIDEOS_PER_PAGE);
sepiaSearchVideo.setStart(String.valueOf(Integer.parseInt(sepiaSearchVideo.getStart())+ videoPerPage));
sepiaSearchVideo.setStart(String.valueOf(Integer.parseInt(sepiaSearchVideo.getStart()) + videoPerPage));
if(!BuildConfig.google_restriction) {
if (!BuildConfig.google_restriction) {
this.peertubes.addAll(videoData.data);
}else{
for(VideoData.Video video: videoData.data) {
if ( video.getName() == null || !video.getName().toLowerCase().contains("youtube") || !video.getName().toLowerCase().contains("download")) {
} else {
for (VideoData.Video video : videoData.data) {
if (video.getName() == null || !video.getName().toLowerCase().contains("youtube") || !video.getName().toLowerCase().contains("download")) {
this.peertubes.add(video);
}
}
@ -237,7 +234,7 @@ public class DisplaySepiaSearchFragment extends Fragment implements AccountsHori
//remove handlers
swipeRefreshLayout.setRefreshing(false);
textviewNoAction.setVisibility(View.GONE);
if (firstLoad && (videoData.data== null || videoData.data.size() == 0)) {
if (firstLoad && (videoData.data == null || videoData.data.size() == 0)) {
textviewNoActionText.setText(R.string.no_video_to_display);
textviewNoAction.setVisibility(View.VISIBLE);
}
@ -291,12 +288,11 @@ public class DisplaySepiaSearchFragment extends Fragment implements AccountsHori
}
static class GridSpacingItemDecoration extends RecyclerView.ItemDecoration {
private int spanCount;
private int spacing;
private boolean includeEdge;
private final int spanCount;
private final int spacing;
private final boolean includeEdge;
public GridSpacingItemDecoration(int spanCount, int spacing, boolean includeEdge) {
this.spanCount = spanCount;

View File

@ -99,6 +99,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
private String playlistId;
private String remoteInstance;
private boolean sepiaSearch;
public DisplayVideosFragment() {
}
@ -121,7 +122,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
playlistId = bundle.getString("playlistId", null);
}
max_id = "0";
forAccount = type== TimelineVM.TimelineType.ACCOUNT_VIDEOS?channelId: null;
forAccount = type == TimelineVM.TimelineType.ACCOUNT_VIDEOS ? channelId : null;
lv_status = rootView.findViewById(R.id.lv_status);
RecyclerView lv_accounts = rootView.findViewById(R.id.lv_accounts);
Button display_all = rootView.findViewById(R.id.display_all);
@ -245,7 +246,6 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
}
@Override
public void onPause() {
super.onPause();
@ -335,11 +335,11 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
apiResponse.getPeertubes().add(v.getVideo());
}
}
if(!BuildConfig.google_restriction) {
if (!BuildConfig.google_restriction) {
this.peertubes.addAll(apiResponse.getPeertubes());
}else{
for(VideoData.Video video: apiResponse.getPeertubes()) {
if ( video.getName() == null || !video.getName().toLowerCase().contains("youtube") || !video.getName().toLowerCase().contains("download")) {
} else {
for (VideoData.Video video : apiResponse.getPeertubes()) {
if (video.getName() == null || !video.getName().toLowerCase().contains("youtube") || !video.getName().toLowerCase().contains("download")) {
this.peertubes.add(video);
}
}
@ -367,7 +367,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
if (Helper.isLoggedIn(context)) {
List<String> uids = new ArrayList<>();
for (VideoData.Video video : apiResponse.getPeertubes()) {
if( video != null) {
if (video != null) {
uids.add(video.getChannel().getName() + "@" + video.getChannel().getHost());
}
}
@ -381,7 +381,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
List<String> videoIds = new ArrayList<>();
for (VideoData.Video video : apiResponse.getPeertubes()) {
if( video != null) {
if (video != null) {
videoIds.add(video.getId());
}
}
@ -405,7 +405,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
}
playlists.putAll(apiResponse.getVideoExistPlaylist());
for (VideoData.Video video : peertubes) {
if( video != null) {
if (video != null) {
video.setPlaylistExists(playlists.get(video.getId()));
}
}
@ -451,10 +451,10 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
public void pullToRefresh(boolean reload) {
if( type == TimelineVM.TimelineType.SUBSCRIBTIONS && reload) {
Fragment fragment = ((AppCompatActivity)context).getSupportFragmentManager().findFragmentByTag("2");
if(fragment != null) {
if( context instanceof MainActivity) {
if (type == TimelineVM.TimelineType.SUBSCRIBTIONS && reload) {
Fragment fragment = ((AppCompatActivity) context).getSupportFragmentManager().findFragmentByTag("2");
if (fragment != null) {
if (context instanceof MainActivity) {
FragmentManager fm = ((MainActivity) context).getSupportFragmentManager();
fm.beginTransaction().remove(fragment).commit();
DisplayVideosFragment subscriptionFragment = new DisplayVideosFragment();
@ -467,7 +467,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
}
}
}else {
} else {
int size = peertubes.size();
peertubes.clear();
peertubes = new ArrayList<>();
@ -498,7 +498,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
private void loadTimeline(String max_id) {
if (search_peertube == null) { //Not a Peertube search
if (type == TimelineVM.TimelineType.CHANNEL_VIDEOS) {
viewModelFeeds.getVideosInChannel(sepiaSearch?remoteInstance:null, channelId, max_id).observe(this.requireActivity(), this::manageVIewVideos);
viewModelFeeds.getVideosInChannel(sepiaSearch ? remoteInstance : null, channelId, max_id).observe(this.requireActivity(), this::manageVIewVideos);
} else if (type == TimelineVM.TimelineType.VIDEOS_IN_PLAYLIST) {
viewModelFeeds.loadVideosInPlaylist(playlistId, max_id).observe(this.requireActivity(), this::manageVIewVideos);
} else {

View File

@ -13,7 +13,9 @@ package app.fedilab.fedilabtube.helper;
*
* 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.content.Context;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@ -31,6 +33,7 @@ public class EmojiHelper {
/**
* Converts emojis in input to unicode
*
* @param input String
* @return String
*/
@ -51,27 +54,27 @@ public class EmojiHelper {
}
public static void fillMapEmoji(Context context) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(context.getAssets().open("emoji.csv")));
String line;
while( (line = br.readLine()) != null) {
while ((line = br.readLine()) != null) {
String[] str = line.split(",");
String unicode = null;
if(str.length == 2)
unicode = new String(new int[] {Integer.parseInt(str[1].replace("0x","").trim(), 16)}, 0, 1);
else if(str.length == 3)
unicode = new String(new int[] {Integer.parseInt(str[1].replace("0x","").trim(), 16), Integer.parseInt(str[2].replace("0x","").trim(), 16)}, 0, 2);
else if(str.length == 4)
unicode = new String(new int[] {Integer.parseInt(str[1].replace("0x","").trim(), 16), Integer.parseInt(str[2].replace("0x","").trim(), 16), Integer.parseInt(str[3].replace("0x","").trim(), 16)}, 0, 3);
else if(str.length == 5)
unicode = new String(new int[] {Integer.parseInt(str[1].replace("0x","").trim(), 16), Integer.parseInt(str[2].replace("0x","").trim(), 16), Integer.parseInt(str[3].replace("0x","").trim(), 16), Integer.parseInt(str[4].replace("0x","").trim(), 16)}, 0, 4);
if( unicode != null)
emoji.put(str[0],unicode);
if (str.length == 2)
unicode = new String(new int[]{Integer.parseInt(str[1].replace("0x", "").trim(), 16)}, 0, 1);
else if (str.length == 3)
unicode = new String(new int[]{Integer.parseInt(str[1].replace("0x", "").trim(), 16), Integer.parseInt(str[2].replace("0x", "").trim(), 16)}, 0, 2);
else if (str.length == 4)
unicode = new String(new int[]{Integer.parseInt(str[1].replace("0x", "").trim(), 16), Integer.parseInt(str[2].replace("0x", "").trim(), 16), Integer.parseInt(str[3].replace("0x", "").trim(), 16)}, 0, 3);
else if (str.length == 5)
unicode = new String(new int[]{Integer.parseInt(str[1].replace("0x", "").trim(), 16), Integer.parseInt(str[2].replace("0x", "").trim(), 16), Integer.parseInt(str[3].replace("0x", "").trim(), 16), Integer.parseInt(str[4].replace("0x", "").trim(), 16)}, 0, 4);
if (unicode != null)
emoji.put(str[0], unicode);
}
br.close();
} catch (IOException ignored) {ignored.printStackTrace();}
} catch (IOException ignored) {
}
}

View File

@ -36,9 +36,9 @@ import app.fedilab.fedilabtube.client.data.VideoData.Video;
*/
public class FullScreenMediaController extends MediaController {
private final Context context;
private ImageButton fullScreen;
private Button resolution;
private final Context context;
private Video peertube;
private String resolutionVal;

View File

@ -256,6 +256,7 @@ public class Helper {
/**
* Get a default instance host name depending of the device locale
*
* @return peertube host String
*/
private static String getDefaultInstance() {
@ -263,38 +264,37 @@ public class Helper {
if (lang.contains("-")) {
if (!lang.split("-")[0].trim().toLowerCase().startsWith("zh")) {
lang = lang.split("-")[0];
if(lang.split("-")[1].toLowerCase().contains("be")){
if (lang.split("-")[1].toLowerCase().contains("be")) {
lang = "be";
}
else if(lang.split("-")[1].toLowerCase().contains("gb")){
} else if (lang.split("-")[1].toLowerCase().contains("gb")) {
lang = "gb";
}
} else {
lang = lang.split("-")[0] + "-" + lang.split("-")[1].toUpperCase();
}
}
switch (lang){
case "it":
return "peertube.uno";
case "be":
return "peertube.be";
case "fr":
return "video.liberta.vip";
case "de":
return "peertube.at";
case "ru":
return "peertube.su";
case "gb":
return "peertube.co.uk";
case "da":
case "sv":
case "nb":
case "fi":
case "is":
return "peertube.dk";
default:
return "peertube.social";
}
switch (lang) {
case "it":
return "peertube.uno";
case "be":
return "peertube.be";
case "fr":
return "video.liberta.vip";
case "de":
return "peertube.at";
case "ru":
return "peertube.su";
case "gb":
return "peertube.co.uk";
case "da":
case "sv":
case "nb":
case "fi":
case "is":
return "peertube.dk";
default:
return "peertube.social";
}
}
/**
@ -338,6 +338,7 @@ public class Helper {
/**
* Convert second to String formated date
*
* @param pTime timestamp
* @return String formatted value
*/
@ -403,6 +404,7 @@ public class Helper {
/**
* Return rounded numbers depending of the value
*
* @param count long
* @return String rounded value to be displayed
*/
@ -448,7 +450,7 @@ public class Helper {
return;
}
if (url.startsWith("/")) {
url = instance!=null?instance+ url:Helper.getLiveInstance(context) + url;
url = instance != null ? instance + url : Helper.getLiveInstance(context) + url;
}
if (!url.startsWith("http")) {
url = "https://" + url;
@ -475,9 +477,10 @@ public class Helper {
/**
* Initialize the webview
* @param activity Current Activity
*
* @param activity Current Activity
* @param webviewId int id of the webview layout
* @param rootView View the root view
* @param rootView View the root view
* @return CustomWebview
*/
@SuppressLint("SetJavaScriptEnabled")

View File

@ -33,8 +33,8 @@ import app.fedilab.fedilabtube.helper.Helper;
@SuppressWarnings("UnusedReturnValue")
public class AccountDAO {
public Context context;
private final SQLiteDatabase db;
public Context context;
public AccountDAO(Context context, SQLiteDatabase db) {

View File

@ -46,9 +46,9 @@ public class CaptionsVM extends AndroidViewModel {
new Thread(() -> {
try {
RetrofitPeertubeAPI retrofitPeertubeAPI;
if( instance == null) {
if (instance == null) {
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
}else{
} else {
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext, instance, null);
}
APIResponse apiResponse = retrofitPeertubeAPI.getCaptions(videoId);

View File

@ -68,7 +68,7 @@ public class ChannelsVM extends AndroidViewModel {
finalElement = account.getUsername() + "@" + account.getHost();
}
RetrofitPeertubeAPI retrofitPeertubeAPI;
if( instance == null ) {
if (instance == null) {
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
} else {
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext, instance, null);

View File

@ -53,9 +53,9 @@ public class CommentVM extends AndroidViewModel {
new Thread(() -> {
try {
RetrofitPeertubeAPI retrofitPeertubeAPI;
if( instance == null) {
if (instance == null) {
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
}else{
} else {
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext, instance, null);
}
APIResponse apiResponse = retrofitPeertubeAPI.getComments(CommentVM.action.GET_THREAD, videoId, null, max_id);

View File

@ -22,6 +22,7 @@ import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import app.fedilab.fedilabtube.client.RetrofitSepiaSearchAPI;
import app.fedilab.fedilabtube.client.data.VideoData;
import app.fedilab.fedilabtube.client.entities.SepiaSearch;

View File

@ -69,13 +69,6 @@ public class TimelineVM extends AndroidViewModel {
return apiResponseMutableLiveData;
}
public LiveData<APIResponse> getVideosInChannel(String channelId, String max_id) {
apiResponseMutableLiveData = new MutableLiveData<>();
loadVideosForChannel(null, channelId, max_id);
return apiResponseMutableLiveData;
}
public LiveData<APIResponse> getVideosInChannel(String instance, String channelId, String max_id) {
apiResponseMutableLiveData = new MutableLiveData<>();
loadVideosForChannel(instance, channelId, max_id);
@ -87,9 +80,9 @@ public class TimelineVM extends AndroidViewModel {
new Thread(() -> {
try {
RetrofitPeertubeAPI retrofitPeertubeAPI;
if( instance == null) {
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
}else {
if (instance == null) {
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
} else {
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext, instance, null);
}
APIResponse apiResponse = retrofitPeertubeAPI.getVideosForChannel(channelId, max_id);
@ -107,9 +100,9 @@ public class TimelineVM extends AndroidViewModel {
new Thread(() -> {
try {
RetrofitPeertubeAPI retrofitPeertubeAPI;
if( instance == null) {
if (instance == null) {
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
}else{
} else {
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext, instance, null);
}
APIResponse apiResponse = retrofitPeertubeAPI.getVideos(videoId, myVideo);

View File

@ -42,12 +42,12 @@ public class MastalabWebChromeClient extends WebChromeClient implements MediaPla
private ToggledFullscreenCallback toggledFullscreenCallback;
private CustomWebview webView;
private View activityNonVideoView;
private ViewGroup activityVideoView;
private ProgressBar pbar;
private final CustomWebview webView;
private final View activityNonVideoView;
private final ViewGroup activityVideoView;
private final ProgressBar pbar;
private boolean isVideoFullscreen;
private Activity activity;
private final Activity activity;
public MastalabWebChromeClient(Activity activity, CustomWebview webView, FrameLayout activityNonVideoView, ViewGroup activityVideoView) {

View File

@ -32,7 +32,7 @@ import app.fedilab.fedilabtube.R;
public class MastalabWebViewClient extends WebViewClient {
private Activity activity;
private final Activity activity;
public MastalabWebViewClient(Activity activity) {

View File

@ -16,6 +16,11 @@
android:icon="@drawable/ic_baseline_subtitles_24"
android:title="@string/captions"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_edit"
android:icon="@drawable/ic_baseline_edit_24"
android:title="@string/edit"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_report"
android:icon="@drawable/ic_baseline_report_24"