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

Commit e5b99970 authored by Ajinkya Chalke's avatar Ajinkya Chalke
Browse files

Update backlinks UI to match mocks.

Bug: 300307759
Test: atest AppClipsActivityTest AppClipsViewModelTest
Flag: com.android.systemui.app_clips_backlinks
Change-Id: Ia9e6834429e417aa1b98b4224bbbb6c0c14ac6bc
parent c795b8f6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -175,4 +175,6 @@
    <dimen name="sfps_progress_bar_padding_from_edge">7dp</dimen>

    <dimen name="keyguard_presentation_width">410dp</dimen>

    <dimen name="appclips_backlinks_icon_size">24dp</dimen>
</resources>
+23 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2024 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<inset xmlns:android="http://schemas.android.com/apk/res/android"
    android:insetBottom="4dp"
    android:insetTop="4dp">
    <shape android:shape="rectangle">
        <corners android:radius="8dp" />
        <solid android:color="@android:color/system_surface_container_highest_light" />
    </shape>
</inset>
 No newline at end of file
+20 −3
Original line number Diff line number Diff line
@@ -51,13 +51,30 @@
        app:layout_constraintStart_toEndOf="@id/save"
        app:layout_constraintTop_toTopOf="parent" />

    <CheckBox
        android:id="@+id/backlinks_include_data"
        android:layout_width="wrap_content"
        android:layout_height="48dp"
        android:layout_marginStart="16dp"
        android:checked="true"
        android:text="@string/backlinks_include_link"
        android:visibility="gone"
        app:layout_constraintBottom_toTopOf="@id/preview"
        app:layout_constraintStart_toEndOf="@id/cancel"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/backlinks_data"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_height="48dp"
        android:layout_marginStart="16dp"
        android:background="@drawable/backlinks_rounded_rectangle"
        android:drawablePadding="4dp"
        android:gravity="center"
        android:paddingHorizontal="8dp"
        android:visibility="gone"
        app:layout_constraintStart_toEndOf="@id/cancel"
        app:layout_constraintBottom_toTopOf="@id/preview"
        app:layout_constraintStart_toEndOf="@id/backlinks_include_data"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
+1 −2
Original line number Diff line number Diff line
@@ -269,8 +269,7 @@
    <string name="screenshot_detected_multiple_template"><xliff:g id="appName" example="Google Chrome">%1$s</xliff:g> and other open apps detected this screenshot.</string>
    <!-- Add to note button used in App Clips flow to return the saved screenshot image to notes app. [CHAR LIMIT=NONE] -->
    <string name="app_clips_save_add_to_note">Add to note</string>
    <!-- TODO(b/300307759): Temporary string for text view that displays backlinks data. [CHAR LIMIT=NONE] -->
    <string name="backlinks_string" translatable="false">Open <xliff:g id="appName" example="Google Chrome">%1$s</xliff:g></string>
    <string name="backlinks_include_link">Include link</string>

    <!-- Notification title displayed for screen recording [CHAR LIMIT=50]-->
    <string name="screenrecord_title">Screen Recorder</string>
+20 −10
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import static com.android.systemui.screenshot.appclips.AppClipsTrampolineActivit

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -46,6 +45,7 @@ import android.os.ResultReceiver;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

@@ -100,7 +100,8 @@ public class AppClipsActivity extends ComponentActivity {
    private CropView mCropView;
    private Button mSave;
    private Button mCancel;
    private TextView mBacklinksData;
    private CheckBox mBacklinksIncludeDataCheckBox;
    private TextView mBacklinksDataTextView;
    private AppClipsViewModel mViewModel;

    private ResultReceiver mResultReceiver;
@@ -161,13 +162,17 @@ public class AppClipsActivity extends ComponentActivity {
        mSave.setOnClickListener(this::onClick);
        mCancel.setOnClickListener(this::onClick);
        mCropView = mLayout.findViewById(R.id.crop_view);
        mBacklinksData = mLayout.findViewById(R.id.backlinks_data);
        mPreview = mLayout.findViewById(R.id.preview);

        mPreview.addOnLayoutChangeListener(
                (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) ->
                        updateImageDimensions());

        mBacklinksDataTextView = mLayout.findViewById(R.id.backlinks_data);
        mBacklinksIncludeDataCheckBox = mLayout.findViewById(R.id.backlinks_include_data);
        mBacklinksIncludeDataCheckBox.setOnCheckedChangeListener(
                (buttonView, isChecked) ->
                        mBacklinksDataTextView.setVisibility(isChecked ? View.VISIBLE : View.GONE));

        mViewModel = new ViewModelProvider(this, mViewModelFactory).get(AppClipsViewModel.class);
        mViewModel.getScreenshot().observe(this, this::setScreenshot);
        mViewModel.getResultLiveData().observe(this, this::setResultThenFinish);
@@ -297,13 +302,18 @@ public class AppClipsActivity extends ComponentActivity {
        finish();
    }

    private void setBacklinksData(ClipData clipData) {
        if (mBacklinksData.getVisibility() == View.GONE) {
            mBacklinksData.setVisibility(View.VISIBLE);
        }
    private void setBacklinksData(InternalBacklinksData backlinksData) {
        mBacklinksIncludeDataCheckBox.setVisibility(View.VISIBLE);
        mBacklinksDataTextView.setVisibility(
                mBacklinksIncludeDataCheckBox.isChecked() ? View.VISIBLE : View.GONE);

        mBacklinksDataTextView.setText(backlinksData.getClipData().getDescription().getLabel());

        mBacklinksData.setText(String.format(getString(R.string.backlinks_string),
                clipData.getDescription().getLabel()));
        Drawable appIcon = backlinksData.getAppIcon();
        int size = getResources().getDimensionPixelSize(R.dimen.appclips_backlinks_icon_size);
        appIcon.setBounds(/* left= */ 0, /* top= */ 0, /* right= */ size, /* bottom= */ size);
        mBacklinksDataTextView.setCompoundDrawablesRelative(/* start= */ appIcon, /* top= */
                null, /* end= */ null, /* bottom= */ null);
    }

    private void setError(int errorCode) {
Loading