Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4332dda9 authored by Sid Soundararajan's avatar Sid Soundararajan
Browse files

Add a check to adjust thumbnail scaling for full screen shots on TV

This should let us get away with taking smaller bitmaps for TV.

BUG: 28371792
Change-Id: Ia5d43dd48c57c4dd519b46f0c0d0ec94df5f42a9
parent 6a983faa
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@
    <dimen name="thumbnail_height">192dp</dimen>
    <!-- The amount to scale a fullscreen screenshot thumbnail. -->
    <item name="thumbnail_fullscreen_scale" type="fraction">60%</item>
    <!-- The width used to calculate scale for full screen thumbnail on TV -->
    <integer name="thumbnail_width_tv">240</integer>
    <!-- The standard size (both width and height) of an application icon that
         will be displayed in the app launcher and elsewhere. -->
    <dimen name="app_icon_size">48dip</dimen>
+1 −0
Original line number Diff line number Diff line
@@ -1496,6 +1496,7 @@
  <java-symbol type="integer" name="config_dockedStackDividerSnapMode" />
  <java-symbol type="fraction" name="docked_stack_divider_fixed_ratio" />
  <java-symbol type="fraction" name="thumbnail_fullscreen_scale" />
  <java-symbol type="integer" name="thumbnail_width_tv" />
  <java-symbol type="dimen" name="resize_shadow_size" />
  <java-symbol type="color" name="resize_shadow_start_color" />
  <java-symbol type="color" name="resize_shadow_end_color" />
+5 −3
Original line number Diff line number Diff line
@@ -54,9 +54,9 @@ import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.tv.animations.HomeRecentsEnterExitAnimationHolder;
import com.android.systemui.recents.tv.views.RecentsTvView;
import com.android.systemui.recents.tv.views.TaskCardView;
import com.android.systemui.recents.tv.views.TaskStackHorizontalGridView;
import com.android.systemui.recents.tv.views.TaskStackHorizontalViewAdapter;
import com.android.systemui.recents.views.AnimationProps;
import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.tv.pip.PipManager;
import com.android.systemui.tv.pip.PipRecentsOverlayManager;
@@ -184,12 +184,14 @@ public class RecentsTvActivity extends Activity implements OnPreDrawListener {
        if (!plan.hasTasks()) {
            loader.preloadTasks(plan, -1, !launchState.launchedFromHome);
        }

        int numVisibleTasks = TaskCardView.getNumberOfVisibleTasks(getApplicationContext());
        mLaunchedFromHome = launchState.launchedFromHome;
        TaskStack stack = plan.getTaskStack();
        RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
        loadOpts.runningTaskId = launchState.launchedToTaskId;
        loadOpts.numVisibleTasks = stack.getStackTaskCount();
        loadOpts.numVisibleTaskThumbnails = stack.getStackTaskCount();
        loadOpts.numVisibleTasks = numVisibleTasks;
        loadOpts.numVisibleTaskThumbnails = numVisibleTasks;
        loader.loadTasks(this, plan, loadOpts);


+13 −2
Original line number Diff line number Diff line
@@ -288,7 +288,6 @@ public class TaskCardView extends LinearLayout {
        lp.height = LayoutParams.MATCH_PARENT;

        screenshotView.setLayoutParams(lp);
        screenshotView.setImageBitmap(screenshot);
        screenshotView.setClipToOutline(true);
        screenshotView.setOutlineProvider(new ViewOutlineProvider() {
            @Override
@@ -296,6 +295,7 @@ public class TaskCardView extends LinearLayout {
                outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), mCornerRadius);
            }
        });
        screenshotView.setImageBitmap(screenshot);
    }

    private void setAsBannerView(Drawable banner, ImageView bannerView) {
@@ -304,7 +304,6 @@ public class TaskCardView extends LinearLayout {
                .getDimensionPixelSize(R.dimen.recents_tv_banner_width);
        lp.height = getResources()
                .getDimensionPixelSize(R.dimen.recents_tv_banner_height);

        bannerView.setLayoutParams(lp);
        bannerView.setImageDrawable(banner);
    }
@@ -327,4 +326,16 @@ public class TaskCardView extends LinearLayout {
    public View getDismissIconView() {
        return mDismissIconView;
    }

    public static int getNumberOfVisibleTasks(Context context) {
        Resources res = context.getResources();
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        int screenWidth = size.x;
        int cardWidth = res.getDimensionPixelSize(R.dimen.recents_tv_card_width);
        int spacing = res.getDimensionPixelSize(R.dimen.recents_tv_gird_card_spacing);
        return (int) (1.0 + Math.ceil(screenWidth / (cardWidth + spacing * 2.0)));
    }
}
+6 −1
Original line number Diff line number Diff line
@@ -23,9 +23,11 @@ import android.view.View;
import android.view.ViewGroup;

import com.android.systemui.R;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.LaunchTvTaskEvent;
import com.android.systemui.recents.events.ui.DeleteTaskDataEvent;
import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.views.AnimationProps;

@@ -122,7 +124,10 @@ public class TaskStackHorizontalViewAdapter extends

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.init(mTaskList.get(position));
        Task task = mTaskList.get(position);
        // Retrives from caches, loading only if necessary
        Recents.getTaskLoader().loadTaskData(task);
        holder.init(task);
    }

    @Override
Loading