Revert "First commit of dynamic home page feature"

This reverts commit 3515bc7259.

Reason for revert: CLs in this topic break color check in repohook.

Bug: 110960820
Change-Id: I5934b6baf65515ebbc4e4660ed99747dd581f526
This commit is contained in:
Lei Yu
2018-06-29 00:18:14 +00:00
parent 3515bc7259
commit 457f6ef140
12 changed files with 31 additions and 392 deletions

View File

@@ -32,7 +32,6 @@ LOCAL_STATIC_ANDROID_LIBRARIES := \
androidx.preference_preference \ androidx.preference_preference \
androidx.recyclerview_recyclerview \ androidx.recyclerview_recyclerview \
androidx.legacy_legacy-preference-v14 \ androidx.legacy_legacy-preference-v14 \
com.google.android.material_material \
LOCAL_JAVA_LIBRARIES := \ LOCAL_JAVA_LIBRARIES := \
bouncycastle \ bouncycastle \

View File

@@ -123,19 +123,12 @@
android:value="true" /> android:value="true" />
</activity> </activity>
<activity android:name=".SettingsHomepageActivity"
android:taskAffinity="com.android.settings.root"
android:label="@string/settings_label_launcher"
android:theme="@style/Theme.Settings.Home"
android:launchMode="singleTask">
</activity>
<!-- Alias for launcher activity only, as this belongs to each profile. --> <!-- Alias for launcher activity only, as this belongs to each profile. -->
<activity-alias android:name="Settings" <activity-alias android:name="Settings"
android:taskAffinity="com.android.settings.root" android:taskAffinity="com.android.settings.root"
android:label="@string/settings_label_launcher" android:label="@string/settings_label_launcher"
android:launchMode="singleTask" android:launchMode="singleTask"
android:targetActivity=".SettingsHomepageActivity"> android:targetActivity="Settings">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />

View File

@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2018 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="?android:attr/colorAccent"
android:pathData="M4,13L4,13c0.55,0 1,-0.45 1,-1v0c0,-0.55 -0.45,-1 -1,-1h0c-0.55,0 -1,0.45 -1,1v0C3,12.55 3.45,13 4,13zM4,17L4,17c0.55,0 1,-0.45 1,-1v0c0,-0.55 -0.45,-1 -1,-1h0c-0.55,0 -1,0.45 -1,1v0C3,16.55 3.45,17 4,17zM4,9L4,9c0.55,0 1,-0.45 1,-1v0c0,-0.55 -0.45,-1 -1,-1h0C3.45,7 3,7.45 3,8v0C3,8.55 3.45,9 4,9zM7,13h14v-2H7V13zM7,17h14v-2H7V17zM7,7v2h14V7H7z"/>
</vector>

View File

@@ -1,50 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2018, 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.
*/
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
android:id="@+id/search_bar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/colorPrimary">
<androidx.cardview.widget.CardView
android:id="@+id/search_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/search_bar_margin"
app:cardCornerRadius="@dimen/search_bar_corner_radius"
app:cardBackgroundColor="?android:attr/colorBackground"
app:cardElevation="@dimen/search_bar_card_elevation">
<Toolbar
android:id="@+id/search_action_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/search_bar_height"
android:background="?android:attr/selectableItemBackground"
android:contentInsetStartWithNavigation="@dimen/search_bar_content_inset"
android:navigationIcon="@drawable/ic_search_24dp"
android:theme="?android:attr/actionBarTheme">
<TextView
android:id="@+id/search_action_bar_title"
style="@style/TextAppearance.SearchBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/search_menu"/>
</Toolbar>
</androidx.cardview.widget.CardView>
</FrameLayout>

View File

