Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.2.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -14,6 +15,7 @@ buildscript {

allprojects {
repositories {
google()
jcenter()
}
}
Expand All @@ -24,11 +26,11 @@ task clean(type: Delete) {

ext {
// sdk and tools
minSdkVersion = 9
targetSdkVersion = 25
compileSdkVersion = 25
buildToolsVersion = '25.0.2'
minSdkVersion = 14
targetSdkVersion = 26
compileSdkVersion = 26
buildToolsVersion = '27.0.3'

// dependencies versions
supportVersion = '25.3.0'
supportVersion = '27.1.1'
}
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true

#org.gradle.jvmargs=-DsocksProxyHost=127.0.0.1 -DsocksProxyPort=1086
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 Jun 20 19:22:06 CEST 2017
#Thu Jan 03 11:12:45 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
3 changes: 1 addition & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ ext {

android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion

defaultConfig {
minSdkVersion rootProject.minSdkVersion
Expand All @@ -25,7 +24,7 @@ android {
}

dependencies {
compile "com.android.support:appcompat-v7:$rootProject.supportVersion"
api "com.android.support:appcompat-v7:$rootProject.supportVersion"
}

// to generate release build use './gradlew clean build generateRelease'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.tolstykh.textviewrichdrawable;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatButton;
import android.util.AttributeSet;

Expand Down Expand Up @@ -70,4 +72,31 @@ public void setDrawableBottomVectorId(@DrawableRes int id) {
mRichDrawableHelper.setDrawableBottomVectorId(id);
mRichDrawableHelper.apply(this);
}


public void setDrawables(@Nullable Drawable left, @Nullable Drawable top, @Nullable Drawable right, @Nullable Drawable bottom) {
super.setCompoundDrawables(left, top, right, bottom);
mRichDrawableHelper.apply(this);
}

public void setLeftDrawable(@Nullable Drawable left) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(left, compoundDrawables[1], compoundDrawables[2], compoundDrawables[3]);
}

public void setRightDrawable(@Nullable Drawable right) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(compoundDrawables[0], compoundDrawables[1], right, compoundDrawables[3]);
}

public void setTopDrawable(@Nullable Drawable top) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(compoundDrawables[0], top, compoundDrawables[2], compoundDrawables[3]);
}

public void setBottomDrawable(@Nullable Drawable bottom) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(compoundDrawables[0], compoundDrawables[1], compoundDrawables[2], bottom);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.tolstykh.textviewrichdrawable;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatCheckBox;
import android.util.AttributeSet;

Expand Down Expand Up @@ -70,4 +72,31 @@ public void setDrawableBottomVectorId(@DrawableRes int id) {
mRichDrawableHelper.setDrawableTopVectorId(id);
mRichDrawableHelper.apply(this);
}


public void setDrawables(@Nullable Drawable left, @Nullable Drawable top, @Nullable Drawable right, @Nullable Drawable bottom) {
super.setCompoundDrawables(left, top, right, bottom);
mRichDrawableHelper.apply(this);
}

public void setLeftDrawable(@Nullable Drawable left) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(left, compoundDrawables[1], compoundDrawables[2], compoundDrawables[3]);
}

public void setRightDrawable(@Nullable Drawable right) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(compoundDrawables[0], compoundDrawables[1], right, compoundDrawables[3]);
}

public void setTopDrawable(@Nullable Drawable top) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(compoundDrawables[0], top, compoundDrawables[2], compoundDrawables[3]);
}

public void setBottomDrawable(@Nullable Drawable bottom) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(compoundDrawables[0], compoundDrawables[1], compoundDrawables[2], bottom);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.tolstykh.textviewrichdrawable;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatEditText;
import android.util.AttributeSet;

Expand Down Expand Up @@ -70,4 +72,31 @@ public void setDrawableBottomVectorId(@DrawableRes int id) {
mRichDrawableHelper.setDrawableBottomVectorId(id);
mRichDrawableHelper.apply(this);
}


public void setDrawables(@Nullable Drawable left, @Nullable Drawable top, @Nullable Drawable right, @Nullable Drawable bottom) {
super.setCompoundDrawables(left, top, right, bottom);
mRichDrawableHelper.apply(this);
}

public void setLeftDrawable(@Nullable Drawable left) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(left, compoundDrawables[1], compoundDrawables[2], compoundDrawables[3]);
}

public void setRightDrawable(@Nullable Drawable right) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(compoundDrawables[0], compoundDrawables[1], right, compoundDrawables[3]);
}

public void setTopDrawable(@Nullable Drawable top) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(compoundDrawables[0], top, compoundDrawables[2], compoundDrawables[3]);
}

