Skip to content

Commit

Permalink
Update to final API 26.
Browse files Browse the repository at this point in the history
- Update to Gradle 4.0-rc-2
- Build Tools 26.0.0
- AGP 3.0.0-alpha3
- Support Library 26.0.0-beta2
- Fix collision with private attr (on foreground view)
  • Loading branch information
nickbutcher committed Jun 13, 2017
1 parent 02200e4 commit 53443f9
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 109 deletions.
12 changes: 5 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ def gitCommitCount = 100 +
Integer.parseInt('git rev-list --count HEAD'.execute([], project.rootDir).text.trim())

android {
compileSdkVersion 'android-O'
buildToolsVersion '26.0.0 rc1'
compileSdkVersion 26
buildToolsVersion '26.0.0'

defaultConfig {
applicationId "io.plaidapp"
minSdkVersion 21
targetSdkVersion 'O'
targetSdkVersion 26
versionCode gitCommitCount
versionName gitTag
archivesBaseName = "plaid"
Expand Down Expand Up @@ -63,12 +63,10 @@ android {

repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
google()
}

ext.supportLibVersion = '26.0.0-beta1'
ext.supportLibVersion = '26.0.0-beta2'
ext.retrofit2Version = '2.2.0'

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.Gravity;
import android.widget.LinearLayout;

import io.plaidapp.R;
Expand All @@ -32,12 +30,7 @@
*/
public class ForegroundLinearLayout extends LinearLayout {

private final Rect mSelfBounds = new Rect();
private final Rect mOverlayBounds = new Rect();
protected boolean mForegroundInPadding = true;
boolean mForegroundBoundsChanged = false;
private Drawable mForeground;
private int mForegroundGravity = Gravity.FILL;

public ForegroundLinearLayout(Context context) {
super(context);
Expand All @@ -52,59 +45,13 @@ public ForegroundLinearLayout(Context context, AttributeSet attrs, int defStyle)

TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundView,
defStyle, 0);

mForegroundGravity = a.getInt(
R.styleable.ForegroundView_android_foregroundGravity, mForegroundGravity);

final Drawable d = a.getDrawable(R.styleable.ForegroundView_android_foreground);
if (d != null) {
setForeground(d);
}

mForegroundInPadding = a.getBoolean(
R.styleable.ForegroundView_android_foregroundInsidePadding, true);

a.recycle();
}

/**
* Describes how the foreground is positioned.
*
* @return foreground gravity.
* @see #setForegroundGravity(int)
*/
public int getForegroundGravity() {
return mForegroundGravity;
}

/**
* Describes how the foreground is positioned. Defaults to START and TOP.
*
* @param foregroundGravity See {@link android.view.Gravity}
* @see #getForegroundGravity()
*/
public void setForegroundGravity(int foregroundGravity) {
if (mForegroundGravity != foregroundGravity) {
if ((foregroundGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) {
foregroundGravity |= Gravity.START;
}

if ((foregroundGravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) {
foregroundGravity |= Gravity.TOP;
}

mForegroundGravity = foregroundGravity;


if (mForegroundGravity == Gravity.FILL && mForeground != null) {
Rect padding = new Rect();
mForeground.getPadding(padding);
}

requestLayout();
}
}

@Override
protected boolean verifyDrawable(Drawable who) {
return super.verifyDrawable(who) || (who == mForeground);
Expand Down Expand Up @@ -157,10 +104,6 @@ public void setForeground(Drawable drawable) {
if (drawable.isStateful()) {
drawable.setState(getDrawableState());
}
if (mForegroundGravity == Gravity.FILL) {
Rect padding = new Rect();
drawable.getPadding(padding);
}
} else {
setWillNotDraw(true);
}
Expand All @@ -169,48 +112,19 @@ public void setForeground(Drawable drawable) {
}
}

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (changed) {
mForegroundBoundsChanged = true;
}
}

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mForegroundBoundsChanged = true;
if (mForeground != null) {
mForeground.setBounds(0, 0, w, h);
}
}

@Override
public void draw(Canvas canvas) {
super.draw(canvas);

if (mForeground != null) {
final Drawable foreground = mForeground;

if (mForegroundBoundsChanged) {
mForegroundBoundsChanged = false;
final Rect selfBounds = mSelfBounds;
final Rect overlayBounds = mOverlayBounds;

final int w = getRight() - getLeft();
final int h = getBottom() - getTop();

if (mForegroundInPadding) {
selfBounds.set(0, 0, w, h);
} else {
selfBounds.set(getPaddingLeft(), getPaddingTop(),
w - getPaddingRight(), h - getPaddingBottom());
}

Gravity.apply(mForegroundGravity, foreground.getIntrinsicWidth(),
foreground.getIntrinsicHeight(), selfBounds, overlayBounds);
foreground.setBounds(overlayBounds);
}

foreground.draw(canvas);
mForeground.draw(canvas);
}
}

Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values/attrs_foreground_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

<declare-styleable name="ForegroundView">
<attr name="android:foreground" />
<attr name="android:foregroundInsidePadding" />
<attr name="android:foregroundGravity" />
</declare-styleable>

</resources>
6 changes: 2 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
buildscript {

repositories {
maven {
url 'https://maven.google.com'
}
google()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
}

}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue May 23 15:23:19 BST 2017
#Mon Jun 12 11:28:19 BST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-rc-2-all.zip
12 changes: 8 additions & 4 deletions third_party/bypass/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 'android-O'
buildToolsVersion '26.0.0 rc1'
compileSdkVersion 26
buildToolsVersion '26.0.0'

defaultConfig {
minSdkVersion 8
targetSdkVersion 'O'
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
Expand All @@ -17,7 +17,11 @@ android {
}
}

repositories {
google()
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-annotations:25.3.0'
compile 'com.android.support:support-annotations:26.0.0-beta2'
}

0 comments on commit 53443f9

Please sign in to comment.