Separate suggestions and conditions.
This is the initial change for updating the suggestion cards: - add a feature flag to swap between the new and current UI - change suggestions to a standalone dashboard item. It becomes a horizontal scroll list that won't collapse/expand. - the expand/collapse logic now only control the conditions list - add draft for the new suggestion UI elements, but detail to fine-tune to match the UI spec will come in following changes. Bug: 70573674 Test: make RunSettingsRoboTests Change-Id: I00c901e2598b26a34288fc73fd6031cc26a29ac6
This commit is contained in:
@@ -65,6 +65,7 @@ public class DashboardSummary extends InstrumentedFragment
|
||||
|
||||
private FocusRecyclerView mDashboard;
|
||||
private DashboardAdapter mAdapter;
|
||||
private DashboardAdapterV2 mAdapterV2;
|
||||
private SummaryLoader mSummaryLoader;
|
||||
private ConditionManager mConditionManager;
|
||||
private LinearLayoutManager mLayoutManager;
|
||||
@@ -175,8 +176,10 @@ public class DashboardSummary extends InstrumentedFragment
|
||||
super.onSaveInstanceState(outState);
|
||||
if (mLayoutManager == null) return;
|
||||
outState.putInt(EXTRA_SCROLL_POSITION, mLayoutManager.findFirstVisibleItemPosition());
|
||||
if (mAdapter != null) {
|
||||
mAdapter.onSaveInstanceState(outState);
|
||||
if (!mDashboardFeatureProvider.useSuggestionUiV2()) {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.onSaveInstanceState(outState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,11 +197,18 @@ public class DashboardSummary extends InstrumentedFragment
|
||||
mDashboard.setLayoutManager(mLayoutManager);
|
||||
mDashboard.setHasFixedSize(true);
|
||||
mDashboard.setListener(this);
|
||||
mAdapter = new DashboardAdapter(getContext(), bundle, mConditionManager.getConditions(),
|
||||
mSuggestionControllerMixin, this /* SuggestionDismissController.Callback */);
|
||||
mDashboard.setAdapter(mAdapter);
|
||||
mDashboard.setItemAnimator(new DashboardItemAnimator());
|
||||
mSummaryLoader.setSummaryConsumer(mAdapter);
|
||||
if (mDashboardFeatureProvider.useSuggestionUiV2()) {
|
||||
mAdapterV2 = new DashboardAdapterV2(getContext(), bundle,
|
||||
mConditionManager.getConditions(), mSuggestionControllerMixin, getLifecycle());
|
||||
mDashboard.setAdapter(mAdapterV2);
|
||||
mSummaryLoader.setSummaryConsumer(mAdapterV2);
|
||||
} else {
|
||||
mAdapter = new DashboardAdapter(getContext(), bundle, mConditionManager.getConditions(),
|
||||
mSuggestionControllerMixin, this /* SuggestionDismissController.Callback */);
|
||||
mDashboard.setAdapter(mAdapter);
|
||||
mSummaryLoader.setSummaryConsumer(mAdapter);
|
||||
}
|
||||
ActionBarShadowController.attachToRecyclerView(
|
||||
getActivity().findViewById(R.id.search_bar_container), getLifecycle(), mDashboard);
|
||||
rebuildUI();
|
||||
@@ -237,7 +247,11 @@ public class DashboardSummary extends InstrumentedFragment
|
||||
if (mOnConditionsChangedCalled) {
|
||||
final boolean scrollToTop =
|
||||
mLayoutManager.findFirstCompletelyVisibleItemPosition() <= 1;
|
||||
mAdapter.setConditions(mConditionManager.getConditions());
|
||||
if (mDashboardFeatureProvider.useSuggestionUiV2()) {
|
||||
mAdapterV2.setConditions(mConditionManager.getConditions());
|
||||
} else {
|
||||
mAdapter.setConditions(mConditionManager.getConditions());
|
||||
}
|
||||
if (scrollToTop) {
|
||||
mDashboard.scrollToPosition(0);
|
||||
}
|
||||
@@ -248,7 +262,11 @@ public class DashboardSummary extends InstrumentedFragment
|
||||
|
||||
@Override
|
||||
public Suggestion getSuggestionAt(int position) {
|
||||
return mAdapter.getSuggestion(position);
|
||||
if (mDashboardFeatureProvider.useSuggestionUiV2()) {
|
||||
return mAdapterV2.getSuggestion(position);
|
||||
} else {
|
||||
return mAdapter.getSuggestion(position);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -259,11 +277,20 @@ public class DashboardSummary extends InstrumentedFragment
|
||||
@Override
|
||||
public void onSuggestionReady(List<Suggestion> suggestions) {
|
||||
mStagingSuggestions = suggestions;
|
||||
mAdapter.setSuggestions(suggestions);
|
||||
if (mStagingCategory != null) {
|
||||
Log.d(TAG, "Category has loaded, setting category from suggestionReady");
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
mAdapter.setCategory(mStagingCategory);
|
||||
if (mDashboardFeatureProvider.useSuggestionUiV2()) {
|
||||
mAdapterV2.setSuggestions(suggestions);
|
||||
if (mStagingCategory != null) {
|
||||
Log.d(TAG, "Category has loaded, setting category from suggestionReady");
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
mAdapterV2.setCategory(mStagingCategory);
|
||||
}
|
||||
} else {
|
||||
mAdapter.setSuggestions(suggestions);
|
||||
if (mStagingCategory != null) {
|
||||
Log.d(TAG, "Category has loaded, setting category from suggestionReady");
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
mAdapter.setCategory(mStagingCategory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,14 +303,26 @@ public class DashboardSummary extends InstrumentedFragment
|
||||
if (mSuggestionControllerMixin.isSuggestionLoaded()) {
|
||||
Log.d(TAG, "Suggestion has loaded, setting suggestion/category");
|
||||
ThreadUtils.postOnMainThread(() -> {
|
||||
if (mStagingSuggestions != null) {
|
||||
mAdapter.setSuggestions(mStagingSuggestions);
|
||||
if (mDashboardFeatureProvider.useSuggestionUiV2()) {
|
||||
if (mStagingSuggestions != null) {
|
||||
mAdapterV2.setSuggestions(mStagingSuggestions);
|
||||
}
|
||||
mAdapterV2.setCategory(mStagingCategory);
|
||||
} else {
|
||||
if (mStagingSuggestions != null) {
|
||||
mAdapter.setSuggestions(mStagingSuggestions);
|
||||
}
|
||||
mAdapter.setCategory(mStagingCategory);
|
||||
}
|
||||
mAdapter.setCategory(mStagingCategory);
|
||||
});
|
||||
} else {
|
||||
Log.d(TAG, "Suggestion NOT loaded, delaying setCategory by " + MAX_WAIT_MILLIS + "ms");
|
||||
mHandler.postDelayed(() -> mAdapter.setCategory(mStagingCategory), MAX_WAIT_MILLIS);
|
||||
if (mDashboardFeatureProvider.useSuggestionUiV2()) {
|
||||
mHandler.postDelayed(()
|
||||
-> mAdapterV2.setCategory(mStagingCategory), MAX_WAIT_MILLIS);
|
||||
} else {
|
||||
mHandler.postDelayed(() -> mAdapter.setCategory(mStagingCategory), MAX_WAIT_MILLIS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user