Skip to content

Commit 2560827

Browse files
Merge pull request #358 from PermanentOrg/feature/VSP-1579
Implemented checklist navigation part 2 + Refactoring
2 parents 8d3f5d5 + 8e34d9c commit 2560827

File tree

10 files changed

+40
-45
lines changed

10 files changed

+40
-45
lines changed

app/src/main/java/org/permanent/permanent/ui/Extensions.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package org.permanent.permanent.ui
33
import android.annotation.SuppressLint
44
import android.app.Activity
55
import android.content.Context
6+
import android.content.Intent
67
import android.content.res.Resources
78
import android.net.Uri
89
import android.os.IBinder
@@ -43,6 +44,14 @@ fun Context.assetSize(resourceUri: Uri): Long {
4344
}
4445
}
4546

47+
fun Context.openLink(uriString: String) {
48+
val intent = Intent(
49+
Intent.ACTION_VIEW,
50+
Uri.parse(uriString)
51+
)
52+
startActivity(intent)
53+
}
54+
4655
fun Activity.computeWindowSizeClasses(): WindowSizeClass {
4756
val metrics = WindowMetricsCalculator.getOrCreate().computeCurrentWindowMetrics(this)
4857
val width = metrics.bounds.width()

app/src/main/java/org/permanent/permanent/ui/activities/UpdateAppActivity.kt

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import org.permanent.permanent.databinding.ActivityUpdateAppBinding
1111
import org.permanent.permanent.ui.PREFS_NAME
1212
import org.permanent.permanent.ui.PreferencesHelper
1313
import org.permanent.permanent.ui.computeWindowSizeClasses
14+
import org.permanent.permanent.ui.openLink
1415

1516
class UpdateAppActivity : PermanentBaseActivity() {
1617

@@ -34,20 +35,10 @@ class UpdateAppActivity : PermanentBaseActivity() {
3435
binding = DataBindingUtil.setContentView(this, R.layout.activity_update_app)
3536
binding.btnUpdate.setOnClickListener {
3637
try {
37-
startActivity(
38-
Intent(
39-
Intent.ACTION_VIEW,
40-
Uri.parse("market://details?id=$packageName")
41-
// Uri.parse("market://details?id=org.permanent.PermanentArchive")
42-
)
43-
)
38+
openLink("market://details?id=$packageName")
39+
// openLink("market://details?id=org.permanent.PermanentArchive")
4440
} catch (e: ActivityNotFoundException) {
45-
startActivity(
46-
Intent(
47-
Intent.ACTION_VIEW,
48-
Uri.parse("https://play.google.com/store/apps/details?id=$packageName")
49-
)
50-
)
41+
openLink("https://play.google.com/store/apps/details?id=$packageName")
5142
}
5243
}
5344
}

app/src/main/java/org/permanent/permanent/ui/login/compose/AuthenticationContainer.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import org.permanent.permanent.R
4545
import org.permanent.permanent.ui.composeComponents.ButtonColor
4646
import org.permanent.permanent.ui.composeComponents.CircularProgressIndicator
4747
import org.permanent.permanent.ui.composeComponents.CustomTextButton
48+
import org.permanent.permanent.ui.openLink
4849
import org.permanent.permanent.viewmodels.AuthenticationViewModel
4950

5051
@Composable
@@ -204,10 +205,7 @@ private fun LeftSideView(
204205
text = stringResource(id = R.string.start_exploring_now),
205206
icon = painterResource(id = R.drawable.ic_arrow_next_rounded_primary)
206207
) {
207-
val intent = Intent(
208-
Intent.ACTION_VIEW, Uri.parse("https://www.permanent.org/gallery")
209-
)
210-
context.startActivity(intent)
208+
context.openLink("https://www.permanent.org/gallery")
211209
}
212210
}
213211

app/src/main/java/org/permanent/permanent/ui/login/compose/CodeVerificationPage.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import org.permanent.permanent.ui.composeComponents.CenteredTextAndIconButton
4545
import org.permanent.permanent.ui.composeComponents.CustomTextButton
4646
import org.permanent.permanent.ui.composeComponents.DigitTextField
4747
import org.permanent.permanent.ui.composeComponents.SnackbarType
48+
import org.permanent.permanent.ui.openLink
4849
import org.permanent.permanent.viewmodels.AuthenticationViewModel
4950

5051
@Composable
@@ -195,11 +196,7 @@ fun CodeVerificationPage(
195196
}
196197

197198
CustomTextButton(text = stringResource(id = R.string.contact_support)) {
198-
val intent = Intent(
199-
Intent.ACTION_VIEW,
200-
Uri.parse("https://permanent.zohodesk.com/portal/en/newticket")
201-
)
202-
context.startActivity(intent)
199+
context.openLink("https://permanent.zohodesk.com/portal/en/newticket")
203200
}
204201
}
205202

