forked from F0x1d/LogFox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
F0x1d
committed
Jun 30, 2022
1 parent
5a22515
commit 9abeb86
Showing
47 changed files
with
292 additions
and
509 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/f0x1d/logfox/extensions/LiveDataExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.f0x1d.logfox.extensions | ||
|
||
import androidx.lifecycle.MutableLiveData | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.withContext | ||
|
||
suspend fun <T> MutableLiveData<T>.suspendAndPostValue(data: T) = withContext(Dispatchers.Main.immediate) { | ||
value = data | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/f0x1d/logfox/extensions/OmnibinExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.f0x1d.logfox.extensions | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.content.pm.PackageManager | ||
|
||
fun Context.isOmnibinInstalled() = try { | ||
packageManager.getPackageInfo("com.f0x1d.dogbin", 0) | ||
true | ||
} catch (e: PackageManager.NameNotFoundException) { | ||
false | ||
} | ||
|
||
fun uploadToFoxBinIntent(content: String) = Intent("com.f0x1d.dogbin.ACTION_UPLOAD_TO_FOXBIN").apply { | ||
putExtra(Intent.EXTRA_TEXT, content) | ||
type = "text/plain" | ||
} | ||
fun Context.uploadToFoxBin(content: String) = startActivity(uploadToFoxBinIntent(content)) |
46 changes: 46 additions & 0 deletions
46
app/src/main/java/com/f0x1d/logfox/extensions/PendingIntentsExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.f0x1d.logfox.extensions | ||
|
||
import android.app.Activity | ||
import android.app.PendingIntent | ||
import android.app.Service | ||
import android.content.BroadcastReceiver | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import com.f0x1d.logfox.utils.pendingIntentFlags | ||
|
||
fun <T : BroadcastReceiver> Context.makeBroadcastPendingIntent(id: Int, clazz: Class<T>, setup: Intent.() -> Unit) = PendingIntent.getBroadcast( | ||
this, | ||
id, | ||
Intent(this, clazz).also { setup.invoke(it) }, | ||
pendingIntentFlags | ||
) | ||
|
||
fun <T : BroadcastReceiver> Context.makeBroadcastPendingIntent(id: Int, clazz: Class<T>, extras: Bundle = Bundle.EMPTY) = makeBroadcastPendingIntent( | ||
id, | ||
clazz | ||
) { putExtras(extras) } | ||
|
||
fun <T : Service> Context.makeServicePendingIntent(id: Int, clazz: Class<T>, setup: Intent.() -> Unit) = PendingIntent.getService( | ||
this, | ||
id, | ||
Intent(this, clazz).also { setup.invoke(it) }, | ||
pendingIntentFlags | ||
) | ||
|
||
fun <T : Service> Context.makeServicePendingIntent(id: Int, clazz: Class<T>, extras: Bundle = Bundle.EMPTY) = makeServicePendingIntent( | ||
id, | ||
clazz | ||
) { putExtras(extras) } | ||
|
||
fun <T : Activity> Context.makeActivityPendingIntent(id: Int, clazz: Class<T>, setup: Intent.() -> Unit) = PendingIntent.getActivity( | ||
this, | ||
id, | ||
Intent(this, clazz).also { setup.invoke(it) }, | ||
pendingIntentFlags | ||
) | ||
|
||
fun <T : Activity> Context.makeActivityPendingIntent(id: Int, clazz: Class<T>, extras: Bundle = Bundle.EMPTY) = makeActivityPendingIntent( | ||
id, | ||
clazz | ||
) { putExtras(extras) } |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/f0x1d/logfox/ui/view/OpenSansToolbar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.f0x1d.logfox.ui.view | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.widget.TextView | ||
import androidx.core.content.res.ResourcesCompat | ||
import androidx.core.view.children | ||
import com.f0x1d.logfox.R | ||
import com.google.android.material.appbar.MaterialToolbar | ||
|
||
class OpenSansToolbar(context: Context, attributeSet: AttributeSet) : MaterialToolbar(context, attributeSet) { | ||
|
||
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) { | ||
super.onLayout(changed, left, top, right, bottom) | ||
|
||
children.forEach { | ||
if (it is TextView) it.typeface = ResourcesCompat.getFont(context, R.font.google_sans_medium) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.