-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
1 parent
ea10791
commit 7c96372
Showing
25 changed files
with
202 additions
and
36 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
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
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
112 changes: 112 additions & 0 deletions
112
app/src/main/java/com/ismartcoding/plain/ui/page/OtherFilePage.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,112 @@ | ||
package com.ismartcoding.plain.ui.page | ||
|
||
|
||
import android.annotation.SuppressLint | ||
import android.content.Intent | ||
import android.net.Uri | ||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.text.selection.SelectionContainer | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.outlined.Share | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.unit.dp | ||
import androidx.navigation.NavHostController | ||
import com.ismartcoding.lib.helpers.FormatHelper | ||
import com.ismartcoding.lib.helpers.ShareHelper | ||
import com.ismartcoding.plain.R | ||
import com.ismartcoding.plain.ui.MainActivity | ||
import com.ismartcoding.plain.ui.base.* | ||
import com.ismartcoding.plain.ui.extensions.openPathIntent | ||
import java.io.File | ||
|
||
@SuppressLint("MissingPermission") | ||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun OtherFilePage( | ||
navController: NavHostController, | ||
) { | ||
val context = LocalContext.current | ||
val path = navController.currentBackStackEntry?.arguments?.getString("path") ?: "" | ||
val file = File(path) | ||
|
||
PScaffold( | ||
navController, | ||
actions = { | ||
PIconButton( | ||
imageVector = Icons.Outlined.Share, | ||
contentDescription = stringResource(R.string.share), | ||
tint = MaterialTheme.colorScheme.onSurface, | ||
) { | ||
ShareHelper.share(context, Uri.parse(path)) | ||
} | ||
}, | ||
content = { | ||
LazyColumn { | ||
item { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(top = 64.dp), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
) { | ||
Image( | ||
modifier = | ||
Modifier | ||
.padding(bottom = 32.dp) | ||
.size(56.dp), | ||
painter = painterResource(id = R.drawable.ic_unknown_file), | ||
contentDescription = "", | ||
) | ||
SelectionContainer { | ||
Text( | ||
text = file.name, | ||
textAlign = TextAlign.Center, | ||
modifier = Modifier | ||
.padding(horizontal = 32.dp), | ||
style = MaterialTheme.typography.titleLarge, | ||
fontWeight = FontWeight.Medium, | ||
color = MaterialTheme.colorScheme.onSurface, | ||
) | ||
} | ||
VerticalSpace(dp = 16.dp) | ||
SelectionContainer { | ||
Text( | ||
text = stringResource(R.string.file_size) + ": " + FormatHelper.formatBytes(file.length()), | ||
textAlign = TextAlign.Center, | ||
modifier = Modifier | ||
.padding(horizontal = 32.dp), | ||
style = MaterialTheme.typography.titleMedium, | ||
color = MaterialTheme.colorScheme.onSurfaceVariant, | ||
) | ||
} | ||
VerticalSpace(dp = 16.dp) | ||
Text( | ||
text = stringResource(R.string.unknown_file_description), | ||
textAlign = TextAlign.Center, | ||
modifier = Modifier | ||
.padding(horizontal = 32.dp), | ||
style = MaterialTheme.typography.bodyLarge, | ||
color = MaterialTheme.colorScheme.onSurfaceVariant, | ||
) | ||
VerticalSpace(dp = 64.dp) | ||
BlockOutlineButton(text = stringResource(id = R.string.open_with_other_app)) { | ||
MainActivity.instance.get()?.openPathIntent(path) | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
) | ||
} |
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 |
---|---|---|
|
@@ -24,4 +24,5 @@ enum class RouteName { | |
SCAN_HISTORY, | ||
MEDIA_PREVIEW, | ||
APPS, | ||
OTHER_FILE, | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="1024" | ||
android:viewportHeight="1024"> | ||
<path | ||
android:fillColor="@color/primary" | ||
android:pathData="M546,136L222,136v752h582L804,395.3L593,395.3c-26,0 -47,-21 -47,-47L546,136zM610,136v195.3h194v-1.5L610.2,136L610,136zM656.4,80.4l203.2,203.2A56,56 0,0 1,876 323.2L876,896c0,35.3 -28.7,64 -64,64L214,960c-35.3,0 -64,-28.7 -64,-64L150,128c0,-35.3 28.7,-64 64,-64h402.8a56,56 0,0 1,39.6 16.4zM430,524.6c0,-10.4 3.3,-20.9 10,-31.6 6.7,-10.7 16.4,-19.5 29.2,-26.5S496.9,456 514,456c15.9,0 29.9,2.9 42,8.8 12.1,5.9 21.5,13.8 28.1,23.9 6.6,10.1 9.9,21 9.9,32.8 0,9.3 -1.9,17.4 -5.7,24.4 -3.8,7 -8.3,13 -13.5,18.1 -5.2,5.1 -14.5,13.6 -28,25.7 -3.7,3.4 -6.7,6.4 -8.9,8.9 -2.2,2.6 -3.9,4.9 -5,7.1 -1.1,2.1 -1.9,4.3 -2.5,6.4 -0.6,2.1 -1.5,5.9 -2.7,11.2 -2.1,11.4 -8.6,17.1 -19.5,17.1 -5.7,0 -10.5,-1.9 -14.4,-5.6 -3.9,-3.7 -5.8,-9.2 -5.8,-16.6 0,-9.2 1.4,-17.1 4.3,-23.9 2.8,-6.7 6.6,-12.6 11.3,-17.7 4.7,-5.1 11,-11.1 19,-18.1 7,-6.1 12.1,-10.7 15.2,-13.9a47.1,47.1 0,0 0,7.9 -10.4c2.1,-3.8 3.2,-8 3.2,-12.5 0,-8.8 -3.3,-16.1 -9.8,-22.1 -6.5,-6 -14.9,-9 -25.2,-9 -12,0 -20.9,3 -26.6,9.1 -5.7,6.1 -10.5,15 -14.4,26.8 -3.7,12.4 -10.8,18.5 -21.2,18.5 -6.1,0 -11.3,-2.2 -15.5,-6.5 -4.2,-4.3 -6.3,-9 -6.3,-14zM510.1,704.4c-6.7,0 -12.5,-2.2 -17.5,-6.5 -5,-4.3 -7.5,-10.4 -7.5,-18.1 0,-6.9 2.4,-12.7 7.2,-17.4 4.8,-4.7 10.7,-7.1 17.7,-7.1 6.9,0 12.7,2.4 17.4,7.1 4.7,4.7 7.1,10.5 7.1,17.4 0,7.7 -2.5,13.7 -7.4,18 -4.9,4.4 -10.6,6.6 -17.1,6.6z" /> | ||
</vector> |
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
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
Oops, something went wrong.