public void setBottomDrawable(@Nullable Drawable bottom) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(compoundDrawables[0], compoundDrawables[1], compoundDrawables[2], bottom);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.tolstykh.textviewrichdrawable;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatRadioButton;
import android.util.AttributeSet;

Expand Down Expand Up @@ -70,4 +72,32 @@ public void setDrawableBottomVectorId(@DrawableRes int id) {
mRichDrawableHelper.setDrawableBottomVectorId(id);
mRichDrawableHelper.apply(this);
}



public void setDrawables(@Nullable Drawable left, @Nullable Drawable top, @Nullable Drawable right, @Nullable Drawable bottom) {
super.setCompoundDrawables(left, top, right, bottom);
mRichDrawableHelper.apply(this);
}

public void setLeftDrawable(@Nullable Drawable left) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(left, compoundDrawables[1], compoundDrawables[2], compoundDrawables[3]);
}

public void setRightDrawable(@Nullable Drawable right) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(compoundDrawables[0], compoundDrawables[1], right, compoundDrawables[3]);
}

public void setTopDrawable(@Nullable Drawable top) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(compoundDrawables[0], top, compoundDrawables[2], compoundDrawables[3]);
}

public void setBottomDrawable(@Nullable Drawable bottom) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(compoundDrawables[0], compoundDrawables[1], compoundDrawables[2], bottom);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.tolstykh.textviewrichdrawable;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;

Expand Down Expand Up @@ -70,4 +72,30 @@ public void setDrawableBottomVectorId(@DrawableRes int id) {
mRichDrawableHelper.setDrawableBottomVectorId(id);
mRichDrawableHelper.apply(this);
}


public void setDrawables(@Nullable Drawable left, @Nullable Drawable top, @Nullable Drawable right, @Nullable Drawable bottom) {
super.setCompoundDrawables(left, top, right, bottom);
mRichDrawableHelper.apply(this);
}

public void setLeftDrawable(@Nullable Drawable left) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(left, compoundDrawables[1], compoundDrawables[2], compoundDrawables[3]);
}

public void setRightDrawable(@Nullable Drawable right) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(compoundDrawables[0], compoundDrawables[1], right, compoundDrawables[3]);
}

public void setTopDrawable(@Nullable Drawable top) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(compoundDrawables[0], top, compoundDrawables[2], compoundDrawables[3]);
}

public void setBottomDrawable(@Nullable Drawable bottom) {
Drawable[] compoundDrawables = getCompoundDrawables();
setDrawables(compoundDrawables[0], compoundDrawables[1], compoundDrawables[2], bottom);
}
}
8 changes: 4 additions & 4 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion

defaultConfig {
applicationId "com.tolstykh.textviewrichdrawable"
Expand All @@ -26,7 +25,8 @@ android {
}

dependencies {
compile "com.android.support:appcompat-v7:$rootProject.supportVersion"
compile "com.android.support:design:$rootProject.supportVersion"
compile 'com.tolstykh.textviewrichdrawable:textview-rich-drawable:0.3.2'
implementation "com.android.support:appcompat-v7:$rootProject.supportVersion"
implementation "com.android.support:design:$rootProject.supportVersion"
// implementation 'com.tolstykh.textviewrichdrawable:textview-rich-drawable:0.3.2'
implementation project(path: ':library')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.tolstykh.textviewrichdrawable.example;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.tolstykh.textviewrichdrawable.R;
import com.tolstykh.textviewrichdrawable.TextViewRichDrawable;

/**
* * Created by rqg on 2019/1/3.
*/
public class ChangeRuntimeFragment extends Fragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.f_runtime_change, container, false);
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

final TextViewRichDrawable tvrd = view.findViewById(R.id.tv_demo);

view.findViewById(R.id.set_top).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tvrd.setTopDrawable(ContextCompat.getDrawable(getContext(), R.drawable.icon_shz_skrz));
}
});

view.findViewById(R.id.set_bottom).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tvrd.setBottomDrawable(ContextCompat.getDrawable(getContext(), R.drawable.icon_shz_skrz));
}
});

view.findViewById(R.id.set_left).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tvrd.setLeftDrawable(ContextCompat.getDrawable(getContext(), R.drawable.icon_shz_skrz));
}
});

view.findViewById(R.id.set_right).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tvrd.setRightDrawable(ContextCompat.getDrawable(getContext(), R.drawable.icon_shz_skrz));
}
});

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Fragment instantiateFragment() {
Fragment instantiateFragment() {
return SimpleFragment.newInstance(R.layout.f_controls_all);
}
},
RUNTIME_CHANGE(R.string.title_runtime_change) {
@Override
Fragment instantiateFragment() {
return new ChangeRuntimeFragment();
}
};

@StringRes
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions sample/src/main/res/drawable/bg_stroke_black.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="#000" />
</shape>
Loading