@@ -1,77 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2018, 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.
*/
-->
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@id/main_content"
android:layout_height="match_parent"
android:layout_width="match_parent" />
<RelativeLayout
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/windowBackground"
android:minHeight="@dimen/homepage_bottomsheet_height"
app:layout_behavior="@string/bottom_sheet_behavior"
app:behavior_peekHeight="@dimen/homepage_bottomsheet_height">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/bottom_area"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/search_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_search_24dp"
app:backgroundTint="@android:color/white"
app:layout_anchor="@id/bar" />
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bar"
android:layout_width="match_parent"
android:layout_height="@dimen/homepage_bottombar_height"
android:layout_alignParentTop="true"
android:layout_marginTop="@dimen/homepage_bottombar_top_margin"
android:clickable="true"
app:fabAttached="true"
app:fabAlignmentMode="end"
app:fabCradleDiameter="@dimen/homepage_bottombar_fab_cradle"
app:navigationIcon="@drawable/ic_list_24dp"
style="@style/Widget.MaterialComponents.BottomAppBar" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<include layout="@layout/search_bar"
android:visibility="invisible" />
<FrameLayout
android:id="@+id/bottom_sheet_fragment"
android:layout_below="@id/bottom_area"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@@ -23,9 +23,36 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<FrameLayout
<include layout="@layout/search_bar" /> android:id="@+id/search_bar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/colorPrimary">
<androidx.cardview.widget.CardView
android:id="@+id/search_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/search_bar_margin"
app:cardCornerRadius="@dimen/search_bar_corner_radius"
app:cardBackgroundColor="?android:attr/colorBackground"
app:cardElevation="2dp">
<Toolbar
android:id="@+id/search_action_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/search_bar_height"
android:background="?android:attr/selectableItemBackground"
android:contentInsetStartWithNavigation="64dp"
android:navigationIcon="@drawable/ic_search_24dp"
android:theme="?android:attr/actionBarTheme">
<TextView
android:id="@+id/search_action_bar_title"
style="@style/TextAppearance.SearchBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/search_menu" />
</Toolbar>
</androidx.cardview.widget.CardView>
</FrameLayout>
<FrameLayout <FrameLayout
android:id="@+id/main_content" android:id="@+id/main_content"
android:layout_height="match_parent" android:layout_height="match_parent"

View File

@@ -136,9 +136,5 @@
<color name="battery_maybe_color_dark">#fdd835</color> <!-- Material Yellow 600 --> <color name="battery_maybe_color_dark">#fdd835</color> <!-- Material Yellow 600 -->
<color name="battery_bad_color_dark">#f44336</color> <!-- Material Red 500 --> <color name="battery_bad_color_dark">#f44336</color> <!-- Material Red 500 -->
<!-- Dynamic home page -->
<color name="homepage_status_bar">#F1F3F4</color>
<color name="homepage_color_primary">#F8F9FA</color>
</resources> </resources>

View File

@@ -128,8 +128,6 @@
<dimen name="search_bar_height">48dp</dimen> <dimen name="search_bar_height">48dp</dimen>
<dimen name="search_bar_corner_radius">2dp</dimen> <dimen name="search_bar_corner_radius">2dp</dimen>
<dimen name="search_bar_text_size">16dp</dimen> <dimen name="search_bar_text_size">16dp</dimen>
<dimen name="search_bar_card_elevation">2dp</dimen>
<dimen name="search_bar_content_inset">64dp</dimen>
<!-- Dimensions for Wifi Assistant Card --> <!-- Dimensions for Wifi Assistant Card -->
<dimen name="wifi_assistant_padding_top_bottom">16dp</dimen> <dimen name="wifi_assistant_padding_top_bottom">16dp</dimen>
@@ -330,10 +328,4 @@
<dimen name="reset_checkbox_title_text_size">18sp</dimen> <dimen name="reset_checkbox_title_text_size">18sp</dimen>
<dimen name="reset_checkbox_summary_text_size">14sp</dimen> <dimen name="reset_checkbox_summary_text_size">14sp</dimen>
<!-- Bottombar size and padding -->
<dimen name="homepage_bottomsheet_height">90dp</dimen>
<dimen name="homepage_bottombar_height">56dp</dimen>
<dimen name="homepage_bottombar_top_margin">34dp</dimen>
<dimen name="homepage_bottombar_fab_cradle">68dp</dimen>
</resources> </resources>

View File

@@ -367,9 +367,4 @@
<item name="android:windowNoTitle">true</item> <item name="android:windowNoTitle">true</item>
</style> </style>
<style name="Theme.Settings.Home" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimaryDark">@color/homepage_status_bar</item>
<item name="android:colorPrimary">@color/homepage_color_primary</item>
</style>
</resources> </resources>

View File

@@ -1,61 +0,0 @@
/*
* Copyright (C) 2018 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.settings;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.FeatureFlagUtils;
import com.android.settings.core.FeatureFlags;
import com.android.settings.homepage.HomepageFragment;
import com.android.settingslib.drawer.SettingsDrawerActivity;
public class SettingsHomepageActivity extends SettingsDrawerActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!isDynamicHomepageEnabled(this)) {
final Intent settings = new Intent();
settings.setAction("android.settings.SETTINGS");
startActivity(settings);
finish();
}
setContentView(R.layout.settings_homepage);
switchToFragment(this, R.id.main_content, HomepageFragment.class.getName());
}
public static boolean isDynamicHomepageEnabled(Context context) {
return FeatureFlagUtils.isEnabled(context, FeatureFlags.DYNAMIC_HOMEPAGE);
}
/**
* Switch to a specific Fragment
*/
public static void switchToFragment(Activity activity, int id, String fragmentName) {
final Fragment f = Fragment.instantiate(activity, fragmentName, null /* args */);
FragmentManager manager = activity.getFragmentManager();
manager.beginTransaction().replace(id, f).commitAllowingStateLoss();
manager.executePendingTransactions();
}
}

