diff --git a/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java b/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java index 304dde1..8390c5d 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/MainActivity.java @@ -74,35 +74,30 @@ public class MainActivity extends AppCompatActivity { private DisplayVideosFragment recentFragment, locaFragment, trendingFragment, subscriptionFragment, mostLikedFragment; private DisplayOverviewFragment overviewFragment; - private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener + private final BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener = item -> { DisplayVideosFragment displayVideosFragment = null; - switch (item.getItemId()) { - case R.id.navigation_subscription: - displayVideosFragment = subscriptionFragment; - setTitle(R.string.subscriptions); - break; - case R.id.navigation_trending: - setTitle(R.string.title_trending); - displayVideosFragment = trendingFragment; - break; - case R.id.navigation_most_liked: - setTitle(R.string.title_most_liked); - displayVideosFragment = mostLikedFragment; - break; - case R.id.navigation_recently_added: - setTitle(R.string.title_recently_added); - displayVideosFragment = recentFragment; - break; - case R.id.navigation_local: - setTitle(R.string.title_local); - displayVideosFragment = locaFragment; - break; - case R.id.navigation_discover: - setTitle(R.string.title_discover); - fm.beginTransaction().hide(active).show(overviewFragment).commit(); - active = overviewFragment; - return true; + int itemId = item.getItemId(); + if (itemId == R.id.navigation_subscription) { + displayVideosFragment = subscriptionFragment; + setTitle(R.string.subscriptions); + } else if (itemId == R.id.navigation_trending) { + setTitle(R.string.title_trending); + displayVideosFragment = trendingFragment; + } else if (itemId == R.id.navigation_most_liked) { + setTitle(R.string.title_most_liked); + displayVideosFragment = mostLikedFragment; + } else if (itemId == R.id.navigation_recently_added) { + setTitle(R.string.title_recently_added); + displayVideosFragment = recentFragment; + } else if (itemId == R.id.navigation_local) { + setTitle(R.string.title_local); + displayVideosFragment = locaFragment; + } else if (itemId == R.id.navigation_discover) { + setTitle(R.string.title_discover); + fm.beginTransaction().hide(active).show(overviewFragment).commit(); + active = overviewFragment; + return true; } if (displayVideosFragment != null) { fm.beginTransaction().hide(active).show(displayVideosFragment).commit(); diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java index 22e146c..0336de7 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java @@ -674,147 +674,147 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd popup.getMenu().findItem(R.id.action_captions).setEnabled(false); } popup.setOnMenuItemClickListener(item -> { - switch (item.getItemId()) { - case R.id.action_download: - if (Build.VERSION.SDK_INT >= 23) { - if (ContextCompat.checkSelfPermission(PeertubeActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(PeertubeActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { - ActivityCompat.requestPermissions(PeertubeActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE); - } else { - Helper.manageDownloads(PeertubeActivity.this, peertube.getFileDownloadUrl(null)); - } + int itemId = item.getItemId(); + if (itemId == R.id.action_download) { + if (Build.VERSION.SDK_INT >= 23) { + if (ContextCompat.checkSelfPermission(PeertubeActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(PeertubeActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(PeertubeActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE); } else { Helper.manageDownloads(PeertubeActivity.this, peertube.getFileDownloadUrl(null)); } - break; - case R.id.action_share: - Intent sendIntent = new Intent(Intent.ACTION_SEND); - sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.shared_via)); - String url; + } else { + Helper.manageDownloads(PeertubeActivity.this, peertube.getFileDownloadUrl(null)); + } + } else if (itemId == R.id.action_share) { + Intent sendIntent = new Intent(Intent.ACTION_SEND); + sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.shared_via)); + String url; - url = peertube.getFiles().get(0).getFileDownloadUrl(); - boolean share_details = sharedpreferences.getBoolean(Helper.SET_SHARE_DETAILS, true); - String extra_text; - if (share_details) { - extra_text = "@" + peertube.getAccount().getAcct(); - extra_text += "\r\n\r\n" + peertube.getName(); - extra_text += "\n\n\uD83D\uDD17 " + url + "\r\n-\n"; - final String contentToot; + url = peertube.getFiles().get(0).getFileDownloadUrl(); + boolean share_details = sharedpreferences.getBoolean(Helper.SET_SHARE_DETAILS, true); + String extra_text; + if (share_details) { + extra_text = "@" + peertube.getAccount().getAcct(); + extra_text += "\r\n\r\n" + peertube.getName(); + extra_text += "\n\n\uD83D\uDD17 " + url + "\r\n-\n"; + final String contentToot; + if (peertube.getDescription() != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) contentToot = Html.fromHtml(peertube.getDescription(), Html.FROM_HTML_MODE_LEGACY).toString(); else contentToot = Html.fromHtml(peertube.getDescription()).toString(); - extra_text += contentToot; } else { - extra_text = url; - } - sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text); - sendIntent.setType("text/plain"); - startActivity(Intent.createChooser(sendIntent, getString(R.string.share_with))); - break; - case R.id.action_captions: - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PeertubeActivity.this); - if (captions == null) { - return true; + contentToot = ""; } + extra_text += contentToot; + } else { + extra_text = url; + } + sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text); + sendIntent.setType("text/plain"); + startActivity(Intent.createChooser(sendIntent, getString(R.string.share_with))); + } else if (itemId == R.id.action_captions) { + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PeertubeActivity.this); + if (captions == null) { + return true; + } - String[] itemsKeyLanguage = new String[captions.size() + 1]; - String[] itemsLabelLanguage = new String[captions.size() + 1]; - itemsLabelLanguage[0] = getString(R.string.none); - itemsKeyLanguage[0] = "null"; - int i = 1; - if (captions.size() > 0) { - for (Caption caption : captions) { - ItemStr lang = caption.getLanguage(); - itemsLabelLanguage[i] = lang.getLabel(); - itemsKeyLanguage[i] = lang.getId(); - i++; + String[] itemsKeyLanguage = new String[captions.size() + 1]; + String[] itemsLabelLanguage = new String[captions.size() + 1]; + itemsLabelLanguage[0] = getString(R.string.none); + itemsKeyLanguage[0] = "null"; + int i = 1; + if (captions.size() > 0) { + for (Caption caption : captions) { + ItemStr lang = caption.getLanguage(); + itemsLabelLanguage[i] = lang.getLabel(); + itemsKeyLanguage[i] = lang.getId(); + i++; + } + } + dialogBuilder.setSingleChoiceItems(itemsLabelLanguage, i, (dialog, which) -> { + + Uri uri = null; + if (which > 0) { + if (!sepiaSearch) { + uri = Uri.parse("https://" + getLiveInstance(PeertubeActivity.this) + captions.get(which - 1).getCaptionPath()); + } else { + uri = Uri.parse("https://" + peertubeInstance + captions.get(which - 1).getCaptionPath()); } } - dialogBuilder.setSingleChoiceItems(itemsLabelLanguage, i, (dialog, which) -> { - Uri uri = null; - if (which > 0) { - if( !sepiaSearch) { - uri = Uri.parse("https://" + getLiveInstance(PeertubeActivity.this) + captions.get(which - 1).getCaptionPath()); - }else{ - uri = Uri.parse("https://" + peertubeInstance + captions.get(which - 1).getCaptionPath()); - } + int video_cache = sharedpreferences.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB); + + long position = player.getCurrentPosition(); + + if (player != null) + player.release(); + + TrackSelector trackSelector = new DefaultTrackSelector(new AdaptiveTrackSelection.Factory()); + player = ExoPlayerFactory.newSimpleInstance(PeertubeActivity.this, trackSelector); + ProgressiveMediaSource videoSource; + MediaSource subtitleSource = null; + Format subtitleFormat = Format.createTextSampleFormat( + null, + MimeTypes.TEXT_VTT, + Format.NO_VALUE, + itemsKeyLanguage[which]); + + + if (apiResponse.getPeertubes().get(0).getFiles() != null && apiResponse.getPeertubes().get(0).getFiles().size() > 0) { + if (video_cache == 0) { + DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this, + Util.getUserAgent(PeertubeActivity.this, null), null); + videoSource = new ProgressiveMediaSource.Factory(dataSourceFactory) + .createMediaSource(Uri.parse(apiResponse.getPeertubes().get(0).getFileUrl(null, PeertubeActivity.this))); + if (uri != null) + subtitleSource = new SingleSampleMediaSource.Factory(dataSourceFactory).createMediaSource(uri, subtitleFormat, C.TIME_UNSET); + + } else { + CacheDataSourceFactory cacheDataSourceFactory = new CacheDataSourceFactory(PeertubeActivity.this); + videoSource = new ProgressiveMediaSource.Factory(cacheDataSourceFactory) + .createMediaSource(Uri.parse(apiResponse.getPeertubes().get(0).getFileUrl(null, PeertubeActivity.this))); + if (uri != null) + subtitleSource = new SingleSampleMediaSource.Factory(cacheDataSourceFactory).createMediaSource(uri, subtitleFormat, C.TIME_UNSET); } - - int video_cache = sharedpreferences.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB); - - long position = player.getCurrentPosition(); - - if (player != null) - player.release(); - - TrackSelector trackSelector = new DefaultTrackSelector(new AdaptiveTrackSelection.Factory()); - player = ExoPlayerFactory.newSimpleInstance(PeertubeActivity.this, trackSelector); - ProgressiveMediaSource videoSource; - MediaSource subtitleSource = null; - Format subtitleFormat = Format.createTextSampleFormat( - null, - MimeTypes.TEXT_VTT, - Format.NO_VALUE, - itemsKeyLanguage[which]); - - - if (apiResponse.getPeertubes().get(0).getFiles() != null && apiResponse.getPeertubes().get(0).getFiles().size() > 0) { - if (video_cache == 0) { - DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this, - Util.getUserAgent(PeertubeActivity.this, null), null); - videoSource = new ProgressiveMediaSource.Factory(dataSourceFactory) - .createMediaSource(Uri.parse(apiResponse.getPeertubes().get(0).getFileUrl(null, PeertubeActivity.this))); - if (uri != null) - subtitleSource = new SingleSampleMediaSource.Factory(dataSourceFactory).createMediaSource(uri, subtitleFormat, C.TIME_UNSET); - - } else { - CacheDataSourceFactory cacheDataSourceFactory = new CacheDataSourceFactory(PeertubeActivity.this); - videoSource = new ProgressiveMediaSource.Factory(cacheDataSourceFactory) - .createMediaSource(Uri.parse(apiResponse.getPeertubes().get(0).getFileUrl(null, PeertubeActivity.this))); - if (uri != null) - subtitleSource = new SingleSampleMediaSource.Factory(cacheDataSourceFactory).createMediaSource(uri, subtitleFormat, C.TIME_UNSET); - } - playerView.setPlayer(player); - if (which > 0 && subtitleSource != null) { - MergingMediaSource mergedSource = - new MergingMediaSource(videoSource, subtitleSource); - player.prepare(mergedSource); - } else { - player.prepare(videoSource); - } - player.seekTo(0, position); - player.setPlayWhenReady(true); + playerView.setPlayer(player); + if (which > 0 && subtitleSource != null) { + MergingMediaSource mergedSource = + new MergingMediaSource(videoSource, subtitleSource); + player.prepare(mergedSource); + } else { + player.prepare(videoSource); } + player.seekTo(0, position); + player.setPlayWhenReady(true); + } - dialog.dismiss(); - }); + dialog.dismiss(); + }); - dialogBuilder.setOnDismissListener(dialogInterface -> { + dialogBuilder.setOnDismissListener(dialogInterface -> { - }); - dialogBuilder.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss()); + }); + dialogBuilder.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss()); - androidx.appcompat.app.AlertDialog alertDialog = dialogBuilder.create(); - alertDialog.setTitle(getString(R.string.pickup_captions)); - alertDialog.show(); - - break; - - case R.id.action_report: - dialogBuilder = new androidx.appcompat.app.AlertDialog.Builder(PeertubeActivity.this); - LayoutInflater inflater1 = getLayoutInflater(); - View dialogView = inflater1.inflate(R.layout.popup_report_choice, new LinearLayout(PeertubeActivity.this), false); - dialogBuilder.setView(dialogView); - Button report_video = dialogView.findViewById(R.id.report_video); - Button report_account = dialogView.findViewById(R.id.report_account); - dialogBuilder.setNeutralButton(R.string.cancel, (dialog, id) -> dialog.dismiss()); - alertDialog = dialogBuilder.create(); - alertDialog.show(); - report_video.setOnClickListener(v -> reportAlert(REPORT_VIDEO, alertDialog)); - report_account.setOnClickListener(v -> reportAlert(REPORT_ACCOUNT, alertDialog)); - break; + AlertDialog alertDialog = dialogBuilder.create(); + alertDialog.setTitle(getString(R.string.pickup_captions)); + alertDialog.show(); + } else if (itemId == R.id.action_report) { + AlertDialog alertDialog; + AlertDialog.Builder dialogBuilder; + dialogBuilder = new AlertDialog.Builder(PeertubeActivity.this); + LayoutInflater inflater1 = getLayoutInflater(); + View dialogView = inflater1.inflate(R.layout.popup_report_choice, new LinearLayout(PeertubeActivity.this), false); + dialogBuilder.setView(dialogView); + Button report_video = dialogView.findViewById(R.id.report_video); + Button report_account = dialogView.findViewById(R.id.report_account); + dialogBuilder.setNeutralButton(R.string.cancel, (dialog, id) -> dialog.dismiss()); + alertDialog = dialogBuilder.create(); + alertDialog.show(); + report_video.setOnClickListener(v -> reportAlert(REPORT_VIDEO, alertDialog)); + report_account.setOnClickListener(v -> reportAlert(REPORT_ACCOUNT, alertDialog)); } return true; }); diff --git a/app/src/main/java/app/fedilab/fedilabtube/SepiaSearchActivity.java b/app/src/main/java/app/fedilab/fedilabtube/SepiaSearchActivity.java index 5ff0a53..4443141 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/SepiaSearchActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/SepiaSearchActivity.java @@ -87,68 +87,55 @@ public class SepiaSearchActivity extends AppCompatActivity { }); RadioGroup sepia_element_nsfw = findViewById(R.id.sepia_element_nsfw); - sepia_element_nsfw.setOnCheckedChangeListener((group, checkedId) -> { - if (checkedId == R.id.sepia_element_nsfw_no) { - sepiaSearchVideo.setNsfw(false); - } else { - sepiaSearchVideo.setNsfw(true); - } - }); + sepia_element_nsfw.setOnCheckedChangeListener((group, checkedId) -> sepiaSearchVideo.setNsfw(checkedId != R.id.sepia_element_nsfw_no)); RadioGroup radio_date = findViewById(R.id.radio_date); radio_date.setOnCheckedChangeListener((group, checkedId) -> { - switch(checkedId){ - case R.id.sepia_element_published_date_today: - Calendar cal = GregorianCalendar.getInstance(); - cal.set(Calendar.HOUR_OF_DAY, 0); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MILLISECOND, 0); - sepiaSearchVideo.setStartDate(cal.getTime()); - break; - case R.id.sepia_element_published_date_last_7_days: - cal = GregorianCalendar.getInstance(); - cal.setTime(new Date()); - cal.add(Calendar.DAY_OF_YEAR, -7); - sepiaSearchVideo.setStartDate(cal.getTime()); - break; - case R.id.sepia_element_published_date_last_30_days: - cal = GregorianCalendar.getInstance(); - cal.setTime(new Date()); - cal.add(Calendar.DAY_OF_YEAR, -30); - sepiaSearchVideo.setStartDate(cal.getTime()); - break; - case R.id.sepia_element_published_date_last_365_days: - cal = GregorianCalendar.getInstance(); - cal.setTime(new Date()); - cal.add(Calendar.DAY_OF_YEAR, -365); - sepiaSearchVideo.setStartDate(cal.getTime()); - break; - default: - sepiaSearchVideo.setStartDate(null); + if (checkedId == R.id.sepia_element_published_date_today) { + Calendar cal = GregorianCalendar.getInstance(); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + sepiaSearchVideo.setStartDate(cal.getTime()); + } else if (checkedId == R.id.sepia_element_published_date_last_7_days) { + Calendar cal; + cal = GregorianCalendar.getInstance(); + cal.setTime(new Date()); + cal.add(Calendar.DAY_OF_YEAR, -7); + sepiaSearchVideo.setStartDate(cal.getTime()); + } else if (checkedId == R.id.sepia_element_published_date_last_30_days) { + Calendar cal; + cal = GregorianCalendar.getInstance(); + cal.setTime(new Date()); + cal.add(Calendar.DAY_OF_YEAR, -30); + sepiaSearchVideo.setStartDate(cal.getTime()); + } else if (checkedId == R.id.sepia_element_published_date_last_365_days) { + Calendar cal; + cal = GregorianCalendar.getInstance(); + cal.setTime(new Date()); + cal.add(Calendar.DAY_OF_YEAR, -365); + sepiaSearchVideo.setStartDate(cal.getTime()); + } else { + sepiaSearchVideo.setStartDate(null); } }); RadioGroup duration = findViewById(R.id.duration); duration.setOnCheckedChangeListener((group, checkedId) -> { - switch(checkedId){ - case R.id.sepia_element_duration_short: - sepiaSearchVideo.setDurationMin(0); - sepiaSearchVideo.setDurationMax(240); - break; - case R.id.sepia_element_duration_medium: - sepiaSearchVideo.setDurationMin(240); - sepiaSearchVideo.setDurationMax(600); - break; - case R.id.sepia_element_duration_long: - sepiaSearchVideo.setDurationMin(600); - sepiaSearchVideo.setDurationMax(999999999); - break; - default: - sepiaSearchVideo.setDurationMin(0); - sepiaSearchVideo.setDurationMax(999999999); - break; + if (checkedId == R.id.sepia_element_duration_short) { + sepiaSearchVideo.setDurationMin(0); + sepiaSearchVideo.setDurationMax(240); + } else if (checkedId == R.id.sepia_element_duration_medium) { + sepiaSearchVideo.setDurationMin(240); + sepiaSearchVideo.setDurationMax(600); + } else if (checkedId == R.id.sepia_element_duration_long) { + sepiaSearchVideo.setDurationMin(600); + sepiaSearchVideo.setDurationMax(999999999); + } else { + sepiaSearchVideo.setDurationMin(0); + sepiaSearchVideo.setDurationMax(999999999); } }); diff --git a/app/src/main/java/app/fedilab/fedilabtube/ShowAccountActivity.java b/app/src/main/java/app/fedilab/fedilabtube/ShowAccountActivity.java index 5e0f952..2907d61 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/ShowAccountActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/ShowAccountActivity.java @@ -319,12 +319,11 @@ public class ShowAccountActivity extends AppCompatActivity { account_follow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(ShowAccountActivity.this, R.color.red_1))); } doAction = action.UNFOLLOW; - account_follow.setVisibility(View.VISIBLE); } else { account_follow.setText(R.string.action_follow); doAction = action.FOLLOW; - account_follow.setVisibility(View.VISIBLE); } + account_follow.setVisibility(View.VISIBLE); } diff --git a/app/src/main/java/app/fedilab/fedilabtube/ShowChannelActivity.java b/app/src/main/java/app/fedilab/fedilabtube/ShowChannelActivity.java index 3463a00..ed9a0a7 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/ShowChannelActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/ShowChannelActivity.java @@ -70,9 +70,7 @@ import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.MUTE import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT; import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.UNFOLLOW; import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.DataType.CHANNEL; -import static app.fedilab.fedilabtube.helper.Helper.getLiveInstance; import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn; -import static app.fedilab.fedilabtube.viewmodel.TimelineVM.TimelineType.SEPIA_SEARCH; public class ShowChannelActivity extends AppCompatActivity { @@ -324,12 +322,11 @@ public class ShowChannelActivity extends AppCompatActivity { account_follow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(ShowChannelActivity.this, R.color.red_1))); } doAction = action.UNFOLLOW; - account_follow.setVisibility(View.VISIBLE); } else { account_follow.setText(R.string.action_follow); doAction = action.FOLLOW; - account_follow.setVisibility(View.VISIBLE); } + account_follow.setVisibility(View.VISIBLE); } diff --git a/app/src/main/java/app/fedilab/fedilabtube/WebviewActivity.java b/app/src/main/java/app/fedilab/fedilabtube/WebviewActivity.java index 863cffd..1bac265 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/WebviewActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/WebviewActivity.java @@ -129,21 +129,20 @@ public class WebviewActivity extends AppCompatActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - finish(); - return true; - case R.id.action_go: - Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); - try { - startActivity(browserIntent); - } catch (Exception e) { - Toasty.error(WebviewActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show(); - } - return true; - default: - return super.onOptionsItemSelected(item); + int itemId = item.getItemId(); + if (itemId == android.R.id.home) { + finish(); + return true; + } else if (itemId == R.id.action_go) { + Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + try { + startActivity(browserIntent); + } catch (Exception e) { + Toasty.error(WebviewActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show(); + } + return true; } + return super.onOptionsItemSelected(item); } public void setUrl(String newUrl) { diff --git a/app/src/main/java/app/fedilab/fedilabtube/helper/FullScreenMediaController.java b/app/src/main/java/app/fedilab/fedilabtube/helper/FullScreenMediaController.java index b7569ce..a1440a7 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/helper/FullScreenMediaController.java +++ b/app/src/main/java/app/fedilab/fedilabtube/helper/FullScreenMediaController.java @@ -23,6 +23,8 @@ import android.widget.Button; import android.widget.ImageButton; import android.widget.MediaController; +import androidx.core.content.res.ResourcesCompat; + import app.fedilab.fedilabtube.PeertubeActivity; import app.fedilab.fedilabtube.R; import app.fedilab.fedilabtube.client.data.VideoData.Video; @@ -36,7 +38,7 @@ public class FullScreenMediaController extends MediaController { private ImageButton fullScreen; private Button resolution; - private Context context; + private final Context context; private Video peertube; private String resolutionVal; @@ -85,12 +87,11 @@ public class FullScreenMediaController extends MediaController { if (((PeertubeActivity) getContext()).getFullscreen() == fullscreen.ON) { Resources resources = getResources(); - fullScreen.setImageDrawable(resources.getDrawable(R.drawable.ic_baseline_fullscreen_exit_24)); + fullScreen.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ic_baseline_fullscreen_exit_24, null)); } else { Resources resources = getResources(); - fullScreen.setImageDrawable(resources.getDrawable(R.drawable.ic_baseline_fullscreen_24)); + fullScreen.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ic_baseline_fullscreen_24, null)); } - //add listener to image button to handle full screen and exit full screen events fullScreen.setOnClickListener(v -> { @@ -115,10 +116,10 @@ public class FullScreenMediaController extends MediaController { //fullscreen indicator from intent if (((PeertubeActivity) getContext()).getFullscreen() == fullscreen.ON) { Resources resources = getResources(); - fullScreen.setImageDrawable(resources.getDrawable(R.drawable.ic_baseline_fullscreen_exit_24)); + fullScreen.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ic_baseline_fullscreen_exit_24, null)); } else { Resources resources = getResources(); - fullScreen.setImageDrawable(resources.getDrawable(R.drawable.ic_baseline_fullscreen_24)); + fullScreen.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ic_baseline_fullscreen_24, null)); } } diff --git a/app/src/main/java/app/fedilab/fedilabtube/helper/RoundedBackgroundSpan.java b/app/src/main/java/app/fedilab/fedilabtube/helper/RoundedBackgroundSpan.java index 37a6ae8..898931f 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/helper/RoundedBackgroundSpan.java +++ b/app/src/main/java/app/fedilab/fedilabtube/helper/RoundedBackgroundSpan.java @@ -12,8 +12,8 @@ import app.fedilab.fedilabtube.R; public class RoundedBackgroundSpan extends ReplacementSpan { - private int backgroundColor; - private int textColor; + private final int backgroundColor; + private final int textColor; public RoundedBackgroundSpan(Context context) { super(); diff --git a/app/src/main/java/app/fedilab/fedilabtube/sqlite/AccountDAO.java b/app/src/main/java/app/fedilab/fedilabtube/sqlite/AccountDAO.java index f641ccf..87e0955 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/sqlite/AccountDAO.java +++ b/app/src/main/java/app/fedilab/fedilabtube/sqlite/AccountDAO.java @@ -34,7 +34,7 @@ import app.fedilab.fedilabtube.helper.Helper; public class AccountDAO { public Context context; - private SQLiteDatabase db; + private final SQLiteDatabase db; public AccountDAO(Context context, SQLiteDatabase db) { diff --git a/app/src/main/java/app/fedilab/fedilabtube/viewmodel/SepiaSearchVM.java b/app/src/main/java/app/fedilab/fedilabtube/viewmodel/SepiaSearchVM.java index c27e294..4546651 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/viewmodel/SepiaSearchVM.java +++ b/app/src/main/java/app/fedilab/fedilabtube/viewmodel/SepiaSearchVM.java @@ -15,7 +15,6 @@ package app.fedilab.fedilabtube.viewmodel; * see . */ import android.app.Application; -import android.content.Context; import android.os.Handler; import android.os.Looper; diff --git a/build.gradle b/build.gradle index 4b65010..fe67ac5 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:4.0.2' + classpath 'com.android.tools.build:gradle:4.1.0' def nav_version = "2.3.0" classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version" // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b525760..37213df 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Jun 25 14:34:43 CEST 2020 +#Wed Oct 14 09:54:01 CEST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip