OmniGears: remove wakelock view since unplug
the data is no correct and just confusing
only support the reset based wakelock data
rework layout of time in state and wakelock view
Change-Id: If7fda204942b69cf0176dbdd26cd5bc321901a12
diff --git a/res/drawable/ic_menu_reset.xml b/res/drawable/ic_menu_reset.xml
new file mode 100644
index 0000000..38066b8
--- /dev/null
+++ b/res/drawable/ic_menu_reset.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="?android:attr/colorControlNormal" >
+ <path android:fillColor="@android:color/white"
+ android:pathData="M12.5,8C9.85,8 7.45,9 5.6,10.6L2,7V16H11L7.38,12.38C8.77,11.22 10.54,10.5 12.5,10.5C16.04,10.5 19.05,12.81 20.1,16L22.47,15.22C21.08,11.03 17.15,8 12.5,8Z"/>
+</vector>
diff --git a/res/layout/time_in_state.xml b/res/layout/time_in_state.xml
index ee295ce..aa5bd4a 100644
--- a/res/layout/time_in_state.xml
+++ b/res/layout/time_in_state.xml
@@ -27,9 +27,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
- android:paddingTop="10dp"
- android:paddingStart="10dp"
- android:paddingEnd="10dp" >
+ android:paddingTop="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -45,8 +43,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
- android:paddingStart="10dp"
- android:paddingEnd="10dp"
android:paddingBottom="10dp"
android:paddingTop="10dp" >
<TextView
@@ -68,41 +64,35 @@
android:layout_gravity="center_vertical"
android:text="@string/state_time_mode" />
</LinearLayout>
- <View
- android:layout_width="match_parent"
- android:layout_height="2dp"
- android:paddingStart="10dp"
- android:paddingEnd="10dp"
- android:background="#28ffffff" />
+
<ScrollView
android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_height="0dp"
android:orientation="vertical"
- android:paddingStart="10dp"
- android:paddingEnd="10dp"
- android:paddingTop="10dp" >
- <LinearLayout
+ android:paddingTop="10dp"
+ android:scrollbarStyle="insideInset"
+ android:layout_weight="1" >
+ <FrameLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
+ android:layout_height="match_parent"
+ android:paddingBottom="10dp" >
<LinearLayout
android:id="@+id/ui_states_view"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingBottom="10dp" />
+ android:layout_height="match_parent"
+ android:orientation="vertical" />
<TextView
android:id="@+id/ui_states_warning"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:padding="15dp"
+ android:layout_height="80dp"
+ android:gravity="center"
android:text="@string/no_states_file_found"
- android:textSize="20sp"
- android:visibility="gone" />
+ android:visibility="gone"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout
android:id="@+id/ui_progress"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="80dp"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone" >
@@ -110,6 +100,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
- </LinearLayout>
+ </FrameLayout>
</ScrollView>
</LinearLayout>
diff --git a/res/layout/wakelocks.xml b/res/layout/wakelocks.xml
index 53799af..38f3bde 100644
--- a/res/layout/wakelocks.xml
+++ b/res/layout/wakelocks.xml
@@ -26,8 +26,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:paddingStart="10dp" >
+ android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -40,105 +39,67 @@
android:gravity="center_vertical" />
</LinearLayout>
<LinearLayout
+ android:id="@+id/state_time_select_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:paddingStart="10dp" >
- <LinearLayout
- android:layout_width="0dp"
+ android:visibility="gone">
+ <TextView
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:gravity="center_vertical"
- android:layout_weight="0.5" >
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:text="@string/spinner_period_title"/>
- <Spinner
- android:id="@+id/period_type_select"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical" />
- </LinearLayout>
- <LinearLayout
- android:id="@+id/state_time_select_group"
- android:layout_width="0dp"
+ android:layout_gravity="center_vertical"
+ android:text="@string/spinner_state_time_title"/>
+ <Spinner
+ android:id="@+id/state_time_select"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:gravity="center_vertical|end"
- android:visibility="gone"
- android:paddingStart="10dp"
- android:layout_weight="0.5">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:text="@string/spinner_state_time_title"/>
- <Spinner
- android:id="@+id/state_time_select"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical" />
- </LinearLayout>
+ android:gravity="center_vertical" />
</LinearLayout>
<LinearLayout
android:id="@+id/ui_state_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:paddingStart="10dp"
- android:paddingEnd="10dp"
android:paddingBottom="10dp"
android:paddingTop="10dp" >
<TextView
android:id="@+id/ui_total_state_time"
- android:layout_width="0dp"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:layout_weight="1" />
+ android:layout_gravity="center_vertical" />
<TextView
android:id="@+id/ui_total_wakelock_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end" />
</LinearLayout>
- <View
- android:layout_width="match_parent"
- android:layout_height="2dp"
- android:paddingStart="10dp"
- android:paddingEnd="10dp"
- android:background="#28ffffff" />
+
<ScrollView
android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_height="0dp"
android:orientation="vertical"
- android:paddingStart="10dp"
- android:paddingEnd="10dp"
android:paddingTop="10dp"
- android:scrollbarStyle="insideInset" >
- <LinearLayout
+ android:scrollbarStyle="insideInset"
+ android:layout_weight="1" >
+ <FrameLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
+ android:layout_height="match_parent"
+ android:paddingBottom="10dp" >
<LinearLayout
android:id="@+id/ui_states_view"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingBottom="10dp" />
+ android:layout_height="match_parent"
+ android:orientation="vertical" />
<TextView
android:id="@+id/ui_kernel_wakelock_warning"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:padding="15dp"
+ android:layout_height="80dp"
+ android:gravity="center"
android:text="@string/no_kernel_wakelock_file_found"
- android:textSize="20sp"
- android:visibility="gone" />
+ android:visibility="gone"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout
android:id="@+id/ui_progress"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="80dp"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone" >
@@ -146,6 +107,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
- </LinearLayout>
+ </FrameLayout>
</ScrollView>
</LinearLayout>
diff --git a/res/menu/time_in_state_menu.xml b/res/menu/time_in_state_menu.xml
index 630b775..d7ef3b0 100644
--- a/res/menu/time_in_state_menu.xml
+++ b/res/menu/time_in_state_menu.xml
@@ -2,6 +2,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/reset"
- android:showAsAction="never"
+ android:showAsAction="ifRoom"
+ android:icon="@drawable/ic_menu_reset"
android:title="@string/create_ref" />
</menu>
diff --git a/res/menu/wakelocks_menu.xml b/res/menu/wakelocks_menu.xml
index 630b775..d7ef3b0 100644
--- a/res/menu/wakelocks_menu.xml
+++ b/res/menu/wakelocks_menu.xml
@@ -2,6 +2,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/reset"
- android:showAsAction="never"
+ android:showAsAction="ifRoom"
+ android:icon="@drawable/ic_menu_reset"
android:title="@string/create_ref" />
</menu>
diff --git a/res/values/custom_strings.xml b/res/values/custom_strings.xml
index 4b991b2..303077e 100644
--- a/res/values/custom_strings.xml
+++ b/res/values/custom_strings.xml
@@ -463,8 +463,9 @@
<string name="copy_as_text">Copy as text</string>
<string name="google_it">Google for it</string>
<string name="app_details">App details</string>
- <string name="no_stat_because_reset">Create reset</string>
- <string name="no_stat_because_plugged">Unplug power</string>
+ <string name="no_stat_because_reset_state">Press reset to start collecting time in state data</string>
+ <string name="no_stat_because_reset_wakelock">Press reset to start collecting wakelock data</string>
+ <string name="no_stat_because_plugged">Please unplug power to get wakelock data</string>
<string name="no_states_file_found">No states file found. Are you sure your phone is
compatible?\n\nIf you are running a custom ROM or kernel, try
contacting its developer to inform him that the states file is not
diff --git a/src/org/omnirom/omnigears/system/TimeInState.java b/src/org/omnirom/omnigears/system/TimeInState.java
index 4125972..8124dbd 100644
--- a/src/org/omnirom/omnigears/system/TimeInState.java
+++ b/src/org/omnirom/omnigears/system/TimeInState.java
@@ -114,13 +114,6 @@
mStatesWarning = (TextView) view.findViewById(R.id.ui_states_warning);
mTotalStateTime = (TextView) view
.findViewById(R.id.ui_total_state_time);
- mTotalStateTime.setOnClickListener(new View.OnClickListener() {
- @Override public void onClick(View v) {
- if (mPeriodType == 0 && !sHasRefData) {
- createResetPoint();
- }
- }
- });
mStateMode = (CheckBox) view.findViewById(R.id.ui_mode_switch);
mActiveStateMode = mPreferences.getBoolean(PREF_STATE_MODE, false);
@@ -249,12 +242,19 @@
if (monitor.getStates(0).size() == 0) {
mStatesWarning.setVisibility(View.VISIBLE);
- mTotalStateTime.setVisibility(View.GONE);
+ mTotalStateTime.setText(getResources().getString(R.string.total_time)
+ + " " + toString(0));
mStatesView.setVisibility(View.GONE);
} else {
if (mPeriodType == 0 && !sHasRefData) {
- mTotalStateTime.setText(getResources().getString(R.string.no_stat_because_reset));
+ mStatesWarning.setVisibility(View.VISIBLE);
+ mStatesWarning.setText(getResources().getString(R.string.no_stat_because_reset_state));
+ mTotalStateTime.setText(getResources().getString(R.string.total_time)
+ + " " + toString(0));
+ mStatesView.setVisibility(View.VISIBLE);
} else {
+ mStatesWarning.setVisibility(View.GONE);
+ mStatesView.setVisibility(View.VISIBLE);
long totTime = getStateTime(mActiveStateMode);
data.append(totTime + "\n");
totTime = totTime / 100;
@@ -404,7 +404,6 @@
@Override
protected void onPreExecute() {
mProgress.setVisibility(View.VISIBLE);
- mStatesView.setVisibility(View.GONE);
mUpdatingData = true;
}
@@ -412,7 +411,6 @@
protected void onPostExecute(Void v) {
try {
mProgress.setVisibility(View.GONE);
- mStatesView.setVisibility(View.VISIBLE);
mUpdatingData = false;
updateView();
} catch(Exception e) {
diff --git a/src/org/omnirom/omnigears/system/Wakelocks.java b/src/org/omnirom/omnigears/system/Wakelocks.java
index 49129d3..23a70c8 100644
--- a/src/org/omnirom/omnigears/system/Wakelocks.java
+++ b/src/org/omnirom/omnigears/system/Wakelocks.java
@@ -92,7 +92,6 @@
private static final int MAX_KERNEL_LIST_ITEMS = 10;
private static final int MAX_USER_LIST_ITEMS = 7;
private static final int TIME_PERIOD_RESET = 43;
- private static final int TIME_PERIOD_UNPLUG = 44;
private LinearLayout mStatesView;
private LinearLayout mTimeView;
private LinearLayout mStateTimeView;
@@ -115,11 +114,9 @@
private static ArrayList<WakelockStats> sUnplugKernelWakelocks = new ArrayList<WakelockStats>();
private static long sRefRealTimestamp = 0;
private static long sRefUpTimestamp = 0;
- private static int sWhich = TIME_PERIOD_UNPLUG;
+ private static int sWhich = TIME_PERIOD_RESET;
private static int sRefBatteryLevel = -1;
private static int sRefUnplugBatteryLevel = -1;
- private int mPeriodType = 1;
- private Spinner mPeriodTypeSelect;
private int mListType;
private Spinner mListTypeSelect;
private static boolean sKernelWakelockData = false;
@@ -293,13 +290,11 @@
super.onCreate(savedInstanceState);
mContext = getActivity();
mPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
- mPeriodType = mPreferences.getInt("which", 1);
mListType = mPreferences.getInt("listType", 0);
mStateTimeMode = mPreferences.getInt("stateTime", 0);
if (savedInstanceState != null) {
mUpdatingData = savedInstanceState.getBoolean("updatingData");
- mPeriodType = savedInstanceState.getInt("which");
mListType = savedInstanceState.getInt("listType");
mStateTimeMode = savedInstanceState.getInt("stateTime");
}
@@ -328,40 +323,10 @@
.findViewById(R.id.state_time_select_group);
mTotalStateTime = (TextView) view
.findViewById(R.id.ui_total_state_time);
- mTotalStateTime.setOnClickListener(new View.OnClickListener() {
- @Override public void onClick(View v) {
- if (mIsOnBattery && !sHasRefData) {
- createResetPoint();
- }
- }
- });
mTotalWakelockTime = (TextView) view
.findViewById(R.id.ui_total_wakelock_time);
- mPeriodTypeSelect = (Spinner) view
- .findViewById(R.id.period_type_select);
- ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
- mContext, R.array.wakelock_period_type_entries,
- R.layout.spinner_item);
- mPeriodTypeSelect.setAdapter(adapter);
- mPeriodTypeSelect
- .setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> parent,
- View view, int position, long id) {
- mPeriodType = position;
- if (position == 0) {
- sWhich = TIME_PERIOD_RESET;
- } else if (position == 1) {
- sWhich = TIME_PERIOD_UNPLUG;
- }
- refreshData();
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> arg0) {
- }
- });
+ sWhich = TIME_PERIOD_RESET;
mListTypeSelect = (Spinner) view.findViewById(R.id.list_type_select);
ArrayAdapter<CharSequence> adapter1 = ArrayAdapter.createFromResource(
@@ -402,7 +367,6 @@
}
});
- mPeriodTypeSelect.setSelection(mPeriodType);
mListTypeSelect.setSelection(mListType);
mStateTimeSelect.setSelection(mStateTimeMode);
@@ -417,7 +381,6 @@
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean("updatingData", mUpdatingData);
- outState.putInt("which", mPeriodType);
outState.putInt("listType", mListType);
outState.putInt("stateTime", mStateTimeMode);
}
@@ -433,7 +396,6 @@
if (mPopup != null) {
mPopup.dismiss();
}
- mPreferences.edit().putInt("which", mPeriodType).commit();
mPreferences.edit().putInt("listType", mListType).commit();
mPreferences.edit().putInt("stateTime", mStateTimeMode).commit();
super.onPause();
@@ -495,19 +457,16 @@
if (!sKernelWakelockData) {
mKernelWakelockWarning.setVisibility(View.VISIBLE);
- mTimeView.setVisibility(View.GONE);
mStatesView.setVisibility(View.GONE);
} else {
- mKernelWakelockWarning.setVisibility(View.GONE);
- mTimeView.setVisibility(View.VISIBLE);
mStatesView.setVisibility(View.VISIBLE);
-
long totalTimeInSecs = 0;
long totalUptimeInSecs = 0;
String batteryLevelText = null;
boolean showStats = false;
mTotalWakelockTime.setText("");
-
+ mTotalStateTime.setText(getResources().getString(
+ R.string.total_time) + " " + toString(totalTimeInSecs));
if (sWhich == TIME_PERIOD_RESET) {
if (mIsOnBattery) {
if (sHasRefData) {
@@ -530,46 +489,20 @@
batteryLevelText = "0% 0.00%/h";
}
}
+ mKernelWakelockWarning.setVisibility(View.GONE);
mTotalStateTime.setText(getResources().getString(
R.string.total_time)
+ " " + toString(totalTimeInSecs));
showStats = true;
} else {
- totalTimeInSecs = 0;
- totalUptimeInSecs = 0;
- mTotalStateTime.setText(getResources().getString(
- R.string.no_stat_because_reset));
+ mKernelWakelockWarning.setText(getResources().getString(
+ R.string.no_stat_because_reset_wakelock));
+ mKernelWakelockWarning.setVisibility(View.VISIBLE);
}
} else {
- totalTimeInSecs = 0;
- totalUptimeInSecs = 0;
- mTotalStateTime.setText(getResources().getString(
+ mKernelWakelockWarning.setText(getResources().getString(
R.string.no_stat_because_plugged));
- }
- } else if (sWhich == TIME_PERIOD_UNPLUG) {
- if (mIsOnBattery) {
- totalTimeInSecs = microToSecs(mUnplugBatteryRealtime);
- totalUptimeInSecs = microToSecs(mUnplugBatteryUptime);
- int batteryLevelDiff = mBatteryLevel - mUnplugBatteryLevel;
- if (batteryLevelDiff != 0) {
- float hours = (float) totalTimeInSecs / 3600;
- batteryLevelText = String.valueOf(batteryLevelDiff)
- + "% "
- + String.format("%.2f",
- (float) batteryLevelDiff / hours)
- + "%/h";
- } else {
- batteryLevelText = "0% 0.00%/h";
- }
- mTotalStateTime.setText(getResources().getString(
- R.string.total_time)
- + " " + toString(totalTimeInSecs));
- showStats = true;
- } else {
- totalTimeInSecs = 0;
- totalUptimeInSecs = 0;
- mTotalStateTime.setText(getResources().getString(
- R.string.no_stat_because_plugged));
+ mKernelWakelockWarning.setVisibility(View.VISIBLE);
}
}
sleepTime = Math.max(totalTimeInSecs - totalUptimeInSecs, 0);
@@ -748,7 +681,6 @@
@Override
protected void onPreExecute() {
mProgress.setVisibility(View.VISIBLE);
- mStatesView.setVisibility(View.GONE);
mUpdatingData = true;
}
@@ -756,7 +688,6 @@
protected void onPostExecute(Void v) {
try {
mProgress.setVisibility(View.GONE);
- mStatesView.setVisibility(View.VISIBLE);
mUpdatingData = false;
updateView();
} catch (Exception e) {
@@ -1451,11 +1382,6 @@
mKernelWakelocks.addAll(diffToWakelockStatus(
sRefKernelWakelocks, allKernelWakelocks));
}
- } else if (sWhich == TIME_PERIOD_UNPLUG) {
- if (mIsOnBattery) {
- mKernelWakelocks.addAll(diffToWakelockStatus(
- sUnplugKernelWakelocks, allKernelWakelocks));
- }
} else {
mKernelWakelocks.addAll(allKernelWakelocks);
}
@@ -1474,10 +1400,6 @@
mUserWakelocks.addAll(diffToWakelockStatus(
sRefUserWakelocks, allUserWakelocks));
}
- } else if (sWhich == TIME_PERIOD_UNPLUG) {
- if (mIsOnBattery) {
- mUserWakelocks.addAll(allUserWakelocks);
- }
} else {
mUserWakelocks.addAll(allUserWakelocks);
}