Code cleaning

This commit is contained in:
Thomas 2020-10-14 10:31:02 +02:00
parent 3e5cefbf24
commit ca69a6e86d
12 changed files with 210 additions and 233 deletions

View File

@ -74,35 +74,30 @@ public class MainActivity extends AppCompatActivity {
private DisplayVideosFragment recentFragment, locaFragment, trendingFragment, subscriptionFragment, mostLikedFragment; private DisplayVideosFragment recentFragment, locaFragment, trendingFragment, subscriptionFragment, mostLikedFragment;
private DisplayOverviewFragment overviewFragment; private DisplayOverviewFragment overviewFragment;
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener private final BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= item -> { = item -> {
DisplayVideosFragment displayVideosFragment = null; DisplayVideosFragment displayVideosFragment = null;
switch (item.getItemId()) { int itemId = item.getItemId();
case R.id.navigation_subscription: if (itemId == R.id.navigation_subscription) {
displayVideosFragment = subscriptionFragment; displayVideosFragment = subscriptionFragment;
setTitle(R.string.subscriptions); setTitle(R.string.subscriptions);
break; } else if (itemId == R.id.navigation_trending) {
case R.id.navigation_trending: setTitle(R.string.title_trending);
setTitle(R.string.title_trending); displayVideosFragment = trendingFragment;
displayVideosFragment = trendingFragment; } else if (itemId == R.id.navigation_most_liked) {
break; setTitle(R.string.title_most_liked);
case R.id.navigation_most_liked: displayVideosFragment = mostLikedFragment;
setTitle(R.string.title_most_liked); } else if (itemId == R.id.navigation_recently_added) {
displayVideosFragment = mostLikedFragment; setTitle(R.string.title_recently_added);
break; displayVideosFragment = recentFragment;
case R.id.navigation_recently_added: } else if (itemId == R.id.navigation_local) {
setTitle(R.string.title_recently_added); setTitle(R.string.title_local);
displayVideosFragment = recentFragment; displayVideosFragment = locaFragment;
break; } else if (itemId == R.id.navigation_discover) {
case R.id.navigation_local: setTitle(R.string.title_discover);
setTitle(R.string.title_local); fm.beginTransaction().hide(active).show(overviewFragment).commit();
displayVideosFragment = locaFragment; active = overviewFragment;
break; return true;
case R.id.navigation_discover:
setTitle(R.string.title_discover);
fm.beginTransaction().hide(active).show(overviewFragment).commit();
active = overviewFragment;
return true;
} }
if (displayVideosFragment != null) { if (displayVideosFragment != null) {
fm.beginTransaction().hide(active).show(displayVideosFragment).commit(); fm.beginTransaction().hide(active).show(displayVideosFragment).commit();

View File

@ -674,147 +674,147 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
popup.getMenu().findItem(R.id.action_captions).setEnabled(false); popup.getMenu().findItem(R.id.action_captions).setEnabled(false);
} }
popup.setOnMenuItemClickListener(item -> { popup.setOnMenuItemClickListener(item -> {
switch (item.getItemId()) { int itemId = item.getItemId();
case R.id.action_download: if (itemId == R.id.action_download) {
if (Build.VERSION.SDK_INT >= 23) { 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) { 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); ActivityCompat.requestPermissions(PeertubeActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, Helper.EXTERNAL_STORAGE_REQUEST_CODE);
} else {
Helper.manageDownloads(PeertubeActivity.this, peertube.getFileDownloadUrl(null));
}
} else { } else {
Helper.manageDownloads(PeertubeActivity.this, peertube.getFileDownloadUrl(null)); Helper.manageDownloads(PeertubeActivity.this, peertube.getFileDownloadUrl(null));
} }
break; } else {
case R.id.action_share: Helper.manageDownloads(PeertubeActivity.this, peertube.getFileDownloadUrl(null));
Intent sendIntent = new Intent(Intent.ACTION_SEND); }
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.shared_via)); } else if (itemId == R.id.action_share) {
String url; 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(); url = peertube.getFiles().get(0).getFileDownloadUrl();
boolean share_details = sharedpreferences.getBoolean(Helper.SET_SHARE_DETAILS, true); boolean share_details = sharedpreferences.getBoolean(Helper.SET_SHARE_DETAILS, true);
String extra_text; String extra_text;
if (share_details) { if (share_details) {
extra_text = "@" + peertube.getAccount().getAcct(); extra_text = "@" + peertube.getAccount().getAcct();
extra_text += "\r\n\r\n" + peertube.getName(); extra_text += "\r\n\r\n" + peertube.getName();
extra_text += "\n\n\uD83D\uDD17 " + url + "\r\n-\n"; extra_text += "\n\n\uD83D\uDD17 " + url + "\r\n-\n";
final String contentToot; final String contentToot;
if (peertube.getDescription() != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
contentToot = Html.fromHtml(peertube.getDescription(), Html.FROM_HTML_MODE_LEGACY).toString(); contentToot = Html.fromHtml(peertube.getDescription(), Html.FROM_HTML_MODE_LEGACY).toString();
else else
contentToot = Html.fromHtml(peertube.getDescription()).toString(); contentToot = Html.fromHtml(peertube.getDescription()).toString();
extra_text += contentToot;
} else { } else {
extra_text = url; contentToot = "";
}
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;
} }
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[] itemsKeyLanguage = new String[captions.size() + 1];
String[] itemsLabelLanguage = new String[captions.size() + 1]; String[] itemsLabelLanguage = new String[captions.size() + 1];
itemsLabelLanguage[0] = getString(R.string.none); itemsLabelLanguage[0] = getString(R.string.none);
itemsKeyLanguage[0] = "null"; itemsKeyLanguage[0] = "null";
int i = 1; int i = 1;
if (captions.size() > 0) { if (captions.size() > 0) {
for (Caption caption : captions) { for (Caption caption : captions) {
ItemStr lang = caption.getLanguage(); ItemStr lang = caption.getLanguage();
itemsLabelLanguage[i] = lang.getLabel(); itemsLabelLanguage[i] = lang.getLabel();
itemsKeyLanguage[i] = lang.getId(); itemsKeyLanguage[i] = lang.getId();
i++; 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; int video_cache = sharedpreferences.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB);
if (which > 0) {
if( !sepiaSearch) { long position = player.getCurrentPosition();
uri = Uri.parse("https://" + getLiveInstance(PeertubeActivity.this) + captions.get(which - 1).getCaptionPath());
}else{ if (player != null)
uri = Uri.parse("https://" + peertubeInstance + captions.get(which - 1).getCaptionPath()); 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);
int video_cache = sharedpreferences.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB); if (which > 0 && subtitleSource != null) {
MergingMediaSource mergedSource =
long position = player.getCurrentPosition(); new MergingMediaSource(videoSource, subtitleSource);
player.prepare(mergedSource);
if (player != null) } else {
player.release(); player.prepare(videoSource);
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);
} }
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 alertDialog = dialogBuilder.create();
alertDialog.setTitle(getString(R.string.pickup_captions)); alertDialog.setTitle(getString(R.string.pickup_captions));
alertDialog.show(); alertDialog.show();
} else if (itemId == R.id.action_report) {
break; AlertDialog alertDialog;
AlertDialog.Builder dialogBuilder;
case R.id.action_report: dialogBuilder = new AlertDialog.Builder(PeertubeActivity.this);
dialogBuilder = new androidx.appcompat.app.AlertDialog.Builder(PeertubeActivity.this); LayoutInflater inflater1 = getLayoutInflater();
LayoutInflater inflater1 = getLayoutInflater(); View dialogView = inflater1.inflate(R.layout.popup_report_choice, new LinearLayout(PeertubeActivity.this), false);
View dialogView = inflater1.inflate(R.layout.popup_report_choice, new LinearLayout(PeertubeActivity.this), false); dialogBuilder.setView(dialogView);
dialogBuilder.setView(dialogView); Button report_video = dialogView.findViewById(R.id.report_video);
Button report_video = dialogView.findViewById(R.id.report_video); Button report_account = dialogView.findViewById(R.id.report_account);
Button report_account = dialogView.findViewById(R.id.report_account); dialogBuilder.setNeutralButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
dialogBuilder.setNeutralButton(R.string.cancel, (dialog, id) -> dialog.dismiss()); alertDialog = dialogBuilder.create();
alertDialog = dialogBuilder.create(); alertDialog.show();
alertDialog.show(); report_video.setOnClickListener(v -> reportAlert(REPORT_VIDEO, alertDialog));
report_video.setOnClickListener(v -> reportAlert(REPORT_VIDEO, alertDialog)); report_account.setOnClickListener(v -> reportAlert(REPORT_ACCOUNT, alertDialog));
report_account.setOnClickListener(v -> reportAlert(REPORT_ACCOUNT, alertDialog));
break;
} }
return true; return true;
}); });

