Merge "Use SetupWizardLib helpers"

This commit is contained in:
Maurice Lam
2015-04-18 00:48:21 +00:00
committed by Android (Google) Code Review
17 changed files with 27 additions and 269 deletions

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 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.
-->
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@integer/setup_wizard_transition_duration"
android:fromXDelta="100%"
android:toXDelta="0%"
android:interpolator="@android:anim/decelerate_interpolator"/>

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 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.
-->
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@integer/setup_wizard_transition_duration"
android:fromXDelta="0%"
android:toXDelta="-100%"
android:interpolator="@android:anim/decelerate_interpolator"/>

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 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.
-->
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@integer/setup_wizard_transition_duration"
android:fromXDelta="-100%"
android:toXDelta="0%"
android:interpolator="@android:anim/decelerate_interpolator"/>

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 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.
-->
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@integer/setup_wizard_transition_duration"
android:fromXDelta="0%"
android:toXDelta="100%"
android:interpolator="@android:anim/decelerate_interpolator"/>

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 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.
-->
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@integer/setup_wizard_transition_duration"
android:fromXDelta="-100%"
android:toXDelta="0%"
android:interpolator="@android:anim/decelerate_interpolator"/>

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 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.
-->
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@integer/setup_wizard_transition_duration"
android:fromXDelta="0%"
android:toXDelta="100%"
android:interpolator="@android:anim/decelerate_interpolator"/>

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 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.
-->
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@integer/setup_wizard_transition_duration"
android:fromXDelta="100%"
android:toXDelta="0%"
android:interpolator="@android:anim/decelerate_interpolator"/>

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 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.
-->
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@integer/setup_wizard_transition_duration"
android:fromXDelta="0%"
android:toXDelta="-100%"
android:interpolator="@android:anim/decelerate_interpolator"/>

View File

@@ -44,11 +44,9 @@
<color name="setup_lock_pattern_view_regular_color_dark">#ffbdbdbd</color>
<color name="setup_lock_pattern_view_regular_color_light">@color/lock_pattern_view_regular_color</color>
<color name="setup_lock_pattern_view_success_color_dark">#ff84ffff</color>
<color name="setup_lock_pattern_view_success_color_light">@color/setup_wizard_color_accent_light</color>
<color name="setup_lock_pattern_view_success_color_light">@color/suw_color_accent_light</color>
<color name="setup_lock_pattern_view_error_color_dark">#fff44336</color>
<color name="setup_lock_pattern_view_error_color_light">@color/lock_pattern_view_error_color</color>
<color name="setup_wizard_color_accent_dark">#ff00e4ff</color>
<color name="setup_wizard_color_accent_light">#ff00828e</color>
<color name="setup_wizard_wifi_color_dark">#ff00e4ff</color>
<color name="setup_wizard_wifi_color_light">#ff0096a6</color>

View File

@@ -29,14 +29,11 @@
<item name="android:windowBackground">@null</item>
</style>
<style name="SetupWizardTheme" parent="android:Theme.Material.NoActionBar">
<style name="SetupWizardTheme" parent="SuwThemeMaterial">
<item name="android:alertDialogTheme">@style/Theme.WifiDialog</item>
<item name="android:colorAccent">@color/setup_wizard_color_accent_dark</item>
<item name="android:listPreferredItemPaddingEnd">@dimen/setup_wizard_margin_sides</item>
<item name="android:listPreferredItemPaddingStart">@dimen/setup_wizard_margin_sides</item>
<item name="android:windowAnimationStyle">@style/Animation.SetupWizard</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
<item name="android:windowSoftInputMode">adjustPan</item>
<item name="@*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
<item name="ic_menu_add">@drawable/ic_menu_add_dark</item>
<item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
@@ -53,14 +50,11 @@
<item name="@*android:errorColor">@color/setup_lock_pattern_view_error_color_dark</item>
</style>
<style name="SetupWizardTheme.Light" parent="android:Theme.Material.Light.NoActionBar">
<style name="SetupWizardTheme.Light" parent="SuwThemeMaterial.Light">
<item name="android:alertDialogTheme">@style/Theme.Light.WifiDialog</item>
<item name="android:colorAccent">@color/setup_wizard_color_accent_light</item>
<item name="android:listPreferredItemPaddingEnd">@dimen/setup_wizard_margin_sides</item>
<item name="android:listPreferredItemPaddingStart">@dimen/setup_wizard_margin_sides</item>
<item name="android:windowAnimationStyle">@style/Animation.SetupWizard</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
<item name="android:windowSoftInputMode">adjustPan</item>
<item name="@*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
<item name="ic_menu_add">@drawable/ic_menu_add_light</item>
<item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
@@ -77,13 +71,6 @@
<item name="@*android:errorColor">@color/setup_lock_pattern_view_error_color_light</item>
</style>
<style name="Animation.SetupWizard" parent="@android:style/Animation.Activity">
<item name="android:activityOpenEnterAnimation">@anim/slide_next_in</item>
<item name="android:activityOpenExitAnimation">@anim/slide_next_out</item>
<item name="android:activityCloseEnterAnimation">@anim/slide_back_in</item>
<item name="android:activityCloseExitAnimation">@anim/slide_back_out</item>
</style>
<style name="Theme.WifiDialog" parent="@*android:style/Theme.Material.Dialog.Alert">
<item name="android:windowSoftInputMode">adjustResize</item>
<item name="ic_menu_add">@drawable/ic_menu_add_dark</item>

