Skip to content

Commit

Permalink
Adapt private share edition
Browse files Browse the repository at this point in the history
  • Loading branch information
davigonz committed Aug 27, 2019
1 parent f2e5ac9 commit a42fbaf
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 161 deletions.
10 changes: 1 addition & 9 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion"
}
Expand Down
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#Thu Apr 25 08:58:52 CEST 2019
#Tue Aug 27 18:09:32 CEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionSha256Sum=53b71812f18cdb2777e9f1b2a0f2038683907c90bdc406bc64d8b400e1fb2c3b
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ public void triggerMediaScan(String path) {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
try {
MainApp.getAppContext().sendBroadcast(intent);
MainApp.Companion.getAppContext().sendBroadcast(intent);
} catch (FileUriExposedException fileUriExposedException) {
Intent newIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
newIntent.setData(FileProvider.getUriForFile(
Expand All @@ -1619,10 +1619,10 @@ public void triggerMediaScan(String path) {
new File(path)
)
);
MainApp.getAppContext().sendBroadcast(newIntent);
MainApp.Companion.getAppContext().sendBroadcast(newIntent);
}
} else {
MainApp.getAppContext().sendBroadcast(intent);
MainApp.Companion.getAppContext().sendBroadcast(intent);
}

MainApp.Companion.getAppContext().sendBroadcast(intent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@ import com.google.android.material.snackbar.Snackbar
import com.owncloud.android.R
import com.owncloud.android.data.sharing.shares.db.OCShareEntity
import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.lib.common.operations.RemoteOperation
import com.owncloud.android.lib.common.operations.RemoteOperationResult
import com.owncloud.android.lib.common.utils.Log_OC
import com.owncloud.android.lib.resources.shares.RemoteShare
import com.owncloud.android.lib.resources.shares.ShareType
import com.owncloud.android.operations.RemoveShareOperation
import com.owncloud.android.presentation.UIResult.Status
import com.owncloud.android.presentation.providers.sharing.UsersAndGroupsSearchProvider
import com.owncloud.android.presentation.ui.sharing.fragments.EditPrivateShareFragment
Expand Down Expand Up @@ -116,17 +113,14 @@ class ShareActivity : FileActivity(), ShareFragmentListener {
)
ft.commit()
}

observePrivateShareCreation()
}

public override fun onStop() {
super.onStop()
}

override fun startObserving() {
observePrivateShareToEdit()
observePrivateShareEdition()
}

override fun observeCapabilities() {
ocCapabilityViewModel.capabilities.observe(
this,
Expand Down Expand Up @@ -173,6 +167,18 @@ class ShareActivity : FileActivity(), ShareFragmentListener {
*********************************************** PRIVATE SHARES ***********************************************
**************************************************************************************************************/

override fun showSearchUsersAndGroups() {
val searchFragment = SearchShareesFragment.newInstance(file, account)
val ft = supportFragmentManager.beginTransaction()
ft.replace(
R.id.share_fragment_container, searchFragment,
TAG_SEARCH_FRAGMENT
)
ft.addToBackStack(null) // BACK button will recover the ShareFragment
ft.commit()
}

// Private share creation needs to be handled from here since is is carried out through intents
override fun onNewIntent(intent: Intent) {
when (intent.action) {
Intent.ACTION_SEARCH -> { // Verify the action and get the query
Expand Down Expand Up @@ -231,17 +237,18 @@ class ShareActivity : FileActivity(), ShareFragmentListener {
}
}

override fun observePrivateShareCreation() {
private fun observePrivateShareCreation() {
ocShareViewModel.privateShareCreationStatus.observe(
this,
Observer { uiResult ->
when (uiResult?.status) {
Status.ERROR -> {
Snackbar.make(
findViewById(android.R.id.content),
findViewById(android.R.id.content)!!,
uiResult.errorMessage!!,
Snackbar.LENGTH_SHORT
).show()
dismissLoadingDialog()
}
Status.LOADING -> {
showLoadingDialog(R.string.common_loading)
Expand All @@ -256,42 +263,6 @@ class ShareActivity : FileActivity(), ShareFragmentListener {
)
}

override fun showSearchUsersAndGroups() {
val searchFragment = SearchShareesFragment.newInstance(file, account)
val ft = supportFragmentManager.beginTransaction()
ft.replace(
R.id.share_fragment_container, searchFragment,
TAG_SEARCH_FRAGMENT
)
ft.addToBackStack(null) // BACK button will recover the ShareFragment
ft.commit()
}

private fun observePrivateShareEdition() {
ocShareViewModel.privateShareEditionStatus.observe(
this,
Observer { uiResult ->
when (uiResult?.status) {
Status.ERROR -> {
Snackbar.make(
findViewById(android.R.id.content),
uiResult.errorMessage!!,
Snackbar.LENGTH_SHORT
).show()
}
Status.LOADING -> {
showLoadingDialog(R.string.common_loading)
}
else -> {
Log.d(
TAG, "Unknown status when editing private share"
)
}
}
}
)
}

override fun showEditPrivateShare(share: OCShareEntity) {
val ft = supportFragmentManager.beginTransaction()
val prev = supportFragmentManager.findFragmentByTag(TAG_EDIT_SHARE_FRAGMENT)
Expand All @@ -308,35 +279,6 @@ class ShareActivity : FileActivity(), ShareFragmentListener {
)
}

override fun updatePrivateShare(remoteId: Long, permissions: Int) {
ocShareViewModel.updatePrivateShare(
remoteId,
permissions
)
}

override fun observePrivateShareToEdit() {
ocShareViewModel.privateShare.observe(
this,
Observer { uiResult ->
when (uiResult?.status) {
Status.SUCCESS -> {
editPrivateShareFragment?.updateShare(uiResult.data)
}
else -> {
Log.d(
TAG, "Unknown status when getting updated private share"
)
}
}
}
)
}

override fun refreshPrivateShare(remoteId: Long) {
ocShareViewModel.refreshPrivateShare(remoteId)
}

override fun copyOrSendPrivateLink(file: OCFile) {
fileOperationsHelper.copyOrSendPrivateLink(file)
}
Expand Down Expand Up @@ -372,6 +314,10 @@ class ShareActivity : FileActivity(), ShareFragmentListener {
)
}

/**************************************************************************************************************
************************************************** COMMON ****************************************************
**************************************************************************************************************/

override fun showRemoveShare(share: OCShareEntity) {
val removePublicShareFragment = RemoveShareDialogFragment.newInstance(share, account)
showDialogFragment(
Expand All @@ -384,21 +330,6 @@ class ShareActivity : FileActivity(), ShareFragmentListener {
fileOperationsHelper.copyOrSendPublicLink(share)
}

/**
* Updates the view associated to the activity after the finish of some operation over files
* in the current account.
*
* @param operation Removal operation performed.
* @param result Result of the removal.
*/
override fun onRemoteOperationFinish(operation: RemoteOperation<*>, result: RemoteOperationResult<*>) {
super.onRemoteOperationFinish(operation, result)

if (operation is RemoveShareOperation && result.isSuccess && editPrivateShareFragment != null) {
supportFragmentManager.popBackStack()
}
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
var retval = true
when (item.itemId) {
Expand All @@ -410,6 +341,14 @@ class ShareActivity : FileActivity(), ShareFragmentListener {
return retval
}

override fun showLoading() {
showLoadingDialog(R.string.common_loading)
}

override fun dismissLoading() {
dismissLoadingDialog()
}

companion object {
private val TAG = ShareActivity::class.java.simpleName

Expand Down
Loading

0 comments on commit a42fbaf

Please sign in to comment.