Skip to content

Commit

Permalink
Merge pull request #401 from Glucosio/lint-warnings-cleanup
Browse files Browse the repository at this point in the history
Lint warnings cleanup
  • Loading branch information
paolorotolo authored Feb 5, 2018
2 parents 40f589f + bd69e28 commit b161f87
Show file tree
Hide file tree
Showing 22 changed files with 127 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.glucosio.android.adapter;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -189,7 +190,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {
datetimeTextView.setText(presenter.convertDate(hb1acDateTimeArray.get(position)));
typeTextView.setText("");
typeTextView.setVisibility(View.GONE);
readingTextView.setTextColor(mContext.getResources().getColor(R.color.glucosio_text_dark));
readingTextView.setTextColor(ContextCompat.getColor(mContext, R.color.glucosio_text_dark));
break;
// Cholesterol
case 2:
Expand All @@ -198,7 +199,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {
readingTextView.setText(mContext.getString(R.string.mg_dL_value, reading));
datetimeTextView.setText(presenter.convertDate(cholesterolDateTimeArray.get(position)));
typeTextView.setText("LDL: " + cholesterolLDLArray.get(position) + " - " + "HDL: " + cholesterolHDLArray.get(position));
readingTextView.setTextColor(mContext.getResources().getColor(R.color.glucosio_text_dark));
readingTextView.setTextColor(ContextCompat.getColor(mContext, R.color.glucosio_text_dark));
break;
// Pressure
case 3:
Expand All @@ -207,7 +208,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {
datetimeTextView.setText(presenter.convertDate(pressureDateTimeArray.get(position)));
typeTextView.setText("");
typeTextView.setVisibility(View.GONE);
readingTextView.setTextColor(mContext.getResources().getColor(R.color.glucosio_text_dark));
readingTextView.setTextColor(ContextCompat.getColor(mContext, R.color.glucosio_text_dark));
break;
//Ketones
case 4:
Expand All @@ -216,7 +217,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {
datetimeTextView.setText(presenter.convertDate(ketoneDataTimeArray.get(position)));
typeTextView.setText("");
typeTextView.setVisibility(View.GONE);
readingTextView.setTextColor(mContext.getResources().getColor(R.color.glucosio_text_dark));
readingTextView.setTextColor(ContextCompat.getColor(mContext, R.color.glucosio_text_dark));
break;
// Weight
case 5:
Expand All @@ -233,7 +234,7 @@ public void onBindViewHolder(ViewHolder holder, int position) {
datetimeTextView.setText(presenter.convertDate(weightDataTime.get(position)));
typeTextView.setText("");
typeTextView.setVisibility(View.GONE);
readingTextView.setTextColor(mContext.getResources().getColor(R.color.glucosio_text_dark));
readingTextView.setTextColor(ContextCompat.getColor(mContext, R.color.glucosio_text_dark));
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import android.support.design.widget.BottomSheetDialog;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.CardView;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
Expand Down Expand Up @@ -232,7 +233,7 @@ public void onClick(View v) {
item.setAlpha(1.0f);
mAdapter.notifyDataSetChanged();
}
}).setActionTextColor(getResources().getColor(R.color.glucosio_accent)).show();
}).setActionTextColor(ContextCompat.getColor(getContext(), R.color.glucosio_accent)).show();

}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public void onNothingSelected(AdapterView<?> parent) {
final XAxis xAxis = chart.getXAxis();
xAxis.setDrawGridLines(false);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setTextColor(getResources().getColor(R.color.glucosio_text_light));
xAxis.setTextColor(ContextCompat.getColor(getContext(), R.color.glucosio_text_light));
xAxis.setAvoidFirstLastClipping(true);

double minGlucoseValue = presenter.getGlucoseMinValue();
Expand All @@ -294,13 +294,13 @@ public void onNothingSelected(AdapterView<?> parent) {
}

ll1.setLineWidth(0.8f);
ll1.setLineColor(getResources().getColor(R.color.glucosio_reading_low));
ll1.setLineColor(ContextCompat.getColor(getContext(), R.color.glucosio_reading_low));

ll2.setLineWidth(0.8f);
ll2.setLineColor(getResources().getColor(R.color.glucosio_reading_high));
ll2.setLineColor(ContextCompat.getColor(getContext(), R.color.glucosio_reading_high));

YAxis leftAxis = chart.getAxisLeft();
leftAxis.setTextColor(getResources().getColor(R.color.glucosio_text_light));
leftAxis.setTextColor(ContextCompat.getColor(getContext(), R.color.glucosio_text_light));
leftAxis.setStartAtZero(false);
leftAxis.disableGridDashedLine();
leftAxis.setDrawGridLines(false);
Expand Down Expand Up @@ -483,7 +483,7 @@ private LineData generateGlucoseData() {
}

xValues = xVals;
LineData data = new LineData(generateLineDataSet(yVals, getResources().getColor(R.color.glucosio_pink)));
LineData data = new LineData(generateLineDataSet(yVals, ContextCompat.getColor(getContext(), R.color.glucosio_pink)));
return data;
}

