mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 20:57:25 +01:00
Use bottom toolbar in ViewImgurVideoFragment is available.
This commit is contained in:
parent
123898c946
commit
27173031a1
@ -51,8 +51,11 @@ import ml.docilealligator.infinityforreddit.RPANBroadcast;
|
||||
import ml.docilealligator.infinityforreddit.apis.Strapi;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.font.ContentFontFamily;
|
||||
import ml.docilealligator.infinityforreddit.font.ContentFontStyle;
|
||||
import ml.docilealligator.infinityforreddit.font.FontFamily;
|
||||
import ml.docilealligator.infinityforreddit.font.FontStyle;
|
||||
import ml.docilealligator.infinityforreddit.font.TitleFontFamily;
|
||||
import ml.docilealligator.infinityforreddit.font.TitleFontStyle;
|
||||
import ml.docilealligator.infinityforreddit.fragments.ViewRPANBroadcastFragment;
|
||||
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
@ -96,6 +99,15 @@ public class RPANActivity extends AppCompatActivity {
|
||||
|
||||
getTheme().applyStyle(R.style.Theme_Normal, true);
|
||||
|
||||
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences
|
||||
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
|
||||
|
||||
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
|
||||
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
|
||||
|
||||
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
|
||||
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
|
||||
|
||||
getTheme().applyStyle(FontFamily.valueOf(mSharedPreferences
|
||||
.getString(SharedPreferencesUtils.FONT_FAMILY_KEY, FontFamily.Default.name())).getResId(), true);
|
||||
|
||||
|
@ -70,8 +70,11 @@ import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.apis.VReddIt;
|
||||
import ml.docilealligator.infinityforreddit.font.ContentFontFamily;
|
||||
import ml.docilealligator.infinityforreddit.font.ContentFontStyle;
|
||||
import ml.docilealligator.infinityforreddit.font.FontFamily;
|
||||
import ml.docilealligator.infinityforreddit.font.FontStyle;
|
||||
import ml.docilealligator.infinityforreddit.font.TitleFontFamily;
|
||||
import ml.docilealligator.infinityforreddit.font.TitleFontStyle;
|
||||
import ml.docilealligator.infinityforreddit.post.FetchPost;
|
||||
import ml.docilealligator.infinityforreddit.post.Post;
|
||||
import ml.docilealligator.infinityforreddit.services.DownloadMediaService;
|
||||
@ -175,6 +178,15 @@ public class ViewVideoActivity extends AppCompatActivity {
|
||||
|
||||
getTheme().applyStyle(R.style.Theme_Normal, true);
|
||||
|
||||
getTheme().applyStyle(FontStyle.valueOf(mSharedPreferences
|
||||
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
|
||||
|
||||
getTheme().applyStyle(TitleFontStyle.valueOf(mSharedPreferences
|
||||
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
|
||||
|
||||
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
|
||||
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
|
||||
|
||||
getTheme().applyStyle(FontFamily.valueOf(mSharedPreferences
|
||||
.getString(SharedPreferencesUtils.FONT_FAMILY_KEY, FontFamily.Default.name())).getResId(), true);
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package ml.docilealligator.infinityforreddit.fragments;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
@ -18,7 +17,9 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@ -39,6 +40,7 @@ import com.google.android.exoplayer2.ui.PlayerView;
|
||||
import com.google.android.exoplayer2.upstream.DataSource;
|
||||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import com.google.android.material.bottomappbar.BottomAppBar;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
@ -48,6 +50,7 @@ import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.ImgurMedia;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.activities.ViewImgurMediaActivity;
|
||||
import ml.docilealligator.infinityforreddit.services.DownloadMediaService;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
|
||||
@ -61,7 +64,13 @@ public class ViewImgurVideoFragment extends Fragment {
|
||||
PlayerView videoPlayerView;
|
||||
@BindView(R.id.mute_exo_playback_control_view)
|
||||
ImageButton muteButton;
|
||||
private Activity activity;
|
||||
@BindView(R.id.bottom_navigation_exo_playback_control_view)
|
||||
BottomAppBar bottomAppBar;
|
||||
@BindView(R.id.title_text_view_exo_playback_control_view)
|
||||
TextView titleTextView;
|
||||
@BindView(R.id.download_image_view_exo_playback_control_view)
|
||||
ImageView downloadImageView;
|
||||
private ViewImgurMediaActivity activity;
|
||||
private ImgurMedia imgurMedia;
|
||||
private SimpleExoPlayer player;
|
||||
private DataSource.Factory dataSourceFactory;
|
||||
@ -136,6 +145,17 @@ public class ViewImgurVideoFragment extends Fragment {
|
||||
player.prepare(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(imgurMedia.getLink())));
|
||||
preparePlayer(savedInstanceState);
|
||||
|
||||
if (activity.isUseBottomAppBar()) {
|
||||
bottomAppBar.setVisibility(View.VISIBLE);
|
||||
downloadImageView.setOnClickListener(view -> {
|
||||
if (isDownloading) {
|
||||
return;
|
||||
}
|
||||
isDownloading = true;
|
||||
requestPermissionAndDownload();
|
||||
});
|
||||
}
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@ -149,6 +169,13 @@ public class ViewImgurVideoFragment extends Fragment {
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == R.id.action_download_view_imgur_video_fragment) {
|
||||
isDownloading = true;
|
||||
requestPermissionAndDownload();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void requestPermissionAndDownload() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
if (ContextCompat.checkSelfPermission(activity,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
@ -165,9 +192,6 @@ public class ViewImgurVideoFragment extends Fragment {
|
||||
} else {
|
||||
download();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -282,6 +306,6 @@ public class ViewImgurVideoFragment extends Fragment {
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
activity = (Activity) context;
|
||||
activity = (ViewImgurMediaActivity) context;
|
||||
}
|
||||
}
|
||||
|
@ -83,4 +83,44 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.bottomappbar.BottomAppBar
|
||||
android:id="@+id/bottom_navigation_exo_playback_control_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:backgroundTint="#80000000"
|
||||
android:visibility="gone"
|
||||
style="@style/Widget.MaterialComponents.BottomAppBar">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title_text_view_exo_playback_control_view"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="?attr/font_20"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/download_image_view_exo_playback_control_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/ic_file_download_toolbar_white_24dp"
|
||||
android:background="?attr/selectableItemBackgroundBorderless" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.bottomappbar.BottomAppBar>
|
||||
|
||||
</LinearLayout>
|
@ -1,15 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<com.google.android.exoplayer2.ui.PlayerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
tools:context=".fragments.ViewImgurVideoFragment">
|
||||
|
||||
<com.google.android.exoplayer2.ui.PlayerView
|
||||
android:id="@+id/player_view_view_imgur_video_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:controller_layout_id="@layout/exo_playback_control_view"/>
|
||||
|
||||
</RelativeLayout>
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
app:controller_layout_id="@layout/exo_playback_control_view"
|
||||
tools:context=".fragments.ViewImgurVideoFragment" />
|
Loading…
Reference in New Issue
Block a user