Skip to content

Commit

Permalink
Fixed some lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mkulesh committed Aug 27, 2017
1 parent eb7fb0a commit 2d771a1
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 98 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android {
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.mkulesh.mmd"
minSdkVersion 9
minSdkVersion 16
targetSdkVersion 25
versionCode 4
versionName "1.3"
Expand All @@ -26,7 +26,7 @@ android {
lintOptions {
checkReleaseBuilds false
abortOnError false
disable "RtlHardcoded", "RtlSymmetry", "RtlEnabled", "ApplySharedPref", "PrivateResource", "SetTextI18n"
disable "RtlHardcoded", "RtlSymmetry", "RtlEnabled", "ApplySharedPref", "PrivateResource", "SetTextI18n", "DefaultLocale"
}
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

<application
android:allowBackup="true"
android:allowClearUserData="true"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MmdActionBarTheme">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public void onOrientationChanged(int orientation)

// surface preparation
surface = (SurfaceView) rootView.findViewById(R.id.experiment_view);
//surface.setZOrderOnTop(true);
surface.getHolder().setFormat(PixelFormat.TRANSPARENT);
touchListener = new SurfaceTouchListener(activity, surface);
surface.setOnTouchListener(touchListener);
Expand Down
15 changes: 7 additions & 8 deletions app/src/main/java/com/mkulesh/mmd/SurfaceTouchListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import android.graphics.RectF;
import android.support.v4.view.MotionEventCompat;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.MotionEvent;
Expand Down Expand Up @@ -59,7 +58,7 @@ private class Pointer
int activeId = INVALID_ID;
}

private Pointer pointer = new Pointer();
private final Pointer pointer = new Pointer();

public SurfaceTouchListener(AppCompatActivity activity, SurfaceView surface)
{
Expand Down Expand Up @@ -97,7 +96,7 @@ private boolean onMoveEvent(MotionEvent ev)
{
final int action = MotionEventCompat.getActionMasked(ev);
final int pointerIndex = MotionEventCompat.getActionIndex(ev);
final int pointerCount = MotionEventCompat.getPointerCount(ev);
final int pointerCount = ev.getPointerCount();
if (pointerIndex != 0 || pointerCount != 1)
{
return true;
Expand All @@ -106,8 +105,8 @@ private boolean onMoveEvent(MotionEvent ev)
switch (action)
{
case MotionEvent.ACTION_DOWN:
mLastTouchX = MotionEventCompat.getX(ev, pointerIndex);
mLastTouchY = MotionEventCompat.getY(ev, pointerIndex);
mLastTouchX = ev.getX(pointerIndex);
mLastTouchY = ev.getY(pointerIndex);

if (pointer.activeId == Pointer.INVALID_ID)
{
Expand All @@ -116,15 +115,15 @@ private boolean onMoveEvent(MotionEvent ev)
return true;
}
}
pointer.activeId = MotionEventCompat.getPointerId(ev, 0);
pointer.activeId = ev.getPointerId(0);
break;

case MotionEvent.ACTION_MOVE:
if (pointer.activeId != Pointer.INVALID_ID)
{

final float x = MotionEventCompat.getX(ev, pointerIndex);
final float y = MotionEventCompat.getY(ev, pointerIndex);
final float x = ev.getX(pointerIndex);
final float y = ev.getY(pointerIndex);

// Calculate the distance moved
final float dx = x - mLastTouchX;
Expand Down
74 changes: 1 addition & 73 deletions app/src/main/java/com/mkulesh/mmd/utils/CompatUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,6 @@ public static boolean isMarshMallowOrLater()
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
}

/**
* Sets the text color, size, style, hint color, and highlight color from the specified TextAppearance resource.
*
* This method was deprecated in API level 23.
*/
@SuppressWarnings("deprecation")
public static final void setTextAppearance(Context context, TextView t, int resId)
{
if (isMarshMallowOrLater())
{
t.setTextAppearance(resId);
}
else
{
t.setTextAppearance(context, resId);
}
}

/**
* Returns a color associated with a particular resource ID.
*
Expand Down Expand Up @@ -114,64 +96,10 @@ public static Drawable getDrawable(Context context, int icon)
}
}

/**
* Procedure sets the background for given view as a drawable with given resource id
*/
@SuppressWarnings("deprecation")
public static void updateBackground(Context c, View v, int resId)
{
Drawable bg = null;

if (resId >= 0)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
{
bg = c.getResources().getDrawable(resId, c.getTheme());
}
else
{
bg = c.getResources().getDrawable(resId);
}
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
{
v.setBackground(bg);
}
else
{
v.setBackgroundDrawable(bg);
}
}

@SafeVarargs
public static <T> void executeAsyncTask(AsyncTask<T, ?, ?> asyncTask, T... params)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
}
else
{
asyncTask.execute(params);
}
}

public static boolean isExternalStorageEmulated()
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
return Environment.isExternalStorageEmulated();
}
else
{
return false;
}
}

/**
* Procedure creates new dot-separated DecimalFormat
*/
@SuppressLint("ObsoleteSdkInt")
public static DecimalFormat getDecimalFormat(String format)
{
DecimalFormat df = new DecimalFormat(format);
Expand Down
13 changes: 1 addition & 12 deletions app/src/main/java/com/mkulesh/mmd/widgets/VerticalSeekBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
public class VerticalSeekBar extends AppCompatSeekBar
{
private Drawable customThumb;
private boolean mMirrorForRtl = false;

public VerticalSeekBar(Context context)
{
Expand Down Expand Up @@ -70,12 +69,7 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr)
Drawable customThumb = customAttr.getDrawable(R.styleable.VerticalSeekBar_customThumb);
setCustomThumb(customThumb);

int[] mirrorForRtlAttr = new int[]{android.R.attr.mirrorForRtl};
TypedArray attributes = context.obtainStyledAttributes(attrs, mirrorForRtlAttr);
mMirrorForRtl = attributes.getBoolean(0, false);

customAttr.recycle();
attributes.recycle();
}

protected void onSizeChanged(int w, int h, int oldw, int oldh)
Expand Down Expand Up @@ -147,7 +141,7 @@ private void drawThumb(Canvas canvas)
top = 0;
bottom = customThumb.getIntrinsicHeight();
}
final int left = (isLayoutRtl() && mMirrorForRtl) ? available - thumbPos : thumbPos;
final int left = thumbPos;
final int right = left + thumbWidth;

Rect thumbBounds = customThumb.getBounds();
Expand All @@ -160,11 +154,6 @@ private void drawThumb(Canvas canvas)
}
}

private boolean isLayoutRtl()
{
return false;
}

private float getScale()
{
final int max = getMax();
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/consts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<item>@raw/ic_grid_square</item>
</array>
<string name="pref_fill_methods_default" translatable="false">@raw/ic_grid_diagonal</string>

<string format="integer" name="pref_grid_hor_dimension_default" translatable="false">10</string>
<string format="integer" name="pref_grid_ver_dimension_default" translatable="false">10</string>

Expand Down Expand Up @@ -77,6 +77,6 @@
<string format="float" name="pref_calc_time_step_min" translatable="false">0.1</string>
<string format="float" name="pref_calc_time_step_max" translatable="false">10.0</string>
<string name="pref_calc_time_step_value_format" translatable="false">0.00</string>
<bool name="pref_system_wallpaper_default" translatable="false">true</bool>
<bool name="pref_system_wallpaper_default" translatable="false">false</bool>

</resources>

0 comments on commit 2d771a1

Please sign in to comment.