Browse Source

Äh Navigation hinzugefügt mithilfe von Fragments, dazu animationen und nicht funktionierende einstellungen, drawer menu außerdem leicht verändert

Signed-off-by: Merthan <me2@live.de>
master
Merthan 3 years ago
committed by Merthan
parent
commit
01afc0709f
  1. 4
      .idea/assetWizardSettings.xml
  2. 2
      .idea/misc.xml
  3. 27
      app/build.gradle
  4. 4
      app/src/androidTest/java/de/anghenfil/fahrinfo/ExampleInstrumentedTest.kt
  5. 5
      app/src/main/java/de/anghenfil/fahrinfo/de/anghenfil/fahrinfo/controller/NavigationListener.kt
  6. 18
      app/src/main/java/de/anghenfil/fahrinfo/view/AboutFragment.java
  7. 17
      app/src/main/java/de/anghenfil/fahrinfo/view/DeparturesFragment.java
  8. 18
      app/src/main/java/de/anghenfil/fahrinfo/view/FavoritesFragment.java
  9. 44
      app/src/main/java/de/anghenfil/fahrinfo/view/MainActivity.kt
  10. 17
      app/src/main/java/de/anghenfil/fahrinfo/view/NavigationFragment.java
  11. 12
      app/src/main/java/de/anghenfil/fahrinfo/view/NotificationSettingsFragment.java
  12. 12
      app/src/main/java/de/anghenfil/fahrinfo/view/SettingsFragment.java
  13. 8
      app/src/main/res/anim/enter_left.xml
  14. 8
      app/src/main/res/anim/exit_right.xml
  15. 9
      app/src/main/res/drawable/vector_bookmark.xml
  16. 9
      app/src/main/res/drawable/vector_save.xml
  17. 6
      app/src/main/res/layout/activity_main.xml
  18. 12
      app/src/main/res/layout/app_bar_main.xml
  19. 23
      app/src/main/res/layout/content_main.xml
  20. 14
      app/src/main/res/layout/fragment_about.xml
  21. 13
      app/src/main/res/layout/fragment_departures.xml
  22. 13
      app/src/main/res/layout/fragment_navigation.xml
  23. 13
      app/src/main/res/layout/fragment_saved.xml
  24. 39
      app/src/main/res/menu/activity_main_drawer.xml
  25. 8
      app/src/main/res/xml/notification_settings.xml
  26. 11
      app/src/main/res/xml/settings.xml
  27. 2
      gradle.properties

4
.idea/assetWizardSettings.xml

@ -89,7 +89,7 @@
<PersistentState>
<option name="values">
<map>
<entry key="url" value="jar:file:/C:/Program%20Files/Android/Android%20Studio/plugins/android/lib/android.jar!/images/material_design_icons/action/ic_info_black_24dp.xml" />
<entry key="url" value="jar:file:/C:/Program%20Files/Android/Android%20Studio/plugins/android/lib/android.jar!/images/material_design_icons/content/ic_save_black_24dp.xml" />
</map>
</option>
</PersistentState>
@ -99,7 +99,7 @@
</option>
<option name="values">
<map>
<entry key="outputName" value="vector_info" />
<entry key="outputName" value="vector_save" />
<entry key="sourceFile" value="C:\Users\merth" />
</map>
</option>

2
.idea/misc.xml

@ -29,7 +29,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

27
app/build.gradle

@ -12,7 +12,7 @@ android {
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
@ -25,16 +25,25 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:1.10.19'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'androidx.test:runner:1.1.0-beta02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-beta02'
def room_version = "1.1.1"
implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version" // use kapt for Kotlin
implementation 'androidx.room:room-runtime:2.1.0-alpha01'
annotationProcessor 'androidx.room:room-compiler:2.1.0-alpha01' // use kapt for Kotlin
implementation 'androidx.core:core-ktx:1.0.0'
implementation 'androidx.fragment:fragment-ktx:1.0.0'
implementation 'com.android.support:preference-v7:28.0.0'
}

4
app/src/androidTest/java/de/anghenfil/fahrinfo/ExampleInstrumentedTest.kt

@ -1,7 +1,7 @@
package de.anghenfil.fahrinfo
import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
import androidx.test.InstrumentationRegistry
import androidx.test.runner.AndroidJUnit4
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

5
app/src/main/java/de/anghenfil/fahrinfo/de/anghenfil/fahrinfo/controller/NavigationListener.kt

@ -1,10 +1,9 @@
package de.anghenfil.fahrinfo.de.anghenfil.fahrinfo.controller
import android.app.Activity
import android.support.design.widget.NavigationView
import android.support.v4.view.GravityCompat
import android.view.Menu
import android.view.MenuItem
import androidx.core.view.GravityCompat
import com.google.android.material.navigation.NavigationView
import de.anghenfil.fahrinfo.R
import de.anghenfil.fahrinfo.view.toast
import kotlinx.android.synthetic.main.activity_main.*

18
app/src/main/java/de/anghenfil/fahrinfo/view/AboutFragment.java

@ -0,0 +1,18 @@
package de.anghenfil.fahrinfo.view;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import de.anghenfil.fahrinfo.R;
public class AboutFragment extends Fragment {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_about,container,false);
}
}

17
app/src/main/java/de/anghenfil/fahrinfo/view/DeparturesFragment.java

@ -0,0 +1,17 @@
package de.anghenfil.fahrinfo.view;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import de.anghenfil.fahrinfo.R;
public class DeparturesFragment extends Fragment {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_departures,container,false);
}
}

18
app/src/main/java/de/anghenfil/fahrinfo/view/FavoritesFragment.java

@ -0,0 +1,18 @@
package de.anghenfil.fahrinfo.view;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import de.anghenfil.fahrinfo.R;
public class FavoritesFragment extends Fragment {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_saved,container,false);
}
}

44
app/src/main/java/de/anghenfil/fahrinfo/view/MainActivity.kt

@ -2,14 +2,14 @@ package de.anghenfil.fahrinfo.view
import android.content.Context
import android.os.Bundle
import android.support.design.widget.NavigationView
import android.support.design.widget.Snackbar
import android.support.v4.view.GravityCompat
import android.support.v7.app.ActionBarDrawerToggle
import android.support.v7.app.AppCompatActivity
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.GravityCompat
import androidx.fragment.app.transaction
import com.google.android.material.navigation.NavigationView
import de.anghenfil.fahrinfo.R
import de.anghenfil.fahrinfo.de.anghenfil.fahrinfo.controller.NavigationListener
import kotlinx.android.synthetic.main.activity_main.*
@ -24,7 +24,7 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val navListener = NavigationListener(this)
findViewById<NavigationView>(R.id.nav_view).setNavigationItemSelectedListener(navListener)
//findViewById<NavigationView>(R.id.nav_view).setNavigationItemSelectedListener(navListener)
setSupportActionBar(toolbar)
val toggle = ActionBarDrawerToggle(
@ -34,6 +34,38 @@ class MainActivity : AppCompatActivity() {
)
drawer_layout.addDrawerListener(toggle)
toggle.syncState()
findViewById<NavigationView>(R.id.nav_view).setNavigationItemSelectedListener { menuItem ->
supportFragmentManager.transaction { //Start Fragment transaction
setCustomAnimations(R.anim.enter_left,R.anim.exit_right)
replace(R.id.main_fragment_container,
when(menuItem.itemId){ //Switch by ID, returns a Fragment class as last parameter of replace()
R.id.nav_navigation -> NavigationFragment()
R.id.nav_departures -> DeparturesFragment()
R.id.nav_settings -> SettingsFragment()
R.id.nav_notification_centre->NotificationSettingsFragment()
R.id.nav_about -> AboutFragment()
R.id.nav_favorites -> FavoritesFragment()
else->TODO("Not implemented yet?")//If ID doesnt match anything above
}
)
}
drawer_layout.closeDrawer(GravityCompat.START)
return@setNavigationItemSelectedListener true
}
}
override fun onBackPressed() {

17
app/src/main/java/de/anghenfil/fahrinfo/view/NavigationFragment.java

@ -0,0 +1,17 @@
package de.anghenfil.fahrinfo.view;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import de.anghenfil.fahrinfo.R;
public class NavigationFragment extends Fragment {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_navigation,container,false);
}
}

12
app/src/main/java/de/anghenfil/fahrinfo/view/NotificationSettingsFragment.java

@ -0,0 +1,12 @@
package de.anghenfil.fahrinfo.view;
import android.os.Bundle;
import androidx.preference.PreferenceFragmentCompat;
import de.anghenfil.fahrinfo.R;
public class NotificationSettingsFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.notification_settings);
}
}

12
app/src/main/java/de/anghenfil/fahrinfo/view/SettingsFragment.java

@ -0,0 +1,12 @@
package de.anghenfil.fahrinfo.view;
import android.os.Bundle;
import androidx.preference.PreferenceFragmentCompat;
import de.anghenfil.fahrinfo.R;
public class SettingsFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.settings);
}
}

8
app/src/main/res/anim/enter_left.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="-100%" android:toXDelta="0%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="700"/>
</set>

