提交 a085da39 编写于 作者: T Takeshi Hagikura

Merge pull request #45 from google/lower_minsdk_to_9

Lower the minSdkVersion to 9.
......@@ -39,7 +39,10 @@ android {
dependencies {
compile project(":flexbox")
compile "com.android.support:support-v4:${rootProject.ext.supportLibVersion}"
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
compile "com.android.support:preference-v7:${rootProject.ext.supportLibVersion}"
compile "com.android.support:preference-v14:${rootProject.ext.supportLibVersion}"
compile "com.android.support:design:${rootProject.ext.supportLibVersion}"
testCompile "junit:junit:${rootProject.ext.junitVersion}"
......
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2016 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
......@@ -15,18 +14,21 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.apps.flexbox" >
xmlns:tools="http://schemas.android.com/tools"
package="com.google.android.apps.flexbox">
<uses-sdk tools:overrideLibrary="android.support.v14.preference" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" >
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......
......@@ -22,32 +22,31 @@ import com.google.android.apps.flexbox.validators.InputValidator;
import com.google.android.apps.flexbox.validators.IntegerInputValidator;
import com.google.android.apps.flexbox.validators.NonNegativeDecimalInputValidator;
import android.app.Activity;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.support.v4.app.FragmentActivity;
import android.support.v7.preference.EditTextPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat;
import android.widget.Toast;
public class SettingsActivity extends Activity {
public class SettingsActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Display the fragment as the main content.
getFragmentManager().beginTransaction().replace(android.R.id.content,
getSupportFragmentManager().beginTransaction().replace(android.R.id.content,
new SettingsFragment()).commit();
}
/**
* Fragment for settings.
*/
public static class SettingsFragment extends PreferenceFragment {
public static class SettingsFragment extends PreferenceFragmentCompat {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
public void onCreatePreferences(Bundle savedInstanceState, String s) {
addPreferencesFromResource(R.xml.new_flex_item_preferences);
EditTextPreference orderPreference = (EditTextPreference) findPreference(
......@@ -152,5 +151,6 @@ public class SettingsActivity extends Activity {
}
});
}
}
}
......@@ -21,8 +21,8 @@ limitations under the License.
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="@dimen/activity_horizontal_margin"
android:paddingEnd="@dimen/activity_horizontal_margin">
android:paddingEnd="@dimen/activity_horizontal_margin"
android:paddingStart="@dimen/activity_horizontal_margin">
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_order"
......@@ -33,10 +33,10 @@ limitations under the License.
android:id="@+id/edit_text_order"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:singleLine="true"
android:hint="@string/hint_order"
android:inputType="numberSigned"
android:hint="@string/hint_order" />
android:lines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
......@@ -48,10 +48,10 @@ limitations under the License.
android:id="@+id/edit_text_flex_grow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:singleLine="true"
android:hint="@string/hint_flex_grow"
android:inputType="numberDecimal"
android:hint="@string/hint_flex_grow" />
android:lines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
......@@ -63,10 +63,10 @@ limitations under the License.
android:id="@+id/edit_text_flex_shrink"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:singleLine="true"
android:hint="@string/hint_flex_shrink"
android:inputType="numberDecimal"
android:hint="@string/hint_flex_shrink" />
android:lines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
......@@ -78,10 +78,10 @@ limitations under the License.
android:id="@+id/edit_text_flex_basis_percent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:singleLine="true"
android:hint="@string/hint_flex_basis_percent"
android:inputType="numberSigned"
android:hint="@string/hint_flex_basis_percent" />
android:lines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
......@@ -93,10 +93,10 @@ limitations under the License.
android:id="@+id/edit_text_width"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:singleLine="true"
android:hint="@string/hint_width"
android:inputType="numberSigned"
android:hint="@string/hint_width" />
android:lines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
......@@ -108,10 +108,10 @@ limitations under the License.
android:id="@+id/edit_text_height"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:singleLine="true"
android:hint="@string/hint_height"
android:inputType="numberSigned"
android:hint="@string/hint_height" />
android:lines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<LinearLayout
......@@ -122,17 +122,17 @@ limitations under the License.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="@dimen/margin_tiny"
android:paddingLeft="@dimen/margin_tiny"
android:paddingEnd="@dimen/margin_tiny"
android:paddingLeft="@dimen/margin_tiny"
android:paddingRight="@dimen/margin_tiny"
android:paddingStart="@dimen/margin_tiny"
android:text="@string/hint_align_self" />
<Spinner
android:id="@+id/spinner_align_self"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end" />
</LinearLayout>
......@@ -140,11 +140,10 @@ limitations under the License.
android:id="@+id/button_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="horizontal"
android:paddingTop="@dimen/margin_small"
android:paddingBottom="@dimen/margin_small"
android:gravity="bottom"
style="?android:attr/buttonBarStyle">
android:paddingTop="@dimen/margin_small">
<View
android:id="@+id/spacer"
......@@ -155,14 +154,14 @@ limitations under the License.
<Button
android:id="@+id/button_cancel"
style="?android:attr/buttonBarStyle"
style="@style/DialogButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cancel" />
<Button
android:id="@+id/button_ok"
style="?android:attr/buttonBarStyle"
style="@style/DialogButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ok" />
......
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2016 Google Inc. All rights reserved.
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.
-->
<resources>
<style name="AppTheme" parent="AppThemeBase">
<!--
This is needed to make the app work with the preference-v7 library while keeping
material theme on API level 14+.
See http://stackoverflow.com/questions/32070670/preferencefragmentcompat-requires-preferencetheme-to-be-set
-->
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
</style>
</resources>
......@@ -21,4 +21,6 @@ limitations under the License.
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
<style name="DialogButton" parent="@android:style/Widget.Material.Button.Borderless.Colored" />
</resources>
......@@ -16,13 +16,16 @@ limitations under the License.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<style name="AppThemeBase" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme" parent="AppThemeBase">
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
......@@ -37,4 +40,5 @@ limitations under the License.
<item name="android:gravity">center</item>
</style>
<style name="DialogButton" />
</resources>
......@@ -30,7 +30,7 @@ buildscript {
}
ext {
minSdkVersion = 14
minSdkVersion = 9
targetSdkVersion = 23
compileSdkVersion = 23
buildToolsVersion = "23.0.3"
......
......@@ -359,7 +359,8 @@ public class FlexboxLayout extends ViewGroup {
getPaddingTop() + getPaddingBottom() + lp.topMargin
+ lp.bottomMargin, lp.height);
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
childState = combineMeasuredStates(childState, child.getMeasuredState());
childState = ViewCompat
.combineMeasuredStates(childState, ViewCompat.getMeasuredState(child));
largestHeightInRow = Math.max(largestHeightInRow,
child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin);
......@@ -501,7 +502,8 @@ public class FlexboxLayout extends ViewGroup {
getPaddingTop() + getPaddingBottom() + lp.topMargin
+ lp.bottomMargin, childHeight);
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
childState = combineMeasuredStates(childState, child.getMeasuredState());
childState = ViewCompat
.combineMeasuredStates(childState, ViewCompat.getMeasuredState(child));
largestWidthInColumn = Math.max(largestWidthInColumn,
child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin);
......@@ -1058,24 +1060,26 @@ public class FlexboxLayout extends ViewGroup {
switch (widthMode) {
case MeasureSpec.EXACTLY:
if (widthSize < calculatedMaxWidth) {
childState = combineMeasuredStates(childState, MEASURED_STATE_TOO_SMALL);
childState = ViewCompat
.combineMeasuredStates(childState, ViewCompat.MEASURED_STATE_TOO_SMALL);
}
widthSizeAndState = resolveSizeAndState(widthSize, widthMeasureSpec,
widthSizeAndState = ViewCompat.resolveSizeAndState(widthSize, widthMeasureSpec,
childState);
break;
case MeasureSpec.AT_MOST: {
if (widthSize < calculatedMaxWidth) {
childState = combineMeasuredStates(childState, MEASURED_STATE_TOO_SMALL);
childState = ViewCompat
.combineMeasuredStates(childState, ViewCompat.MEASURED_STATE_TOO_SMALL);
} else {
widthSize = calculatedMaxWidth;
}
widthSizeAndState = resolveSizeAndState(widthSize, widthMeasureSpec,
widthSizeAndState = ViewCompat.resolveSizeAndState(widthSize, widthMeasureSpec,
childState);
break;
}
case MeasureSpec.UNSPECIFIED: {
widthSizeAndState = resolveSizeAndState(calculatedMaxWidth, widthMeasureSpec,
childState);
widthSizeAndState = ViewCompat
.resolveSizeAndState(calculatedMaxWidth, widthMeasureSpec, childState);
break;
}
default:
......@@ -1085,25 +1089,27 @@ public class FlexboxLayout extends ViewGroup {
switch (heightMode) {
case MeasureSpec.EXACTLY:
if (heightSize < calculatedMaxHeight) {
childState = combineMeasuredStates(childState,
MEASURED_STATE_TOO_SMALL >> MEASURED_HEIGHT_STATE_SHIFT);
childState = ViewCompat.combineMeasuredStates(childState,
ViewCompat.MEASURED_STATE_TOO_SMALL
>> ViewCompat.MEASURED_HEIGHT_STATE_SHIFT);
}
heightSizeAndState = resolveSizeAndState(heightSize, heightMeasureSpec,
heightSizeAndState = ViewCompat.resolveSizeAndState(heightSize, heightMeasureSpec,
childState);
break;
case MeasureSpec.AT_MOST: {
if (heightSize < calculatedMaxHeight) {
childState = combineMeasuredStates(childState,
MEASURED_STATE_TOO_SMALL >> MEASURED_HEIGHT_STATE_SHIFT);
childState = ViewCompat.combineMeasuredStates(childState,
ViewCompat.MEASURED_STATE_TOO_SMALL
>> ViewCompat.MEASURED_HEIGHT_STATE_SHIFT);
} else {
heightSize = calculatedMaxHeight;
}
heightSizeAndState = resolveSizeAndState(heightSize, heightMeasureSpec,
heightSizeAndState = ViewCompat.resolveSizeAndState(heightSize, heightMeasureSpec,
childState);
break;
}
case MeasureSpec.UNSPECIFIED: {
heightSizeAndState = resolveSizeAndState(calculatedMaxHeight,
heightSizeAndState = ViewCompat.resolveSizeAndState(calculatedMaxHeight,
heightMeasureSpec, childState);
break;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册