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:
parent
142b5c06eb
commit
b284725b28
4 changed files with 24 additions and 1 deletions
|
@ -212,6 +212,10 @@ public abstract class ZLApplication {
|
|||
}
|
||||
}
|
||||
|
||||
public int getBatteryLevel() {
|
||||
return (myWindow != null) ? myWindow.getBatteryLevel() : 0;
|
||||
}
|
||||
|
||||
//Menu
|
||||
static class Menu {
|
||||
public interface Item {
|
||||
|
|
|
@ -46,4 +46,6 @@ abstract public class ZLApplicationWindow {
|
|||
abstract protected boolean canRotate();
|
||||
|
||||
abstract protected void close();
|
||||
|
||||
abstract protected int getBatteryLevel();
|
||||
}
|
||||
|
|
|
@ -128,4 +128,12 @@ public final class ZLAndroidApplicationWindow extends ZLApplicationWindow {
|
|||
public void close() {
|
||||
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).finish();
|
||||
}
|
||||
|
||||
private int myBatteryLevel;
|
||||
protected int getBatteryLevel() {
|
||||
return myBatteryLevel;
|
||||
}
|
||||
public void setBatteryLevel(int percent) {
|
||||
myBatteryLevel = percent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.io.File;
|
|||
import android.net.Uri;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.content.Intent;
|
||||
import android.content.*;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.view.*;
|
||||
|
@ -100,6 +100,8 @@ public abstract class ZLAndroidActivity extends Activity {
|
|||
ZLApplication.Instance().openFile(ZLFile.createFileByPath(fileToOpen));
|
||||
}
|
||||
ZLApplication.Instance().repaintView();
|
||||
|
||||
registerReceiver(myBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -255,4 +257,11 @@ public abstract class ZLAndroidActivity extends Activity {
|
|||
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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue