Merge "Update strings related to intent resolver and share sheet." into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-03-06 13:48:02 +00:00
committed by Android (Google) Code Review
8 changed files with 120 additions and 39 deletions

View File

@@ -299,11 +299,8 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
.createEvent(DevicePolicyEnums.RESOLVER_EMPTY_STATE_WORK_APPS_DISABLED)
.setStrings(getMetricsCategory())
.write();
showEmptyState(activeListAdapter,
R.drawable.ic_work_apps_off,
R.string.resolver_turn_on_work_apps,
R.string.resolver_turn_on_work_apps_explanation,
(View.OnClickListener) v -> {
showWorkProfileOffEmptyState(activeListAdapter,
v -> {
ProfileDescriptor descriptor = getItem(
userHandleToPageIndex(activeListAdapter.getUserHandle()));
showSpinner(descriptor.getEmptyStateView());
@@ -319,19 +316,13 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
DevicePolicyEnums.RESOLVER_EMPTY_STATE_NO_SHARING_TO_PERSONAL)
.setStrings(getMetricsCategory())
.write();
showEmptyState(activeListAdapter,
R.drawable.ic_sharing_disabled,
R.string.resolver_cant_share_with_personal_apps,
R.string.resolver_cant_share_cross_profile_explanation);
showNoWorkToPersonalIntentsEmptyState(activeListAdapter);
} else {
DevicePolicyEventLogger.createEvent(
DevicePolicyEnums.RESOLVER_EMPTY_STATE_NO_SHARING_TO_WORK)
.setStrings(getMetricsCategory())
.write();
showEmptyState(activeListAdapter,
R.drawable.ic_sharing_disabled,
R.string.resolver_cant_share_with_work_apps,
R.string.resolver_cant_share_cross_profile_explanation);
showNoPersonalToWorkIntentsEmptyState(activeListAdapter);
}
return false;
}
@@ -340,6 +331,15 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
return activeListAdapter.rebuildList(doPostProcessing);
}
protected abstract void showWorkProfileOffEmptyState(
ResolverListAdapter activeListAdapter, View.OnClickListener listener);
protected abstract void showNoPersonalToWorkIntentsEmptyState(
ResolverListAdapter activeListAdapter);
protected abstract void showNoWorkToPersonalIntentsEmptyState(
ResolverListAdapter activeListAdapter);
void showEmptyState(ResolverListAdapter listAdapter) {
UserHandle listUserHandle = listAdapter.getUserHandle();
if (UserHandle.myUserId() == listUserHandle.getIdentifier()
@@ -353,16 +353,16 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
showEmptyState(listAdapter,
R.drawable.ic_no_apps,
R.string.resolver_no_apps_available,
R.string.resolver_no_apps_available_explanation);
/* subtitleRes */ 0);
}
}
private void showEmptyState(ResolverListAdapter activeListAdapter,
protected void showEmptyState(ResolverListAdapter activeListAdapter,
@DrawableRes int iconRes, @StringRes int titleRes, @StringRes int subtitleRes) {
showEmptyState(activeListAdapter, iconRes, titleRes, subtitleRes, /* buttonOnClick */ null);
}
private void showEmptyState(ResolverListAdapter activeListAdapter,
protected void showEmptyState(ResolverListAdapter activeListAdapter,
@DrawableRes int iconRes, @StringRes int titleRes, @StringRes int subtitleRes,
View.OnClickListener buttonOnClick) {
ProfileDescriptor descriptor = getItem(
@@ -379,7 +379,12 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter {
title.setText(titleRes);
TextView subtitle = emptyStateView.findViewById(R.id.resolver_empty_state_subtitle);
subtitle.setText(subtitleRes);
if (subtitleRes != 0) {
subtitle.setVisibility(View.VISIBLE);
subtitle.setText(subtitleRes);
} else {
subtitle.setVisibility(View.GONE);
}
Button button = emptyStateView.findViewById(R.id.resolver_empty_state_button);
button.setVisibility(buttonOnClick != null ? View.VISIBLE : View.GONE);

View File

@@ -20,6 +20,7 @@ import android.annotation.Nullable;
import android.content.Context;
import android.os.UserHandle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.android.internal.R;
@@ -169,6 +170,32 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd
return ResolverActivity.METRICS_CATEGORY_CHOOSER;
}
@Override
protected void showWorkProfileOffEmptyState(ResolverListAdapter activeListAdapter,
View.OnClickListener listener) {
showEmptyState(activeListAdapter,
R.drawable.ic_work_apps_off,
R.string.resolver_turn_on_work_apps_share,
/* subtitleRes */ 0,
listener);
}
@Override
protected void showNoPersonalToWorkIntentsEmptyState(ResolverListAdapter activeListAdapter) {
showEmptyState(activeListAdapter,
R.drawable.ic_sharing_disabled,
R.string.resolver_cant_share_with_work_apps,
R.string.resolver_cant_share_cross_profile_explanation);
}
@Override
protected void showNoWorkToPersonalIntentsEmptyState(ResolverListAdapter activeListAdapter) {
showEmptyState(activeListAdapter,
R.drawable.ic_sharing_disabled,
R.string.resolver_cant_share_with_personal_apps,
R.string.resolver_cant_share_cross_profile_explanation);
}
class ChooserProfileDescriptor extends ProfileDescriptor {
private ChooserActivity.ChooserGridAdapter chooserGridAdapter;
private RecyclerView recyclerView;

View File

@@ -1595,9 +1595,17 @@ public class ResolverActivity extends Activity implements
}
private void resetTabsHeaderStyle(TabWidget tabWidget) {
String workContentDescription = getString(R.string.resolver_work_tab_accessibility);
String personalContentDescription = getString(R.string.resolver_personal_tab_accessibility);
for (int i = 0; i < tabWidget.getChildCount(); i++) {
TextView title = tabWidget.getChildAt(i).findViewById(android.R.id.title);
View tabView = tabWidget.getChildAt(i);
TextView title = tabView.findViewById(android.R.id.title);
title.setTextColor(getColor(R.color.resolver_tabs_inactive_color));
if (title.getText().equals(getString(R.string.resolver_personal_tab))) {
tabView.setContentDescription(personalContentDescription);
} else if (title.getText().equals(getString(R.string.resolver_work_tab))) {
tabView.setContentDescription(workContentDescription);
}
}
}

View File

@@ -20,6 +20,7 @@ import android.annotation.Nullable;
import android.content.Context;
import android.os.UserHandle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
@@ -161,6 +162,32 @@ public class ResolverMultiProfilePagerAdapter extends AbstractMultiProfilePagerA
return ResolverActivity.METRICS_CATEGORY_RESOLVER;
}
@Override
protected void showWorkProfileOffEmptyState(ResolverListAdapter activeListAdapter,
View.OnClickListener listener) {
showEmptyState(activeListAdapter,
R.drawable.ic_work_apps_off,
R.string.resolver_turn_on_work_apps_view,
/* subtitleRes */ 0,
listener);
}
@Override
protected void showNoPersonalToWorkIntentsEmptyState(ResolverListAdapter activeListAdapter) {
showEmptyState(activeListAdapter,
R.drawable.ic_sharing_disabled,
R.string.resolver_cant_access_work_apps,
R.string.resolver_cant_access_work_apps_explanation);
}
@Override
protected void showNoWorkToPersonalIntentsEmptyState(ResolverListAdapter activeListAdapter) {
showEmptyState(activeListAdapter,
R.drawable.ic_sharing_disabled,
R.string.resolver_cant_access_personal_apps,
R.string.resolver_cant_access_personal_apps_explanation);
}
class ResolverProfileDescriptor extends ProfileDescriptor {
private ResolverListAdapter resolverListAdapter;
final ListView listView;