Skip to content

Commit

Permalink
Merge branch 'development' into feature/optional-long-press-toasts
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
roughike committed Apr 2, 2017
2 parents 5148b64 + 4585fbd commit e913c37
Show file tree
Hide file tree
Showing 30 changed files with 418 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ captures/
.idea/libraries

# Keystore files
*.jks
*.jks
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android:
components:
- tools
- platform-tools
- build-tools-25.0.1
- build-tools-25.0.2
- android-25
- extra-android-m2repository

Expand Down
4 changes: 0 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

(or: y u no add shiny new things?!)

### 2.2.1

* The toasts can now be disabled when long pressing tabs.

### 2.2.0

* Ability to change icons when the tabs are selected, using drawable selectors
Expand Down
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ android {
}
}
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:23.1.0'
resolutionStrategy.force "com.android.support:support-annotations:${rootProject.ext.supportLibraryVersion}"
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':bottom-bar')
compile 'com.android.support:appcompat-v7:' + rootProject.ext.supportLibraryVersion
compile 'com.android.support:design:' + rootProject.ext.supportLibraryVersion
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibraryVersion}"
compile "com.android.support:design:${rootProject.ext.supportLibraryVersion}"

androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'org.mockito:mockito-core:1.+'
androidTestCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile "com.google.dexmaker:dexmaker:1.2"
androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</intent-filter>
</activity>
<activity android:name=".ThreeTabsActivity" />
<activity android:name=".IconsOnlyActivity" />
<activity android:name=".FiveColorChangingTabsActivity" android:theme="@style/AppTheme.TransNav" />
<activity android:name=".ThreeTabsQRActivity" android:theme="@style/AppTheme.TransNav" />
<activity android:name=".BadgeActivity" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.example.bottombar.sample;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.Nullable;
import android.widget.TextView;
import android.widget.Toast;

import com.roughike.bottombar.BottomBar;
import com.roughike.bottombar.OnTabReselectListener;
import com.roughike.bottombar.OnTabSelectListener;

public class IconsOnlyActivity extends Activity {
private TextView messageView;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_icons_only);

messageView = (TextView) findViewById(R.id.messageView);

BottomBar bottomBar = (BottomBar) findViewById(R.id.bottomBar);
bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
@Override
public void onTabSelected(@IdRes int tabId) {
messageView.setText(TabMessage.get(tabId, false));
}
});

