├── .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 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/test_menu_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/test_menu_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/test_menu_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/programmerr47/navigation-widgets/2a7c5bfef0941224a99e2f40dbd46d28cf0708ef/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/programmerr47/navigation-widgets/2a7c5bfef0941224a99e2f40dbd46d28cf0708ef/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/programmerr47/navigation-widgets/2a7c5bfef0941224a99e2f40dbd46d28cf0708ef/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/programmerr47/navigation-widgets/2a7c5bfef0941224a99e2f40dbd46d28cf0708ef/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/programmerr47/navigation-widgets/2a7c5bfef0941224a99e2f40dbd46d28cf0708ef/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Navigation Widgets
3 | Generate new\nnavigation
4 | Search
5 | Account
6 | Messages
7 | Up
8 | Down
9 | Back
10 | Search
11 | Messages
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/github/programmerr47/navigationwidgets/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigationwidgets;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/programmerr47/navigation-widgets/2a7c5bfef0941224a99e2f40dbd46d28cf0708ef/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/navigation/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/navigation/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.1"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 |
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | compile fileTree(dir: 'libs', include: ['*.jar'])
26 |
27 | testCompile 'junit:junit:4.12'
28 |
29 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
30 | exclude group: 'com.android.support', module: 'support-annotations'
31 | })
32 |
33 | compile 'com.android.support:appcompat-v7:25.0.1'
34 | compile 'com.aurelhubert:ahbottomnavigation:2.0.1'
35 | }
36 |
--------------------------------------------------------------------------------
/navigation/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 |
--------------------------------------------------------------------------------
/navigation/src/androidTest/java/com/github/programmerr47/navigation/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigation;
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.navigation.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/navigation/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/navigation/src/main/java/com/github/programmerr47/navigation/AndroidUtils.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigation;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.support.annotation.ColorInt;
6 | import android.support.annotation.ColorRes;
7 | import android.support.annotation.NonNull;
8 | import android.support.v4.content.ContextCompat;
9 | import android.util.TypedValue;
10 | import android.view.View;
11 |
12 | import static android.util.TypedValue.COMPLEX_UNIT_DIP;
13 |
14 | public class AndroidUtils {
15 | private AndroidUtils() {}
16 |
17 | public static float dp(@NonNull Context context, float dp) {
18 | return applyDimen(context, dp, COMPLEX_UNIT_DIP);
19 | }
20 |
21 | private static float applyDimen(@NonNull Context context, float value, int unit) {
22 | Resources res = context.getResources();
23 | return TypedValue.applyDimension(unit, value, res.getDisplayMetrics());
24 | }
25 |
26 | @ColorInt
27 | public static int color(@NonNull Context context, @ColorRes int id) {
28 | return ContextCompat.getColor(context, id);
29 | }
30 |
31 | @SuppressWarnings("unchecked")
32 | public static T bind(View view, int id) {
33 | return (T) view.findViewById(id);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/navigation/src/main/java/com/github/programmerr47/navigation/AutoLayoutNavigationBuilder.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigation;
2 |
3 | import android.view.View;
4 |
5 | import com.github.programmerr47.navigation.NavigationDefaults.NavigationDefaultsHolder;
6 | import com.github.programmerr47.navigation.layoutfactory.DummyLayoutFactory;
7 | import com.github.programmerr47.navigation.layoutfactory.IdLayoutFactory;
8 | import com.github.programmerr47.navigation.layoutfactory.LayoutFactory;
9 | import com.github.programmerr47.navigation.layoutfactory.NavigationLayoutFactory;
10 |
11 | public final class AutoLayoutNavigationBuilder extends NavigationBuilder {
12 | private boolean includeToolbar;
13 | private boolean includeBottomBar;
14 |
15 | public static AutoLayoutNavigationBuilder navigation(int id) {
16 | return new AutoLayoutNavigationBuilder(new IdLayoutFactory(id));
17 | }
18 |
19 | public static AutoLayoutNavigationBuilder navigation(View view) {
20 | return new AutoLayoutNavigationBuilder(new DummyLayoutFactory(view));
21 | }
22 |
23 | public AutoLayoutNavigationBuilder(LayoutFactory layoutFactory) {
24 | super(layoutFactory, NavigationDefaultsHolder.navigationDefaults());
25 | }
26 |
27 | @Override
28 | protected AutoLayoutNavigationBuilder getThis() {
29 | return this;
30 | }
31 |
32 | @Override
33 | public LayoutFactory layoutFactory() {
34 | return new NavigationLayoutFactory(includeToolbar, includeBottomBar, super.layoutFactory());
35 | }
36 |
37 | public AutoLayoutNavigationBuilder includeToolbar() {
38 | this.includeToolbar = true;
39 | return this;
40 | }
41 |
42 | public AutoLayoutNavigationBuilder excludeToolbar() {
43 | this.includeToolbar = false;
44 | return this;
45 | }
46 |
47 | public AutoLayoutNavigationBuilder includeBottomNavigation() {
48 | this.includeBottomBar = true;
49 | return this;
50 | }
51 |
52 | public AutoLayoutNavigationBuilder excludeBottomNavigation() {
53 | this.includeBottomBar = false;
54 | return this;
55 | }
56 |
57 | public CustomLayoutNavigationBuilder custom() {
58 | return new CustomLayoutNavigationBuilder(super.layoutFactory());
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/navigation/src/main/java/com/github/programmerr47/navigation/CustomLayoutNavigationBuilder.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigation;
2 |
3 | import com.github.programmerr47.navigation.NavigationDefaults.NavigationDefaultsHolder;
4 | import com.github.programmerr47.navigation.layoutfactory.LayoutFactory;
5 |
6 | public final class CustomLayoutNavigationBuilder extends NavigationBuilder {
7 |
8 | public CustomLayoutNavigationBuilder(LayoutFactory layoutFactory) {
9 | super(layoutFactory, NavigationDefaultsHolder.navigationDefaults());
10 | }
11 |
12 | @Override
13 | protected CustomLayoutNavigationBuilder getThis() {
14 | return this;
15 | }
16 |
17 | public CustomLayoutNavigationBuilder toolbarId(int toolbarId) {
18 | this.toolbarId = toolbarId;
19 | return this;
20 | }
21 |
22 | public CustomLayoutNavigationBuilder bottomBarId(int bottomBarId) {
23 | this.bottomBarId = bottomBarId;
24 | return this;
25 | }
26 |
27 | public AutoLayoutNavigationBuilder auto() {
28 | return new AutoLayoutNavigationBuilder(layoutFactory());
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/navigation/src/main/java/com/github/programmerr47/navigation/NavigationBuilder.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigation;
2 |
3 | import android.graphics.drawable.Drawable;
4 |
5 | import com.github.programmerr47.navigation.layoutfactory.LayoutFactory;
6 | import com.github.programmerr47.navigation.menu.MenuActions;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | public abstract class NavigationBuilder> {
12 | public static final int NO_NAV_ICON = -1;
13 |
14 | private final LayoutFactory layoutFactory;
15 | private final NavigationDefaults navigationDefaults;
16 |
17 | int toolbarId = R.id.toolbar;
18 | int bottomBarId = R.id.bottomNavigation;
19 |
20 | int currentBottomBarItem;
21 | int toolbarNavigationIcon;
22 | int toolbarTitleRes;
23 | CharSequence toolbarTitle;
24 | int toolbarSubtitleRes;
25 | CharSequence toolbarSubtitle;
26 | int toolbarLogoRes;
27 | Drawable toolbarLogo;
28 |
29 | List menuRes = new ArrayList<>();
30 | MenuActions.Builder menuActions = new MenuActions.Builder();
31 |
32 | public NavigationBuilder(LayoutFactory layoutFactory, NavigationDefaults navigationDefaults) {
33 | this.layoutFactory = layoutFactory;
34 | this.navigationDefaults = navigationDefaults;
35 | this.toolbarNavigationIcon = navigationDefaults.defaultNavigationIconType();
36 | this.currentBottomBarItem = navigationDefaults.defaultBottomNavigationItem();
37 | }
38 |
39 | protected abstract T getThis();
40 |
41 | public LayoutFactory layoutFactory() {
42 | return layoutFactory;
43 | }
44 |
45 | public NavigationDefaults navigationDefaults() {
46 | return navigationDefaults;
47 | }
48 |
49 | public T currentBottomBarItem(int currentBottomBarItem) {
50 | if (!navigationDefaults.navigationItems().contains(currentBottomBarItem)) {
51 | throw new IllegalArgumentException("There is no navigation item for type: " + currentBottomBarItem);
52 | }
53 |
54 | this.currentBottomBarItem = currentBottomBarItem;
55 | return getThis();
56 | }
57 |
58 | public T toolbarNavigationIcon(int toolbarNavigationIcon) {
59 | if (!navigationDefaults.navigationIcons().contains(toolbarNavigationIcon) &&
60 | toolbarNavigationIcon != NO_NAV_ICON) {
61 | throw new IllegalArgumentException("There is no navigation icon for type: " + toolbarNavigationIcon);
62 | }
63 |
64 | this.toolbarNavigationIcon = toolbarNavigationIcon;
65 | return getThis();
66 | }
67 |
68 | public T toolbarTitleRes(int toolbarTitleRes) {
69 | this.toolbarTitleRes = toolbarTitleRes;
70 | return getThis();
71 | }
72 |
73 | public T toolbarTitle(CharSequence toolbarTitle) {
74 | this.toolbarTitle = toolbarTitle;
75 | return getThis();
76 | }
77 |
78 | public T toolbarSubtitleRes(int toolbarSubtitleRes) {
79 | this.toolbarSubtitleRes = toolbarSubtitleRes;
80 | return getThis();
81 | }
82 |
83 | public T toolbarSubtitle(CharSequence toolbarSubtitle) {
84 | this.toolbarSubtitle = toolbarSubtitle;
85 | return getThis();
86 | }
87 |
88 | public T toolbarLogoRes(int toolbarLogoRes) {
89 | this.toolbarLogoRes = toolbarLogoRes;
90 | return getThis();
91 | }
92 |
93 | public T toolbarLogo(Drawable toolbarLogo) {
94 | this.toolbarLogo = toolbarLogo;
95 | return getThis();
96 | }
97 |
98 | public T menuRes(int menuRes, MenuActions.MenuActionItem... items) {
99 | return menuRes(menuRes, new MenuActions.Builder(items));
100 | }
101 |
102 | public T menuRes(int menuRes, MenuActions.Builder menuBuilder) {
103 | this.menuRes.add(menuRes);
104 | this.menuActions.append(menuBuilder);
105 | return getThis();
106 | }
107 |
108 | public T menuRes(int menuRes, MenuActions menuActions) {
109 | this.menuRes.add(menuRes);
110 | this.menuActions.append(menuActions);
111 | return getThis();
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/navigation/src/main/java/com/github/programmerr47/navigation/NavigationDefaults.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigation;
2 |
3 |
4 | import android.graphics.drawable.Drawable;
5 | import android.support.annotation.DrawableRes;
6 | import android.support.annotation.NonNull;
7 | import android.view.View;
8 |
9 | import com.github.programmerr47.navigation.NavigationIcons.NavigationIcon;
10 | import com.github.programmerr47.navigation.NavigationItems.NavigationItem;
11 |
12 | import static java.util.Arrays.asList;
13 |
14 | public final class NavigationDefaults {
15 | private static final View.OnClickListener DUMMY_NAV_ICON_LISTENER = new View.OnClickListener() {
16 | @Override public void onClick(View view) {}
17 | };
18 |
19 | private NavigationItems navigationItems = new NavigationItems();
20 | private NavigationIcons navigationIcons = new NavigationIcons();
21 | private View.OnClickListener navigationIconListener = DUMMY_NAV_ICON_LISTENER;
22 | private int defaultNavigationIconType;
23 | private int defaultBottomNavigationItem;
24 |
25 | public NavigationDefaults navigationItems(NavigationItem... navigationItems) {
26 | this.navigationItems.addAll(navigationItems);
27 | return this;
28 | }
29 |
30 | public NavigationDefaults navigationItem(int type, int titleRes, int iconRes, int colorRes) {
31 | return navigationItem(NavigationItem.navigationItem(type, titleRes, iconRes, colorRes));
32 | }
33 |
34 | public NavigationDefaults navigationItem(NavigationItem navigationItem) {
35 | navigationItems.add(navigationItem);
36 | return this;
37 | }
38 |
39 | public NavigationDefaults navigationIcons(NavigationIcon... navigationIcons) {
40 | this.navigationIcons.addAll(asList(navigationIcons));
41 | return this;
42 | }
43 |
44 | public NavigationDefaults navigationIcon(int type, @DrawableRes int drawableRes) {
45 | return navigationIcon(NavigationIcon.navigationIcon(type, drawableRes));
46 | }
47 |
48 | public NavigationDefaults navigationIcon(int type, @NonNull Drawable drawable) {
49 | return navigationIcon(NavigationIcon.navigationIcon(type, drawable));
50 | }
51 |
52 | public NavigationDefaults navigationIcon(NavigationIcon navigationIcon) {
53 | this.navigationIcons.add(navigationIcon);
54 | return this;
55 | }
56 |
57 | public NavigationDefaults navigationIconListener(View.OnClickListener listener) {
58 | this.navigationIconListener = listener == null ? DUMMY_NAV_ICON_LISTENER : listener;
59 | return this;
60 | }
61 |
62 | public NavigationDefaults defaultNavigationIconType(int defaultNavigationIconType) {
63 | this.defaultNavigationIconType = defaultNavigationIconType;
64 | return this;
65 | }
66 |
67 | public NavigationDefaults defaultBottomNavigationItem(int defaultBottomNavigationItem) {
68 | this.defaultBottomNavigationItem = defaultBottomNavigationItem;
69 | return this;
70 | }
71 |
72 | public NavigationItems navigationItems() {
73 | return navigationItems;
74 | }
75 |
76 | public NavigationIcons navigationIcons() {
77 | return navigationIcons;
78 | }
79 |
80 | public View.OnClickListener navigationIconListener() {
81 | return navigationIconListener;
82 | }
83 |
84 | public int defaultNavigationIconType() {
85 | return defaultNavigationIconType;
86 | }
87 |
88 | public int defaultBottomNavigationItem() {
89 | return defaultBottomNavigationItem;
90 | }
91 |
92 | public static final class NavigationDefaultsHolder {
93 | private static NavigationDefaults defaults;
94 |
95 | public static void initDefaults(NavigationDefaults defaults) {
96 | NavigationDefaultsHolder.defaults = defaults;
97 | }
98 |
99 | public static NavigationDefaults navigationDefaults() {
100 | return defaults;
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/navigation/src/main/java/com/github/programmerr47/navigation/NavigationFragment.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigation;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v7.widget.Toolbar;
7 | import android.view.LayoutInflater;
8 | import android.view.Menu;
9 | import android.view.MenuItem;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.view.animation.Animation;
13 |
14 | import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
15 | import com.aurelhubert.ahbottomnavigation.AHBottomNavigation.OnTabSelectedListener;
16 | import com.github.programmerr47.navigation.NavigationIcons.NavigationIcon;
17 | import com.github.programmerr47.navigation.layoutfactory.DummyLayoutFactory;
18 | import com.github.programmerr47.navigation.layoutfactory.LayoutFactory;
19 | import com.github.programmerr47.navigation.menu.MenuActions;
20 |
21 | import static android.view.View.GONE;
22 | import static android.view.View.VISIBLE;
23 | import static com.aurelhubert.ahbottomnavigation.AHBottomNavigation.TitleState.ALWAYS_SHOW;
24 | import static com.github.programmerr47.navigation.AndroidUtils.bind;
25 | import static com.github.programmerr47.navigation.NavigationBuilder.NO_NAV_ICON;
26 |
27 | public abstract class NavigationFragment extends Fragment implements OnTabSelectedListener {
28 | private static final LayoutFactory DUMMY_FACTORY = new DummyLayoutFactory(null);
29 |
30 | private NavigationBuilder> navigationBuilder;
31 |
32 | protected Toolbar toolbar;
33 | protected AHBottomNavigation bottomNavigation;
34 |
35 | @Nullable
36 | @Override
37 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
38 | navigationBuilder = buildNavigation();
39 | return navigationBuilder.layoutFactory().produceLayout(inflater, container);
40 | }
41 |
42 | @Override
43 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
44 | toolbar = bind(view, navigationBuilder.toolbarId);
45 | bottomNavigation = bind(view, navigationBuilder.bottomBarId);
46 | prepareNavigation();
47 | }
48 |
49 | protected void invalidateNavigation(NavigationBuilder newNavigation) {
50 | navigationBuilder = newNavigation;
51 | prepareNavigation();
52 | }
53 |
54 | private void prepareNavigation() {
55 | if (toolbar != null) {
56 | prepareToolbar(toolbar);
57 | }
58 |
59 | if (bottomNavigation != null) {
60 | prepareBottomNavigation(bottomNavigation);
61 | }
62 | }
63 |
64 | protected void prepareToolbar(Toolbar toolbar) {
65 | if (navigationBuilder.toolbarTitleRes != 0) {
66 | toolbar.setTitle(navigationBuilder.toolbarTitleRes);
67 | } else {
68 | toolbar.setTitle(navigationBuilder.toolbarTitle);
69 | }
70 | if (navigationBuilder.toolbarSubtitleRes != 0) {
71 | toolbar.setSubtitle(navigationBuilder.toolbarSubtitleRes);
72 | } else {
73 | toolbar.setSubtitle(navigationBuilder.toolbarSubtitle);
74 | }
75 | if (navigationBuilder.toolbarLogoRes != 0) {
76 | toolbar.setLogo(navigationBuilder.toolbarLogoRes);
77 | } else {
78 | toolbar.setLogo(navigationBuilder.toolbarLogo);
79 | }
80 | if (navigationBuilder.toolbarNavigationIcon == NO_NAV_ICON) {
81 | toolbar.setNavigationIcon(null);
82 | toolbar.setNavigationOnClickListener(null);
83 | } else {
84 | NavigationIcon navIcon = navigationBuilder.navigationDefaults().navigationIcons().fromType(navigationBuilder.toolbarNavigationIcon);
85 | toolbar.setNavigationIcon(navIcon.iconDrawable(toolbar.getContext()));
86 | toolbar.setNavigationOnClickListener(navigationBuilder.navigationDefaults().navigationIconListener());
87 | }
88 |
89 |
90 | Menu menu = toolbar.getMenu();
91 | if (menu != null) {
92 | menu.clear();
93 | }
94 | if (!navigationBuilder.menuRes.isEmpty()) {
95 | final MenuActions actions = navigationBuilder.menuActions.build();
96 | for (Integer menuRes : navigationBuilder.menuRes) {
97 | toolbar.inflateMenu(menuRes);
98 | }
99 | toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
100 | @Override
101 | public boolean onMenuItemClick(MenuItem item) {
102 | return actions.onMenuItemClick(item);
103 | }
104 | });
105 | }
106 | }
107 |
108 | protected void prepareBottomNavigation(AHBottomNavigation bottomNavigation) {
109 | NavigationItems navigationItems = navigationBuilder.navigationDefaults().navigationItems();
110 | bottomNavigation.removeAllItems();
111 | bottomNavigation.addItems(navigationItems.bottomNavigationItems());
112 | bottomNavigation.setCurrentItem(navigationItems.indexFromType(navigationBuilder.currentBottomBarItem), false);
113 | bottomNavigation.setOnTabSelectedListener(this);
114 | bottomNavigation.setTitleState(ALWAYS_SHOW);
115 | bottomNavigation.setColored(true);
116 | }
117 |
118 | @Override
119 | public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
120 | Animation result = new Animation() {};
121 | result.setDuration(0);
122 | return result;
123 | }
124 |
125 | @Override
126 | public final boolean onTabSelected(int position, boolean wasSelected) {
127 | int itemType = navigationBuilder.navigationDefaults().navigationItems().get(position).type();
128 | return onTabTypeSelected(itemType, wasSelected);
129 | }
130 |
131 | public boolean onTabTypeSelected(int type, boolean wasSelected) {
132 | return true;
133 | }
134 |
135 | public void showBottomNavigation() {
136 | if (bottomNavigation != null) {
137 | bottomNavigation.setVisibility(VISIBLE);
138 | }
139 | }
140 |
141 | public void hideBottomNavigation() {
142 | if (bottomNavigation != null) {
143 | bottomNavigation.setVisibility(GONE);
144 | }
145 | }
146 |
147 | protected NavigationBuilder buildNavigation() {
148 | return new CustomLayoutNavigationBuilder(DUMMY_FACTORY);
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/navigation/src/main/java/com/github/programmerr47/navigation/NavigationIcons.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigation;
2 |
3 | import android.content.Context;
4 | import android.graphics.drawable.Drawable;
5 | import android.support.annotation.DrawableRes;
6 | import android.support.annotation.NonNull;
7 | import android.support.annotation.Nullable;
8 | import android.support.graphics.drawable.VectorDrawableCompat;
9 | import android.support.v4.graphics.drawable.DrawableCompat;
10 |
11 | import java.util.ArrayList;
12 | import java.util.Collection;
13 |
14 | import static android.support.graphics.drawable.VectorDrawableCompat.create;
15 | import static android.support.v4.graphics.drawable.DrawableCompat.setTint;
16 | import static com.github.programmerr47.navigation.AndroidUtils.color;
17 |
18 | public class NavigationIcons extends ArrayList {
19 |
20 | public NavigationIcons(int initialCapacity) {
21 | super(initialCapacity);
22 | }
23 |
24 | public NavigationIcons() {
25 | super();
26 | }
27 |
28 | public NavigationIcons(Collection extends NavigationIcon> c) {
29 | super(c);
30 | }
31 |
32 | public boolean contains(int type) {
33 | return fromType(type) != null;
34 | }
35 |
36 | @Nullable
37 | public NavigationIcon fromType(int type) {
38 | for (NavigationIcon icon : this) {
39 | if (icon.type == type) {
40 | return icon;
41 | }
42 | }
43 |
44 | return null;
45 | }
46 |
47 | public static final class NavigationIcon {
48 | private final int type;
49 | private final int drawableRes;
50 | private final Drawable drawable;
51 |
52 | public static NavigationIcon navigationIcon(int type, @DrawableRes int drawableRes) {
53 | return new NavigationIcon(type, drawableRes, null);
54 | }
55 |
56 | public static NavigationIcon navigationIcon(int type, @NonNull Drawable drawable) {
57 | return new NavigationIcon(type, 0, drawable);
58 | }
59 |
60 | private NavigationIcon(int type, @DrawableRes int drawableRes, Drawable drawable) {
61 | this.type = type;
62 | this.drawableRes = drawableRes;
63 | this.drawable = drawable;
64 | }
65 |
66 | public Drawable iconDrawable(@NonNull Context context) {
67 | if (drawable != null) {
68 | return drawable;
69 | } else {
70 | VectorDrawableCompat navIcon = create(context.getResources(), drawableRes, context.getTheme());
71 | setTint(navIcon, color(context, android.R.color.white));
72 | return navIcon;
73 | }
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/navigation/src/main/java/com/github/programmerr47/navigation/NavigationItems.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigation;
2 |
3 | import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem;
4 |
5 | import java.util.ArrayList;
6 | import java.util.Collection;
7 | import java.util.List;
8 |
9 | import static java.util.Arrays.asList;
10 |
11 | public final class NavigationItems extends ArrayList {
12 | public static NavigationItems of(NavigationItem... items) {
13 | return new NavigationItems(asList(items));
14 | }
15 |
16 | public NavigationItems(int initialCapacity) {
17 | super(initialCapacity);
18 | }
19 |
20 | public NavigationItems() {
21 | super();
22 | }
23 |
24 | public NavigationItems(Collection extends NavigationItem> c) {
25 | super(c);
26 | }
27 |
28 | public boolean contains(int type) {
29 | for (NavigationItem item : this) {
30 | if (item.type == type) {
31 | return true;
32 | }
33 | }
34 |
35 | return false;
36 | }
37 |
38 | public List bottomNavigationItems() {
39 | List result = new ArrayList<>();
40 | for (NavigationItem item : this) {
41 | result.add(item.ahItem);
42 | }
43 |
44 | return result;
45 | }
46 |
47 | public int indexFromType(int type) {
48 | for (int i = 0; i < size(); i++) {
49 | if (get(i).type == type) {
50 | return i;
51 | }
52 | }
53 |
54 | return -1;
55 | }
56 |
57 | public void addAll(NavigationItem... navigationItems) {
58 | addAll(NavigationItems.of(navigationItems));
59 | }
60 |
61 | public static final class NavigationItem {
62 | private final int type;
63 | private final AHBottomNavigationItem ahItem;
64 |
65 | public static NavigationItem navigationItem(int type, int titleRes, int iconRes, int colorRes) {
66 | return new NavigationItem(type, new AHBottomNavigationItem(titleRes, iconRes, colorRes));
67 | }
68 |
69 | public NavigationItem(int type, AHBottomNavigationItem ahItem) {
70 | this.type = type;
71 | this.ahItem = ahItem;
72 | }
73 |
74 | public int type() {
75 | return type;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/navigation/src/main/java/com/github/programmerr47/navigation/layoutfactory/DummyLayoutFactory.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigation.layoutfactory;
2 |
3 | import android.support.annotation.Nullable;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | public final class DummyLayoutFactory implements LayoutFactory {
9 | private final View view;
10 |
11 | public DummyLayoutFactory(View view) {
12 | this.view = view;
13 | }
14 |
15 | @Override
16 | public View produceLayout(LayoutInflater inflater, @Nullable ViewGroup container) {
17 | return view;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/navigation/src/main/java/com/github/programmerr47/navigation/layoutfactory/IdLayoutFactory.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigation.layoutfactory;
2 |
3 | import android.support.annotation.Nullable;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | public final class IdLayoutFactory implements LayoutFactory {
9 | private final int layoutId;
10 |
11 | public IdLayoutFactory(int layoutId) {
12 | this.layoutId = layoutId;
13 | }
14 |
15 | @Override
16 | public View produceLayout(LayoutInflater inflater, @Nullable ViewGroup container) {
17 | return inflater.inflate(layoutId, container, false);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/navigation/src/main/java/com/github/programmerr47/navigation/layoutfactory/LayoutFactory.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigation.layoutfactory;
2 |
3 | import android.support.annotation.Nullable;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | public interface LayoutFactory {
9 | View produceLayout(LayoutInflater inflater, @Nullable ViewGroup container);
10 | }
11 |
--------------------------------------------------------------------------------
/navigation/src/main/java/com/github/programmerr47/navigation/layoutfactory/NavigationLayoutFactory.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigation.layoutfactory;
2 |
3 | import android.support.annotation.Nullable;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.LinearLayout;
8 |
9 | import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
10 | import com.github.programmerr47.navigation.R;
11 |
12 | import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
13 | import static android.widget.LinearLayout.VERTICAL;
14 | import static com.github.programmerr47.navigation.AndroidUtils.dp;
15 |
16 | public final class NavigationLayoutFactory implements LayoutFactory {
17 | private final boolean includeToolbar;
18 | private final boolean includeBottomBar;
19 | private final LayoutFactory origin;
20 |
21 | public NavigationLayoutFactory(boolean includeToolbar, boolean includeBottomBar, LayoutFactory origin) {
22 | this.includeToolbar = includeToolbar;
23 | this.includeBottomBar = includeBottomBar;
24 | this.origin = origin;
25 | }
26 |
27 | @Override
28 | public View produceLayout(LayoutInflater inflater, @Nullable ViewGroup container) {
29 | LinearLayout parent = new LinearLayout(inflater.getContext());
30 | parent.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
31 | parent.setOrientation(VERTICAL);
32 |
33 | View child = origin.produceLayout(inflater, parent);
34 | LinearLayout.LayoutParams childParams = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
35 | if (includeBottomBar) {
36 | childParams.weight = 1;
37 | }
38 |
39 | if (includeToolbar) {
40 | inflater.inflate(R.layout.toolbar, parent);
41 | }
42 | parent.addView(child, childParams);
43 | if (includeBottomBar) {
44 | AHBottomNavigation bottomNavigation = new AHBottomNavigation(parent.getContext());
45 | bottomNavigation.setId(R.id.bottomNavigation);
46 | parent.addView(
47 | bottomNavigation,
48 | new LinearLayout.LayoutParams(MATCH_PARENT, (int) dp(parent.getContext(), 56)));
49 | }
50 |
51 | return parent;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/navigation/src/main/java/com/github/programmerr47/navigation/menu/MenuAction.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigation.menu;
2 |
3 | public interface MenuAction {
4 | void execute();
5 | }
6 |
--------------------------------------------------------------------------------
/navigation/src/main/java/com/github/programmerr47/navigation/menu/MenuActions.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigation.menu;
2 |
3 | import android.support.v7.widget.PopupMenu;
4 | import android.util.SparseArray;
5 | import android.view.MenuItem;
6 |
7 | public final class MenuActions implements PopupMenu.OnMenuItemClickListener {
8 | private static final MenuAction DUMMY = new SimpleMenuAction();
9 | private final SparseArray actions;
10 |
11 | private MenuActions(Builder builder) {
12 | this.actions = builder.actions;
13 | }
14 |
15 | @Override
16 | public boolean onMenuItemClick(MenuItem item) {
17 | int itemId = item.getItemId();
18 | actions.get(itemId, DUMMY).execute();
19 | return actions.indexOfKey(itemId) > 0;
20 | }
21 |
22 | public static final class Builder {
23 | private final SparseArray actions = new SparseArray<>();
24 |
25 | public Builder() {}
26 |
27 | public Builder(MenuActionItem... items) {
28 | for (MenuActionItem item : items) {
29 | action(item.id, item.action);
30 | }
31 | }
32 |
33 | public Builder action(int itemId, MenuAction action) {
34 | actions.put(itemId, action == null ? DUMMY : action);
35 | return this;
36 | }
37 |
38 | public Builder append(MenuActions menuActions) {
39 | return append(menuActions.actions);
40 | }
41 |
42 | public Builder append(MenuActions.Builder anotherActionBuilder) {
43 | return append(anotherActionBuilder.actions);
44 | }
45 |
46 | private Builder append(SparseArray actions) {
47 | for (int i = 0; i < actions.size(); i++) {
48 | this.actions.put(actions.keyAt(i), actions.valueAt(i));
49 | }
50 | return this;
51 | }
52 |
53 | public MenuActions build() {
54 | return new MenuActions(this);
55 | }
56 | }
57 |
58 | public static final class MenuActionItem {
59 | private final int id;
60 | private final MenuAction action;
61 |
62 | public static MenuActionItem item(int id, MenuAction action) {
63 | return new MenuActionItem(id, action);
64 | }
65 |
66 | public MenuActionItem(int id, MenuAction action) {
67 | this.id = id;
68 | this.action = action;
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/navigation/src/main/java/com/github/programmerr47/navigation/menu/SimpleMenuAction.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigation.menu;
2 |
3 | public final class SimpleMenuAction implements MenuAction {
4 | @Override
5 | public void execute() {}
6 | }
7 |
--------------------------------------------------------------------------------
/navigation/src/main/res/layout/toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
--------------------------------------------------------------------------------
/navigation/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/navigation/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Navigation
3 |
4 |
--------------------------------------------------------------------------------
/navigation/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/navigation/src/test/java/com/github/programmerr47/navigation/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.github.programmerr47.navigation;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':navigation'
2 |
--------------------------------------------------------------------------------