Remove clock date complication.

Date will be shown inside smartspace.

Bug: 239569907
Test: tested on device

Change-Id: I7355e2071dd7fc05fbee18521f70a454083bbd58
This commit is contained in:
Darrell Shi
2022-07-28 21:43:31 +00:00
parent 3f2c081a30
commit 2d9d8fc6c5
4 changed files with 0 additions and 311 deletions

View File

@@ -1,111 +0,0 @@
/*
* Copyright (C) 2022 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.
*/
package com.android.systemui.dreams.complication;
import static com.android.systemui.dreams.complication.dagger.DreamClockDateComplicationModule.DREAM_CLOCK_DATE_COMPLICATION_LAYOUT_PARAMS;
import static com.android.systemui.dreams.complication.dagger.DreamClockDateComplicationModule.DREAM_CLOCK_DATE_COMPLICATION_VIEW;
import android.content.Context;
import android.view.View;
import com.android.systemui.CoreStartable;
import com.android.systemui.dreams.DreamOverlayStateController;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
/**
* Clock Date Complication that produce Clock Date view holder.
*/
public class DreamClockDateComplication implements Complication {
private final Provider<DreamClockDateViewHolder> mDreamClockDateViewHolderProvider;
/**
* Default constructor for {@link DreamClockDateComplication}.
*/
@Inject
public DreamClockDateComplication(
Provider<DreamClockDateViewHolder> dreamClockDateViewHolderProvider) {
mDreamClockDateViewHolderProvider = dreamClockDateViewHolderProvider;
}
@Override
public int getRequiredTypeAvailability() {
return COMPLICATION_TYPE_DATE;
}
/**
* Create {@link DreamClockDateViewHolder}.
*/
@Override
public ViewHolder createView(ComplicationViewModel model) {
return mDreamClockDateViewHolderProvider.get();
}
/**
* {@link CoreStartable} responsible for registering {@link DreamClockDateComplication} with
* SystemUI.
*/
public static class Registrant extends CoreStartable {
private final DreamOverlayStateController mDreamOverlayStateController;
private final DreamClockDateComplication mComplication;
/**
* Default constructor to register {@link DreamClockDateComplication}.
*/
@Inject
public Registrant(Context context,
DreamOverlayStateController dreamOverlayStateController,
DreamClockDateComplication dreamClockDateComplication) {
super(context);
mDreamOverlayStateController = dreamOverlayStateController;
mComplication = dreamClockDateComplication;
}
@Override
public void start() {
mDreamOverlayStateController.addComplication(mComplication);
}
}
/**
* {@link ViewHolder} to contain value/logic associated with {@link DreamClockDateComplication}.
*/
public static class DreamClockDateViewHolder implements ViewHolder {
private final View mView;
private final ComplicationLayoutParams mLayoutParams;
@Inject
DreamClockDateViewHolder(@Named(DREAM_CLOCK_DATE_COMPLICATION_VIEW) View view,
@Named(DREAM_CLOCK_DATE_COMPLICATION_LAYOUT_PARAMS)
ComplicationLayoutParams layoutParams) {
mView = view;
mLayoutParams = layoutParams;
}
@Override
public View getView() {
return mView;
}
@Override
public ComplicationLayoutParams getLayoutParams() {
return mLayoutParams;
}
}
}

View File

