General layout (WIP)
This commit is contained in:
parent
cf99bc9591
commit
1a123f6b8d
@ -4,11 +4,13 @@ import android.os.Bundle;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
|
||||||
|
import com.cringe_studios.cringe_authenticator.ui.dynamic.DynamicFragment;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
import com.google.android.material.navigation.NavigationView;
|
import com.google.android.material.navigation.NavigationView;
|
||||||
|
|
||||||
import androidx.navigation.NavController;
|
import androidx.navigation.NavController;
|
||||||
import androidx.navigation.Navigation;
|
import androidx.navigation.Navigation;
|
||||||
|
import androidx.navigation.fragment.NavHostFragment;
|
||||||
import androidx.navigation.ui.AppBarConfiguration;
|
import androidx.navigation.ui.AppBarConfiguration;
|
||||||
import androidx.navigation.ui.NavigationUI;
|
import androidx.navigation.ui.NavigationUI;
|
||||||
import androidx.drawerlayout.widget.DrawerLayout;
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
@ -29,8 +31,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
setSupportActionBar(binding.appBarMain.toolbar);
|
setSupportActionBar(binding.appBarMain.toolbar);
|
||||||
binding.appBarMain.fab.setOnClickListener(view -> Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
|
binding.appBarMain.fab.setOnClickListener(view -> {
|
||||||
.setAction("Action", null).show());
|
getSupportActionBar().setTitle("DYNAMIC");
|
||||||
|
NavHostFragment f = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment_content_main);
|
||||||
|
f.getChildFragmentManager().beginTransaction().replace(R.id.nav_host_fragment_content_main, new DynamicFragment()).commit();
|
||||||
|
Snackbar.make(view, "Dynamic fragment opened", Snackbar.LENGTH_LONG).setAction("Action", null).show();
|
||||||
|
});
|
||||||
DrawerLayout drawer = binding.drawerLayout;
|
DrawerLayout drawer = binding.drawerLayout;
|
||||||
NavigationView navigationView = binding.navView;
|
NavigationView navigationView = binding.navView;
|
||||||
// Passing each menu ID as a set of Ids because each
|
// Passing each menu ID as a set of Ids because each
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.cringe_studios.cringe_authenticator.ui.credits;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.cringe_studios.cringe_authenticator.databinding.FragmentCreditsBinding;
|
||||||
|
|
||||||
|
public class CreditsFragment extends Fragment {
|
||||||
|
|
||||||
|
private FragmentCreditsBinding binding;
|
||||||
|
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
binding = FragmentCreditsBinding.inflate(inflater, container, false);
|
||||||
|
View root = binding.getRoot();
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
binding = null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.cringe_studios.cringe_authenticator.ui.dynamic;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.cringe_studios.cringe_authenticator.databinding.FragmentDynamicBinding;
|
||||||
|
|
||||||
|
public class DynamicFragment extends Fragment {
|
||||||
|
|
||||||
|
private FragmentDynamicBinding binding;
|
||||||
|
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
binding = FragmentDynamicBinding.inflate(inflater, container, false);
|
||||||
|
View root = binding.getRoot();
|
||||||
|
|
||||||
|
final TextView textView = binding.textDynamic;
|
||||||
|
textView.append("!");
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
binding = null;
|
||||||
|
}
|
||||||
|
}
|
@ -1,37 +0,0 @@
|
|||||||
package com.cringe_studios.cringe_authenticator.ui.gallery;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
|
||||||
|
|
||||||
import com.cringe_studios.cringe_authenticator.databinding.FragmentGalleryBinding;
|
|
||||||
|
|
||||||
public class GalleryFragment extends Fragment {
|
|
||||||
|
|
||||||
private FragmentGalleryBinding binding;
|
|
||||||
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
|
||||||
ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
GalleryViewModel galleryViewModel =
|
|
||||||
new ViewModelProvider(this).get(GalleryViewModel.class);
|
|
||||||
|
|
||||||
binding = FragmentGalleryBinding.inflate(inflater, container, false);
|
|
||||||
View root = binding.getRoot();
|
|
||||||
|
|
||||||
final TextView textView = binding.textGallery;
|
|
||||||
galleryViewModel.getText().observe(getViewLifecycleOwner(), textView::setText);
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroyView() {
|
|
||||||
super.onDestroyView();
|
|
||||||
binding = null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package com.cringe_studios.cringe_authenticator.ui.gallery;
|
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData;
|
|
||||||
import androidx.lifecycle.MutableLiveData;
|
|
||||||
import androidx.lifecycle.ViewModel;
|
|
||||||
|
|
||||||
public class GalleryViewModel extends ViewModel {
|
|
||||||
|
|
||||||
private final MutableLiveData<String> mText;
|
|
||||||
|
|
||||||
public GalleryViewModel() {
|
|
||||||
mText = new MutableLiveData<>();
|
|
||||||
mText.setValue("This is gallery fragment");
|
|
||||||
}
|
|
||||||
|
|
||||||
public LiveData<String> getText() {
|
|
||||||
return mText;
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,16 +16,9 @@ public class HomeFragment extends Fragment {
|
|||||||
|
|
||||||
private FragmentHomeBinding binding;
|
private FragmentHomeBinding binding;
|
||||||
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
HomeViewModel homeViewModel =
|
|
||||||
new ViewModelProvider(this).get(HomeViewModel.class);
|
|
||||||
|
|
||||||
binding = FragmentHomeBinding.inflate(inflater, container, false);
|
binding = FragmentHomeBinding.inflate(inflater, container, false);
|
||||||
View root = binding.getRoot();
|
View root = binding.getRoot();
|
||||||
|
|
||||||
final TextView textView = binding.textHome;
|
|
||||||
homeViewModel.getText().observe(getViewLifecycleOwner(), textView::setText);
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
package com.cringe_studios.cringe_authenticator.ui.home;
|
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData;
|
|
||||||
import androidx.lifecycle.MutableLiveData;
|
|
||||||
import androidx.lifecycle.ViewModel;
|
|
||||||
|
|
||||||
public class HomeViewModel extends ViewModel {
|
|
||||||
|
|
||||||
private final MutableLiveData<String> mText;
|
|
||||||
|
|
||||||
public HomeViewModel() {
|
|
||||||
mText = new MutableLiveData<>();
|
|
||||||
mText.setValue("This is home fragment");
|
|
||||||
}
|
|
||||||
|
|
||||||
public LiveData<String> getText() {
|
|
||||||
return mText;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.cringe_studios.cringe_authenticator.ui.settings;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.cringe_studios.cringe_authenticator.databinding.FragmentSettingsBinding;
|
||||||
|
|
||||||
|
public class SettingsFragment extends Fragment {
|
||||||
|
|
||||||
|
private FragmentSettingsBinding binding;
|
||||||
|
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
binding = FragmentSettingsBinding.inflate(inflater, container, false);
|
||||||
|
View root = binding.getRoot();
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
binding = null;
|
||||||
|
}
|
||||||
|
}
|
@ -1,37 +0,0 @@
|
|||||||
package com.cringe_studios.cringe_authenticator.ui.slideshow;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
|
||||||
|
|
||||||
import com.cringe_studios.cringe_authenticator.databinding.FragmentSlideshowBinding;
|
|
||||||
|
|
||||||
public class SlideshowFragment extends Fragment {
|
|
||||||
|
|
||||||
private FragmentSlideshowBinding binding;
|
|
||||||
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
|
||||||
ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
SlideshowViewModel slideshowViewModel =
|
|
||||||
new ViewModelProvider(this).get(SlideshowViewModel.class);
|
|
||||||
|
|
||||||
binding = FragmentSlideshowBinding.inflate(inflater, container, false);
|
|
||||||
View root = binding.getRoot();
|
|
||||||
|
|
||||||
final TextView textView = binding.textSlideshow;
|
|
||||||
slideshowViewModel.getText().observe(getViewLifecycleOwner(), textView::setText);
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroyView() {
|
|
||||||
super.onDestroyView();
|
|
||||||
binding = null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package com.cringe_studios.cringe_authenticator.ui.slideshow;
|
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData;
|
|
||||||
import androidx.lifecycle.MutableLiveData;
|
|
||||||
import androidx.lifecycle.ViewModel;
|
|
||||||
|
|
||||||
public class SlideshowViewModel extends ViewModel {
|
|
||||||
|
|
||||||
private final MutableLiveData<String> mText;
|
|
||||||
|
|
||||||
public SlideshowViewModel() {
|
|
||||||
mText = new MutableLiveData<>();
|
|
||||||
mText.setValue("This is slideshow fragment");
|
|
||||||
}
|
|
||||||
|
|
||||||
public LiveData<String> getText() {
|
|
||||||
return mText;
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,7 +4,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".ui.slideshow.SlideshowFragment">
|
tools:context=".ui.credits.CreditsFragment">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_slideshow"
|
android:id="@+id/text_slideshow"
|
||||||
@ -13,6 +13,7 @@
|
|||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
|
android:text="Credits"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
17
app/src/main/res/layout/fragment_dynamic.xml
Normal file
17
app/src/main/res/layout/fragment_dynamic.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?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"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_dynamic"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Dynamic Fragment"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -13,6 +13,7 @@
|
|||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
|
android:text="Home"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".ui.gallery.GalleryFragment">
|
tools:context=".ui.settings.SettingsFragment">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_gallery"
|
android:id="@+id/text_gallery"
|
||||||
@ -13,6 +13,7 @@
|
|||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
|
android:text="Settings"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
@ -6,15 +6,15 @@
|
|||||||
<group android:checkableBehavior="single">
|
<group android:checkableBehavior="single">
|
||||||
<item
|
<item
|
||||||
android:id="@+id/nav_home"
|
android:id="@+id/nav_home"
|
||||||
android:icon="@drawable/ic_menu_camera"
|
android:icon="@drawable/ic_launcher_foreground"
|
||||||
android:title="@string/menu_home" />
|
android:title="Home" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/nav_settings"
|
android:id="@+id/nav_settings"
|
||||||
android:icon="@drawable/ic_menu_gallery"
|
android:icon="@drawable/ic_launcher_foreground"
|
||||||
android:title="@string/menu_gallery" />
|
android:title="Settings" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/nav_credits"
|
android:id="@+id/nav_credits"
|
||||||
android:icon="@drawable/ic_menu_slideshow"
|
android:icon="@drawable/ic_launcher_foreground"
|
||||||
android:title="@string/menu_slideshow" />
|
android:title="Credits" />
|
||||||
</group>
|
</group>
|
||||||
</menu>
|
</menu>
|
@ -13,13 +13,13 @@
|
|||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/nav_settings"
|
android:id="@+id/nav_settings"
|
||||||
android:name="com.cringe_studios.cringe_authenticator.ui.slideshow.SlideshowFragment"
|
android:name="com.cringe_studios.cringe_authenticator.ui.settings.SettingsFragment"
|
||||||
android:label="Settings"
|
android:label="Settings"
|
||||||
tools:layout="@layout/fragment_slideshow" />
|
tools:layout="@layout/fragment_settings" />
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/nav_credits"
|
android:id="@+id/nav_credits"
|
||||||
android:name="com.cringe_studios.cringe_authenticator.ui.slideshow.SlideshowFragment"
|
android:name="com.cringe_studios.cringe_authenticator.ui.credits.CreditsFragment"
|
||||||
android:label="Credits"
|
android:label="Credits"
|
||||||
tools:layout="@layout/fragment_slideshow" />
|
tools:layout="@layout/fragment_credits" />
|
||||||
</navigation>
|
</navigation>
|
Loading…
Reference in New Issue
Block a user