Show settings app icon and name in recents
If user opens a settings activity by intent, it will show icon and label get from activity. However, we should show settings app icon and name constantly. Bug: 34645742 Test: RunSettingsRoboTest Change-Id: Ic2f0fef32529ba3f425a0130d25ead47fa0bb97d
This commit is contained in:
@@ -31,6 +31,10 @@ import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.nfc.NfcAdapter;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
@@ -679,6 +683,13 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
mDevelopmentPreferencesListener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTaskDescription(ActivityManager.TaskDescription taskDescription) {
|
||||
final Bitmap icon = getBitmapFromXmlResource(R.drawable.ic_launcher_settings);
|
||||
taskDescription.setIcon(icon);
|
||||
super.setTaskDescription(taskDescription);
|
||||
}
|
||||
|
||||
protected boolean isValidFragment(String fragmentName) {
|
||||
// Almost all fragments are wrapped in this,
|
||||
// except for a few that have their own activities.
|
||||
@@ -1114,4 +1125,17 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
Bitmap getBitmapFromXmlResource(int drawableRes) {
|
||||
Drawable drawable = getResources().getDrawable(drawableRes, getTheme());
|
||||
Canvas canvas = new Canvas();
|
||||
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
|
||||
drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
|
||||
canvas.setBitmap(bitmap);
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
drawable.draw(canvas);
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user