View File

@@ -58,7 +58,7 @@ public class SetupChooseLockGeneric extends ChooseLockGeneric
@Override
public void onNavigationBarCreated(SetupWizardNavBar bar) {
SetupWizardUtils.setImmersiveMode(this, bar);
SetupWizardUtils.setImmersiveMode(this);
bar.getNextButton().setEnabled(false);
}

View File

@@ -17,6 +17,7 @@
package com.android.settings;
import com.android.setupwizard.navigationbar.SetupWizardNavBar;
import com.android.setupwizardlib.util.SystemBarHelper;
import android.app.Fragment;
import android.content.Context;
@@ -26,7 +27,6 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
/**
* Setup Wizard's version of ChooseLockPassword screen. It inherits the logic and basic structure
@@ -88,7 +88,7 @@ public class SetupChooseLockPassword extends ChooseLockPassword
@Override
public void onNavigationBarCreated(SetupWizardNavBar bar) {
mNavigationBar = bar;
SetupWizardUtils.setImmersiveMode(this, bar);
SetupWizardUtils.setImmersiveMode(this);
}
@Override
@@ -111,15 +111,14 @@ public class SetupChooseLockPassword extends ChooseLockPassword
}
}
public static class SetupChooseLockPasswordFragment extends ChooseLockPasswordFragment
implements View.OnApplyWindowInsetsListener {
public static class SetupChooseLockPasswordFragment extends ChooseLockPasswordFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.setup_template, container, false);
View scrollView = view.findViewById(R.id.bottom_scroll_view);
scrollView.setOnApplyWindowInsetsListener(this);
SystemBarHelper.setImeInsetView(scrollView);
ViewGroup setupContent = (ViewGroup) view.findViewById(R.id.setup_content);
inflater.inflate(R.layout.setup_choose_lock_password, setupContent, true);
return view;
@@ -151,20 +150,5 @@ public class SetupChooseLockPassword extends ChooseLockPassword
SetupChooseLockPassword activity = (SetupChooseLockPassword) getActivity();
activity.mNavigationBar.getNextButton().setText(text);
}
@Override
public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
SetupChooseLockPassword activity = (SetupChooseLockPassword) getActivity();
final int bottomMargin = Math.max(insets.getSystemWindowInsetBottom()
- activity.mNavigationBar.getView().getHeight(), 0);
ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
lp.setMargins(lp.leftMargin, lp.topMargin, lp.rightMargin, bottomMargin);
view.setLayoutParams(lp);
return insets.replaceSystemWindowInsets(
insets.getSystemWindowInsetLeft(),
insets.getSystemWindowInsetTop(),
insets.getSystemWindowInsetRight(),
0 /* bottom */);
}
}
}

View File

@@ -80,7 +80,7 @@ public class SetupChooseLockPattern extends ChooseLockPattern
@Override
public void onNavigationBarCreated(SetupWizardNavBar bar) {
mNavigationBar = bar;
SetupWizardUtils.setImmersiveMode(this, bar);
SetupWizardUtils.setImmersiveMode(this);
}
@Override

View File

@@ -68,7 +68,7 @@ public class SetupEncryptionInterstitial extends EncryptionInterstitial
@Override
public void onNavigationBarCreated(SetupWizardNavBar bar) {
SetupWizardUtils.setImmersiveMode(this, bar);
SetupWizardUtils.setImmersiveMode(this);
}
@Override

View File

@@ -66,7 +66,7 @@ public class SetupRedactionInterstitial extends RedactionInterstitial
@Override
public void onNavigationBarCreated(SetupWizardNavBar bar) {
SetupWizardUtils.setImmersiveMode(this, bar);
SetupWizardUtils.setImmersiveMode(this);
bar.getBackButton().setEnabled(false);
}

View File

