1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 10:49:24 +02:00

battery level (from the branch footer) has been added

This commit is contained in:
Nikolay Pultsin 2010-10-21 00:27:21 +01:00
parent 142b5c06eb
commit b284725b28
4 changed files with 24 additions and 1 deletions

View file

@ -212,6 +212,10 @@ public abstract class ZLApplication {
} }
} }
public int getBatteryLevel() {
return (myWindow != null) ? myWindow.getBatteryLevel() : 0;
}
//Menu //Menu
static class Menu { static class Menu {
public interface Item { public interface Item {

View file

@ -46,4 +46,6 @@ abstract public class ZLApplicationWindow {
abstract protected boolean canRotate(); abstract protected boolean canRotate();
abstract protected void close(); abstract protected void close();
abstract protected int getBatteryLevel();
} }

View file

@ -128,4 +128,12 @@ public final class ZLAndroidApplicationWindow extends ZLApplicationWindow {
public void close() { public void close() {
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).finish(); ((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).finish();
} }
private int myBatteryLevel;
protected int getBatteryLevel() {
return myBatteryLevel;
}
public void setBatteryLevel(int percent) {
myBatteryLevel = percent;
}
} }

View file

@ -24,7 +24,7 @@ import java.io.File;
import android.net.Uri; import android.net.Uri;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.content.Intent; import android.content.*;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.view.*; import android.view.*;
@ -100,6 +100,8 @@ public abstract class ZLAndroidActivity extends Activity {
ZLApplication.Instance().openFile(ZLFile.createFileByPath(fileToOpen)); ZLApplication.Instance().openFile(ZLFile.createFileByPath(fileToOpen));
} }
ZLApplication.Instance().repaintView(); ZLApplication.Instance().repaintView();
registerReceiver(myBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
} }
@Override @Override
@ -255,4 +257,11 @@ public abstract class ZLAndroidActivity extends Activity {
myChangeCounter = 0; myChangeCounter = 0;
} }
} }
BroadcastReceiver myBatteryInfoReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
final int level = intent.getIntExtra("level", 100);
((ZLAndroidApplication)getApplication()).myMainWindow.setBatteryLevel(level);
}
};
} }