View File

@ -87,68 +87,55 @@ public class SepiaSearchActivity extends AppCompatActivity {
}); });
RadioGroup sepia_element_nsfw = findViewById(R.id.sepia_element_nsfw); RadioGroup sepia_element_nsfw = findViewById(R.id.sepia_element_nsfw);
sepia_element_nsfw.setOnCheckedChangeListener((group, checkedId) -> { sepia_element_nsfw.setOnCheckedChangeListener((group, checkedId) -> sepiaSearchVideo.setNsfw(checkedId != R.id.sepia_element_nsfw_no));
if (checkedId == R.id.sepia_element_nsfw_no) {
sepiaSearchVideo.setNsfw(false);
} else {
sepiaSearchVideo.setNsfw(true);
}
});
RadioGroup radio_date = findViewById(R.id.radio_date); RadioGroup radio_date = findViewById(R.id.radio_date);
radio_date.setOnCheckedChangeListener((group, checkedId) -> { radio_date.setOnCheckedChangeListener((group, checkedId) -> {
switch(checkedId){ if (checkedId == R.id.sepia_element_published_date_today) {
case R.id.sepia_element_published_date_today: Calendar cal = GregorianCalendar.getInstance();
Calendar cal = GregorianCalendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0);
cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0);
cal.set(Calendar.MILLISECOND, 0); sepiaSearchVideo.setStartDate(cal.getTime());
sepiaSearchVideo.setStartDate(cal.getTime()); } else if (checkedId == R.id.sepia_element_published_date_last_7_days) {
break; Calendar cal;
case R.id.sepia_element_published_date_last_7_days: cal = GregorianCalendar.getInstance();
cal = GregorianCalendar.getInstance(); cal.setTime(new Date());
cal.setTime(new Date()); cal.add(Calendar.DAY_OF_YEAR, -7);
cal.add(Calendar.DAY_OF_YEAR, -7); sepiaSearchVideo.setStartDate(cal.getTime());
sepiaSearchVideo.setStartDate(cal.getTime()); } else if (checkedId == R.id.sepia_element_published_date_last_30_days) {
break; Calendar cal;
case R.id.sepia_element_published_date_last_30_days: cal = GregorianCalendar.getInstance();
cal = GregorianCalendar.getInstance(); cal.setTime(new Date());
cal.setTime(new Date()); cal.add(Calendar.DAY_OF_YEAR, -30);
cal.add(Calendar.DAY_OF_YEAR, -30); sepiaSearchVideo.setStartDate(cal.getTime());
sepiaSearchVideo.setStartDate(cal.getTime()); } else if (checkedId == R.id.sepia_element_published_date_last_365_days) {
break; Calendar cal;
case R.id.sepia_element_published_date_last_365_days: cal = GregorianCalendar.getInstance();
cal = GregorianCalendar.getInstance(); cal.setTime(new Date());
cal.setTime(new Date()); cal.add(Calendar.DAY_OF_YEAR, -365);
cal.add(Calendar.DAY_OF_YEAR, -365); sepiaSearchVideo.setStartDate(cal.getTime());
sepiaSearchVideo.setStartDate(cal.getTime()); } else {
break; sepiaSearchVideo.setStartDate(null);
default:
sepiaSearchVideo.setStartDate(null);
} }
}); });
RadioGroup duration = findViewById(R.id.duration); RadioGroup duration = findViewById(R.id.duration);
duration.setOnCheckedChangeListener((group, checkedId) -> { duration.setOnCheckedChangeListener((group, checkedId) -> {
switch(checkedId){ if (checkedId == R.id.sepia_element_duration_short) {
case R.id.sepia_element_duration_short: sepiaSearchVideo.setDurationMin(0);
sepiaSearchVideo.setDurationMin(0); sepiaSearchVideo.setDurationMax(240);
sepiaSearchVideo.setDurationMax(240); } else if (checkedId == R.id.sepia_element_duration_medium) {
break; sepiaSearchVideo.setDurationMin(240);
case R.id.sepia_element_duration_medium: sepiaSearchVideo.setDurationMax(600);
sepiaSearchVideo.setDurationMin(240); } else if (checkedId == R.id.sepia_element_duration_long) {
sepiaSearchVideo.setDurationMax(600); sepiaSearchVideo.setDurationMin(600);
break; sepiaSearchVideo.setDurationMax(999999999);
case R.id.sepia_element_duration_long: } else {
sepiaSearchVideo.setDurationMin(600); sepiaSearchVideo.setDurationMin(0);
sepiaSearchVideo.setDurationMax(999999999); sepiaSearchVideo.setDurationMax(999999999);
break;
default:
sepiaSearchVideo.setDurationMin(0);
sepiaSearchVideo.setDurationMax(999999999);
break;
} }
}); });

View File

@ -319,12 +319,11 @@ public class ShowAccountActivity extends AppCompatActivity {
account_follow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(ShowAccountActivity.this, R.color.red_1))); account_follow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(ShowAccountActivity.this, R.color.red_1)));
} }
doAction = action.UNFOLLOW; doAction = action.UNFOLLOW;
account_follow.setVisibility(View.VISIBLE);
} else { } else {
account_follow.setText(R.string.action_follow); account_follow.setText(R.string.action_follow);
doAction = action.FOLLOW; doAction = action.FOLLOW;
account_follow.setVisibility(View.VISIBLE);
} }
account_follow.setVisibility(View.VISIBLE);
} }

View File

@ -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.REPORT_ACCOUNT;
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.UNFOLLOW; import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.UNFOLLOW;
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.DataType.CHANNEL; 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.helper.Helper.isLoggedIn;
import static app.fedilab.fedilabtube.viewmodel.TimelineVM.TimelineType.SEPIA_SEARCH;
public class ShowChannelActivity extends AppCompatActivity { 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))); account_follow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(ShowChannelActivity.this, R.color.red_1)));
} }
doAction = action.UNFOLLOW; doAction = action.UNFOLLOW;
account_follow.setVisibility(View.VISIBLE);
} else { } else {
account_follow.setText(R.string.action_follow); account_follow.setText(R.string.action_follow);
doAction = action.FOLLOW; doAction = action.FOLLOW;
account_follow.setVisibility(View.VISIBLE);
} }
account_follow.setVisibility(View.VISIBLE);
} }

