Skip to content

Commit

Permalink
replace AutofitTextView with android autosizing textview
Browse files Browse the repository at this point in the history
  • Loading branch information
connyduck committed Mar 8, 2024
1 parent 263d6a4 commit 4569442
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ dependencies {
implementation 'com.afollestad.material-dialogs:commons:0.9.6.0'
implementation 'com.mikhaellopez:circularimageview:3.0.2'
implementation 'com.github.chrisbanes:PhotoView:1.3.1'
implementation 'me.grantland:autofittextview:0.2.1'
implementation 'com.github.KeepSafe:TapTargetView:1.9.1'
implementation 'com.github.sarsamurmu:AdaptiveIconBitmap:1.0.1'
implementation 'com.github.zixpo:recycler-fast-scroll:6add4dff39'
Expand Down
11 changes: 5 additions & 6 deletions library/src/main/java/candybar/lib/adapters/HomeAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import androidx.core.graphics.drawable.RoundedBitmapDrawable;
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;
import androidx.core.text.HtmlCompat;
import androidx.core.widget.TextViewCompat;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

Expand Down Expand Up @@ -78,7 +79,6 @@
import candybar.lib.utils.AsyncTaskBase;
import candybar.lib.utils.CandyBarGlideModule;
import candybar.lib.utils.views.HeaderView;
import me.grantland.widget.AutofitTextView;

/*
* CandyBar - Material Dashboard
Expand Down Expand Up @@ -182,7 +182,7 @@ public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {

contentViewHolder.title.setSingleLine(false);
contentViewHolder.title.setMaxLines(10);
contentViewHolder.title.setSizeToFit(false);
TextViewCompat.setAutoSizeTextTypeWithDefaults(contentViewHolder.title, TextViewCompat.AUTO_SIZE_TEXT_TYPE_NONE);
contentViewHolder.title.setGravity(Gravity.CENTER_VERTICAL);
contentViewHolder.title.setIncludeFontPadding(true);
contentViewHolder.title.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
Expand Down Expand Up @@ -288,13 +288,12 @@ public boolean onResourceReady(Bitmap bitmap, Object model, Target<Bitmap> targe
contentViewHolder.title.setVisibility(View.VISIBLE);
}

contentViewHolder.title.setSingleLine(true);
contentViewHolder.title.setMaxLines(1);
contentViewHolder.title.setLines(1);
contentViewHolder.title.setTextSize(TypedValue.COMPLEX_UNIT_PX,
mContext.getResources().getDimension(R.dimen.text_max_size));
contentViewHolder.title.setGravity(Gravity.END | Gravity.CENTER_VERTICAL);
contentViewHolder.title.setIncludeFontPadding(false);
contentViewHolder.title.setSizeToFit(true);
TextViewCompat.setAutoSizeTextTypeWithDefaults(contentViewHolder.title, TextViewCompat.AUTO_SIZE_TEXT_TYPE_UNIFORM);

contentViewHolder.subtitle.setGravity(Gravity.END | Gravity.CENTER_VERTICAL);
} else {
Expand Down Expand Up @@ -642,7 +641,7 @@ protected void postRun(boolean ok) {
private class ContentViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {

private final TextView subtitle;
private final AutofitTextView title;
private final TextView title;
private final ProgressBar progressBar;
private final boolean quickApply;

Expand Down
7 changes: 4 additions & 3 deletions library/src/main/res/layout/fragment_home_item_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@
android:layout_gravity="end"
android:visibility="gone" />

<me.grantland.widget.AutofitTextView
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="@dimen/button_margin"
android:gravity="center_vertical"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/text_max_size"
app:minTextSize="@dimen/text_content_title" />
android:textColor="?android:attr/textColorPrimary"
app:autoSizeMaxTextSize="@dimen/text_max_size"
app:autoSizeMinTextSize="@dimen/text_content_title" />

<TextView
android:id="@+id/subtitle"
Expand Down

0 comments on commit 4569442

Please sign in to comment.