[Bugfix] : avoid going to pip when leaving the app due to share button
This commit is contained in:
parent
95353ca673
commit
43b7b6ee0a
@ -351,11 +351,17 @@ public class VideoPlayActivity extends AppCompatActivity {
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment);
|
||||
VideoMetaDataFragment videoMetaDataFragment = (VideoMetaDataFragment) fragmentManager.findFragmentById(R.id.video_meta_data_fragment);
|
||||
|
||||
String backgroundBehavior = sharedPref.getString(getString(R.string.pref_background_behavior_key), getString(R.string.pref_background_stop_key));
|
||||
|
||||
assert videoPlayerFragment != null;
|
||||
assert backgroundBehavior != null;
|
||||
if ( videoMetaDataFragment.isLeaveAppExpected() )
|
||||
{
|
||||
super.onUserLeaveHint();
|
||||
return;
|
||||
}
|
||||
|
||||
if (backgroundBehavior.equals(getString(R.string.pref_background_stop_key))) {
|
||||
Log.v(TAG, "stop the video");
|
||||
|
@ -72,6 +72,8 @@ public class VideoMetaDataFragment extends Fragment {
|
||||
private Rating videoRating;
|
||||
private ColorStateList defaultTextColor;
|
||||
|
||||
private boolean leaveAppExpected = false;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
@ -80,6 +82,18 @@ public class VideoMetaDataFragment extends Fragment {
|
||||
return inflater.inflate(R.layout.fragment_video_meta, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause()
|
||||
{
|
||||
leaveAppExpected = false;
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
public boolean isLeaveAppExpected()
|
||||
{
|
||||
return leaveAppExpected;
|
||||
}
|
||||
|
||||
public void updateVideoMeta(Video video, VideoPlayerService mService) {
|
||||
Context context = getContext();
|
||||
Activity activity = getActivity();
|
||||
@ -131,7 +145,11 @@ public class VideoMetaDataFragment extends Fragment {
|
||||
Button videoShareButton = activity.findViewById(R.id.video_share);
|
||||
videoShareButton.setText(R.string.video_share_icon);
|
||||
new Iconics.IconicsBuilder().ctx(context).on(videoShareButton).build();
|
||||
videoShareButton.setOnClickListener(v -> Intents.Share(context, video));
|
||||
videoShareButton.setOnClickListener(v ->
|
||||
{
|
||||
leaveAppExpected = true;
|
||||
Intents.Share( context, video );
|
||||
} );
|
||||
|
||||
// Download
|
||||
Button videoDownloadButton = activity.findViewById(R.id.video_download);
|
||||
@ -140,6 +158,7 @@ public class VideoMetaDataFragment extends Fragment {
|
||||
videoDownloadButton.setOnClickListener(v -> {
|
||||
// get permission to store file
|
||||
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
leaveAppExpected = true;
|
||||
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
|
||||
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
Intents.Download(context, video);
|
||||
|
Loading…
Reference in New Issue
Block a user