diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-08-04 06:15:28 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-08-04 06:15:28 +0000 |
commit | 5ecb2b7f1479d655bc69d45f447d6750096add20 (patch) | |
tree | ad490af84d4c55cf04b001ccd8cf8109b1050e71 /app/src/main | |
parent | 085eaa8505a7ef64c3342219e8a7b7c484e22435 (diff) | |
download | infinity-for-reddit-5ecb2b7f1479d655bc69d45f447d6750096add20.tar infinity-for-reddit-5ecb2b7f1479d655bc69d45f447d6750096add20.tar.gz infinity-for-reddit-5ecb2b7f1479d655bc69d45f447d6750096add20.tar.bz2 infinity-for-reddit-5ecb2b7f1479d655bc69d45f447d6750096add20.tar.lz infinity-for-reddit-5ecb2b7f1479d655bc69d45f447d6750096add20.tar.xz infinity-for-reddit-5ecb2b7f1479d655bc69d45f447d6750096add20.tar.zst infinity-for-reddit-5ecb2b7f1479d655bc69d45f447d6750096add20.zip |
Use bottom toolbar in ViewVideoActivity is available.
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java | 74 |
1 files changed, 53 insertions, 21 deletions
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 f23c2844..0b1da47b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java @@ -22,8 +22,10 @@ import android.view.OrientationEventListener; import android.view.View; import android.view.ViewGroup; import android.widget.ImageButton; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; +import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; @@ -51,6 +53,7 @@ import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory; import com.google.android.exoplayer2.upstream.cache.CacheDataSourceFactory; import com.google.android.exoplayer2.upstream.cache.SimpleCache; import com.google.android.exoplayer2.util.Util; +import com.google.android.material.bottomappbar.BottomAppBar; import com.google.android.material.snackbar.Snackbar; import com.thefuntasty.hauler.DragDirection; import com.thefuntasty.hauler.HaulerView; @@ -123,6 +126,12 @@ public class ViewVideoActivity extends AppCompatActivity { ImageButton muteButton; @BindView(R.id.hd_exo_playback_control_view) ImageButton hdButton; + @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 Uri mVideoUri; private SimpleExoPlayer player; @@ -203,10 +212,29 @@ public class ViewVideoActivity extends AppCompatActivity { Resources resources = getResources(); - ActionBar actionBar = getSupportActionBar(); - Drawable upArrow = resources.getDrawable(R.drawable.ic_arrow_back_white_24dp); - actionBar.setHomeAsUpIndicator(upArrow); - actionBar.setBackgroundDrawable(new ColorDrawable(resources.getColor(R.color.transparentActionBarAndExoPlayerControllerColor))); + boolean useBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_BOTTOM_TOOLBAR_IN_MEDIA_VIEWER, false); + if (useBottomAppBar) { + getSupportActionBar().hide(); + bottomAppBar.setVisibility(View.VISIBLE); + downloadImageView.setOnClickListener(view -> { + if (isDownloading) { + return; + } + + if (videoDownloadUrl == null) { + Toast.makeText(this, R.string.fetching_video_info_please_wait, Toast.LENGTH_SHORT).show(); + return; + } + + isDownloading = true; + requestPermissionAndDownload(); + }); + } else { + ActionBar actionBar = getSupportActionBar(); + Drawable upArrow = resources.getDrawable(R.drawable.ic_arrow_back_white_24dp); + actionBar.setHomeAsUpIndicator(upArrow); + actionBar.setBackgroundDrawable(new ColorDrawable(resources.getColor(R.color.transparentActionBarAndExoPlayerControllerColor))); + } String dataSavingModeString = mSharedPreferences.getString(SharedPreferencesUtils.DATA_SAVING_MODE, SharedPreferencesUtils.DATA_SAVING_MODE_OFF); int networkType = Utils.getConnectedNetwork(this); @@ -584,29 +612,33 @@ public class ViewVideoActivity extends AppCompatActivity { } isDownloading = true; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { - if (ContextCompat.checkSelfPermission(this, - Manifest.permission.WRITE_EXTERNAL_STORAGE) - != PackageManager.PERMISSION_GRANTED) { - - // Permission is not granted - // No explanation needed; request the permission - ActivityCompat.requestPermissions(this, - new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, - PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE); - } else { - // Permission has already been granted - download(); - } - } else { - 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(this, + Manifest.permission.WRITE_EXTERNAL_STORAGE) + != PackageManager.PERMISSION_GRANTED) { + + // Permission is not granted + // No explanation needed; request the permission + ActivityCompat.requestPermissions(this, + new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, + PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE); + } else { + // Permission has already been granted + download(); + } + } else { + download(); + } + } + @Override protected void onStart() { super.onStart(); |