extensions: Drop unused extensions
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Aurora Store
|
||||
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
*
|
||||
* Aurora Store is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Aurora Store is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.aurora.extensions
|
||||
|
||||
import android.text.format.DateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
|
||||
fun Long.toDate(): String {
|
||||
val calendar = Calendar.getInstance(Locale.getDefault())
|
||||
calendar.timeInMillis = this
|
||||
return DateFormat.format("dd/MM/yy", calendar).toString()
|
||||
}
|
||||
@@ -63,7 +63,3 @@ fun Context.showDialog(
|
||||
fun Fragment.showDialog(@StringRes titleId: Int, @StringRes messageId: Int) {
|
||||
requireContext().showDialog(titleId, messageId)
|
||||
}
|
||||
|
||||
fun Fragment.showDialog(title: String, message: String) {
|
||||
requireContext().showDialog(title, message)
|
||||
}
|
||||
|
||||
@@ -19,29 +19,10 @@
|
||||
|
||||
package com.aurora.extensions
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.UrlQuerySanitizer
|
||||
import android.os.Bundle
|
||||
|
||||
inline fun <reified T : Context> Context.newIntent(): Intent =
|
||||
Intent(this, T::class.java)
|
||||
|
||||
inline fun <reified T : Context> Context.newIntent(flags: Int): Intent {
|
||||
val intent = newIntent<T>()
|
||||
intent.flags = flags
|
||||
return intent
|
||||
}
|
||||
|
||||
inline fun <reified T : Context> Context.newIntent(extras: Bundle): Intent =
|
||||
newIntent<T>(0, extras)
|
||||
|
||||
inline fun <reified T : Context> Context.newIntent(flags: Int, extras: Bundle): Intent {
|
||||
val intent = newIntent<T>(flags)
|
||||
intent.putExtras(extras)
|
||||
return intent
|
||||
}
|
||||
|
||||
fun Intent.getPackageName(fallbackBundle: Bundle? = null): String? {
|
||||
return when (action) {
|
||||
Intent.ACTION_VIEW -> {
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 The Calyx Institute
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.aurora.extensions
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.navigation.NavBackStackEntry
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavGraph.Companion.findStartDestination
|
||||
|
||||
/**
|
||||
* Gets viewModel from the parent composable if exists
|
||||
*/
|
||||
@Composable
|
||||
inline fun <reified T : ViewModel> NavBackStackEntry.parentViewModel(navController: NavController): T {
|
||||
val navGraphRoute = navController.graph.findStartDestination().route ?: return hiltViewModel()
|
||||
val parentEntry = remember(this) { navController.getBackStackEntry(navGraphRoute) }
|
||||
return hiltViewModel<T>(parentEntry)
|
||||
}
|
||||
@@ -21,8 +21,5 @@ package com.aurora.extensions
|
||||
|
||||
import android.content.res.Resources
|
||||
|
||||
val Number.dp: Number
|
||||
get() = (this.toFloat() / Resources.getSystem().displayMetrics.density).toInt()
|
||||
|
||||
val Number.px: Number
|
||||
get() = (this.toFloat() * Resources.getSystem().displayMetrics.density).toInt()
|
||||
@@ -22,8 +22,6 @@ package com.aurora.extensions
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
|
||||
fun runAsync(action: () -> Unit) = Thread(Runnable(action)).start()
|
||||
|
||||
fun runOnUiThread(action: () -> Unit) {
|
||||
when {
|
||||
isMainThread() -> action.invoke()
|
||||
|
||||
Reference in New Issue
Block a user