Skip to content

Commit

Permalink
Migrate to AndroidX
Browse files Browse the repository at this point in the history
  • Loading branch information
manidevi-zuper committed Jul 26, 2022
1 parent 7a3f4e1 commit 91bf6d9
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

21 changes: 13 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
compileSdkVersion 31
defaultConfig {
applicationId "com.skyhope.showmoretext"
minSdkVersion 16
targetSdkVersion 28
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation project(':showmoretextview')
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.skyhope.showmoretext;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
11 changes: 9 additions & 2 deletions app/src/main/java/com/skyhope/showmoretext/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.skyhope.showmoretext;

import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import com.skyhope.showmoretextview.ShowMoreTextView;

Expand All @@ -25,6 +24,14 @@ protected void onCreate(Bundle savedInstanceState) {
textView.addShowMoreText("Continue");
textView.addShowLessText("Less");

textView.postDelayed(new Runnable() {
@Override
public void run() {
textView.setText("This is a very long note. This is a very long note. This is a very long note. This is a very long note. This is a very long note. This is a very long note. blah blah blah");
textView.setShowingLine(2);
}
}, 3000);


}
}
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
Expand All @@ -15,4 +15,4 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
58 changes: 45 additions & 13 deletions showmoretextview/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'

android {
compileSdkVersion 28

def zuperGroupId = "co.zuper.android"

android {
compileSdkVersion 31

defaultConfig {
minSdkVersion 16
targetSdkVersion 28
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

buildTypes {
Expand All @@ -22,14 +21,47 @@ android {
}
}

compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "com.android.support:design:28.0.0"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
// testImplementation 'junit:junit:4.12'
// androidTestImplementation 'androidx.test.ext:junit:1.1.1'
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}

task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}

publishing {
publications {
aar(MavenPublication) {
groupId zuperGroupId
artifactId archivesBaseName

// Tell maven to prepare the generated "*.aar" file for publishing
artifact("$buildDir/outputs/aar/${archivesBaseName}-release.aar")
artifact sourcesJar

// pom.withXml {
// def dependencies = asNode().appendNode('dependencies')
// configurations.getByName("releaseCompileClasspath").getResolvedConfiguration().getFirstLevelModuleDependencies().each {
// def dependency = dependencies.appendNode('dependency')
// dependency.appendNode('groupId', it.moduleGroup)
// dependency.appendNode('artifactId', it.moduleName)
// dependency.appendNode('version', it.moduleVersion)
// }
// }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.skyhope.showmoretextview;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import android.content.Context;
import android.graphics.Color;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextPaint;
Expand Down Expand Up @@ -83,7 +83,7 @@ private void addShowMore() {
@Override
public void onGlobalLayout() {
String text = getText().toString();
if (!isAlreadySet) {
if (!text.equals(mainText)) {
mainText = getText().toString();
isAlreadySet = true;
}
Expand All @@ -102,9 +102,8 @@ public void onGlobalLayout() {
SaveState.isCollapse = true;

setText(newText);
Log.d(TAG, "Text: " + newText);
// Log.d(TAG, "Text (chars): " + newText);
} else {

if (showingLine >= getLineCount()) {
try {
throw new Exception("Line Number cannot be exceed total line count");
Expand All @@ -124,8 +123,8 @@ public void onGlobalLayout() {
}

String newText = showingText.substring(0, showingText.length() - (dotdot.length() + showMore.length() + MAGIC_NUMBER));
Log.d(TAG, "Text: " + newText);
Log.d(TAG, "Text: " + showingText);
// Log.d(TAG, "Text (lines - new text): " + newText);
// Log.d(TAG, "Text (lines - showing text): " + showingText);
newText += dotdot + showMore;

SaveState.isCollapse = true;
Expand All @@ -145,7 +144,7 @@ public void onGlobalLayout() {
private void setShowMoreColoringAndClickable() {
final SpannableString spannableString = new SpannableString(getText());

Log.d(TAG, "Text: " + getText());
// Log.d(TAG, "Text: setShowMoreColoringAndClickable" + getText());
spannableString.setSpan(new ClickableSpan() {
@Override
public void updateDrawState(TextPaint ds) {
Expand All @@ -158,7 +157,7 @@ public void onClick(@Nullable View view) {
setText(mainText);
SaveState.isCollapse = false;
showLessButton();
Log.d(TAG, "Item clicked: " + mainText);
// Log.d(TAG, "Item clicked: " + mainText);

}
},
Expand All @@ -179,7 +178,7 @@ private void showLessButton() {
if (!getText().toString().endsWith(dotdot + showLess)) {
text = getText() + dotdot + showLess;
}

SpannableString spannableString = new SpannableString(text);

spannableString.setSpan(new ClickableSpan() {
Expand All @@ -195,7 +194,7 @@ public void onClick(@Nullable View view) {

addShowMore();

Log.d(TAG, "Item clicked: ");
// Log.d(TAG, "Item clicked: ");

}
},
Expand Down

0 comments on commit 91bf6d9

Please sign in to comment.