forked from mozilla-mobile/fenix
-
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.
For mozilla-mobile#3709: Add save to PDF UI.
- Loading branch information
Showing
15 changed files
with
322 additions
and
37 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
16 changes: 16 additions & 0 deletions
16
app/src/main/java/org/mozilla/fenix/share/SaveToPDFInteractor.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,16 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.mozilla.fenix.share | ||
|
||
/** | ||
* Callbacks for possible user interactions on the [SaveToPDFItem] | ||
*/ | ||
interface SaveToPDFInteractor { | ||
/** | ||
* Generates a PDF from the given [tabId]. | ||
* @param tabId The ID of the tab to save as PDF. | ||
*/ | ||
fun onSaveToPDF(tabId: String?) | ||
} |
70 changes: 70 additions & 0 deletions
70
app/src/main/java/org/mozilla/fenix/share/SaveToPDFItem.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,70 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.mozilla.fenix.share | ||
|
||
import android.content.res.Configuration | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.material.Icon | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import org.mozilla.fenix.R | ||
import org.mozilla.fenix.theme.FirefoxTheme | ||
|
||
/** | ||
* A save to PDF item. | ||
* | ||
* @param onClick event handler when the save to PDF item is clicked. | ||
*/ | ||
@Composable | ||
fun SaveToPDFItem( | ||
onClick: () -> Unit, | ||
) { | ||
Row( | ||
modifier = Modifier | ||
.height(56.dp) | ||
.fillMaxWidth() | ||
.clickable(onClick = onClick), | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
Spacer(Modifier.width(16.dp)) | ||
|
||
Icon( | ||
painter = painterResource(R.drawable.ic_download), | ||
contentDescription = stringResource( | ||
R.string.content_description_close_button, | ||
), | ||
tint = FirefoxTheme.colors.iconPrimary, | ||
) | ||
|
||
Spacer(Modifier.width(32.dp)) | ||
|
||
Text( | ||
color = FirefoxTheme.colors.textPrimary, | ||
text = stringResource(R.string.share_save_to_pdf), | ||
style = FirefoxTheme.typography.subtitle1, | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
@Preview | ||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) | ||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) | ||
private fun SaveToPDFItemPreview() { | ||
FirefoxTheme { | ||
SaveToPDFItem {} | ||
} | ||
} |
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
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.