Skip to content

Commit

Permalink
Merge community enterprise security (#168)
Browse files Browse the repository at this point in the history
* saving credentials in secure way

* PMD implementation in GitHub action (#294)

* PMD implementation in GitHub action

* Update build.yml

* MOBIELAPPS-2121 (#295)

* fixed progress running infinite issue

* removed print statements

* MOBILEAPPS-2120 (#296)

* fixed move crash

* merged community code
  • Loading branch information
aman-alfresco authored Oct 18, 2023
1 parent 2237c9b commit bf44bb0
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import android.content.Context
import android.os.Bundle
import androidx.activity.result.ActivityResultLauncher
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.alfresco.content.actions.MoveResultContract.Companion.ENTRY_OBJ_KEY
import com.alfresco.content.data.Entry
import com.alfresco.content.withNewFragment
Expand All @@ -15,21 +17,23 @@ import kotlinx.coroutines.suspendCancellableCoroutine
*/
class ActionMoveFragment : Fragment() {
private lateinit var requestLauncher: ActivityResultLauncher<Unit>
private var onResult: CancellableContinuation<String?>? = null
private lateinit var viewModel: ActionMoveViewModel

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
viewModel = ViewModelProvider(this)[ActionMoveViewModel::class.java]

arguments?.let { bundle ->
val entryObj = bundle.getParcelable(ENTRY_OBJ_KEY) as Entry?
requestLauncher = registerForActivityResult(MoveResultContract(entryObj)) {
onResult?.resume(it, null)
viewModel.onResult?.resume(it, null)
}
}
}

private suspend fun moveItems(): String? =
suspendCancellableCoroutine { continuation ->
onResult = continuation
viewModel.onResult = continuation
requestLauncher.launch(Unit)
}

Expand Down Expand Up @@ -57,3 +61,10 @@ class ActionMoveFragment : Fragment() {
}
}
}

/**
* ViewModel to retain the continuation
*/
class ActionMoveViewModel : ViewModel() {
var onResult: CancellableContinuation<String?>? = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ data class ActionAddOffline(
entries.forEachIndexed { index, obj ->
val res = repository.markForSync(obj)
// return item without status
entriesObj[index] = res.copy(offlineStatus = OfflineStatus.UNDEFINED, isSelectedForMultiSelection = false)
entriesObj[index] = res.copy(offlineStatus = OfflineStatus.UNDEFINED)
}
return Pair(entry, entriesObj)
}
Expand Down Expand Up @@ -63,7 +63,7 @@ data class ActionRemoveOffline(
override suspend fun executeMulti(context: Context): Pair<Entry, List<Entry>> {
val entriesObj = entries.toMutableList()
entries.forEachIndexed { index, obj ->
entriesObj[index] = repository.removeFromSync(obj).copy(isSelectedForMultiSelection = false)
entriesObj[index] = repository.removeFromSync(obj).copy(offlineStatus = OfflineStatus.UNDEFINED)
}
return Pair(entry, entriesObj)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import com.alfresco.content.data.Entry
class MoveResultContract(private val entryObj: Entry?) : ActivityResultContract<Unit, String?>() {
@CallSuper
override fun createIntent(context: Context, input: Unit): Intent {
val intent = Intent(
context,
Class.forName("com.alfresco.content.app.activity.MoveActivity"),
)
intent.putExtra(ENTRY_OBJ_KEY, entryObj)
return intent
}
Expand All @@ -29,13 +33,5 @@ class MoveResultContract(private val entryObj: Entry?) : ActivityResultContract<
const val OUTPUT_KEY = "targetParentId"
const val ENTRY_OBJ_KEY = "entryObj"
const val MOVE_ID_KEY = "moveId"
lateinit var intent: Intent

/**
* adding intent for MoveActivity
*/
fun addMoveIntent(moveIntent: Intent) {
intent = moveIntent
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import androidx.navigation.findNavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.NavigationUI
import androidx.navigation.ui.setupWithNavController
Expand All @@ -35,7 +36,6 @@ import com.alfresco.auth.activity.LoginViewModel.Companion.DISTRIBUTION_VERSION
import com.alfresco.auth.ui.observe
import com.alfresco.content.actions.Action
import com.alfresco.content.actions.ContextualActionsSheet
import com.alfresco.content.actions.MoveResultContract
import com.alfresco.content.activityViewModel
import com.alfresco.content.app.R
import com.alfresco.content.app.widget.ActionBarController
Expand Down Expand Up @@ -70,6 +70,7 @@ class MainActivity : AppCompatActivity(), MavericksView, ActionMode.Callback {
@OptIn(InternalMavericksApi::class)
private val viewModel: MainActivityViewModel by activityViewModel()
private val navController by lazy { findNavController(R.id.nav_host_fragment) }
private var navHostFragment: NavHostFragment? = null
private val bottomNav by lazy { findViewById<BottomNavigationView>(R.id.bottom_nav) }
private var actionBarController: ActionBarController? = null
private var signedOutDialog = WeakReference<AlertDialog>(null)
Expand Down Expand Up @@ -205,6 +206,7 @@ class MainActivity : AppCompatActivity(), MavericksView, ActionMode.Callback {
}

private fun configure() = withState(viewModel) { state ->
navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
val graph = navController.navInflater.inflate(R.navigation.nav_bottom)
graph.setStartDestination(if (state.isOnline) R.id.nav_recents else R.id.nav_offline)
navController.graph = graph
Expand All @@ -216,7 +218,6 @@ class MainActivity : AppCompatActivity(), MavericksView, ActionMode.Callback {
bottomNav.setupWithNavController(navController)

setupActionToasts()
MoveResultContract.addMoveIntent(Intent(this, MoveActivity::class.java))
setupDownloadNotifications()

bottomNav.setOnItemSelectedListener { item ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package com.alfresco.content.data.rooted

import android.content.Context
import com.scottyab.rootbeer.RootBeer
import com.scottyab.rootbeer.util.Utils


class CheckForRootWorker(context: Context) {

Expand All @@ -17,10 +15,10 @@ class CheckForRootWorker(context: Context) {
RootItemResult("Root Cloaking Apps", rootBeer.detectRootCloakingApps()),
RootItemResult("TestKeys", rootBeer.detectTestKeys()),
RootItemResult("BusyBoxBinary", rootBeer.checkForBusyBoxBinary()),
RootItemResult("SU Binary", rootBeer.checkForSuBinary()),
// RootItemResult("SU Binary", rootBeer.checkForSuBinary()),
RootItemResult("2nd SU Binary check", rootBeer.checkSuExists()),
RootItemResult("For RW Paths", rootBeer.checkForRWPaths()),
RootItemResult("Dangerous Props", rootBeer.checkForDangerousProps()),
// RootItemResult("Dangerous Props", rootBeer.checkForDangerousProps()),
RootItemResult("Root via native check", rootBeer.checkForRootNative()),
// RootItemResult("SE linux Flag Is Enabled", !Utils.isSelinuxFlagInEnabled()),
RootItemResult("Magisk specific checks", rootBeer.checkForMagiskBinary()),
Expand Down
12 changes: 7 additions & 5 deletions move/src/main/java/com/alfresco/content/move/MoveFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,19 @@ class MoveFragment : Fragment(), MavericksView {
@OptIn(InternalMavericksApi::class)
val viewModel: MoveViewModel by fragmentViewModelWithArgs { args }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

args = MoveArgs.with(requireArguments())

override fun onStart() {
super.onStart()
val nodeId = viewModel.getMyFilesNodeId()
args.entryObj?.let {
findNavController().navigateToMoveParent(nodeId, it.id, getString(R.string.browse_menu_personal))
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
args = MoveArgs.with(requireArguments())
}

override fun invalidate() = withState(viewModel) { state ->
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class ViewerFragment : Fragment(), MavericksView {
private val viewModel: ViewerViewModel by fragmentViewModelWithArgs { args }
private lateinit var binding: ViewerBinding
private var childFragment: ChildViewerFragment? = null
private var hasLoadingStatus: Boolean = false

private val viewerLoadingListener = object : LoadingListener {
override fun onContentLoaded() {
Expand Down Expand Up @@ -119,7 +120,9 @@ class ViewerFragment : Fragment(), MavericksView {
state.viewerUri,
state.viewerMimeType,
)
show(Status.LoadingPreview)
if (!hasLoadingStatus) {
show(Status.LoadingPreview)
}
} else {
show(Status.NotSupported)
}
Expand Down Expand Up @@ -180,12 +183,14 @@ class ViewerFragment : Fragment(), MavericksView {
}

Status.PreviewLoaded -> {
hasLoadingStatus = true
info.isVisible = childFragment?.showInfoWhenLoaded() == true
loading.isVisible = false
status.text = ""
}

Status.NotSupported -> {
hasLoadingStatus = true
info.isVisible = true
loading.isVisible = false
status.text = getString(R.string.error_preview_not_available)
Expand Down

0 comments on commit bf44bb0

Please sign in to comment.