From d7ef368f0b61312a3a1407236e142f96e4541e04 Mon Sep 17 00:00:00 2001 From: M M Arif Date: Thu, 23 Apr 2020 17:05:50 +0500 Subject: [PATCH] Create new screen for administration --- .../mian/gitnex/activities/MainActivity.java | 18 ++++----- .../fragments/AdministrationFragment.java | 35 +++++++++++++++++ .../BottomSheetNavSubMenuFragment.java | 39 ------------------- app/src/main/res/drawable/ic_admin.xml | 5 +++ ...layout.xml => fragment_administration.xml} | 27 ++++++------- app/src/main/res/layout/nav_header.xml | 10 ----- app/src/main/res/menu/drawer_menu.xml | 3 ++ app/src/main/res/values/strings.xml | 4 +- 8 files changed, 69 insertions(+), 72 deletions(-) create mode 100644 app/src/main/java/org/mian/gitnex/fragments/AdministrationFragment.java delete mode 100644 app/src/main/java/org/mian/gitnex/fragments/BottomSheetNavSubMenuFragment.java create mode 100644 app/src/main/res/drawable/ic_admin.xml rename app/src/main/res/layout/{bottom_sheet_nav_sub_menu_layout.xml => fragment_administration.xml} (56%) diff --git a/app/src/main/java/org/mian/gitnex/activities/MainActivity.java b/app/src/main/java/org/mian/gitnex/activities/MainActivity.java index 7f67e58e..63e803a8 100644 --- a/app/src/main/java/org/mian/gitnex/activities/MainActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/MainActivity.java @@ -27,9 +27,9 @@ import org.mian.gitnex.R; import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.fragments.AboutFragment; +import org.mian.gitnex.fragments.AdministrationFragment; import org.mian.gitnex.fragments.ExploreRepositoriesFragment; import org.mian.gitnex.fragments.MyRepositoriesFragment; -import org.mian.gitnex.fragments.BottomSheetNavSubMenuFragment; import org.mian.gitnex.fragments.OrganizationsFragment; import org.mian.gitnex.fragments.SettingsFragment; import org.mian.gitnex.fragments.StarredRepositoriesFragment; @@ -151,20 +151,15 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig else if (fragmentById instanceof AboutFragment) { toolbarTitle.setText(getResources().getString(R.string.pageTitleAbout)); } + else if (fragmentById instanceof AdministrationFragment) { + toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration)); + } drawer = findViewById(R.id.drawer_layout); NavigationView navigationView = findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); final View hView = navigationView.getHeaderView(0); - ImageView navSubMenu = hView.findViewById(R.id.navSubMenu); - navSubMenu.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - BottomSheetNavSubMenuFragment bottomSheet = new BottomSheetNavSubMenuFragment(); - bottomSheet.show(getSupportFragmentManager(), "adminMenuBottomSheet"); - } - }); - ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); toggle.getDrawerArrowDrawable().setColor(getResources().getColor(R.color.darkGreen)); @@ -371,6 +366,11 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new ExploreRepositoriesFragment()).commit(); break; + case R.id.nav_administration: + toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration)); + getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, + new AdministrationFragment()).commit(); + break; } diff --git a/app/src/main/java/org/mian/gitnex/fragments/AdministrationFragment.java b/app/src/main/java/org/mian/gitnex/fragments/AdministrationFragment.java new file mode 100644 index 00000000..3ed55de1 --- /dev/null +++ b/app/src/main/java/org/mian/gitnex/fragments/AdministrationFragment.java @@ -0,0 +1,35 @@ +package org.mian.gitnex.fragments; + +import android.content.Intent; +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.annotation.Nullable; +import androidx.fragment.app.Fragment; +import org.mian.gitnex.R; +import org.mian.gitnex.activities.AdminGetUsersActivity; +import org.mian.gitnex.util.TinyDB; + +/** + * Author M M Arif + */ + +public class AdministrationFragment extends Fragment { + + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + + View v = inflater.inflate(R.layout.fragment_administration, container, false); + + TinyDB tinyDb = new TinyDB(getContext()); + + TextView adminUsers = v.findViewById(R.id.adminUsers); + + adminUsers.setOnClickListener(v1 -> startActivity(new Intent(getContext(), AdminGetUsersActivity.class))); + + return v; + } + +} diff --git a/app/src/main/java/org/mian/gitnex/fragments/BottomSheetNavSubMenuFragment.java b/app/src/main/java/org/mian/gitnex/fragments/BottomSheetNavSubMenuFragment.java deleted file mode 100644 index 684579ad..00000000 --- a/app/src/main/java/org/mian/gitnex/fragments/BottomSheetNavSubMenuFragment.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.mian.gitnex.fragments; - -import android.content.Intent; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; -import com.google.android.material.bottomsheet.BottomSheetDialogFragment; -import org.mian.gitnex.R; -import org.mian.gitnex.activities.AdminGetUsersActivity; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -/** - * Author M M Arif - */ - -public class BottomSheetNavSubMenuFragment extends BottomSheetDialogFragment { - - @Nullable - @Override - public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View v = inflater.inflate(R.layout.bottom_sheet_nav_sub_menu_layout, container, false); - - TextView adminUsers = v.findViewById(R.id.adminUsers); - - adminUsers.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - startActivity(new Intent(getContext(), AdminGetUsersActivity.class)); - dismiss(); - } - }); - - return v; - } - -} diff --git a/app/src/main/res/drawable/ic_admin.xml b/app/src/main/res/drawable/ic_admin.xml new file mode 100644 index 00000000..59024e09 --- /dev/null +++ b/app/src/main/res/drawable/ic_admin.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/bottom_sheet_nav_sub_menu_layout.xml b/app/src/main/res/layout/fragment_administration.xml similarity index 56% rename from app/src/main/res/layout/bottom_sheet_nav_sub_menu_layout.xml rename to app/src/main/res/layout/fragment_administration.xml index 1241c538..1cbf6b85 100644 --- a/app/src/main/res/layout/bottom_sheet_nav_sub_menu_layout.xml +++ b/app/src/main/res/layout/fragment_administration.xml @@ -1,16 +1,12 @@ - + android:layout_height="match_parent" + android:background="?attr/primaryBackgroundColor"> - + + + - + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/nav_header.xml b/app/src/main/res/layout/nav_header.xml index b8676c4c..a9c78f47 100644 --- a/app/src/main/res/layout/nav_header.xml +++ b/app/src/main/res/layout/nav_header.xml @@ -50,16 +50,6 @@ android:paddingStart="20dp" android:paddingEnd="5dp" /> - - + Rate GitNex Logout Explore + Administration @@ -56,6 +57,7 @@ Add Email Address New File Explore + Gitea Administration Version\u0020:\u0020 @@ -413,7 +415,7 @@ Add New User - Users + System Users Admin