Skip to content
Snippets Groups Projects
Commit f717c259 authored by Fabio Heyming's avatar Fabio Heyming
Browse files

test

parent 228ff550
No related branches found
No related tags found
1 merge request!1Mal aufn Master megren
...@@ -40,6 +40,7 @@ dependencies { ...@@ -40,6 +40,7 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
implementation 'androidx.navigation:navigation-fragment:2.5.3' implementation 'androidx.navigation:navigation-fragment:2.5.3'
implementation 'androidx.navigation:navigation-ui:2.5.3' implementation 'androidx.navigation:navigation-ui:2.5.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools" >
<application <application
android:allowBackup="true" android:allowBackup="true"
...@@ -11,11 +11,15 @@ ...@@ -11,11 +11,15 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.MampfMobil" android:theme="@style/Theme.MampfMobil"
tools:targetApi="31"> tools:targetApi="31" >
<activity
android:name=".ui.CostumerActivity"
android:exported="false"
android:label="@string/title_activity_costumer" />
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true" android:exported="true"
android:label="@string/app_name"> android:label="@string/app_name" >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
......
package com.example.mampfmobil; package com.example.mampfmobil;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.example.mampfmobil.ui.CostumerActivity;
import com.example.mampfmobil.ui.DecideFragment;
import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.android.material.bottomnavigation.BottomNavigationView;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.navigation.NavController; import androidx.navigation.NavController;
import androidx.navigation.Navigation; import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration; import androidx.navigation.ui.AppBarConfiguration;
...@@ -23,15 +30,14 @@ public class MainActivity extends AppCompatActivity { ...@@ -23,15 +30,14 @@ public class MainActivity extends AppCompatActivity {
binding = ActivityMainBinding.inflate(getLayoutInflater()); binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot()); setContentView(binding.getRoot());
BottomNavigationView navView = findViewById(R.id.nav_view); // Hier wird die Bottom Navigation View ausgeblendet
// Passing each menu ID as a set of Ids because each binding.navView.setVisibility(View.GONE);
// menu should be considered as top level destinations.
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder( // Fragment "fragment_decide" wird angezeigt
R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications) Fragment fragment = new DecideFragment();
.build(); FragmentManager fragmentManager = getSupportFragmentManager();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main); fragmentManager.beginTransaction().replace(R.id.nav_host_fragment_activity_main, fragment).commit();
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
NavigationUI.setupWithNavController(binding.navView, navController);
} }
} }
\ No newline at end of file
package com.example.mampfmobil.ui;
import android.os.Bundle;
import android.view.View;
import com.example.mampfmobil.R;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import com.example.mampfmobil.databinding.ActivityCostumerBinding;
import com.example.mampfmobil.ui.dashboard.DashboardFragment;
public class CostumerActivity extends AppCompatActivity {
private ActivityCostumerBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityCostumerBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
// Hier wird die Bottom Navigation View ausgeblendet
binding.navView.setVisibility(View.GONE);
// Fragment "fragment_decide" wird angezeigt
Fragment fragment = new DashboardFragment();
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.nav_host_fragment_activity_costumer, fragment).commit();
}
}
\ No newline at end of file
package com.example.mampfmobil.ui;
import androidx.lifecycle.ViewModelProvider;
import android.content.Intent;
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 android.widget.Button;
import com.example.mampfmobil.R;
public class DecideFragment extends Fragment {
private DecideViewModel mViewModel;
public static DecideFragment newInstance() {
return new DecideFragment();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_decide, container, false);
Button button = rootView.findViewById(R.id.CostumerButton);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Wechsel zur anderen Activity
Intent intent = new Intent(getActivity(), CostumerActivity.class);
startActivity(intent);
}
});
return rootView;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mViewModel = new ViewModelProvider(this).get(DecideViewModel.class);
// TODO: Use the ViewModel
}
}
\ No newline at end of file
package com.example.mampfmobil.ui;
import androidx.lifecycle.ViewModel;
public class DecideViewModel extends ViewModel {
// TODO: Implement the ViewModel
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize" >
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu"/>
<fragment
android:id="@+id/nav_host_fragment_activity_costumer"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/nav_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/mobile_navigation"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.DecideFragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/CostumerButton"
android:layout_width="200dp"
android:layout_height="70dp"
android:text="@string/title_costumer"
app:layout_constraintBottom_toTopOf="@+id/button3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.952" />
<Button
android:id="@+id/button3"
android:layout_width="200dp"
android:layout_height="70dp"
android:text="@string/title_supplier"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button"
android:layout_width="200dp"
android:layout_height="70dp"
android:text="@string/title_deliverer"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button3"
app:layout_constraintVertical_bias="0.051" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Mampf Mobil</string>
<string name="title_home">Zuhause</string>
<string name="title_dashboard">Dash</string>
<string name="title_notifications">Nachrichten</string>
<string name="title_costumer">Kunde</string>
<string name="title_supplier">Lieferant</string>
<string name="title_deliverer">Zusteller</string>
</resources>
\ No newline at end of file
...@@ -3,4 +3,8 @@ ...@@ -3,4 +3,8 @@
<string name="title_home">Home</string> <string name="title_home">Home</string>
<string name="title_dashboard">Dashboard</string> <string name="title_dashboard">Dashboard</string>
<string name="title_notifications">Notifications</string> <string name="title_notifications">Notifications</string>
<string name="title_costumer">Costumer</string>
<string name="title_supplier">Supplier</string>
<string name="title_deliverer">Deliverer</string>
<string name="title_activity_costumer">CostumerActivity</string>
</resources> </resources>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment