diff options
Diffstat (limited to 'app/src')
5 files changed, 110 insertions, 28 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java index 5d2d47f4..d99511ac 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/RPANActivity.java @@ -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); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java index 848cd2d1..f23c2844 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java @@ -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); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java index 1d3e2f51..e2b7ba17 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java @@ -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,25 +169,29 @@ public class ViewImgurVideoFragment extends Fragment { public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == R.id.action_download_view_imgur_video_fragment) { isDownloading = true; - 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) - != PackageManager.PERMISSION_GRANTED) { - - // Permission is not granted - // No explanation needed; request the permission - requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, - PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE); - } else { - // Permission has already been granted - download(); - } + 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) + != PackageManager.PERMISSION_GRANTED) { + + // Permission is not granted + // No explanation needed; request the permission + requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, + PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE); } else { + // Permission has already been granted download(); } - return true; + } else { + download(); } - 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; } } diff --git a/app/src/main/res/layout/exo_playback_control_view.xml b/app/src/main/res/layout/exo_playback_control_view.xml index 17b332ef..b81b5026 100644 --- a/app/src/main/res/layout/exo_playback_control_view.xml +++ b/app/src/main/res/layout/exo_playback_control_view.xml @@ -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>
\ No newline at end of file diff --git a/app/src/main/res/layout/fragment_view_imgur_video.xml b/app/src/main/res/layout/fragment_view_imgur_video.xml index 19331536..824a6b02 100644 --- a/app/src/main/res/layout/fragment_view_imgur_video.xml +++ b/app/src/main/res/layout/fragment_view_imgur_video.xml @@ -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" + android:id="@+id/player_view_view_imgur_video_fragment" 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>
\ No newline at end of file + app:controller_layout_id="@layout/exo_playback_control_view" + tools:context=".fragments.ViewImgurVideoFragment" />
\ No newline at end of file |