View File

@ -129,21 +129,20 @@ public class WebviewActivity extends AppCompatActivity {
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { int itemId = item.getItemId();
case android.R.id.home: if (itemId == android.R.id.home) {
finish(); finish();
return true; return true;
case R.id.action_go: } else if (itemId == R.id.action_go) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
try { try {
startActivity(browserIntent); startActivity(browserIntent);
} catch (Exception e) { } catch (Exception e) {
Toasty.error(WebviewActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Toasty.error(WebviewActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
} }
return true; return true;
default:
return super.onOptionsItemSelected(item);
} }
return super.onOptionsItemSelected(item);
} }
public void setUrl(String newUrl) { public void setUrl(String newUrl) {

View File

@ -23,6 +23,8 @@ import android.widget.Button;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.MediaController; import android.widget.MediaController;
import androidx.core.content.res.ResourcesCompat;
import app.fedilab.fedilabtube.PeertubeActivity; import app.fedilab.fedilabtube.PeertubeActivity;
import app.fedilab.fedilabtube.R; import app.fedilab.fedilabtube.R;
import app.fedilab.fedilabtube.client.data.VideoData.Video; import app.fedilab.fedilabtube.client.data.VideoData.Video;
@ -36,7 +38,7 @@ public class FullScreenMediaController extends MediaController {
private ImageButton fullScreen; private ImageButton fullScreen;
private Button resolution; private Button resolution;
private Context context; private final Context context;
private Video peertube; private Video peertube;
private String resolutionVal; private String resolutionVal;
@ -85,12 +87,11 @@ public class FullScreenMediaController extends MediaController {
if (((PeertubeActivity) getContext()).getFullscreen() == fullscreen.ON) { if (((PeertubeActivity) getContext()).getFullscreen() == fullscreen.ON) {
Resources resources = getResources(); 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 { } else {
Resources resources = getResources(); 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 //add listener to image button to handle full screen and exit full screen events
fullScreen.setOnClickListener(v -> { fullScreen.setOnClickListener(v -> {
@ -115,10 +116,10 @@ public class FullScreenMediaController extends MediaController {
//fullscreen indicator from intent //fullscreen indicator from intent
if (((PeertubeActivity) getContext()).getFullscreen() == fullscreen.ON) { if (((PeertubeActivity) getContext()).getFullscreen() == fullscreen.ON) {
Resources resources = getResources(); 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 { } else {
Resources resources = getResources(); 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));
} }
} }

View File

@ -12,8 +12,8 @@ import app.fedilab.fedilabtube.R;
public class RoundedBackgroundSpan extends ReplacementSpan { public class RoundedBackgroundSpan extends ReplacementSpan {
private int backgroundColor; private final int backgroundColor;
private int textColor; private final int textColor;
public RoundedBackgroundSpan(Context context) { public RoundedBackgroundSpan(Context context) {
super(); super();

View File

@ -34,7 +34,7 @@ import app.fedilab.fedilabtube.helper.Helper;
public class AccountDAO { public class AccountDAO {
public Context context; public Context context;
private SQLiteDatabase db; private final SQLiteDatabase db;
public AccountDAO(Context context, SQLiteDatabase db) { public AccountDAO(Context context, SQLiteDatabase db) {

View File

@ -15,7 +15,6 @@ package app.fedilab.fedilabtube.viewmodel;
* see <http://www.gnu.org/licenses>. */ * see <http://www.gnu.org/licenses>. */
import android.app.Application; import android.app.Application;
import android.content.Context;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;

View File

@ -5,7 +5,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { 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" def nav_version = "2.3.0"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version" classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong

View File

@ -1,6 +1,6 @@
#Thu Jun 25 14:34:43 CEST 2020 #Wed Oct 14 09:54:01 CEST 2020
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists 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