Skip to content

Commit

Permalink
Fixes and improvements
Browse files Browse the repository at this point in the history
- Fixed home counters, drawer and cards background colors.
- Fixed wrong icons count.
- Replaced FABsMenu with a simple FAB to quickly apply the icon pack.
- Removed the card to apply in home section.
- Arctic Manager support is working normally now.
  • Loading branch information
jahirfiquitiva committed Feb 9, 2018
1 parent 1e083d3 commit 573b48b
Show file tree
Hide file tree
Showing 19 changed files with 174 additions and 342 deletions.
9 changes: 3 additions & 6 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ ext.versions = [
targetSdk : 27,
buildTools : '27.0.3',
// Versions:
versionCode : 106,
versionName : '1.0.6',
versionCode : 107,
versionName : '1.0.7',
// Gradle Plugins
gradle : '3.0.1',
kotlin : '1.2.21',
libs : '2.0',
// Dependencies
kuper : '1.2.1',
kuper : '1.2.3',
materialDrawer: '6.0.6',
fabsMenu : '1.1.2',
counterFab : '1.0.3',
bridge : '5.1.2',
oneSignal : '3.7.1'
Expand All @@ -45,8 +44,6 @@ ext.libraries = [
kuper : 'me.jahirfiquitiva:Kuper:' + versions.kuper + '@aar',
// Material Drawer
materialDrawer: 'com.mikepenz:materialdrawer:' + versions.materialDrawer + '@aar',
// FABsMenu
fabsMenu : 'me.jahirfiquitiva:FABsMenu:' + versions.fabsMenu,
// CounterFab
counterFab : 'com.github.andremion:counterfab:' + versions.counterFab,
// Bridge
Expand Down
2 changes: 0 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ dependencies {
exclude group: 'org.json', module: 'json'
exclude group: 'com.intellij', module: 'annotations'
}
// FABs Menu
api libraries.fabsMenu
// CounterFab
api libraries.counterFab
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ data class Icon(val name: String, @DrawableRes val icon: Int) : Comparable<Icon>
}

data class IconsCategory(val title: String) {
val icons: ArrayList<Icon> = ArrayList()
private val icons: ArrayList<Icon> = ArrayList()

fun getIcons(): ArrayList<Icon> = ArrayList(icons.distinctBy { it.name }.sortedBy { it.name })

fun setIcons(newIcons: ArrayList<Icon>) {
icons.clear()
icons.addAll(newIcons)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ class BPKonfigs(nm: String, cntxt: Context) : KuperKonfigs(nm, cntxt) {
get() = prefs.getBoolean(LAUNCHER_ICON_SHOWN, false)
set(shown) = prefsEditor.putBoolean(LAUNCHER_ICON_SHOWN, shown).apply()

var isApplyCardDismissed: Boolean
get() = prefs.getBoolean(APPLY_CARD_DISMISSED, false)
set(dismissed) = prefsEditor.putBoolean(APPLY_CARD_DISMISSED, dismissed).apply()

var wallpaperInIconsPreview: Boolean
get() = prefs.getBoolean(WALLPAPER_IN_ICONS_PREVIEW, true)
set(enabled) = prefsEditor.putBoolean(WALLPAPER_IN_ICONS_PREVIEW, enabled).apply()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,23 @@ class IconsViewModel : ListViewModel<Context, IconsCategory>() {
} else {
param.stringArray(R.array.icon_filters).forEach {
val icons = ArrayList<Icon>()
val list = ArrayList<String>()
list.addAll(
param.stringArray(
param.resources.getIdentifier(it, "array", param.packageName)))
list.forEach {
icons.add(
Icon(it.formatCorrectly().blueprintFormat(), it.getIconResource(param)))
param.stringArray(
param.resources.getIdentifier(it, "array", param.packageName)).forEach {
val iconRes = it.getIconResource(param)
if (iconRes > 0) {
icons += Icon(it.formatCorrectly().blueprintFormat(), iconRes)
} else {
Log.e(param.getAppName(), "Could NOT find icon with name '$it'")
}
}
val filteredIcons = ArrayList(icons.distinctBy { it.name }.sortedBy { it.name })
if (filteredIcons.isNotEmpty()) {
val category = IconsCategory(it.formatCorrectly().blueprintFormat())
category.setIcons(filteredIcons)
categories.add(category)
}
val category = IconsCategory(it)
category.setIcons(ArrayList(icons.distinct().sortedBy { it.name }))
categories.add(category)
}
}
return ArrayList(categories.distinct().sortedBy { it.title })
return ArrayList(categories.distinctBy { it.title }.sortedBy { it.title })
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -798,27 +798,6 @@ class IconRequest private constructor() {
return@Thread
}

// Zip everything into an archive
BPLog.d { "Creating ZIP..." }
val zipFile = File(builder?.saveDir, "IconRequest-$date.zip")
try {
zipFile.zip(filesToZip)
} catch (e: Exception) {
e.printStackTrace()
postError("Failed to create the request ZIP file: " + e.message, e)
onRequestProgress?.doOnError()
return@Thread
}

// Cleanup files
BPLog.d { "Cleaning up files..." }
val files = builder?.saveDir?.listFiles()
files?.forEach {
if (!it.isDirectory && (it.name.endsWith(".png") || it.name.endsWith(".xml"))) {
it.delete()
}
}

val host = builder?.apiHost.orEmpty()
val apiKey = builder?.apiKey.orEmpty()

Expand All @@ -830,19 +809,27 @@ class IconRequest private constructor() {
.defaultHeader("User-Agent", "afollestad/icon-request")
.validators(RemoteValidator())
try {
val form = MultipartForm()
form.add("archive", zipFile)
form.add("apps", JSONObject(jsonSb?.toString().orEmpty()).toString())
post("/v1/request").throwIfNotSuccess().body(form).request()
BPLog.d { "Request uploaded to the server!" }

val amount = requestsLeft - selectedApps.size
BPLog.d { "Request: Allowing $amount more requests." }
saveRequestsLeft(if (amount < 0) 0 else amount)

if (requestsLeft == 0) saveRequestMoment()

onRequestProgress?.doWhenReady()
val zipFile = buildZip(
date,
ArrayList(filesToZip.filter { it.name.endsWith("png", true) }))
if (zipFile != null) {
val form = MultipartForm()
form.add("archive", zipFile)
form.add("apps", JSONObject(jsonSb?.toString().orEmpty()).toString())
post("/v1/request").throwIfNotSuccess().body(form).request()
BPLog.d { "Request uploaded to the server!" }

val amount = requestsLeft - selectedApps.size
BPLog.d { "Request: Allowing $amount more requests." }
saveRequestsLeft(if (amount < 0) 0 else amount)

if (requestsLeft == 0) saveRequestMoment()

cleanFiles(true)
onRequestProgress?.doWhenReady(true)
} else {
onRequestProgress?.doOnError()
}
} catch (e: Exception) {
Log.e(
builder?.context?.getAppName() ?: "Blueprint",
Expand All @@ -853,10 +840,20 @@ class IconRequest private constructor() {
Log.e(builder?.context?.getAppName() ?: "Blueprint", errors.toString())
} catch (ignored: Exception) {
}
sendRequestViaEmail(zipFile, onRequestProgress)
val zipFile = buildZip(date, filesToZip)
if (zipFile != null) {
sendRequestViaEmail(zipFile, onRequestProgress)
} else {
onRequestProgress?.doOnError()
}
}
} else {
sendRequestViaEmail(zipFile, onRequestProgress)
val zipFile = buildZip(date, filesToZip)
if (zipFile != null) {
sendRequestViaEmail(zipFile, onRequestProgress)
} else {
onRequestProgress?.doOnError()
}
}
}.start()
} else {
Expand All @@ -866,8 +863,23 @@ class IconRequest private constructor() {
}
}

private fun buildZip(date: String, filesToZip: ArrayList<File>): File? {
// Zip everything into an archive
BPLog.d { "Creating ZIP..." }
val zipFile = File(builder?.saveDir, "IconRequest-$date.zip")
return try {
zipFile.zip(filesToZip)
zipFile
} catch (e: Exception) {
BPLog.e { e.message }
postError("Failed to create the request ZIP file: " + e.message, e)
null
}
}

private fun sendRequestViaEmail(zipFile: File, onRequestProgress: OnRequestProgress?) {
try {
cleanFiles()
BPLog.d { "Launching intent!" }
val zipUri = builder?.context?.let { zipFile.getUri(it) }
val emailIntent = Intent(Intent.ACTION_SEND)
Expand All @@ -888,7 +900,7 @@ class IconRequest private constructor() {
if (requestsLeft == 0)
saveRequestMoment()

onRequestProgress?.doWhenReady()
onRequestProgress?.doWhenReady(false)

(builder?.context as? Activity)?.startActivityForResult(
Intent.createChooser(
Expand All @@ -904,6 +916,21 @@ class IconRequest private constructor() {
}
}

private fun cleanFiles(everything: Boolean = false) {
BPLog.d { "Cleaning up files..." }
try {
val files = builder?.saveDir?.listFiles()
files?.forEach {
if (!it.isDirectory &&
(everything || (it.name.endsWith(".png") || it.name.endsWith(".xml")))) {
it.delete()
}
}
} catch (e: Exception) {
BPLog.e { e.message }
}
}

@State
private fun getRequestState(toSend: Boolean): Int {
val max = builder?.maxCount ?: -1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package jahirfiquitiva.libs.blueprint.quest.events
@Suppress("unused", "UNUSED_PARAMETER")
abstract class OnRequestProgress {
abstract fun doWhenStarted()

abstract fun doOnError()

fun updateWithProgress(progress: Int) {}

abstract fun doWhenReady()
abstract fun doWhenReady(forArctic: Boolean)
}
Loading

0 comments on commit 573b48b

Please sign in to comment.