() }
47 | .show()
48 | ```
49 |
50 | #### Custom items
51 | Apart from the predefined items, you can inject your own list of items.
52 | There are two types of items:
53 |
54 | - **InfoItemWithView** - when selected, a bottom sheet dialog with your own defined content is displayed
55 | - **InfoItemWithLink** - when selected, a link defined by you is opened
56 |
57 | **InfoItemWithView** fields:
58 | - ```iconId: Int``` - a drawable resource that is used on the main page and inside the bottom sheet dialog (header icon)
59 | - ```title: String``` - the name of the item used on the main page
60 | - ```headerColor: Int```: - background color of the header
61 | - ```res: Int?``` - a layout resouce that will be displayed on the bottom sheet dialog
62 | - ```view: View?``` - a view that will be displayed on the bottom sheet dialog You can only use one of the *two*: res or *view*!
63 |
64 | **InfoItemWithLink** fields:
65 | - ```iconId: Int``` - a drawable resource that is used on the main page and inside the bottom sheet dialog (header icon)
66 | - ```title: String``` - the name of the item used on the main page
67 | - ```headerColor: Int```: - background color of the header
68 | - ```link: Uri``` - the URI of the resource that will be open on item click
69 | ##### Samples:
70 | ``` kotlin
71 | val itemWithView = InfoItemWithView(
72 | iconId = R.drawable.ic_test,
73 | title = "First custom item with view",
74 | headerColor = R.color.deep_purple_600,
75 | res = null,
76 | view = ImageView(this).also {
77 | it.setImageResource(R.drawable.ic_link)
78 | }
79 | )
80 |
81 | val itemWithRes = InfoItemWithView(
82 | iconId = R.drawable.ic_test,
83 | title = "Second custom item with view",
84 | headerColor = R.color.indigo_600,
85 | res = R.layout.test_item,
86 | view = null
87 | )
88 |
89 | val itemWithLink = InfoItemWithLink(
90 | iconId = R.drawable.ic_link,
91 | title = "Custom link",
92 | headerColor = R.color.deep_purple_600,
93 | link = Uri.parse("https://www.google.com")
94 | )
95 | ```
96 |
97 | #### Changelog
98 | An HTML file named **changelog.html** that you have to put under ***assets***.
99 | ##### Sample:
100 | ```
101 |
102 |
103 |
104 | Version 3
105 | This new version is amazing
106 |
107 | Version 2
108 | Bugfixes and general improvements
109 |
110 | Version 1
111 | Initial release
112 |
113 |
114 |
115 | ```
116 | #### Libraries
117 | An HTML file named **libraries.html** that you have to put under ***assets***.
118 | ##### Sample:
119 | ```
120 |
121 |
122 |
126 |
127 |
128 | ```
129 | #### License
130 | An HTML file named **license.html** that you have to put under ***assets***.
131 | ##### Sample:
132 | ```
133 |
134 |
135 |
136 | Apache License, Version 2.0
137 |
138 | Apache License
139 | Version 2.0, January 2004
140 | http://www.apache.org/licenses/
141 |
142 |
143 | Licensed under the Apache License, Version 2.0 (the "License");
144 | you may not use this file except in compliance with the License.
145 | You may obtain a copy of the License at
146 |
147 | http://www.apache.org/licenses/LICENSE-2.0
148 |
149 | Unless required by applicable law or agreed to in writing, software
150 | distributed under the License is distributed on an "AS IS" BASIS,
151 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
152 | See the License for the specific language governing permissions and
153 | limitations under the License.
154 |
155 |
156 | GNU General Public License version 3
157 |
158 | License Copyright: Copyright © 2007 Free Software Foundation, Inc.
159 |
160 |
161 | This program is free software: you can redistribute it and/or modify
162 | it under the terms of the GNU General Public License as published by
163 | the Free Software Foundation, either version 3 of the License, or
164 | (at your option) any later version.
165 |
166 | This program is distributed in the hope that it will be useful,
167 | but WITHOUT ANY WARRANTY; without even the implied warranty of
168 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
169 | GNU General Public License for more details.
170 |
171 | You should have received a copy of the GNU General Public License
172 | along with this program.
173 |
174 |
175 | MIT License
176 |
177 | Copyright (c) <2020> <>
178 | Permission is hereby granted, free of charge, to any person obtaining a copy
179 | of this software and associated documentation files (the "Software"), to deal
180 | in the Software without restriction, including without limitation the rights
181 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
182 | copies of the Software, and to permit persons to whom the Software is
183 | furnished to do so, subject to the following conditions:
184 |
185 | The above copyright notice and this permission notice shall be included in all
186 | copies or substantial portions of the Software.
187 |
188 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
189 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
190 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
191 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
192 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
193 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
194 | SOFTWARE.
195 |
196 |
197 |
198 |
199 | ```
200 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 29
7 | buildToolsVersion "29.0.2"
8 |
9 | defaultConfig {
10 | applicationId "com.dci.dev.aib.demo"
11 | minSdkVersion 21
12 | targetSdkVersion 29
13 | versionCode 2
14 | versionName "1.0.0"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 |
27 | // To inline the bytecode built with JVM target 1.8 into
28 |
29 | // bytecode that is being built with JVM target 1.6. (e.g. navArgs)
30 |
31 | compileOptions {
32 | sourceCompatibility JavaVersion.VERSION_1_8
33 | targetCompatibility JavaVersion.VERSION_1_8
34 | }
35 |
36 | kotlinOptions {
37 | jvmTarget = "1.8"
38 | }
39 | }
40 |
41 | dependencies {
42 |
43 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
44 |
45 | implementation fileTree(dir: 'libs', include: ['*.jar'])
46 |
47 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
48 | implementation 'androidx.appcompat:appcompat:1.1.0'
49 | implementation 'androidx.core:core-ktx:1.2.0'
50 | implementation 'com.google.android.material:material:1.1.0'
51 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
52 | testImplementation 'junit:junit:4.13'
53 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
54 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
55 | implementation project(path: ':appinfobadge')
56 | }
57 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/dci/dev/appinfobadge/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.dci.dev.appinfobadge", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
15 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/assets/changelog.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Version 3
5 | This new version is amazing
6 |
7 | Version 2
8 | Bugfixes and general improvements
9 |
10 | Version 1
11 | Initial release
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/assets/libraries.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/assets/license.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Apache License, Version 2.0
5 |
6 | Apache License
7 | Version 2.0, January 2004
8 | http://www.apache.org/licenses/
9 |
10 |
11 | Licensed under the Apache License, Version 2.0 (the "License");
12 | you may not use this file except in compliance with the License.
13 | You may obtain a copy of the License at
14 |
15 | http://www.apache.org/licenses/LICENSE-2.0
16 |
17 | Unless required by applicable law or agreed to in writing, software
18 | distributed under the License is distributed on an "AS IS" BASIS,
19 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | See the License for the specific language governing permissions and
21 | limitations under the License.
22 |
23 |
24 | GNU General Public License version 3
25 |
26 | License Copyright: Copyright © 2007 Free Software Foundation, Inc.
27 |
28 |
29 | This program is free software: you can redistribute it and/or modify
30 | it under the terms of the GNU General Public License as published by
31 | the Free Software Foundation, either version 3 of the License, or
32 | (at your option) any later version.
33 |
34 | This program is distributed in the hope that it will be useful,
35 | but WITHOUT ANY WARRANTY; without even the implied warranty of
36 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 | GNU General Public License for more details.
38 |
39 | You should have received a copy of the GNU General Public License
40 | along with this program.
41 |
42 |
43 | MIT License
44 |
45 | Copyright (c) <2020> <>
46 | Permission is hereby granted, free of charge, to any person obtaining a copy
47 | of this software and associated documentation files (the "Software"), to deal
48 | in the Software without restriction, including without limitation the rights
49 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
50 | copies of the Software, and to permit persons to whom the Software is
51 | furnished to do so, subject to the following conditions:
52 |
53 | The above copyright notice and this permission notice shall be included in all
54 | copies or substantial portions of the Software.
55 |
56 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
57 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
58 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
59 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
60 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
61 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
62 | SOFTWARE.
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dci/dev/aib/demo/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.aib.demo
2 |
3 | import android.graphics.Color
4 | import android.net.Uri
5 | import android.os.Bundle
6 | import android.util.Log
7 | import android.view.ViewGroup
8 | import android.widget.ImageView
9 | import android.widget.TextView
10 | import androidx.appcompat.app.AppCompatActivity
11 | import androidx.core.content.res.ResourcesCompat
12 | import com.dci.dev.appinfobadge.AppInfoBadge
13 | import com.dci.dev.appinfobadge.InfoItemWithLink
14 | import com.dci.dev.appinfobadge.InfoItemWithView
15 | import com.dci.dev.appinfobadge.utils.dp
16 | import com.dci.dev.appinfobadge.utils.px
17 | import kotlinx.android.synthetic.main.activity_main.*
18 | import java.lang.reflect.Field
19 |
20 |
21 | class MainActivity : AppCompatActivity() {
22 |
23 | override fun onCreate(savedInstanceState: Bundle?) {
24 | super.onCreate(savedInstanceState)
25 | setContentView(R.layout.activity_main)
26 | setSupportActionBar(toolbar)
27 |
28 | val colors = arrayListOf(Color.RED, Color.BLACK, Color.BLUE, Color.GRAY, Color.GREEN)
29 | if (android.os.Build.VERSION.SDK_INT > 21) {
30 | val fields: Array =
31 | Class.forName("$packageName.R\$color").declaredFields
32 | for (field in fields) {
33 | val colorName: String = field.name
34 | val colorId: Int = field.getInt(null)
35 | val color = ResourcesCompat.getColor(resources, colorId, null)
36 | colors.add(color)
37 | Log.i("test", "$colorName => $colorId => $color")
38 | }
39 | }
40 | val randomDisplayBool = booleanArrayOf(true, false)
41 |
42 | val testItemWithView = InfoItemWithView(
43 | iconId = R.drawable.ic_test,
44 | title = "First custom item with view",
45 | headerColor = R.color.deep_purple_600,
46 | res = null,
47 | view = ImageView(this).also {
48 | it.setImageResource(R.drawable.ic_link)
49 | it.layoutParams = ViewGroup.LayoutParams(128.px, 128.px)
50 | }
51 | )
52 |
53 | val testItemWithRes = InfoItemWithView(
54 | iconId = R.drawable.ic_chemistry,
55 | title = "Second custom item with view",
56 | headerColor = R.color.indigo_600,
57 | res = R.layout.test_item,
58 | view = null
59 | )
60 |
61 | val testLinkItem = InfoItemWithLink(
62 | iconId = R.drawable.ic_link,
63 | title = "Custom link",
64 | headerColor = R.color.deep_purple_600,
65 | link = Uri.parse("http://www.google.com")
66 | )
67 |
68 | val fragment = AppInfoBadge
69 | .darkMode { true }
70 | .withAppIcon { true }
71 | .headerColor { resources.getColor(R.color.red_600)}
72 | .withPermissions { true }
73 | .withChangelog { true }
74 | .withLicenses { true }
75 | .withLibraries { true }
76 | .withRater { true }
77 | .withEmail { "dev.dci91@gmail.com" }
78 | .withSite { "https://github.com/ditacristianionut/AppInfoBadge" }
79 | .withCustomItems {
80 | listOf(testItemWithView, testItemWithRes, testLinkItem)
81 | }
82 | .show()
83 |
84 |
85 | supportFragmentManager.beginTransaction()
86 | .replace(R.id.fragment, fragment)
87 | .commit()
88 |
89 | fab.setOnClickListener {
90 | val randomFragment = AppInfoBadge
91 | .darkMode { randomDisplayBool.random() }
92 | .withAppIcon { randomDisplayBool.random() }
93 | .headerColor { colors.random() }
94 | .withPermissions { randomDisplayBool.random() }
95 | .withChangelog { randomDisplayBool.random() }
96 | .withLicenses { randomDisplayBool.random() }
97 | .withLibraries { randomDisplayBool.random() }
98 | .withRater { randomDisplayBool.random() }
99 | .withEmail { "dev.dci91@gmail.com" }
100 | .withSite { "https://github.com/ditacristianionut/AppInfoBadge" }
101 | .show()
102 | supportFragmentManager.beginTransaction()
103 | .replace(R.id.fragment, randomFragment)
104 | .commit()
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_app_icon.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
33 |
36 |
39 |
42 |
45 |
48 |
51 |
54 |
57 |
60 |
63 |
66 |
69 |
72 |
75 |
78 |
81 |
84 |
87 |
90 |
91 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_chemistry.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
33 |
36 |
39 |
42 |
45 |
48 |
51 |
54 |
57 |
60 |
63 |
66 |
69 |
72 |
75 |
76 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_link.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_random.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_test.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
23 |
24 |
25 |
26 |
27 |
28 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/test_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
18 |
19 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AppInfoBadge Demo
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/test/java/com/dci/dev/appinfobadge/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/appinfobadge/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/appinfobadge/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'kotlinx-serialization'
5 | apply plugin: 'kotlin-kapt'
6 | apply plugin: 'com.github.dcendents.android-maven'
7 |
8 | group='com.github.ditacristianionut'
9 |
10 | android {
11 | compileSdkVersion 29
12 | buildToolsVersion "29.0.2"
13 |
14 | defaultConfig {
15 | minSdkVersion 21
16 | targetSdkVersion 29
17 | versionCode 13
18 | versionName "1.3"
19 |
20 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
21 | consumerProguardFiles 'consumer-rules.pro'
22 | }
23 |
24 | buildTypes {
25 | release {
26 | minifyEnabled false
27 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
28 | }
29 | }
30 |
31 | compileOptions {
32 | sourceCompatibility JavaVersion.VERSION_1_8
33 | targetCompatibility JavaVersion.VERSION_1_8
34 | }
35 |
36 | kotlinOptions {
37 | jvmTarget = JavaVersion.VERSION_1_8.toString()
38 | }
39 |
40 | androidExtensions {
41 | experimental = true
42 | }
43 |
44 | }
45 |
46 | dependencies {
47 | implementation fileTree(dir: 'libs', include: ['*.jar'])
48 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
49 | implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
50 | implementation 'androidx.core:core-ktx:1.2.0'
51 | testImplementation 'junit:junit:4.13'
52 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
53 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
54 |
55 | implementation 'com.google.code.gson:gson:2.8.6'
56 | implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0" // JVM dependency
57 |
58 |
59 | implementation 'com.google.android.material:material:1.1.0'
60 | implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta4"
61 | implementation 'androidx.webkit:webkit:1.2.0'
62 | implementation "androidx.core:core-ktx:1.2.0"
63 |
64 |
65 | implementation 'com.afollestad.material-dialogs:core:3.3.0'
66 | implementation 'com.afollestad.material-dialogs:bottomsheets:3.3.0'
67 | implementation 'com.afollestad.material-dialogs:lifecycle:3.3.0'
68 | implementation 'com.afollestad:recyclical:1.1.1'
69 |
70 | implementation 'com.github.bumptech.glide:glide:4.11.0'
71 | kapt 'com.github.bumptech.glide:compiler:4.11.0'
72 |
73 | implementation 'me.jorgecastillo:androidcolorx:0.2.0'
74 |
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/appinfobadge/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/appinfobadge/consumer-rules.pro
--------------------------------------------------------------------------------
/appinfobadge/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/appinfobadge/src/androidTest/java/com/dci/dev/appinfobadge/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.dci.dev.appinfobadge.test", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/java/com/dci/dev/appinfobadge/AppInfoBadge.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge
2 |
3 | import androidx.annotation.ColorInt
4 |
5 |
6 | object AppInfoBadge {
7 | private var darkMode: Boolean = false
8 | private var withAppIcon: Boolean = true
9 | @ColorInt private var headerColor: Int = 0
10 | private var withPermissions: Boolean = true
11 | private var withChangelog: Boolean = true
12 | private var withEmail: String? = null
13 | private var withSite: String? = null
14 | private var withLicense: Boolean = true
15 | private var withLibraries: Boolean = true
16 | private var withRater: Boolean = true
17 | internal var customItems: List = listOf()
18 |
19 | /**
20 | * Switch between dark or light mode
21 | */
22 | fun darkMode(init: AppInfoBadge.() -> Boolean) = apply { darkMode = init() }
23 |
24 | /**
25 | * Show the icon of the app in the header view
26 | */
27 | fun withAppIcon(init: AppInfoBadge.() -> Boolean) = apply { withAppIcon = init() }
28 |
29 | /**
30 | * Header background color (resolved Color resource)
31 | */
32 | fun headerColor(init: AppInfoBadge.() -> Int) = apply { headerColor = init() }
33 |
34 | /**
35 | * Show permissions item
36 | */
37 | fun withPermissions(init: AppInfoBadge.() -> Boolean) = apply { withPermissions = init() }
38 |
39 | /**
40 | * Show changelog item
41 | */
42 | fun withChangelog(init: AppInfoBadge.() -> Boolean) = apply { withChangelog = init() }
43 |
44 | /**
45 | * Set developer item
46 | */
47 | fun withEmail(init: AppInfoBadge.() -> String?) = apply { withEmail = init() }
48 |
49 | /**
50 | * Show developer web page
51 | */
52 | fun withSite(init: AppInfoBadge.() -> String?) = apply { withSite = init() }
53 |
54 | /**
55 | * Show license item
56 | */
57 | fun withLicenses(init: AppInfoBadge.() -> Boolean) = apply { withLicense = init() }
58 |
59 | /**
60 | * Show libraries item
61 | */
62 | fun withLibraries(init: AppInfoBadge.() -> Boolean) = apply { withLibraries = init() }
63 |
64 | /**
65 | * Show app rating item
66 | */
67 | fun withRater(init: AppInfoBadge.() -> Boolean) = apply { withRater = init() }
68 |
69 | /**
70 | * Custom items
71 | */
72 | fun withCustomItems(init: AppInfoBadge.() -> List) = apply { customItems = init() }
73 |
74 | /**
75 | * Creates a new instance of [AppInfoBadgeFragment]
76 | */
77 | fun show(): AppInfoBadgeFragment = AppInfoBadgeFragment.newInstance(
78 | darkMode,
79 | withAppIcon,
80 | headerColor,
81 | withPermissions,
82 | withChangelog,
83 | withEmail,
84 | withSite,
85 | withLicense,
86 | withLibraries,
87 | withRater
88 | )
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/java/com/dci/dev/appinfobadge/AppInfoBadgeFragment.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge
2 |
3 | import android.annotation.SuppressLint
4 | import android.content.Context
5 | import android.content.res.ColorStateList
6 | import android.content.res.Resources
7 | import android.graphics.Color
8 | import android.net.Uri
9 | import android.os.Bundle
10 | import android.util.Log
11 | import android.view.LayoutInflater
12 | import android.view.View
13 | import android.view.ViewGroup
14 | import android.view.ViewTreeObserver.OnGlobalLayoutListener
15 | import android.webkit.WebView
16 | import android.widget.ImageView
17 | import android.widget.LinearLayout
18 | import android.widget.TextView
19 | import androidx.annotation.ColorInt
20 | import androidx.core.content.res.ResourcesCompat
21 | import androidx.core.os.bundleOf
22 | import androidx.core.view.isGone
23 | import androidx.core.view.isVisible
24 | import androidx.fragment.app.Fragment
25 | import androidx.recyclerview.widget.RecyclerView
26 | import androidx.webkit.WebViewFeature
27 | import com.afollestad.materialdialogs.MaterialDialog
28 | import com.afollestad.materialdialogs.bottomsheets.BottomSheet
29 | import com.afollestad.materialdialogs.bottomsheets.setPeekHeight
30 | import com.afollestad.materialdialogs.customview.customView
31 | import com.afollestad.materialdialogs.lifecycle.lifecycleOwner
32 | import com.afollestad.recyclical.datasource.dataSourceTypedOf
33 | import com.afollestad.recyclical.setup
34 | import com.afollestad.recyclical.withItem
35 | import com.dci.dev.appinfobadge.permissions.PermissionItem
36 | import com.dci.dev.appinfobadge.permissions.PermissionViewHolder
37 | import com.dci.dev.appinfobadge.utils.*
38 | import com.dci.dev.appinfobadge.view.BottomDialogContentView
39 | import com.dci.dev.appinfobadge.view.DividerItemDecoration
40 | import dev.jorgecastillo.androidcolorx.library.isDark
41 | import kotlinx.android.synthetic.main.fragment_app_info_badge.*
42 | import kotlin.math.roundToInt
43 |
44 |
45 | class AppInfoBadgeFragment : Fragment() {
46 |
47 | companion object {
48 | private const val DARK_MODE = "dark_mode"
49 | private const val WITH_APP_ICON = "with_app_icon"
50 | private const val HEADER_COLOR = "header_color"
51 | private const val WITH_CHANGELOG = "with_changelog"
52 | private const val WITH_PERMISSIONS = "with_permissions"
53 | private const val WITH_EMAIL= "with_email"
54 | private const val WITH_SITE = "with_site"
55 | private const val WITH_LICENSE = "with_license"
56 | private const val WITH_LIBRARIES = "with_libraries"
57 | private const val WITH_RATER = "with_rater"
58 |
59 | fun newInstance(
60 | darkMode: Boolean,
61 | withAppIcon: Boolean,
62 | headerColor: Int,
63 | withPermissions: Boolean,
64 | withChangelog: Boolean,
65 | withEmail: String?,
66 | withSite: String?,
67 | withLicense: Boolean,
68 | withLibraries: Boolean,
69 | withRater: Boolean) = AppInfoBadgeFragment().apply {
70 | arguments = bundleOf(
71 | DARK_MODE to darkMode,
72 | WITH_APP_ICON to withAppIcon,
73 | HEADER_COLOR to headerColor,
74 | WITH_PERMISSIONS to withPermissions,
75 | WITH_CHANGELOG to withChangelog,
76 | WITH_EMAIL to withEmail,
77 | WITH_SITE to withSite,
78 | WITH_LICENSE to withLicense,
79 | WITH_LIBRARIES to withLibraries,
80 | WITH_RATER to withRater
81 | )
82 | }
83 | }
84 |
85 | private val permissionsList = arrayListOf()
86 |
87 | private val defaultItems = arrayListOf()
88 |
89 | override fun onCreateView(
90 | inflater: LayoutInflater, container: ViewGroup?,
91 | savedInstanceState: Bundle?
92 | ): View? {
93 | return inflater.inflate(R.layout.fragment_app_info_badge, container, false)
94 | }
95 |
96 | fun bottomDialog(
97 | sheetPeek: Int,
98 | darkModeOn: Boolean,
99 | itemWithView: InfoItemWithView
100 | ): MaterialDialog {
101 | val view = BottomDialogContentView(context!!).also {
102 | it.setData(itemWithView)
103 | it.isDarkModeOn = darkModeOn
104 | }
105 | val dialog = MaterialDialog(context!!, BottomSheet())
106 | .customView(view = view, noVerticalPadding = true)
107 | .cornerRadius(20f)
108 | .setPeekHeight(sheetPeek)
109 | .lifecycleOwner(this@AppInfoBadgeFragment)
110 | return dialog
111 | }
112 |
113 | @SuppressLint("SetTextI18n", "SetJavaScriptEnabled")
114 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
115 | super.onViewCreated(view, savedInstanceState)
116 |
117 | context?.let { ctx ->
118 | val darkMode = arguments?.getBoolean(DARK_MODE) ?: DefaultValues.darkMode
119 | val withAppIcon = arguments?.getBoolean(WITH_APP_ICON) ?: DefaultValues.withAppIcon
120 | @ColorInt val headerColor = arguments?.getInt(HEADER_COLOR) ?: DefaultValues.headerColor(ctx)
121 | val withPermissions = arguments?.getBoolean(WITH_PERMISSIONS) ?: DefaultValues.withPermissions
122 | val withChangelog = arguments?.getBoolean(WITH_CHANGELOG) ?: DefaultValues.withChangelog
123 | val withLicense = arguments?.getBoolean(WITH_LICENSE) ?: DefaultValues.withLicense
124 | val withLibraries = arguments?.getBoolean(WITH_LIBRARIES) ?: DefaultValues.withLibraries
125 | val withRater = arguments?.getBoolean(WITH_RATER) ?: DefaultValues.withRater
126 | val withEmail = arguments?.getString(WITH_EMAIL) ?: DefaultValues.withEmail
127 | val withSite = arguments?.getString(WITH_SITE) ?: DefaultValues.withSite
128 | val customItems = AppInfoBadge.customItems
129 | val headerTextColor = if (headerColor.isDark())
130 | ctx.resolveColor(R.color.grey_100)
131 | else
132 | ctx.resolveColor(R.color.grey_900)
133 | val appIcon = ctx.resolveDrawable(ctx.applicationInfo.icon)
134 | var sheetPeek = (ctx.displayHeight * 0.6).roundToInt()
135 | val bodyBackgroundColor = if (darkMode)
136 | ctx.resolveColor(R.color.dark_background)
137 | else
138 | ctx.resolveColor(R.color.light_background)
139 | val bodyTextColor = if (darkMode)
140 | ctx.resolveColor(R.color.grey_100)
141 | else
142 | ctx.resolveColor(R.color.grey_900)
143 | val iconTint = ColorStateList.valueOf(bodyTextColor)
144 | val divider = DividerItemDecoration(
145 | ctx, DividerItemDecoration.VERTICAL, false, darkMode
146 | )
147 | header.viewTreeObserver.addOnGlobalLayoutListener(object : OnGlobalLayoutListener {
148 | override fun onGlobalLayout() {
149 | header.viewTreeObserver.removeOnGlobalLayoutListener(this)
150 | sheetPeek = view.height - header.height
151 | }
152 | })
153 | val versionName = Utils.getAppVersionName(ctx)
154 |
155 | // App permissions
156 | if (withPermissions) {
157 | readPermissions(ctx)
158 | val rvPermissions = RecyclerView(context!!)
159 | rvPermissions.setBackgroundColor(bodyBackgroundColor)
160 | rvPermissions.setup {
161 | val permissionsDataSource = dataSourceTypedOf(permissionsList)
162 | withDataSource(permissionsDataSource)
163 | withItem(R.layout.item_permission_view) {
164 | onBind(::PermissionViewHolder) { index, item ->
165 | settingsIv.imageTintList = iconTint
166 | settingsIv.setOnClickListener {
167 | ctx.goToSettings()
168 | }
169 | name.text = item.name
170 | val textColor = if (item.isGranted)
171 | ctx.resolveColor(R.color.green_400)
172 | else
173 | ctx.resolveColor(R.color.red_400)
174 | name.setTextColor(textColor)
175 | try {
176 | description.text = getString(item.description)
177 | description.setTextColor(bodyTextColor)
178 | } catch (exception: Resources.NotFoundException) {
179 | Log.e(
180 | "AIB",
181 | "Permission details not found for [${item.name}]"
182 | )
183 | }
184 | settings.setOnClickListener {
185 | ctx.goToSettings()
186 | }
187 | }
188 | onClick { index ->
189 | // item is a `val` in `this` here
190 | }
191 | onLongClick { index ->
192 | // item is a `val` in `this` here
193 | }
194 | }
195 | }
196 | defaultItems.add(
197 | InfoItemWithView(
198 | iconId = R.drawable.ic_banner_permissions_2,
199 | title = getString(R.string.trust_badge),
200 | headerColor = R.color.red_600,
201 | res = null,
202 | view = rvPermissions
203 | )
204 | )
205 | }
206 |
207 | // Changelog
208 | if (withChangelog) {
209 | val webViewWhatsNew = WebView(ctx)
210 | webViewWhatsNew.settings.javaScriptEnabled = true
211 | if (darkMode && WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
212 | webViewWhatsNew.setBackgroundColor(Color.TRANSPARENT)
213 | }
214 | webViewWhatsNew.loadAsset("changelog.html", context!!.applicationContext, darkMode)
215 | defaultItems.add(
216 | InfoItemWithView(
217 | iconId = R.drawable.ic_banner_whats_new,
218 | title = getString(R.string.what_s_new),
219 | headerColor = R.color.green_600,
220 | res = null,
221 | view = webViewWhatsNew
222 | )
223 | )
224 | }
225 |
226 | // License
227 | if (withLicense) {
228 | val webViewLicense = WebView(ctx)
229 | webViewLicense.settings.javaScriptEnabled = true
230 | if (darkMode && WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
231 | webViewLicense.setBackgroundColor(Color.TRANSPARENT)
232 | }
233 | webViewLicense.loadAsset("license.html", context!!.applicationContext, darkMode)
234 | defaultItems.add(
235 | InfoItemWithView(
236 | iconId = R.drawable.ic_banner_licenses,
237 | title = getString(R.string.license),
238 | headerColor = R.color.orange_600,
239 | res = null,
240 | view = webViewLicense
241 | )
242 | )
243 | }
244 |
245 | // Libraries
246 | if (withLibraries) {
247 | val webViewLibraries = WebView(ctx)
248 | webViewLibraries.settings.javaScriptEnabled = true
249 | if (darkMode && WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
250 | webViewLibraries.setBackgroundColor(Color.TRANSPARENT)
251 | }
252 | webViewLibraries.loadAsset("libraries.html", context!!.applicationContext, darkMode)
253 | defaultItems.add(
254 | InfoItemWithView(
255 | iconId = R.drawable.ic_banner_libraries,
256 | title = getString(R.string.libraries),
257 | headerColor = R.color.grey_600,
258 | res = null,
259 | view = webViewLibraries
260 | )
261 | )
262 | }
263 |
264 | // Contact
265 | if (!withEmail.isNullOrBlank() || !withSite.isNullOrBlank()) {
266 | val contactContentView = LayoutInflater.from(context)
267 | .inflate(R.layout.custom_view_contact, null, false)
268 | val containerMail =
269 | contactContentView.findViewById(R.id.containerMail)
270 | val containerSite = contactContentView
271 | .findViewById(R.id.containerSite)
272 | val mail = contactContentView
273 | .findViewById(R.id.tvMail)
274 | val site = contactContentView
275 | .findViewById(R.id.tvSite)
276 | val iconMail = contactContentView
277 | .findViewById(R.id.ivMail)
278 | val iconSite = contactContentView
279 | .findViewById(R.id.ivSite)
280 |
281 | containerMail.isVisible = !withEmail.isNullOrBlank()
282 | if (!withEmail.isNullOrBlank()) {
283 | mail.text = withEmail
284 | iconMail.imageTintList = iconTint
285 | }
286 |
287 | containerSite.isVisible = !withSite.isNullOrBlank()
288 | if (!withSite.isNullOrBlank()) {
289 | site.text = withSite
290 | when {
291 | withSite.contains("github", true) -> {
292 | iconSite.setImageResource(R.drawable.ic_contact_site_github)
293 | }
294 | withSite.contains("gitlab", true) -> {
295 | iconSite.setImageResource(R.drawable.ic_contact_site_gitlab)
296 | }
297 | withSite.contains("bitbucket", true) -> {
298 | iconSite.setImageResource(R.drawable.ic_contact_site_bitbucket)
299 | }
300 | withSite.contains("facebook", true) -> {
301 | iconSite.setImageResource(R.drawable.ic_contact_site_facebook)
302 | }
303 | }
304 | iconSite.imageTintList = iconTint
305 | defaultItems.add(
306 | InfoItemWithView(
307 | iconId = R.drawable.ic_banner_contact,
308 | title = getString(R.string.contact),
309 | headerColor = R.color.orange_600,
310 | res = null,
311 | view = contactContentView
312 | )
313 | )
314 | }
315 | }
316 |
317 | // Rater
318 | if (withRater) {
319 | defaultItems.add(
320 | InfoItemWithLink(
321 | iconId = R.drawable.ic_banner_rate,
322 | title = getString(R.string.rate_me),
323 | headerColor = R.color.red_600,
324 | link = Uri.parse("market://details?id=" + ctx.packageName)
325 | )
326 | )
327 | }
328 |
329 | defaultItems.addAll(customItems)
330 |
331 | // Header
332 | header.setBackgroundColor(headerColor)
333 | if (withAppIcon) {
334 | ivAppIcon.setImageDrawable(appIcon)
335 | } else {
336 | ivAppIcon.visibility = View.INVISIBLE
337 | }
338 |
339 | // Body
340 | main?.setBackgroundColor(bodyBackgroundColor)
341 | val dataSource = dataSourceTypedOf(
342 | defaultItems
343 | )
344 | rvItems.setup {
345 | val emptyMessage = TextView(context!!)
346 | emptyMessage.text = "No item"
347 | withEmptyView(emptyMessage)
348 | withDataSource(dataSource)
349 | withItem(R.layout.info_item) {
350 | onBind(::InfoItemViewHolder) { index: Int, itemWithView: InfoItemWithView ->
351 | title.setTextColor(bodyTextColor)
352 | if (itemWithView !in customItems)
353 | icon.imageTintList = iconTint
354 | title.text = itemWithView.title
355 | icon.setImageResource(itemWithView.iconId)
356 | }
357 | onClick { index: Int ->
358 | bottomDialog(
359 | sheetPeek,
360 | darkMode,
361 | item
362 | ).show()
363 | }
364 | }
365 | withItem(R.layout.info_item) {
366 | onBind(::InfoItemViewHolder) { index: Int, itemWithLink: InfoItemWithLink ->
367 | title.setTextColor(bodyTextColor)
368 | if (itemWithLink !in customItems)
369 | icon.imageTintList = iconTint
370 | title.text = itemWithLink.title
371 | icon.setImageResource(itemWithLink.iconId)
372 | }
373 | onClick { index: Int ->
374 | Utils.openUri(ctx, item.link)
375 | }
376 | }
377 | }
378 | rvItems.addItemDecoration(divider)
379 |
380 | // App name & version
381 | tvAppName.text = ctx.applicationInfo?.loadLabel(context!!.packageManager)
382 | if (versionName.isBlank()) {
383 | tvAppVersion.isGone = true
384 | } else {
385 | tvAppVersion.text = getString(R.string.app_version_name, versionName)
386 | }
387 | tvAppName.setTextColor(headerTextColor)
388 | tvAppVersion.setTextColor(headerTextColor)
389 |
390 | }
391 | }
392 |
393 | private fun readPermissions(context: Context) {
394 | permissionsList.clear()
395 | val appPermissions = PermissionUtils.retrievePermissions(context).map {
396 | PermissionUtils.getPermissionName(it, context)?.let { _name ->
397 | PermissionItem(
398 | name = _name,
399 | description = PermissionUtils.getPermissionDescription(it, context) ?: 0,
400 | isGranted = PermissionUtils.hasPermission(it, context)
401 | )
402 | }
403 | }
404 | appPermissions.forEach { it?.let { permissionsList.add(it) } }
405 | }
406 |
407 | private object DefaultValues {
408 | fun headerColor(context: Context) = ResourcesCompat.getColor(context.resources, R.color.green_400, null)
409 | const val darkMode = false
410 | const val withPermissions = true
411 | const val withChangelog = true
412 | const val withLicense = true
413 | const val withLibraries = true
414 | const val withRater = true
415 | const val withAppIcon = true
416 | val withEmail: String? = null
417 | val withSite: String? = null
418 | }
419 | }
420 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/java/com/dci/dev/appinfobadge/InfoItemViewHolder.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge
2 |
3 | import android.view.View
4 | import android.widget.ImageView
5 | import android.widget.TextView
6 | import com.afollestad.recyclical.ViewHolder
7 |
8 | class InfoItemViewHolder(itemView: View) : ViewHolder(itemView) {
9 | val title: TextView = itemView.findViewById(R.id.tvName)
10 | val icon: ImageView = itemView.findViewById(R.id.ivIcon)
11 | }
12 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/java/com/dci/dev/appinfobadge/InfoItemWithView.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge
2 |
3 | import android.net.Uri
4 | import android.view.View
5 | import androidx.annotation.LayoutRes
6 | import kotlinx.serialization.ContextualSerialization
7 |
8 | @kotlinx.serialization.Serializable
9 | abstract class BaseInfoItem
10 |
11 | @kotlinx.serialization.Serializable
12 | data class InfoItemWithView(
13 | val iconId: Int = -1,
14 | val title: String = "",
15 | val headerColor: Int = R.color.white,
16 | @LayoutRes val res: Int?,
17 | @ContextualSerialization val view: View?
18 | ) : BaseInfoItem()
19 |
20 | @kotlinx.serialization.Serializable
21 | data class InfoItemWithLink(
22 | val iconId: Int = -1,
23 | val title: String = "",
24 | val headerColor: Int = R.color.white,
25 | @ContextualSerialization val link: Uri
26 | ) : BaseInfoItem()
27 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/java/com/dci/dev/appinfobadge/InfoItemsAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge
2 |
3 | class InfoItemsAdapter
4 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/java/com/dci/dev/appinfobadge/permissions/PermissionItem.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge.permissions
2 |
3 | import androidx.annotation.StringRes
4 |
5 | internal data class PermissionItem(
6 | val name: String,
7 | @StringRes val description: Int,
8 | val isGranted: Boolean = false
9 | )
10 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/java/com/dci/dev/appinfobadge/permissions/PermissionViewHolder.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge.permissions
2 |
3 | import android.view.View
4 | import android.widget.ImageView
5 | import android.widget.TextView
6 | import com.afollestad.recyclical.ViewHolder
7 | import com.dci.dev.appinfobadge.R
8 |
9 | internal class PermissionViewHolder (itemView: View) : ViewHolder(itemView) {
10 | val name: TextView = itemView.findViewById(R.id.tvPermissionName)
11 | val description: TextView = itemView.findViewById(R.id.tvPermissionDetails)
12 | val settings: TextView = itemView.findViewById(R.id.tvGoToSettings)
13 | val settingsIv: ImageView = itemView.findViewById(R.id.ivGoToSettings)
14 | }
15 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/java/com/dci/dev/appinfobadge/utils/AssetsWebViewClient.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge.utils
2 |
3 | import android.content.Context
4 | import android.webkit.WebResourceRequest
5 | import android.webkit.WebResourceResponse
6 | import android.webkit.WebView
7 | import android.webkit.WebViewClient
8 | import androidx.webkit.WebViewAssetLoader
9 |
10 | internal class AssetsWebViewClient(context: Context, private val darkMode: Boolean) : WebViewClient() {
11 | private val assetLoader = WebViewAssetLoader.Builder()
12 | .addPathHandler("/assets/", WebViewAssetLoader.AssetsPathHandler(context))
13 | .addPathHandler("/res/", WebViewAssetLoader.ResourcesPathHandler(context))
14 | .build()
15 |
16 | override fun shouldInterceptRequest(
17 | view: WebView?,
18 | request: WebResourceRequest
19 | ): WebResourceResponse? {
20 | return assetLoader.shouldInterceptRequest(request.url)
21 | }
22 |
23 | override fun onPageFinished(view: WebView?, url: String?) {
24 | if (darkMode) {
25 | view?.loadUrl(
26 | "javascript:document.body.style.setProperty(\"color\", \"white\");"
27 | )
28 | } else {
29 | super.onPageFinished(view, url)
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/java/com/dci/dev/appinfobadge/utils/Extensions.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge.utils
2 |
3 | import android.content.Context
4 | import android.content.Intent
5 | import android.content.res.Resources
6 | import android.net.Uri
7 | import android.provider.Settings
8 | import android.webkit.WebView
9 | import androidx.core.content.res.ResourcesCompat
10 |
11 | /**
12 | * Extension method to find a device height in pixels
13 | */
14 | inline val Context.displayHeight: Int
15 | get() = resources.displayMetrics.heightPixels
16 |
17 | fun Context.goToSettings() {
18 | val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
19 | val uri = Uri.fromParts("package", packageName, null)
20 | intent.data = uri
21 | intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
22 | startActivity(intent)
23 | }
24 |
25 | /**
26 | * Converts dp unit to equivalent pixels, depending on device density.
27 | **/
28 | val Int.dp: Int
29 | get() = (this / Resources.getSystem().displayMetrics.density).toInt()
30 |
31 | /**
32 | * Converts device specific pixels to density independent pixels.
33 | **/
34 | val Int.px: Int
35 | get() = (this * Resources.getSystem().displayMetrics.density).toInt()
36 |
37 | // Assets are hosted under http(s)://appassets.androidplatform.net/assets/... .
38 | // If the application's assets are in the "main/assets" folder this will read the file
39 | // from "main/assets/www/index.html" and load it as if it were hosted on:
40 | // https://appassets.androidplatform.net/assets/www/index.html
41 | fun WebView.loadAsset(file: String, context: Context, darkMode: Boolean) {
42 | this.webViewClient = AssetsWebViewClient(context, darkMode)
43 | loadUrl("https://appassets.androidplatform.net/assets/$file")
44 | }
45 |
46 | fun Context.resolveColor(colorRes: Int) =
47 | ResourcesCompat.getColor(resources, colorRes, null)
48 |
49 | fun Context.resolveDrawable(drawableRes: Int) =
50 | ResourcesCompat.getDrawable(resources, drawableRes, null)
51 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/java/com/dci/dev/appinfobadge/utils/PermissionUtils.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge.utils
2 |
3 | import android.annotation.SuppressLint
4 | import android.content.Context
5 | import android.content.pm.PackageManager
6 | import android.content.pm.PermissionInfo
7 | import java.util.*
8 |
9 | internal object PermissionUtils {
10 |
11 | private const val permissionPrefix = "android.permission."
12 | private val dangerousPermissions = arrayListOf(
13 | "android.permission.READ_CALENDAR",
14 | "android.permission.WRITE_CALENDAR",
15 | "android.permission.CAMERA",
16 | "android.permission.READ_CONTACTS",
17 | "android.permission.WRITE_CONTACTS",
18 | "android.permission.GET_ACCOUNTS",
19 | "android.permission.ACCESS_FINE_LOCATION",
20 | "android.permission.ACCESS_COARSE_LOCATION",
21 | "android.permission.RECORD_AUDIO",
22 | "android.permission.READ_PHONE_STATE",
23 | "android.permission.READ_PHONE_NUMBERS",
24 | "android.permission.CALL_PHONE",
25 | "android.permission.ANSWER_PHONE_CALLS",
26 | "android.permission.READ_CALL_LOG",
27 | "android.permission.WRITE_CALL_LOG",
28 | "android.permission.ADD_VOICEMAIL",
29 | "android.permission.USE_SIP",
30 | "android.permission.PROCESS_OUTGOING_CALLS",
31 | "android.permission.BODY_SENSORS",
32 | "android.permission.SEND_SMS",
33 | "android.permission.RECEIVE_SMS",
34 | "android.permission.READ_SMS",
35 | "android.permission.RECEIVE_WAP_PUSH",
36 | "android.permission.RECEIVE_MMS",
37 | "android.permission.READ_EXTERNAL_STORAGE",
38 | "android.permission.WRITE_EXTERNAL_STORAGE"
39 | )
40 |
41 | @SuppressLint("DefaultLocale")
42 | fun retrievePermissions(context: Context): List {
43 | val permissions = arrayListOf()
44 | try {
45 | permissions.addAll(
46 | context.packageManager
47 | ?.getPackageInfo(context.packageName, PackageManager.GET_PERMISSIONS)
48 | ?.requestedPermissions
49 | ?.filter {
50 | it.toLowerCase().startsWith(permissionPrefix)
51 | } ?: emptyList()
52 | )
53 | } catch (e: PackageManager.NameNotFoundException) {
54 | throw RuntimeException("This should have never happened.", e)
55 | }
56 | return permissions
57 | }
58 |
59 | private fun getPermissionDetails(permission: String, context: Context): PermissionInfo? {
60 | return context.packageManager.getPermissionInfo(
61 | permission,
62 | PackageManager.GET_META_DATA
63 | )
64 | }
65 |
66 | @SuppressLint("DefaultLocale")
67 | fun getPermissionName(permission: String, context: Context): String? {
68 | return getPermissionDetails(
69 | permission,
70 | context
71 | )?.name
72 | ?.replace(permissionPrefix.toRegex(), "")
73 | ?.replace("_".toRegex(), " ")
74 | ?.toLowerCase(Locale.ROOT)
75 | ?.capitalize()
76 | }
77 |
78 | fun getPermissionDescription(permission: String, context: Context): Int? {
79 | return getPermissionDetails(
80 | permission,
81 | context
82 | )?.descriptionRes
83 | }
84 |
85 | fun hasPermission(
86 | permission: String,
87 | context: Context
88 | ): Boolean {
89 | return PackageManager.PERMISSION_GRANTED == context.packageManager.checkPermission(
90 | permission,
91 | context.packageName
92 | )
93 | }
94 |
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/java/com/dci/dev/appinfobadge/utils/Utils.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge.utils
2 |
3 | import android.content.ActivityNotFoundException
4 | import android.content.Context
5 | import android.content.Intent
6 | import android.content.pm.PackageInfo
7 | import android.content.pm.PackageManager
8 | import android.net.Uri
9 | import android.os.Build
10 | import android.util.Log
11 | import androidx.core.content.ContextCompat.startActivity
12 |
13 |
14 | internal object Utils {
15 | fun openAppInPlayStore(context: Context) {
16 | val uri = Uri.parse("market://details?id=" + context.packageName)
17 | val goToMarketIntent = Intent(Intent.ACTION_VIEW, uri)
18 |
19 | var flags = Intent.FLAG_ACTIVITY_NO_HISTORY or Intent.FLAG_ACTIVITY_MULTIPLE_TASK
20 | flags = if (Build.VERSION.SDK_INT >= 21) {
21 | flags or Intent.FLAG_ACTIVITY_NEW_DOCUMENT
22 | } else {
23 | flags or Intent.FLAG_ACTIVITY_CLEAR_TASK
24 | }
25 | goToMarketIntent.addFlags(flags)
26 |
27 | try {
28 | startActivity(context, goToMarketIntent, null)
29 | } catch (e: ActivityNotFoundException) {
30 | val intent = Intent(Intent.ACTION_VIEW,
31 | Uri.parse("http://play.google.com/store/apps/details?id=" + context.packageName))
32 |
33 | startActivity(context, intent, null)
34 | }
35 | }
36 |
37 | fun openUri(context: Context, uri: Uri) {
38 | val intent = Intent(Intent.ACTION_VIEW, uri)
39 |
40 | var flags = Intent.FLAG_ACTIVITY_NO_HISTORY or Intent.FLAG_ACTIVITY_MULTIPLE_TASK
41 | flags = if (Build.VERSION.SDK_INT >= 21) {
42 | flags or Intent.FLAG_ACTIVITY_NEW_DOCUMENT
43 | } else {
44 | flags or Intent.FLAG_ACTIVITY_CLEAR_TASK
45 | }
46 | intent.addFlags(flags)
47 |
48 | try {
49 | startActivity(context, intent, null)
50 | } catch (e: ActivityNotFoundException) {
51 | Log.e(this::class.java.simpleName, e.message ?: "Failed to open uri $uri")
52 | }
53 | }
54 |
55 | fun getAppVersionName(context: Context): String {
56 | var version: String = ""
57 | try {
58 | val pInfo: PackageInfo =
59 | context.packageManager.getPackageInfo(context.packageName, 0)
60 | version = pInfo.versionName
61 | } catch (e: PackageManager.NameNotFoundException) {
62 | e.printStackTrace()
63 | }
64 | return version
65 | }
66 | }
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/java/com/dci/dev/appinfobadge/utils/Views.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge.utils
2 |
3 | import android.view.LayoutInflater
4 | import android.view.ViewGroup
5 | import androidx.annotation.LayoutRes
6 |
7 | @Suppress("UNCHECKED_CAST")
8 | internal fun ViewGroup.inflate(
9 | @LayoutRes res: Int,
10 | root: ViewGroup? = this
11 | ) = LayoutInflater.from(context).inflate(res, root, false) as T
12 |
13 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/java/com/dci/dev/appinfobadge/view/BottomDialogContentView.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge.view
2 |
3 | import android.content.Context
4 | import android.util.AttributeSet
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import android.widget.FrameLayout
9 | import android.widget.ImageView
10 | import android.widget.LinearLayout
11 | import android.widget.RelativeLayout
12 | import androidx.annotation.LayoutRes
13 | import com.dci.dev.appinfobadge.InfoItemWithView
14 | import com.dci.dev.appinfobadge.R
15 | import com.dci.dev.appinfobadge.utils.inflate
16 | import com.dci.dev.appinfobadge.utils.px
17 | import com.dci.dev.appinfobadge.utils.resolveColor
18 |
19 | class BottomDialogContentView @JvmOverloads constructor(
20 | context: Context,
21 | attrs: AttributeSet? = null,
22 | defStyle: Int = 0,
23 | defStyleRes: Int = 0
24 | ) : RelativeLayout(context, attrs, defStyle, defStyleRes) {
25 |
26 | private var headerBackground: RoundedCornerImageView
27 | private var headerIcon: ImageView
28 | private var contentLayout: LinearLayout
29 | private var customView: View? = null
30 |
31 | fun setData(data: InfoItemWithView) {
32 | headerIcon.setImageResource(data.iconId)
33 | headerBackground.setImageResource(data.headerColor)
34 | headerBackground.radius = RoundedCornerImageView.Radius(20.px, 20.px, 0.px, 0.px)
35 | headerBackground.roundedCorners = RoundedCornerImageView.CORNER_ALL
36 | addCustomView(res = data.res, view = data.view)
37 | invalidate()
38 | }
39 |
40 | var isDarkModeOn: Boolean = false
41 | set(value) {
42 | field = value
43 | if (field)
44 | contentLayout.setBackgroundColor(context.resolveColor(R.color.dark_background))
45 | else
46 | contentLayout.setBackgroundColor(context.resolveColor(R.color.light_background))
47 | }
48 |
49 | init {
50 | LayoutInflater.from(context).inflate(R.layout.bottom_dialog_layout, this, true)
51 | headerBackground = findViewById(R.id.ivBannerBackground)
52 | headerIcon = findViewById(R.id.ivBanner)
53 | contentLayout = findViewById(R.id.content)
54 | }
55 |
56 | private fun addCustomView(
57 | @LayoutRes res: Int?,
58 | view: View?
59 | ): View {
60 | check(customView == null) { "Custom view already set." }
61 |
62 | if (view != null && view.parent != null) {
63 | // Make sure the view is detached from any former parents.
64 | val parent = view.parent as? ViewGroup
65 | parent?.let { parent.removeView(view) }
66 | }
67 |
68 | customView = view ?: inflate(res!!)
69 | contentLayout.addView(customView)
70 | return customView!!
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/java/com/dci/dev/appinfobadge/view/DividerItemDecoration.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge.view
2 |
3 | import android.content.Context
4 | import android.graphics.Canvas
5 | import android.graphics.Rect
6 | import android.graphics.drawable.Drawable
7 | import android.os.Build
8 | import android.view.View
9 | import android.widget.LinearLayout
10 | import androidx.core.content.ContextCompat
11 | import androidx.recyclerview.widget.LinearLayoutManager
12 | import androidx.recyclerview.widget.RecyclerView
13 | import androidx.recyclerview.widget.RecyclerView.ItemDecoration
14 | import com.dci.dev.appinfobadge.R
15 |
16 |
17 | /**
18 | * DividerItemDecoration is a [RecyclerView.ItemDecoration] that can be used as a divider
19 | * between items of a [LinearLayoutManager]. It supports both [.HORIZONTAL] and
20 | * [.VERTICAL] orientations.
21 | *
22 | *
23 | * mDividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
24 | * mLayoutManager.getOrientation());
25 | * recyclerView.addItemDecoration(mDividerItemDecoration);
26 |
*
27 | */
28 | class DividerItemDecoration(
29 | context: Context,
30 | orientation: Int,
31 | isShowInLastItem: Boolean,
32 | isDarkMode: Boolean
33 | ) :
34 | ItemDecoration() {
35 | private var divider: Drawable?
36 | /**
37 | * Current orientation. Either [.HORIZONTAL] or [.VERTICAL].
38 | */
39 | private var orientation = 0
40 | private val isShowInLastItem: Boolean
41 |
42 | /**
43 | * Sets the orientation for this divider. This should be called if
44 | * [RecyclerView.LayoutManager] changes orientation.
45 | *
46 | * @param orientation [.HORIZONTAL] or [.VERTICAL]
47 | */
48 | fun setOrientation(orientation: Int) {
49 | require(!(orientation != HORIZONTAL && orientation != VERTICAL)) { "Invalid orientation. It should be either HORIZONTAL or VERTICAL" }
50 | this.orientation = orientation
51 | }
52 |
53 | /**
54 | * Sets the [Drawable] for this divider.
55 | *
56 | * @param drawable Drawable that should be used as a divider.
57 | */
58 | fun setDrawable(drawable: Drawable) {
59 | requireNotNull(drawable) { "Drawable cannot be null." }
60 | divider = drawable
61 | }
62 |
63 | override fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
64 | if (parent.layoutManager == null || divider == null) {
65 | return
66 | }
67 | if (orientation == VERTICAL) {
68 | drawVertical(c, parent)
69 | } else {
70 | drawHorizontal(c, parent)
71 | }
72 | }
73 |
74 | private fun drawVertical(canvas: Canvas, parent: RecyclerView) {
75 | canvas.save()
76 | val left: Int
77 | val right: Int
78 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && parent.clipToPadding) {
79 | left = parent.paddingLeft
80 | right = parent.width - parent.paddingRight
81 | canvas.clipRect(
82 | left, parent.paddingTop, right,
83 | parent.height - parent.paddingBottom
84 | )
85 | } else {
86 | left = 0
87 | right = parent.width
88 | }
89 | val childCount: Int
90 | childCount = if (isShowInLastItem) {
91 | parent.childCount
92 | } else {
93 | parent.childCount - 1
94 | }
95 | for (i in 0 until childCount) {
96 | val child: View = parent.getChildAt(i)
97 | // parent.getDecoratedBoundsWithMargins(child, mBounds);
98 | // final int bottom = mBounds.bottom + Math.round(child.getTranslationY());
99 | val decoratedBottom = parent.layoutManager!!.getDecoratedBottom(child)
100 | val bottom = (decoratedBottom + Math.round(child.getTranslationY())).toInt()
101 | val top = bottom - divider!!.intrinsicHeight
102 | divider!!.setBounds(left, top, right, bottom)
103 | divider!!.draw(canvas)
104 | }
105 | canvas.restore()
106 | }
107 |
108 | private fun drawHorizontal(canvas: Canvas, parent: RecyclerView) {
109 | canvas.save()
110 | val top: Int
111 | val bottom: Int
112 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && parent.clipToPadding) {
113 | top = parent.paddingTop
114 | bottom = parent.height - parent.paddingBottom
115 | canvas.clipRect(
116 | parent.paddingLeft, top,
117 | parent.width - parent.paddingRight, bottom
118 | )
119 | } else {
120 | top = 0
121 | bottom = parent.height
122 | }
123 | val childCount: Int
124 | childCount = if (isShowInLastItem) {
125 | parent.childCount
126 | } else {
127 | parent.childCount - 1
128 | }
129 | for (i in 0 until childCount) {
130 | val child: View = parent.getChildAt(i)
131 | // parent.getLayoutManager().getDecoratedBoundsWithMargins(child, mBounds);
132 | // final int right = mBounds.right + Math.round(child.getTranslationX());
133 | val decoratedRight = parent.layoutManager!!.getDecoratedRight(child)
134 | val right = (decoratedRight + Math.round(child.getTranslationX())).toInt()
135 | val left = right - divider!!.intrinsicWidth
136 | divider!!.setBounds(left, top, right, bottom)
137 | divider!!.draw(canvas)
138 | }
139 | canvas.restore()
140 | }
141 |
142 | override fun getItemOffsets(
143 | outRect: Rect,
144 | view: View,
145 | parent: RecyclerView,
146 | state: RecyclerView.State
147 | ) {
148 | if (divider == null) {
149 | outRect.setEmpty()
150 | return
151 | }
152 | val itemPosition =
153 | (view.getLayoutParams() as RecyclerView.LayoutParams).viewLayoutPosition
154 | val itemCount = state.itemCount
155 | if (isShowInLastItem) {
156 | if (orientation == VERTICAL) {
157 | outRect.set(0, 0, 0, divider!!.intrinsicHeight)
158 | } else {
159 | outRect.set(0, 0, divider!!.intrinsicWidth, 0)
160 | }
161 | } else if (itemPosition == itemCount - 1) { // We didn't set the last item when mIsShowInLastItem's value is false.
162 | outRect.setEmpty()
163 | } else {
164 | if (orientation == VERTICAL) {
165 | outRect.set(0, 0, 0, divider!!.intrinsicHeight)
166 | } else {
167 | outRect.set(0, 0, divider!!.intrinsicWidth, 0)
168 | }
169 | }
170 | }
171 |
172 | companion object {
173 | const val HORIZONTAL = LinearLayout.HORIZONTAL
174 | const val VERTICAL = LinearLayout.VERTICAL
175 | private const val TAG = "DividerItem"
176 | }
177 |
178 | /**
179 | * Creates a divider [RecyclerView.ItemDecoration] that can be used with a
180 | * [LinearLayoutManager].
181 | *
182 | * @param context Current context, it will be used to access resources.
183 | * @param orientation Divider orientation. Should be [.HORIZONTAL] or [.VERTICAL].
184 | * @param isShowInLastItem Whether show the divider in last item.
185 | */
186 | init {
187 | divider = if (isDarkMode)
188 | ContextCompat.getDrawable(context, R.drawable.item_separator_dark)
189 | else
190 | ContextCompat.getDrawable(context, R.drawable.item_separator)
191 | setOrientation(orientation)
192 | this.isShowInLastItem = isShowInLastItem
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/java/com/dci/dev/appinfobadge/view/RoundedCornerImageView.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge.view
2 |
3 | import android.annotation.SuppressLint
4 | import android.content.Context
5 | import android.graphics.Canvas
6 | import android.graphics.Path
7 | import android.graphics.RectF
8 | import android.util.AttributeSet
9 | import android.widget.ImageView
10 | import com.dci.dev.appinfobadge.utils.px
11 |
12 | /**
13 | * The RoundedCornerImageView class provides a way to round individual corners for an imageView.
14 | * The two main parameters are radius and roundedCorners
15 | * @see radius and
16 | * @see roundedCorners
17 | */
18 | @SuppressLint("AppCompatCustomView")
19 | class RoundedCornerImageView : ImageView {
20 |
21 | /**
22 | * Specify the radius of the corners that will be rounded in pixels
23 | */
24 | var radius: Radius =
25 | Radius(20.px)
26 | set(value) {
27 | field = value
28 | recalculateClipPath()
29 | }
30 |
31 | /**
32 | * Specify the corners to be rounded(bit-wise). eg. CORNER_BOTTOM_LEFT or CORNER_TOP_LEFT will round both those corners
33 | * CORNER_ALL xor CORNER_BOTTOM_LEFT will round everything except bottom left corner
34 | */
35 | var roundedCorners: Int =
36 | CORNER_NONE
37 | set(value) {
38 | field = value
39 | recalculateClipPath()
40 | }
41 |
42 | /**
43 | * Hold all corners for recalculating
44 | */
45 | private val cornersAll = intArrayOf(
46 | CORNER_TOP_LEFT,
47 | CORNER_TOP_RIGHT,
48 | CORNER_BOTTOM_RIGHT,
49 | CORNER_BOTTOM_LEFT
50 | )
51 |
52 | /**
53 | * The Clipping path that will be applied to the view
54 | */
55 | private val clipPath = Path()
56 |
57 | constructor(context: Context) : super(context)
58 | constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
59 | constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)
60 |
61 | override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
62 | super.onSizeChanged(w, h, oldw, oldh)
63 |
64 | // recalculate clipping path when the size of the view has been changed
65 | recalculateClipPath()
66 | }
67 |
68 | /**
69 | * Recalculates the clipping path of the view based on selected rounded corners and the actual radius
70 | * If no corners have been selected or the radius is 0 no clipping will occur
71 | */
72 | private fun recalculateClipPath() {
73 | clipPath.rewind()
74 |
75 | if (roundedCorners != CORNER_NONE && radius.sum() > 0) {
76 | val radii = FloatArray(8)
77 |
78 | for (i in 0..3) {
79 | if (isCornerRounded(cornersAll[i])) {
80 | radii[2 * i] = radius[i].toFloat()
81 | radii[2 * i + 1] = radius[i].toFloat()
82 | }
83 | }
84 | clipPath.addRoundRect(
85 | RectF(0f, 0f, width.toFloat(), height.toFloat()),
86 | radii, Path.Direction.CW
87 | )
88 | }
89 | }
90 |
91 | override fun onDraw(canvas: Canvas) {
92 | if (!clipPath.isEmpty) {
93 | canvas.clipPath(clipPath)
94 | }
95 | super.onDraw(canvas)
96 | }
97 |
98 | /**
99 | * Utility function to check corner selection
100 | */
101 | private fun isCornerRounded(corner: Int): Boolean {
102 | return roundedCorners and corner == corner
103 | }
104 |
105 | /**
106 | * Helper class for specifying radius for each individual corner
107 | */
108 | data class Radius(
109 | val topLeft: Int = 0,
110 | val topRight: Int = 0,
111 | val bottomRight: Int = 0,
112 | val bottomLeft: Int = 0
113 | ) {
114 | /**
115 | * Initialize all corners with same radius
116 | */
117 | constructor(radius: Int = 0) : this(
118 | topLeft = radius,
119 | topRight = radius,
120 | bottomRight = radius,
121 | bottomLeft = radius
122 | )
123 |
124 | override fun toString(): String = "Radius - tl:$topLeft, tr:$topRight, br:$bottomRight, $bottomLeft"
125 | fun sum(): Int = topLeft + topRight + bottomRight + bottomLeft
126 | }
127 |
128 | /**
129 | * Index operator to make drawing easier
130 | */
131 | operator fun Radius.get(index: Int): Int =
132 | when (index) {
133 | 0 -> topLeft
134 | 1 -> topRight
135 | 2 -> bottomRight
136 | 3 -> bottomLeft
137 | else -> 0
138 | }
139 |
140 | companion object {
141 | const val CORNER_NONE = 0
142 | const val CORNER_TOP_LEFT = 1
143 | const val CORNER_TOP_RIGHT = 2
144 | const val CORNER_BOTTOM_RIGHT = 4
145 | const val CORNER_BOTTOM_LEFT = 8
146 | const val CORNER_ALL = 15
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/app_info_badge_banner.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/appinfobadge/src/main/res/drawable/app_info_badge_banner.jpg
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/ic_banner_contact.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
25 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/ic_banner_libraries.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
33 |
36 |
39 |
42 |
43 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/ic_banner_licenses.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
33 |
36 |
39 |
42 |
45 |
48 |
51 |
52 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/ic_banner_permissions.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
33 |
36 |
39 |
42 |
45 |
48 |
51 |
54 |
57 |
60 |
63 |
64 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/ic_banner_permissions_2.xml:
--------------------------------------------------------------------------------
1 |
6 |
12 |
18 |
24 |
30 |
36 |
42 |
48 |
49 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/ic_banner_rate.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
22 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/ic_banner_whats_new.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
25 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/ic_contact_mail.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/ic_contact_mail_2.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/ic_contact_mail_3.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/ic_contact_site.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/ic_contact_site_2.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
33 |
36 |
37 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/ic_contact_site_bitbucket.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/ic_contact_site_facebook.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
33 |
36 |
39 |
42 |
43 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/ic_contact_site_github.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/ic_contact_site_gitlab.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/ic_right_chevron.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
16 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/item_separator.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/item_separator_dark.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/drawable/rounded_corners_mask.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/font/coda.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/font/lato.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/font/lato_bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/appinfobadge/src/main/res/font/lato_bold.ttf
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/font/lato_light.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/appinfobadge/src/main/res/font/lato_light.ttf
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/font/lato_thin.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/appinfobadge/src/main/res/font/lato_thin.ttf
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/font/roboto_mono.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/appinfobadge/src/main/res/font/roboto_mono.ttf
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/layout/bottom_dialog_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
27 |
28 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/layout/custom_view_contact.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
19 |
20 |
26 |
27 |
36 |
37 |
38 |
39 |
46 |
47 |
53 |
54 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/layout/fragment_app_info_badge.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
26 |
27 |
36 |
37 |
45 |
46 |
47 |
48 |
54 |
55 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/layout/info_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
17 |
18 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/layout/item_permission_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
23 |
24 |
25 |
36 |
37 |
53 |
54 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
13 |
14 |
15 | #FFEBEE
16 | #FFCDD2
17 | #EF9A9A
18 | #E57373
19 | #EF5350
20 | #F44336
21 | #E53935
22 | #D32F2F
23 | #C62828
24 | #B71C1C
25 | #FF8A80
26 | #FF5252
27 | #FF1744
28 | #D50000
29 |
30 | #EDE7F6
31 | #D1C4E9
32 | #B39DDB
33 | #9575CD
34 | #7E57C2
35 | #673AB7
36 | #5E35B1
37 | #512DA8
38 | #4527A0
39 | #311B92
40 | #B388FF
41 | #7C4DFF
42 | #651FFF
43 | #6200EA
44 |
45 | #E1F5FE
46 | #B3E5FC
47 | #81D4FA
48 | #4FC3F7
49 | #29B6F6
50 | #03A9F4
51 | #039BE5
52 | #0288D1
53 | #0277BD
54 | #01579B
55 | #80D8FF
56 | #40C4FF
57 | #00B0FF
58 | #0091EA
59 |
60 | #E8F5E9
61 | #C8E6C9
62 | #A5D6A7
63 | #81C784
64 | #66BB6A
65 | #4CAF50
66 | #43A047
67 | #388E3C
68 | #2E7D32
69 | #1B5E20
70 | #B9F6CA
71 | #69F0AE
72 | #00E676
73 | #00C853
74 |
75 | #FFFDE7
76 | #FFF9C4
77 | #FFF59D
78 | #FFF176
79 | #FFEE58
80 | #FFEB3B
81 | #FDD835
82 | #FBC02D
83 | #F9A825
84 | #F57F17
85 | #FFFF8D
86 | #FFFF00
87 | #FFEA00
88 | #FFD600
89 |
90 | #FBE9E7
91 | #FFCCBC
92 | #FFAB91
93 | #FF8A65
94 | #FF7043
95 | #FF5722
96 | #F4511E
97 | #E64A19
98 | #D84315
99 | #BF360C
100 | #FF9E80
101 | #FF6E40
102 | #FF3D00
103 | #DD2C00
104 |
105 | #ECEFF1
106 | #CFD8DC
107 | #B0BEC5
108 | #90A4AE
109 | #78909C
110 | #607D8B
111 | #546E7A
112 | #455A64
113 | #37474F
114 | #263238
115 |
116 | #FCE4EC
117 | #F8BBD0
118 | #F48FB1
119 | #F06292
120 | #EC407A
121 | #E91E63
122 | #D81B60
123 | #C2185B
124 | #AD1457
125 | #880E4F
126 | #FF80AB
127 | #FF4081
128 | #F50057
129 | #C51162
130 |
131 | #E8EAF6
132 | #C5CAE9
133 | #9FA8DA
134 | #7986CB
135 | #5C6BC0
136 | #3F51B5
137 | #3949AB
138 | #303F9F
139 | #283593
140 | #1A237E
141 | #8C9EFF
142 | #536DFE
143 | #3D5AFE
144 | #304FFE
145 |
146 | #E0F7FA
147 | #B2EBF2
148 | #80DEEA
149 | #4DD0E1
150 | #26C6DA
151 | #00BCD4
152 | #00ACC1
153 | #0097A7
154 | #00838F
155 | #006064
156 | #84FFFF
157 | #18FFFF
158 | #00E5FF
159 | #00B8D4
160 |
161 | #F1F8E9
162 | #DCEDC8
163 | #C5E1A5
164 | #AED581
165 | #9CCC65
166 | #8BC34A
167 | #7CB342
168 | #689F38
169 | #558B2F
170 | #33691E
171 | #CCFF90
172 | #B2FF59
173 | #76FF03
174 | #64DD17
175 |
176 | #FFF8E1
177 | #FFECB3
178 | #FFE082
179 | #FFD54F
180 | #FFCA28
181 | #FFC107
182 | #FFB300
183 | #FFA000
184 | #FF8F00
185 | #FF6F00
186 | #FFE57F
187 | #FFD740
188 | #FFC400
189 | #FFAB00
190 |
191 | #EFEBE9
192 | #D7CCC8
193 | #BCAAA4
194 | #A1887F
195 | #8D6E63
196 | #795548
197 | #6D4C41
198 | #5D4037
199 | #4E342E
200 | #3E2723
201 |
202 | #F3E5F5
203 | #E1BEE7
204 | #CE93D8
205 | #BA68C8
206 | #AB47BC
207 | #9C27B0
208 | #8E24AA
209 | #7B1FA2
210 | #6A1B9A
211 | #4A148C
212 | #EA80FC
213 | #E040FB
214 | #D500F9
215 | #AA00FF
216 |
217 | #E3F2FD
218 | #BBDEFB
219 | #90CAF9
220 | #64B5F6
221 | #42A5F5
222 | #2196F3
223 | #1E88E5
224 | #1976D2
225 | #1565C0
226 | #0D47A1
227 | #82B1FF
228 | #448AFF
229 | #2979FF
230 | #2962FF
231 |
232 | #E0F2F1
233 | #B2DFDB
234 | #80CBC4
235 | #4DB6AC
236 | #26A69A
237 | #009688
238 | #00897B
239 | #00796B
240 | #00695C
241 | #004D40
242 | #A7FFEB
243 | #64FFDA
244 | #1DE9B6
245 | #00BFA5
246 |
247 | #F9FBE7
248 | #F0F4C3
249 | #E6EE9C
250 | #DCE775
251 | #D4E157
252 | #CDDC39
253 | #C0CA33
254 | #AFB42B
255 | #9E9D24
256 | #827717
257 | #F4FF81
258 | #EEFF41
259 | #C6FF00
260 | #AEEA00
261 |
262 | #FFF3E0
263 | #FFE0B2
264 | #FFCC80
265 | #FFB74D
266 | #FFA726
267 | #FF9800
268 | #FB8C00
269 | #F57C00
270 | #EF6C00
271 | #E65100
272 | #FFD180
273 | #FFAB40
274 | #FF9100
275 | #FF6D00
276 |
277 | #FAFAFA
278 | #F5F5F5
279 | #EEEEEE
280 | #E0E0E0
281 | #BDBDBD
282 | #9E9E9E
283 | #757575
284 | #616161
285 | #424242
286 | #212121
287 |
288 | #000000
289 | #FFFFFF
290 |
291 |
292 | #DE000000
293 | #8A000000
294 | #61000000
295 | #61000000
296 |
297 |
298 | #FFFFFFFF
299 | #B3FFFFFF
300 | #80FFFFFF
301 | #80FFFFFF
302 |
303 | #FFFFFF
304 | #121212
305 |
306 |
307 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/values/font_certs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - @array/com_google_android_gms_fonts_certs_dev
5 | - @array/com_google_android_gms_fonts_certs_prod
6 |
7 |
8 | -
9 | MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAeFw0wODA0MTUyMzM2NTZaFw0zNTA5MDEyMzM2NTZaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBANbOLggKv+IxTdGNs8/TGFy0PTP6DHThvbbR24kT9ixcOd9W+EaBPWW+wPPKQmsHxajtWjmQwWfna8mZuSeJS48LIgAZlKkpFeVyxW0qMBujb8X8ETrWy550NaFtI6t9+u7hZeTfHwqNvacKhp1RbE6dBRGWynwMVX8XW8N1+UjFaq6GCJukT4qmpN2afb8sCjUigq0GuMwYXrFVee74bQgLHWGJwPmvmLHC69EH6kWr22ijx4OKXlSIx2xT1AsSHee70w5iDBiK4aph27yH3TxkXy9V89TDdexAcKk/cVHYNnDBapcavl7y0RiQ4biu8ymM8Ga/nmzhRKya6G0cGw8CAQOjgfwwgfkwHQYDVR0OBBYEFI0cxb6VTEM8YYY6FbBMvAPyT+CyMIHJBgNVHSMEgcEwgb6AFI0cxb6VTEM8YYY6FbBMvAPyT+CyoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJANWFuGx90071MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADggEBABnTDPEF+3iSP0wNfdIjIz1AlnrPzgAIHVvXxunW7SBrDhEglQZBbKJEk5kT0mtKoOD1JMrSu1xuTKEBahWRbqHsXclaXjoBADb0kkjVEJu/Lh5hgYZnOjvlba8Ld7HCKePCVePoTJBdI4fvugnL8TsgK05aIskyY0hKI9L8KfqfGTl1lzOv2KoWD0KWwtAWPoGChZxmQ+nBli+gwYMzM1vAkP+aayLe0a1EQimlOalO762r0GXO0ks+UeXde2Z4e+8S/pf7pITEI/tP+MxJTALw9QUWEv9lKTk+jkbqxbsh8nfBUapfKqYn0eidpwq2AzVp3juYl7//fKnaPhJD9gs=
10 |
11 |
12 |
13 | -
14 | MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0wODA4MjEyMzEzMzRaFw0zNjAxMDcyMzEzMzRaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBAKtWLgDYO6IIrgqWbxJOKdoR8qtW0I9Y4sypEwPpt1TTcvZApxsdyxMJZ2JORland2qSGT2y5b+3JKkedxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjAsb/GEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/CxURaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJEqO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/Tgt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/appinfobadge/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Trust badge
4 | What\'s new
5 | License
6 | Libraries
7 | Rate me
8 | Contact
9 | Version %1$s
10 | SETTINGS
11 |
12 |
--------------------------------------------------------------------------------
/appinfobadge/src/test/java/com/dci/dev/appinfobadge/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.dci.dev.appinfobadge
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.3.61'
5 | repositories {
6 | google()
7 | jcenter()
8 |
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.6.1'
12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13 | // Jitpack
14 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
15 | classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
16 |
17 | // NOTE: Do not place your application dependencies here; they belong
18 | // in the individual module build.gradle files
19 | }
20 | }
21 |
22 | allprojects {
23 | repositories {
24 | google()
25 | jcenter()
26 | maven { url 'https://jitpack.io' }
27 | }
28 | }
29 |
30 | task clean(type: Delete) {
31 | delete rootProject.buildDir
32 | }
33 |
--------------------------------------------------------------------------------
/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/demo.gif
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
22 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ditacristianionut/AppInfoBadge/43f6c3426d51515d5b9c15734aec16eef26197a5/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Mar 15 23:07:36 EET 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name='AppInfoBadge'
2 | include ':app'
3 | include ':appinfobadge'
4 |
--------------------------------------------------------------------------------