mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-26 01:43:59 +02:00
added to widget an evaluation indicator and show for one-cell-width widget an icon
This commit is contained in:
@@ -20,6 +20,7 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
@@ -322,6 +323,11 @@ public abstract class MeasurementView extends TableLayout {
|
|||||||
return valueView.getCurrentTextColor();
|
return valueView.getCurrentTextColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getIndicatorColor() {
|
||||||
|
ColorDrawable background = (ColorDrawable)indicatorView.getBackground();
|
||||||
|
return background.getColor();
|
||||||
|
}
|
||||||
|
|
||||||
protected void showEvaluatorRow(boolean show) {
|
protected void showEvaluatorRow(boolean show) {
|
||||||
if (show) {
|
if (show) {
|
||||||
evaluatorRow.setVisibility(View.VISIBLE);
|
evaluatorRow.setVisibility(View.VISIBLE);
|
||||||
|
@@ -87,12 +87,17 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||||||
|
|
||||||
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
|
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
|
||||||
|
|
||||||
|
views.setInt(R.id.indicator_view, "setBackgroundColor", measurementView.getIndicatorColor());
|
||||||
|
|
||||||
// Show icon in >= two cell mode
|
// Show icon in >= two cell mode
|
||||||
if (minWidth >= twoCellsMinWidth) {
|
if (minWidth >= twoCellsMinWidth) {
|
||||||
views.setImageViewResource(R.id.widget_icon, measurementView.getIconResource());
|
views.setImageViewResource(R.id.widget_icon, measurementView.getIconResource());
|
||||||
views.setViewVisibility(R.id.widget_icon, View.VISIBLE);
|
views.setViewVisibility(R.id.widget_icon, View.VISIBLE);
|
||||||
|
views.setViewVisibility(R.id.widget_icon_vertical, View.GONE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
views.setImageViewResource(R.id.widget_icon_vertical, measurementView.getIconResource());
|
||||||
|
views.setViewVisibility(R.id.widget_icon_vertical, View.VISIBLE);
|
||||||
views.setViewVisibility(R.id.widget_icon, View.GONE);
|
views.setViewVisibility(R.id.widget_icon, View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -60,6 +60,12 @@
|
|||||||
android:paddingEnd="8dp"
|
android:paddingEnd="8dp"
|
||||||
android:paddingStart="4dp">
|
android:paddingStart="4dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/widget_icon_vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingBottom="8dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/widget_value"
|
android:id="@+id/widget_value"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -75,7 +81,14 @@
|
|||||||
android:gravity="right"
|
android:gravity="right"
|
||||||
android:lines="1"
|
android:lines="1"
|
||||||
android:textColor="@color/widgetTextColor" />
|
android:textColor="@color/widgetTextColor" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/indicator_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="0.2" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
Reference in New Issue
Block a user