app/src/main/java/org/permanent/permanent/ui/login/compose/SignUpPage.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import org.permanent.permanent.ui.composeComponents.AnimatedSnackbar
6060
import org.permanent.permanent.ui.composeComponents.ButtonColor
6161
import org.permanent.permanent.ui.composeComponents.CenteredTextAndIconButton
6262
import org.permanent.permanent.ui.composeComponents.SnackbarType
63+
import org.permanent.permanent.ui.openLink
6364
import org.permanent.permanent.viewmodels.AuthenticationViewModel
6465

6566
@Composable
@@ -324,8 +325,7 @@ fun SignUpPage(
324325
annotatedText.getStringAnnotations(
325326
tag = "URL", start = offset, end = offset
326327
).firstOrNull()?.let {
327-
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(it.item))
328-
context.startActivity(intent)
328+
context.openLink(it.item)
329329
}
330330
})
331331

app/src/main/java/org/permanent/permanent/ui/myFiles/MyFilesFragment.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import org.permanent.permanent.ui.myFiles.checklist.ChecklistItemType
4848
import org.permanent.permanent.ui.myFiles.checklist.toChecklistType
4949
import org.permanent.permanent.ui.myFiles.download.DownloadsAdapter
5050
import org.permanent.permanent.ui.myFiles.saveToPermanent.SaveToPermanentFragment
51+
import org.permanent.permanent.ui.openLink
5152
import org.permanent.permanent.ui.public.PublicFragment
5253
import org.permanent.permanent.ui.shareManagement.ShareManagementFragment
5354
import org.permanent.permanent.ui.shares.PreviewState
@@ -393,9 +394,12 @@ class MyFilesFragment : PermanentBaseFragment() {
393394
val bundle = bundleOf(PARCELABLE_ARCHIVE_KEY to viewModel.getCurrentArchive())
394395
findNavController().navigate(R.id.archiveStewardFragment, bundle)
395396
}
396-
ChecklistItemType.FIRST_UPLOAD -> {}
397-
ChecklistItemType.ARCHIVE_PROFILE -> {}
398-
ChecklistItemType.PUBLISH_CONTENT -> {}
397+
ChecklistItemType.FIRST_UPLOAD -> context?.openLink("https://permanent.zohodesk.com/portal/en/kb/articles/uploading-files-mobile-apps")
398+
ChecklistItemType.ARCHIVE_PROFILE -> {
399+
val bundle = bundleOf(PublicFragment.OPEN_PROFILE_TAB to true)
400+
findNavController().navigate(R.id.publicFragment, bundle)
401+
}
402+
ChecklistItemType.PUBLISH_CONTENT -> context?.openLink("https://permanent.zohodesk.com/portal/en/kb/articles/how-to-publish-a-file-or-folder-mobile")
399403
ChecklistItemType.ARCHIVE_CREATED, null -> {}
400404
}
401405
}

app/src/main/java/org/permanent/permanent/ui/public/PublicFragment.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ class PublicFragment : PermanentBaseFragment(), View.OnClickListener {
124124
setArchive(arguments?.getParcelable(ARCHIVE) ?: prefsHelper.getCurrentArchive())
125125
}
126126

