├── .bettercodehub.yml
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ ├── config.yml
│ ├── documentation_needed.md
│ └── feature_request.md
└── workflows
│ ├── build.yml
│ ├── minorBuild.yml
│ ├── prepRelease.yml
│ └── release.yml
├── .gitignore
├── .project
├── .remarkrc
├── .vscode
└── settings.json
├── LICENSE
├── README.md
├── base-android-library
├── .classpath
├── .gitignore
├── build.gradle
├── proguard-rules.pro
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── kotlin
│ │ └── network
│ │ │ └── xyo
│ │ │ └── base
│ │ │ ├── Helpers.kt
│ │ │ ├── XYBase.kt
│ │ │ ├── XYLogging.kt
│ │ │ └── XYRandom.kt
│ │ └── res
│ │ └── values
│ │ └── strings.xml
└── version.properties
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── jitpack.yml
└── settings.gradle
/.bettercodehub.yml:
--------------------------------------------------------------------------------
1 | component_depth: 8
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve the XYO Android SDK
4 | title: '[BUG]'
5 | labels: bug
6 | assignees: ''
7 | ---
8 |
9 | **Observed behavior**
10 | A clear and concise description of what exactly happened.
11 |
12 | **Expected behavior**
13 | A clear and concise description of what you expected to happen.
14 |
15 | **To Reproduce**
16 | Steps to reproduce the behavior:
17 |
18 | 1. Go to '...'
19 | 2. Click on '....'
20 | 3. Scroll down to '....'
21 | 4. See error
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Smartphone (please complete the following information):**
27 |
28 | - Device: [e.g. Samsung Galaxy, Google Pixel]
29 | - OS: [e.g. Android 10]
30 | - Browser [e.g. stock browser, chrome]
31 |
32 | **Additional context**
33 | Add any other context about the problem here.
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 | contact_links:
3 | - name: XYO Developer Portal
4 | url: https://developers.xyo.network/
5 | about: XYO Foundation Developer Portal
6 | - name: XYO Foundation Site
7 | url: https://xyo.network/
8 | about: Check out the fundamentals of our Foundation here
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/documentation_needed.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Documentation needed
3 | about: Suggest documentation that is needed
4 | title: '[DOCUMENTATION]:'
5 | labels: documentation
6 | assignees: ''
7 | ---
8 |
9 | **Is your documentation request related to a problem? Please describe.**
10 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11 |
12 | **Describe the documentation and format you would like**
13 | A clear and concise description of what documentation you would like to see and what type for format.
14 | Ex. Step-by-step, Paragraph explainer, screenshots, etc.
15 |
16 | **Additional context**
17 | Add any other context or screenshots about the document request here.
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for XYO SDK Android
4 | title: '[FEATURE]'
5 | labels: enhancement
6 | assignees: ''
7 | ---
8 |
9 | **Is your feature request related to a problem? Please describe.**
10 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11 |
12 | **Describe the solution you'd like**
13 | A clear and concise description of what you want to happen.
14 |
15 | **Describe alternatives you've considered**
16 | A clear and concise description of any alternative solutions or features you've considered.
17 |
18 | **Additional context**
19 | Add any other context or screenshots about the feature request here. This could include specific devices, android versions, etc.
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 |
3 | on:
4 | push:
5 | branches:
6 | - 'develop'
7 |
8 | jobs:
9 | build:
10 |
11 | runs-on: ubuntu-latest
12 | steps:
13 | - uses: actions/checkout@v2
14 | - name: pre-build
15 | run: chmod +x ./gradlew
16 | - name: build
17 | run: ./gradlew clean assemble
18 |
--------------------------------------------------------------------------------
/.github/workflows/minorBuild.yml:
--------------------------------------------------------------------------------
1 | name: Minor Branch Build
2 |
3 | on:
4 | push:
5 | branches-ignore:
6 | - 'develop'
7 | - 'release'
8 | - 'master'
9 |
10 | jobs:
11 | build:
12 |
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v2
16 | - name: pre-build
17 | run: chmod +x ./gradlew
18 | - name: build
19 | run: ./gradlew clean assemble
--------------------------------------------------------------------------------
/.github/workflows/prepRelease.yml:
--------------------------------------------------------------------------------
1 | name: Prepare Release
2 |
3 | on:
4 | push:
5 | branches:
6 | - 'release'
7 |
8 | jobs:
9 | build:
10 |
11 | runs-on: ubuntu-latest
12 | steps:
13 | - uses: actions/checkout@v2
14 | - name: pre-build
15 | run: chmod +x ./gradlew
16 | - name: build
17 | run: ./gradlew :base-android-library:assemble
18 | - name: check in local changes
19 | run: |
20 | git status
21 | git add base-android-library/version.properties
22 | - name: commit file
23 | run: |
24 | git config --local user.email "action@github.com"
25 | git config --local user.name "GitHub Action"
26 | git commit -m "version bump" -a
27 | - name: push changes
28 | uses: ad-m/github-push-action@master
29 | with:
30 | github_token: ${{ secrets.GITHUB_TOKEN }}
31 | branch: 'release'
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 |
3 | on:
4 | push:
5 | branches:
6 | - "master"
7 |
8 | jobs:
9 | publish:
10 | runs-on: ubuntu-latest
11 |
12 | steps:
13 | - uses: actions/checkout@master
14 | - uses: actions/setup-java@v1
15 | with:
16 | java-version: 1.8
17 | - name: pre-build
18 | run: chmod +x gradlew
19 | - name: install
20 | run: ./gradlew install
21 | - name: assemble
22 | run: ./gradlew :base-android-library:assembleRelease
23 | - name: print version
24 | run: |
25 | echo "##[set-output name=version;]$(gradle -q printVersion)"
26 | id: release_version
27 | env:
28 | ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"
29 | - name: bintray upload
30 | env:
31 | BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
32 | BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
33 | run: ./gradlew :base-android-library:bintrayUpload
34 | - name: get commit message
35 | run: |
36 | echo ::set-env name=commitmsg::$(git log --format=%B -n 1 ${{ github.event.after }})
37 | env:
38 | ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"
39 | - name: show commit message
40 | run: echo $commitmsg
41 | env:
42 | ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"
43 | - name: Create Release
44 | id: create_release
45 | uses: actions/create-release@v1
46 | env:
47 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48 | with:
49 | tag_name: ${{ steps.release_version.outputs.version }}
50 | release_name: Release ${{ env.commitmsg }}
51 | draft: true
52 | prerelease: false
53 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | local.properties
3 | .idea
4 | *.iml
5 | build
6 | captures
7 | proguardTools
8 | .DS_Store
9 | .DS_Store?
10 | *.apk
11 | google-services.json
12 | .settings
13 | .project
14 | base-android-sample/release/
15 |
16 | *.hprof
17 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | sdk-base-android
4 | Project sdk-base-android created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.buildship.core.gradleprojectbuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.buildship.core.gradleprojectnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.remarkrc:
--------------------------------------------------------------------------------
1 | {
2 |
3 | }
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "java.configuration.updateBuildConfiguration": "interactive"
3 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [logo]:https://cdn.xy.company/img/brand/XYO_full_colored.png
2 |
3 | [![logo]](https://xyo.network)
4 |
5 |
6 | # sdk-base-android
7 |
8 |   [](https://jitpack.io/#XYOracleNetwork/sdk-base-android) [](https://bettercodehub.com/) [](https://www.codacy.com/gh/XYOracleNetwork/sdk-base-android?utm_source=github.com&utm_medium=referral&utm_content=XYOracleNetwork/sdk-base-android&utm_campaign=Badge_Grade) [](https://codeclimate.com/github/XYOracleNetwork/sdk-base-android/maintainability) [](https://snyk.io/test/github/XYOracleNetwork/sdk-base-android?targetFile=base-android-library/build.gradle)
9 |
10 | > The XYO Foundation provides this source code available in our efforts to advance the understanding of the XYO Protocol and its possible uses. We continue to maintain this software in the interest of developer education. Usage of this source code is not intended for production.
11 |
12 | ## Table of Contents
13 |
14 | - [Title](#sdk-base-android)
15 | - [Install](#install)
16 | - [Contributing](#contributing)
17 | - [License](#license)
18 | - [Credits](#credits)
19 |
20 | An XY inspired utility framework for Android and Kotlin
21 |
22 | ## Install
23 |
24 | Add as dependency in `build.gradle`
25 |
26 | ```gradle
27 | dependencies {
28 | api 'com.github.XYOracleNetwork:sdk-base-android:2.1.289'
29 | }
30 | ```
31 |
32 | ## How to use
33 |
34 | Easily check for required permissions:
35 |
36 | ```kotlin
37 | val permissions = XYPermissions(this.activity!!)
38 | permissions.requestPermission(Manifest.permission.READ_EXTERNAL_STORAGE,
39 | "Store a picture on your device.", CAM_PERMISSION_REQ_CODE)
40 | ```
41 |
42 | Get the device name:
43 |
44 | ```kotlin
45 | val deviceName = XYDeviceName.getDeviceName()
46 | val deviceName = XYDeviceName.getDeviceName("default_val_if_unknown")
47 | val deviceName = XYDeviceName.getDeviceName(Build.MANUFACTURER, Build.MODEL, "default_val_if_unknown")
48 | ```
49 |
50 | Logging:
51 |
52 | ```kotlin
53 | log.info("A simple INFO log")
54 | log.info("myFunctionName", "A simple INFO log")
55 | log.action("Actions are events that are generated by the user, like pushing a button")
56 | log.status("Status are Large Scale Events, Such As Startup, or Shutdown")
57 | log.error("An error occured" , false) //set true to rethrow error
58 | log.error(myException) //Any Handled Exceptions
59 | log.error("An error with a custom message")
60 | ```
61 |
62 | ## Contributing
63 |
64 | Please note that any contributions must clear the `release` branch.
65 |
66 | ## License
67 |
68 | See the [LICENSE.md](LICENSE) file for license details.
69 |
70 | ## Credits
71 |
72 | Made with 🔥and ❄️ by [XYO](https://www.xyo.network)
73 |
--------------------------------------------------------------------------------
/base-android-library/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/base-android-library/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | local.properties
3 | .idea
4 | *.iml
5 | build
6 | captures
7 | proguardTools
8 | .DS_Store
9 | .DS_Store?
10 | *.apk
11 | google-services.json
12 | .settings
13 | .project
--------------------------------------------------------------------------------
/base-android-library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'maven-publish'
4 |
5 | group = 'network.xyo'
6 |
7 | buildscript {
8 | repositories {
9 | mavenCentral()
10 | mavenLocal()
11 | google()
12 | }
13 | }
14 |
15 | Properties versionProps = new Properties()
16 | def versionPropsFile = file('version.properties')
17 |
18 | if (versionPropsFile.exists())
19 | versionProps.load(new FileInputStream(versionPropsFile))
20 |
21 | def increment = 0
22 |
23 | def runTasks = gradle.startParameter.taskNames
24 |
25 | if (':base-android-library:assemble' in runTasks) {
26 | increment = 1
27 | }
28 |
29 | def majorVersion = 4
30 | def minorVersion = 2
31 | def patchVersion = versionProps['VERSION_PATCH'].toInteger() + increment
32 |
33 | def verString = majorVersion + '.' + minorVersion + '.' + patchVersion
34 |
35 | task printVersion {
36 | println verString
37 | }
38 |
39 | android {
40 | compileSdkVersion 31
41 | buildToolsVersion '30.0.3'
42 |
43 | versionProps['VERSION_PATCH'] = patchVersion.toString()
44 | versionProps.store(versionPropsFile.newWriter(), null)
45 |
46 | defaultConfig {
47 | minSdkVersion 21
48 | targetSdkVersion 31
49 | }
50 |
51 | buildTypes {
52 | release {
53 | minifyEnabled false
54 | }
55 | debug {
56 | minifyEnabled false
57 | }
58 | }
59 |
60 | compileOptions {
61 | sourceCompatibility "1.8"
62 | targetCompatibility "1.8"
63 | kotlinOptions {
64 | allWarningsAsErrors = true
65 | }
66 | }
67 |
68 | sourceSets {
69 | main.java.srcDirs += 'src/main/kotlin'
70 | }
71 |
72 | packagingOptions {
73 | exclude 'META-INF/build.kotlin_module'
74 | exclude 'META-INF/atomicfu.kotlin_module'
75 | exclude 'META-INF/library_release.kotlin_module'
76 | }
77 | }
78 |
79 | publishing {
80 | publications {
81 | Production(MavenPublication) {
82 | artifact("$buildDir/outputs/aar/base-android-library-release.aar")
83 | groupId 'network.xyo'
84 | artifactId 'sdk-base-android'
85 | version verString
86 |
87 | //The publication doesn't know about our dependencies, so we have to manually add them to the pom
88 | pom.withXml {
89 | def dependenciesNode = asNode()['dependencies'][0] ?: asNode().appendNode('dependencies')
90 | //Iterate over the compile dependencies (we don't want the test ones), adding a node for each
91 | configurations.implementation.allDependencies.each {
92 | if (it.name != 'unspecified') {
93 | def dependencyNode = dependenciesNode.appendNode('dependency')
94 | dependencyNode.appendNode('groupId', it.group)
95 | dependencyNode.appendNode('artifactId', it.name)
96 | dependencyNode.appendNode('version', it.version)
97 | }
98 | }
99 | }
100 | }
101 | }
102 | }
103 |
104 | repositories {
105 | mavenCentral()
106 | mavenLocal()
107 | google()
108 | }
109 |
110 | dependencies {
111 | implementation fileTree(include: ['*.jar'], dir: 'libs')
112 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0'
113 | implementation 'com.jaredrummler:android-device-names:2.1.0'
114 | }
115 |
--------------------------------------------------------------------------------
/base-android-library/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/arietrouw/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
27 | # We only want obfuscation
28 | -keepattributes InnerClasses
29 | -keepattributes Signature
30 | -keepattributes Exceptions
31 | -keepattributes *Annotation*
32 | -keepattributes EnclosingMethod
33 |
34 | -keep public class network.xyo.base.* { *; }
35 |
36 | -dontwarn java.lang.invoke.**
37 |
38 | -verbose
--------------------------------------------------------------------------------
/base-android-library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/base-android-library/src/main/kotlin/network/xyo/base/Helpers.kt:
--------------------------------------------------------------------------------
1 | package network.xyo.base
2 |
3 | import android.os.Debug
4 | import com.jaredrummler.android.device.DeviceName
5 |
6 | val currentThreadName : String
7 | get() = Thread.currentThread().name
8 |
9 | val deviceName: String
10 | get() = DeviceName.getDeviceName()
11 |
12 | val hasDebugger: Boolean
13 | get() = Debug.isDebuggerConnected()
14 |
15 | fun classNameFromObject(objectToCheck: Any): String {
16 | val parts = objectToCheck.javaClass.kotlin.simpleName?.split('.') ?: return "Unknown"
17 | return parts[parts.lastIndex]
18 | }
--------------------------------------------------------------------------------
/base-android-library/src/main/kotlin/network/xyo/base/XYBase.kt:
--------------------------------------------------------------------------------
1 | package network.xyo.base
2 |
3 | import android.app.Activity
4 | import android.content.Context
5 | import android.content.ContextWrapper
6 |
7 | open class XYBase {
8 |
9 | val now: Long
10 | get() {
11 | return System.currentTimeMillis()
12 | }
13 |
14 | val nowNano: Long
15 | get() {
16 | return System.nanoTime()
17 | }
18 |
19 | //we just-in-time create this as to not create it on objects that don't need it
20 | private var _log: XYLogging? = null
21 | val log: XYLogging
22 | get() {
23 | synchronized(this) {
24 | if (_log == null) {
25 | _log = XYLogging(this)
26 | }
27 | return _log ?: throw NullPointerException()
28 | }
29 | }
30 |
31 | val className: String
32 | get() {
33 | return classNameFromObject(this)
34 | }
35 |
36 | fun getActivity(context: Context): Activity? {
37 | var contextToCheck = context
38 | while (contextToCheck is ContextWrapper) {
39 | when (contextToCheck) {
40 | is Activity -> return contextToCheck
41 | else -> contextToCheck = contextToCheck.baseContext
42 | }
43 | }
44 | return null
45 | }
46 | }
--------------------------------------------------------------------------------
/base-android-library/src/main/kotlin/network/xyo/base/XYLogging.kt:
--------------------------------------------------------------------------------
1 | package network.xyo.base
2 |
3 | import android.util.Log
4 |
5 | /* We have everyone of these functions returning 'this' to allow for chaining */
6 |
7 | open class XYLogging(sourceAny: Any) {
8 | private val source = classNameFromObject(sourceAny)
9 |
10 | open fun error(message: String, reThrow: Boolean): XYLogging {
11 | Log.e(source, message)
12 | val stackTrace = Thread.currentThread().stackTrace
13 | if (!stackTrace.isNullOrEmpty()) {
14 | Log.e(source, stackTrace.contentDeepToString().replace(", ", ",\r\n"))
15 | }
16 | if (reThrow) {
17 | throw RuntimeException()
18 | }
19 | return this
20 | }
21 |
22 | //Any Handled Exceptions
23 | open fun error(ex: Throwable): XYLogging {
24 | error(ex, false)
25 | return this
26 | }
27 |
28 | open fun error(ex: Throwable, reThrow: Boolean): XYLogging {
29 | Log.e(source, classNameFromObject(ex))
30 | val stackTrace = ex.stackTrace
31 | if (!stackTrace.isNullOrEmpty()) {
32 | Log.e(source, stackTrace.contentDeepToString().replace(", ", ",\r\n"))
33 | }
34 |
35 | if (hasDebugger) {
36 | if (reThrow) {
37 | throw RuntimeException(ex)
38 | }
39 | }
40 | return this
41 | }
42 |
43 | open fun error(message: String): XYLogging {
44 | Log.e(source, "$message:${currentThreadName}")
45 | return this
46 | }
47 |
48 | //Normal information used for debugging. Items should be less noisy than Extreme items
49 | open fun info(function: String, message: String): XYLogging {
50 | Log.i(source, "$source:$function:$message [${currentThreadName}]")
51 | return this
52 | }
53 |
54 | open fun info(message: String): XYLogging {
55 | Log.i(source, "$message [${currentThreadName}]")
56 | return this
57 | }
58 |
59 | //Actions are events that are generated by the user, like pushing a button
60 | open fun action(action: String): XYLogging {
61 | Log.i(source, action)
62 | return this
63 | }
64 |
65 | //Status are Large Scale Events, Such As Startup, or Shutdown,
66 | //that may or may not be a result of a user action
67 | open fun status(status: String): XYLogging {
68 | Log.i(source, "App Status: $status")
69 | return this
70 | }
71 | }
--------------------------------------------------------------------------------
/base-android-library/src/main/kotlin/network/xyo/base/XYRandom.kt:
--------------------------------------------------------------------------------
1 | package network.xyo.base
2 |
3 | import java.util.*
4 |
5 | class XYRandom : XYBase() {
6 | companion object {
7 | fun generateRandomBase62String(length: Int): String {
8 | val randomString = StringBuilder()
9 | val rand = Random(System.currentTimeMillis())
10 | for (x in 0 until length) {
11 | var rnd = rand.nextInt(62)
12 | rnd += when {
13 | rnd < 10 -> 48
14 | rnd < 36 -> 65 - 10
15 | else -> 97 - 36
16 | }
17 | randomString.append(rnd.toChar())
18 | }
19 | return randomString.toString()
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/base-android-library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/base-android-library/version.properties:
--------------------------------------------------------------------------------
1 | #Thu Dec 02 13:57:46 PST 2021
2 | VERSION_PATCH=16
3 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | repositories {
4 | google()
5 | mavenCentral()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:7.0.3'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0"
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | mavenCentral()
21 | maven { url "https://jitpack.io" }
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 |
2 | android.enableJetifier=true
3 | android.useAndroidX=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xy-graveyard/sdk-base-android/235c3e4d9b9394abf3c13e82ebceafff1d4ccdd4/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Aug 08 21:05:15 PDT 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-7.0.2-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 |
--------------------------------------------------------------------------------
/jitpack.yml:
--------------------------------------------------------------------------------
1 | jdk:
2 | - openjdk11
3 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':base-android-library'
2 | rootProject.name='sdk-base-android'
--------------------------------------------------------------------------------