├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── github │ │ └── programmerr47 │ │ └── navigationwidgets │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── programmerr47 │ │ │ └── navigationwidgets │ │ │ ├── AppActivity.java │ │ │ ├── AppApplication.java │ │ │ ├── AppFragment.java │ │ │ ├── GenerateUtil.java │ │ │ └── constants │ │ │ ├── NavigationIconType.java │ │ │ └── NavigationItemType.java │ └── res │ │ ├── drawable │ │ ├── account.xml │ │ ├── arrow_down.xml │ │ ├── arrow_left.xml │ │ ├── arrow_up.xml │ │ ├── close.xml │ │ ├── magnify.xml │ │ ├── message_text.xml │ │ └── subdirectory_arrow_left.xml │ │ ├── layout │ │ ├── activity_app.xml │ │ └── fragment_app.xml │ │ ├── menu │ │ ├── test_menu_1.xml │ │ ├── test_menu_2.xml │ │ └── test_menu_3.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── github │ └── programmerr47 │ └── navigationwidgets │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── navigation ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── github │ │ └── programmerr47 │ │ └── navigation │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── programmerr47 │ │ │ └── navigation │ │ │ ├── AndroidUtils.java │ │ │ ├── AutoLayoutNavigationBuilder.java │ │ │ ├── CustomLayoutNavigationBuilder.java │ │ │ ├── NavigationBuilder.java │ │ │ ├── NavigationDefaults.java │ │ │ ├── NavigationFragment.java │ │ │ ├── NavigationIcons.java │ │ │ ├── NavigationItems.java │ │ │ ├── layoutfactory │ │ │ ├── DummyLayoutFactory.java │ │ │ ├── IdLayoutFactory.java │ │ │ ├── LayoutFactory.java │ │ │ └── NavigationLayoutFactory.java │ │ │ └── menu │ │ │ ├── MenuAction.java │ │ │ ├── MenuActions.java │ │ │ └── SimpleMenuAction.java │ └── res │ │ ├── layout │ │ └── toolbar.xml │ │ └── values │ │ ├── ids.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── github │ └── programmerr47 │ └── navigation │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | /*/build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Idea 30 | *.iml 31 | *.ipr 32 | *.iws 33 | .idea/ 34 | out/ 35 | 36 | # Mac 37 | .DS_Store 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Michael 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # navigation-widgets -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.1" 6 | defaultConfig { 7 | applicationId "com.github.programmerr47.navigationwidgets" 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | vectorDrawables.useSupportLibrary = true 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | compile fileTree(dir: 'libs', include: ['*.jar']) 25 | compile project(':navigation') 26 | 27 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 28 | exclude group: 'com.android.support', module: 'support-annotations' 29 | }) 30 | testCompile 'junit:junit:4.12' 31 | 32 | compile 'com.android.support:appcompat-v7:25.0.1' 33 | } 34 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/m.spitsin/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/github/programmerr47/navigationwidgets/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.github.programmerr47.navigationwidgets; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.github.programmerr47.navigationwidgets", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/programmerr47/navigationwidgets/AppActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.programmerr47.navigationwidgets; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.support.v7.app.AppCompatActivity; 6 | 7 | public class AppActivity extends AppCompatActivity { 8 | 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | setContentView(R.layout.activity_app); 13 | 14 | Fragment appFragment = new AppFragment(); 15 | getSupportFragmentManager() 16 | .beginTransaction() 17 | .replace(R.id.fragmentContainer, appFragment, "AppFragment") 18 | .commit(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/programmerr47/navigationwidgets/AppApplication.java: -------------------------------------------------------------------------------- 1 | package com.github.programmerr47.navigationwidgets; 2 | 3 | import android.app.Activity; 4 | import android.app.Application; 5 | import android.content.Context; 6 | import android.view.View; 7 | 8 | import com.github.programmerr47.navigation.NavigationDefaults; 9 | 10 | import static com.github.programmerr47.navigation.NavigationDefaults.NavigationDefaultsHolder.initDefaults; 11 | import static com.github.programmerr47.navigationwidgets.constants.NavigationIconType.BACK; 12 | import static com.github.programmerr47.navigationwidgets.constants.NavigationIconType.CLOSE; 13 | import static com.github.programmerr47.navigationwidgets.constants.NavigationIconType.DOWN; 14 | import static com.github.programmerr47.navigationwidgets.constants.NavigationIconType.ENTER; 15 | import static com.github.programmerr47.navigationwidgets.constants.NavigationIconType.UP; 16 | import static com.github.programmerr47.navigationwidgets.constants.NavigationItemType.ACCOUNT; 17 | import static com.github.programmerr47.navigationwidgets.constants.NavigationItemType.MESSAGES; 18 | import static com.github.programmerr47.navigationwidgets.constants.NavigationItemType.SEARCH; 19 | 20 | public class AppApplication extends Application { 21 | private static Context appContext; 22 | 23 | @Override 24 | public void onCreate() { 25 | super.onCreate(); 26 | 27 | appContext = this; 28 | 29 | initDefaults(new NavigationDefaults() 30 | .navigationIcon(BACK, R.drawable.arrow_left) 31 | .navigationIcon(CLOSE, R.drawable.close) 32 | .navigationIcon(ENTER, R.drawable.subdirectory_arrow_left) 33 | .navigationIcon(UP, R.drawable.arrow_up) 34 | .navigationIcon(DOWN, R.drawable.arrow_down) 35 | .navigationItem(SEARCH, R.string.nav_item_search, R.drawable.magnify, R.color.colorPrimary) 36 | .navigationItem(ACCOUNT, R.string.nav_item_account, R.drawable.account, R.color.colorAccent) 37 | .navigationItem(MESSAGES, R.string.nav_item_messages, R.drawable.message_text, R.color.colorPrimaryDark) 38 | .defaultNavigationIconType(ENTER) 39 | .defaultBottomNavigationItem(ACCOUNT) 40 | .navigationIconListener(new View.OnClickListener() { 41 | @Override 42 | public void onClick(View view) { 43 | Context context = view.getContext(); 44 | if (context instanceof Activity) { 45 | ((Activity) context).onBackPressed(); 46 | } 47 | } 48 | })); 49 | } 50 | 51 | public static Context appContext() { 52 | return appContext; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/programmerr47/navigationwidgets/AppFragment.java: -------------------------------------------------------------------------------- 1 | package com.github.programmerr47.navigationwidgets; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.view.View; 6 | import android.widget.Toast; 7 | 8 | import com.github.programmerr47.navigation.AutoLayoutNavigationBuilder; 9 | import com.github.programmerr47.navigation.NavigationBuilder; 10 | import com.github.programmerr47.navigation.NavigationFragment; 11 | import com.github.programmerr47.navigation.menu.MenuAction; 12 | import com.github.programmerr47.navigation.menu.MenuActions; 13 | 14 | import java.util.Random; 15 | 16 | import static android.widget.Toast.LENGTH_SHORT; 17 | import static com.github.programmerr47.navigation.AutoLayoutNavigationBuilder.navigation; 18 | import static com.github.programmerr47.navigation.NavigationBuilder.NO_NAV_ICON; 19 | import static com.github.programmerr47.navigationwidgets.AppApplication.appContext; 20 | import static com.github.programmerr47.navigationwidgets.GenerateUtil.generateFrom; 21 | import static com.github.programmerr47.navigationwidgets.constants.NavigationIconType.BACK; 22 | import static com.github.programmerr47.navigationwidgets.constants.NavigationIconType.CLOSE; 23 | import static com.github.programmerr47.navigationwidgets.constants.NavigationIconType.DOWN; 24 | import static com.github.programmerr47.navigationwidgets.constants.NavigationIconType.ENTER; 25 | import static com.github.programmerr47.navigationwidgets.constants.NavigationIconType.UP; 26 | import static com.github.programmerr47.navigationwidgets.constants.NavigationItemType.ACCOUNT; 27 | import static com.github.programmerr47.navigationwidgets.constants.NavigationItemType.MESSAGES; 28 | import static com.github.programmerr47.navigationwidgets.constants.NavigationItemType.SEARCH; 29 | 30 | public final class AppFragment extends NavigationFragment { 31 | private static final Random rand = new Random(); 32 | private static final MenuActions globalMenuActions = buildGlobalActions(); 33 | 34 | @Override 35 | protected NavigationBuilder buildNavigation() { 36 | return navigation(R.layout.fragment_app) 37 | .includeToolbar() 38 | .includeBottomNavigation() 39 | .toolbarTitle("It's a test!") 40 | .toolbarSubtitle("Super subtitle test!"); 41 | } 42 | 43 | @Override 44 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 45 | super.onViewCreated(view, savedInstanceState); 46 | view.findViewById(R.id.generateButton).setOnClickListener(new View.OnClickListener() { 47 | @Override 48 | public void onClick(View view) { 49 | invalidateNavigation(generateNavigation()); 50 | } 51 | }); 52 | } 53 | 54 | private NavigationBuilder generateNavigation() { 55 | return navigation(R.layout.fragment_app) 56 | .toolbarTitle(generateFrom("", "Test title", "Random Test Title", "Big random awesome heh test title wow!", "RTT", "Hello!")) 57 | .toolbarSubtitle(generateFrom("", "Test subtitle", "Super Big test subtitle for this test")) 58 | .toolbarNavigationIcon(generateFrom(BACK, UP, DOWN, ENTER, CLOSE, NO_NAV_ICON)) 59 | .currentBottomBarItem(generateFrom(ACCOUNT, MESSAGES, SEARCH)) 60 | .menuRes( 61 | generateFrom(R.menu.test_menu_1, R.menu.test_menu_2, R.menu.test_menu_3), 62 | globalMenuActions); 63 | } 64 | 65 | private static MenuActions buildGlobalActions() { 66 | return new MenuActions.Builder() 67 | .action(R.id.search, new ToastAction("Search menu item!")) 68 | .action(R.id.messages, new ToastAction("Messages menu item!")) 69 | .action(R.id.back, new ToastAction("bACk menu item!")) 70 | .action(R.id.up, new ToastAction("UUUUUp menu item!")) 71 | .action(R.id.down, new ToastAction("DoWn menu item!")) 72 | .build(); 73 | } 74 | 75 | private static final class ToastAction implements MenuAction { 76 | private final String text; 77 | 78 | private ToastAction(String text) {this.text = text;} 79 | 80 | @Override 81 | public void execute() { 82 | Toast.makeText(appContext(), text, LENGTH_SHORT).show(); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/programmerr47/navigationwidgets/GenerateUtil.java: -------------------------------------------------------------------------------- 1 | package com.github.programmerr47.navigationwidgets; 2 | 3 | import java.util.Random; 4 | 5 | public class GenerateUtil { 6 | private GenerateUtil() {} 7 | 8 | private static final Random rand = new Random(); 9 | 10 | public static T generateFrom(T... variants) { 11 | int index = rand.nextInt(variants.length); 12 | return variants[index]; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/programmerr47/navigationwidgets/constants/NavigationIconType.java: -------------------------------------------------------------------------------- 1 | package com.github.programmerr47.navigationwidgets.constants; 2 | 3 | public class NavigationIconType { 4 | private NavigationIconType() {} 5 | 6 | public static final int BACK = 0; 7 | public static final int CLOSE = 1; 8 | public static final int ENTER = 2; 9 | public static final int UP = 3; 10 | public static final int DOWN = 4; 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/programmerr47/navigationwidgets/constants/NavigationItemType.java: -------------------------------------------------------------------------------- 1 | package com.github.programmerr47.navigationwidgets.constants; 2 | 3 | public class NavigationItemType { 4 | private NavigationItemType() {} 5 | 6 | public static final int SEARCH = 101; 7 | public static final int ACCOUNT = 234; 8 | public static final int MESSAGES = 3; 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/account.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/arrow_down.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/arrow_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/arrow_up.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/close.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/magnify.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/message_text.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/subdirectory_arrow_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_app.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_app.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 |