mirror of
https://github.com/helloworld1/FreeOTPPlus
synced 2025-10-06 00:23:07 +02:00
Upgrade to AGP 4.2.1 and embed dependency of text-drawable
This commit is contained in:
@@ -27,39 +27,37 @@ android {
|
||||
resValue("string", "app_name", "FreeOTP+")
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":token-images"))
|
||||
implementation("androidx.appcompat:appcompat:1.2.0")
|
||||
implementation(project(":text-drawable"))
|
||||
implementation("androidx.appcompat:appcompat:1.3.0")
|
||||
implementation("com.google.android.material:material:1.3.0")
|
||||
|
||||
|
||||
// Version 3.4.0 contains a crashing bug before api level 24
|
||||
implementation("com.google.zxing:core:3.3.3")
|
||||
implementation("com.google.code.gson:gson:2.8.6")
|
||||
implementation("com.github.bumptech.glide:glide:4.11.0")
|
||||
implementation("androidx.core:core-ktx:1.3.2")
|
||||
implementation("androidx.core:core-ktx:1.5.0")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9")
|
||||
implementation(kotlin("stdlib-jdk7", KotlinCompilerVersion.VERSION))
|
||||
implementation(kotlin("stdlib-jdk8", KotlinCompilerVersion.VERSION))
|
||||
implementation("com.google.dagger:dagger:2.28.3")
|
||||
implementation("com.google.dagger:dagger-android:2.28.3")
|
||||
implementation("com.google.dagger:dagger-android-support:2.28.3")
|
||||
implementation("androidx.camera:camera-core:1.0.0-rc04")
|
||||
implementation("androidx.camera:camera-camera2:1.0.0-rc04")
|
||||
implementation("androidx.camera:camera-lifecycle:1.0.0-rc04")
|
||||
implementation("androidx.camera:camera-view:1.0.0-alpha23")
|
||||
implementation("androidx.camera:camera-core:1.0.0")
|
||||
implementation("androidx.camera:camera-camera2:1.0.0")
|
||||
implementation("androidx.camera:camera-lifecycle:1.0.0")
|
||||
implementation("androidx.camera:camera-view:1.0.0-alpha24")
|
||||
implementation("androidx.biometric:biometric:1.1.0")
|
||||
implementation("com.amulyakhare:com.amulyakhare.textdrawable:1.0.1")
|
||||
|
||||
kapt("com.google.dagger:dagger-compiler:2.28.3")
|
||||
kapt("com.google.dagger:dagger-android-processor:2.28.3")
|
||||
|
@@ -1,18 +1,18 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath("com.android.tools.build:gradle:4.1.2")
|
||||
classpath(kotlin("gradle-plugin", version = "1.4.0"))
|
||||
classpath("com.android.tools.build:gradle:4.2.1")
|
||||
classpath(kotlin("gradle-plugin", version = "1.4.32"))
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
google()
|
||||
}
|
||||
}
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -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-6.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
|
||||
|
@@ -1,2 +1,3 @@
|
||||
include(":token-images")
|
||||
include(":app")
|
||||
include(":text-drawable")
|
||||
|
1
text-drawable/.gitignore
vendored
Normal file
1
text-drawable/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
43
text-drawable/build.gradle.kts
Normal file
43
text-drawable/build.gradle.kts
Normal file
@@ -0,0 +1,43 @@
|
||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
kotlin("android")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion(30)
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion(21)
|
||||
targetSdkVersion(30)
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles("consumer-rules.pro")
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
getByName("release") {
|
||||
isMinifyEnabled = false
|
||||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib-jdk8", KotlinCompilerVersion.VERSION))
|
||||
implementation("androidx.core:core-ktx:1.5.0")
|
||||
implementation("androidx.appcompat:appcompat:1.3.0")
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.2")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.3.0")
|
||||
}
|
0
text-drawable/consumer-rules.pro
Normal file
0
text-drawable/consumer-rules.pro
Normal file
21
text-drawable/proguard-rules.pro
vendored
Normal file
21
text-drawable/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
5
text-drawable/src/main/AndroidManifest.xml
Normal file
5
text-drawable/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.amulyakhare.textdrawable">
|
||||
|
||||
</manifest>
|
@@ -0,0 +1,316 @@
|
||||
package com.amulyakhare.textdrawable;
|
||||
|
||||
import android.graphics.*;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.graphics.drawable.shapes.OvalShape;
|
||||
import android.graphics.drawable.shapes.RectShape;
|
||||
import android.graphics.drawable.shapes.RoundRectShape;
|
||||
|
||||
/**
|
||||
* @author amulya
|
||||
* @datetime 14 Oct 2014, 3:53 PM
|
||||
*/
|
||||
public class TextDrawable extends ShapeDrawable {
|
||||
|
||||
private final Paint textPaint;
|
||||
private final Paint borderPaint;
|
||||
private static final float SHADE_FACTOR = 0.9f;
|
||||
private final String text;
|
||||
private final int color;
|
||||
private final RectShape shape;
|
||||
private final int height;
|
||||
private final int width;
|
||||
private final int fontSize;
|
||||
private final float radius;
|
||||
private final int borderThickness;
|
||||
|
||||
private TextDrawable(Builder builder) {
|
||||
super(builder.shape);
|
||||
|
||||
// shape properties
|
||||
shape = builder.shape;
|
||||
height = builder.height;
|
||||
width = builder.width;
|
||||
radius = builder.radius;
|
||||
|
||||
// text and color
|
||||
text = builder.toUpperCase ? builder.text.toUpperCase() : builder.text;
|
||||
color = builder.color;
|
||||
|
||||
// text paint settings
|
||||
fontSize = builder.fontSize;
|
||||
textPaint = new Paint();
|
||||
textPaint.setColor(builder.textColor);
|
||||
textPaint.setAntiAlias(true);
|
||||
textPaint.setFakeBoldText(builder.isBold);
|
||||
textPaint.setStyle(Paint.Style.FILL);
|
||||
textPaint.setTypeface(builder.font);
|
||||
textPaint.setTextAlign(Paint.Align.CENTER);
|
||||
textPaint.setStrokeWidth(builder.borderThickness);
|
||||
|
||||
// border paint settings
|
||||
borderThickness = builder.borderThickness;
|
||||
borderPaint = new Paint();
|
||||
borderPaint.setColor(getDarkerShade(color));
|
||||
borderPaint.setStyle(Paint.Style.STROKE);
|
||||
borderPaint.setStrokeWidth(borderThickness);
|
||||
|
||||
// drawable paint color
|
||||
Paint paint = getPaint();
|
||||
paint.setColor(color);
|
||||
|
||||
}
|
||||
|
||||
private int getDarkerShade(int color) {
|
||||
return Color.rgb((int)(SHADE_FACTOR * Color.red(color)),
|
||||
(int)(SHADE_FACTOR * Color.green(color)),
|
||||
(int)(SHADE_FACTOR * Color.blue(color)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
Rect r = getBounds();
|
||||
|
||||
|
||||
// draw border
|
||||
if (borderThickness > 0) {
|
||||
drawBorder(canvas);
|
||||
}
|
||||
|
||||
int count = canvas.save();
|
||||
canvas.translate(r.left, r.top);
|
||||
|
||||
// draw text
|
||||
int width = this.width < 0 ? r.width() : this.width;
|
||||
int height = this.height < 0 ? r.height() : this.height;
|
||||
int fontSize = this.fontSize < 0 ? (Math.min(width, height) / 2) : this.fontSize;
|
||||
textPaint.setTextSize(fontSize);
|
||||
canvas.drawText(text, width / 2, height / 2 - ((textPaint.descent() + textPaint.ascent()) / 2), textPaint);
|
||||
|
||||
canvas.restoreToCount(count);
|
||||
|
||||
}
|
||||
|
||||
private void drawBorder(Canvas canvas) {
|
||||
RectF rect = new RectF(getBounds());
|
||||
rect.inset(borderThickness/2, borderThickness/2);
|
||||
|
||||
if (shape instanceof OvalShape) {
|
||||
canvas.drawOval(rect, borderPaint);
|
||||
}
|
||||
else if (shape instanceof RoundRectShape) {
|
||||
canvas.drawRoundRect(rect, radius, radius, borderPaint);
|
||||
}
|
||||
else {
|
||||
canvas.drawRect(rect, borderPaint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
textPaint.setAlpha(alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
textPaint.setColorFilter(cf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return PixelFormat.TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public static IShapeBuilder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder implements IConfigBuilder, IShapeBuilder, IBuilder {
|
||||
|
||||
private String text;
|
||||
|
||||
private int color;
|
||||
|
||||
private int borderThickness;
|
||||
|
||||
private int width;
|
||||
|
||||
private int height;
|
||||
|
||||
private Typeface font;
|
||||
|
||||
private RectShape shape;
|
||||
|
||||
public int textColor;
|
||||
|
||||
private int fontSize;
|
||||
|
||||
private boolean isBold;
|
||||
|
||||
private boolean toUpperCase;
|
||||
|
||||
public float radius;
|
||||
|
||||
private Builder() {
|
||||
text = "";
|
||||
color = Color.GRAY;
|
||||
textColor = Color.WHITE;
|
||||
borderThickness = 0;
|
||||
width = -1;
|
||||
height = -1;
|
||||
shape = new RectShape();
|
||||
font = Typeface.create("sans-serif-light", Typeface.NORMAL);
|
||||
fontSize = -1;
|
||||
isBold = false;
|
||||
toUpperCase = false;
|
||||
}
|
||||
|
||||
public IConfigBuilder width(int width) {
|
||||
this.width = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IConfigBuilder height(int height) {
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IConfigBuilder textColor(int color) {
|
||||
this.textColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IConfigBuilder withBorder(int thickness) {
|
||||
this.borderThickness = thickness;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IConfigBuilder useFont(Typeface font) {
|
||||
this.font = font;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IConfigBuilder fontSize(int size) {
|
||||
this.fontSize = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IConfigBuilder bold() {
|
||||
this.isBold = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IConfigBuilder toUpperCase() {
|
||||
this.toUpperCase = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigBuilder beginConfig() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IShapeBuilder endConfig() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBuilder rect() {
|
||||
this.shape = new RectShape();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBuilder round() {
|
||||
this.shape = new OvalShape();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBuilder roundRect(int radius) {
|
||||
this.radius = radius;
|
||||
float[] radii = {radius, radius, radius, radius, radius, radius, radius, radius};
|
||||
this.shape = new RoundRectShape(radii, null, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextDrawable buildRect(String text, int color) {
|
||||
rect();
|
||||
return build(text, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextDrawable buildRoundRect(String text, int color, int radius) {
|
||||
roundRect(radius);
|
||||
return build(text, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextDrawable buildRound(String text, int color) {
|
||||
round();
|
||||
return build(text, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextDrawable build(String text, int color) {
|
||||
this.color = color;
|
||||
this.text = text;
|
||||
return new TextDrawable(this);
|
||||
}
|
||||
}
|
||||
|
||||
public interface IConfigBuilder {
|
||||
public IConfigBuilder width(int width);
|
||||
|
||||
public IConfigBuilder height(int height);
|
||||
|
||||
public IConfigBuilder textColor(int color);
|
||||
|
||||
public IConfigBuilder withBorder(int thickness);
|
||||
|
||||
public IConfigBuilder useFont(Typeface font);
|
||||
|
||||
public IConfigBuilder fontSize(int size);
|
||||
|
||||
public IConfigBuilder bold();
|
||||
|
||||
public IConfigBuilder toUpperCase();
|
||||
|
||||
public IShapeBuilder endConfig();
|
||||
}
|
||||
|
||||
public static interface IBuilder {
|
||||
|
||||
public TextDrawable build(String text, int color);
|
||||
}
|
||||
|
||||
public static interface IShapeBuilder {
|
||||
|
||||
public IConfigBuilder beginConfig();
|
||||
|
||||
public IBuilder rect();
|
||||
|
||||
public IBuilder round();
|
||||
|
||||
public IBuilder roundRect(int radius);
|
||||
|
||||
public TextDrawable buildRect(String text, int color);
|
||||
|
||||
public TextDrawable buildRoundRect(String text, int color, int radius);
|
||||
|
||||
public TextDrawable buildRound(String text, int color);
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
package com.amulyakhare.textdrawable.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author amulya
|
||||
* @datetime 14 Oct 2014, 5:20 PM
|
||||
*/
|
||||
public class ColorGenerator {
|
||||
|
||||
public static ColorGenerator DEFAULT;
|
||||
|
||||
public static ColorGenerator MATERIAL;
|
||||
|
||||
static {
|
||||
DEFAULT = create(Arrays.asList(
|
||||
0xfff16364,
|
||||
0xfff58559,
|
||||
0xfff9a43e,
|
||||
0xffe4c62e,
|
||||
0xff67bf74,
|
||||
0xff59a2be,
|
||||
0xff2093cd,
|
||||
0xffad62a7,
|
||||
0xff805781
|
||||
));
|
||||
MATERIAL = create(Arrays.asList(
|
||||
0xffe57373,
|
||||
0xfff06292,
|
||||
0xffba68c8,
|
||||
0xff9575cd,
|
||||
0xff7986cb,
|
||||
0xff64b5f6,
|
||||
0xff4fc3f7,
|
||||
0xff4dd0e1,
|
||||
0xff4db6ac,
|
||||
0xff81c784,
|
||||
0xffaed581,
|
||||
0xffff8a65,
|
||||
0xffd4e157,
|
||||
0xffffd54f,
|
||||
0xffffb74d,
|
||||
0xffa1887f,
|
||||
0xff90a4ae
|
||||
));
|
||||
}
|
||||
|
||||
private final List<Integer> mColors;
|
||||
private final Random mRandom;
|
||||
|
||||
public static ColorGenerator create(List<Integer> colorList) {
|
||||
return new ColorGenerator(colorList);
|
||||
}
|
||||
|
||||
private ColorGenerator(List<Integer> colorList) {
|
||||
mColors = colorList;
|
||||
mRandom = new Random(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public int getRandomColor() {
|
||||
return mColors.get(mRandom.nextInt(mColors.size()));
|
||||
}
|
||||
|
||||
public int getColor(Object key) {
|
||||
return mColors.get(Math.abs(key.hashCode()) % mColors.size());
|
||||
}
|
||||
}
|
@@ -3,7 +3,6 @@ import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
kotlin("android")
|
||||
kotlin("android.extensions")
|
||||
}
|
||||
|
||||
android {
|
||||
@@ -25,13 +24,20 @@ android {
|
||||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib-jdk7", KotlinCompilerVersion.VERSION))
|
||||
implementation("androidx.core:core-ktx:1.3.2")
|
||||
implementation("androidx.appcompat:appcompat:1.2.0")
|
||||
testImplementation("junit:junit:4.13.1")
|
||||
implementation(kotlin("stdlib-jdk8", KotlinCompilerVersion.VERSION))
|
||||
implementation("androidx.core:core-ktx:1.5.0")
|
||||
implementation("androidx.appcompat:appcompat:1.3.0")
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.2")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.3.0")
|
||||
}
|
@@ -1,5 +1,3 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.liberty.android.freeotp.token_images">
|
||||
|
||||
/
|
||||
</manifest>
|
Reference in New Issue
Block a user