127+
val shouldOpenProfileTab = arguments?.getBoolean(OPEN_PROFILE_TAB) == true
128+
if (shouldOpenProfileTab) {
129+
binding.vpPublic.post {
130+
binding.vpPublic.currentItem = 1
131+
}
132+
}
133+
127134
return binding.root
128135
}
129136

@@ -200,5 +207,6 @@ class PublicFragment : PermanentBaseFragment(), View.OnClickListener {
200207
const val FOLDER_ARCHIVE_NR = "folder_archive_nr"
201208
const val FOLDER_LINK_ID = "folder_link_id"
202209
const val FILE_ARCHIVE_NR = "file_archive_nr"
210+
const val OPEN_PROFILE_TAB = "open_profile_tab"
203211
}
204212
}

app/src/main/java/org/permanent/permanent/ui/settings/compose/twoStepVerification/CodeVerificationPage.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import org.permanent.permanent.ui.composeComponents.CustomTextButton
5858
import org.permanent.permanent.ui.composeComponents.DigitTextField
5959
import org.permanent.permanent.ui.composeComponents.DigitTextFieldColor
6060
import org.permanent.permanent.ui.composeComponents.TimerButton
61+
import org.permanent.permanent.ui.openLink
6162
import org.permanent.permanent.viewmodels.LoginAndSecurityViewModel
6263

6364
@Composable
@@ -253,11 +254,7 @@ fun CodeVerificationPage(
253254
style = ButtonColor.TRANSPARENT,
254255
text = stringResource(id = R.string.contact_support),
255256
) {
256-
val intent = Intent(
257-
Intent.ACTION_VIEW,
258-
Uri.parse("https://permanent.zohodesk.com/portal/en/newticket")
259-
)
260-
context.startActivity(intent)
257+
context.openLink("https://permanent.zohodesk.com/portal/en/newticket")
261258
}
262259
}
263260
}

app/src/main/java/org/permanent/permanent/ui/storage/AddStorageFragment.kt

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import org.permanent.permanent.R
2222
import org.permanent.permanent.databinding.FragmentAddStorageBinding
2323
import org.permanent.permanent.models.AccountEventAction
2424
import org.permanent.permanent.ui.PermanentBaseFragment
25+
import org.permanent.permanent.ui.openLink
2526
import org.permanent.permanent.viewmodels.AddStorageViewModel
2627
import org.permanent.permanent.viewmodels.AddStorageViewModel.Companion.DONATION_AMOUNT_10_VALUE
2728
import org.permanent.permanent.viewmodels.AddStorageViewModel.Companion.DONATION_AMOUNT_20_VALUE
@@ -151,19 +152,9 @@ class AddStorageFragment : PermanentBaseFragment(), TabLayout.OnTabSelectedListe
151152
R.string.button_go_to_wallet
152153
) { _, _ ->
153154
try {
154-
startActivity(
155-
Intent(
156-
Intent.ACTION_VIEW,
157-
Uri.parse("market://details?id=$GOOGLE_WALLET_APP_ID")
158-
)
159-
)
155+
context?.openLink("market://details?id=$GOOGLE_WALLET_APP_ID")
160156
} catch (e: ActivityNotFoundException) {
161-
startActivity(
162-
Intent(
163-
Intent.ACTION_VIEW,
164-
Uri.parse("https://play.google.com/store/apps/details?id=$GOOGLE_WALLET_APP_ID")
165-
)
166-
)
157+
context?.openLink("https://play.google.com/store/apps/details?id=$GOOGLE_WALLET_APP_ID")
167158
}
168159
}
169160
alertDialog.setNegativeButton(R.string.button_cancel) { _, _ -> }

app/src/main/java/org/permanent/permanent/viewmodels/PublicProfileViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class PublicProfileViewModel(application: Application) : ObservableAndroidViewMo
184184
}
185185

186186
fun onIsProfilePublicChanged(checked: Boolean) {
187-
if (isViewOnlyMode.value == false) {
187+
if (isViewOnlyMode.value == false && isProfilePublic.value != checked) {
188188
isBusy.value = true
189189
profileRepository.safeAddUpdateProfileItems(
190190
getProfileItemsToUpdateVisibility(checked), true,

0 commit comments

Comments
 (0)