8
app/src/main/res/anim/exit_right.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="0%" android:toXDelta="100%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="700" />
</set>

9
app/src/main/res/drawable/vector_bookmark.xml

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M18,2H6c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V4c0,-1.1 -0.9,-2 -2,-2zM6,4h5v8l-2.5,-1.5L6,12V4z"/>
</vector>

9
app/src/main/res/drawable/vector_save.xml

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z"/>
</vector>

6
app/src/main/res/layout/activity_main.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
@ -14,7 +14,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.design.widget.NavigationView
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
@ -23,4 +23,4 @@
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer"/>
</android.support.v4.widget.DrawerLayout>
</androidx.drawerlayout.widget.DrawerLayout>

12
app/src/main/res/layout/app_bar_main.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
@ -7,23 +7,23 @@
android:layout_height="match_parent"
tools:context=".view.MainActivity">
<android.support.design.widget.AppBarLayout
<com.google.android.material.appbar.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</android.support.design.widget.AppBarLayout>
</com.google.android.material.appbar.AppBarLayout>
<include layout="@layout/content_main"/>
<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -31,4 +31,4 @@
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_dialog_email"/>
</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

23
app/src/main/res/layout/content_main.xml

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
<FrameLayout
android:id="@+id/main_fragment_container"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
@ -9,22 +10,6 @@
tools:showIn="@layout/app_bar_main"
tools:context=".view.MainActivity">
<TextView
android:id="@+id/deleteThisTextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hör auf zu lesen und arbeite weiter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<android.support.v7.widget.AppCompatImageView
app:layout_constraintTop_toBottomOf="@id/deleteThisTextview"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@mipmap/ic_launcher"
/>
</android.support.constraint.ConstraintLayout>
</FrameLayout>

14
app/src/main/res/layout/fragment_about.xml

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@android:color/holo_green_light"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="About screen"/>
</androidx.constraintlayout.widget.ConstraintLayout>

13
app/src/main/res/layout/fragment_departures.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@android:color/holo_red_light"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="textDep"/>
</androidx.constraintlayout.widget.ConstraintLayout>

13
app/src/main/res/layout/fragment_navigation.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@android:color/holo_blue_light"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="textNav"/>
</androidx.constraintlayout.widget.ConstraintLayout>

13
app/src/main/res/layout/fragment_saved.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@android:color/holo_orange_light"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="textSavedRoutes/Stops"/>
</androidx.constraintlayout.widget.ConstraintLayout>

39
app/src/main/res/menu/activity_main_drawer.xml

@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
tools:showIn="navigation_view">
<group android:checkableBehavior="single">
<group android:checkableBehavior="single" >
<item
android:id="@+id/nav_departures"
android:icon="@drawable/baseline_departure_board_24"
@ -13,26 +13,33 @@
android:icon="@drawable/baseline_navigation_24"
android:title="@string/navigation"/>
<item
android:id="@+id/baseline_save"
android:icon="@drawable/ic_menu_slideshow"
android:id="@+id/nav_favorites"
android:icon="@drawable/vector_save"
android:title="@string/saved_routes"/>
</group>
<item>
<item android:title="@string/settings">
<menu>
<item
android:id="@+id/nav_notification_centre"
android:icon="@drawable/baseline_notification_important_24"
android:title="@string/notification_centre"/>
<item
android:id="@+id/nav_settings"
android:icon="@drawable/ic_menu_manage"
android:title="@string/settings"/>
<item
android:id="@+id/nav_about"
android:icon="@drawable/vector_info"
android:title="@string/about"/>
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_notification_centre"
android:icon="@drawable/baseline_notification_important_24"
android:title="@string/notification_centre"/>
<item
android:id="@+id/nav_settings"
android:icon="@drawable/ic_menu_manage"
android:title="@string/settings"/>
<item
android:id="@+id/nav_about"
android:icon="@drawable/vector_info"
android:title="@string/about"/>
</group>
</menu>
</item>
</menu>

8
app/src/main/res/xml/notification_settings.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreference android:title="Hier notification dinger" android:summary="notificationcenter" android:id="@+id/setting12"
android:key="switch12"/>
</PreferenceScreen>

11
app/src/main/res/xml/settings.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreference android:title="Switch" android:summary="summary3" android:id="@+id/setting1"
android:key="switch1"/>
<SwitchPreference android:title="Switch" android:summary="summary3" android:id="@+id/setting2"
android:key="switch2"/>
</PreferenceScreen>

2
gradle.properties

@ -13,3 +13,5 @@ org.gradle.jvmargs=-Xmx1536m
# org.gradle.parallel=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
android.useAndroidX=true
android.enableJetifier=true
Loading…
Cancel
Save