diff --git a/app/build.gradle b/app/build.gradle index 6a2611634..b7ddaa4cb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -30,5 +30,6 @@ dependencies { compile 'org.jsoup:jsoup:1.10.2' compile 'com.android.support:design:25.3.1' compile 'com.android.support:support-vector-drawable:25.3.1' + compile 'com.android.support:support-v4:25.3.1' testCompile 'junit:junit:4.12' } diff --git a/app/src/main/java/io/github/wulkanowy/activity/dashboard/DashboardActivity.java b/app/src/main/java/io/github/wulkanowy/activity/dashboard/DashboardActivity.java index 782eb58e0..76866f985 100644 --- a/app/src/main/java/io/github/wulkanowy/activity/dashboard/DashboardActivity.java +++ b/app/src/main/java/io/github/wulkanowy/activity/dashboard/DashboardActivity.java @@ -1,39 +1,59 @@ package io.github.wulkanowy.activity.dashboard; + import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; -import android.widget.TextView; +import android.support.v4.app.FragmentTransaction; import io.github.wulkanowy.R; +import io.github.wulkanowy.activity.dashboard.attendance.AttendanceFragment; +import io.github.wulkanowy.activity.dashboard.board.BoardFragment; +import io.github.wulkanowy.activity.dashboard.lessonplan.LessonplanFragment; +import io.github.wulkanowy.activity.dashboard.marks.MarksFragment; + public class DashboardActivity extends AppCompatActivity { - private TextView mTextMessage; + + MarksFragment marksFragment = new MarksFragment(); + AttendanceFragment attendanceFragment = new AttendanceFragment(); + BoardFragment boardFragment = new BoardFragment(); + LessonplanFragment lessonplanFragment = new LessonplanFragment(); + private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { + + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); + switch (item.getItemId()) { case R.id.navigation_marks: - mTextMessage.setText(R.string.title_marks); + transaction.replace(R.id.fragment_container, marksFragment); + transaction.commit(); return true; case R.id.navigation_attendance: - mTextMessage.setText(R.string.title_attendance); + transaction.replace(R.id.fragment_container, attendanceFragment); + transaction.commit(); return true; case R.id.navigation_dashboard: - mTextMessage.setText(R.string.title_dashboard); + transaction.replace(R.id.fragment_container, boardFragment); + transaction.commit(); return true; case R.id.navigation_lessonplan: - mTextMessage.setText(R.string.title_lessonplan); + transaction.replace(R.id.fragment_container, lessonplanFragment); + transaction.commit(); return true; - case R.id.navigation_settings: - mTextMessage.setText(R.string.title_settings); + /* + case R.id.navigation_settings: + return true; + */ } return false; } @@ -44,10 +64,28 @@ public class DashboardActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dashboard); - mTextMessage = (TextView) findViewById(R.id.message); BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); navigation.setSelectedItemId(R.id.navigation_dashboard); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); + + getSupportFragmentManager().beginTransaction() + .add(R.id.fragment_container, boardFragment).commit(); } + public void onBackPressed() { + + BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); + + if (navigation.getSelectedItemId() != R.id.navigation_dashboard) { + + navigation.setSelectedItemId(R.id.navigation_dashboard); + + } + + else if (navigation.getSelectedItemId() == R.id.navigation_dashboard){ + + moveTaskToBack(true); + + } + } } diff --git a/app/src/main/java/io/github/wulkanowy/activity/dashboard/attendance/AttendanceFragment.java b/app/src/main/java/io/github/wulkanowy/activity/dashboard/attendance/AttendanceFragment.java new file mode 100644 index 000000000..e33fd7c74 --- /dev/null +++ b/app/src/main/java/io/github/wulkanowy/activity/dashboard/attendance/AttendanceFragment.java @@ -0,0 +1,25 @@ +package io.github.wulkanowy.activity.dashboard.attendance; + + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import io.github.wulkanowy.R; + +public class AttendanceFragment extends Fragment { + + + public AttendanceFragment() { + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + return inflater.inflate(R.layout.fragment_attendance, container, false); + } + +} diff --git a/app/src/main/java/io/github/wulkanowy/activity/dashboard/board/BoardFragment.java b/app/src/main/java/io/github/wulkanowy/activity/dashboard/board/BoardFragment.java new file mode 100644 index 000000000..f53c476ba --- /dev/null +++ b/app/src/main/java/io/github/wulkanowy/activity/dashboard/board/BoardFragment.java @@ -0,0 +1,25 @@ +package io.github.wulkanowy.activity.dashboard.board; + + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import io.github.wulkanowy.R; + +public class BoardFragment extends Fragment { + + + public BoardFragment() { + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + return inflater.inflate(R.layout.fragment_board, container, false); + } + +} diff --git a/app/src/main/java/io/github/wulkanowy/activity/dashboard/lessonplan/LessonplanFragment.java b/app/src/main/java/io/github/wulkanowy/activity/dashboard/lessonplan/LessonplanFragment.java new file mode 100644 index 000000000..dbdb1bb40 --- /dev/null +++ b/app/src/main/java/io/github/wulkanowy/activity/dashboard/lessonplan/LessonplanFragment.java @@ -0,0 +1,25 @@ +package io.github.wulkanowy.activity.dashboard.lessonplan; + + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import io.github.wulkanowy.R; + +public class LessonplanFragment extends Fragment { + + + public LessonplanFragment() { + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + return inflater.inflate(R.layout.fragment_lessonplan, container, false); + } + +} diff --git a/app/src/main/java/io/github/wulkanowy/activity/dashboard/marks/MarksFragment.java b/app/src/main/java/io/github/wulkanowy/activity/dashboard/marks/MarksFragment.java new file mode 100644 index 000000000..3af34af13 --- /dev/null +++ b/app/src/main/java/io/github/wulkanowy/activity/dashboard/marks/MarksFragment.java @@ -0,0 +1,25 @@ +package io.github.wulkanowy.activity.dashboard.marks; + + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import io.github.wulkanowy.R; + +public class MarksFragment extends Fragment { + + + public MarksFragment() { + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + return inflater.inflate(R.layout.fragment_marks, container, false); + } + +} diff --git a/app/src/main/res/layout/activity_dashboard.xml b/app/src/main/res/layout/activity_dashboard.xml index 736c558c0..b326bcdcd 100644 --- a/app/src/main/res/layout/activity_dashboard.xml +++ b/app/src/main/res/layout/activity_dashboard.xml @@ -6,25 +6,15 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - tools:context="io.github.wulkanowy.activity.dashboard.DashboardActivity"> + tools:context="io.github.wulkanowy.activity.dashboard.DashboardActivity" + android:weightSum="1"> - + android:layout_weight="1" /> - - - + + + + diff --git a/app/src/main/res/layout/fragment_board.xml b/app/src/main/res/layout/fragment_board.xml new file mode 100644 index 000000000..b75e8c31d --- /dev/null +++ b/app/src/main/res/layout/fragment_board.xml @@ -0,0 +1,14 @@ + + + + + + + diff --git a/app/src/main/res/layout/fragment_dashboard.xml b/app/src/main/res/layout/fragment_dashboard.xml deleted file mode 100644 index 3c00bd70d..000000000 --- a/app/src/main/res/layout/fragment_dashboard.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - diff --git a/app/src/main/res/layout/fragment_lessonplan.xml b/app/src/main/res/layout/fragment_lessonplan.xml new file mode 100644 index 000000000..9330078ae --- /dev/null +++ b/app/src/main/res/layout/fragment_lessonplan.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/app/src/main/res/layout/fragment_marks.xml b/app/src/main/res/layout/fragment_marks.xml new file mode 100644 index 000000000..d662d69bd --- /dev/null +++ b/app/src/main/res/layout/fragment_marks.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f7a631f38..b63eae8ad 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -19,4 +19,6 @@ Attendance Lesson Plan Settings + + TO JEST FRAGMENT