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

Update project #104

Open
wants to merge 2 commits 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
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Add it in your root build.gradle at the end of repositories:
Add the dependency
```
dependencies {
implementation 'com.github.Yalantis:Context-Menu.Android:1.1.4'
implementation 'com.github.Yalantis:Context-Menu.Android:1.1.5'
}
```
#### 2. Create list of `MenuObject`, which consists of icon or icon and description.
Expand Down Expand Up @@ -185,6 +185,11 @@ To stay `Context Menu` below Status Bar set `fitSystemWindows` to true and `clip

# Changelog

### Version: 1.1.5

* updated library dependencies
* migrated to AndroidX

### Version: 1.1.4

* added background color animation
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
buildscript {
ext.kotlin_version = '1.3.20'
ext.kotlin_version = '1.7.10'

repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Expand Down
9 changes: 7 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

VERSION_NAME=1.1.0
VERSION_CODE=10
android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official

VERSION_NAME=1.1.5
VERSION_CODE=11
GROUP=com.yalantis

POM_DESCRIPTION=Android Library to display awesome context menu
Expand Down
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Jan 15 12:30:17 EET 2019
#Wed Sep 21 13:04:03 EEST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
zipStoreBase=GRADLE_USER_HOME
15 changes: 9 additions & 6 deletions lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
compileSdkVersion 33

defaultConfig {
minSdkVersion 19
targetSdkVersion 28
targetSdkVersion 33
versionCode Integer.parseInt(project.VERSION_CODE)
versionName VERSION_NAME
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

buildFeatures {
viewBinding true
}
}

Expand All @@ -23,5 +26,5 @@ dependencies {

implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "androidx.appcompat:appcompat:1.5.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ package com.yalantis.contextmenu.lib

import android.os.Bundle
import android.os.Handler
import android.support.v4.app.DialogFragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import androidx.fragment.app.DialogFragment
import com.yalantis.contextmenu.lib.databinding.FragmentMenuBinding
import com.yalantis.contextmenu.lib.extensions.backgroundColorAppear
import com.yalantis.contextmenu.lib.extensions.backgroundColorDisappear
import kotlinx.android.synthetic.main.fragment_menu.*

open class ContextMenuDialogFragment : DialogFragment() {

private lateinit var binding: FragmentMenuBinding
var menuItemClickListener: (view: View, position: Int) -> Unit = { _, _ -> }
var menuItemLongClickListener: (view: View, position: Int) -> Unit = { _, _ -> }

Expand All @@ -29,10 +30,14 @@ open class ContextMenuDialogFragment : DialogFragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = inflater.inflate(R.layout.fragment_menu, container, false)?.apply {
fitsSystemWindows = menuParams.isFitsSystemWindow
(this as ViewGroup).clipToPadding = menuParams.isClipToPadding
dialog.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
): View? {
binding = FragmentMenuBinding.inflate(layoutInflater, container, false)
binding.root.apply {
fitsSystemWindows = menuParams.isFitsSystemWindow
(this as ViewGroup).clipToPadding = menuParams.isClipToPadding
dialog?.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
}
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Expand All @@ -42,7 +47,7 @@ open class ContextMenuDialogFragment : DialogFragment() {
dropDownMenuAdapter.menuToggle()
}, menuParams.animationDelay)

wrapperView.apply {
binding.wrapperView.apply {
backgroundColorAppear(menuParams.backgroundColorAnimationDuration)
show(menuParams.gravity)

Expand All @@ -59,12 +64,12 @@ open class ContextMenuDialogFragment : DialogFragment() {
private fun initDropDownMenuAdapter() {
activity?.let {
dropDownMenuAdapter = MenuAdapter(
it,
wrapperView.wrapperButtons,
wrapperView.wrapperText,
menuParams.menuObjects,
menuParams.actionBarSize,
menuParams.gravity
it,
binding.wrapperView.wrapperButtons,
binding.wrapperView.wrapperText,
menuParams.menuObjects,
menuParams.actionBarSize,
menuParams.gravity
).apply {
setAnimationDuration(menuParams.animationDuration)

Expand All @@ -88,7 +93,7 @@ open class ContextMenuDialogFragment : DialogFragment() {
}

private fun close() {
wrapperView.backgroundColorDisappear(menuParams.backgroundColorAnimationDuration) {
binding.wrapperView.backgroundColorDisappear(menuParams.backgroundColorAnimationDuration) {
Handler().postDelayed({
dismissAllowingStateLoss()
}, menuParams.animationDelay)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.yalantis.contextmenu.lib

import android.content.Context
import android.support.v4.view.ViewCompat
import android.util.AttributeSet
import android.view.Gravity
import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.RelativeLayout
import android.widget.ScrollView
import androidx.core.view.ViewCompat
import com.yalantis.contextmenu.lib.extensions.getDimension

open class WrapperView @JvmOverloads constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import android.animation.Animator

internal fun Animator.onAnimationEnd(onAnimationEnd: (Animator?) -> Unit) {
this.addListener(object : Animator.AnimatorListener {
override fun onAnimationRepeat(animation: Animator?) {
override fun onAnimationRepeat(animation: Animator) {
// do nothing
}

override fun onAnimationEnd(animation: Animator?) {
override fun onAnimationEnd(animation: Animator) {
onAnimationEnd(animation)
}

override fun onAnimationCancel(animation: Animator?) {
override fun onAnimationCancel(animation: Animator) {
// do nothing
}

override fun onAnimationStart(animation: Animator?) {
override fun onAnimationStart(animation: Animator) {
// do nothing
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Build
import android.support.annotation.ColorRes
import android.support.annotation.DimenRes
import android.support.v4.content.ContextCompat
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.*
import androidx.annotation.ColorRes
import androidx.annotation.DimenRes
import androidx.core.content.ContextCompat
import com.yalantis.contextmenu.lib.MenuObject
import com.yalantis.contextmenu.lib.R

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.yalantis.contextmenu.lib.extensions
import android.animation.AnimatorSet
import android.animation.ArgbEvaluator
import android.animation.ObjectAnimator
import android.support.annotation.ColorRes
import android.view.View
import androidx.annotation.ColorRes
import com.yalantis.contextmenu.lib.MenuGravity
import com.yalantis.contextmenu.lib.R

Expand Down Expand Up @@ -93,9 +93,9 @@ internal fun View.fadeOutSet(x: Float, gravity: MenuGravity): AnimatorSet = Anim
}

internal fun View.colorAnimation(
duration: Long,
@ColorRes startColorResId: Int,
@ColorRes endColorResId: Int
duration: Long,
@ColorRes startColorResId: Int,
@ColorRes endColorResId: Int
): ObjectAnimator =
ObjectAnimator.ofObject(
this,
Expand Down
19 changes: 11 additions & 8 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
compileSdkVersion 33

defaultConfig {
applicationId "com.yalantis.contextmenu.sample"
minSdkVersion 19
targetSdkVersion 28
targetSdkVersion 33
versionCode Integer.parseInt(project.VERSION_CODE)
versionName VERSION_NAME
vectorDrawables.useSupportLibrary = true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

buildFeatures {
viewBinding true
}
}

Expand All @@ -25,8 +28,8 @@ dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "androidx.appcompat:appcompat:1.5.1"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"

implementation 'com.github.yalantis:context-menu.android:1.1.4'
implementation "com.github.yalantis:context-menu.android:1.1.4"
}
3 changes: 2 additions & 1 deletion sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
<activity
android:name=".sample.SampleActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
android:screenOrientation="portrait"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@ package com.yalantis.contextmenu.sample
import android.graphics.BitmapFactory
import android.graphics.drawable.BitmapDrawable
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.yalantis.contextmenu.R
import com.yalantis.contextmenu.databinding.ActivitySampleBinding
import com.yalantis.contextmenu.lib.ContextMenuDialogFragment
import com.yalantis.contextmenu.lib.MenuObject
import com.yalantis.contextmenu.lib.MenuParams
import kotlinx.android.synthetic.main.toolbar.*

class SampleActivity : AppCompatActivity() {

private val binding: ActivitySampleBinding by lazy { ActivitySampleBinding.inflate(layoutInflater) }
private lateinit var contextMenuDialogFragment: ContextMenuDialogFragment

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sample)
setContentView(binding.root)

initToolbar()
initMenuFragment()
Expand All @@ -30,12 +31,10 @@ class SampleActivity : AppCompatActivity() {
return true
}

override fun onOptionsItemSelected(item: MenuItem?): Boolean {
item?.let {
when (it.itemId) {
R.id.context_menu -> {
showContextMenuDialogFragment()
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.context_menu -> {
showContextMenuDialogFragment()
}
}

Expand All @@ -51,20 +50,20 @@ class SampleActivity : AppCompatActivity() {
}

private fun initToolbar() {
setSupportActionBar(toolbar)
setSupportActionBar(binding.toolbar.rootView)

supportActionBar?.apply {
setHomeButtonEnabled(true)
setDisplayHomeAsUpEnabled(true)
setDisplayShowTitleEnabled(false)
}

toolbar.apply {
binding.toolbar.rootView.apply {
setNavigationIcon(R.drawable.ic_arrow_back)
setNavigationOnClickListener { onBackPressed() }
}

tvToolbarTitle.text = "Samantha"
binding.toolbar.tvToolbarTitle.text = "Samantha"
}

/**
Expand Down
Loading