@@ -1,71 +0,0 @@
/*
* Copyright (C) 2022 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.
*/
package com.android.systemui.dreams.complication.dagger;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.android.internal.util.Preconditions;
import com.android.systemui.R;
import com.android.systemui.dreams.complication.ComplicationLayoutParams;
import com.android.systemui.dreams.complication.DreamClockDateComplication;
import javax.inject.Named;
import dagger.Module;
import dagger.Provides;
/**
* Module for providing {@link DreamClockDateComplication}.
*/
@Module
public interface DreamClockDateComplicationModule {
String DREAM_CLOCK_DATE_COMPLICATION_VIEW = "clock_date_complication_view";
String DREAM_CLOCK_DATE_COMPLICATION_LAYOUT_PARAMS =
"clock_date_complication_layout_params";
// Order weight of insert into parent container
//TODO(b/217199227): move to a single location.
int INSERT_ORDER_WEIGHT = 3;
/**
* Provides the complication view.
*/
@Provides
@Named(DREAM_CLOCK_DATE_COMPLICATION_VIEW)
static View provideComplicationView(LayoutInflater layoutInflater) {
return Preconditions.checkNotNull(
layoutInflater.inflate(R.layout.dream_overlay_complication_clock_date,
null, false),
"R.layout.dream_overlay_complication_clock_date did not properly inflated");
}
/**
* Provides the layout parameters for the complication view.
*/
@Provides
@Named(DREAM_CLOCK_DATE_COMPLICATION_LAYOUT_PARAMS)
static ComplicationLayoutParams provideLayoutParams() {
return new ComplicationLayoutParams(0,
ViewGroup.LayoutParams.WRAP_CONTENT,
ComplicationLayoutParams.POSITION_BOTTOM
| ComplicationLayoutParams.POSITION_START,
ComplicationLayoutParams.DIRECTION_END,
INSERT_ORDER_WEIGHT, /* snapToGuide= */ true);
}
}

View File

@@ -25,7 +25,6 @@ import dagger.Module;
* {@link SystemUIBinder}.
*/
@Module(includes = {
DreamClockDateComplicationModule.class,
DreamClockTimeComplicationModule.class,
},
subcomponents = {

View File

@@ -1,128 +0,0 @@
/*
* Copyright (C) 2022 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.
*/
package com.android.systemui.dreams.complication;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.testing.AndroidTestingRunner;
import android.view.View;
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.dreams.DreamOverlayStateController;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import javax.inject.Provider;
@SmallTest
@RunWith(AndroidTestingRunner.class)
public class DreamClockDateComplicationTest extends SysuiTestCase {
@SuppressWarnings("HidingField")
@Mock
private Context mContext;
@Mock
private DreamOverlayStateController mDreamOverlayStateController;
@Mock
private DreamClockDateComplication mComplication;
@Mock
private Provider<DreamClockDateComplication.DreamClockDateViewHolder>
mDreamClockDateViewHolderProvider;
@Mock
private DreamClockDateComplication.DreamClockDateViewHolder
mDreamClockDateViewHolder;
@Mock
private ComplicationViewModel mComplicationViewModel;
@Mock
private View mView;
@Mock
private ComplicationLayoutParams mLayoutParams;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
when(mDreamClockDateViewHolderProvider.get()).thenReturn(mDreamClockDateViewHolder);
}
/**
* Ensures {@link DreamClockDateComplication} is registered.
*/
@Test
public void testComplicationAdded() {
final DreamClockDateComplication.Registrant registrant =
new DreamClockDateComplication.Registrant(
mContext,
mDreamOverlayStateController,
mComplication);
registrant.start();
verify(mDreamOverlayStateController).addComplication(eq(mComplication));
}
/**
* Verifies {@link DreamClockDateComplication} has the required type.
*/
@Test
public void testComplicationRequiredTypeAvailability() {
final DreamClockDateComplication complication =
new DreamClockDateComplication(mDreamClockDateViewHolderProvider);
assertEquals(Complication.COMPLICATION_TYPE_DATE,
complication.getRequiredTypeAvailability());
}
/**
* Verifies {@link DreamClockDateComplication.DreamClockDateViewHolder} is obtainable from its
* provider when the complication creates view.
*/
@Test
public void testComplicationViewHolderProviderOnCreateView() {
final DreamClockDateComplication complication =
new DreamClockDateComplication(mDreamClockDateViewHolderProvider);
final Complication.ViewHolder viewHolder = complication.createView(mComplicationViewModel);
verify(mDreamClockDateViewHolderProvider).get();
assertThat(viewHolder).isEqualTo(mDreamClockDateViewHolder);
}
/**
* Verifies {@link DreamClockDateComplication.DreamClockDateViewHolder} has the intended view
* and layout parameters from constructor.
*/
@Test
public void testComplicationViewHolderContentAccessors() {
final DreamClockDateComplication.DreamClockDateViewHolder viewHolder =
new DreamClockDateComplication.DreamClockDateViewHolder(mView, mLayoutParams);
assertThat(viewHolder.getView()).isEqualTo(mView);
assertThat(viewHolder.getLayoutParams()).isEqualTo(mLayoutParams);
}
}