Expand All @@ -505,7 +505,7 @@ private LineData generateA1cData() {

xValues = xVals;
// create a data object with the datasets
return new LineData(generateLineDataSet(yVals, getResources().getColor(R.color.glucosio_fab_HB1AC)));
return new LineData(generateLineDataSet(yVals, ContextCompat.getColor(getContext(), R.color.glucosio_fab_HB1AC)));
}

private LineData generateKetonesData() {
Expand All @@ -526,7 +526,7 @@ private LineData generateKetonesData() {

xValues = xVals;
// create a data object with the datasets
return new LineData(generateLineDataSet(yVals, getResources().getColor(R.color.glucosio_fab_ketones)));
return new LineData(generateLineDataSet(yVals, ContextCompat.getColor(getContext(), R.color.glucosio_fab_ketones)));
}

private LineData generateWeightData() {
Expand All @@ -547,7 +547,7 @@ private LineData generateWeightData() {

xValues = xVals;
// create a data object with the datasets
return new LineData(generateLineDataSet(yVals, getResources().getColor(R.color.glucosio_fab_weight)));
return new LineData(generateLineDataSet(yVals, ContextCompat.getColor(getContext(), R.color.glucosio_fab_weight)));
}

private LineData generatePressureData() {
Expand Down Expand Up @@ -575,8 +575,8 @@ private LineData generatePressureData() {
}

xValues = xVals;
LineData data = new LineData(generateLineDataSet(yValsMax, getResources().getColor(R.color.glucosio_fab_pressure)));
data.addDataSet(generateLineDataSet(yValsMin, getResources().getColor(R.color.glucosio_fab_pressure)));
LineData data = new LineData(generateLineDataSet(yValsMax, ContextCompat.getColor(getContext(), R.color.glucosio_fab_pressure)));
data.addDataSet(generateLineDataSet(yValsMin, ContextCompat.getColor(getContext(), R.color.glucosio_fab_pressure)));
// create a data object with the datasets
return data;
}
Expand All @@ -599,15 +599,15 @@ private LineData generateCholesterolData() {

xValues = xVals;
// create a data object with the datasets
return new LineData(generateLineDataSet(yVals, getResources().getColor(R.color.glucosio_fab_cholesterol)));
return new LineData(generateLineDataSet(yVals, ContextCompat.getColor(getContext(), R.color.glucosio_fab_cholesterol)));
}

private LineDataSet generateLineDataSet(List<Entry> vals, int color) {
// create a dataset and give it a type
LineDataSet set1 = new LineDataSet(vals, "");
List<Integer> colors = new ArrayList<>();

if (color == getResources().getColor(R.color.glucosio_pink)) {
if (color == ContextCompat.getColor(getContext(), R.color.glucosio_pink)) {
for (Entry val : vals) {
if (val.getY() == (0)) {
colors.add(Color.TRANSPARENT);
Expand All @@ -630,7 +630,7 @@ private LineDataSet generateLineDataSet(List<Entry> vals, int color) {
set1.setValueTextSize(0);
set1.setValueTextColor(Color.parseColor("#FFFFFF"));
set1.setFillDrawable(getResources().getDrawable(R.drawable.graph_gradient));
set1.setHighLightColor(getResources().getColor(R.color.glucosio_gray_light));
set1.setHighLightColor(ContextCompat.getColor(getContext(), R.color.glucosio_gray_light));
set1.setCubicIntensity(0.2f);

if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.app.PendingIntent;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import com.google.android.gms.wearable.MessageEvent;
import com.google.android.gms.wearable.WearableListenerService;
Expand Down Expand Up @@ -79,7 +80,7 @@ private void showNotification(String reading, String readingType) {
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_stat_glucosio)
.setContentTitle(getResources().getString(R.string.wear_new_reading))
.setColor(getResources().getColor(R.color.glucosio_pink))
.setColor(ContextCompat.getColor(getApplicationContext(), R.color.glucosio_pink))
.setContentIntent(contentIntent)
.setAutoCancel(true)
.setContentText(reading + ", " + readingType);
Expand Down
19 changes: 13 additions & 6 deletions app/src/main/java/org/glucosio/android/tools/GlucoseRanges.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.glucosio.android.tools;

import android.content.Context;
import android.support.annotation.ColorRes;
import android.support.annotation.VisibleForTesting;
import android.support.v4.content.ContextCompat;
import org.glucosio.android.R;
Expand Down Expand Up @@ -106,18 +107,24 @@ public String colorFromReading(double reading) {
}

public int stringToColor(String color) {
@ColorRes int colorInt;
switch (color) {
case "green":
return ContextCompat.getColor(mContext, R.color.glucosio_reading_ok);
colorInt = R.color.glucosio_reading_ok;
break;
case "red":
return ContextCompat.getColor(mContext, R.color.glucosio_reading_hyper);
colorInt = R.color.glucosio_reading_hyper;
break;
case "blue":
return ContextCompat.getColor(mContext, R.color.glucosio_reading_low);
colorInt = R.color.glucosio_reading_low;
break;
case "orange":
return ContextCompat.getColor(mContext, R.color.glucosio_reading_high);
colorInt = R.color.glucosio_reading_high;
break;
default:
return ContextCompat.getColor(mContext, R.color.glucosio_reading_hypo);
colorInt = R.color.glucosio_reading_hypo;
}
}

return ContextCompat.getColor(mContext, colorInt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.ArrayRes;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.support.annotation.LayoutRes;
import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -91,7 +93,7 @@ private void initializeViews(Context context, AttributeSet attrs) {
0);
String labelText = typedArray.getString(R.styleable.LabelledSpinner_labelText);
mWidgetColor = typedArray.getColor(R.styleable.LabelledSpinner_widgetColor,
getResources().getColor(R.color.widget_labelled_spinner));
ContextCompat.getColor(getContext(), R.color.widget_labelled_spinner));
typedArray.recycle();

LayoutInflater inflater =
Expand Down Expand Up @@ -174,8 +176,9 @@ public int getColor() {
* color that is to be displayed on the widget.
*/
public void setColor(@ColorRes int colorRes) {
mLabel.setTextColor(getResources().getColor(colorRes));
mDivider.setBackgroundColor(getResources().getColor(colorRes));
@ColorInt int color = ContextCompat.getColor(getContext(), colorRes);
mLabel.setTextColor(color);
mDivider.setBackgroundColor(color);
}

/**
Expand Down Expand Up @@ -400,4 +403,4 @@ public interface OnItemChosenListener {
*/
void onNothingChosen(View labelledSpinner, AdapterView<?> adapterView);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
package org.glucosio.android.tools;

import android.content.Context;
import android.support.v7.widget.AppCompatEditText;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.widget.EditText;


public class NotDismissableEditText extends EditText {
public class NotDismissableEditText extends AppCompatEditText {

public NotDismissableEditText(Context context, AttributeSet attrs) {
super(context, attrs);
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/res/layout/activity_a1_calculator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
android:text="@string/activity_converter_a1c_glucose"
android:textColor="@color/glucosio_text_dark"
android:textSize="12sp"
android:textStyle="bold" />
android:textStyle="bold"
tools:ignore="MissingPrefix" />

<LinearLayout
android:layout_width="match_parent"
Expand All @@ -82,7 +83,8 @@
android:paddingTop="8dp"
android:singleLine="true"
android:textColor="@color/glucosio_text_dark"
android:textSize="52sp" />
android:textSize="52sp"
tools:ignore="MissingPrefix" />

<TextView
android:id="@+id/activity_converter_a1c_glucose_unit"
Expand Down Expand Up @@ -135,7 +137,8 @@
android:paddingTop="8dp"
android:text="00"
android:textColor="@color/glucosio_text_dark"
android:textSize="52sp" />
android:textSize="52sp"
tools:ignore="MissingPrefix" />

<TextView
android:id="@+id/activity_converter_a1c_a1c_unit"
Expand Down
Loading

0 comments on commit b161f87

Please sign in to comment.