-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
166 additions
and
16 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
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
12 changes: 12 additions & 0 deletions
12
wear/src/main/java/com/eveningoutpost/dexdrip/UtilityModels/NotificationChannels.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,12 @@ | ||
|
||
// stub class just to satisfy unified source trees while wear is not on sdk 26+ | ||
|
||
package com.eveningoutpost.dexdrip.UtilityModels; | ||
|
||
public class NotificationChannels { | ||
|
||
public final static String LOW_TRANSMITTER_BATTERY_CHANNEL = "stub"; | ||
} | ||
|
||
|
||
|
63 changes: 63 additions & 0 deletions
63
wear/src/main/java/com/eveningoutpost/dexdrip/utils/FileUtils.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,63 @@ | ||
package com.eveningoutpost.dexdrip.utils; | ||
|
||
import android.content.Context; | ||
import android.os.Environment; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
import com.eveningoutpost.dexdrip.xdrip; | ||
import com.eveningoutpost.dexdrip.Models.UserError; | ||
|
||
public class FileUtils { | ||
|
||
public static boolean makeSureDirectoryExists( final String dir ) { | ||
final File file = new File( dir ); | ||
return file.exists() || file.mkdirs(); | ||
} | ||
|
||
public static String getExternalDir() { | ||
final StringBuilder sb = new StringBuilder(); | ||
sb.append( Environment.getExternalStorageDirectory().getAbsolutePath() ); | ||
sb.append( "/xdrip" ); | ||
|
||
final String dir = sb.toString(); | ||
return dir; | ||
} | ||
|
||
public static String combine( final String path1, final String path2 ) { | ||
final File file1 = new File( path1 ); | ||
final File file2 = new File( file1, path2 ); | ||
return file2.getPath(); | ||
} | ||
|
||
public static void writeToFileWithCurrentDate(String TAG, String file, byte []data) { | ||
Context context = xdrip.getAppContext(); | ||
|
||
String dir = context.getFilesDir().getPath(); | ||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss"); | ||
String currentDateandTime = sdf.format(new Date()); | ||
|
||
String fileName = dir + '/' + file+ "_" + currentDateandTime + ".dat"; | ||
writeToFile(TAG, fileName, data); | ||
} | ||
|
||
public static void writeToFile(String TAG, String fileName, byte []data) { | ||
|
||
|
||
UserError.Log.i(TAG, "Writing to file" + fileName); | ||
try { | ||
FileOutputStream f = new FileOutputStream(new File(fileName)); | ||
if(data != null) { | ||
// if no data exists, file will be written with zero length to let the user know what is happening. | ||
f.write(data); | ||
} | ||
f.close(); | ||
}catch (IOException e) { | ||
UserError.Log.e(TAG, "Cought exception when trying to write file", e); | ||
} | ||
} | ||
} |