@@ -17,43 +17,22 @@
package com.android.settings;
import com.android.settings.widget.SetupWizardIllustration;
import com.android.setupwizard.navigationbar.SetupWizardNavBar;
import com.android.setupwizardlib.util.SystemBarHelper;
import com.android.setupwizardlib.util.WizardManagerHelper;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
public class SetupWizardUtils {
private static final String TAG = "SetupWizardUtils";
public static final int DIALOG_IMMERSIVE_FLAGS = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
// Extra containing the resource name of the theme to be used
public static final String EXTRA_THEME = "theme";
public static final String THEME_HOLO = "holo";
public static final String THEME_HOLO_LIGHT = "holo_light";
public static final String THEME_MATERIAL = "material";
public static final String THEME_MATERIAL_LIGHT = "material_light";
public static final String THEME_MATERIAL_BLUE = "material_blue";
public static final String THEME_MATERIAL_BLUE_LIGHT = "material_blue_light";
public static final String EXTRA_USE_IMMERSIVE_MODE = "useImmersiveMode";
// From WizardManager (must match constants maintained there)
public static final String ACTION_NEXT = "com.android.wizard.NEXT";
public static final String EXTRA_SCRIPT_URI = "scriptUri";
public static final String EXTRA_ACTION_ID = "actionId";
public static final String EXTRA_RESULT_CODE = "com.android.setupwizard.ResultCode";
public static final int NEXT_REQUEST = 10000;
public static boolean isUsingWizardManager(Activity activity) {
@@ -68,21 +47,15 @@ public class SetupWizardUtils {
*/
public static void sendResultsToSetupWizard(Activity activity, int resultCode) {
final Intent intent = activity.getIntent();
final Intent nextIntent = new Intent(ACTION_NEXT);
nextIntent.putExtra(EXTRA_SCRIPT_URI, intent.getStringExtra(EXTRA_SCRIPT_URI));
nextIntent.putExtra(EXTRA_ACTION_ID, intent.getStringExtra(EXTRA_ACTION_ID));
nextIntent.putExtra(EXTRA_THEME, intent.getStringExtra(EXTRA_THEME));
nextIntent.putExtra(EXTRA_RESULT_CODE, resultCode);
final Intent nextIntent = WizardManagerHelper.getNextIntent(intent, resultCode);
activity.startActivityForResult(nextIntent, NEXT_REQUEST);
}
public static int getTheme(Intent intent) {
final String themeName = intent.getStringExtra(EXTRA_THEME);
if (THEME_HOLO.equalsIgnoreCase(themeName) || THEME_MATERIAL.equalsIgnoreCase(themeName)
|| THEME_MATERIAL_BLUE.equalsIgnoreCase(themeName)) {
return R.style.SetupWizardTheme;
} else {
if (WizardManagerHelper.isLightTheme(intent, true)) {
return R.style.SetupWizardTheme_Light;
} else {
return R.style.SetupWizardTheme;
}
}
@@ -90,25 +63,16 @@ public class SetupWizardUtils {
* Sets the immersive mode related flags based on the extra in the intent which started the
* activity.
*/
public static void setImmersiveMode(Activity activity, SetupWizardNavBar navBar) {
final boolean useImmersiveMode =
activity.getIntent().getBooleanExtra(EXTRA_USE_IMMERSIVE_MODE, false);
navBar.setUseImmersiveMode(useImmersiveMode);
public static void setImmersiveMode(Activity activity) {
final boolean useImmersiveMode = activity.getIntent().getBooleanExtra(
WizardManagerHelper.EXTRA_USE_IMMERSIVE_MODE, false);
if (useImmersiveMode) {
final Window window = activity.getWindow();
window.setNavigationBarColor(Color.TRANSPARENT);
window.setStatusBarColor(Color.TRANSPARENT);
SystemBarHelper.hideSystemBars(activity.getWindow());
}
}
public static void applyImmersiveFlags(final Dialog dialog) {
applyImmersiveFlags(dialog.getWindow(), DIALOG_IMMERSIVE_FLAGS);
}
private static void applyImmersiveFlags(final Window window, final int vis) {
WindowManager.LayoutParams attrs = window.getAttributes();
attrs.systemUiVisibility |= vis;
window.setAttributes(attrs);
SystemBarHelper.hideSystemBars(dialog);
}
public static TextView getHeader(Activity activity) {
@@ -124,9 +88,10 @@ public class SetupWizardUtils {
}
public static void copySetupExtras(Intent fromIntent, Intent toIntent) {
toIntent.putExtra(EXTRA_THEME, fromIntent.getStringExtra(EXTRA_THEME));
toIntent.putExtra(EXTRA_USE_IMMERSIVE_MODE,
fromIntent.getBooleanExtra(EXTRA_USE_IMMERSIVE_MODE, false));
toIntent.putExtra(WizardManagerHelper.EXTRA_THEME,
fromIntent.getStringExtra(WizardManagerHelper.EXTRA_THEME));
toIntent.putExtra(WizardManagerHelper.EXTRA_USE_IMMERSIVE_MODE,
fromIntent.getBooleanExtra(WizardManagerHelper.EXTRA_USE_IMMERSIVE_MODE, false));
}
public static void setIllustration(Activity activity, int asset) {

View File

@@ -212,7 +212,7 @@ public class WifiSetupActivity extends WifiPickerActivity
@Override
public void onNavigationBarCreated(final SetupWizardNavBar bar) {
mNavigationBar = bar;
SetupWizardUtils.setImmersiveMode(this, bar);
SetupWizardUtils.setImmersiveMode(this);
}
@Override