bottomBar.setOnTabReselectListener(new OnTabReselectListener() {
@Override
public void onTabReSelected(@IdRes int tabId) {
Toast.makeText(getApplicationContext(), TabMessage.get(tabId, true), Toast.LENGTH_LONG).show();
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);

findViewById(R.id.simple_three_tabs).setOnClickListener(this);
findViewById(R.id.icons_only).setOnClickListener(this);
findViewById(R.id.five_tabs_changing_colors).setOnClickListener(this);
findViewById(R.id.three_tabs_quick_return).setOnClickListener(this);
findViewById(R.id.five_tabs_custom_colors).setOnClickListener(this);
Expand All @@ -27,6 +28,9 @@ public void onClick(View v) {
case R.id.simple_three_tabs:
clazz = ThreeTabsActivity.class;
break;
case R.id.icons_only:
clazz = IconsOnlyActivity.class;
break;
case R.id.five_tabs_changing_colors:
clazz = FiveColorChangingTabsActivity.class;
break;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_color_changing_tabs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<com.roughike.bottombar.BottomBar
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_height="64dp"
android:layout_alignParentBottom="true"
app:bb_tabXmlResource="@xml/bottombar_tabs_color_changing"
app:bb_behavior="shifting|underNavbar" />
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/res/layout/activity_icons_only.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<TextView
android:id="@+id/messageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottomBar"
android:gravity="center"
android:text="Hi mom!" />

<com.roughike.bottombar.BottomBar
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
app:bb_tabXmlResource="@xml/bottombar_tabs_five"
app:bb_behavior="iconsOnly" />

</RelativeLayout>
6 changes: 6 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
android:layout_height="wrap_content"
android:text="Simple example with three tabs" />

<Button
android:id="@+id/icons_only"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tabs with icons only" />

<Button
android:id="@+id/five_tabs_custom_colors"
android:layout_width="wrap_content"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

import static org.junit.Assert.assertEquals;

/**
* Created by iiro on 22.8.2016.
*/
@RunWith(AndroidJUnit4.class)
public class BottomBarTabTest {
private FrameLayout tabContainer;
Expand All @@ -28,19 +25,25 @@ public void setUp() {
}

@Test
public void correctLayoutReturned_ForFixedTab() {
public void correctLayoutReturnedForFixedTab() {
tab.setType(BottomBarTab.Type.FIXED);
assertEquals(R.layout.bb_bottom_bar_item_fixed, tab.getLayoutResource());
}

@Test(expected = IllegalStateException.class)
public void setIsTitleless_WhenTrueAndIconDoesNotExist_ThrowsException() {
tab.setIsTitleless(true);
assertEquals(R.layout.bb_bottom_bar_item_titleless, tab.getLayoutResource());
}

@Test
public void correctLayoutReturned_ForShiftingTab() {
public void correctLayoutForShiftingTab() {
tab.setType(BottomBarTab.Type.SHIFTING);
assertEquals(R.layout.bb_bottom_bar_item_shifting, tab.getLayoutResource());
}

@Test
public void correctLayoutReturned_ForTabletTab() {
public void correctLayoutForTabletTab() {
tab.setType(BottomBarTab.Type.TABLET);
assertEquals(R.layout.bb_bottom_bar_item_fixed_tablet, tab.getLayoutResource());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ public void correctBadgeHidingPolicies() {
assertTrue(tabs.get(4).getBadgeHidesWhenActive());
}

@Test
public void titlelessTabsAsExpected() {
assertFalse(tabs.get(0).isTitleless());
assertFalse(tabs.get(1).isTitleless());
assertTrue(tabs.get(2).isTitleless());
assertFalse(tabs.get(3).isTitleless());
assertTrue(tabs.get(4).isTitleless());
}

private Drawable getDrawableByResource(int iconResId) {
return ContextCompat.getDrawable(context, iconResId);
}
Expand Down
4 changes: 2 additions & 2 deletions bottom-bar/src/androidTest/res/xml/dummy_tabs_five.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<tabs>
<tab inActiveColor="#00FF00" activeColor="#FF0000" id="@+id/tab_recents" title="Recents" icon="@drawable/empty_icon" barColorWhenSelected="#FF0000" badgeBackgroundColor="#FF0000" badgeHidesWhenActive="false" />
<tab inActiveColor="#0000FF" activeColor="@color/test_random_color" id="@+id/tab_favorites" title="@string/favorites" icon="@drawable/empty_icon" barColorWhenSelected="#00FF00" badgeBackgroundColor="#00FF00" />
<tab inActiveColor="#FF0000" activeColor="#0000FF" id="@+id/tab_nearby" title="Nearby" icon="@drawable/empty_icon" barColorWhenSelected="#F00000" badgeBackgroundColor="#F00000" badgeHidesWhenActive="false" />
<tab inActiveColor="#FF0000" activeColor="#0000FF" id="@+id/tab_nearby" title="Nearby" icon="@drawable/empty_icon" barColorWhenSelected="#F00000" badgeBackgroundColor="#F00000" badgeHidesWhenActive="false" iconOnly="true" />
<tab inActiveColor="#F0F000" activeColor="@color/test_random_color_two" id="@+id/tab_friends" title="@string/friends" icon="@drawable/empty_icon" barColorWhenSelected="#00F000" badgeBackgroundColor="#00F000" badgeHidesWhenActive="true" />
<tab inActiveColor="#F00F00" activeColor="#F00F00" id="@+id/tab_food" title="Food" icon="@drawable/empty_icon" barColorWhenSelected="#00F0F0" badgeBackgroundColor="#00F0F0" />
<tab inActiveColor="#F00F00" activeColor="#F00F00" id="@+id/tab_food" title="Food" icon="@drawable/empty_icon" barColorWhenSelected="#00F0F0" badgeBackgroundColor="#00F0F0" iconOnly="true" />
</tabs>
Loading

0 comments on commit e913c37

Please sign in to comment.