Merge "Change icon for Private Space unlocked and setup success toast" into main

This commit is contained in:
Joseph Vincent
2024-03-26 19:04:11 +00:00
committed by Android (Google) Code Review
4 changed files with 57 additions and 5 deletions

View File

@@ -19,6 +19,7 @@ package com.android.settings.privatespace;
import static com.android.settings.privatespace.PrivateSpaceAuthenticationActivity.EXTRA_SHOW_PRIVATE_SPACE_UNLOCKED;
import android.app.settings.SettingsEnums;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
@@ -38,7 +39,14 @@ public class PrivateSpaceDashboardFragment extends DashboardFragment {
if (icicle == null
&& getIntent().getBooleanExtra(EXTRA_SHOW_PRIVATE_SPACE_UNLOCKED, false)) {
Log.i(TAG, "Private space unlocked showing toast");
Toast.makeText(getContext(), R.string.private_space_unlocked, Toast.LENGTH_SHORT)
Drawable drawable =
getContext().getDrawable(R.drawable.ic_private_space_unlock_icon);
Toast.makeCustomToastWithIcon(
getContext(),
null /* looper */,
getContext().getString(R.string.private_space_unlocked),
Toast.LENGTH_SHORT,
drawable)
.show();
}
}

View File

@@ -21,6 +21,7 @@ import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
@@ -100,6 +101,7 @@ public class SetupSuccessFragment extends InstrumentedFragment {
allAppsIntent.setPackage(resolveInfo.activityInfo.packageName);
allAppsIntent.setComponent(resolveInfo.activityInfo.getComponentName());
}
activity.setTheme(R.style.Theme_SubSettings);
accessPrivateSpaceToast();
startActivity(allAppsIntent);
Log.i(TAG, "Private space setup complete");
@@ -109,7 +111,13 @@ public class SetupSuccessFragment extends InstrumentedFragment {
}
private void accessPrivateSpaceToast() {
Toast.makeText(getContext(), R.string.private_space_scrolldown_to_access,
Toast.LENGTH_SHORT).show();
Drawable drawable = getContext().getDrawable(R.drawable.ic_private_space_icon);
Toast.makeCustomToastWithIcon(
getContext(),
null /* looper */ ,
getContext().getString(R.string.private_space_scrolldown_to_access),
Toast.LENGTH_SHORT,
drawable)
.show();
}
}

View File

@@ -21,6 +21,7 @@ import static com.android.settings.privatespace.PrivateSpaceMaintainer.ErrorDele
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -132,13 +133,23 @@ public class PrivateSpaceDeletionProgressFragment extends InstrumentedFragment {
/** Shows a toast saying that the private space was deleted */
@VisibleForTesting
public void showSuccessfulDeletionToast() {
Toast.makeText(getContext(), R.string.private_space_deleted, Toast.LENGTH_SHORT).show();
showToastWithCustomIcon(R.string.private_space_deleted);
}
/** Shows a toast saying that the private space could not be deleted */
@VisibleForTesting
public void showDeletionInternalErrorToast() {
Toast.makeText(getContext(), R.string.private_space_delete_failed, Toast.LENGTH_SHORT)
showToastWithCustomIcon(R.string.private_space_delete_failed);
}
private void showToastWithCustomIcon(int stringRes) {
Drawable drawable = getContext().getDrawable(R.drawable.ic_private_space_icon);
Toast.makeCustomToastWithIcon(
getContext(),
null /* looper */ ,
getContext().getString(stringRes),
Toast.LENGTH_SHORT,
drawable)
.show();
}
}