Skip to content

Commit

Permalink
Migrated to AndroidX
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Zawadzki authored and zawadz88 committed Nov 4, 2018
1 parent 17c78cd commit 3064401
Show file tree
Hide file tree
Showing 27 changed files with 118 additions and 105 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ jobs:
working_directory: ~/mpm

docker:
- image: circleci/android:api-27-alpha
- image: circleci/android:api-28-alpha

environment:
ANDROID_HOME: /opt/android/sdk
ANDROID_BUILD_TOOLS: 27.0.3
ANDROID_BUILD_TOOLS: 28.0.2

steps:
- checkout
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [3.0.0]
### Changed
- Migrated to AndroidX package structure (https://developer.android.com/topic/libraries/support-library/androidx-overview)
- Updated Kotlin to 1.2.71

## [2.2.0]
### Added
- A way to set custom vertical offsets via android:dropDownVerticalOffset and by setting Gravity.BOTTOM
Expand Down Expand Up @@ -57,6 +62,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
Initial release of the library.

[3.0.0]: https://github.com/zawadz88/MaterialPopupMenu/compare/2.2.0...3.0.0
[2.2.0]: https://github.com/zawadz88/MaterialPopupMenu/compare/2.1.0...2.2.0
[2.1.0]: https://github.com/zawadz88/MaterialPopupMenu/compare/2.0.0...2.1.0
[2.0.0]: https://github.com/zawadz88/MaterialPopupMenu/compare/1.4.2...2.0.0
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This library allows to create simple popup menus programmatically with a nice [t

## Download (from JCenter)
```groovy
implementation 'com.github.zawadz88.materialpopupmenu:material-popup-menu:2.2.0'
implementation 'com.github.zawadz88.materialpopupmenu:material-popup-menu:3.0.0'
```

## Getting started
Expand Down Expand Up @@ -194,7 +194,9 @@ You may now use this library with [React Native](https://github.com/facebook/rea
Kotlin is extremely easy to use if you already know Java.
Check out the [official documentation](https://kotlinlang.org/docs/reference/basic-syntax.html) - it's really great!

### I have not migrated to AndroidX. Can I use this library?
If you're still using legacy Android Support libraries you can use version 2.2.0. AndroidX is supported by default since 3.0.0.

## TODOs:
* add Espresso tests
* add item selection
* refactor measuring
29 changes: 16 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.KOTLIN_VERSION = '1.2.61'
ext.ANDROID_GRADLE_PLUGIN_VERSION = '3.1.2'
ext.DOKKA_VERSION = '0.9.16'
ext.KOTLIN_VERSION = '1.2.71'
ext.ANDROID_GRADLE_PLUGIN_VERSION = '3.2.0'
ext.DOKKA_VERSION = '0.9.17'
ext.BINTRAY_VERSION = '1.7.3'
repositories {
google()
Expand All @@ -29,18 +29,21 @@ allprojects {

configure(allprojects) {
ext {
ANDROID_MIN_SDK_VERSION = 16
ANDROID_TARGET_SDK_VERSION = 27
ANDROID_COMPILE_SDK_VERSION = 27
ANDROID_BUILD_TOOLS_VERSION = '27.0.3'
ANDROID_MIN_SDK_VERSION = 16
ANDROID_TARGET_SDK_VERSION = 28
ANDROID_COMPILE_SDK_VERSION = 28
ANDROID_BUILD_TOOLS_VERSION = '28.0.2'

ANDROID_SUPPORT_LIBRARY_VERSION = '27.1.1'
CONSTRAINT_LAYOUT_VERSION = '1.0.2'
BUTTERKNIFE_VERSION = '8.7.0'
ANDROIDX_CORE_VERSION = '1.0.0'
ANDROIDX_ANNOTATION_VERSION = '1.0.0'
ANDROIDX_APPCOMPAT_VERSION = '1.0.0'
ANDROIDX_RECYCLERVIEW_VERSION = '1.0.0'
ANDROIDX_CONSTRAINTLAYOUT_VERSION = '1.1.3'
BUTTERKNIFE_VERSION = '9.0.0-rc1'

JUNIT_VERSION = '4.12'
HAMCREST_VERSION = '1.3'
MOCKITO_KOTLIN_VERSION = '1.5.0'
JUNIT_VERSION = '4.12'
HAMCREST_VERSION = '1.3'
MOCKITO_KOTLIN_VERSION = '1.5.0'
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/material-popup-menu/alltypes/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h3>All Types</h3>
</tr>
<tr>
<td>
<a href="../android.support.v7.widget/-material-recycler-view-popup-window/index.html">android.support.v7.widget.MaterialRecyclerViewPopupWindow</a></td>
<a href="../androidx.appcompat.widget/-material-recycler-view-popup-window/index.html">androidx.appcompat.widget.MaterialRecyclerViewPopupWindow</a></td>
<td>
<p>A more Material version of <a href="#">ListPopupWindow</a> based on <a href="#">RecyclerView</a>.</p>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ <h3>Functions</h3>
<p><a href="on-bind-view-holder.html">onBindViewHolder</a></p>
</td>
<td>
<code><span class="keyword">open</span> <span class="keyword">fun </span><span class="identifier">onBindViewHolder</span><span class="symbol">(</span><span class="identifier" id="com.github.zawadz88.materialpopupmenu.internal.SectionedRecyclerViewAdapter$onBindViewHolder(android.support.v7.widget.RecyclerView.ViewHolder, kotlin.Int)/holder">holder</span><span class="symbol">:</span>&nbsp;<span class="identifier">ViewHolder</span><span class="symbol">, </span><span class="identifier" id="com.github.zawadz88.materialpopupmenu.internal.SectionedRecyclerViewAdapter$onBindViewHolder(android.support.v7.widget.RecyclerView.ViewHolder, kotlin.Int)/position">position</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html"><span class="identifier">Int</span></a><span class="symbol">)</span><span class="symbol">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html"><span class="identifier">Unit</span></a></code></td>
<code><span class="keyword">open</span> <span class="keyword">fun </span><span class="identifier">onBindViewHolder</span><span class="symbol">(</span><span class="identifier" id="com.github.zawadz88.materialpopupmenu.internal.SectionedRecyclerViewAdapter$onBindViewHolder(androidx.recyclerview.widget.RecyclerView.ViewHolder, kotlin.Int)/holder">holder</span><span class="symbol">:</span>&nbsp;<span class="identifier">ViewHolder</span><span class="symbol">, </span><span class="identifier" id="com.github.zawadz88.materialpopupmenu.internal.SectionedRecyclerViewAdapter$onBindViewHolder(androidx.recyclerview.widget.RecyclerView.ViewHolder, kotlin.Int)/position">position</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html"><span class="identifier">Int</span></a><span class="symbol">)</span><span class="symbol">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html"><span class="identifier">Unit</span></a></code></td>
</tr>
<tr>
<td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<a href="../../index.html">material-popup-menu</a>&nbsp;/&nbsp;<a href="../index.html">com.github.zawadz88.materialpopupmenu.internal</a>&nbsp;/&nbsp;<a href="index.html">SectionedRecyclerViewAdapter</a>&nbsp;/&nbsp;<a href="./on-bind-view-holder.html">onBindViewHolder</a><br/>
<br/>
<h1>onBindViewHolder</h1>
<a name="com.github.zawadz88.materialpopupmenu.internal.SectionedRecyclerViewAdapter$onBindViewHolder(android.support.v7.widget.RecyclerView.ViewHolder, kotlin.Int)"></a>
<code><span class="keyword">open</span> <span class="keyword">fun </span><span class="identifier">onBindViewHolder</span><span class="symbol">(</span><span class="identifier" id="com.github.zawadz88.materialpopupmenu.internal.SectionedRecyclerViewAdapter$onBindViewHolder(android.support.v7.widget.RecyclerView.ViewHolder, kotlin.Int)/holder">holder</span><span class="symbol">:</span>&nbsp;<span class="identifier">ViewHolder</span><span class="symbol">, </span><span class="identifier" id="com.github.zawadz88.materialpopupmenu.internal.SectionedRecyclerViewAdapter$onBindViewHolder(android.support.v7.widget.RecyclerView.ViewHolder, kotlin.Int)/position">position</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html"><span class="identifier">Int</span></a><span class="symbol">)</span><span class="symbol">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html"><span class="identifier">Unit</span></a></code>
<a name="com.github.zawadz88.materialpopupmenu.internal.SectionedRecyclerViewAdapter$onBindViewHolder(androidx.recyclerview.widget.RecyclerView.ViewHolder, kotlin.Int)"></a>
<code><span class="keyword">open</span> <span class="keyword">fun </span><span class="identifier">onBindViewHolder</span><span class="symbol">(</span><span class="identifier" id="com.github.zawadz88.materialpopupmenu.internal.SectionedRecyclerViewAdapter$onBindViewHolder(androidx.recyclerview.widget.RecyclerView.ViewHolder, kotlin.Int)/holder">holder</span><span class="symbol">:</span>&nbsp;<span class="identifier">ViewHolder</span><span class="symbol">, </span><span class="identifier" id="com.github.zawadz88.materialpopupmenu.internal.SectionedRecyclerViewAdapter$onBindViewHolder(androidx.recyclerview.widget.RecyclerView.ViewHolder, kotlin.Int)/position">position</span><span class="symbol">:</span>&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html"><span class="identifier">Int</span></a><span class="symbol">)</span><span class="symbol">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html"><span class="identifier">Unit</span></a></code>
</BODY>
</HTML>
2 changes: 1 addition & 1 deletion docs/material-popup-menu/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h3>Packages</h3>
<tbody>
<tr>
<td>
<p><a href="android.support.v7.widget/index.html">android.support.v7.widget</a></p>
<p><a href="androidx.appcompat.widget/index.html">androidx.appcompat.widget</a></p>
</td>
<td>
</td>
Expand Down
2 changes: 1 addition & 1 deletion docs/material-popup-menu/package-list
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$dokka.format:html
$dokka.linkExtension:html

android.support.v7.widget
androidx.appcompat.widget
com.github.zawadz88.materialpopupmenu
com.github.zawadz88.materialpopupmenu.internal
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
# org.gradle.parallel=true

android.builder.sdkDownload=true
android.enableJetifier=true
android.useAndroidX=true
org.gradle.configureondemand=false
8 changes: 4 additions & 4 deletions material-popup-menu/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
targetSdkVersion ANDROID_TARGET_SDK_VERSION
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {}
Expand All @@ -23,8 +23,8 @@ android {

dependencies {

api "com.android.support:appcompat-v7:$ANDROID_SUPPORT_LIBRARY_VERSION"
api "com.android.support:recyclerview-v7:$ANDROID_SUPPORT_LIBRARY_VERSION"
api "androidx.appcompat:appcompat:$ANDROIDX_APPCOMPAT_VERSION"
api "androidx.recyclerview:recyclerview:$ANDROIDX_RECYCLERVIEW_VERSION"

api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$KOTLIN_VERSION"

Expand Down Expand Up @@ -75,7 +75,7 @@ ext {
siteUrl = 'https://github.com/zawadz88/MaterialPopupMenu'
gitUrl = 'https://github.com/zawadz88/MaterialPopupMenu.git'

libraryVersion = '2.2.0'
libraryVersion = '3.0.0'

developerId = 'zawadz88'
developerName = 'Piotr Zawadzki'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package android.support.v7.widget
package androidx.appcompat.widget

import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Rect
import android.support.annotation.StyleRes
import android.support.v4.widget.PopupWindowCompat
import android.support.v7.view.ContextThemeWrapper
import android.util.Log
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.FrameLayout
import android.widget.PopupWindow
import androidx.annotation.StyleRes
import androidx.appcompat.view.ContextThemeWrapper
import androidx.core.widget.PopupWindowCompat
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.github.zawadz88.materialpopupmenu.R
import com.github.zawadz88.materialpopupmenu.internal.PopupMenuAdapter
import java.lang.reflect.Method
Expand Down Expand Up @@ -97,10 +99,10 @@ class MaterialRecyclerViewPopupWindow(
popupMinWidth = contextThemeWrapper.resources.getDimensionPixelSize(R.dimen.mpm_popup_menu_min_width)
popupWidthUnit = contextThemeWrapper.resources.getDimensionPixelSize(R.dimen.mpm_popup_menu_width_unit)

val a = context.obtainStyledAttributes(null, android.support.v7.appcompat.R.styleable.ListPopupWindow, 0, defStyleRes)
val a = context.obtainStyledAttributes(null, androidx.appcompat.R.styleable.ListPopupWindow, 0, defStyleRes)

dropDownHorizontalOffset = a.getDimensionPixelOffset(android.support.v7.appcompat.R.styleable.ListPopupWindow_android_dropDownHorizontalOffset, 0)
dropDownVerticalOffset = a.getDimensionPixelOffset(android.support.v7.appcompat.R.styleable.ListPopupWindow_android_dropDownVerticalOffset, 0)
dropDownHorizontalOffset = a.getDimensionPixelOffset(androidx.appcompat.R.styleable.ListPopupWindow_android_dropDownHorizontalOffset, 0)
dropDownVerticalOffset = a.getDimensionPixelOffset(androidx.appcompat.R.styleable.ListPopupWindow_android_dropDownVerticalOffset, 0)

a.recycle()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ package com.github.zawadz88.materialpopupmenu

import android.content.Context
import android.graphics.drawable.Drawable
import android.support.annotation.*
import android.support.v7.widget.MaterialRecyclerViewPopupWindow
import androidx.appcompat.widget.MaterialRecyclerViewPopupWindow
import android.view.View
import androidx.annotation.ColorInt
import androidx.annotation.DrawableRes
import androidx.annotation.LayoutRes
import androidx.annotation.StyleRes
import androidx.annotation.UiThread
import com.github.zawadz88.materialpopupmenu.internal.PopupMenuAdapter


Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.github.zawadz88.materialpopupmenu

import android.graphics.drawable.Drawable
import android.support.annotation.ColorInt
import android.support.annotation.DrawableRes
import android.support.annotation.LayoutRes
import android.view.Gravity
import android.view.View
import androidx.annotation.ColorInt
import androidx.annotation.DrawableRes
import androidx.annotation.LayoutRes

/**
* Builder for creating a [MaterialPopupMenu].
Expand Down Expand Up @@ -57,7 +57,7 @@ class MaterialPopupMenuBuilder {
* - see class description for validation details.
*/
fun build(): MaterialPopupMenu {
check(sectionHolderList.isNotEmpty(), { "Popup menu sections cannot be empty!" })
check(sectionHolderList.isNotEmpty()) { "Popup menu sections cannot be empty!" }

val sections = sectionHolderList.map { it.convertToPopupMenuSection() }

Expand Down Expand Up @@ -103,7 +103,7 @@ class MaterialPopupMenuBuilder {
}

internal fun convertToPopupMenuSection(): MaterialPopupMenu.PopupMenuSection {
check(itemsHolderList.isNotEmpty(), { "Section '$this' has no items!" })
check(itemsHolderList.isNotEmpty()) { "Section '$this' has no items!" }
return MaterialPopupMenu.PopupMenuSection(
title = title,
items = itemsHolderList.map { it.convertToPopupMenuItem() }
Expand Down Expand Up @@ -168,7 +168,7 @@ class MaterialPopupMenuBuilder {

override fun convertToPopupMenuItem(): MaterialPopupMenu.PopupMenuItem {
return MaterialPopupMenu.PopupMenuItem(
label = checkNotNull(label, { "Item '$this' does not have a label" }),
label = checkNotNull(label) { "Item '$this' does not have a label" },
labelColor = labelColor,
icon = icon,
iconDrawable = iconDrawable,
Expand Down Expand Up @@ -201,7 +201,7 @@ class MaterialPopupMenuBuilder {
}

override fun convertToPopupMenuItem(): MaterialPopupMenu.PopupMenuCustomItem {
check(layoutResId != 0, { "Layout resource ID must be set for a custom item!" })
check(layoutResId != 0) { "Layout resource ID must be set for a custom item!" }
return MaterialPopupMenu.PopupMenuCustomItem(
layoutResId = layoutResId,
viewBoundCallback = viewBoundCallback,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ package com.github.zawadz88.materialpopupmenu.internal
import android.annotation.SuppressLint
import android.content.Context
import android.content.res.ColorStateList
import android.support.annotation.StyleRes
import android.support.v7.view.ContextThemeWrapper
import android.support.v7.widget.AppCompatImageView
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.annotation.StyleRes
import androidx.appcompat.view.ContextThemeWrapper
import androidx.appcompat.widget.AppCompatImageView
import androidx.recyclerview.widget.RecyclerView
import com.github.zawadz88.materialpopupmenu.MaterialPopupMenu
import com.github.zawadz88.materialpopupmenu.R


/**
* RecyclerView adapter used for displaying popup menu items grouped in sections.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package com.github.zawadz88.materialpopupmenu.internal
* limitations under the License.
*/

import android.support.v7.widget.RecyclerView
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView

/**
* An extension to RecyclerView.Adapter to provide sections with headers to a
Expand Down Expand Up @@ -118,7 +118,6 @@ abstract class SectionedRecyclerViewAdapter<H : RecyclerView.ViewHolder, VH : Re
} else {
getSectionItemViewType(section, index)
}

}

@Suppress("UNUSED_PARAMETER")
Expand Down Expand Up @@ -180,5 +179,4 @@ abstract class SectionedRecyclerViewAdapter<H : RecyclerView.ViewHolder, VH : Re
internal const val TYPE_SECTION_HEADER = -1
internal const val TYPE_ITEM = -2
}

}
}
4 changes: 2 additions & 2 deletions material-popup-menu/src/main/res/layout/mpm_popup_menu.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="@dimen/mpm_popup_menu_vertical_padding"
android:paddingBottom="@dimen/mpm_popup_menu_vertical_padding"
tools:listitem="@layout/mpm_popup_menu_item" />
tools:listitem="@layout/mpm_popup_menu_item" />
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
tools:ignore="UseCompoundDrawables"
tools:theme="@style/Widget.MPM.Menu">

<android.support.v7.widget.AppCompatImageView
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/mpm_popup_menu_item_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -37,4 +37,4 @@
android:textSize="@dimen/mpm_popup_menu_item_label_text_size"
tools:text="Preview" />

</LinearLayout>
</LinearLayout>
Loading

0 comments on commit 3064401

Please sign in to comment.