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

Modernize project #407

Merged
merged 7 commits into from
Aug 16, 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Prepend the changelog with this template on every release.
-->

## [Unreleased]
- Modernize project build files (#407)
- Enable edge to edge on sample app (#407)
- Add setDrawBehindStatusBar and setDrawBehindNavigationBar (#407)

## [1.13.3] - Released July 9, 2021
- Removed JCenter dependencies and updated other build dependencies (#388)
Expand Down
18 changes: 11 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
apply plugin: 'com.android.application'
plugins {
alias(libs.plugins.android.application)
}

android {
compileSdkVersion defCompileSdkVersion
namespace 'com.getkeepsafe.taptargetviewsample'
compileSdk libs.versions.compileSdk.get().toInteger()

defaultConfig {
applicationId 'com.getkeepsafe.taptargetviewsample'
minSdkVersion defMinSdkVersion
targetSdkVersion defCompileSdkVersion
minSdkVersion libs.versions.minSdk.get().toInteger()
targetSdkVersion libs.versions.compileSdk.get().toInteger()
versionCode 1
versionName '1.0'
}

buildTypes {
release {
minifyEnabled false
Expand All @@ -20,7 +24,7 @@ android {

dependencies {
implementation project(':taptargetview')
implementation "androidx.appcompat:appcompat:$defAppCompatVersion"
implementation "com.google.android.material:material:$defMaterialVersion"
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation libs.androidx.appcompat
implementation libs.material
implementation libs.stetho
}
14 changes: 8 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.getkeepsafe.taptargetviewsample">
package="com.getkeepsafe.taptargetviewsample">

<application
android:name=".SampleApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name=".SampleApplication">
<activity android:name=".MainActivity">
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;

import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.WindowCompat;

import android.text.SpannableString;
import android.text.style.StyleSpan;
import android.text.style.UnderlineSpan;
Expand All @@ -25,6 +28,7 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
setContentView(R.layout.activity_main);

final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
Expand Down
20 changes: 10 additions & 10 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand All @@ -16,30 +15,31 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:fitsSystemWindows="true"
android:theme="@style/Theme.AppCompat" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?attr/colorPrimary"
android:orientation="vertical"
android:padding="16dp"
android:background="?attr/colorPrimary">
android:padding="16dp">

<TextView
style="@style/TextAppearance.AppCompat.Subhead"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some place"
android:theme="@style/Theme.AppCompat"/>
android:theme="@style/Theme.AppCompat" />

<TextView
style="@style/TextAppearance.AppCompat.Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:text="Building"
android:theme="@style/Theme.AppCompat"/>
android:theme="@style/Theme.AppCompat" />

</LinearLayout>

Expand All @@ -48,10 +48,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_marginBottom="50dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
android:src="@drawable/ic_directions_car_black_24dp"/>
android:layout_marginRight="16dp"
android:layout_marginBottom="50dp"
android:src="@drawable/ic_directions_car_black_24dp" />

</FrameLayout>

Expand All @@ -60,6 +60,6 @@
style="@style/TextAppearance.AppCompat.Display1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"/>
android:padding="16dp" />

</LinearLayout>
13 changes: 13 additions & 0 deletions app/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>
35 changes: 5 additions & 30 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.17.0'
}
}

ext {
defAndroidXCoreVersion = '1.6.0'
defAndroidAnnotationVersion = '1.2.0'
defAppCompatVersion = '1.3.0'
defMaterialVersion = '1.4.0'
defCompileSdkVersion = 30
defMinSdkVersion = 14
}

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

task clean(type: Delete) {
delete rootProject.buildDir
}
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.mavenpublish) apply false
}
23 changes: 23 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[versions]
compileSdk = "30"
minSdk = "14"

androidGradlePlugin = "8.5.1"
androidxAnnotation = "1.2.0"
androidxAppcompat = "1.3.0"
androidxCore = "1.6.0"
material = "1.4.0"
mavenpublish = "0.29.0"
stetho = "1.5.0"

[libraries]
androidx-annotation = { group = "androidx.annotation", name = "annotation", version.ref = "androidxAnnotation" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppcompat" }
androidx-core = { group = "androidx.core", name = "core", version.ref = "androidxCore" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
stetho = { group = "com.facebook.stetho", name = "stetho", version.ref = "stetho" }

[plugins]
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
mavenpublish = { id = "com.vanniktech.maven.publish", version.ref = "mavenpublish" }
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Mon Jul 15 20:56:48 EDT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
16 changes: 16 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}

dependencyResolutionManagement {
repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
repositories {
google()
mavenCentral()
}
}

include ':app', ':taptargetview'
31 changes: 17 additions & 14 deletions taptargetview/build.gradle
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
apply plugin: 'com.android.library'
apply plugin: 'com.vanniktech.maven.publish'
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.mavenpublish)
}

android {
compileSdkVersion defCompileSdkVersion
namespace 'com.getkeepsafe.taptargetview'
compileSdk libs.versions.compileSdk.get().toInteger()

defaultConfig {
minSdkVersion defMinSdkVersion
targetSdkVersion defCompileSdkVersion
minSdkVersion libs.versions.minSdk.get().toInteger()
}
}

dependencies {
api "androidx.annotation:annotation:$defAndroidAnnotationVersion"
api "androidx.appcompat:appcompat:$defAppCompatVersion"
implementation "androidx.core:core:$defAndroidXCoreVersion"
api libs.androidx.annotation
api libs.androidx.appcompat
implementation libs.androidx.core
}

// build a jar with source files
task sourcesJar(type: Jar) {
tasks.register('sourcesJar', Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
archiveClassifier = 'sources'
}

task javadoc(type: Javadoc) {
failOnError false
tasks.register('javadoc', Javadoc) {
failOnError false
source = android.sourceSets.main.java.sourceFiles
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

// build a jar with javadoc
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
tasks.register('javadocJar', Jar) {
dependsOn javadoc
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public class TapTarget {
boolean transparentTarget = false;
float descriptionTextAlpha = 0.54f;

boolean drawBehindStatusBar = true;
boolean drawBehindNavigationBar = true;

/**
* Return a tap target for the overflow button from the given toolbar
* <p>
Expand Down Expand Up @@ -203,6 +206,18 @@ protected TapTarget(CharSequence title, @Nullable CharSequence description) {
this.description = description;
}

/** Specify whether the target should draw behind the status bar. */
public TapTarget setDrawBehindStatusBar(boolean drawBehindStatusBar) {
this.drawBehindStatusBar = drawBehindStatusBar;
return this;
}

/** Specify whether the target should draw behind the navigation bar. */
public TapTarget setDrawBehindNavigationBar(boolean drawBehindNavigationBar) {
this.drawBehindNavigationBar = drawBehindNavigationBar;
return this;
}

/** Specify whether the target should be transparent **/
public TapTarget transparentTarget(boolean transparent) {
this.transparentTarget = transparent;
Expand Down
Loading