Use getSummary() to get tile summary text.
Bug: 77600770 Test: robotests Change-Id: Iecef09853bb49bc259502494912ed81d52e2d7ce
This commit is contained in:
@@ -356,8 +356,9 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
}
|
||||
holder.icon.setImageDrawable(icon);
|
||||
holder.title.setText(tile.getTitle(mContext));
|
||||
if (!TextUtils.isEmpty(tile.summary)) {
|
||||
holder.summary.setText(tile.summary);
|
||||
final CharSequence summary = tile.getSummary(mContext);
|
||||
if (!TextUtils.isEmpty(summary)) {
|
||||
holder.summary.setText(summary);
|
||||
holder.summary.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.summary.setVisibility(View.GONE);
|
||||
|
@@ -426,7 +426,9 @@ public class DashboardData {
|
||||
|
||||
// Only check id and summary for dashboard tile
|
||||
return localTile.getId() == targetTile.getId()
|
||||
&& TextUtils.equals(localTile.summary, targetTile.summary);
|
||||
&& TextUtils.equals(
|
||||
localTile.getSummaryReference(),
|
||||
targetTile.getSummaryReference());
|
||||
case TYPE_SUGGESTION_CONTAINER:
|
||||
case TYPE_CONDITION_CONTAINER:
|
||||
// Fall through to default
|
||||
|
@@ -172,8 +172,9 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
}
|
||||
|
||||
private void bindSummary(Preference preference, Tile tile) {
|
||||
if (tile.summary != null) {
|
||||
preference.setSummary(tile.summary);
|
||||
final CharSequence summary = tile.getSummary(mContext);
|
||||
if (summary != null) {
|
||||
preference.setSummary(summary);
|
||||
} else if (tile.getMetaData() != null
|
||||
&& tile.getMetaData().containsKey(META_DATA_PREFERENCE_SUMMARY_URI)) {
|
||||
// Set a placeholder summary before starting to fetch real summary, this is necessary
|
||||
@@ -183,9 +184,9 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
ThreadUtils.postOnBackgroundThread(() -> {
|
||||
final Map<String, IContentProvider> providerMap = new ArrayMap<>();
|
||||
final String uri = tile.getMetaData().getString(META_DATA_PREFERENCE_SUMMARY_URI);
|
||||
final String summary = TileUtils.getTextFromUri(
|
||||
final String summaryFromUri = TileUtils.getTextFromUri(
|
||||
mContext, uri, providerMap, META_DATA_PREFERENCE_SUMMARY);
|
||||
ThreadUtils.postOnMainThread(() -> preference.setSummary(summary));
|
||||
ThreadUtils.postOnMainThread(() -> preference.setSummary(summaryFromUri));
|
||||
});
|
||||
} else {
|
||||
preference.setSummary(R.string.summary_placeholder);
|
||||
|
@@ -157,11 +157,11 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
||||
final Preference pref = getPreferenceScreen().findPreference(key);
|
||||
if (pref == null) {
|
||||
Log.d(getLogTag(), String.format(
|
||||
"Can't find pref by key %s, skipping update summary %s/%s",
|
||||
key, tile.getDescription(), tile.summary));
|
||||
"Can't find pref by key %s, skipping update summary %s",
|
||||
key, tile.getDescription()));
|
||||
return;
|
||||
}
|
||||
pref.setSummary(tile.summary);
|
||||
pref.setSummary(tile.getSummary(pref.getContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.dashboard;
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
@@ -99,13 +100,13 @@ public class SummaryLoader {
|
||||
Log.d(TAG, "setSummary " + tile.getDescription() + " - " + summary);
|
||||
}
|
||||
|
||||
updateSummaryIfNeeded(tile, summary);
|
||||
updateSummaryIfNeeded(mActivity.getApplicationContext(), tile, summary);
|
||||
});
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void updateSummaryIfNeeded(Tile tile, CharSequence summary) {
|
||||
if (TextUtils.equals(tile.summary, summary)) {
|
||||
void updateSummaryIfNeeded(Context context, Tile tile, CharSequence summary) {
|
||||
if (TextUtils.equals(tile.getSummary(context), summary)) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Summary doesn't change, skipping summary update for "
|
||||
+ tile.getDescription());
|
||||
@@ -113,7 +114,7 @@ public class SummaryLoader {
|
||||
return;
|
||||
}
|
||||
mSummaryTextMap.put(mDashboardFeatureProvider.getDashboardKeyForTile(tile), summary);
|
||||
tile.summary = summary;
|
||||
tile.overrideSummary(summary);
|
||||
if (mSummaryConsumer != null) {
|
||||
mSummaryConsumer.notifySummaryChanged(tile);
|
||||
} else {
|
||||
@@ -216,7 +217,7 @@ public class SummaryLoader {
|
||||
for (Tile tile : category.getTiles()) {
|
||||
final String key = mDashboardFeatureProvider.getDashboardKeyForTile(tile);
|
||||
if (mSummaryTextMap.containsKey(key)) {
|
||||
tile.summary = mSummaryTextMap.get(key);
|
||||
tile.overrideSummary(mSummaryTextMap.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user