diff --git a/.travis.yml b/.travis.yml
index a82dba3b..50d35052 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,12 +6,13 @@ jdk:
android:
components:
- tools
- - android-28
- - build-tools-28.0.3
+ - android-29
+ - build-tools-29.0.2
- platform-tools
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
cache:
+ bundler : true
directories:
- "${TRAVIS_BUILD_DIR}/gradle/caches/"
- "${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/"
@@ -23,6 +24,7 @@ install:
before_script:
- bash scripts/prep-key.sh
+ - bash scripts/check-screenshots.sh
script:
- ./gradlew spotlessCheck
@@ -35,8 +37,10 @@ deploy:
on:
all_branches: true
condition: $TRAVIS_BRANCH =~ ^(master|development)$
+ repo: fossasia/badge-magic-android
- provider: script
skip_cleanup: true
script: bash scripts/upload-gh-pages.sh
on:
- all_branches: true
\ No newline at end of file
+ all_branches: true
+ repo: fossasia/badge-magic-android
diff --git a/README.md b/README.md
index f8679777..bd0704f6 100644
--- a/README.md
+++ b/README.md
@@ -1,61 +1,51 @@
-# Badge Magic [![Build Status](https://travis-ci.org/fossasia/badge-magic-android.svg?branch=development)](https://travis-ci.org/fossasia/badge-magic-android) [![Join the chat at https://gitter.im/fossasia/badge-magic](https://badges.gitter.im/fossasia/badge-magic.svg)](https://gitter.im/fossasia/badge-magic?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+# Badge Magic
+[![Build Status](https://travis-ci.org/fossasia/badge-magic-android.svg?branch=development)](https://travis-ci.org/fossasia/badge-magic-android) [![Join the chat at https://gitter.im/fossasia/badge-magic](https://badges.gitter.im/fossasia/badge-magic.svg)](https://gitter.im/fossasia/badge-magic?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-**Magically Create Symbols and Text on LED Name Badges using Bluetooth**
+**Magically Create Text and Draw Cliparts on LED Name Badges using Bluetooth**
-The Badge Magic Android app lets you create scrolling symbols and text on LED name badges through Bluetooth. The app provides options to portray names, clipart and simple animations on LED badges. For the data transfer from the smartphone to the LED badge we use Bluetooth. The project is based on the work of [Nilhcem](https://github.com/Nilhcem).
+The Badge Magic Android app lets you create moving text and draw cliparts for to LED name badges. The app provides options to portray names, cliparts and simple animations on the badges. For the data transfer from the smartphone to the LED badge it uses Bluetooth. The project is based on the work of [Nilhcem](https://github.com/Nilhcem).
-
-
-
-
-
-
-
-
+
+
## Download
-* Download **[Badge Magic Dev Release here](https://github.com/fossasia/badge-magic-android/blob/apk/badge-magic-dev-release.apk)**
-* Download Tested [LED Badge Version here](https://github.com/fossasia/badge-magic-android/blob/apk/LED-badge-dev.apk)
+* [Latest Release Build](https://github.com/fossasia/badge-magic-android/raw/apk/badge-magic-master-release.apk) in the apk branch
+* [Latest Development Build](https://github.com/fossasia/badge-magic-android/raw/apk/badge-magic-development-release.apk) in the apk branch
## Permissions
-* Bluetooth: For sending data to the badge.
-* GPS Location: This has been the standard set by Android for use with Bluetooth Low Energy (BLE) devices. For more information, please read the notes on [Android website](https://source.android.com/devices/bluetooth/ble).
+* **Bluetooth**: For sending data to the badge.
+* **GPS Location**: This has been the standard set by Android for use with Bluetooth Low Energy (BLE) devices. For more information, please read the notes on [Android website](https://source.android.com/devices/bluetooth/ble).
+* **Storage**: For storing and saving badges.
## Communication
Please talk to us on the badge-magic [Gitter channel here](https://gitter.im/fossasia/badge-magic).
-## Reverse-Engineering Bluetooth LE Devices
-
-Security in Bluetooth LE devices is optional, and many cheap products you can find on the market are not secured at all. This applies to our Bluetooth LED Badge. While this could lead to some privacy issues, this can also be a source of fun, especially when you want to use an LED Badge in a different way. It also makes it easy for us to get started with the development of a Free and Open Source Android app.
-
-As we understand how the Bluetooth LED badge works, converting a text to multiple byte arrays, we can send using the Bluetooth LE APIs. An indepth blog post about reverse-engineering the Bluetooth community [is here](http://nilhcem.com/iot/reverse-engineering-bluetooth-led-name-badge).
-
-The implementation in the Android app consists of manipulating bits. That may be tricky. A single bit error and nothing will work, plus it will be hard to debug. For those reasons, and since the specs are perfectly clear the reverse engineer Gautier Mechling strongly recommends to start writing unit tests before the code implementation.
-
## Available Devices
There are a number of devices with Bluetooth on the market. As far as we can tell they are mostly from the same manufacturer. When you get a device ensure it comes with Bluetooth. There are devices that don't support Bluetooth. These are not supported in the app currently.
-* Get one from [here](https://sg.pslab.io/product/led-badge/)
+* Get one from the [FOSSASIA Shop here](https://fossasia.com/product/led-badge/)
## Screenshots
| | | |
|-------------|-------------|-------------|
-| | | |
+| | | |
| | | |
-| | | |
+| | | |
-## Contributions Best Practices
+## Reverse-Engineering Bluetooth LE Devices
-### For first time Contributor
+Security in Bluetooth LE devices is optional, and many cheap products you can find on the market are not secured at all. This applies to our Bluetooth LED Badge. While this could lead to some privacy issues, this can also be a source of fun, especially when you want to use an LED Badge in a different way. It also makes it easy for us to get started with the development of a Free and Open Source Android app.
-First time contributors can read [CONTRIBUTING.md](CONTRIBUTING.md) file for help regarding creating issues and sending pull requests.
+As we understand how the Bluetooth LED badge works, converting a text to multiple byte arrays, we can send using the Bluetooth LE APIs. An indepth blog post about reverse-engineering the Bluetooth community [is here](http://nilhcem.com/iot/reverse-engineering-bluetooth-led-name-badge).
-### Branch Policy
+The implementation in the Android app consists of manipulating bits. That may be tricky. A single bit error and nothing will work, plus it will be hard to debug. For those reasons, and since the specs are perfectly clear the reverse engineer Gautier Mechling strongly recommends to start writing unit tests before the code implementation.
+
+## Branch Policy
We have the following branches
@@ -66,17 +56,18 @@ We have the following branches
- Once a pull request is merged, the previous APK branch is deleted and a new APK branch is created.
- If a PR is merged in development branch then the new APKs for the development branch are generated whereas the APKs corresponding to the master branch are not regenerated and simply the previously generated files are added.
-### Code practices
+## Contributions Best Practices
-Please help us follow the best practice to make it easy for the reviewer as well as the contributor. We want to focus on the code quality more than on managing pull request ethics.
+Please read FOSSASIA's [Best Practices](https://blog.fossasia.org/open-source-developer-guide-and-best-practices-at-fossasia/) before contributing. Please help us follow the best practice to make it easy for the reviewer as well as the contributor. We want to focus on the code quality more than on managing pull request ethics. Here are some basics:
- * Single commit per pull request
- * For writing commit messages please read the [CommitStyle.md](docs/commitStyle.md) carefully. Kindly adhere to the guidelines.
- * Follow uniform design practices. The design language must be consistent throughout the app.
- * The pull request will not get merged until and unless the commits are squashed. In case there are multiple commits on the PR, the commit author needs to squash them and not the maintainers cherrypicking and merging squashes.
- * If the PR is related to any front end change, please attach relevant screenshots in the pull request description.
+* Single commit per pull request
+* For writing commit messages please read the [CommitStyle.md](docs/commitStyle.md).
+* Follow uniform design practices. The design language must be consistent throughout the app.
+* The pull request will not get merged until and unless the commits are squashed. In case there are multiple commits on the PR, the commit author needs to squash them and not the maintainers cherrypicking and merging squashes.
+* If the PR is related to any front end change, please attach relevant screenshots in the pull request description.
+* Before you join development, please set up the project on your local machine, run it and go through the application completely. Press on any button you can find and see where it leads to. Explore.
+* If you would like to work on an issue, drop in a comment at the issue. If it is already assigned to someone, but there is no sign of any work being done, please free to drop in a comment and start working on it.
-### Join the development
+## LICENSE
-* Before you join development, please set up the project on your local machine, run it and go through the application completely. Press on any button you can find and see where it leads to. Explore. (Don't worry ... Nothing will happen to the app or to you due to the exploring :wink: Only thing that will happen is, you'll be more familiar with what is where and might even get some cool ideas on how to improve various aspects of the app.)
-* If you would like to work on an issue, drop in a comment at the issue. If it is already assigned to someone, but there is no sign of any work being done, please free to drop in a comment so that the issue can be assigned to you if the previous assignee has dropped it entirely.
+The application is licensed under the [Apache License 2.0](/LICENSE). Copyright is owned by FOSSASIA and its contributors.
diff --git a/app/build.gradle b/app/build.gradle
index c74ca1ba..0bc6b206 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,5 +1,5 @@
plugins {
- id "com.diffplug.gradle.spotless" version "3.24.1"
+ id "com.diffplug.gradle.spotless" version "3.26.1"
}
apply plugin: "com.github.b3er.local.properties"
apply plugin: 'com.android.application'
@@ -23,8 +23,8 @@ android {
applicationId 'org.fossasia.badgemagic'
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
- versionCode 7
- versionName '1.5.0'
+ versionCode 8
+ versionName '1.6.0'
vectorDrawables.useSupportLibrary = true
}
@@ -84,8 +84,8 @@ dependencies {
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.16'
//Android X Libraries
- implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
- implementation 'androidx.recyclerview:recyclerview:1.1.0-beta02'
+ implementation 'androidx.appcompat:appcompat:1.1.0'
+ implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
@@ -93,17 +93,17 @@ dependencies {
implementation "org.koin:koin-androidx-viewmodel:${versions.koin_version}"
//Material Design
- implementation 'com.google.android.material:material:1.1.0-alpha09'
+ implementation 'com.google.android.material:material:1.1.0-beta01'
//Timber
implementation 'com.jakewharton.timber:timber:4.7.1'
- implementation 'no.nordicsemi.android.support.v18:scanner:1.4.2'
+ implementation 'no.nordicsemi.android.support.v18:scanner:1.4.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
testImplementation 'com.nhaarman:mockito-kotlin-kt1.1:1.5.0'
- testImplementation 'org.amshove.kluent:kluent:1.53'
+ testImplementation 'org.amshove.kluent:kluent:1.58'
// Leak Canary
debugImplementation "com.squareup.leakcanary:leakcanary-android:${versions.leak_canary}"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 2812dcfa..1d273b69 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -6,9 +6,9 @@
-
+
-
+
@@ -20,6 +20,7 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
+ android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
diff --git a/app/src/main/java/org/fossasia/badgemagic/adapter/DrawableAdapter.kt b/app/src/main/java/org/fossasia/badgemagic/adapter/DrawableAdapter.kt
index 606ba364..e480f023 100644
--- a/app/src/main/java/org/fossasia/badgemagic/adapter/DrawableAdapter.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/adapter/DrawableAdapter.kt
@@ -1,8 +1,8 @@
package org.fossasia.badgemagic.adapter
-import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.ViewGroup
+import androidx.recyclerview.widget.RecyclerView
import org.fossasia.badgemagic.R
import org.fossasia.badgemagic.data.DrawableInfo
import org.fossasia.badgemagic.ui.DrawerActivity
@@ -49,4 +49,4 @@ class DrawableAdapter : RecyclerView.Adapter() {
interface OnDrawableSelected {
fun onSelected(selectedItem: DrawableInfo)
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/adapter/DrawableItemHolder.kt b/app/src/main/java/org/fossasia/badgemagic/adapter/DrawableItemHolder.kt
index 1355dc0e..98018b10 100644
--- a/app/src/main/java/org/fossasia/badgemagic/adapter/DrawableItemHolder.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/adapter/DrawableItemHolder.kt
@@ -5,6 +5,7 @@ import android.graphics.drawable.VectorDrawable
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
+import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import org.fossasia.badgemagic.R
import org.fossasia.badgemagic.data.DrawableInfo
@@ -23,10 +24,10 @@ class DrawableItemHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
else if (drawableInfo.image is BitmapDrawable)
image.setImageBitmap(ImageUtils.trim(drawableInfo.image.bitmap, 80))
- image.setColorFilter(itemView.context.resources.getColor(android.R.color.black))
+ image.setColorFilter(ContextCompat.getColor(itemView.context, android.R.color.black))
card.setOnClickListener {
listener?.onSelected(drawableInfo)
}
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/adapter/ModeAdapter.kt b/app/src/main/java/org/fossasia/badgemagic/adapter/ModeAdapter.kt
index 8a605ef8..b024c107 100644
--- a/app/src/main/java/org/fossasia/badgemagic/adapter/ModeAdapter.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/adapter/ModeAdapter.kt
@@ -1,8 +1,8 @@
package org.fossasia.badgemagic.adapter
-import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.ViewGroup
+import androidx.recyclerview.widget.RecyclerView
import org.fossasia.badgemagic.R
import org.fossasia.badgemagic.data.ModeInfo
@@ -45,4 +45,4 @@ class ModeAdapter : RecyclerView.Adapter() {
interface OnModeSelected {
fun onSelected(position: Int)
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/adapter/ModeItemHolder.kt b/app/src/main/java/org/fossasia/badgemagic/adapter/ModeItemHolder.kt
index dfeae5e1..78dfe648 100644
--- a/app/src/main/java/org/fossasia/badgemagic/adapter/ModeItemHolder.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/adapter/ModeItemHolder.kt
@@ -4,6 +4,7 @@ import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
+import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import org.fossasia.badgemagic.R
import org.fossasia.badgemagic.data.ModeInfo
@@ -25,14 +26,14 @@ class ModeItemHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
when (itemPosition == modeSelectedPosition) {
true -> {
- card.background = itemView.context.resources.getDrawable(R.color.colorAccent)
- title.setTextColor(itemView.context.resources.getColor(android.R.color.white))
- image.setColorFilter(itemView.context.resources.getColor(android.R.color.white))
+ card.background = ContextCompat.getDrawable(itemView.context, R.color.colorAccent)
+ title.setTextColor(ContextCompat.getColor(itemView.context, android.R.color.white))
+ image.setColorFilter(ContextCompat.getColor(itemView.context, android.R.color.white))
}
false -> {
- card.background = itemView.context.resources.getDrawable(android.R.color.transparent)
- title.setTextColor(itemView.context.resources.getColor(android.R.color.black))
- image.setColorFilter(itemView.context.resources.getColor(android.R.color.black))
+ card.background = ContextCompat.getDrawable(itemView.context, android.R.color.transparent)
+ title.setTextColor(ContextCompat.getColor(itemView.context, android.R.color.black))
+ image.setColorFilter(ContextCompat.getColor(itemView.context, android.R.color.black))
}
}
@@ -40,4 +41,4 @@ class ModeItemHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
listener?.onSelected(itemPosition)
}
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/adapter/SaveAdapter.kt b/app/src/main/java/org/fossasia/badgemagic/adapter/SaveAdapter.kt
index b113682b..54520a6e 100644
--- a/app/src/main/java/org/fossasia/badgemagic/adapter/SaveAdapter.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/adapter/SaveAdapter.kt
@@ -1,13 +1,14 @@
package org.fossasia.badgemagic.adapter
import android.content.Context
-import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.widget.AppCompatImageView
+import androidx.core.content.ContextCompat
+import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.chip.Chip
import org.fossasia.badgemagic.R
import org.fossasia.badgemagic.data.fragments.BadgeConfig
@@ -71,32 +72,32 @@ class SaveAdapter(private val context: Context?, private val list: List context?.resources?.getDrawable(R.color.colorAccent)
- else -> context?.resources?.getDrawable(android.R.color.transparent)
+ selectedPosition != -1 && selectedPosition == adapterPosition -> ContextCompat.getDrawable(itemView.context, R.color.colorAccent)
+ else -> ContextCompat.getDrawable(itemView.context, android.R.color.transparent)
}
text.setTextColor(
- when {
- selectedPosition != -1 && selectedPosition == adapterPosition -> context?.resources?.getColor(android.R.color.white) as Int
- else -> context?.resources?.getColor(android.R.color.black) as Int
- }
+ when {
+ selectedPosition != -1 && selectedPosition == adapterPosition -> ContextCompat.getColor(itemView.context, android.R.color.white)
+ else -> ContextCompat.getColor(itemView.context, android.R.color.black)
+ }
)
playPause.setColorFilter(
- when {
- selectedPosition != -1 && selectedPosition == adapterPosition -> context.resources.getColor(android.R.color.white)
- else -> context.resources.getColor(android.R.color.black)
- }
+ when {
+ selectedPosition != -1 && selectedPosition == adapterPosition -> ContextCompat.getColor(itemView.context, android.R.color.white)
+ else -> ContextCompat.getColor(itemView.context, android.R.color.black)
+ }
)
editButton.setColorFilter(
- when {
- selectedPosition != -1 && selectedPosition == adapterPosition -> context.resources.getColor(android.R.color.white)
- else -> context.resources.getColor(android.R.color.black)
- }
+ when {
+ selectedPosition != -1 && selectedPosition == adapterPosition -> ContextCompat.getColor(itemView.context, android.R.color.white)
+ else -> ContextCompat.getColor(itemView.context, android.R.color.black)
+ }
)
options.setColorFilter(
- when {
- selectedPosition != -1 && selectedPosition == adapterPosition -> context.resources.getColor(android.R.color.white)
- else -> context.resources.getColor(android.R.color.black)
- }
+ when {
+ selectedPosition != -1 && selectedPosition == adapterPosition -> ContextCompat.getColor(itemView.context, android.R.color.white)
+ else -> ContextCompat.getColor(itemView.context, android.R.color.black)
+ }
)
val badge: BadgeConfig? = MoshiUtils.getAdapter().fromJson(item.badgeJSON)
@@ -127,4 +128,4 @@ interface OnSavedItemSelected {
fun onSelected(item: ConfigInfo?)
fun onEdit(item: ConfigInfo?)
fun onOptionsSelected(item: ConfigInfo)
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/adapter/SavedClipartsAdapter.kt b/app/src/main/java/org/fossasia/badgemagic/adapter/SavedClipartsAdapter.kt
index 7e836a23..87a0fb99 100644
--- a/app/src/main/java/org/fossasia/badgemagic/adapter/SavedClipartsAdapter.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/adapter/SavedClipartsAdapter.kt
@@ -4,8 +4,8 @@ import android.content.Intent
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.Toast
-import androidx.recyclerview.widget.RecyclerView
import androidx.databinding.DataBindingUtil
+import androidx.recyclerview.widget.RecyclerView
import org.fossasia.badgemagic.R
import org.fossasia.badgemagic.data.SavedClipart
import org.fossasia.badgemagic.databinding.RecyclerItemSavedClipartBinding
diff --git a/app/src/main/java/org/fossasia/badgemagic/adapter/SavedClipartsViewHolder.kt b/app/src/main/java/org/fossasia/badgemagic/adapter/SavedClipartsViewHolder.kt
index 987248a5..88a97dc7 100644
--- a/app/src/main/java/org/fossasia/badgemagic/adapter/SavedClipartsViewHolder.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/adapter/SavedClipartsViewHolder.kt
@@ -11,7 +11,7 @@ class SavedClipartsViewHolder(private val binding: RecyclerItemSavedClipartBindi
binding.bitmap = bitmap
}
- fun getBindingView() = binding.root
+ private fun getBindingView() = binding.root
fun getDeleteButton(): AppCompatImageView = getBindingView().findViewById(R.id.button_delete)
fun getEditButton(): AppCompatImageView = getBindingView().findViewById(R.id.button_edit)
}
diff --git a/app/src/main/java/org/fossasia/badgemagic/bindings/EditBadgeViewBindings.kt b/app/src/main/java/org/fossasia/badgemagic/bindings/EditBadgeViewBindings.kt
index cd2f74ce..0c916505 100644
--- a/app/src/main/java/org/fossasia/badgemagic/bindings/EditBadgeViewBindings.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/bindings/EditBadgeViewBindings.kt
@@ -33,4 +33,4 @@ fun changeColorState(imageView: ImageView, isEnabled: ObservableBoolean) {
else
imageView.context.resources.getColor(android.R.color.black)
)
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/bindings/SavedClipartsViewBindings.kt b/app/src/main/java/org/fossasia/badgemagic/bindings/SavedClipartsViewBindings.kt
index ee6d4e5f..3510a641 100644
--- a/app/src/main/java/org/fossasia/badgemagic/bindings/SavedClipartsViewBindings.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/bindings/SavedClipartsViewBindings.kt
@@ -17,4 +17,4 @@ fun setSavedClipRecyclerAdapter(recyclerView: RecyclerView, adapter: SavedClipar
@BindingAdapter("bindImage")
fun bindImage(imageView: SquareImageView, image: Bitmap) {
imageView.setImageBitmap(ImageUtils.trim(image, 200))
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/bindings/SettingsViewBindings.kt b/app/src/main/java/org/fossasia/badgemagic/bindings/SettingsViewBindings.kt
index 4a06dea9..f7e0fc73 100644
--- a/app/src/main/java/org/fossasia/badgemagic/bindings/SettingsViewBindings.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/bindings/SettingsViewBindings.kt
@@ -20,4 +20,4 @@ fun setSpinnerAdapter(spinner: AppCompatSpinner, viewModel: SettingsViewModel) {
viewModel.setSelectedSpinnerLangauge(position)
}
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/core/android/ext/ViewExt.kt b/app/src/main/java/org/fossasia/badgemagic/core/android/ext/ViewExt.kt
index 9640a354..bdb45ab3 100644
--- a/app/src/main/java/org/fossasia/badgemagic/core/android/ext/ViewExt.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/core/android/ext/ViewExt.kt
@@ -14,4 +14,4 @@ fun View.showKeyboard() {
fun View.hideKeyboard() {
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(windowToken, 0)
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/data/Language.kt b/app/src/main/java/org/fossasia/badgemagic/data/Language.kt
index 5a8548a5..00cb2ce1 100644
--- a/app/src/main/java/org/fossasia/badgemagic/data/Language.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/data/Language.kt
@@ -5,4 +5,4 @@ import java.util.Locale
enum class Language(val locale: Locale) {
ENGLISH(Locale.ENGLISH),
CHINESE(Locale.CHINA),
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/data/ModeInfo.kt b/app/src/main/java/org/fossasia/badgemagic/data/ModeInfo.kt
index f828c0fe..e5744bf5 100644
--- a/app/src/main/java/org/fossasia/badgemagic/data/ModeInfo.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/data/ModeInfo.kt
@@ -3,4 +3,4 @@ package org.fossasia.badgemagic.data
import androidx.annotation.DrawableRes
import org.fossasia.badgemagic.data.device.model.Mode
-data class ModeInfo(@DrawableRes val drawableID: Int, val mode: Mode)
\ No newline at end of file
+data class ModeInfo(@DrawableRes val drawableID: Int, val mode: Mode)
diff --git a/app/src/main/java/org/fossasia/badgemagic/data/SavedClipart.kt b/app/src/main/java/org/fossasia/badgemagic/data/SavedClipart.kt
index 2b7d2328..2ee8d72e 100644
--- a/app/src/main/java/org/fossasia/badgemagic/data/SavedClipart.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/data/SavedClipart.kt
@@ -2,4 +2,4 @@ package org.fossasia.badgemagic.data
import android.graphics.Bitmap
-data class SavedClipart(val fileName: String, val bitmap: Bitmap)
\ No newline at end of file
+data class SavedClipart(val fileName: String, val bitmap: Bitmap)
diff --git a/app/src/main/java/org/fossasia/badgemagic/data/device/DataToByteArrayConverter.kt b/app/src/main/java/org/fossasia/badgemagic/data/device/DataToByteArrayConverter.kt
index c79ef530..e7b13bc7 100644
--- a/app/src/main/java/org/fossasia/badgemagic/data/device/DataToByteArrayConverter.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/data/device/DataToByteArrayConverter.kt
@@ -1,10 +1,10 @@
package org.fossasia.badgemagic.data.device
+import java.util.Calendar
+import kotlin.experimental.or
import org.fossasia.badgemagic.core.utils.ByteArrayUtils.byteArrayToHexString
import org.fossasia.badgemagic.core.utils.ByteArrayUtils.hexStringToByteArray
import org.fossasia.badgemagic.data.device.model.DataToSend
-import java.util.Calendar
-import kotlin.experimental.or
object DataToByteArrayConverter {
@@ -210,4 +210,4 @@ object DataToByteArrayConverter {
private fun fillWithZeros(length: Int): String {
return "0".repeat((length / (PACKET_BYTE_SIZE * 2) + 1) * PACKET_BYTE_SIZE * 2 - length)
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/data/device/bluetooth/GattClient.kt b/app/src/main/java/org/fossasia/badgemagic/data/device/bluetooth/GattClient.kt
index b5701bc0..5b5a0f0c 100644
--- a/app/src/main/java/org/fossasia/badgemagic/data/device/bluetooth/GattClient.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/data/device/bluetooth/GattClient.kt
@@ -8,11 +8,11 @@ import android.bluetooth.BluetoothManager
import android.bluetooth.BluetoothProfile
import android.content.Context
import android.content.Context.BLUETOOTH_SERVICE
+import java.util.LinkedList
import org.fossasia.badgemagic.core.android.log.Timber
import org.fossasia.badgemagic.core.utils.ByteArrayUtils
import org.fossasia.badgemagic.data.device.bluetooth.Constants.CHARACTERISTIC_UUID
import org.fossasia.badgemagic.data.device.bluetooth.Constants.SERVICE_UUID
-import java.util.LinkedList
class GattClient {
diff --git a/app/src/main/java/org/fossasia/badgemagic/data/device/bluetooth/ScanHelper.kt b/app/src/main/java/org/fossasia/badgemagic/data/device/bluetooth/ScanHelper.kt
index 6812597d..d76d5141 100644
--- a/app/src/main/java/org/fossasia/badgemagic/data/device/bluetooth/ScanHelper.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/data/device/bluetooth/ScanHelper.kt
@@ -3,13 +3,13 @@ package org.fossasia.badgemagic.data.device.bluetooth
import android.bluetooth.BluetoothDevice
import android.os.Handler
import android.os.ParcelUuid
-import org.fossasia.badgemagic.core.android.log.Timber
-import org.fossasia.badgemagic.data.device.bluetooth.Constants.SERVICE_UUID
import no.nordicsemi.android.support.v18.scanner.BluetoothLeScannerCompat
import no.nordicsemi.android.support.v18.scanner.ScanCallback
import no.nordicsemi.android.support.v18.scanner.ScanFilter
import no.nordicsemi.android.support.v18.scanner.ScanResult
import no.nordicsemi.android.support.v18.scanner.ScanSettings
+import org.fossasia.badgemagic.core.android.log.Timber
+import org.fossasia.badgemagic.data.device.bluetooth.Constants.SERVICE_UUID
class ScanHelper {
diff --git a/app/src/main/java/org/fossasia/badgemagic/data/device/model/Message.kt b/app/src/main/java/org/fossasia/badgemagic/data/device/model/Message.kt
index 2e5d8442..430a309c 100644
--- a/app/src/main/java/org/fossasia/badgemagic/data/device/model/Message.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/data/device/model/Message.kt
@@ -1,3 +1,3 @@
package org.fossasia.badgemagic.data.device.model
-data class Message(val hexStrings: List, val flash: Boolean = false, val marquee: Boolean = false, val speed: Speed = Speed.ONE, val mode: Mode = Mode.LEFT)
\ No newline at end of file
+data class Message(val hexStrings: List, val flash: Boolean = false, val marquee: Boolean = false, val speed: Speed = Speed.ONE, val mode: Mode = Mode.LEFT)
diff --git a/app/src/main/java/org/fossasia/badgemagic/data/fragments/BadgeConfig.kt b/app/src/main/java/org/fossasia/badgemagic/data/fragments/BadgeConfig.kt
index 87418951..f5864ae8 100644
--- a/app/src/main/java/org/fossasia/badgemagic/data/fragments/BadgeConfig.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/data/fragments/BadgeConfig.kt
@@ -1,9 +1,9 @@
package org.fossasia.badgemagic.data.fragments
-import org.fossasia.badgemagic.data.device.model.Mode
-import org.fossasia.badgemagic.data.device.model.Speed
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
+import org.fossasia.badgemagic.data.device.model.Mode
+import org.fossasia.badgemagic.data.device.model.Speed
const val CONF_HEX_STRINGS = "hex_strings"
const val CONF_SPEED = "speed"
@@ -31,4 +31,4 @@ class BadgeConfig {
@Json(name = CONF_INVERTED)
var isInverted: Boolean = false
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/database/ClipArtService.kt b/app/src/main/java/org/fossasia/badgemagic/database/ClipArtService.kt
index f7cc7dde..c091e21d 100644
--- a/app/src/main/java/org/fossasia/badgemagic/database/ClipArtService.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/database/ClipArtService.kt
@@ -68,4 +68,4 @@ class ClipArtService : KoinComponent {
StorageUtils.deleteClipart(fileName)
updateClipArts()
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/database/StorageFilesService.kt b/app/src/main/java/org/fossasia/badgemagic/database/StorageFilesService.kt
index 18b9841b..aecbbeb2 100644
--- a/app/src/main/java/org/fossasia/badgemagic/database/StorageFilesService.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/database/StorageFilesService.kt
@@ -30,4 +30,4 @@ class StorageFilesService {
fun getAbsPath(fileName: String): String? = StorageUtils.getAbsolutePathofFiles(fileName)
fun checkIfFilePresent(fileName: String): Boolean = StorageUtils.checkIfFilePresent(fileName)
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/di/Modules.kt b/app/src/main/java/org/fossasia/badgemagic/di/Modules.kt
index 05008813..9d3a4c84 100644
--- a/app/src/main/java/org/fossasia/badgemagic/di/Modules.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/di/Modules.kt
@@ -4,14 +4,14 @@ import org.fossasia.badgemagic.database.ClipArtService
import org.fossasia.badgemagic.database.StorageFilesService
import org.fossasia.badgemagic.util.PreferenceUtils
import org.fossasia.badgemagic.util.Resource
-import org.fossasia.badgemagic.viewmodels.FilesViewModel
-import org.fossasia.badgemagic.viewmodels.TextArtViewModel
-import org.fossasia.badgemagic.viewmodels.SettingsViewModel
import org.fossasia.badgemagic.viewmodels.DrawViewModel
import org.fossasia.badgemagic.viewmodels.DrawerViewModel
import org.fossasia.badgemagic.viewmodels.EditBadgeViewModel
import org.fossasia.badgemagic.viewmodels.EditClipartViewModel
+import org.fossasia.badgemagic.viewmodels.FilesViewModel
import org.fossasia.badgemagic.viewmodels.SavedClipartViewModel
+import org.fossasia.badgemagic.viewmodels.SettingsViewModel
+import org.fossasia.badgemagic.viewmodels.TextArtViewModel
import org.koin.android.ext.koin.androidContext
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module
@@ -35,4 +35,4 @@ val singletonModules = module {
val utilModules = module {
single { PreferenceUtils(androidContext()) }
single { Resource(androidContext()) }
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/extensions/ActivityExtensions.kt b/app/src/main/java/org/fossasia/badgemagic/extensions/ActivityExtensions.kt
index 77ce75a5..1ba6d35f 100644
--- a/app/src/main/java/org/fossasia/badgemagic/extensions/ActivityExtensions.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/extensions/ActivityExtensions.kt
@@ -6,4 +6,4 @@ import androidx.annotation.Keep
@Keep
fun A.setRotation(rotation: Int) {
this.requestedOrientation = rotation
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/text/CenteredImageSpan.kt b/app/src/main/java/org/fossasia/badgemagic/text/CenteredImageSpan.kt
index 47ad3d94..2648438e 100644
--- a/app/src/main/java/org/fossasia/badgemagic/text/CenteredImageSpan.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/text/CenteredImageSpan.kt
@@ -73,4 +73,4 @@ class CenteredImageSpan(context: Context, bitmapRes: Bitmap) : ImageSpan(context
b.draw(canvas)
canvas.restore()
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/DrawerActivity.kt b/app/src/main/java/org/fossasia/badgemagic/ui/DrawerActivity.kt
index f797d167..ad37deb5 100644
--- a/app/src/main/java/org/fossasia/badgemagic/ui/DrawerActivity.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/ui/DrawerActivity.kt
@@ -9,29 +9,29 @@ import android.content.pm.ActivityInfo
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Bundle
-import androidx.core.view.GravityCompat
-import androidx.appcompat.app.ActionBarDrawerToggle
-import android.view.MenuItem
-import androidx.drawerlayout.widget.DrawerLayout
-import com.google.android.material.navigation.NavigationView
import android.view.Menu
+import android.view.MenuItem
import android.view.View
import android.widget.Toast
+import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
+import androidx.core.view.GravityCompat
+import androidx.drawerlayout.widget.DrawerLayout
+import com.google.android.material.navigation.NavigationView
import kotlinx.android.synthetic.main.activity_drawer.*
import kotlinx.android.synthetic.main.app_bar_drawer.*
import org.fossasia.badgemagic.R
import org.fossasia.badgemagic.core.android.log.Timber
import org.fossasia.badgemagic.extensions.setRotation
-import org.fossasia.badgemagic.ui.base.BaseFragment
import org.fossasia.badgemagic.ui.base.BaseActivity
+import org.fossasia.badgemagic.ui.base.BaseFragment
import org.fossasia.badgemagic.ui.fragments.AboutFragment
+import org.fossasia.badgemagic.ui.fragments.DrawFragment
import org.fossasia.badgemagic.ui.fragments.SavedBadgesFragment
+import org.fossasia.badgemagic.ui.fragments.SavedClipartFragment
import org.fossasia.badgemagic.ui.fragments.SettingsFragment
import org.fossasia.badgemagic.ui.fragments.TextArtFragment
-import org.fossasia.badgemagic.ui.fragments.DrawFragment
-import org.fossasia.badgemagic.ui.fragments.SavedClipartFragment
import org.fossasia.badgemagic.util.SendingUtils
import org.fossasia.badgemagic.util.StorageUtils
import org.fossasia.badgemagic.viewmodels.DrawerViewModel
@@ -62,13 +62,32 @@ class DrawerActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedLi
setupDrawerAndToolbar()
prepareForScan()
+
+ handleIfReceiveIntent()
+ }
+
+ private fun handleIfReceiveIntent() {
+ val bundle = intent.extras
+ if (bundle?.getString("clipart").equals("clipart")) {
+ val clipart = SavedClipartFragment()
+ supportFragmentManager.beginTransaction()
+ .replace(R.id.frag_container, clipart)
+ .commit()
+ nav_view.setCheckedItem(R.id.saved_cliparts)
+ } else if (bundle?.getString("badge").equals("badge")) {
+ val badge = SavedBadgesFragment()
+ supportFragmentManager.beginTransaction()
+ .replace(R.id.frag_container, badge)
+ .commit()
+ nav_view.setCheckedItem(R.id.saved_badges)
+ }
}
private fun setupDrawerAndToolbar() {
setSupportActionBar(toolbar)
val toggle = ActionBarDrawerToggle(
- this, drawer_layout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close)
+ this, drawer_layout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close)
drawer_layout.addDrawerListener(toggle)
toggle.syncState()
@@ -122,6 +141,13 @@ class DrawerActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedLi
R.id.buy -> {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://sg.pslab.io")))
}
+ R.id.share_app_details -> {
+ val shareIntent = Intent()
+ shareIntent.type = "text/plain"
+ shareIntent.action = Intent.ACTION_SEND
+ shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_msg))
+ startActivity(Intent.createChooser(shareIntent, getString(R.string.share_using)))
+ }
R.id.about -> {
switchFragment(AboutFragment.newInstance())
showMenu?.setGroupVisible(R.id.saved_group, false)
@@ -179,19 +205,19 @@ class DrawerActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedLi
private fun showImportDialog(uri: Uri?) {
AlertDialog.Builder(this)
- .setTitle(getString(R.string.import_dialog))
- .setMessage("${getString(R.string.import_dialog_message)} ${StorageUtils.getFileName(this, uri
- ?: Uri.EMPTY)}")
- .setPositiveButton(android.R.string.ok) { _: DialogInterface, _: Int ->
- if (!StorageUtils.checkIfFilePresent(this, uri)) {
- saveImportFile(uri)
- } else
- showOverrideDialog(uri)
- }
- .setNegativeButton(android.R.string.cancel) { dialog, _ ->
- dialog.cancel()
- }
- .show()
+ .setTitle(getString(R.string.import_dialog))
+ .setMessage("${getString(R.string.import_dialog_message)} ${StorageUtils.getFileName(this, uri
+ ?: Uri.EMPTY)}")
+ .setPositiveButton(android.R.string.ok) { _: DialogInterface, _: Int ->
+ if (!StorageUtils.checkIfFilePresent(this, uri)) {
+ saveImportFile(uri)
+ } else
+ showOverrideDialog(uri)
+ }
+ .setNegativeButton(android.R.string.cancel) { dialog, _ ->
+ dialog.cancel()
+ }
+ .show()
}
override fun onPause() {
@@ -219,16 +245,16 @@ class DrawerActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedLi
private fun switchFragment(fragment: BaseFragment) {
supportFragmentManager.beginTransaction()
- .replace(R.id.frag_container, fragment)
- .commit()
+ .replace(R.id.frag_container, fragment)
+ .commit()
}
private fun checkManifestPermission() {
- if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED &&
- ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED &&
+ ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
Timber.i { "Coarse permission granted" }
} else {
- ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.WRITE_EXTERNAL_STORAGE), REQUEST_PERMISSION_CODE)
+ ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.WRITE_EXTERNAL_STORAGE), REQUEST_PERMISSION_CODE)
}
}
@@ -256,15 +282,15 @@ class DrawerActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedLi
private fun showOverrideDialog(uri: Uri?) {
AlertDialog.Builder(this)
- .setTitle(getString(R.string.save_dialog_already_present))
- .setMessage(getString(R.string.save_dialog_already_present_override))
- .setPositiveButton(android.R.string.ok) { _: DialogInterface, _: Int ->
- saveImportFile(uri)
- }
- .setNegativeButton(android.R.string.cancel) { dialog, _ ->
- dialog.cancel()
- }
- .show()
+ .setTitle(getString(R.string.save_dialog_already_present))
+ .setMessage(getString(R.string.save_dialog_already_present_override))
+ .setPositiveButton(android.R.string.ok) { _: DialogInterface, _: Int ->
+ saveImportFile(uri)
+ }
+ .setNegativeButton(android.R.string.cancel) { dialog, _ ->
+ dialog.cancel()
+ }
+ .show()
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/EditBadgeActivity.kt b/app/src/main/java/org/fossasia/badgemagic/ui/EditBadgeActivity.kt
index 8c3bdc0e..6beaac86 100644
--- a/app/src/main/java/org/fossasia/badgemagic/ui/EditBadgeActivity.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/ui/EditBadgeActivity.kt
@@ -1,7 +1,10 @@
package org.fossasia.badgemagic.ui
+import android.content.Intent
import android.os.AsyncTask
import android.os.Bundle
+import android.view.Menu
+import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
@@ -35,8 +38,8 @@ class EditBadgeActivity : AppCompatActivity() {
if (it) {
val badgeConfig = SendingUtils.getBadgeFromJSON(viewModel.drawingJSON.get() ?: "{}")
badgeConfig?.hexStrings = Converters.convertBitmapToLEDHex(
- Converters.convertStringsToLEDHex(draw_layout.getCheckedList()),
- false
+ Converters.convertStringsToLEDHex(draw_layout.getCheckedList()),
+ false
)
badgeConfig?.let { config -> StoreAsync(fileName, config, viewModel).execute() }
Toast.makeText(this, R.string.saved_edited_badge, Toast.LENGTH_LONG).show()
@@ -51,6 +54,23 @@ class EditBadgeActivity : AppCompatActivity() {
})
}
+ override fun onCreateOptionsMenu(menu: Menu?): Boolean {
+ menuInflater.inflate(R.menu.open_folder, menu)
+ return super.onCreateOptionsMenu(menu)
+ }
+
+ override fun onOptionsItemSelected(item: MenuItem): Boolean {
+ when (item.itemId) {
+ R.id.open_Folder -> {
+ val intent = Intent(this, DrawerActivity::class.java)
+ intent.putExtra("badge", "badge")
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
+ startActivity(intent)
+ }
+ }
+ return super.onOptionsItemSelected(item)
+ }
+
companion object {
class StoreAsync(private val fileName: String, private val badgeConfig: BadgeConfig, private val viewModel: EditBadgeViewModel) : AsyncTask() {
diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/EditClipartActivity.kt b/app/src/main/java/org/fossasia/badgemagic/ui/EditClipartActivity.kt
index d1b8f2df..c58e84cc 100644
--- a/app/src/main/java/org/fossasia/badgemagic/ui/EditClipartActivity.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/ui/EditClipartActivity.kt
@@ -1,6 +1,9 @@
package org.fossasia.badgemagic.ui
+import android.content.Intent
import android.os.Bundle
+import android.view.Menu
+import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
@@ -45,4 +48,21 @@ class EditClipartActivity : AppCompatActivity() {
}
})
}
+
+ override fun onCreateOptionsMenu(menu: Menu?): Boolean {
+ menuInflater.inflate(R.menu.open_folder, menu)
+ return super.onCreateOptionsMenu(menu)
+ }
+
+ override fun onOptionsItemSelected(item: MenuItem): Boolean {
+ when (item.itemId) {
+ R.id.open_Folder -> {
+ val intent = Intent(this, DrawerActivity::class.java)
+ intent.putExtra("clipart", "clipart")
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
+ startActivity(intent)
+ }
+ }
+ return super.onOptionsItemSelected(item)
+ }
}
diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/base/BaseActivity.kt b/app/src/main/java/org/fossasia/badgemagic/ui/base/BaseActivity.kt
index 5d4ab957..69a7db23 100644
--- a/app/src/main/java/org/fossasia/badgemagic/ui/base/BaseActivity.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/ui/base/BaseActivity.kt
@@ -8,4 +8,4 @@ abstract class BaseActivity : AppCompatActivity() {
override fun attachBaseContext(base: Context?) {
super.attachBaseContext(LocaleManager.setLocale(base))
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/base/BaseFragment.kt b/app/src/main/java/org/fossasia/badgemagic/ui/base/BaseFragment.kt
index 6f2a33fb..e38a91d2 100644
--- a/app/src/main/java/org/fossasia/badgemagic/ui/base/BaseFragment.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/ui/base/BaseFragment.kt
@@ -15,4 +15,4 @@ open class BaseFragment : Fragment(), BaseFragmentInterface {
interface BaseFragmentInterface {
fun getSendData(): DataToSend
fun initializePreview()
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/custom/DrawBadgeLayout.kt b/app/src/main/java/org/fossasia/badgemagic/ui/custom/DrawBadgeLayout.kt
index ed452005..0b2bbd07 100644
--- a/app/src/main/java/org/fossasia/badgemagic/ui/custom/DrawBadgeLayout.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/ui/custom/DrawBadgeLayout.kt
@@ -2,11 +2,11 @@ package org.fossasia.badgemagic.ui.custom
import android.annotation.SuppressLint
import android.content.Context
-import android.graphics.Rect
-import android.graphics.RectF
import android.graphics.Canvas
-import android.graphics.Paint
import android.graphics.Color
+import android.graphics.Paint
+import android.graphics.Rect
+import android.graphics.RectF
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.MotionEvent
@@ -179,4 +179,4 @@ class DrawBadgeLayout(context: Context?, attrs: AttributeSet?) : View(context, a
}
invalidate()
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/custom/PreviewBadge.kt b/app/src/main/java/org/fossasia/badgemagic/ui/custom/PreviewBadge.kt
index bc087013..843910aa 100644
--- a/app/src/main/java/org/fossasia/badgemagic/ui/custom/PreviewBadge.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/ui/custom/PreviewBadge.kt
@@ -1,21 +1,20 @@
package org.fossasia.badgemagic.ui.custom
+import android.animation.ValueAnimator
+import android.annotation.SuppressLint
import android.content.Context
-import android.graphics.RectF
import android.graphics.Canvas
-import android.graphics.Paint
import android.graphics.Color
+import android.graphics.Paint
import android.graphics.Rect
+import android.graphics.RectF
import android.graphics.drawable.Drawable
-import androidx.annotation.Nullable
-import android.util.AttributeSet
-import android.view.View
-
-import android.animation.ValueAnimator
-import android.annotation.SuppressLint
import android.os.Bundle
import android.os.Parcelable
+import android.util.AttributeSet
+import android.view.View
import android.view.animation.LinearInterpolator
+import androidx.annotation.Nullable
import org.fossasia.badgemagic.R
import org.fossasia.badgemagic.data.badge_preview.Cell
import org.fossasia.badgemagic.data.badge_preview.CheckList
@@ -121,12 +120,12 @@ class PreviewBadge : View {
this.ifMarquee = currentState.getBoolean(BUNDLE_MARQUEE)
this.badgeSpeed = currentState.getInt(BUNDLE_SPEED)
this.badgeMode = Mode.values()[currentState.getInt(BUNDLE_MODE)]
- this.checkList = currentState.getParcelableArrayList(BUNDLE_CHECKLIST)
+ this.checkList = currentState.getParcelableArrayList(BUNDLE_CHECKLIST) ?: ArrayList()
countFrame = 0
lastFrame = 0
- currentState = currentState.getParcelable(BUNDLE_STATE) as Parcelable
+ currentState.getParcelable(BUNDLE_STATE)?.let { currentState = it }
}
super.onRestoreInstanceState(currentState)
}
@@ -524,4 +523,4 @@ class PreviewBadge : View {
else
configValueAnimation()
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/custom/SquareImageView.kt b/app/src/main/java/org/fossasia/badgemagic/ui/custom/SquareImageView.kt
index 2b81ce19..3add3bb4 100644
--- a/app/src/main/java/org/fossasia/badgemagic/ui/custom/SquareImageView.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/ui/custom/SquareImageView.kt
@@ -1,8 +1,8 @@
package org.fossasia.badgemagic.ui.custom
-import androidx.appcompat.widget.AppCompatImageView
import android.content.Context
import android.util.AttributeSet
+import androidx.appcompat.widget.AppCompatImageView
import kotlin.math.max
class SquareImageView : AppCompatImageView {
diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/custom/knob/Croller.kt b/app/src/main/java/org/fossasia/badgemagic/ui/custom/knob/Croller.kt
index 1bb4ef34..874c85bd 100644
--- a/app/src/main/java/org/fossasia/badgemagic/ui/custom/knob/Croller.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/ui/custom/knob/Croller.kt
@@ -10,7 +10,6 @@ import android.util.AttributeSet
import android.util.TypedValue
import android.view.MotionEvent
import android.view.View
-
import org.fossasia.badgemagic.R
import org.fossasia.badgemagic.ui.custom.knob.utilities.Utils
diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/fragments/AboutFragment.kt b/app/src/main/java/org/fossasia/badgemagic/ui/fragments/AboutFragment.kt
index bf73645c..35f9c5f4 100644
--- a/app/src/main/java/org/fossasia/badgemagic/ui/fragments/AboutFragment.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/ui/fragments/AboutFragment.kt
@@ -6,14 +6,14 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import org.fossasia.badgemagic.R
-import org.fossasia.badgemagic.ui.base.BaseFragment
import de.psdev.licensesdialog.LicensesDialog
import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20
import de.psdev.licensesdialog.licenses.MITLicense
import de.psdev.licensesdialog.model.Notice
import de.psdev.licensesdialog.model.Notices
import kotlinx.android.synthetic.main.fragment_about_us.*
+import org.fossasia.badgemagic.R
+import org.fossasia.badgemagic.ui.base.BaseFragment
class AboutFragment : BaseFragment() {
@@ -118,4 +118,4 @@ class AboutFragment : BaseFragment() {
.build()
.show()
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/fragments/DrawFragment.kt b/app/src/main/java/org/fossasia/badgemagic/ui/fragments/DrawFragment.kt
index f28e29b8..26befe0c 100644
--- a/app/src/main/java/org/fossasia/badgemagic/ui/fragments/DrawFragment.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/ui/fragments/DrawFragment.kt
@@ -51,4 +51,4 @@ class DrawFragment : BaseFragment() {
}
})
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/fragments/SavedBadgesFragment.kt b/app/src/main/java/org/fossasia/badgemagic/ui/fragments/SavedBadgesFragment.kt
index d06e7481..dbe5244c 100644
--- a/app/src/main/java/org/fossasia/badgemagic/ui/fragments/SavedBadgesFragment.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/ui/fragments/SavedBadgesFragment.kt
@@ -3,30 +3,29 @@ package org.fossasia.badgemagic.ui.fragments
import android.bluetooth.BluetoothAdapter
import android.content.Intent
import android.os.Bundle
-import android.view.View
import android.view.LayoutInflater
+import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.core.content.FileProvider
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
+import java.io.File
import kotlinx.android.synthetic.main.fragment_main_save.*
-
import org.fossasia.badgemagic.R
-import org.fossasia.badgemagic.data.fragments.ConfigInfo
+import org.fossasia.badgemagic.adapter.OnSavedItemSelected
+import org.fossasia.badgemagic.adapter.SaveAdapter
import org.fossasia.badgemagic.data.device.model.DataToSend
import org.fossasia.badgemagic.data.device.model.Mode
import org.fossasia.badgemagic.data.device.model.Speed
-import org.fossasia.badgemagic.viewmodels.FilesViewModel
+import org.fossasia.badgemagic.data.fragments.ConfigInfo
+import org.fossasia.badgemagic.ui.EditBadgeActivity
import org.fossasia.badgemagic.ui.base.BaseFragment
import org.fossasia.badgemagic.util.Converters
import org.fossasia.badgemagic.util.SendingUtils
-import org.fossasia.badgemagic.adapter.OnSavedItemSelected
-import org.fossasia.badgemagic.adapter.SaveAdapter
-import org.fossasia.badgemagic.ui.EditBadgeActivity
+import org.fossasia.badgemagic.viewmodels.FilesViewModel
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
-import java.io.File
class SavedBadgesFragment : BaseFragment() {
@@ -193,4 +192,4 @@ class SavedBadgesFragment : BaseFragment() {
badgeConfig?.mode ?: Mode.LEFT
)
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/fragments/SavedClipartFragment.kt b/app/src/main/java/org/fossasia/badgemagic/ui/fragments/SavedClipartFragment.kt
index f281caff..12a387bd 100644
--- a/app/src/main/java/org/fossasia/badgemagic/ui/fragments/SavedClipartFragment.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/ui/fragments/SavedClipartFragment.kt
@@ -39,4 +39,4 @@ class SavedClipartFragment : BaseFragment() {
)
})
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/fragments/SettingsFragment.kt b/app/src/main/java/org/fossasia/badgemagic/ui/fragments/SettingsFragment.kt
index 5fdf978f..7baa48b7 100644
--- a/app/src/main/java/org/fossasia/badgemagic/ui/fragments/SettingsFragment.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/ui/fragments/SettingsFragment.kt
@@ -1,10 +1,10 @@
package org.fossasia.badgemagic.ui.fragments
-import androidx.databinding.DataBindingUtil
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import com.google.android.material.snackbar.Snackbar
import org.fossasia.badgemagic.R
@@ -43,4 +43,4 @@ class SettingsFragment : BaseFragment() {
.show()
})
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/ui/fragments/TextArtFragment.kt b/app/src/main/java/org/fossasia/badgemagic/ui/fragments/TextArtFragment.kt
index b427dd6b..83592aaf 100644
--- a/app/src/main/java/org/fossasia/badgemagic/ui/fragments/TextArtFragment.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/ui/fragments/TextArtFragment.kt
@@ -6,13 +6,16 @@ import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothManager
import android.content.Context
import android.content.DialogInterface
+import android.content.Intent
import android.content.pm.PackageManager
import android.content.res.Configuration
import android.graphics.Color
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.VectorDrawable
+import android.location.LocationManager
import android.os.AsyncTask
import android.os.Bundle
+import android.provider.Settings
import android.text.Editable
import android.text.SpannableStringBuilder
import android.text.TextWatcher
@@ -21,46 +24,45 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
-import android.widget.TextView
import android.widget.LinearLayout
+import android.widget.TextView
import android.widget.Toast
import androidx.core.app.ActivityCompat
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.GridLayoutManager
import com.google.android.material.tabs.TabLayout
+import java.text.SimpleDateFormat
+import java.util.Calendar
+import java.util.Locale
+import java.util.Timer
+import java.util.TimerTask
import kotlinx.android.synthetic.main.effects_layout.*
-
-import org.fossasia.badgemagic.R
-import org.fossasia.badgemagic.data.DrawableInfo
-import org.fossasia.badgemagic.data.ModeInfo
-import org.fossasia.badgemagic.data.device.model.Mode
-import org.fossasia.badgemagic.ui.custom.knob.Croller
-import org.fossasia.badgemagic.ui.base.BaseFragment
import kotlinx.android.synthetic.main.fragment_main_textart.*
import kotlinx.android.synthetic.main.sections_tab.*
+import org.fossasia.badgemagic.R
import org.fossasia.badgemagic.adapter.DrawableAdapter
import org.fossasia.badgemagic.adapter.ModeAdapter
import org.fossasia.badgemagic.adapter.OnDrawableSelected
import org.fossasia.badgemagic.adapter.OnModeSelected
import org.fossasia.badgemagic.core.android.ext.hideKeyboard
import org.fossasia.badgemagic.core.android.ext.showKeyboard
+import org.fossasia.badgemagic.data.DrawableInfo
+import org.fossasia.badgemagic.data.ModeInfo
import org.fossasia.badgemagic.data.device.model.DataToSend
import org.fossasia.badgemagic.data.device.model.Message
+import org.fossasia.badgemagic.data.device.model.Mode
import org.fossasia.badgemagic.data.device.model.Speed
import org.fossasia.badgemagic.text.CenteredImageSpan
-import org.fossasia.badgemagic.util.SendingUtils
+import org.fossasia.badgemagic.ui.base.BaseFragment
+import org.fossasia.badgemagic.ui.custom.knob.Croller
import org.fossasia.badgemagic.util.Converters
-import org.fossasia.badgemagic.util.ImageUtils
import org.fossasia.badgemagic.util.DRAWABLE_END
import org.fossasia.badgemagic.util.DRAWABLE_START
+import org.fossasia.badgemagic.util.ImageUtils
+import org.fossasia.badgemagic.util.SendingUtils
import org.fossasia.badgemagic.viewmodels.TextArtViewModel
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
import pl.droidsonroids.gif.GifImageView
-import java.text.SimpleDateFormat
-import java.util.Timer
-import java.util.Calendar
-import java.util.Locale
-import java.util.TimerTask
class TextArtFragment : BaseFragment() {
companion object {
@@ -68,7 +70,7 @@ class TextArtFragment : BaseFragment() {
private const val REQUEST_PERMISSION_CODE = 10
@JvmStatic
fun newInstance() =
- TextArtFragment()
+ TextArtFragment()
}
private val drawableRecyclerAdapter = DrawableAdapter()
@@ -94,14 +96,14 @@ class TextArtFragment : BaseFragment() {
override fun getSendData(): DataToSend {
textViewMainText.hideKeyboard()
return SendingUtils.convertToDeviceDataModel(
- Message(
- Converters.convertEditableToLEDHex(textViewMainText.text.toString(), invertLED.isChecked, viewModel.getClipArts().value
- ?: SparseArray()),
- flash.isChecked,
- marquee.isChecked,
- Speed.values()[speedKnob.progress.minus(1)],
- Mode.values()[modeAdapter.getSelectedItemPosition()]
- )
+ Message(
+ Converters.convertEditableToLEDHex(textViewMainText.text.toString(), invertLED.isChecked, viewModel.getClipArts().value
+ ?: SparseArray()),
+ flash.isChecked,
+ marquee.isChecked,
+ Speed.values()[speedKnob.progress.minus(1)],
+ Mode.values()[modeAdapter.getSelectedItemPosition()]
+ )
)
}
@@ -119,23 +121,25 @@ class TextArtFragment : BaseFragment() {
transfer_button.setOnClickListener {
if (textViewMainText.text.trim().toString() != "") {
if (BluetoothAdapter.getDefaultAdapter().isEnabled) {
- // Easter egg
- Toast.makeText(requireContext(), getString(R.string.sending_data), Toast.LENGTH_LONG).show()
-
- transfer_button.visibility = View.GONE
- send_progress.visibility = View.VISIBLE
-
- val buttonTimer = Timer()
- buttonTimer.schedule(object : TimerTask() {
- override fun run() {
- activity?.runOnUiThread {
- transfer_button.visibility = View.VISIBLE
- send_progress.visibility = View.GONE
+ if (scanLocationPermissions()) {
+ // Easter egg
+ Toast.makeText(requireContext(), getString(R.string.sending_data), Toast.LENGTH_LONG).show()
+
+ transfer_button.visibility = View.GONE
+ send_progress.visibility = View.VISIBLE
+
+ val buttonTimer = Timer()
+ buttonTimer.schedule(object : TimerTask() {
+ override fun run() {
+ activity?.runOnUiThread {
+ transfer_button.visibility = View.VISIBLE
+ send_progress.visibility = View.GONE
+ }
}
- }
- }, SCAN_TIMEOUT_MS)
+ }, SCAN_TIMEOUT_MS)
- SendingUtils.sendMessage(requireContext(), getSendData())
+ SendingUtils.sendMessage(requireContext(), getSendData())
+ }
} else
showAlertDialog()
} else
@@ -143,6 +147,22 @@ class TextArtFragment : BaseFragment() {
}
}
+ private fun scanLocationPermissions(): Boolean {
+ val lm = requireContext().getSystemService(Context.LOCATION_SERVICE)
+ if (lm is LocationManager) {
+ if (lm.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
+ AlertDialog.Builder(requireContext())
+ .setMessage(R.string.no_gps_enabled)
+ .setPositiveButton("OK") { _, _ -> requireContext().startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)) }
+ .setNegativeButton("Cancel", null)
+ .show()
+ return false
+ }
+ return true
+ }
+ return false
+ }
+
private fun startSaveFile() {
textViewMainText.hideKeyboard()
showSaveFileDialog()
@@ -161,7 +181,7 @@ class TextArtFragment : BaseFragment() {
private fun checkStoragePermission(): Boolean {
return if (ActivityCompat.checkSelfPermission(requireContext(),
- android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
+ android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(arrayOf(android.Manifest.permission.WRITE_EXTERNAL_STORAGE), REQUEST_PERMISSION_CODE)
false
} else
@@ -225,10 +245,10 @@ class TextArtFragment : BaseFragment() {
viewModel.showClipart.let {
clipart_layout.visibility = if (it) View.VISIBLE else View.GONE
clipart_handler.setImageResource(
- if (it)
- R.drawable.ic_clipart_switcher_enabled
- else
- R.drawable.ic_clipart_switcher_disabled
+ if (it)
+ R.drawable.ic_clipart_switcher_enabled
+ else
+ R.drawable.ic_clipart_switcher_disabled
)
if (it) textViewMainText.hideKeyboard() else textViewMainText.showKeyboard()
}
@@ -379,15 +399,15 @@ class TextArtFragment : BaseFragment() {
modeRecyclerView.adapter = null
val listOfAnimations = listOf(
- ModeInfo(R.drawable.ic_anim_left, Mode.LEFT),
- ModeInfo(R.drawable.ic_anim_right, Mode.RIGHT),
- ModeInfo(R.drawable.ic_anim_up, Mode.UP),
- ModeInfo(R.drawable.ic_anim_down, Mode.DOWN),
- ModeInfo(R.drawable.ic_anim_fixed, Mode.FIXED),
- ModeInfo(R.drawable.ic_anim_fixed, Mode.SNOWFLAKE),
- ModeInfo(R.drawable.ic_anim_picture, Mode.PICTURE),
- ModeInfo(R.drawable.ic_anim_animation, Mode.ANIMATION),
- ModeInfo(R.drawable.ic_anim_laser, Mode.LASER)
+ ModeInfo(R.drawable.ic_anim_left, Mode.LEFT),
+ ModeInfo(R.drawable.ic_anim_right, Mode.RIGHT),
+ ModeInfo(R.drawable.ic_anim_up, Mode.UP),
+ ModeInfo(R.drawable.ic_anim_down, Mode.DOWN),
+ ModeInfo(R.drawable.ic_anim_fixed, Mode.FIXED),
+ ModeInfo(R.drawable.ic_anim_fixed, Mode.SNOWFLAKE),
+ ModeInfo(R.drawable.ic_anim_picture, Mode.PICTURE),
+ ModeInfo(R.drawable.ic_anim_animation, Mode.ANIMATION),
+ ModeInfo(R.drawable.ic_anim_laser, Mode.LASER)
)
modeAdapter.addAll(listOfAnimations)
modeAdapter.setSelectedAnimationPosition(viewModel.animationPosition)
@@ -435,12 +455,12 @@ class TextArtFragment : BaseFragment() {
private fun setPreview() {
preview_badge.setValue(
- Converters.convertEditableToLEDHex(textViewMainText.text.toString(), invertLED.isChecked, viewModel.getClipArts().value
- ?: SparseArray()),
- marquee.isChecked,
- flash.isChecked,
- Speed.values()[speedKnob.progress.minus(1)],
- Mode.values()[modeAdapter.getSelectedItemPosition()]
+ Converters.convertEditableToLEDHex(textViewMainText.text.toString(), invertLED.isChecked, viewModel.getClipArts().value
+ ?: SparseArray()),
+ marquee.isChecked,
+ flash.isChecked,
+ Speed.values()[speedKnob.progress.minus(1)],
+ Mode.values()[modeAdapter.getSelectedItemPosition()]
)
}
@@ -455,13 +475,13 @@ class TextArtFragment : BaseFragment() {
saveFileEditText.setText(getCurrentDate())
val alertDialog = AlertDialog.Builder(context)
- .setTitle(getString(R.string.save_dialog_title))
- .setView(view)
- .setPositiveButton(R.string.save_button, null)
- .setNegativeButton(android.R.string.cancel) { dialog, _ ->
- dialog.cancel()
- }
- .create()
+ .setTitle(getString(R.string.save_dialog_title))
+ .setView(view)
+ .setPositiveButton(R.string.save_button, null)
+ .setNegativeButton(android.R.string.cancel) { dialog, _ ->
+ dialog.cancel()
+ }
+ .create()
alertDialog.setOnShowListener {
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
@@ -487,29 +507,29 @@ class TextArtFragment : BaseFragment() {
private fun configToJSON(): String {
return SendingUtils.configToJSON(
- Message(
- Converters.convertEditableToLEDHex(textViewMainText.text.toString(), false, viewModel.getClipArts().value
- ?: SparseArray()),
- flash.isChecked,
- marquee.isChecked,
- Speed.values()[speedKnob.progress.minus(1)],
- Mode.values()[modeAdapter.getSelectedItemPosition()]
- ),
- invertLED.isChecked
+ Message(
+ Converters.convertEditableToLEDHex(textViewMainText.text.toString(), false, viewModel.getClipArts().value
+ ?: SparseArray()),
+ flash.isChecked,
+ marquee.isChecked,
+ Speed.values()[speedKnob.progress.minus(1)],
+ Mode.values()[modeAdapter.getSelectedItemPosition()]
+ ),
+ invertLED.isChecked
)
}
private fun showFileOverrideDialog(fileName: String, jsonString: String) {
AlertDialog.Builder(context)
- .setTitle(context?.getString(R.string.save_dialog_already_present))
- .setMessage(context?.getString(R.string.save_dialog_already_present_override))
- .setPositiveButton(android.R.string.ok) { _: DialogInterface, _: Int ->
- saveFile(fileName, jsonString)
- }
- .setNegativeButton(android.R.string.cancel) { dialog, _ ->
- dialog.cancel()
- }
- .show()
+ .setTitle(context?.getString(R.string.save_dialog_already_present))
+ .setMessage(context?.getString(R.string.save_dialog_already_present_override))
+ .setPositiveButton(android.R.string.ok) { _: DialogInterface, _: Int ->
+ saveFile(fileName, jsonString)
+ }
+ .setNegativeButton(android.R.string.cancel) { dialog, _ ->
+ dialog.cancel()
+ }
+ .show()
}
private fun saveFile(fileName: String, jsonString: String) {
@@ -527,4 +547,4 @@ class TextArtFragment : BaseFragment() {
viewModel.updateList()
}
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/util/Converters.kt b/app/src/main/java/org/fossasia/badgemagic/util/Converters.kt
index fb71182f..2d0de8cf 100644
--- a/app/src/main/java/org/fossasia/badgemagic/util/Converters.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/util/Converters.kt
@@ -6,9 +6,9 @@ import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.graphics.drawable.VectorDrawable
import android.util.SparseArray
+import java.math.BigInteger
import org.fossasia.badgemagic.data.badge_preview.CheckList
import org.fossasia.badgemagic.data.device.DataToByteArrayConverter
-import java.math.BigInteger
const val DRAWABLE_START = '«'
const val DRAWABLE_END = '»'
diff --git a/app/src/main/java/org/fossasia/badgemagic/util/ImageUtils.kt b/app/src/main/java/org/fossasia/badgemagic/util/ImageUtils.kt
index d41cbd3e..6f48209e 100644
--- a/app/src/main/java/org/fossasia/badgemagic/util/ImageUtils.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/util/ImageUtils.kt
@@ -101,4 +101,4 @@ object ImageUtils {
else
Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888)
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/util/LocaleManager.kt b/app/src/main/java/org/fossasia/badgemagic/util/LocaleManager.kt
index aa1f8820..5a14bc8d 100644
--- a/app/src/main/java/org/fossasia/badgemagic/util/LocaleManager.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/util/LocaleManager.kt
@@ -2,8 +2,8 @@ package org.fossasia.badgemagic.util
import android.content.Context
import android.content.res.Configuration
-import org.fossasia.badgemagic.data.Language
import java.util.Locale
+import org.fossasia.badgemagic.data.Language
object LocaleManager {
@@ -27,4 +27,4 @@ object LocaleManager {
return contextFun
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/util/MoshiUtils.kt b/app/src/main/java/org/fossasia/badgemagic/util/MoshiUtils.kt
index 533388f1..a7a810fd 100644
--- a/app/src/main/java/org/fossasia/badgemagic/util/MoshiUtils.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/util/MoshiUtils.kt
@@ -1,11 +1,11 @@
package org.fossasia.badgemagic.util
-import org.fossasia.badgemagic.data.fragments.BadgeConfig
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import org.fossasia.badgemagic.data.device.model.Mode
import org.fossasia.badgemagic.data.device.model.Speed
+import org.fossasia.badgemagic.data.fragments.BadgeConfig
class MoshiUtils private constructor() {
companion object {
@@ -22,4 +22,4 @@ class MoshiUtils private constructor() {
return adapter as JsonAdapter
}
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/util/PreferenceUtils.kt b/app/src/main/java/org/fossasia/badgemagic/util/PreferenceUtils.kt
index 2c004703..e0166cdb 100644
--- a/app/src/main/java/org/fossasia/badgemagic/util/PreferenceUtils.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/util/PreferenceUtils.kt
@@ -15,4 +15,4 @@ class PreferenceUtils(val context: Context) {
set(value) {
getPrefs()?.edit()?.putInt(SELECTED_LANGUAGE, value)?.apply()
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/util/Resource.kt b/app/src/main/java/org/fossasia/badgemagic/util/Resource.kt
index cc6775cc..56ee4cb5 100644
--- a/app/src/main/java/org/fossasia/badgemagic/util/Resource.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/util/Resource.kt
@@ -10,4 +10,4 @@ class Resource(val context: Context) {
fun getDrawable(@DrawableRes resId: Int) = context.getDrawable(resId)
fun getString(@StringRes resId: Int) = context.getString(resId)
fun getColor(@ColorRes resId: Int) = context.resources?.getColor(resId)
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/util/SendingUtils.kt b/app/src/main/java/org/fossasia/badgemagic/util/SendingUtils.kt
index 7eb438cf..0af235c8 100644
--- a/app/src/main/java/org/fossasia/badgemagic/util/SendingUtils.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/util/SendingUtils.kt
@@ -96,4 +96,4 @@ object SendingUtils {
}
internal fun getBadgeFromJSON(json: String): BadgeConfig? = MoshiUtils.getAdapter().fromJson(json)
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/util/StorageUtils.kt b/app/src/main/java/org/fossasia/badgemagic/util/StorageUtils.kt
index 0006817a..b77b62cb 100644
--- a/app/src/main/java/org/fossasia/badgemagic/util/StorageUtils.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/util/StorageUtils.kt
@@ -5,19 +5,19 @@ import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Environment
+import java.io.BufferedReader
+import java.io.File
+import java.io.FileOutputStream
+import java.io.InputStreamReader
+import org.fossasia.badgemagic.data.fragments.BadgeConfig
+import org.fossasia.badgemagic.data.fragments.CONF_FLASH
import org.fossasia.badgemagic.data.fragments.CONF_HEX_STRINGS
import org.fossasia.badgemagic.data.fragments.CONF_INVERTED
import org.fossasia.badgemagic.data.fragments.CONF_MARQUEE
-import org.fossasia.badgemagic.data.fragments.CONF_FLASH
import org.fossasia.badgemagic.data.fragments.CONF_MODE
import org.fossasia.badgemagic.data.fragments.CONF_SPEED
import org.fossasia.badgemagic.data.fragments.ConfigInfo
-import org.fossasia.badgemagic.data.fragments.BadgeConfig
import org.json.JSONObject
-import java.io.File
-import java.io.BufferedReader
-import java.io.FileOutputStream
-import java.io.InputStreamReader
object StorageUtils {
private val EXTERNAL_STORAGE_DIRECTORY = "${Environment.getExternalStorageDirectory()
@@ -196,4 +196,4 @@ object StorageUtils {
val deleteFile = File(EXTERNAL_CLIPART_DIRECTORY, fileName)
deleteFile.delete()
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/viewmodels/DrawViewModel.kt b/app/src/main/java/org/fossasia/badgemagic/viewmodels/DrawViewModel.kt
index 6d41b39f..772bcd2f 100644
--- a/app/src/main/java/org/fossasia/badgemagic/viewmodels/DrawViewModel.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/viewmodels/DrawViewModel.kt
@@ -10,7 +10,7 @@ import org.fossasia.badgemagic.database.ClipArtService
class DrawViewModel(
private val clipArtService: ClipArtService
) : ViewModel() {
- var drawModeState: ObservableField = ObservableField(DrawMode.NOTHING)
+ var drawModeState: ObservableField = ObservableField(DrawMode.DRAW)
var drawState: ObservableBoolean = ObservableBoolean(true)
var eraseState: ObservableBoolean = ObservableBoolean(false)
@@ -44,4 +44,4 @@ class DrawViewModel(
}
fun updateCliparts() = clipArtService.updateClipArts()
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/viewmodels/DrawerViewModel.kt b/app/src/main/java/org/fossasia/badgemagic/viewmodels/DrawerViewModel.kt
index e659b822..2bc387c4 100644
--- a/app/src/main/java/org/fossasia/badgemagic/viewmodels/DrawerViewModel.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/viewmodels/DrawerViewModel.kt
@@ -9,4 +9,4 @@ class DrawerViewModel(
var swappingOrientation = false
fun updateList() = storageFilesService.update()
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/viewmodels/EditBadgeViewModel.kt b/app/src/main/java/org/fossasia/badgemagic/viewmodels/EditBadgeViewModel.kt
index 14dc7653..d4dac753 100644
--- a/app/src/main/java/org/fossasia/badgemagic/viewmodels/EditBadgeViewModel.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/viewmodels/EditBadgeViewModel.kt
@@ -10,7 +10,7 @@ import org.fossasia.badgemagic.database.StorageFilesService
class EditBadgeViewModel(
private val storageFilesService: StorageFilesService
) : ViewModel() {
- var drawModeState: ObservableField = ObservableField(DrawMode.NOTHING)
+ var drawModeState: ObservableField = ObservableField(DrawMode.DRAW)
var drawingJSON: ObservableField = ObservableField("[]")
var drawState: ObservableBoolean = ObservableBoolean(true)
@@ -45,4 +45,4 @@ class EditBadgeViewModel(
}
fun updateFiles() = storageFilesService.update()
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/viewmodels/EditClipartViewModel.kt b/app/src/main/java/org/fossasia/badgemagic/viewmodels/EditClipartViewModel.kt
index 1b61f6bd..f6c35fb5 100644
--- a/app/src/main/java/org/fossasia/badgemagic/viewmodels/EditClipartViewModel.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/viewmodels/EditClipartViewModel.kt
@@ -10,7 +10,7 @@ import org.fossasia.badgemagic.database.ClipArtService
class EditClipartViewModel(
private val clipArtService: ClipArtService
) : ViewModel() {
- var drawModeState: ObservableField = ObservableField(DrawMode.NOTHING)
+ var drawModeState: ObservableField = ObservableField(DrawMode.DRAW)
var drawingJSON: ObservableField> = ObservableField(listOf())
var drawState: ObservableBoolean = ObservableBoolean(true)
@@ -45,4 +45,4 @@ class EditClipartViewModel(
}
fun updateClipArts() = clipArtService.updateClipArts()
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/viewmodels/FilesViewModel.kt b/app/src/main/java/org/fossasia/badgemagic/viewmodels/FilesViewModel.kt
index 44601c5c..bec84f15 100644
--- a/app/src/main/java/org/fossasia/badgemagic/viewmodels/FilesViewModel.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/viewmodels/FilesViewModel.kt
@@ -12,4 +12,4 @@ class FilesViewModel(
fun deleteFile(fileName: String) = storageFilesService.deleteFile(fileName)
fun getAbsPath(fileName: String): String? = storageFilesService.getAbsPath(fileName)
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/viewmodels/SettingsViewModel.kt b/app/src/main/java/org/fossasia/badgemagic/viewmodels/SettingsViewModel.kt
index 79e46cce..fe3a37b7 100644
--- a/app/src/main/java/org/fossasia/badgemagic/viewmodels/SettingsViewModel.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/viewmodels/SettingsViewModel.kt
@@ -24,4 +24,4 @@ class SettingsViewModel(
preferenceUtils.selectedLanguage = position
changedLanguage.value = true
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/fossasia/badgemagic/viewmodels/TextArtViewModel.kt b/app/src/main/java/org/fossasia/badgemagic/viewmodels/TextArtViewModel.kt
index 9ecb1371..7a41c3c3 100644
--- a/app/src/main/java/org/fossasia/badgemagic/viewmodels/TextArtViewModel.kt
+++ b/app/src/main/java/org/fossasia/badgemagic/viewmodels/TextArtViewModel.kt
@@ -24,4 +24,4 @@ class TextArtViewModel(
fun saveFile(filename: String, json: String) = storageFilesService.saveFile(filename, json)
fun getClipArts() = clipArtService.getClipArts()
-}
\ No newline at end of file
+}
diff --git a/app/src/main/res/drawable/ic_folder_open_black_24dp.xml b/app/src/main/res/drawable/ic_folder_open_black_24dp.xml
new file mode 100644
index 00000000..4779afdf
--- /dev/null
+++ b/app/src/main/res/drawable/ic_folder_open_black_24dp.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_share.xml b/app/src/main/res/drawable/ic_share.xml
new file mode 100644
index 00000000..e3fe874d
--- /dev/null
+++ b/app/src/main/res/drawable/ic_share.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/menu/drawer_items.xml b/app/src/main/res/menu/drawer_items.xml
index 57cb58ad..be2533ca 100644
--- a/app/src/main/res/menu/drawer_items.xml
+++ b/app/src/main/res/menu/drawer_items.xml
@@ -32,6 +32,10 @@
android:id="@+id/buy"
android:icon="@drawable/ic_menu_buy"
android:title="@string/drawer_buy_badge" />
+
-
+
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 6b733348..e49144d6 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -49,6 +49,7 @@
反馈/错误报告
买徽章
关于我们
+ 分享
保存的徽章
创建徽章
导入成功
@@ -91,4 +92,8 @@
ClipArt已成功保存
保存剪贴画时出错
保存的教具
+ 找不到GPS,请从设置中启用GPS
+
+ Badge Magic是一个用于控制LED名称徽章的Android应用。该应用程序提供了在LED徽章上描绘姓名,图形和简单动画的功能。 \n您也可以从下面的链接下载它 https://play.google.com/store/apps/details?id=org.fossasia.badgemagic
+ 分享使用
\ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 74406dcc..9a2ea992 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -35,7 +35,7 @@
22sp
16sp
50dp
- 48dp
+ 28dp
50dp
10dp
2dp
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5e0a2db0..1857044d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -59,6 +59,7 @@
Other
Feedback/Bug Reports
Buy Badge
+ Share
About Us
Saved Badges
Create Badges
@@ -102,4 +103,8 @@
ClipArt Saved Successfully
Error in saving Clipart
Saved Cliparts
+ No GPS Found, Please Enable GPS from Settings
+
+ Badge Magic is an Android app to control LED name badges. This app provides features to portray names, graphics and simple animations on LED badges. \nYou can also download it from below link \nhttps://play.google.com/store/apps/details?id=org.fossasia.badgemagic
+ Share Using
diff --git a/build.gradle b/build.gradle
index 87fef7fb..afa34c0c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -10,7 +10,7 @@ buildscript {
}
dependencies {
- classpath "com.android.tools.build:gradle:3.4.2"
+ classpath "com.android.tools.build:gradle:3.5.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin_version"
classpath "gradle.plugin.com.github.b3er.local.properties:local-properties-plugin:1.1"
}
diff --git a/docs/images/screen-1.png b/docs/images/screen-1.png
new file mode 100644
index 00000000..f21bdecf
Binary files /dev/null and b/docs/images/screen-1.png differ
diff --git a/docs/images/screen-2.png b/docs/images/screen-2.png
new file mode 100644
index 00000000..d12f5c01
Binary files /dev/null and b/docs/images/screen-2.png differ
diff --git a/docs/images/screen-3.png b/docs/images/screen-3.png
new file mode 100644
index 00000000..6fb782d1
Binary files /dev/null and b/docs/images/screen-3.png differ
diff --git a/docs/images/screen-4.png b/docs/images/screen-4.png
new file mode 100644
index 00000000..3e7fa5a0
Binary files /dev/null and b/docs/images/screen-4.png differ
diff --git a/docs/images/screen-5.png b/docs/images/screen-5.png
new file mode 100644
index 00000000..804974c2
Binary files /dev/null and b/docs/images/screen-5.png differ
diff --git a/docs/images/screen-6.png b/docs/images/screen-6.png
new file mode 100644
index 00000000..83686afb
Binary files /dev/null and b/docs/images/screen-6.png differ
diff --git a/fastlane/metadata/android/en-US/changelogs/8.txt b/fastlane/metadata/android/en-US/changelogs/8.txt
new file mode 100644
index 00000000..74a00a23
--- /dev/null
+++ b/fastlane/metadata/android/en-US/changelogs/8.txt
@@ -0,0 +1,12 @@
+🚀 Features
+
+- share app details on social platforms
+- added shortcut to open saved activities from edit activities
+- support for android 10
+- Improve Edit Clipart Screen - Size and Buttons
+
+🐛 Bug Fixes
+
+- privacy storage access crash
+- deprecated context calls
+- Draw Clipart Screen - Cannot draw
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index fb94a20c..b5dd08a2 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
diff --git a/scripts/check-screenshots.sh b/scripts/check-screenshots.sh
new file mode 100644
index 00000000..d41750d6
--- /dev/null
+++ b/scripts/check-screenshots.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+FILES_DIFF=$(diff <(find docs/images -type f -name "screen-?.png" -exec md5sum {} + | sort -k 2 | sed 's/ .*\// /') <(find fastlane/metadata/android/en-US/images/phoneScreenshots -type f -exec md5sum {} + | sort -k 2 | sed 's/ .*\// /'))
+if [[ $FILES_DIFF ]]; then
+ echo -e "\033[0;31mScreenshots in docs/images and fastlane/metadata/android/en-US/images/phoneScreenshots are not same\033[0m" >&2
+ exit 1;
+fi
diff --git a/versions.gradle b/versions.gradle
index c8670c65..bc63ccb9 100644
--- a/versions.gradle
+++ b/versions.gradle
@@ -1,9 +1,9 @@
ext.versions = [:]
-versions.compileSdk = 28
-versions.buildTools = '28.0.3'
+versions.compileSdk = 29
+versions.buildTools = '29.0.2'
versions.minSdk = 21
-versions.targetSdk = 28
+versions.targetSdk = 29
versions.kotlin_version = '1.3.41'