forked from commons-app/apps-android-commons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for issue commons-app#1224 showing complete notification on click
- Loading branch information
Showing
5 changed files
with
123 additions
and
24 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
app/src/main/java/fr/free/nrw/commons/notification/ExpandableTextView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package fr.free.nrw.commons.notification; | ||
|
||
/** | ||
* Created by jatin on 1/3/18. | ||
*/ | ||
|
||
import android.content.Context; | ||
import android.content.res.TypedArray; | ||
import android.text.SpannableStringBuilder; | ||
import android.util.AttributeSet; | ||
import android.view.View; | ||
|
||
import fr.free.nrw.commons.R; | ||
|
||
/** | ||
* User: Bazlur Rahman Rokon | ||
* Date: 9/7/13 - 3:33 AM | ||
*/ | ||
public class ExpandableTextView extends android.support.v7.widget.AppCompatTextView { | ||
private static final int DEFAULT_TRIM_LENGTH = 40; | ||
private static final String ELLIPSIS = "...More"; | ||
|
||
private CharSequence originalText; | ||
private CharSequence trimmedText; | ||
private BufferType bufferType; | ||
private boolean trim = true; | ||
private int trimLength; | ||
|
||
public ExpandableTextView(Context context) { | ||
this(context, null); | ||
} | ||
|
||
public ExpandableTextView(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
|
||
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ExpandableTextView); | ||
this.trimLength = typedArray.getInt(R.styleable.ExpandableTextView_trimLength, DEFAULT_TRIM_LENGTH); | ||
typedArray.recycle(); | ||
|
||
setOnClickListener(new OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
trim = !trim; | ||
setText(); | ||
requestFocusFromTouch(); | ||
} | ||
}); | ||
} | ||
|
||
private void setText() { | ||
super.setText(getDisplayableText(), bufferType); | ||
} | ||
|
||
private CharSequence getDisplayableText() { | ||
return trim ? trimmedText : originalText; | ||
} | ||
|
||
@Override | ||
public void setText(CharSequence text, BufferType type) { | ||
originalText = text; | ||
trimmedText = getTrimmedText(text); | ||
bufferType = type; | ||
setText(); | ||
} | ||
|
||
private CharSequence getTrimmedText(CharSequence text) { | ||
if (originalText != null && originalText.length() > trimLength) { | ||
return new SpannableStringBuilder(originalText, 0, trimLength + 1).append(ELLIPSIS); | ||
} else { | ||
return originalText; | ||
} | ||
} | ||
|
||
public CharSequence getOriginalText() { | ||
return originalText; | ||
} | ||
|
||
public void setTrimLength(int trimLength) { | ||
this.trimLength = trimLength; | ||
trimmedText = getTrimmedText(originalText); | ||
setText(); | ||
} | ||
|
||
public int getTrimLength() { | ||
return trimLength; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,29 @@ | ||
gradleVersion = 3.0.0 | ||
|
||
SUPPORT_LIB_VERSION = 26.0.2 | ||
|
||
compileSdkVersion = android-26 | ||
buildToolsVersion = 26.0.2 | ||
|
||
minSdkVersion = 15 | ||
|
||
targetSdkVersion = 25 | ||
## Project-wide Gradle settings. | ||
# | ||
# 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: -Xmx1024m -XX:MaxPermSize=256m | ||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 | ||
# | ||
# 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 | ||
#Thu Mar 01 15:28:48 IST 2018 | ||
systemProp.http.proxyPort=0 | ||
compileSdkVersion=android-26 | ||
android.useDeprecatedNdk=true | ||
|
||
# Library dependencies | ||
BUTTERKNIFE_VERSION=8.6.0 | ||
DAGGER_VERSION=2.13 | ||
LEAK_CANARY=1.5.4 | ||
org.gradle.jvmargs=-Xmx1536M | ||
|
||
#TODO: Temporary disabled. https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#aapt2 | ||
#Refer to PR: https://github.com/commons-app/apps-android-commons/pull/932 | ||
android.enableAapt2=false | ||
buildToolsVersion=26.0.2 | ||
targetSdkVersion=25 | ||
android.enableAapt2=false | ||
SUPPORT_LIB_VERSION=26.0.2 | ||
minSdkVersion=15 | ||
systemProp.http.proxyHost= | ||
LEAK_CANARY=1.5.4 | ||
DAGGER_VERSION=2.13 | ||
gradleVersion=3.0.0 |