Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Network
KDE Connect Android
Commits
177c18e0
Commit
177c18e0
authored
Apr 02, 2019
by
Simon Redman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up uriToNetworkPacket
- Remove redundant code - Make top-level block function properly
parent
a3fb423d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
36 deletions
+15
-36
src/org/kde/kdeconnect/Helpers/FilesHelper.java
src/org/kde/kdeconnect/Helpers/FilesHelper.java
+15
-36
No files found.
src/org/kde/kdeconnect/Helpers/FilesHelper.java
View file @
177c18e0
...
...
@@ -134,44 +134,23 @@ public class FilesHelper {
}
else
{
// Probably a content:// uri, so we query the Media content provider
Cursor
cursor
=
null
;
try
{
String
[]
proj
=
{
MediaStore
.
MediaColumns
.
DATA
,
MediaStore
.
MediaColumns
.
SIZE
,
MediaStore
.
MediaColumns
.
DISPLAY_NAME
};
cursor
=
cr
.
query
(
uri
,
proj
,
null
,
null
,
null
);
int
column_index
=
cursor
.
getColumnIndexOrThrow
(
MediaStore
.
MediaColumns
.
DATA
);
String
[]
proj
=
{
MediaStore
.
MediaColumns
.
SIZE
,
MediaStore
.
MediaColumns
.
DISPLAY_NAME
,
};
try
(
Cursor
cursor
=
cr
.
query
(
uri
,
proj
,
null
,
null
,
null
))
{
int
nameColumnIndex
=
cursor
.
getColumnIndexOrThrow
(
MediaStore
.
MediaColumns
.
DISPLAY_NAME
);
int
sizeColumnIndex
=
cursor
.
getColumnIndexOrThrow
(
MediaStore
.
MediaColumns
.
SIZE
);
cursor
.
moveToFirst
();
String
path
=
cursor
.
getString
(
column_index
);
np
.
set
(
"filename"
,
Uri
.
parse
(
path
).
getLastPathSegment
());
size
=
new
File
(
path
).
length
();
}
catch
(
Exception
unused
)
{
Log
.
w
(
"SendFileActivity"
,
"Could not resolve media to a file, trying to get info as media"
);
try
{
int
column_index
=
cursor
.
getColumnIndexOrThrow
(
MediaStore
.
MediaColumns
.
DISPLAY_NAME
);
cursor
.
moveToFirst
();
String
name
=
cursor
.
getString
(
column_index
);
np
.
set
(
"filename"
,
name
);
}
catch
(
Exception
e
)
{
Log
.
e
(
"SendFileActivity"
,
"Could not obtain file name"
,
e
);
}
try
{
int
column_index
=
cursor
.
getColumnIndexOrThrow
(
MediaStore
.
MediaColumns
.
SIZE
);
cursor
.
moveToFirst
();
//For some reason this size can differ from the actual file size!
size
=
cursor
.
getInt
(
column_index
);
}
catch
(
Exception
e
)
{
Log
.
e
(
"SendFileActivity"
,
"Could not obtain file size"
,
e
);
}
}
finally
{
try
{
cursor
.
close
();
}
catch
(
Exception
ignored
)
{
}
}
String
filename
=
cursor
.
getString
(
nameColumnIndex
);
size
=
cursor
.
getInt
(
sizeColumnIndex
);
np
.
set
(
"filename"
,
filename
);
}
catch
(
Exception
e
)
{
Log
.
e
(
"SendFileActivity"
,
"Problem getting file information"
,
e
);
}
}
np
.
setPayload
(
new
NetworkPacket
.
Payload
(
inputStream
,
size
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment