Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Worked on the show tooltip in dialogfragment. Added example too. #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 11 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
compileSdkVersion project.COMPILE_SDK
Expand All @@ -15,6 +17,13 @@ android {

dependencies {
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.github.florent37:viewtooltip:1.1.8'
//implementation project(path: ':viewtooltip')
// implementation 'com.github.florent37:viewtooltip:1.1.8'
implementation "androidx.core:core-ktx:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation project(path: ':viewtooltip')
implementation 'com.android.support.constraint:constraint-layout:1.1.3'

}
repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package florent37.github.com.viewtooltip

import android.app.Dialog
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import androidx.fragment.app.DialogFragment
import com.github.florent37.viewtooltip.ViewTooltip

class DialogFragmentInfo : DialogFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val v = inflater.inflate(R.layout.dialog_fragment, container, false).also {


it.findViewById<Button>(R.id.top).setOnClickListener(View.OnClickListener {
ViewTooltip
.on(this, it.findViewById<Button>(R.id.top))
// .customView(customView)
.position(ViewTooltip.Position.TOP)
.arrowSourceMargin(0)
.arrowTargetMargin(0)
.text(resources.getString(R.string.lorem))
.clickToHide(true)
.autoHide(false, 0)
.animation(ViewTooltip.FadeTooltipAnimation(500))
.onDisplay(ViewTooltip.ListenerDisplay { Log.d("ViewTooltip", "onDisplay") })
.onHide({ Log.d("ViewTooltip", "onHide") })
.show()
})
}
return v
}

override fun getDialog(): Dialog {
return super.getDialog()
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ public void onClick(View v) {
.position(ViewTooltip.Position.TOP)
.text("bottomLeft bottomLeft bottomLeft")
.show();
DialogFragmentInfo d = new DialogFragmentInfo();
d.show(MainActivity.this.getSupportFragmentManager(), "");
}
});
}
Expand Down
24 changes: 24 additions & 0 deletions app/src/main/res/layout/dialog_fragment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"/>

<Button
android:id="@+id/top"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
buildscript {
ext.kotlin_version = '1.3.41'
repositories {
jcenter()
google()
Expand All @@ -7,6 +8,7 @@ buildscript {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand All @@ -20,7 +22,7 @@ allprojects {
ext{
COMPILE_SDK=28
TARGET_SDK=28
MIN_SDK = 14
MIN_SDK = 26
sourceCompatibilityVersion = JavaVersion.VERSION_1_8
targetCompatibilityVersion = JavaVersion.VERSION_1_8

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import androidx.fragment.app.Fragment;

import android.text.Html;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
Expand All @@ -39,9 +40,10 @@ public class ViewTooltip {
private View rootView;
private final View view;
private final TooltipView tooltip_view;

private MyContext myContext;
private ViewTooltip(MyContext myContext, View view) {
this.view = view;
this.myContext = myContext;
this.tooltip_view = new TooltipView(myContext.getContext());
final NestedScrollView scrollParent = findScrollParent(view);
if (scrollParent != null) {
Expand Down Expand Up @@ -164,8 +166,8 @@ public TooltipView show() {
if (activityContext != null && activityContext instanceof Activity) {
final ViewGroup decorView = rootView != null ?
(ViewGroup) rootView :
(ViewGroup) ((Activity) activityContext).getWindow().getDecorView();

// (ViewGroup) ((Activity) activityContext).getWindow().getDecorView();
(ViewGroup) myContext.getWindow().getDecorView();
view.postDelayed(new Runnable() {
@Override
public void run() {
Expand Down