View File

@@ -23,5 +23,4 @@ public class FeatureFlags {
public static final String BATTERY_DISPLAY_APP_LIST = "settings_battery_display_app_list"; public static final String BATTERY_DISPLAY_APP_LIST = "settings_battery_display_app_list";
public static final String BLUETOOTH_WHILE_DRIVING = "settings_bluetooth_while_driving"; public static final String BLUETOOTH_WHILE_DRIVING = "settings_bluetooth_while_driving";
public static final String AUDIO_SWITCHER_SETTINGS = "settings_audio_switcher"; public static final String AUDIO_SWITCHER_SETTINGS = "settings_audio_switcher";
public static final String DYNAMIC_HOMEPAGE = "settings_dynamic_homepage";
} }

View File

@@ -1,150 +0,0 @@
/*
* Copyright (C) 2018 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.settings.homepage;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toolbar;
import androidx.annotation.NonNull;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.SettingsHomepageActivity;
import com.android.settings.Utils;
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.dashboard.DashboardSummary;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.SearchFeatureProvider;
import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
public class HomepageFragment extends InstrumentedFragment {
private static final String TAG = "HomepageFragment";
private FloatingActionButton mSearchButton;
private BottomSheetBehavior mBottomSheetBehavior;
private boolean mBottomFragmentLoaded = false;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.dashboard, container, false);
return rootView;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setupBottomBar();
setupSearchBar();
}
@Override
public int getMetricsCategory() {
return MetricsEvent.SETTINGS_HOMEPAGE;
}
private void setupBottomBar() {
final Activity activity = getActivity();
mSearchButton = (FloatingActionButton) activity.findViewById(R.id.search_fab);
mSearchButton.setOnClickListener(v -> {
final Intent intent = SearchFeatureProvider.SEARCH_UI_INTENT;
intent.setPackage(FeatureFactory.getFactory(activity)
.getSearchFeatureProvider().getSettingsIntelligencePkgName());
startActivityForResult(intent, 0 /* requestCode */);
});
mBottomSheetBehavior = BottomSheetBehavior.from(activity.findViewById(R.id.bottom_sheet));
final BottomAppBar bottomBar = (BottomAppBar) activity.findViewById(R.id.bar);
bottomBar.setOnClickListener(v -> {
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
});
final int screenWidthpx = getResources().getDisplayMetrics().widthPixels;
final View searchbar = activity.findViewById(R.id.search_bar_container);
final View bottombar = activity.findViewById(R.id.bar);
mBottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (!mBottomFragmentLoaded) {
SettingsHomepageActivity.switchToFragment(getActivity(),
R.id.bottom_sheet_fragment, DashboardSummary.class.getName());
mBottomFragmentLoaded = true;
}
if (newState == BottomSheetBehavior.STATE_EXPANDED) {
bottombar.setVisibility(View.INVISIBLE);
searchbar.setVisibility(View.VISIBLE);
mSearchButton.setVisibility(View.GONE);
} else if (newState == BottomSheetBehavior.STATE_COLLAPSED) {
bottombar.setVisibility(View.VISIBLE);
searchbar.setVisibility(View.INVISIBLE);
mSearchButton.setVisibility(View.VISIBLE);
} else if (newState == BottomSheetBehavior.STATE_SETTLING) {
bottombar.setVisibility(View.VISIBLE);
searchbar.setVisibility(View.VISIBLE);
mSearchButton.setVisibility(View.VISIBLE);
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
bottombar.setAlpha(1 - slideOffset);
mSearchButton.setAlpha(1 - slideOffset);
searchbar.setAlpha(slideOffset);
searchbar.setPadding((int) (screenWidthpx * (1 - slideOffset)), 0, 0, 0);
}
});
}
//TODO(110767984), copied from settingsActivity. We have to merge them
private void setupSearchBar() {
final Activity activity = getActivity();
final Toolbar toolbar = activity.findViewById(R.id.search_action_bar);
FeatureFactory.getFactory(activity).getSearchFeatureProvider()
.initSearchToolbar(activity, toolbar);
activity.setActionBar(toolbar);
// Please forgive me for what I am about to do.
//
// Need to make the navigation icon non-clickable so that the entire card is clickable
// and goes to the search UI. Also set the background to null so there's no ripple.
final View navView = toolbar.getNavigationView();
navView.setClickable(false);
navView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
navView.setBackground(null);
final ActionBar actionBar = activity.getActionBar();
if (actionBar != null) {
boolean deviceProvisioned = Utils.isDeviceProvisioned(activity);
actionBar.setDisplayHomeAsUpEnabled(deviceProvisioned);
actionBar.setHomeButtonEnabled(deviceProvisioned);
actionBar.setDisplayShowTitleEnabled(false);
}
}
}