Change homepage layout
- merge PersonalSettingsFragment and TopLevelSettings together Bug: 118224579 Test: manual Change-Id: Ieee50a22babb25023e2a1767793e220862a38363
This commit is contained in:
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="36dp"
|
android:layout_height="@dimen/condition_header_height"
|
||||||
android:layout_centerHorizontal="true">
|
android:layout_centerHorizontal="true">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="36dp"
|
android:minHeight="@dimen/condition_header_height"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
@@ -15,8 +15,43 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/card_container"
|
android:id="@+id/card_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/suggestion_footer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/condition_header_height"
|
||||||
|
android:layout_centerHorizontal="true">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/expand_indicator"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingEnd="16dp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/expand_summary"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_toStartOf="@id/expand_indicator"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:gravity="end"
|
||||||
|
android:textAppearance="@style/TextAppearance.SuggestionTitle"
|
||||||
|
android:textColor="?android:attr/colorAccent"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
<include layout="@layout/horizontal_divider"/>
|
||||||
|
</LinearLayout>
|
||||||
|
@@ -15,44 +15,28 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<LinearLayout
|
<androidx.core.widget.NestedScrollView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
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_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1">
|
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
|
||||||
android:id="@+id/homepage_appbar"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:elevation="0dp">
|
android:orientation="vertical"
|
||||||
|
android:descendantFocusability="blocksDescendants">
|
||||||
|
|
||||||
<include layout="@layout/search_bar"/>
|
<include layout="@layout/search_bar"/>
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
<FrameLayout
|
||||||
|
android:id="@+id/suggestion_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@id/main_content"
|
android:id="@+id/main_content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"/>
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
||||||
|
|
||||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
</LinearLayout>
|
||||||
android:id="@+id/bottom_nav"
|
</androidx.core.widget.NestedScrollView>
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginEnd="0dp"
|
|
||||||
android:layout_marginStart="0dp"
|
|
||||||
android:background="?android:attr/windowBackground"
|
|
||||||
app:itemIconTint="@color/bottom_navigation_colors"
|
|
||||||
app:itemTextColor="@color/bottom_navigation_colors"
|
|
||||||
app:menu="@menu/home_bottom_navigation"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
@@ -311,6 +311,7 @@
|
|||||||
<!-- Suggestion/condition header padding -->
|
<!-- Suggestion/condition header padding -->
|
||||||
<dimen name="suggestion_condition_header_padding_collapsed">10dp</dimen>
|
<dimen name="suggestion_condition_header_padding_collapsed">10dp</dimen>
|
||||||
<dimen name="suggestion_condition_header_padding_expanded">5dp</dimen>
|
<dimen name="suggestion_condition_header_padding_expanded">5dp</dimen>
|
||||||
|
<dimen name="condition_header_height">36dp</dimen>
|
||||||
|
|
||||||
<!-- Suggestion cards size and padding -->
|
<!-- Suggestion cards size and padding -->
|
||||||
<dimen name="suggestion_card_icon_size">24dp</dimen>
|
<dimen name="suggestion_card_icon_size">24dp</dimen>
|
||||||
@@ -357,4 +358,6 @@
|
|||||||
<!-- Signal icon in NetworkSelectSetting -->
|
<!-- Signal icon in NetworkSelectSetting -->
|
||||||
<dimen name="signal_strength_icon_size">24dp</dimen>
|
<dimen name="signal_strength_icon_size">24dp</dimen>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -10271,4 +10271,9 @@
|
|||||||
|
|
||||||
<!-- Used for EmergencyInfoSlice slice helper class -->
|
<!-- Used for EmergencyInfoSlice slice helper class -->
|
||||||
<string name="emergency_info_contextual_card_summary" translatable="false">Medical info, emergency contacts</string>
|
<string name="emergency_info_contextual_card_summary" translatable="false">Medical info, emergency contacts</string>
|
||||||
|
|
||||||
|
<!-- See more items in contextual homepage [CHAR LIMIT=30]-->
|
||||||
|
<string name="see_more">See more</string>
|
||||||
|
<!-- See less items in contextual homepage [CHAR LIMIT=30]-->
|
||||||
|
<string name="see_less">See less</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -17,7 +17,6 @@
|
|||||||
package com.android.settings.homepage;
|
package com.android.settings.homepage;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@@ -22,7 +22,6 @@ import android.os.Bundle;
|
|||||||
import android.util.FeatureFlagUtils;
|
import android.util.FeatureFlagUtils;
|
||||||
import android.widget.Toolbar;
|
import android.widget.Toolbar;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
@@ -32,13 +31,10 @@ import com.android.settings.core.FeatureFlags;
|
|||||||
import com.android.settings.core.SettingsBaseActivity;
|
import com.android.settings.core.SettingsBaseActivity;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
|
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
|
||||||
|
|
||||||
public class SettingsHomepageActivity extends SettingsBaseActivity {
|
public class SettingsHomepageActivity extends SettingsBaseActivity {
|
||||||
|
|
||||||
@VisibleForTesting
|
private static final String SUGGESTION_TAG = "suggestion";
|
||||||
static final String PERSONAL_SETTINGS_TAG = "personal_settings";
|
private static final String MAIN_TAG = "main";
|
||||||
private static final String ALL_SETTINGS_TAG = "all_settings";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -58,49 +54,18 @@ public class SettingsHomepageActivity extends SettingsBaseActivity {
|
|||||||
FeatureFactory.getFactory(this).getSearchFeatureProvider()
|
FeatureFactory.getFactory(this).getSearchFeatureProvider()
|
||||||
.initSearchToolbar(this, toolbar);
|
.initSearchToolbar(this, toolbar);
|
||||||
|
|
||||||
final BottomNavigationView navigation = findViewById(R.id.bottom_nav);
|
showFragment(new PersonalSettingsFragment(), R.id.suggestion_content, SUGGESTION_TAG);
|
||||||
navigation.setOnNavigationItemSelectedListener(item -> {
|
showFragment(new TopLevelSettings(), R.id.main_content, MAIN_TAG);
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.homepage_personal_settings:
|
|
||||||
switchFragment(new PersonalSettingsFragment(), PERSONAL_SETTINGS_TAG,
|
|
||||||
ALL_SETTINGS_TAG);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case R.id.homepage_all_settings:
|
|
||||||
switchFragment(new TopLevelSettings(), ALL_SETTINGS_TAG,
|
|
||||||
PERSONAL_SETTINGS_TAG);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
|
||||||
// savedInstanceState is null, this is first load.
|
|
||||||
// Default to open contextual cards.
|
|
||||||
switchFragment(new PersonalSettingsFragment(), PERSONAL_SETTINGS_TAG,
|
|
||||||
ALL_SETTINGS_TAG);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isDynamicHomepageEnabled(Context context) {
|
public static boolean isDynamicHomepageEnabled(Context context) {
|
||||||
return FeatureFlagUtils.isEnabled(context, FeatureFlags.DYNAMIC_HOMEPAGE);
|
return FeatureFlagUtils.isEnabled(context, FeatureFlags.DYNAMIC_HOMEPAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchFragment(Fragment fragment, String showFragmentTag, String hideFragmentTag) {
|
private void showFragment(Fragment fragment, int id, String tag) {
|
||||||
final FragmentManager fragmentManager = getSupportFragmentManager();
|
final FragmentManager fragmentManager = getSupportFragmentManager();
|
||||||
final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
||||||
|
fragmentTransaction.add(id, fragment, tag);
|
||||||
final Fragment hideFragment = fragmentManager.findFragmentByTag(hideFragmentTag);
|
|
||||||
if (hideFragment != null) {
|
|
||||||
fragmentTransaction.hide(hideFragment);
|
|
||||||
}
|
|
||||||
|
|
||||||
Fragment showFragment = fragmentManager.findFragmentByTag(showFragmentTag);
|
|
||||||
if (showFragment == null) {
|
|
||||||
fragmentTransaction.add(R.id.main_content, fragment, showFragmentTag);
|
|
||||||
} else {
|
|
||||||
fragmentTransaction.show(showFragment);
|
|
||||||
}
|
|
||||||
fragmentTransaction.commit();
|
fragmentTransaction.commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,71 +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 static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
|
||||||
|
|
||||||
import static com.android.settings.homepage.SettingsHomepageActivity.PERSONAL_SETTINGS_TAG;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.support.test.InstrumentationRegistry;
|
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
|
||||||
import android.util.FeatureFlagUtils;
|
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
|
|
||||||
import com.android.settings.core.FeatureFlags;
|
|
||||||
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
public class SettingsHomepageActivityTest {
|
|
||||||
|
|
||||||
private Context mContext;
|
|
||||||
private SettingsHomepageActivity mActivity;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
mContext = InstrumentationRegistry.getTargetContext();
|
|
||||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.DYNAMIC_HOMEPAGE, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.DYNAMIC_HOMEPAGE, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void launchHomepage_shouldOpenPersonalSettings() {
|
|
||||||
final Intent intent = new Intent().setClass(mContext, SettingsHomepageActivity.class)
|
|
||||||
.addFlags(FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
|
|
||||||
mActivity = (SettingsHomepageActivity) InstrumentationRegistry.getInstrumentation()
|
|
||||||
.startActivitySync(intent);
|
|
||||||
|
|
||||||
final Fragment fragment = mActivity.getSupportFragmentManager()
|
|
||||||
.findFragmentByTag(PERSONAL_SETTINGS_TAG);
|
|
||||||
|
|
||||||
assertThat(fragment).isInstanceOf(PersonalSettingsFragment.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Reference in New Issue
Block a user