forked from nickbutcher/plaid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better landscape / wide device support for DN story.
- Loading branch information
1 parent
3725d1d
commit bd64f9c
Showing
20 changed files
with
338 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
app/src/main/java/io/plaidapp/ui/widget/DynamicTypeTextView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright 2016 Google Inc. | ||
* | ||
* 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 io.plaidapp.ui.widget; | ||
|
||
import android.content.Context; | ||
import android.content.res.TypedArray; | ||
import android.util.AttributeSet; | ||
import android.util.TypedValue; | ||
|
||
import io.plaidapp.R; | ||
import io.plaidapp.util.ViewUtils; | ||
|
||
/** | ||
* An extension to {@link android.widget.TextView} which sizes text to grow up to a specified | ||
* maximum size, per the material spec: | ||
* https://www.google.com/design/spec/style/typography.html#typography-other-typographic-guidelines | ||
*/ | ||
public class DynamicTypeTextView extends BaselineGridTextView { | ||
|
||
// configurable attributes | ||
private final float minTextSize; | ||
private final float maxTextSize; | ||
|
||
public DynamicTypeTextView(Context context) { | ||
this(context, null); | ||
} | ||
|
||
public DynamicTypeTextView(Context context, AttributeSet attrs) { | ||
this(context, attrs, android.R.attr.textViewStyle); | ||
} | ||
|
||
public DynamicTypeTextView(Context context, AttributeSet attrs, int defStyleAttr) { | ||
this(context, attrs, defStyleAttr, 0); | ||
} | ||
|
||
public DynamicTypeTextView(Context context, AttributeSet attrs, | ||
int defStyleAttr, int defStyleRes) { | ||
super(context, attrs, defStyleAttr, defStyleRes); | ||
|
||
/* re-use CollapsingTitleLayout attribs */ | ||
final TypedArray a = | ||
context.obtainStyledAttributes(attrs, R.styleable.CollapsingTitleLayout); | ||
if (a.hasValue(R.styleable.CollapsingTitleLayout_collapsedTextSize)) { | ||
minTextSize = a.getDimensionPixelSize( | ||
R.styleable.CollapsingTitleLayout_collapsedTextSize, 0); | ||
setTextSize(TypedValue.COMPLEX_UNIT_PX, minTextSize); | ||
} else { | ||
// if not explicitly set then use the default text size as the min | ||
minTextSize = getTextSize(); | ||
} | ||
maxTextSize = a.getDimensionPixelSize( | ||
R.styleable.CollapsingTitleLayout_maxExpandedTextSize, Integer.MAX_VALUE); | ||
a.recycle(); | ||
} | ||
|
||
@Override | ||
protected void onSizeChanged(int w, int h, int oldw, int oldh) { | ||
super.onSizeChanged(w, h, oldw, oldh); | ||
final float expandedTitleTextSize = Math.max(minTextSize, | ||
ViewUtils.getSingleLineTextSize(getText().toString(), getPaint(), | ||
w - getPaddingStart() - getPaddingEnd(), | ||
minTextSize, | ||
maxTextSize, 0.5f, getResources().getDisplayMetrics())); | ||
setTextSize(TypedValue.COMPLEX_UNIT_PX, expandedTitleTextSize); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright 2016 Google Inc. | ||
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. | ||
--> | ||
|
||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<item android:state_activated="true"> | ||
|
||
<set android:ordering="together"> | ||
|
||
<objectAnimator | ||
android:propertyName="backgroundColor" | ||
android:valueFrom="@color/background_light" | ||
android:valueTo="@color/selected_comment_background" | ||
android:duration="@android:integer/config_shortAnimTime" | ||
android:valueType="colorType" /> | ||
|
||
<objectAnimator | ||
android:propertyName="translationZ" | ||
android:valueTo="@dimen/z_card" | ||
android:startOffset="300" | ||
android:duration="@android:integer/config_shortAnimTime" | ||
android:interpolator="@android:interpolator/fast_out_slow_in" /> | ||
|
||
</set> | ||
|
||
</item> | ||
|
||
<item> | ||
|
||
<set android:ordering="together"> | ||
|
||
<objectAnimator | ||
android:propertyName="backgroundColor" | ||
android:valueFrom="@color/selected_comment_background" | ||
android:valueTo="@color/background_light" | ||
android:duration="@android:integer/config_shortAnimTime" | ||
android:valueType="colorType" /> | ||
|
||
<objectAnimator | ||
android:propertyName="translationZ" | ||
android:valueTo="0dp" | ||
android:duration="@android:integer/config_shortAnimTime" | ||
android:interpolator="@android:interpolator/fast_out_slow_in" /> | ||
|
||
</set> | ||
|
||
</item> | ||
|
||
</selector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
app/src/main/res/layout-land/activity_designer_news_story.xml
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
app/src/main/res/layout-land/designer_news_story_title_toolbar.xml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.