Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SedentaryBehaviourApplication
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Peter Joseph De Jonckheere CESM2014
SedentaryBehaviourApplication
Commits
bc31d9e1
Commit
bc31d9e1
authored
7 years ago
by
Peter Joseph De Jonckheere CESM2014
Browse files
Options
Downloads
Patches
Plain Diff
Added upload file logic
parent
644176da
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/com/example/pharmacy/frontEnd/AdvancedSettings.java
+13
-1
13 additions, 1 deletion
.../java/com/example/pharmacy/frontEnd/AdvancedSettings.java
src/main/java/com/example/pharmacy/frontEnd/SaveFile.java
+42
-0
42 additions, 0 deletions
src/main/java/com/example/pharmacy/frontEnd/SaveFile.java
with
55 additions
and
1 deletion
src/main/java/com/example/pharmacy/frontEnd/AdvancedSettings.java
+
13
−
1
View file @
bc31d9e1
...
...
@@ -3,6 +3,7 @@ package com.example.pharmacy.frontEnd;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.support.v7.app.AppCompatActivity
;
import
android.view.View
;
...
...
@@ -16,6 +17,9 @@ import android.widget.Spinner;
import
android.widget.Switch
;
import
android.widget.Toast
;
import
java.io.File
;
import
java.io.FileOutputStream
;
/**
* Created by pharmacy on 16/02/2018.
*/
...
...
@@ -62,7 +66,15 @@ public class AdvancedSettings extends AppCompatActivity {
@Override
public
void
onClick
(
View
view
)
{
//DO UPLOAD THINGS HERE
File
file
=
SaveFile
.
zipFiles
(
view
.
getContext
());
Intent
sendIntent
=
new
Intent
(
Intent
.
ACTION_SEND
);
if
(
file
.
exists
()
&&
(
file
!=
null
)){
sendIntent
.
setType
(
"notificationapp/zip"
);
sendIntent
.
putExtra
(
Intent
.
EXTRA_STREAM
,
Uri
.
parse
(
"file://"
+
file
.
getAbsolutePath
()));
sendIntent
.
putExtra
(
Intent
.
EXTRA_SUBJECT
,
"Sharing File..."
);
sendIntent
.
putExtra
(
Intent
.
EXTRA_TEXT
,
"Sharing File..."
);
startActivity
(
Intent
.
createChooser
(
sendIntent
,
"Share File"
));
}
}
});
populateSpinners
();
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/example/pharmacy/frontEnd/SaveFile.java
+
42
−
0
View file @
bc31d9e1
...
...
@@ -5,14 +5,19 @@ import android.content.SharedPreferences;
import
android.os.Environment
;
import
android.util.Log
;
import
java.io.BufferedOutputStream
;
import
java.io.BufferedReader
;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.FileReader
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
/**
* Created by pharmacy on 12/02/2018.
...
...
@@ -116,6 +121,43 @@ public class SaveFile {
recordTimeStamp
(
sent
,
clicked
,
acknowledged
,
context
);
}
public
static
File
zipFiles
(
Context
context
)
{
File
file
=
null
;
if
(
isExternalStorageMounted
())
{
File
dir
=
getDirectory
(
context
);
if
(
dir
.
isDirectory
())
{
file
=
new
File
(
dir
,
"ZIPFILE.zip"
);
try
{
if
(!
file
.
exists
())
{
file
.
createNewFile
();
}
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
ZipOutputStream
zos
=
new
ZipOutputStream
(
new
BufferedOutputStream
(
fos
));
File
[]
files
=
dir
.
listFiles
();
try
{
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++){
byte
[]
buffer
=
new
byte
[
1024
];
FileInputStream
fis
=
new
FileInputStream
(
files
[
i
]);
zos
.
putNextEntry
(
new
ZipEntry
(
files
[
i
].
getName
()));
int
length
;
while
((
length
=
fis
.
read
(
buffer
))
>
0
)
{
zos
.
write
(
buffer
,
0
,
length
);
}
zos
.
closeEntry
();
fis
.
close
();
}
}
finally
{
zos
.
close
();
}
}
catch
(
IOException
e
)
{
}
}
}
return
file
;
}
public
static
void
recordNotificationType
(
Context
context
)
{
SharedPreferences
shared
=
context
.
getSharedPreferences
(
context
.
getString
(
R
.
string
.
preference_file_key
),
Context
.
MODE_PRIVATE
);
int
sound
=
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment