Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Commit

Permalink
Merge pull request #13 from zeoflow/set-text-alignment
Browse files Browse the repository at this point in the history
created setTextAlignment method
  • Loading branch information
teogor authored Oct 7, 2020
2 parents 85b98be + b8469f2 commit 5d9ad20
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 17 deletions.
14 changes: 2 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,7 @@ ext {
buildToolsVersion = '30.0.1'
minSdkVersion = 21
targetSdkVersion = 30
versionCode = 2
versionName = "1.0.1"
versionCode = 3
versionName = "1.1.0"
ndk = "21.3.6528147"

ANNOTATIONS = 'org.jetbrains:annotations-java5:17.0.0'

IX_JAVA = 'com.github.akarnokd:ixjava:1.0.0'
COMMONS_IO = 'commons-io:commons-io:2.6'
GOOGLE_JAVA_FORMAT = 'com.google.googlejavaformat:google-java-format:1.6'
GSON = 'com.google.code.gson:gson:2.8.5'
JSON_UNIT = 'net.javacrumbs.json-unit:json-unit:2.0.0.RC1'

JUNIT = 'junit:junit:4.12'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.graphics.Color;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.Toast;

import androidx.annotation.NonNull;
Expand All @@ -13,6 +14,7 @@
import com.zeoflow.stylar.core.StylarTheme;
import com.zeoflow.stylar.view.StylarView;

import static com.zeoflow.stylar.view.StylarView.ALIGNMENT_LEFT;
import static com.zeoflow.utils.FileUtil.readFile;

public class MainActivity extends ActivityCore
Expand Down Expand Up @@ -48,9 +50,11 @@ public void configureTheme(@NonNull StylarTheme.Builder builder)
.build();
stylar.setMarkdown(accClosed);

stylar.setMarkdown(readFile(getAssets(), "content.txt", "\n\n"));
// stylarView.setTextAlignment(ALIGNMENT_LEFT);

logger(stylarView.getText());
// stylar.setMarkdown(readFile(getAssets(), "content.txt", "\n\n"));

// logger(stylarView.getText());

}

Expand Down
8 changes: 6 additions & 2 deletions stylar/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
POM_NAME=Stylar
POM_ARTIFACT_ID=stylar
POM_PACKAGING=aar
VERSION_NAME=1.0.1
VERSION_CODE=2

VERSION_NAME=1.1.0
VERSION_CODE=3
GROUP=com.zeoflow

POM_DESCRIPTION=An Android markdown library - it does not require WebView
POM_URL=https://github.com/zeoflow/stylar
POM_SCM_URL=https://github.com/zeoflow/stylar
Expand All @@ -14,7 +16,9 @@ POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=zeoflow
POM_DEVELOPER_NAME=ZeoFlow

org.gradle.daemon=true

NEXUS_USERNAME=
NEXUS_PASSWORD=
signing.keyId=
Expand Down
17 changes: 17 additions & 0 deletions stylar/src/main/java/com/zeoflow/stylar/view/StylarView.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ScrollView;
import android.widget.TextView;
Expand Down Expand Up @@ -69,6 +71,21 @@ public String getText()
return String.valueOf(this.mtvTextView.getText());
}

public static String ALIGNMENT_LEFT = "left";
public static String ALIGNMENT_CENTER = "center";
public static String ALIGNMENT_RIGHT = "right";

public void setTextAlignment(String alignment)
{
if (alignment.equals(ALIGNMENT_LEFT)) {
mtvTextView.setGravity(Gravity.START);
} else if (alignment.equals(ALIGNMENT_CENTER)) {
mtvTextView.setGravity(Gravity.CENTER);
} else if (alignment.equals(ALIGNMENT_RIGHT)) {
mtvTextView.setGravity(Gravity.END);
}
}

public TextView getMtvTextView()
{
return this.mtvTextView;
Expand Down
2 changes: 1 addition & 1 deletion stylar/src/main/res/layout/stylar_text_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
android:background="#ffffff"
android:fontFamily="@font/zeoflow_normal"
android:padding="5dp"
android:textAlignment="center" />
android:gravity="center" />
</LinearLayout>
</ScrollView>

0 comments on commit 5d9ad20

Please sign in to comment.