This repository has been archived by the owner on Sep 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from coderbunker/issue#27-eye_tracking
Issue#27 eye tracking
- Loading branch information
Showing
9 changed files
with
310 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,5 @@ | |
/build | ||
/captures | ||
.externalNativeBuild | ||
.idea/caches/build_file_checksums.ser | ||
.idea/caches/build_file_checksums.ser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
app/src/main/java/com/coderbunker/kioskapp/lib/SaveAndLoad.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package com.coderbunker.kioskapp.lib; | ||
|
||
import android.content.Context; | ||
import android.util.Log; | ||
import android.webkit.MimeTypeMap; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.FileNotFoundException; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.io.OutputStreamWriter; | ||
|
||
public class SaveAndLoad { | ||
//Source: https://stackoverflow.com/questions/14376807/how-to-read-write-string-from-a-file-in-android | ||
|
||
public static void writeToFile(String filename, String data, Context ctx) { | ||
try { | ||
FileOutputStream fou = ctx.openFileOutput(filename, Context.MODE_PRIVATE); | ||
OutputStreamWriter osw = new OutputStreamWriter(fou); | ||
try { | ||
osw.write(data); | ||
osw.flush(); | ||
osw.close(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} catch (FileNotFoundException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public static String readFromFile(String filename, Context context) { | ||
|
||
String ret = ""; | ||
|
||
try { | ||
InputStream inputStream = context.openFileInput(filename); | ||
|
||
if (inputStream != null) { | ||
InputStreamReader inputStreamReader = new InputStreamReader(inputStream); | ||
BufferedReader bufferedReader = new BufferedReader(inputStreamReader); | ||
String receiveString = ""; | ||
StringBuilder stringBuilder = new StringBuilder(); | ||
|
||
while ((receiveString = bufferedReader.readLine()) != null) { | ||
stringBuilder.append(receiveString); | ||
} | ||
|
||
inputStream.close(); | ||
ret = stringBuilder.toString(); | ||
} | ||
} catch (FileNotFoundException e) { | ||
Log.e("login activity", "File not found: " + e.toString()); | ||
} catch (IOException e) { | ||
Log.e("login activity", "Can not read file: " + e.toString()); | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
public static InputStream readFromFileAndReturnInputStream(String filename, Context context) { | ||
|
||
String ret = ""; | ||
|
||
try { | ||
InputStream inputStream = context.openFileInput(filename); | ||
|
||
return inputStream; | ||
} catch (FileNotFoundException e) { | ||
Log.e("login activity", "File not found: " + e.toString()); | ||
} catch (IOException e) { | ||
Log.e("login activity", "Can not read file: " + e.toString()); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public static String getMimeType(String url) { | ||
String type = null; | ||
String extension = MimeTypeMap.getFileExtensionFromUrl(url); | ||
if (extension != null) { | ||
type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); | ||
} | ||
return type; | ||
} | ||
} |
Oops, something went wrong.