-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Private link #1978
Conversation
@@ -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" |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
Approved. |
@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)); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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/"
.
There was a problem hiding this comment.
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 QA process was reviewed again succesfully. |
You did it |
Implements #1970
Requires owncloud/android-library#165