Messaging: Remove setHost() logic
* This relies too much on call order and other things to go right * We can use the activity just fine for it Fixes: https://gitlab.com/LineageOS/issues/android/-/issues/8623 Change-Id: I048910258cedaa21e26fb88a57e5028ae1df9f83
This commit is contained in:
@@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
Copyright (C) 2015 The Android Open Source Project
|
|
||||||
Copyright (C) 2025 The LineageOS Project
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-->
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:name="com.android.messaging.ui.conversationlist.ConversationListFragment"
|
|
||||||
android:id="@+id/conversation_list_fragment"
|
|
||||||
android:theme="@style/Theme.MaterialComponents.Light.DarkActionBar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent" />
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 The Android Open Source Project
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
* Copyright (C) 2024 The LineageOS Project
|
* Copyright (C) 2024-2025 The LineageOS Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -20,25 +20,22 @@ import android.graphics.drawable.ColorDrawable;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.fragment.app.FragmentManager;
|
|
||||||
import androidx.fragment.app.FragmentOnAttachListener;
|
|
||||||
|
|
||||||
import com.android.messaging.R;
|
import com.android.messaging.R;
|
||||||
|
|
||||||
public class ArchivedConversationListActivity extends AbstractConversationListActivity
|
public class ArchivedConversationListActivity extends AbstractConversationListActivity {
|
||||||
implements FragmentOnAttachListener {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(final Bundle savedInstanceState) {
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
final ConversationListFragment fragment =
|
mConversationListFragment =
|
||||||
ConversationListFragment.createArchivedConversationListFragment();
|
ConversationListFragment.createArchivedConversationListFragment();
|
||||||
getSupportFragmentManager().addFragmentOnAttachListener(this);
|
getSupportFragmentManager()
|
||||||
getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
|
.beginTransaction()
|
||||||
|
.add(android.R.id.content, mConversationListFragment)
|
||||||
|
.commit();
|
||||||
invalidateActionBar();
|
invalidateActionBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,13 +77,4 @@ public class ArchivedConversationListActivity extends AbstractConversationListAc
|
|||||||
public boolean isSwipeAnimatable() {
|
public boolean isSwipeAnimatable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttachFragment(@NonNull FragmentManager fragmentManager,
|
|
||||||
@NonNull Fragment fragment) {
|
|
||||||
if (fragment instanceof ConversationListFragment) {
|
|
||||||
mConversationListFragment = (ConversationListFragment) fragment;
|
|
||||||
mConversationListFragment.setHost(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 The Android Open Source Project
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
* Copyright (C) 2024 The LineageOS Project
|
* Copyright (C) 2024-2025 The LineageOS Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -24,22 +24,23 @@ import android.view.MenuItem;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.fragment.app.FragmentManager;
|
|
||||||
import androidx.fragment.app.FragmentOnAttachListener;
|
|
||||||
|
|
||||||
import com.android.messaging.R;
|
import com.android.messaging.R;
|
||||||
import com.android.messaging.ui.UIIntents;
|
import com.android.messaging.ui.UIIntents;
|
||||||
import com.android.messaging.util.Trace;
|
import com.android.messaging.util.Trace;
|
||||||
|
|
||||||
public class ConversationListActivity extends AbstractConversationListActivity implements FragmentOnAttachListener {
|
public class ConversationListActivity extends AbstractConversationListActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(final Bundle savedInstanceState) {
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
Trace.beginSection("ConversationListActivity.onCreate");
|
Trace.beginSection("ConversationListActivity.onCreate");
|
||||||
setTheme(R.style.BugleTheme_ConversationListActivity);
|
setTheme(R.style.BugleTheme_ConversationListActivity);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
getSupportFragmentManager().addFragmentOnAttachListener(this);
|
mConversationListFragment = ConversationListFragment.createConversationListFragment(null);
|
||||||
setContentView(R.layout.conversation_list_activity);
|
getSupportFragmentManager()
|
||||||
|
.beginTransaction()
|
||||||
|
.add(android.R.id.content, mConversationListFragment)
|
||||||
|
.commit();
|
||||||
Trace.endSection();
|
Trace.endSection();
|
||||||
invalidateActionBar();
|
invalidateActionBar();
|
||||||
}
|
}
|
||||||
@@ -131,22 +132,10 @@ public class ConversationListActivity extends AbstractConversationListActivity i
|
|||||||
@Override
|
@Override
|
||||||
public void onWindowFocusChanged(final boolean hasFocus) {
|
public void onWindowFocusChanged(final boolean hasFocus) {
|
||||||
super.onWindowFocusChanged(hasFocus);
|
super.onWindowFocusChanged(hasFocus);
|
||||||
final ConversationListFragment conversationListFragment =
|
|
||||||
(ConversationListFragment) getSupportFragmentManager().findFragmentById(
|
|
||||||
R.id.conversation_list_fragment);
|
|
||||||
// When the screen is turned on, the last used activity gets resumed, but it gets
|
// When the screen is turned on, the last used activity gets resumed, but it gets
|
||||||
// window focus only after the lock screen is unlocked.
|
// window focus only after the lock screen is unlocked.
|
||||||
if (hasFocus && conversationListFragment != null) {
|
if (hasFocus && mConversationListFragment != null) {
|
||||||
conversationListFragment.setScrolledToNewestConversationIfNeeded();
|
mConversationListFragment.setScrolledToNewestConversationIfNeeded();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttachFragment(@NonNull FragmentManager fragmentManager,
|
|
||||||
@NonNull Fragment fragment) {
|
|
||||||
if (fragment instanceof ConversationListFragment) {
|
|
||||||
mConversationListFragment = (ConversationListFragment) fragment;
|
|
||||||
mConversationListFragment.setHost(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ import com.android.messaging.ui.ListEmptyView;
|
|||||||
import com.android.messaging.ui.SnackBarInteraction;
|
import com.android.messaging.ui.SnackBarInteraction;
|
||||||
import com.android.messaging.ui.UIIntents;
|
import com.android.messaging.ui.UIIntents;
|
||||||
import com.android.messaging.util.AccessibilityUtil;
|
import com.android.messaging.util.AccessibilityUtil;
|
||||||
import com.android.messaging.util.Assert;
|
|
||||||
import com.android.messaging.util.ImeUtil;
|
import com.android.messaging.util.ImeUtil;
|
||||||
import com.android.messaging.util.LogUtil;
|
import com.android.messaging.util.LogUtil;
|
||||||
import com.android.messaging.util.UiUtils;
|
import com.android.messaging.util.UiUtils;
|
||||||
@@ -110,9 +109,11 @@ public class ConversationListFragment extends Fragment implements ConversationLi
|
|||||||
|
|
||||||
public static ConversationListFragment createConversationListFragment(String modeKeyName) {
|
public static ConversationListFragment createConversationListFragment(String modeKeyName) {
|
||||||
final ConversationListFragment fragment = new ConversationListFragment();
|
final ConversationListFragment fragment = new ConversationListFragment();
|
||||||
|
if (modeKeyName != null) {
|
||||||
final Bundle bundle = new Bundle();
|
final Bundle bundle = new Bundle();
|
||||||
bundle.putBoolean(modeKeyName, true);
|
bundle.putBoolean(modeKeyName, true);
|
||||||
fragment.setArguments(bundle);
|
fragment.setArguments(bundle);
|
||||||
|
}
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +131,7 @@ public class ConversationListFragment extends Fragment implements ConversationLi
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
Assert.notNull(mHost);
|
mHost = (ConversationListFragmentHost) getActivity();
|
||||||
setScrolledToNewestConversationIfNeeded();
|
setScrolledToNewestConversationIfNeeded();
|
||||||
|
|
||||||
updateUi();
|
updateUi();
|
||||||
@@ -265,14 +266,6 @@ public class ConversationListFragment extends Fragment implements ConversationLi
|
|||||||
mListBinding.getData().setScrolledToNewestConversation(false);
|
mListBinding.getData().setScrolledToNewestConversation(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Call this immediately after attaching the fragment
|
|
||||||
*/
|
|
||||||
public void setHost(final ConversationListFragmentHost host) {
|
|
||||||
Assert.isNull(mHost);
|
|
||||||
mHost = host;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConversationListCursorUpdated(final ConversationListData data,
|
public void onConversationListCursorUpdated(final ConversationListData data,
|
||||||
final Cursor cursor) {
|
final Cursor cursor) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015 The Android Open Source Project
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
* Copyright (C) 2024 The LineageOS Project
|
* Copyright (C) 2024-2025 The LineageOS Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -19,11 +19,6 @@ package com.android.messaging.ui.conversationlist;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.fragment.app.FragmentManager;
|
|
||||||
import androidx.fragment.app.FragmentOnAttachListener;
|
|
||||||
|
|
||||||
import com.android.messaging.datamodel.data.ConversationListData;
|
import com.android.messaging.datamodel.data.ConversationListData;
|
||||||
import com.android.messaging.datamodel.data.ConversationListItemData;
|
import com.android.messaging.datamodel.data.ConversationListItemData;
|
||||||
import com.android.messaging.datamodel.data.MessageData;
|
import com.android.messaging.datamodel.data.MessageData;
|
||||||
@@ -36,13 +31,12 @@ import com.android.messaging.ui.conversationlist.ConversationListFragment.Conver
|
|||||||
* conversation list.
|
* conversation list.
|
||||||
*/
|
*/
|
||||||
public class ForwardMessageActivity extends BaseBugleActivity
|
public class ForwardMessageActivity extends BaseBugleActivity
|
||||||
implements ConversationListFragmentHost, FragmentOnAttachListener {
|
implements ConversationListFragmentHost {
|
||||||
private MessageData mDraftMessage;
|
private MessageData mDraftMessage;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(final Bundle savedInstanceState) {
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
getSupportFragmentManager().addFragmentOnAttachListener(this);
|
|
||||||
final ConversationListFragment fragment =
|
final ConversationListFragment fragment =
|
||||||
ConversationListFragment.createForwardMessageConversationListFragment();
|
ConversationListFragment.createForwardMessageConversationListFragment();
|
||||||
getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
|
getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
|
||||||
@@ -50,15 +44,6 @@ public class ForwardMessageActivity extends BaseBugleActivity
|
|||||||
MessageData.class);
|
MessageData.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttachFragment(@NonNull FragmentManager fragmentManager,
|
|
||||||
@NonNull Fragment fragment) {
|
|
||||||
if (fragment instanceof ConversationListFragment) {
|
|
||||||
final ConversationListFragment clf = (ConversationListFragment) fragment;
|
|
||||||
clf.setHost(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConversationClick(final ConversationListData listData,
|
public void onConversationClick(final ConversationListData listData,
|
||||||
final ConversationListItemData conversationListItemData,
|
final ConversationListItemData conversationListItemData,
|
||||||
|
|||||||
Reference in New Issue
Block a user