Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4 from hishoot2i/wip_modular
Browse files Browse the repository at this point in the history
v1.2.4
  • Loading branch information
ratabb authored Aug 16, 2018
2 parents 3005959 + 621ba1a commit 5c67388
Show file tree
Hide file tree
Showing 152 changed files with 1,319 additions and 1,565 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog
-----
### **v1.2.4 (20180817)**
- Handle device without external storage
- [Badge] preview font at choice
- Bug fixes and some improvements

### **v1.2.3 (20180806)**
- Bug fixes

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.3
1.2.4
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ kapt { useBuildCache = true }

dependencies {
implementation project(':common')
implementation project(':entity')
implementation project(':imageloader')
implementation project(':template')

implementation deps.universalImageLoader

implementation deps.kotlin.stdlib

implementation deps.supportLibrary.annotations
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class DebugApp : App() {
StrictMode.setThreadPolicy(
StrictMode.ThreadPolicy.Builder()
.detectAll()
// .permitDiskReads() // FIXME: SharedPreference [Editor] get/set Value?
.penaltyLog()
.build()
)
Expand Down

This file was deleted.

8 changes: 2 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<!-- TODO: -->
<!--
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
-->

<application
android:name=".App"
Expand All @@ -23,7 +18,7 @@
android:supportsRtl="false"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">
<!-- android:largeHeap="true" Ouch! -->
<!-- NOTE: -->
<!-- GoogleAppIndexingWarning: IDK -->
<!-- UnusedAttribute: android:appCategory="image" Api26+ -->
<activity
Expand All @@ -36,6 +31,7 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<!-- NOTE: Explicit here, cause category launcher using ALIAS -->
<action android:name="cat.ereza.customactivityoncrash.RESTART" />
</intent-filter>
</activity>
Expand Down
7 changes: 1 addition & 6 deletions app/src/main/java/org/illegaller/ratabb/hishoot2i/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@ import com.squareup.leakcanary.LeakCanary
import dagger.android.AndroidInjector
import dagger.android.DaggerApplication

/**/
@SuppressLint("Registered") //
open class App : DaggerApplication() {
override fun onCreate() {
super.onCreate()

if (LeakCanary.isInAnalyzerProcess(this)) {
// This process is dedicated to LeakCanary for heap analysis.
// You should not init your app in this process.
return
}
if (LeakCanary.isInAnalyzerProcess(this)) return
installLeakCanary()
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@ package org.illegaller.ratabb.hishoot2i.data

import android.content.Context
import com.chibatching.kotpref.Kotpref
import common.FileConstants
import common.egl.MaxTexture
import common.egl.MaxTextureCompat
import dagger.Module
import dagger.Provides
import org.illegaller.ratabb.hishoot2i.data.core.CoreProcess
import org.illegaller.ratabb.hishoot2i.data.core.CoreProcessImpl
import org.illegaller.ratabb.hishoot2i.data.pref.AppPref
import org.illegaller.ratabb.hishoot2i.data.rx.AppScheduler
import org.illegaller.ratabb.hishoot2i.data.rx.SchedulerProvider
import rbb.hishoot2i.common.FileConstants
import rbb.hishoot2i.common.egl.MaxTexture
import rbb.hishoot2i.common.egl.MaxTextureCompat
import rbb.hishoot2i.common.imageloader.ImageLoader
import rbb.hishoot2i.common.imageloader.uil.UilImageLoaderImpl
import rbb.hishoot2i.template.TemplateFactoryManager
import rbb.hishoot2i.template.TemplateFactoryManagerImpl
import javax.inject.Singleton

@Module
Expand Down Expand Up @@ -46,13 +42,16 @@ object DataModule {
@Provides
@Singleton
@JvmStatic
fun provideImageLoader(context: Context): ImageLoader =
UilImageLoaderImpl(context, /*BuildConfig.DEBUG*/ false)
fun provideImageLoader(
impl: imageloader.uil.UilImageLoaderImpl
): imageloader.ImageLoader = impl

@Provides
@Singleton
@JvmStatic
fun provideFactoryManager(impl: TemplateFactoryManagerImpl): TemplateFactoryManager = impl
fun provideFactoryManager(
impl: template.TemplateFactoryManagerImpl
): template.TemplateFactoryManager = impl

@Provides
@Singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,43 @@ package org.illegaller.ratabb.hishoot2i.data
import android.content.Context
import android.net.Uri
import android.os.Environment
import android.support.v4.content.FileProvider
import org.illegaller.ratabb.hishoot2i.BuildConfig
import rbb.hishoot2i.common.FileConstants
import android.support.v4.content.FileProvider.getUriForFile
import org.illegaller.ratabb.hishoot2i.BuildConfig.FILE_AUTHORITY
import java.io.File
import java.io.IOException
import javax.inject.Inject

class FileConstantsImpl @Inject constructor(val context: Context) : FileConstants {
private var saved: File? = null
private var htz: File? = null
private var bgCrop: File? = null
class FileConstantsImpl @Inject constructor(val context: Context) : common.FileConstants {
override fun savedDir(): File {
saved?.let { return it }
val result = File(Environment.getExternalStorageDirectory(), "HiShoot")
if (!result.exists()) {
result.mkdirs()
val parent = Environment.getExternalStorageState().let { state ->
when (state) {
Environment.MEDIA_MOUNTED -> Environment.getExternalStorageDirectory()
else -> context.getExternalFilesDir(null)
}.let { if (!it.canWrite()) context.filesDir else it }
}
saved = result
val result = File(parent, "HiShoot")
if (!result.exists()) result.mkdirs()
return result
}

override fun htzDir(): File {
htz?.let { return it }
val result = File(context.filesDir, "htz")
if (!result.exists()) {
result.mkdirs()
}
if (!result.exists()) result.mkdirs()
try {
File(result, FileConstants.NO_MEDIA).createNewFile()
} catch (e: IOException) {
e.printStackTrace()
File(result, common.FileConstants.NO_MEDIA).createNewFile()
} catch (ignore: IOException) {
}
htz = result
return result
}

override fun File.toUri(): Uri =
FileProvider.getUriForFile(context, BuildConfig.FILE_AUTHORITY, this)

override fun File.toUri(): Uri = getUriForFile(context, FILE_AUTHORITY, this)
override fun bgCrop(): File {
bgCrop?.let { return it }
val result =
File(context.cacheDir, FileConstants.BG_CROP)
val result = File(context.cacheDir, common.FileConstants.BG_CROP)
if (result.exists()) result.delete()
result.createNewFile()
bgCrop = result
try {
result.createNewFile()
} catch (e: IOException) {
}
return result
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import io.reactivex.rxkotlin.mergeDelayError
import io.reactivex.rxkotlin.toFlowable
import org.illegaller.ratabb.hishoot2i.data.pref.AppPref
import java.io.File
import java.text.Collator
import javax.inject.Inject
import android.os.Environment.getExternalStorageDirectory as ExternalStorageDir

Expand All @@ -17,13 +18,12 @@ class FileFontStorageSourceImpl @Inject constructor(val appPref: AppPref) : File
.asIterable()
.mergeDelayError()
.filter { it.canRead() && it.isDirectory }
.flatMap { dir: File ->
dir.listFiles { file: File? ->
SUPPORT_FONT_EXT.contains(file?.extension)
}.toFlowable()
.flatMap {
it.listFiles { file: File? -> SUPPORT_FONT_EXT.contains(file?.extension) }
.toFlowable()
}
.distinct { it.nameWithoutExtension } //
.sorted { lhs: File, rhs: File -> lhs.name.compareTo(rhs.name, true) }
.sorted(::sortFileByNames)

private fun defaultFontDir(): Flowable<File> = DEFAULT_FONT_PATH.toFlowable()
.flatMap { path: String -> Flowable.fromCallable { File(ExternalStorageDir(), path) } }
Expand All @@ -32,14 +32,16 @@ class FileFontStorageSourceImpl @Inject constructor(val appPref: AppPref) : File
Flowable.fromCallable { File(path) }
} ?: Flowable.empty()

private fun systemFontDir(): Flowable<File> = when (appPref.systemFontEnable) {
true -> Flowable.fromCallable { File(SYSTEM_FONT_PATH) }
false -> Flowable.empty()
}
private fun systemFontDir(): Flowable<File> = if (appPref.systemFontEnable) {
Flowable.fromCallable { File(SYSTEM_FONT_PATH) }
} else Flowable.empty()

private fun sortFileByNames(lhs: File, rhs: File): Int = collator.compare(lhs.name, rhs.name)

companion object {
private const val SYSTEM_FONT_PATH = "/system/fonts" //
private val DEFAULT_FONT_PATH = arrayOf("font", "fonts")
private val SUPPORT_FONT_EXT = arrayOf("ttf", "otf")
private val collator = Collator.getInstance()
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package org.illegaller.ratabb.hishoot2i.data

import android.content.pm.ApplicationInfo
import android.content.pm.PackageInfo
import android.content.pm.ResolveInfo
import io.reactivex.Flowable

interface PackageResolver {
fun queryIntentActivities(category: String): Flowable<ResolveInfo>
fun installedApplications(): Flowable<ApplicationInfo>
fun getPackageInfo(packageName: String): PackageInfo
fun installedTemplateLegacy(): Flowable<entity.AppInfo>
fun installedTemplate(version: Int): Flowable<entity.AppInfo>
}
Loading

0 comments on commit 5c67388

Please sign in to comment.