Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1 from kacpak/develop
Browse files Browse the repository at this point in the history
Moved database to DBFlow with EventBus and introduced looking for mul…
  • Loading branch information
kacpak authored Jul 1, 2016
2 parents 81c6c57 + 69e1a36 commit 3cb74bc
Show file tree
Hide file tree
Showing 27 changed files with 549 additions and 869 deletions.
23 changes: 18 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion 24
buildToolsVersion "23.0.3"

defaultConfig {
applicationId "net.kacpak.batterychargingmonitor"
Expand All @@ -28,13 +28,17 @@ android {
}

repositories {
maven { url "https://jitpack.io" } // To compile from GitHub when MavenCentral is outdated (circleprogress)
maven { url "https://jitpack.io" } // To compile from GitHub when MavenCentral is outdated (circleprogress, DBFlow)
}

ext {
supportLibrary_version = "23.3.0"
supportLibrary_version = "24.0.0"
circleProgress_version = "a947edf" // TODO change to new release when startingPoint is merged
butterKnife_version = "8.0.1"
butterKnife_version = "8.1.0"
dbFlow_version = "3.0.1"
eventbus_version = "3.0.0"
apacheCommonsLang = "3.4"
apacheCommonsIo = "1.3.2"
}

dependencies {
Expand All @@ -52,4 +56,13 @@ dependencies {
// Butter Knife
compile "com.jakewharton:butterknife:$butterKnife_version"
apt "com.jakewharton:butterknife-compiler:$butterKnife_version"
// DBFlow
apt "com.github.Raizlabs.DBFlow:dbflow-processor:$dbFlow_version"
compile "com.github.Raizlabs.DBFlow:dbflow-core:$dbFlow_version"
compile "com.github.Raizlabs.DBFlow:dbflow:$dbFlow_version"
// EventBus
compile "org.greenrobot:eventbus:$eventbus_version"
// Apache Commons
compile "org.apache.commons:commons-lang3:$apacheCommonsLang"
compile "org.apache.commons:commons-io:$apacheCommonsIo"
}
2 changes: 2 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

-keep class * extends com.raizlabs.android.dbflow.config.DatabaseHolder { *; }
5 changes: 0 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
android:value=".ui.MainActivity" />
</activity>

<provider
android:authorities="net.kacpak.batterychargingmonitor"
android:name=".data.database.DataProvider"
android:exported="false" />

<receiver android:name=".data.receiver.PowerConnectionReceiver">
<intent-filter>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED"/>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/net/kacpak/batterychargingmonitor/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import android.app.Application;
import android.content.Context;

import com.raizlabs.android.dbflow.config.FlowConfig;
import com.raizlabs.android.dbflow.config.FlowManager;

public class App extends Application {

private static Context mContext;
Expand All @@ -11,6 +14,9 @@ public class App extends Application {
public void onCreate() {
super.onCreate();
mContext = this;

FlowConfig flowConfig = new FlowConfig.Builder(this).build();
FlowManager.init(flowConfig);
}

public static Context getContext(){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package net.kacpak.batterychargingmonitor.data;

import android.util.Log;

import java.io.File;

public class BatteryDataPaths {

/**
* Znane ścieżki do folderu systemowego zawierającego dane o stanie baterii
*/
private static final String[] mBatteryDataPaths = new String[] {
"/sys/class/power_supply/battery/"
};

/**
*
*/
private static final String[] mCurrentNowFilenames = new String[] {
"batt_current_ua_now",
"current_now"
};

/**
*
*/
private static final String[] mCurrentAvgFilenames = new String[] {
"batt_current_ua_avg",
"current_avg"
};

public static final String CurrentNow;

public static final String CurrentAvg;

private static final String mBatteryDataPath;

static {
mBatteryDataPath = getBatteryDataPath();
CurrentNow = getCurrentNowPath();
CurrentAvg = getCurrentAvgPath();
}

/**
*
* @return
*/
private static String getBatteryDataPath() {
File dir;
for (String path : mBatteryDataPaths) {
Log.d("BatteryStatus", "PATH checked: " + path);
dir = new File(path);
if (dir.isDirectory()) {
return path;
}
}
return null;
}

/**
*
* @return
*/
private static String getCurrentNowPath() {
File dir;
for (String path : mCurrentNowFilenames) {
dir = new File(mBatteryDataPath + path);
if (dir.isFile()) {
return dir.getPath();
}
}
return "";
}

/**
*
* @return
*/
private static String getCurrentAvgPath() {
File dir;
for (String path : mCurrentAvgFilenames) {
dir = new File(mBatteryDataPath + path);
if (dir.isFile()) {
return dir.getPath();
}
}
return "";
}

private BatteryDataPaths() {
}
}
Loading

0 comments on commit 3cb74bc

Please sign in to comment.