mirror of
https://github.com/thunderbird/thunderbird-android.git
synced 2024-09-20 12:12:15 +02:00
Update AndroidX Fragment to 1.2.1
This commit is contained in:
parent
0f807bb741
commit
9e06676d33
@ -2,11 +2,11 @@ package com.fsck.k9.ui.addaccount
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.ui.AppBarConfiguration
|
||||
import androidx.navigation.ui.setupActionBarWithNavController
|
||||
import com.fsck.k9.activity.K9Activity
|
||||
import com.fsck.k9.jmap.R
|
||||
import com.fsck.k9.ui.findNavController
|
||||
|
||||
class AddAccountActivity : K9Activity() {
|
||||
private lateinit var navController: NavController
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
<include layout="@layout/toolbar" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/nav_host_fragment"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -14,6 +14,7 @@ import android.content.res.TypedArray;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentManager.OnBackStackChangedListener;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
@ -21,11 +22,9 @@ import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
@ -59,6 +58,7 @@ import com.fsck.k9.ui.managefolders.ManageFoldersActivity;
|
||||
import com.fsck.k9.ui.messagelist.DefaultFolderProvider;
|
||||
import com.fsck.k9.ui.messageview.MessageViewFragment;
|
||||
import com.fsck.k9.ui.messageview.MessageViewFragment.MessageViewFragmentListener;
|
||||
import com.fsck.k9.ui.messageview.PlaceholderFragment;
|
||||
import com.fsck.k9.ui.onboarding.OnboardingActivity;
|
||||
import com.fsck.k9.view.ViewSwitcher;
|
||||
import com.fsck.k9.view.ViewSwitcher.OnSwitchCompleteListener;
|
||||
@ -91,6 +91,9 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
|
||||
private static final String STATE_MESSAGE_LIST_WAS_DISPLAYED = "messageListWasDisplayed";
|
||||
private static final String STATE_FIRST_BACK_STACK_ID = "firstBackstackId";
|
||||
|
||||
private static final String FRAGMENT_TAG_MESSAGE_VIEW = "MessageViewFragment";
|
||||
private static final String FRAGMENT_TAG_PLACEHOLDER = "MessageViewPlaceholder";
|
||||
|
||||
// Used for navigating to next/previous message
|
||||
private static final int PREVIOUS = 1;
|
||||
private static final int NEXT = 2;
|
||||
@ -183,8 +186,7 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
|
||||
private Menu menu;
|
||||
|
||||
private ProgressBar progressBar;
|
||||
private ViewGroup messageViewContainer;
|
||||
private View messageViewPlaceHolder;
|
||||
private PlaceholderFragment messageViewPlaceHolder;
|
||||
|
||||
private MessageListFragment messageListFragment;
|
||||
private MessageViewFragment messageViewFragment;
|
||||
@ -311,7 +313,7 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
|
||||
private void findFragments() {
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
messageListFragment = (MessageListFragment) fragmentManager.findFragmentById(R.id.message_list_container);
|
||||
messageViewFragment = (MessageViewFragment) fragmentManager.findFragmentById(R.id.message_view_container);
|
||||
messageViewFragment = (MessageViewFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG_MESSAGE_VIEW);
|
||||
|
||||
if (messageListFragment != null) {
|
||||
initializeFromLocalSearch(messageListFragment.getLocalSearch());
|
||||
@ -390,10 +392,7 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
|
||||
|
||||
private void initializeLayout() {
|
||||
progressBar = findViewById(R.id.message_list_progress);
|
||||
messageViewContainer = findViewById(R.id.message_view_container);
|
||||
|
||||
LayoutInflater layoutInflater = getLayoutInflater();
|
||||
messageViewPlaceHolder = layoutInflater.inflate(R.layout.empty_message_view, messageViewContainer, false);
|
||||
messageViewPlaceHolder = new PlaceholderFragment();
|
||||
}
|
||||
|
||||
private void displayViews() {
|
||||
@ -1216,17 +1215,15 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
|
||||
if (folderServerId.equals(account.getDraftsFolder())) {
|
||||
MessageActions.actionEditDraft(this, messageReference);
|
||||
} else {
|
||||
messageViewContainer.removeView(messageViewPlaceHolder);
|
||||
|
||||
if (messageListFragment != null) {
|
||||
messageListFragment.setActiveMessage(messageReference);
|
||||
}
|
||||
|
||||
MessageViewFragment fragment = MessageViewFragment.newInstance(messageReference);
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
ft.replace(R.id.message_view_container, fragment);
|
||||
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
||||
fragmentTransaction.replace(R.id.message_view_container, fragment, FRAGMENT_TAG_MESSAGE_VIEW);
|
||||
fragmentTransaction.commit();
|
||||
messageViewFragment = fragment;
|
||||
ft.commit();
|
||||
|
||||
if (displayMode != DisplayMode.SPLIT_VIEW) {
|
||||
showMessageView();
|
||||
@ -1383,9 +1380,12 @@ public class MessageList extends K9Activity implements MessageListFragmentListen
|
||||
private void showMessageViewPlaceHolder() {
|
||||
removeMessageViewFragment();
|
||||
|
||||
// Add placeholder view if necessary
|
||||
if (messageViewPlaceHolder.getParent() == null) {
|
||||
messageViewContainer.addView(messageViewPlaceHolder);
|
||||
// Add placeholder fragment if necessary
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
if (fragmentManager.findFragmentByTag(FRAGMENT_TAG_PLACEHOLDER) == null) {
|
||||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
||||
fragmentTransaction.replace(R.id.message_view_container, messageViewPlaceHolder, FRAGMENT_TAG_PLACEHOLDER);
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
|
||||
messageListFragment.setActiveMessage(null);
|
||||
|
@ -881,7 +881,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
|
||||
}
|
||||
|
||||
fragment.setTargetFragment(this, dialogId);
|
||||
fragment.show(getFragmentManager(), getDialogTag(dialogId));
|
||||
fragment.show(getParentFragmentManager(), getDialogTag(dialogId));
|
||||
}
|
||||
|
||||
private String getDialogTag(int dialogId) {
|
||||
|
11
app/ui/src/main/java/com/fsck/k9/ui/NavigationExtensions.kt
Normal file
11
app/ui/src/main/java/com/fsck/k9/ui/NavigationExtensions.kt
Normal file
@ -0,0 +1,11 @@
|
||||
package com.fsck.k9.ui
|
||||
|
||||
import androidx.annotation.IdRes
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
|
||||
fun FragmentActivity.findNavController(@IdRes containerIdRes: Int): NavController {
|
||||
val navHostFragment = supportFragmentManager.findFragmentById(containerIdRes) as NavHostFragment
|
||||
return navHostFragment.navController
|
||||
}
|
@ -138,7 +138,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
||||
downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
messageCryptoPresenter = new MessageCryptoPresenter(messageCryptoMvpView);
|
||||
messageLoaderHelper = messageLoaderHelperFactory.createForMessageView(
|
||||
context, getLoaderManager(), getFragmentManager(), messageLoaderCallbacks);
|
||||
context, getLoaderManager(), getParentFragmentManager(), messageLoaderCallbacks);
|
||||
mInitialized = true;
|
||||
}
|
||||
|
||||
@ -542,16 +542,16 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
||||
}
|
||||
|
||||
fragment.setTargetFragment(this, dialogId);
|
||||
fragment.show(getFragmentManager(), getDialogTag(dialogId));
|
||||
fragment.show(getParentFragmentManager(), getDialogTag(dialogId));
|
||||
}
|
||||
|
||||
private void removeDialog(int dialogId) {
|
||||
FragmentManager fm = getFragmentManager();
|
||||
|
||||
if (fm == null || isRemoving() || isDetached()) {
|
||||
if (!isAdded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
FragmentManager fm = getParentFragmentManager();
|
||||
|
||||
// Make sure the "show dialog" transaction has been processed when we call
|
||||
// findFragmentByTag() below. Otherwise the fragment won't be found and the dialog will
|
||||
// never be dismissed.
|
||||
@ -679,7 +679,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
||||
public void showCryptoInfoDialog(MessageCryptoDisplayStatus displayStatus, boolean hasSecurityWarning) {
|
||||
CryptoInfoDialog dialog = CryptoInfoDialog.newInstance(displayStatus, hasSecurityWarning);
|
||||
dialog.setTargetFragment(MessageViewFragment.this, 0);
|
||||
dialog.show(getFragmentManager(), "crypto_info_dialog");
|
||||
dialog.show(getParentFragmentManager(), "crypto_info_dialog");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,14 @@
|
||||
package com.fsck.k9.ui.messageview
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.fsck.k9.ui.R
|
||||
|
||||
class PlaceholderFragment : Fragment() {
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.empty_message_view, container, false)
|
||||
}
|
||||
}
|
@ -4,11 +4,11 @@ import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.ui.AppBarConfiguration
|
||||
import androidx.navigation.ui.setupActionBarWithNavController
|
||||
import com.fsck.k9.activity.K9Activity
|
||||
import com.fsck.k9.ui.R
|
||||
import com.fsck.k9.ui.findNavController
|
||||
|
||||
class OnboardingActivity : K9Activity() {
|
||||
private lateinit var navController: NavController
|
||||
|
@ -4,11 +4,11 @@ import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.ui.AppBarConfiguration
|
||||
import androidx.navigation.ui.setupActionBarWithNavController
|
||||
import com.fsck.k9.activity.K9Activity
|
||||
import com.fsck.k9.ui.R
|
||||
import com.fsck.k9.ui.findNavController
|
||||
|
||||
class SettingsActivity : K9Activity() {
|
||||
private lateinit var navController: NavController
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
<FrameLayout
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/accountSettingsContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dip"
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
<include layout="@layout/toolbar" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/nav_host_fragment"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
<include layout="@layout/toolbar" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/nav_host_fragment"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
<include layout="@layout/toolbar" />
|
||||
|
||||
<FrameLayout
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/generalSettingsContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dip"
|
||||
|
@ -25,12 +25,12 @@
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1">
|
||||
|
||||
<FrameLayout
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/message_list_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
|
||||
<FrameLayout
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/message_view_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
|
@ -28,7 +28,7 @@
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<FrameLayout
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/message_list_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
@ -41,7 +41,7 @@
|
||||
android:background="?attr/messageListDividerColor"
|
||||
tools:ignore="PxUsage"/>
|
||||
|
||||
<FrameLayout
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/message_view_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
|
@ -17,7 +17,7 @@ buildscript {
|
||||
'androidxNavigation': '2.2.1',
|
||||
'androidxConstraintLayout': '1.1.3',
|
||||
'androidxWorkManager': '2.3.1',
|
||||
'androidxFragment': '1.1.0',
|
||||
'androidxFragment': '1.2.1',
|
||||
'androidxLocalBroadcastManager': '1.0.0',
|
||||
'materialComponents': '1.1.0-rc02',
|
||||
'coreKtx': '1.1.0',
|
||||
|
Loading…
Reference in New Issue
Block a user