Skip to content

Commit aae3813

Browse files
committed
fixed app crash when the battery extra info view is enabled on the phone layout in portrait mode.
1 parent 383807f commit aae3813

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

Android/src/org/droidplanner/android/fragments/SettingsFragment.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
/**
5454
* Implements the application settings screen.
5555
*/
56-
public class SettingsFragment extends PreferenceFragment implements
57-
OnSharedPreferenceChangeListener, DroidPlannerApp.ApiListener {
56+
public class SettingsFragment extends PreferenceFragment implements OnSharedPreferenceChangeListener,
57+
DroidPlannerApp.ApiListener {
5858

5959
/**
6060
* Used as tag for logging.
@@ -67,8 +67,7 @@ public class SettingsFragment extends PreferenceFragment implements
6767
* Action used to broadcast updates to the period for the spoken status
6868
* summary.
6969
*/
70-
public static final String ACTION_UPDATED_STATUS_PERIOD = PACKAGE_NAME + ""
71-
+ ".ACTION_UPDATED_STATUS_PERIOD";
70+
public static final String ACTION_UPDATED_STATUS_PERIOD = PACKAGE_NAME + ".ACTION_UPDATED_STATUS_PERIOD";
7271

7372
/**
7473
* Used to retrieve the new period for the spoken status summary.

Android/src/org/droidplanner/android/widgets/actionProviders/InfoBarItem.java

+30-2
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public static class BatteryInfo extends InfoBarItem {
292292
/**
293293
* This popup is used to show additional signal info.
294294
*/
295-
private PopupWindow mPopup;
295+
protected PopupWindow mPopup;
296296

297297

298298
private TextView currentView;
@@ -594,7 +594,7 @@ protected void initItemView(Context context, View parentView, Drone drone) {
594594

595595
mExtraInfoBarItems = new InfoBarItem[] { new HomeInfo(context, popupView, drone),
596596
new GpsInfo(context, popupView, drone),
597-
new BatteryInfo(context, popupView, drone),
597+
new ExtraBatteryInfo(context, popupView, drone, mItemView),
598598
new ExtraFlightTimeInfo(context, popupView, drone, mItemView),
599599
new ExtraSignalInfo(context, popupView, drone, mItemView) };
600600

@@ -622,6 +622,34 @@ public void updateItemView(final Context context, final Drone drone) {
622622
}
623623
}
624624

625+
private static class ExtraBatteryInfo extends BatteryInfo {
626+
627+
private final View mWindowView;
628+
629+
public ExtraBatteryInfo(Context context, View parentView, Drone drone, View windowView) {
630+
super(context, parentView, drone);
631+
mWindowView = windowView;
632+
}
633+
634+
@Override
635+
protected void initItemView(Context context, final View parentView, Drone drone){
636+
super.initItemView(context, parentView, drone);
637+
if(mItemView == null)
638+
return;
639+
640+
mItemView.setOnClickListener(new View.OnClickListener() {
641+
@Override
642+
public void onClick(View v) {
643+
if(mPopup == null)
644+
return;
645+
646+
int yLoc = mWindowView.getBottom() + mItemView.getBottom();
647+
mPopup.showAtLocation(mWindowView, Gravity.RIGHT | Gravity.TOP, 0, yLoc);
648+
}
649+
});
650+
}
651+
}
652+
625653
private static class ExtraFlightTimeInfo extends FlightTimeInfo {
626654

627655
/**

0 commit comments

Comments
 (0)