getItemList() {
135 | return itemList;
136 | }
137 |
138 | @Override
139 | public int getContentViewHeight() {
140 | int totalHeight = 0;
141 |
142 | for (int i = 0; i < getCount(); i++) {
143 | View view = getView(i, null, getListView());
144 | view.measure(
145 | View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
146 | View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
147 | totalHeight += view.getMeasuredHeight();
148 | }
149 |
150 | totalHeight += (getListView().getDividerHeight() * (getCount() - 1));
151 |
152 | ViewGroup.LayoutParams params = getListView().getLayoutParams();
153 | params.height = totalHeight;
154 | getListView().setLayoutParams(params);
155 |
156 | return totalHeight;
157 | }
158 |
159 | public void setPreference(String preferenceName) {
160 | this.preferenceName = preferenceName;
161 | }
162 |
163 | public String getPreferenceName() {
164 | return preferenceName;
165 | }
166 | }
167 |
--------------------------------------------------------------------------------
/powermenu/src/main/java/com/skydoves/powermenu/MenuListAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 skydoves (Jaewoong Eum)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.skydoves.powermenu;
18 |
19 | import android.content.Context;
20 | import android.content.res.ColorStateList;
21 | import android.graphics.Color;
22 | import android.graphics.Typeface;
23 | import android.view.Gravity;
24 | import android.view.LayoutInflater;
25 | import android.view.View;
26 | import android.view.ViewGroup;
27 | import android.widget.ImageView;
28 | import android.widget.ListView;
29 | import android.widget.TextView;
30 | import androidx.annotation.ColorInt;
31 | import androidx.core.widget.ImageViewCompat;
32 | import com.skydoves.powermenu.annotations.Dp;
33 | import com.skydoves.powermenu.annotations.Sp;
34 | import com.skydoves.powermenu.databinding.ItemPowerMenuLibrarySkydovesBinding;
35 |
36 | /**
37 | * MenuListAdapter extends {@link MenuBaseAdapter}.
38 | *
39 | * This is the {@link PowerMenu}'s default adapter.
40 | */
41 | public class MenuListAdapter extends MenuBaseAdapter implements IPowerMenuAdapter {
42 |
43 | @ColorInt private int textColor = -2;
44 | @ColorInt private int menuColor = -2;
45 | @ColorInt private int selectedTextColor = -2;
46 | @ColorInt private int selectedMenuColor = -2;
47 | @ColorInt private int iconColor = -2;
48 | @Sp private int textSize = 12;
49 | @Dp private int iconSize = 35;
50 | @Dp private int iconPadding = 7;
51 | private int textGravity = Gravity.START;
52 | private Typeface textTypeface = null;
53 |
54 | private boolean selectedEffect = true;
55 |
56 | public MenuListAdapter(ListView listView) {
57 | super(listView);
58 | }
59 |
60 | @Override
61 | public View getView(final int index, View view, ViewGroup viewGroup) {
62 | final Context context = viewGroup.getContext();
63 |
64 | if (view == null) {
65 | LayoutInflater inflater = LayoutInflater.from(context);
66 | view = ItemPowerMenuLibrarySkydovesBinding.inflate(inflater, viewGroup, false).getRoot();
67 | }
68 |
69 | PowerMenuItem powerMenuItem = (PowerMenuItem) getItem(index);
70 |
71 | final View background = view.findViewById(R.id.item_power_menu_layout);
72 | final TextView title = view.findViewById(R.id.item_power_menu_title);
73 | final ImageView icon = view.findViewById(R.id.item_power_menu_icon);
74 |
75 | title.setText(powerMenuItem.title);
76 | title.setTextSize(textSize);
77 | title.setGravity(textGravity);
78 |
79 | if (textTypeface != null) {
80 | title.setTypeface(textTypeface);
81 | }
82 |
83 | if (powerMenuItem.iconRes != 0 || powerMenuItem.icon != null) {
84 | icon.getLayoutParams().width = ConvertUtil.convertDpToPixel(iconSize, context);
85 | icon.getLayoutParams().height = ConvertUtil.convertDpToPixel(iconSize, context);
86 | if (powerMenuItem.iconRes != 0) {
87 | icon.setImageResource(powerMenuItem.iconRes);
88 | } else if (powerMenuItem.icon != null) {
89 | icon.setImageDrawable(powerMenuItem.icon);
90 | }
91 | if (iconColor != -2) {
92 | ImageViewCompat.setImageTintList(icon, ColorStateList.valueOf(iconColor));
93 | }
94 | if (icon.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
95 | ((ViewGroup.MarginLayoutParams) icon.getLayoutParams()).rightMargin =
96 | ConvertUtil.convertDpToPixel(iconPadding, context);
97 | }
98 | icon.setVisibility(View.VISIBLE);
99 | } else if (powerMenuItem.iconContentDescription != null) {
100 | icon.setContentDescription(powerMenuItem.iconContentDescription);
101 | } else {
102 | icon.setVisibility(View.GONE);
103 | }
104 |
105 | if (powerMenuItem.isSelected) {
106 |
107 | setSelectedPosition(index);
108 |
109 | if (selectedMenuColor == -2) {
110 | background.setBackgroundColor(Color.WHITE);
111 | } else {
112 | background.setBackgroundColor(selectedMenuColor);
113 | }
114 |
115 | if (selectedTextColor == -2) {
116 | title.setTextColor(ResourceUtil.getAccentColor(context));
117 | } else {
118 | title.setTextColor(selectedTextColor);
119 | }
120 | } else {
121 | if (menuColor == -2) {
122 | background.setBackgroundColor(Color.WHITE);
123 | } else {
124 | background.setBackgroundColor(menuColor);
125 | }
126 |
127 | if (textColor == -2) {
128 | title.setTextColor(Color.BLACK);
129 | } else {
130 | title.setTextColor(textColor);
131 | }
132 | }
133 | return super.getView(index, view, viewGroup);
134 | }
135 |
136 | @Override
137 | public void setSelectedPosition(int position) {
138 | super.setSelectedPosition(position);
139 |
140 | if (selectedEffect) {
141 | for (int i = 0; i < getItemList().size(); i++) {
142 | PowerMenuItem item = (PowerMenuItem) getItem(i);
143 | item.isSelected = i == position;
144 | }
145 | notifyDataSetChanged();
146 | }
147 | }
148 |
149 | @Override
150 | public void setTextColor(@ColorInt int color) {
151 | this.textColor = color;
152 | }
153 |
154 | @Override
155 | public void setMenuColor(@ColorInt int color) {
156 | this.menuColor = color;
157 | }
158 |
159 | @Override
160 | public void setSelectedTextColor(@ColorInt int color) {
161 | this.selectedTextColor = color;
162 | }
163 |
164 | @Override
165 | public void setSelectedMenuColor(@ColorInt int color) {
166 | this.selectedMenuColor = color;
167 | }
168 |
169 | @Override
170 | public void setSelectedEffect(boolean selectedEffect) {
171 | this.selectedEffect = selectedEffect;
172 | }
173 |
174 | @Override
175 | public void setTextSize(@Sp int size) {
176 | this.textSize = size;
177 | }
178 |
179 | @Override
180 | public void setIconSize(int iconSize) {
181 | this.iconSize = iconSize;
182 | }
183 |
184 | @Override
185 | public void setIconColor(int iconColor) {
186 | this.iconColor = iconColor;
187 | }
188 |
189 | @Override
190 | public void setIconPadding(int iconPadding) {
191 | this.iconPadding = iconPadding;
192 | }
193 |
194 | @Override
195 | public void setTextGravity(int gravity) {
196 | this.textGravity = gravity;
197 | }
198 |
199 | @Override
200 | public void setTextTypeface(Typeface typeface) {
201 | this.textTypeface = typeface;
202 | }
203 | }
204 |
--------------------------------------------------------------------------------
/powermenu/src/main/java/com/skydoves/powermenu/MenuPreferenceManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 skydoves (Jaewoong Eum)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.skydoves.powermenu;
18 |
19 | import android.content.Context;
20 | import android.content.SharedPreferences;
21 |
22 | @SuppressWarnings({"unused"})
23 | class MenuPreferenceManager {
24 |
25 | private static final String position = "_POSITION";
26 | private static MenuPreferenceManager menuPreferenceManager;
27 | private final SharedPreferences sharedPreferences;
28 |
29 | private MenuPreferenceManager(Context context) {
30 | sharedPreferences =
31 | context.getSharedPreferences("com.skydoves.powermenu", Context.MODE_PRIVATE);
32 | }
33 |
34 | /**
35 | * initialize the {@link MenuPreferenceManager} instance.
36 | *
37 | * @param context context.
38 | */
39 | protected static void initialize(Context context) {
40 | menuPreferenceManager = new MenuPreferenceManager(context);
41 | }
42 |
43 | /**
44 | * gets an instance of the {@link MenuPreferenceManager}.
45 | *
46 | * It must be called after invoking initialize() method.
47 | *
48 | * @return {@link MenuPreferenceManager}.
49 | */
50 | protected static MenuPreferenceManager getInstance() {
51 | return menuPreferenceManager;
52 | }
53 |
54 | /**
55 | * gets the saved menu position from preference.
56 | *
57 | * @param name preference name.
58 | * @param defaultPosition default preference menu position.
59 | * @return the saved menu position.
60 | */
61 | protected int getPosition(String name, int defaultPosition) {
62 | return sharedPreferences.getInt(name, defaultPosition);
63 | }
64 |
65 | /**
66 | * saves a menu position on preference.
67 | *
68 | * @param name preference name.
69 | * @param position preference menu position.
70 | */
71 | protected void setPosition(String name, int position) {
72 | sharedPreferences.edit().putInt(name, position).apply();
73 | }
74 |
75 | /**
76 | * clears the saved color from preference.
77 | *
78 | * @param name preference name.
79 | */
80 | protected void clearPosition(String name) {
81 | sharedPreferences.edit().remove(name).apply();
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/powermenu/src/main/java/com/skydoves/powermenu/OnDismissedListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 skydoves (Jaewoong Eum)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.skydoves.powermenu;
18 |
19 | /** OnDismissedListener is for listening to the dismissing of the popup menu. */
20 | public interface OnDismissedListener {
21 | /** invoked when the popup menu would be dismissed. */
22 | void onDismissed();
23 | }
24 |
--------------------------------------------------------------------------------
/powermenu/src/main/java/com/skydoves/powermenu/OnMenuItemClickListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 skydoves (Jaewoong Eum)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.skydoves.powermenu;
18 |
19 | /** OnMenuItemClickListener is for listening to the item click of the popup menu. */
20 | public interface OnMenuItemClickListener {
21 | /**
22 | * invoked when the popup menu item would be clicked.
23 | *
24 | * @param position the position of the item.
25 | * @param item the clicked item.
26 | */
27 | void onItemClick(int position, T item);
28 | }
29 |
--------------------------------------------------------------------------------
/powermenu/src/main/java/com/skydoves/powermenu/PowerMenuItem.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 skydoves (Jaewoong Eum)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.skydoves.powermenu
18 |
19 | import android.graphics.drawable.Drawable
20 | import androidx.annotation.DrawableRes
21 |
22 | /** PowerMenuItem is the item class for constructing the [PowerMenu]'s list. */
23 | public data class PowerMenuItem @JvmOverloads constructor(
24 | @JvmField public var title: CharSequence? = null,
25 | @JvmField public var isSelected: Boolean = false,
26 | @JvmField @DrawableRes
27 | public var iconRes: Int = 0,
28 | @JvmField public var icon: Drawable? = null,
29 | @JvmField public val iconContentDescription: CharSequence? = null,
30 | @JvmField public var tag: Any? = null,
31 | )
32 |
--------------------------------------------------------------------------------
/powermenu/src/main/java/com/skydoves/powermenu/ResourceUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 skydoves (Jaewoong Eum)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.skydoves.powermenu;
18 |
19 | import android.content.Context;
20 | import android.content.res.TypedArray;
21 | import android.util.TypedValue;
22 | import androidx.annotation.RestrictTo;
23 |
24 | @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
25 | class ResourceUtil {
26 |
27 | protected static int getAccentColor(Context context) {
28 | TypedValue typedValue = new TypedValue();
29 | TypedArray a =
30 | context.obtainStyledAttributes(
31 | typedValue.data, new int[] {androidx.appcompat.R.attr.colorAccent});
32 | int color = a.getColor(0, 0);
33 | a.recycle();
34 | return color;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/powermenu/src/main/java/com/skydoves/powermenu/annotations/Dp.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 skydoves (Jaewoong Eum)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.skydoves.powermenu.annotations
18 |
19 | import androidx.annotation.Dimension
20 |
21 | /**
22 | * Denotes that an integer parameter, field or method return value is expected
23 | * to represent a device independent pixel dimension.
24 | */
25 | @MustBeDocumented
26 | @Retention(AnnotationRetention.BINARY)
27 | @Target(
28 | AnnotationTarget.FUNCTION,
29 | AnnotationTarget.PROPERTY_GETTER,
30 | AnnotationTarget.PROPERTY_SETTER,
31 | AnnotationTarget.VALUE_PARAMETER,
32 | AnnotationTarget.FIELD,
33 | AnnotationTarget.LOCAL_VARIABLE,
34 | )
35 | @Dimension(unit = Dimension.DP)
36 | internal annotation class Dp
37 |
--------------------------------------------------------------------------------
/powermenu/src/main/java/com/skydoves/powermenu/annotations/Sp.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 skydoves (Jaewoong Eum)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.skydoves.powermenu.annotations
18 |
19 | import androidx.annotation.Dimension
20 |
21 | /**
22 | * Denotes that an integer parameter, field or method return value is expected
23 | * to represent a scale independent pixel dimension.
24 | */
25 | @MustBeDocumented
26 | @Retention(AnnotationRetention.BINARY)
27 | @Target(
28 | AnnotationTarget.FUNCTION,
29 | AnnotationTarget.PROPERTY_GETTER,
30 | AnnotationTarget.PROPERTY_SETTER,
31 | AnnotationTarget.VALUE_PARAMETER,
32 | AnnotationTarget.FIELD,
33 | AnnotationTarget.LOCAL_VARIABLE,
34 | )
35 | @Dimension(unit = Dimension.SP)
36 | internal annotation class Sp
37 |
--------------------------------------------------------------------------------
/powermenu/src/main/java/com/skydoves/powermenu/kotlin/ActivityPowerMenuLazy.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 skydoves (Jaewoong Eum)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.skydoves.powermenu.kotlin
18 |
19 | import android.content.Context
20 | import androidx.lifecycle.LifecycleOwner
21 | import com.skydoves.powermenu.PowerMenu
22 | import kotlin.reflect.KClass
23 |
24 | /**
25 | * An implementation of [Lazy] for creating an instance of the [PowerMenu] lazily in Activities.
26 | * Tied to the given [lifecycleOwner], [clazz].
27 | *
28 | * @param context A context for creating resources of the [PowerMenu] lazily.
29 | * @param lifecycleOwner A [LifecycleOwner] for dismissing automatically when the [LifecycleOwner] is being destroyed.
30 | * This will prevents memory leak: [Avoid Memory Leak](https://github.com/skydoves/powermenu#avoid-memory-leak).
31 | * @param clazz A [PowerMenu.Factory] kotlin class for creating a new instance of the PowerMenu.
32 | */
33 | @PublishedApi
34 | internal class ActivityPowerMenuLazy(
35 | private val context: Context,
36 | private val lifecycleOwner: LifecycleOwner,
37 | private val clazz: KClass,
38 | ) : Lazy {
39 |
40 | private var cached: PowerMenu? = null
41 |
42 | override val value: PowerMenu
43 | get() {
44 | var instance = cached
45 | if (instance === null) {
46 | val factory = clazz::java.get().newInstance()
47 | instance = factory.create(context, lifecycleOwner)
48 | cached = instance
49 | }
50 |
51 | return instance
52 | }
53 |
54 | override fun isInitialized(): Boolean = cached !== null
55 |
56 | override fun toString(): String =
57 | if (isInitialized()) value.toString() else "Lazy value not initialized yet."
58 | }
59 |
--------------------------------------------------------------------------------
/powermenu/src/main/java/com/skydoves/powermenu/kotlin/ContextExtensions.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 skydoves (Jaewoong Eum)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | @file:JvmName("ContextExt")
18 |
19 | package com.skydoves.powermenu.kotlin
20 |
21 | import android.app.Activity
22 | import android.content.Context
23 |
24 | /** returns if an Activity is finishing or not. */
25 | internal fun Context.isFinishing(): Boolean {
26 | return this is Activity && this.isFinishing
27 | }
28 |
--------------------------------------------------------------------------------
/powermenu/src/main/java/com/skydoves/powermenu/kotlin/FragmentPowerMenuLazy.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 skydoves (Jaewoong Eum)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.skydoves.powermenu.kotlin
18 |
19 | import androidx.fragment.app.Fragment
20 | import com.skydoves.powermenu.PowerMenu
21 | import kotlin.reflect.KClass
22 |
23 | /**
24 | * An implementation of [Lazy] for creating an instance of the [PowerMenu] in Fragments.
25 | * Tied to the given fragment's lifecycle and, [clazz].
26 | *
27 | * @param fragment An instance of the [PowerMenu] will be created in this Fragment lazily.
28 | * This will prevents memory leak: [Avoid Memory Leak](https://github.com/skydoves/powermenu#avoid-memory-leak).
29 | * @param clazz A [PowerMenu.Factory] kotlin class for creating a new instance of the PowerMenu.
30 | */
31 | @PublishedApi
32 | internal class FragmentPowerMenuLazy(
33 | private val fragment: Fragment,
34 | private val clazz: KClass,
35 | ) : Lazy {
36 |
37 | private var cached: PowerMenu? = null
38 |
39 | override val value: PowerMenu?
40 | get() {
41 | var instance = cached
42 | if (instance == null && fragment.context !== null) {
43 | val factory = clazz::java.get().newInstance()
44 | val lifecycle = if (fragment.view !== null) {
45 | fragment.viewLifecycleOwner
46 | } else {
47 | fragment
48 | }
49 | instance = factory.create(fragment.requireContext(), lifecycle)
50 | cached = instance
51 | }
52 |
53 | return instance
54 | }
55 |
56 | override fun isInitialized() = cached !== null
57 |
58 | override fun toString(): String =
59 | if (isInitialized()) value.toString() else "Lazy value not initialized yet."
60 | }
61 |
--------------------------------------------------------------------------------
/powermenu/src/main/java/com/skydoves/powermenu/kotlin/PowerMenuExtension.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 skydoves (Jaewoong Eum)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | @file:Suppress("SpellCheckingInspection", "unused")
18 |
19 | package com.skydoves.powermenu.kotlin
20 |
21 | import android.view.View
22 | import androidx.annotation.MainThread
23 | import com.skydoves.powermenu.AbstractPowerMenu
24 |
25 | /** showing the popup menu as drop down to the anchor. */
26 | public fun View.showAsDropDown(powerMenu: AbstractPowerMenu<*, *>) {
27 | powermenu { powerMenu.showAsDropDown(this) }
28 | }
29 |
30 | /** showing the popup menu as drop down to the anchor with x-off and y-off. */
31 | public fun View.showAsDropDown(powerMenu: AbstractPowerMenu<*, *>, xOff: Int, yOff: Int) {
32 | powermenu { powerMenu.showAsDropDown(this, xOff, yOff) }
33 | }
34 |
35 | /** showing the popup menu as left-top aligns to the anchor. */
36 | public fun View.showAsAnchorLeftTop(powerMenu: AbstractPowerMenu<*, *>) {
37 | powermenu { powerMenu.showAsAnchorLeftTop(this) }
38 | }
39 |
40 | /** showing the popup menu as left-top aligns to the anchor with x-off and y-off. */
41 | public fun View.showAsAnchorLeftTop(powerMenu: AbstractPowerMenu<*, *>, xOff: Int, yOff: Int) {
42 | powermenu { powerMenu.showAsAnchorLeftTop(this, xOff, yOff) }
43 | }
44 |
45 | /** showing the popup menu as left-bottom aligns to the anchor. */
46 | public fun View.showAsAnchorLeftBottom(powerMenu: AbstractPowerMenu<*, *>) {
47 | powermenu { powerMenu.showAsAnchorLeftBottom(this) }
48 | }
49 |
50 | /** showing the popup menu as left-bottom aligns to the anchor. */
51 | public fun View.showAsAnchorLeftBottom(powerMenu: AbstractPowerMenu<*, *>, xOff: Int, yOff: Int) {
52 | powermenu { powerMenu.showAsAnchorLeftBottom(this, xOff, yOff) }
53 | }
54 |
55 | /** showing the popup menu as right-top aligns to the anchor. */
56 | public fun View.showAsAnchorRightTop(powerMenu: AbstractPowerMenu<*, *>) {
57 | powermenu { powerMenu.showAsAnchorRightTop(this) }
58 | }
59 |
60 | /** showing the popup menu as right-top aligns to the anchor. */
61 | public fun View.showAsAnchorRightTop(powerMenu: AbstractPowerMenu<*, *>, xOff: Int, yOff: Int) {
62 | powermenu { powerMenu.showAsAnchorRightTop(this, xOff, yOff) }
63 | }
64 |
65 | /** showing the popup menu as right-bottom aligns to the anchor. */
66 | public fun View.showAsAnchorRightBottom(powerMenu: AbstractPowerMenu<*, *>) {
67 | powermenu { powerMenu.showAsAnchorRightBottom(this) }
68 | }
69 |
70 | /** showing the popup menu as right-bottom aligns to the anchor. */
71 | public fun View.showAsAnchorRightBottom(powerMenu: AbstractPowerMenu<*, *>, xOff: Int, yOff: Int) {
72 | powermenu { powerMenu.showAsAnchorRightBottom(this, xOff, yOff) }
73 | }
74 |
75 | /** showing the popup menu as center align to the anchor. */
76 | public fun View.showAsAnchorCenter(powerMenu: AbstractPowerMenu<*, *>) {
77 | powermenu { powerMenu.showAsAnchorRightBottom(this) }
78 | }
79 |
80 | /** showing the popup menu as center align to the anchor. */
81 | public fun View.showAsAnchorCenter(powerMenu: AbstractPowerMenu<*, *>, xOff: Int, yOff: Int) {
82 | powermenu { powerMenu.showAsAnchorCenter(this, xOff, yOff) }
83 | }
84 |
85 | /** showing the popup menu as center aligns to the anchor. */
86 | public fun View.showAtCenter(powerMenu: AbstractPowerMenu<*, *>) {
87 | powermenu { powerMenu.showAtCenter(this) }
88 | }
89 |
90 | /** showing the popup menu as center aligns to the anchor with x-off and y-off. */
91 | public fun View.showAtCenter(powerMenu: AbstractPowerMenu<*, *>, xOff: Int, yOff: Int) {
92 | powermenu { powerMenu.showAtCenter(this, xOff, yOff) }
93 | }
94 |
95 | /** showing the popup menu to the specific location to the anchor. */
96 | public fun View.showAtLocation(powerMenu: AbstractPowerMenu<*, *>, xOff: Int, yOff: Int) {
97 | powermenu { powerMenu.showAtLocation(this, xOff, yOff) }
98 | }
99 |
100 | /** showing the popup menu to the specific location to the anchor with {@link Gravity}. */
101 | public fun View.showAtLocation(
102 | powerMenu: AbstractPowerMenu<*, *>,
103 | gravity: Int,
104 | xOff: Int,
105 | yOff: Int,
106 | ) {
107 | powermenu { powerMenu.showAtLocation(this, gravity, xOff, yOff) }
108 | }
109 |
110 | @MainThread
111 | @JvmSynthetic
112 | internal inline fun View.powermenu(crossinline block: () -> Unit) {
113 | post { block() }
114 | }
115 |
--------------------------------------------------------------------------------
/powermenu/src/main/java/com/skydoves/powermenu/kotlin/PowerMenuKotlinDsl.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 skydoves (Jaewoong Eum)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | @file:Suppress("unused")
18 |
19 | package com.skydoves.powermenu.kotlin
20 |
21 | import android.content.Context
22 | import androidx.annotation.MainThread
23 | import com.skydoves.powermenu.PowerMenu
24 |
25 | @DslMarker
26 | internal annotation class PowerMenuDsl
27 |
28 | /** creates an instance of [PowerMenu] by [PowerMenu.Builder] using kotlin dsl. */
29 | @MainThread
30 | @PowerMenuDsl
31 | @JvmSynthetic
32 | public inline fun createPowerMenu(
33 | context: Context,
34 | crossinline block: PowerMenu.Builder.() -> Unit,
35 | ): PowerMenu =
36 | PowerMenu.Builder(context).apply(block).build()
37 |
--------------------------------------------------------------------------------
/powermenu/src/main/java/com/skydoves/powermenu/kotlin/PowerMenuLazyExtension.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 skydoves (Jaewoong Eum)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | @file:Suppress("unused")
18 |
19 | package com.skydoves.powermenu.kotlin
20 |
21 | import android.view.View
22 | import androidx.activity.ComponentActivity
23 | import androidx.annotation.MainThread
24 | import androidx.fragment.app.Fragment
25 | import com.skydoves.powermenu.PowerMenu
26 |
27 | /**
28 | * Returns a [Lazy] delegate to access the [ComponentActivity]'s PowerMenu property.
29 | * The PowerMenu property will be initialized lazily.
30 | *
31 | * @see [Lazy Initialization](https://github.com/skydoves/powermenu#lazy-initialization-in-kotlin)
32 | */
33 | @MainThread
34 | @JvmSynthetic
35 | public inline fun ComponentActivity.powerMenu(): Lazy {
36 | return ActivityPowerMenuLazy(this, this, T::class)
37 | }
38 |
39 | /**
40 | * Returns a [Lazy] delegate to access the [Fragment]'s PowerMenu property.
41 | * The PowerMenu property will be initialized lazily.
42 | *
43 | * @see [Lazy Initialization](https://github.com/skydoves/powermenu#lazy-initialization-in-kotlin)
44 | */
45 | @MainThread
46 | @JvmSynthetic
47 | public inline fun Fragment.powerMenu(): Lazy {
48 | return FragmentPowerMenuLazy(this, T::class)
49 | }
50 |
51 | /**
52 | * Returns a [Lazy] delegate to access the custom [View]'s PowerMenu property.
53 | * The PowerMenu property will be initialized lazily.
54 | *
55 | * @see [Lazy Initialization](https://github.com/skydoves/powermenu#lazy-initialization-in-kotlin)
56 | */
57 | @MainThread
58 | @JvmSynthetic
59 | public inline fun View.powerMenu(): Lazy {
60 | return ViewPowerMenuLazy(context, T::class)
61 | }
62 |
--------------------------------------------------------------------------------
/powermenu/src/main/java/com/skydoves/powermenu/kotlin/ViewPowerMenuLazy.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 skydoves (Jaewoong Eum)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.skydoves.powermenu.kotlin
18 |
19 | import android.content.Context
20 | import androidx.activity.ComponentActivity
21 | import com.skydoves.powermenu.PowerMenu
22 | import java.io.Serializable
23 | import kotlin.reflect.KClass
24 |
25 | /**
26 | * An implementation of [Lazy] for creating an instance of the [PowerMenu] lazily in Activities.
27 | * Tied to the given Activity's lifecycleOwner, [factory].
28 | *
29 | * @param context A context for creating resources of the [PowerMenu] lazily.
30 | * This will prevents memory leak: [Avoid Memory Leak](https://github.com/skydoves/powermenu#avoid-memory-leak).
31 | * @param factory A [PowerMenu.Factory] kotlin class for creating a new instance of the PowerMenu.
32 | */
33 | @PublishedApi
34 | internal class ViewPowerMenuLazy(
35 | private val context: Context,
36 | private val factory: KClass,
37 | ) : Lazy, Serializable {
38 |
39 | private var cached: PowerMenu? = null
40 |
41 | override val value: PowerMenu
42 | get() {
43 | var instance = cached
44 | if (instance === null) {
45 | if (context is ComponentActivity) {
46 | val factory = factory::java.get().newInstance()
47 | instance = factory.create(context, context)
48 | cached = instance
49 | } else {
50 | throw IllegalArgumentException(
51 | "PowerMenu can not be initialized. " +
52 | "The passed context is not an instance of the ComponentActivity.",
53 | )
54 | }
55 | }
56 |
57 | return instance
58 | }
59 |
60 | override fun isInitialized(): Boolean = cached !== null
61 |
62 | override fun toString(): String =
63 | if (isInitialized()) value.toString() else "Lazy value not initialized yet."
64 | }
65 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/anim/menu_elastic_bl.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
27 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/anim/menu_elastic_br.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
27 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/anim/menu_elastic_center.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
27 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/anim/menu_elastic_tl.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
27 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/anim/menu_elastic_tr.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
27 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/anim/menu_fade_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
23 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/anim/menu_fade_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
23 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/anim/menu_show_down_bl.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
26 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/anim/menu_show_down_br.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
26 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/anim/menu_show_down_center.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
26 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/anim/menu_show_down_tl.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
26 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/anim/menu_show_down_tr.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
26 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/anim/menu_show_up_bl.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
26 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/anim/menu_show_up_br.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
26 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/anim/menu_show_up_center.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
26 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/anim/menu_show_up_tl.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
26 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/anim/menu_show_up_tr.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
26 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/layout/item_power_menu_library_skydoves.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
28 |
29 |
37 |
38 |
48 |
49 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/layout/layout_material_power_menu_library_skydoves.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
21 |
22 |
28 |
29 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/layout/layout_power_background_library_skydoves.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
22 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/layout/layout_power_menu_library_skydoves.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
22 |
23 |
31 |
32 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/powermenu/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
23 |
24 |
28 |
29 |
33 |
34 |
38 |
39 |
43 |
44 |
48 |
49 |
53 |
54 |
58 |
59 |
63 |
64 |
68 |
69 |
73 |
74 |
--------------------------------------------------------------------------------
/scripts/publish-module.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'maven-publish'
2 | apply plugin: 'signing'
3 | apply plugin: 'org.jetbrains.dokka'
4 |
5 | task androidSourcesJar(type: Jar) {
6 | archiveClassifier.set('sources')
7 | if (project.plugins.findPlugin("com.android.library")) {
8 | from android.sourceSets.main.java.srcDirs
9 | from android.sourceSets.main.kotlin.srcDirs
10 | } else {
11 | from sourceSets.main.java.srcDirs
12 | from sourceSets.main.kotlin.srcDirs
13 | }
14 | }
15 |
16 | tasks.withType(dokkaHtmlPartial.getClass()).configureEach {
17 | pluginsMapConfiguration.set(
18 | ["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""]
19 | )
20 | }
21 |
22 | task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
23 | archiveClassifier.set('javadoc')
24 | from dokkaJavadoc.outputDirectory
25 | }
26 |
27 | artifacts {
28 | archives androidSourcesJar
29 | archives javadocJar
30 | }
31 |
32 | group = PUBLISH_GROUP_ID
33 | version = PUBLISH_VERSION
34 |
35 | afterEvaluate {
36 | publishing {
37 | publications {
38 | release(MavenPublication) {
39 | groupId PUBLISH_GROUP_ID
40 | artifactId PUBLISH_ARTIFACT_ID
41 | version PUBLISH_VERSION
42 | if (project.plugins.findPlugin("com.android.library")) {
43 | from components.release
44 | } else {
45 | from components.java
46 | }
47 |
48 | artifact androidSourcesJar
49 | artifact javadocJar
50 |
51 | pom {
52 | name = PUBLISH_ARTIFACT_ID
53 | description = 'Powerful and modernized popup menu with fully customizable.'
54 | url = 'https://github.com/skydoves/powermenu'
55 | licenses {
56 | license {
57 | name = 'The Apache Software License, Version 2.0'
58 | url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
59 | }
60 | }
61 | developers {
62 | developer {
63 | id = 'skydoves'
64 | name = 'Jaewoong Eum'
65 | email = "skydoves2@gmail.com"
66 | url = "https://github.com/skydoves"
67 | }
68 | }
69 | scm {
70 | connection = 'scm:git:github.com/skydoves/powermenu.git'
71 | developerConnection = 'scm:git:ssh://github.com/skydoves/powermenu.git'
72 | url = 'https://github.com/skydoves/powermenu/tree/main'
73 | }
74 | }
75 | }
76 | }
77 | }
78 | }
79 |
80 | signing {
81 | useInMemoryPgpKeys(
82 | rootProject.ext["signing.keyId"],
83 | rootProject.ext["signing.key"],
84 | rootProject.ext["signing.password"],
85 | )
86 | sign publishing.publications
87 | }
88 |
--------------------------------------------------------------------------------
/scripts/publish-root.gradle:
--------------------------------------------------------------------------------
1 | import com.skydoves.powermenu.Configuration
2 |
3 | // Create variables with empty default values
4 | ext["ossrhUsername"] = ''
5 | ext["ossrhPassword"] = ''
6 | ext["sonatypeStagingProfileId"] = ''
7 | ext["signing.keyId"] = ''
8 | ext["signing.password"] = ''
9 | ext["signing.key"] = ''
10 | ext["snapshot"] = ''
11 |
12 | File secretPropsFile = project.rootProject.file('local.properties')
13 | if (secretPropsFile.exists()) {
14 | // Read local.properties file first if it exists
15 | Properties p = new Properties()
16 | new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
17 | p.each { name, value -> ext[name] = value }
18 | } else {
19 | // Use system environment variables
20 | ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
21 | ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
22 | ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
23 | ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
24 | ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
25 | ext["signing.key"] = System.getenv('SIGNING_KEY')
26 | ext["snapshot"] = System.getenv('SNAPSHOT')
27 | }
28 |
29 | if (snapshot) {
30 | ext["rootVersionName"] = Configuration.snapshotVersionName
31 | } else {
32 | ext["rootVersionName"] = Configuration.versionName
33 | }
34 |
35 | // Set up Sonatype repository
36 | nexusPublishing {
37 | repositories {
38 | sonatype {
39 | stagingProfileId = sonatypeStagingProfileId
40 | username = ossrhUsername
41 | password = ossrhPassword
42 | version = rootVersionName
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':powermenu'
2 |
--------------------------------------------------------------------------------
/spotless/spotless.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.diffplug.spotless"
2 | spotless {
3 | java {
4 | target "**/*.java"
5 | trimTrailingWhitespace()
6 | removeUnusedImports()
7 | licenseHeaderFile "$rootDir/spotless/spotless.license.java"
8 | googleJavaFormat()
9 | endWithNewline()
10 | }
11 | kotlin {
12 | target "**/*.kt"
13 | ktlint().setUseExperimental(true).editorConfigOverride(['indent_size': '2', 'continuation_indent_size': '2'])
14 | licenseHeaderFile "$rootDir/spotless/spotless.license.kt"
15 | trimTrailingWhitespace()
16 | endWithNewline()
17 | }
18 | format "xml", {
19 | target "**/*.xml"
20 | targetExclude "**/build/**/*.xml", "**/detekt-baseline.xml"
21 | licenseHeaderFile "$rootDir/spotless/spotless.license.xml", "(<[^!?])"
22 | }
23 | }
--------------------------------------------------------------------------------
/spotless/spotless.license.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 skydoves (Jaewoong Eum)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
--------------------------------------------------------------------------------
/spotless/spotless.license.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 skydoves (Jaewoong Eum)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
--------------------------------------------------------------------------------
/spotless/spotless.license.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
--------------------------------------------------------------------------------