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
21 changes: 8 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
compileSdkVersion 28

defaultConfig {
applicationId "com.viksaa.autofit.et"
minSdkVersion 14
targetSdkVersion 23
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
Expand All @@ -20,13 +19,9 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'

compile project(":lib")

/* ButterKnife */
compile 'com.jakewharton:butterknife:7.0.1'
implementation project(":lib")
testImplementation 'junit:junit:4.12'
implementation "androidx.appcompat:appcompat:1.1.0-rc01"
implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0-beta01"
implementation "com.google.android.material:material:1.1.0-alpha09"
}
57 changes: 42 additions & 15 deletions app/src/main/java/com/viksaa/autofit/et/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,51 @@
package com.viksaa.autofit.et;

import android.os.Bundle;
import android.support.design.widget.CoordinatorLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.SeekBar;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;

import com.autofit.et.lib.AutoFitEditText;
import com.autofit.et.lib.AutoFitEditTextUtil;

import butterknife.Bind;
import butterknife.ButterKnife;

public class MainActivity extends AppCompatActivity {

@Bind(R.id.toolbar)
Toolbar mToolbar;
@Bind(R.id.rET)
AutoFitEditText mAutoFitEditText;
@Bind(R.id.root)
CoordinatorLayout mRootView;
private Toolbar mToolbar;
private AutoFitEditText mAutoFitEditText;
private CoordinatorLayout mRootView;
private SeekBar mLetterSpacingSeekBar;
private SeekBar mLineSpacingSeekBar;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
setSupportActionBar(mToolbar);
mToolbar = findViewById(R.id.toolbar);
mAutoFitEditText = findViewById(R.id.rET);
mRootView = findViewById(R.id.root);
mLetterSpacingSeekBar = findViewById(R.id.letter_spacing_seek_bar);
mLineSpacingSeekBar = findViewById(R.id.line_spacing_seek_bar);

initAutoFitEditText();

mLineSpacingSeekBar.setOnSeekBarChangeListener(new SimpleOnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mAutoFitEditText.setLineSpacing(progress, 1f);
}
});

mLetterSpacingSeekBar.setOnSeekBarChangeListener(new SimpleOnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mAutoFitEditText.setLetterSpacing(progress/100f);
}
});
}


Expand All @@ -41,11 +56,11 @@ public void initAutoFitEditText() {
mAutoFitEditText.setFocusable(true);
mAutoFitEditText.setEnableSizeCache(false);
//might cause crash on some devices
mAutoFitEditText.setMovementMethod(null);
// mAutoFitEditText.setMovementMethod(null);
// can be added after layout inflation;
mAutoFitEditText.setMaxHeight(330);
//don't forget to add min text size programmatically
mAutoFitEditText.setMinTextSize(60f);
mAutoFitEditText.setMinTextSize(1f);

AutoFitEditTextUtil.setNormalization(this, mRootView, mAutoFitEditText);
}
Expand All @@ -64,4 +79,16 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
return super.onOptionsItemSelected(item);
}

private static abstract class SimpleOnSeekBarChangeListener implements SeekBar.OnSeekBarChangeListener {

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { }

@Override
public void onStartTrackingTouch(SeekBar seekBar) { }

@Override
public void onStopTrackingTouch(SeekBar seekBar) { }
}
}
14 changes: 7 additions & 7 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout
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:id="@+id/root"
Expand All @@ -8,21 +9,20 @@
android:fitsSystemWindows="true"
tools:context=".MainActivity">

<android.support.design.widget.AppBarLayout
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
android:background="?attr/colorPrimary" />

</android.support.design.widget.AppBarLayout>
</com.google.android.material.appbar.AppBarLayout>

<include layout="@layout/content_main" />


</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
35 changes: 29 additions & 6 deletions app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,47 @@
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="333dp"
android:layout_centerInParent="true"
android:background="@color/primary" >
android:layout_height="match_parent"
android:layout_above="@id/seek_bars_container">

<com.autofit.et.lib.AutoFitEditText
android:id="@+id/rET"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="@color/primary"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center_vertical|center_horizontal"
android:hint="@string/hint"
android:isScrollContainer="false"
android:inputType="textMultiLine|textNoSuggestions"
android:maxLength="240"
android:textColor="@android:color/white"
android:textColorHint="@android:color/white"
android:textSize="90sp" />
</FrameLayout>

<LinearLayout
android:id="@+id/seek_bars_container"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="24dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/letter_spacing"
android:layout_gravity="center_vertical"/>
<SeekBar
android:id="@+id/letter_spacing_seek_bar"
android:layout_width="match_parent"
android:layout_height="48dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/line_spacing"
android:layout_gravity="center_vertical"/>
<SeekBar
android:id="@+id/line_spacing_seek_bar"
android:layout_width="match_parent"
android:layout_height="48dp"/>
</LinearLayout>
</RelativeLayout>
6 changes: 3 additions & 3 deletions app/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<resources>>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<!-- <item name="windowNoTitle">true</item>-->
<!-- <item name="android:windowDrawsSystemBarBackgrounds">true</item>-->
<!-- <item name="android:statusBarColor">@android:color/transparent</item>-->
</style>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<color name="primary">#4CAF50</color>
<color name="primary_dark">#388E3C</color>
<color name="primary_light">#C8E6C9</color>
<color name="accent">#9E9E9E</color>
<color name="accent">#3F51B5</color>
<color name="primary_text">#212121</color>
<color name="secondary_text">#727272</color>
<color name="icons">#FFFFFF</color>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
<string name="action_settings">Settings</string>

<string name="hint">HINT</string>
<string name="letter_spacing">Letter Spacing:</string>
<string name="line_spacing">Line Spacing:</string>
</resources>
4 changes: 2 additions & 2 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<!-- <item name="windowNoTitle">true</item>-->
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
Expand Down
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.android.tools.build:gradle:3.5.0-rc01'

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

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand Down
16 changes: 9 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# 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.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

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
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
org.gradle.parallel=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
12 changes: 5 additions & 7 deletions lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
compileSdkVersion 28

defaultConfig {
minSdkVersion 14
targetSdkVersion 23
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
Expand All @@ -19,7 +18,6 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
testImplementation 'junit:junit:4.12'
implementation "androidx.appcompat:appcompat:1.1.0-rc01"
}
Loading