Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace AutofitTextView with android autosizing textview #182

Merged
merged 2 commits into from
Apr 10, 2024
Merged
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
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
16 changes: 0 additions & 16 deletions library/src/main/res/xml/dashboard_licenses.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,6 @@
limitations under the License.
</license>

<license name="Autofit TextView">
Copyright (c) 2014 Grantland Chew

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
</license>

<license name="TapTargetView">
Copyright (c) 2016 Keepsafe Software Inc.

Expand Down
Loading