Skip to content

Commit

Permalink
2.0.1 released
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashok-Varma committed Jun 26, 2017
1 parent ab57224 commit a9af55f
Show file tree
Hide file tree
Showing 19 changed files with 155 additions and 120 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ Download [the latest JAR][mavenAarDownload] or grab via Maven:
<dependency>
<groupId>com.ashokvarma.android</groupId>
<artifactId>bottom-navigation-bar</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<type>pom</type>
</dependency>
```
or Gradle:
```groovy
compile 'com.ashokvarma.android:bottom-navigation-bar:2.0.0'
compile 'com.ashokvarma.android:bottom-navigation-bar:2.0.1'
```
or Ivy:
```xml
<dependency org='com.ashokvarma.android' name='bottom-navigation-bar' rev='2.0.0'>
<dependency org='com.ashokvarma.android' name='bottom-navigation-bar' rev='2.0.1'>
<artifact name='$AID' ext='pom'></artifact>
</dependency>
```
Expand Down Expand Up @@ -73,5 +73,5 @@ limitations under the License.
[wikiLink]: https://github.com/Ashok-Varma/BottomNavigation/wiki/Usage
[googlePlayStoreLink]: https://play.google.com/store/apps/details?id=com.ashokvarma.bottomnavigation.sample
[googlePage]: https://www.google.com/design/spec/components/bottom-navigation.html
[mavenAarDownload]: https://repo1.maven.org/maven2/com/ashokvarma/android/bottom-navigation-bar/2.0.0/bottom-navigation-bar-2.0.0.aar
[mavenAarDownload]: https://repo1.maven.org/maven2/com/ashokvarma/android/bottom-navigation-bar/2.0.1/bottom-navigation-bar-2.0.1.aar
[mavenLatestJarDownload]: https://search.maven.org/remote_content?g=com.ashokvarma.android&a=bottom-navigation-bar&v=LATEST
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.ashokvarma.bottomnavigation;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;

/**
* Class description
Expand All @@ -12,7 +13,8 @@
* @version 1.0
* @since 23 Jun 2017
*/
public class BadgeTextView extends AppCompatTextView {
@SuppressLint("Instantiatable")
class BadgeTextView extends AppCompatTextView {

private ShapeBadgeItem mShapeBadgeItem;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private BottomNavigationHelper() {
* @param scrollable is bottom bar scrollable
* @return width of each tab
*/
public static int[] getMeasurementsForFixedMode(Context context, int screenWidth, int noOfTabs, boolean scrollable) {
static int[] getMeasurementsForFixedMode(Context context, int screenWidth, int noOfTabs, boolean scrollable) {

int[] result = new int[2];

Expand Down Expand Up @@ -61,7 +61,7 @@ public static int[] getMeasurementsForFixedMode(Context context, int screenWidth
* @param scrollable is bottom bar scrollable
* @return min and max width of each tab
*/
public static int[] getMeasurementsForShiftingMode(Context context, int screenWidth, int noOfTabs, boolean scrollable) {
static int[] getMeasurementsForShiftingMode(Context context, int screenWidth, int noOfTabs, boolean scrollable) {

int[] result = new int[2];

Expand Down Expand Up @@ -112,7 +112,7 @@ public static int[] getMeasurementsForShiftingMode(Context context, int screenWi
* @param bottomNavigationTab view to which data need to be set
* @param bottomNavigationBar view which holds all the tabs
*/
public static void bindTabWithData(BottomNavigationItem bottomNavigationItem, BottomNavigationTab bottomNavigationTab, BottomNavigationBar bottomNavigationBar) {
static void bindTabWithData(BottomNavigationItem bottomNavigationItem, BottomNavigationTab bottomNavigationTab, BottomNavigationBar bottomNavigationBar) {

Context context = bottomNavigationBar.getContext();

Expand Down Expand Up @@ -158,8 +158,8 @@ public static void bindTabWithData(BottomNavigationItem bottomNavigationItem, Bo
* @param newColor the new color i.e ripple color
* @param animationDuration duration for which animation runs
*/
public static void setBackgroundWithRipple(View clickedView, final View backgroundView,
final View bgOverlay, final int newColor, int animationDuration) {
static void setBackgroundWithRipple(View clickedView, final View backgroundView,
final View bgOverlay, final int newColor, int animationDuration) {
int centerX = (int) (clickedView.getX() + (clickedView.getMeasuredWidth() / 2));
int centerY = clickedView.getMeasuredHeight() / 2;
int finalRadius = backgroundView.getWidth();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public class ShapeBadgeItem extends BadgeItem<ShapeBadgeItem> {

public static final int SHAPE_OVAL = 0;
public static final int SHAPE_RECTANGLE = 1;
// public static final int SHAPE_HEART = 2;
public static final int SHAPE_HEART = 2;
public static final int SHAPE_STAR_3_VERTICES = 3;
public static final int SHAPE_STAR_4_VERTICES = 4;
public static final int SHAPE_STAR_5_VERTICES = 5;
public static final int SHAPE_STAR_6_VERTICES = 6;

@IntDef({SHAPE_OVAL, SHAPE_RECTANGLE, SHAPE_STAR_3_VERTICES, SHAPE_STAR_4_VERTICES, SHAPE_STAR_5_VERTICES, SHAPE_STAR_6_VERTICES})
@IntDef({SHAPE_OVAL, SHAPE_RECTANGLE, SHAPE_HEART, SHAPE_STAR_3_VERTICES, SHAPE_STAR_4_VERTICES, SHAPE_STAR_5_VERTICES, SHAPE_STAR_6_VERTICES})
@Retention(RetentionPolicy.SOURCE)
@interface Shape {
}
Expand Down Expand Up @@ -178,7 +178,9 @@ void draw(Canvas canvas) {
} else if (mShape == SHAPE_OVAL) {
canvas.drawOval(mCanvasRect, mCanvasPaint);
} else if (mShape == SHAPE_STAR_3_VERTICES || mShape == SHAPE_STAR_4_VERTICES || mShape == SHAPE_STAR_5_VERTICES || mShape == SHAPE_STAR_6_VERTICES) {
drawStar(canvas, mCanvasPaint, mShape);
drawStar(canvas, mShape);
} else if (mShape == SHAPE_HEART) {
drawHeart(canvas);
}
}

Expand Down Expand Up @@ -268,11 +270,12 @@ private void refreshMargin() {

/**
* @param canvas on which star needs to be drawn
* @param paint used to draw star
* @param numOfPt no of points a star should have
*/
private void drawStar(Canvas canvas, Paint paint, int numOfPt) {
private void drawStar(Canvas canvas, int numOfPt) {
double section = 2.0 * Math.PI / numOfPt;
double halfSection = section / 2.0d;
double antiClockRotation = getStarAntiClockRotationOffset(numOfPt);

float x = (float) canvas.getWidth() / 2.0f;
float y = (float) canvas.getHeight() / 2.0f;
Expand All @@ -286,27 +289,53 @@ private void drawStar(Canvas canvas, Paint paint, int numOfPt) {
innerRadius = canvas.getWidth() * 0.25f;
}


mPath.reset();

mPath.moveTo(
(float) (x + radius * Math.cos(0)),
(float) (y + radius * Math.sin(0)));
(float) (x + radius * Math.cos(0 - antiClockRotation)),
(float) (y + radius * Math.sin(0 - antiClockRotation)));
mPath.lineTo(
(float) (x + innerRadius * Math.cos(0 + section / 2.0)),
(float) (y + innerRadius * Math.sin(0 + section / 2.0)));
(float) (x + innerRadius * Math.cos(0 + halfSection - antiClockRotation)),
(float) (y + innerRadius * Math.sin(0 + halfSection - antiClockRotation)));

for (int i = 1; i < numOfPt; i++) {
mPath.lineTo(
(float) (x + radius * Math.cos(section * i)),
(float) (y + radius * Math.sin(section * i)));
(float) (x + radius * Math.cos(section * i - antiClockRotation)),
(float) (y + radius * Math.sin(section * i - antiClockRotation)));
mPath.lineTo(
(float) (x + innerRadius * Math.cos(section * i + section / 2.0)),
(float) (y + innerRadius * Math.sin(section * i + section / 2.0)));
(float) (x + innerRadius * Math.cos(section * i + halfSection - antiClockRotation)),
(float) (y + innerRadius * Math.sin(section * i + halfSection - antiClockRotation)));
}

mPath.close();

canvas.drawPath(mPath, mCanvasPaint);
}

/**
* offset to make star shape look straight
*
* @param numOfPt no of points a star should have
*/
private double getStarAntiClockRotationOffset(int numOfPt) {
if (numOfPt == 5) {
return 2.0 * Math.PI / 20.0d; // quarter of (section angle for 5 point star) = 36 degrees
} else if (numOfPt == 6) {
return 2.0 * Math.PI / 12.0d; // half the (section angle for 6 point star) = 60 degrees
}
return 0;
}

private void drawHeart(Canvas canvas) {
float curveLength = canvas.getHeight() / 3;

mPath.reset();
mPath.moveTo(canvas.getWidth() / 2, canvas.getHeight());// bottom part
mPath.lineTo(curveLength / 3, 7 * curveLength / 4);
mPath.arcTo(new RectF(0, 0, canvas.getWidth() / 2, 2 * curveLength), -225, 225);
mPath.arcTo(new RectF(canvas.getWidth() / 2, 0, canvas.getWidth(), 2 * curveLength), -180, 225);
mPath.close();

canvas.drawPath(mPath, paint);
canvas.drawPath(mPath, mCanvasPaint);
}
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ANDROID_BUILD_TOOLS_VERSION=25.0.2
ANDROID_BUILD_TARGET_SDK_VERSION=26
ANDROID_MIN_SDK_VERSION=14

APP_VERSION_NAME = 2.0.0
APP_VERSION_CODE = 11
APP_VERSION_NAME = 2.0.1
APP_VERSION_CODE = 12

ANDROID_SUPPORT_LIBRARY_VERSION = 25.3.1
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
FloatingActionButton fabHome;

Spinner modeSpinner;
Spinner shapeSpinner;
Spinner itemSpinner;
CheckBox bgStatic;
CheckBox bgRipple;
Spinner bgSpinner;
CheckBox autoHide;

Button toggleHide;
Expand All @@ -66,9 +66,9 @@ protected void onCreate(Bundle savedInstanceState) {
fabHome = (FloatingActionButton) findViewById(R.id.fab_home);

modeSpinner = (Spinner) findViewById(R.id.mode_spinner);
bgSpinner = (Spinner) findViewById(R.id.bg_spinner);
shapeSpinner = (Spinner) findViewById(R.id.shape_spinner);
itemSpinner = (Spinner) findViewById(R.id.item_spinner);
bgStatic = (CheckBox) findViewById(R.id.bg_static);
bgRipple = (CheckBox) findViewById(R.id.bg_ripple);
autoHide = (CheckBox) findViewById(R.id.auto_hide);

toggleHide = (Button) findViewById(R.id.toggle_hide);
Expand All @@ -78,22 +78,34 @@ protected void onCreate(Bundle savedInstanceState) {
scrollableText = (TextView) findViewById(R.id.scrollable_text);

modeSpinner.setOnItemSelectedListener(this);
bgSpinner.setOnItemSelectedListener(this);
shapeSpinner.setOnItemSelectedListener(this);
itemSpinner.setOnItemSelectedListener(this);
bgRipple.setOnCheckedChangeListener(this);
bgStatic.setOnCheckedChangeListener(this);
autoHide.setOnCheckedChangeListener(this);

toggleHide.setOnClickListener(this);
toggleBadge.setOnClickListener(this);
fabHome.setOnClickListener(this);

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, Arrays.asList(new String[]{"MODE_DEFAULT", "MODE_FIXED", "MODE_SHIFTING", "MODE_FIXED_NO_TITLE", "MODE_SHIFTING_NO_TITLE"}));
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, Arrays.asList(new String[]{"MODE_DEFAULT", "MODE_FIXED", "MODE_SHIFTING", "MODE_FIXED_NO_TITLE", "MODE_SHIFTING_NO_TITLE"}));
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
modeSpinner.setAdapter(adapter);
modeSpinner.setSelection(2);

ArrayAdapter<String> itemAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, Arrays.asList(new String[]{"3 items", "4 items", "5 items"}));
ArrayAdapter<String> itemAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, Arrays.asList(new String[]{"3 items", "4 items", "5 items"}));
itemAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
itemSpinner.setAdapter(itemAdapter);
itemSpinner.setSelection(2);

ArrayAdapter<String> shapeAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, Arrays.asList(new String[]{"SHAPE_OVAL", "SHAPE_RECTANGLE", "SHAPE_HEART", "SHAPE_STAR_3_VERTICES", "SHAPE_STAR_4_VERTICES", "SHAPE_STAR_5_VERTICES", "SHAPE_STAR_6_VERTICES"}));
shapeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
shapeSpinner.setAdapter(shapeAdapter);
shapeSpinner.setSelection(5);

ArrayAdapter<String> bgAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, Arrays.asList(new String[]{"BACKGROUND_STYLE_DEFAULT", "BACKGROUND_STYLE_STATIC", "BACKGROUND_STYLE_RIPPLE"}));
bgAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
bgSpinner.setAdapter(bgAdapter);
bgSpinner.setSelection(1);

bottomNavigationBar.setTabSelectedListener(this);
}
Expand Down Expand Up @@ -143,16 +155,18 @@ public void onClick(View v) {
}
}

@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
refresh();
}

@Override
public void onNothingSelected(AdapterView<?> adapterView) {

}

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch (buttonView.getId()) {
case R.id.bg_ripple:
bgStatic.setChecked(!isChecked);
break;
case R.id.bg_static:
bgRipple.setChecked(!isChecked);
break;
}
refresh();
}

Expand All @@ -171,23 +185,15 @@ private void refresh() {
.setHideOnSelect(autoHide.isChecked());

shapeBadgeItem = new ShapeBadgeItem()
.setShape(ShapeBadgeItem.SHAPE_STAR_5_VERTICES)
.setShape(shapeSpinner.getSelectedItemPosition())
.setShapeColorResource(R.color.teal)
.setGravity(Gravity.TOP | Gravity.END)
.setHideOnSelect(autoHide.isChecked());


bottomNavigationBar.setMode(modeSpinner.getSelectedItemPosition());
bottomNavigationBar.setBackgroundStyle(bgSpinner.getSelectedItemPosition());


if (bgStatic.isChecked()) {
bottomNavigationBar
.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC);
} else if (bgRipple.isChecked()) {
bottomNavigationBar
.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_RIPPLE);
}

if (itemSpinner.getSelectedItemPosition() == 0) {
bottomNavigationBar
.addItem(new BottomNavigationItem(R.drawable.ic_location_on_white_24dp, "Nearby").setActiveColorResource(R.color.orange).setBadgeItem(numberBadgeItem))
Expand Down Expand Up @@ -260,14 +266,4 @@ private void setScrollableText(int position) {
break;
}
}

@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
refresh();
}

@Override
public void onNothingSelected(AdapterView<?> adapterView) {

}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading

0 comments on commit a9af55f

Please sign in to comment.