Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Private link #1978

Merged
merged 13 commits into from
Jun 7, 2017
Merged

Private link #1978

merged 13 commits into from
Jun 7, 2017

Conversation

davigonz
Copy link
Contributor

@davigonz davigonz commented Jun 1, 2017

Implements #1970
Requires owncloud/android-library#165

@davigonz davigonz requested a review from davivel June 1, 2017 13:15
@davigonz
Copy link
Contributor Author

davigonz commented Jun 1, 2017

@davivel , @jesmrec , ready for code review and QA

@jesmrec jesmrec mentioned this pull request Jun 2, 2017
@@ -50,6 +50,7 @@
android:layout_marginRight="@dimen/standard_half_margin"
android:layout_marginStart="4dp"
android:layout_toEndOf="@+id/shareFileIcon"
android:layout_toLeftOf="@+id/getPrivateLinkButton"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add also android:layout_toStartOf="@id/getPrivateLinkButton" for better support of RTL languages.

import android.app.SearchManager;
import android.content.Context;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be removed?

@@ -29,6 +29,7 @@
import android.widget.TextView;

import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be removed?

@Override
public boolean onLongClick(View view) {
// Show a toast message explaining what a private link is
Toast.makeText(getActivity(), R.string.private_link_info, Toast.LENGTH_LONG).show();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea! 👍

@@ -21,20 +21,26 @@

package com.owncloud.android.ui.fragment;

import android.accounts.Account;
import android.content.Context;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove the imports that are not really used.

* @param file @param file {@link OCFile} which will be shared with internal users
* @param account
*/
public void copyOrSendPrivateLink(Context context, Account account, OCFile file) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to pass a context to the method. FileOperationsHelper has a field mFileActivity that can be used instead.


String fileId = Integer.valueOf(parsedRemoteId).toString();

Uri uri = Uri.parse(com.owncloud.android.lib.common.accounts.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here first a String is parsed to Uri, then the Uri is serialized to String immediately. Why is it? Needs to be normalized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right. Parsing the String to Uri is not needed, I can use directly the link obtained in AccountUtils.getUrlForFile to share it later.

try {

// Parse remoteId
String remoteId = file.getRemoteId();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this block would be better together in a method getPermalink(), or getPrivateLink(); might be in OCFile, and receive the base URL to the server as a parameter. Take into account that the manipulation of the remote Id is quite specific of private link right now, and the responsibility of this method is not generating the permalink itself, but that of displaying the menu of apps capable of handling the permalink.

shareLink(link);

} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
e.printStackTrace();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather to use Log_OC.e(..., e), it prints the stack trace too.

@jesmrec
Copy link
Collaborator

jesmrec commented Jun 2, 2017

Approved.

@jesmrec
Copy link
Collaborator

jesmrec commented Jun 5, 2017

Lot of changes in the code review. @davivel @davigonz will be needed a new QA review?

@davigonz davigonz changed the title Permalink Private link Jun 5, 2017
@davigonz
Copy link
Contributor Author

davigonz commented Jun 5, 2017

@jesmrec All the changes are related to code refactoring, I've tested it and is working properly but you can test it again to be sure.

public String getPrivateLink(Context context, Account account) {

// Parse remoteId
String parsedRemoteId = mRemoteId.substring(0, Math.min(mRemoteId.length(), 8));
Copy link
Contributor

@davivel davivel Jun 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't understand what conversion are you doing here to get the string for the private link

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point here is that I get the complete remoteId from the server but I only need the first 8 characters.

Example:

remoteId from server: 00000003ocr2n5bhxjuy

  • 00000003 => file id
  • ocr2n5bhxjuy => server instance ID

BTW, Math.min(mRemoteId.length() is not required, I will delete it

if (baseUrl == null)
throw new AccountUtils.AccountNotFoundException(account, "Account not found", null);

privateLink = baseUrl + AccountUtils.INDEX_PATH + FILES_PATH + "/" + fileId;
Copy link
Contributor

@davivel davivel Jun 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather to have a single constant, fully meaningful by itself; something like PRIVATE_LINK_PATH = /index.php/f/" .

Copy link
Contributor Author

@davigonz davigonz Jun 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had separated it into two different paths just in case we needed to use /index.php in the future, similarly to STATUS_PATH constant.

@davigonz
Copy link
Contributor Author

davigonz commented Jun 6, 2017

@davivel @jesmrec , finished all the requested changes. Ready for approving and a second round of QA

@jesmrec
Copy link
Collaborator

jesmrec commented Jun 6, 2017

@davigonz QA process was reviewed again succesfully.

@davivel
Copy link
Contributor

davivel commented Jun 7, 2017

You did it

@davivel davivel merged commit 7b0046c into master Jun 7, 2017
@davivel davivel deleted the permalink branch June 7, 2017 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants