Wear: add battery receiver home2
This commit is contained in:
parent
30d500fa75
commit
51a88cff6c
2 changed files with 25 additions and 0 deletions
|
@ -100,6 +100,9 @@
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.service.wallpaper.WallpaperService" />
|
<action android:name="android.service.wallpaper.WallpaperService" />
|
||||||
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
|
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
|
||||||
|
|
||||||
|
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
|
||||||
|
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
@ -544,6 +547,7 @@
|
||||||
<action android:name="watch_face_configuration_largehome" />
|
<action android:name="watch_face_configuration_largehome" />
|
||||||
<action android:name="watch_face_configuration_nochart" />
|
<action android:name="watch_face_configuration_nochart" />
|
||||||
<action android:name="watch_face_configuration_steampunk" />
|
<action android:name="watch_face_configuration_steampunk" />
|
||||||
|
|
||||||
<category android:name="com.google.android.wearable.watchface.category.WEARABLE_CONFIGURATION" />
|
<category android:name="com.google.android.wearable.watchface.category.WEARABLE_CONFIGURATION" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package info.nightscout.androidaps.watchfaces;
|
package info.nightscout.androidaps.watchfaces;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
@ -29,9 +31,28 @@ public class Home2 extends BaseWatchFace {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||||
layoutView = inflater.inflate(R.layout.activity_home_2, null);
|
layoutView = inflater.inflate(R.layout.activity_home_2, null);
|
||||||
|
|
||||||
|
IntentFilter intentBatteryFilter = new IntentFilter();
|
||||||
|
intentBatteryFilter.addAction(BatteryManager.ACTION_CHARGING);
|
||||||
|
intentBatteryFilter.addAction(BatteryManager.ACTION_DISCHARGING);
|
||||||
|
registerReceiver(batteryReceiver, intentBatteryFilter);
|
||||||
performViewSetup();
|
performViewSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BroadcastReceiver batteryReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
setDataFields();
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
unregisterReceiver(batteryReceiver);
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onTapCommand(int tapType, int x, int y, long eventTime) {
|
protected void onTapCommand(int tapType, int x, int y, long eventTime) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue