Use bottom toolbar in ViewVideoActivity is available.

This commit is contained in:
Alex Ning 2021-08-04 14:15:28 +08:00
parent 085eaa8505
commit 5ecb2b7f14

View File

@ -22,8 +22,10 @@ import android.view.OrientationEventListener;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; 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.CacheDataSourceFactory;
import com.google.android.exoplayer2.upstream.cache.SimpleCache; import com.google.android.exoplayer2.upstream.cache.SimpleCache;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.thefuntasty.hauler.DragDirection; import com.thefuntasty.hauler.DragDirection;
import com.thefuntasty.hauler.HaulerView; import com.thefuntasty.hauler.HaulerView;
@ -123,6 +126,12 @@ public class ViewVideoActivity extends AppCompatActivity {
ImageButton muteButton; ImageButton muteButton;
@BindView(R.id.hd_exo_playback_control_view) @BindView(R.id.hd_exo_playback_control_view)
ImageButton hdButton; 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 Uri mVideoUri;
private SimpleExoPlayer player; private SimpleExoPlayer player;
@ -203,10 +212,29 @@ public class ViewVideoActivity extends AppCompatActivity {
Resources resources = getResources(); Resources resources = getResources();
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(); ActionBar actionBar = getSupportActionBar();
Drawable upArrow = resources.getDrawable(R.drawable.ic_arrow_back_white_24dp); Drawable upArrow = resources.getDrawable(R.drawable.ic_arrow_back_white_24dp);
actionBar.setHomeAsUpIndicator(upArrow); actionBar.setHomeAsUpIndicator(upArrow);
actionBar.setBackgroundDrawable(new ColorDrawable(resources.getColor(R.color.transparentActionBarAndExoPlayerControllerColor))); actionBar.setBackgroundDrawable(new ColorDrawable(resources.getColor(R.color.transparentActionBarAndExoPlayerControllerColor)));
}
String dataSavingModeString = mSharedPreferences.getString(SharedPreferencesUtils.DATA_SAVING_MODE, SharedPreferencesUtils.DATA_SAVING_MODE_OFF); String dataSavingModeString = mSharedPreferences.getString(SharedPreferencesUtils.DATA_SAVING_MODE, SharedPreferencesUtils.DATA_SAVING_MODE_OFF);
int networkType = Utils.getConnectedNetwork(this); int networkType = Utils.getConnectedNetwork(this);
@ -584,6 +612,14 @@ public class ViewVideoActivity extends AppCompatActivity {
} }
isDownloading = true; 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 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
if (ContextCompat.checkSelfPermission(this, if (ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE) Manifest.permission.WRITE_EXTERNAL_STORAGE)
@ -601,10 +637,6 @@ public class ViewVideoActivity extends AppCompatActivity {
} else { } else {
download(); download();
} }
return true;
}
return false;
} }
@Override @Override