diff --git a/src/org/thoughtcrime/securesms/MediaOverviewActivity.java b/src/org/thoughtcrime/securesms/MediaOverviewActivity.java index 3bb2b6eb77..0b3da4a02e 100644 --- a/src/org/thoughtcrime/securesms/MediaOverviewActivity.java +++ b/src/org/thoughtcrime/securesms/MediaOverviewActivity.java @@ -34,6 +34,7 @@ import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; +import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.view.ActionMode; @@ -136,9 +137,12 @@ public class MediaOverviewActivity extends PassphraseRequiredActionBarActivity { private void initializeToolbar() { setSupportActionBar(this.toolbar); - getSupportActionBar().setTitle(recipient.toShortString()); + ActionBar actionBar = getSupportActionBar(); + actionBar.setTitle(recipient.toShortString()); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setHomeButtonEnabled(true); this.recipient.addListener(recipient -> { - Util.runOnMain(() -> getSupportActionBar().setTitle(recipient.toShortString())); + Util.runOnMain(() -> actionBar.setTitle(recipient.toShortString())); }); } diff --git a/src/org/thoughtcrime/securesms/MediaPreviewActivity.java b/src/org/thoughtcrime/securesms/MediaPreviewActivity.java index 429b39c00e..9db868eba2 100644 --- a/src/org/thoughtcrime/securesms/MediaPreviewActivity.java +++ b/src/org/thoughtcrime/securesms/MediaPreviewActivity.java @@ -19,6 +19,8 @@ package org.thoughtcrime.securesms; import android.annotation.SuppressLint; import android.annotation.TargetApi; +import androidx.appcompat.app.ActionBar; +import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProviders; import android.content.Context; import android.content.Intent; @@ -122,7 +124,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im protected void onCreate(Bundle bundle, boolean ready) { dynamicLanguage.onCreate(this); - viewModel = ViewModelProviders.of(this).get(MediaPreviewViewModel.class); + viewModel = new ViewModelProvider(this).get(MediaPreviewViewModel.class); setContentView(R.layout.media_preview_activity); @@ -224,8 +226,10 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im captionContainer = findViewById(R.id.media_preview_caption_container); playbackControlsContainer = findViewById(R.id.media_preview_playback_controls_container); - setSupportActionBar(findViewById(R.id.toolbar)); + ActionBar actionBar = getSupportActionBar(); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setHomeButtonEnabled(true); } private void initializeResources() { diff --git a/src/org/thoughtcrime/securesms/mediasend/MediaPickerFolderFragment.java b/src/org/thoughtcrime/securesms/mediasend/MediaPickerFolderFragment.java index d492a113d1..0df12eb0a0 100644 --- a/src/org/thoughtcrime/securesms/mediasend/MediaPickerFolderFragment.java +++ b/src/org/thoughtcrime/securesms/mediasend/MediaPickerFolderFragment.java @@ -1,5 +1,7 @@ package org.thoughtcrime.securesms.mediasend; +import androidx.appcompat.app.ActionBar; +import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProviders; import android.content.Context; import android.content.res.Configuration; @@ -53,7 +55,7 @@ public class MediaPickerFolderFragment extends Fragment implements MediaPickerFo public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); recipientName = getArguments().getString(KEY_RECIPIENT_NAME); - viewModel = ViewModelProviders.of(requireActivity(), new MediaSendViewModel.Factory(requireActivity().getApplication(), new MediaRepository())).get(MediaSendViewModel.class); + viewModel = new ViewModelProvider(requireActivity(), new MediaSendViewModel.Factory(requireActivity().getApplication(), new MediaRepository())).get(MediaSendViewModel.class); } @Override @@ -85,7 +87,7 @@ public class MediaPickerFolderFragment extends Fragment implements MediaPickerFo list.setLayoutManager(layoutManager); list.setAdapter(adapter); - viewModel.getFolders(requireContext()).observe(this, adapter::setFolders); + viewModel.getFolders(requireContext()).observe(getViewLifecycleOwner(), adapter::setFolders); initToolbar(view.findViewById(R.id.mediapicker_toolbar)); } @@ -107,7 +109,10 @@ public class MediaPickerFolderFragment extends Fragment implements MediaPickerFo private void initToolbar(Toolbar toolbar) { ((AppCompatActivity) requireActivity()).setSupportActionBar(toolbar); - ((AppCompatActivity) requireActivity()).getSupportActionBar().setTitle(getString(R.string.MediaPickerActivity_send_to, recipientName)); + ActionBar actionBar = ((AppCompatActivity) requireActivity()).getSupportActionBar(); + actionBar.setTitle(getString(R.string.MediaPickerActivity_send_to, recipientName)); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setHomeButtonEnabled(true); toolbar.setNavigationOnClickListener(v -> requireActivity().onBackPressed()); } diff --git a/src/org/thoughtcrime/securesms/mediasend/MediaSendActivity.java b/src/org/thoughtcrime/securesms/mediasend/MediaSendActivity.java index ff1792ec1a..cc8269032d 100644 --- a/src/org/thoughtcrime/securesms/mediasend/MediaSendActivity.java +++ b/src/org/thoughtcrime/securesms/mediasend/MediaSendActivity.java @@ -1,16 +1,10 @@ package org.thoughtcrime.securesms.mediasend; import android.Manifest; - -import androidx.lifecycle.ViewModelProvider; -import androidx.lifecycle.ViewModelProviders; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentManager; import android.view.View; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.AccelerateInterpolator; @@ -21,8 +15,13 @@ import android.view.animation.ScaleAnimation; import android.widget.TextView; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.appcompat.app.ActionBar; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.lifecycle.ViewModelProvider; + import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity; -import network.loki.messenger.R; import org.thoughtcrime.securesms.TransportOption; import org.thoughtcrime.securesms.database.Address; import org.thoughtcrime.securesms.logging.Log; @@ -41,6 +40,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; +import network.loki.messenger.R; + /** * Encompasses the entire flow of sending media, starting from the selection process to the actual * captioning and editing of the content. @@ -124,6 +125,8 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple @Override protected void onCreate(Bundle savedInstanceState, boolean ready) { + super.onCreate(savedInstanceState, ready); + setContentView(R.layout.mediasend_activity); setResult(RESULT_CANCELED);