mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2024-12-16 15:48:13 +08:00
Merge pull request 'Create new screen for administration' (#442) from 438-admin-nav into master
Reviewed-on: https://gitea.com/gitnex/GitNex/pulls/442 Reviewed-by: 6543 <6543@noreply.gitea.io>
This commit is contained in:
commit
625e60f2e2
@ -27,9 +27,9 @@ import org.mian.gitnex.R;
|
|||||||
import org.mian.gitnex.clients.PicassoService;
|
import org.mian.gitnex.clients.PicassoService;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.fragments.AboutFragment;
|
import org.mian.gitnex.fragments.AboutFragment;
|
||||||
|
import org.mian.gitnex.fragments.AdministrationFragment;
|
||||||
import org.mian.gitnex.fragments.ExploreRepositoriesFragment;
|
import org.mian.gitnex.fragments.ExploreRepositoriesFragment;
|
||||||
import org.mian.gitnex.fragments.MyRepositoriesFragment;
|
import org.mian.gitnex.fragments.MyRepositoriesFragment;
|
||||||
import org.mian.gitnex.fragments.BottomSheetNavSubMenuFragment;
|
|
||||||
import org.mian.gitnex.fragments.OrganizationsFragment;
|
import org.mian.gitnex.fragments.OrganizationsFragment;
|
||||||
import org.mian.gitnex.fragments.SettingsFragment;
|
import org.mian.gitnex.fragments.SettingsFragment;
|
||||||
import org.mian.gitnex.fragments.StarredRepositoriesFragment;
|
import org.mian.gitnex.fragments.StarredRepositoriesFragment;
|
||||||
@ -151,20 +151,15 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
else if (fragmentById instanceof AboutFragment) {
|
else if (fragmentById instanceof AboutFragment) {
|
||||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleAbout));
|
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);
|
drawer = findViewById(R.id.drawer_layout);
|
||||||
NavigationView navigationView = findViewById(R.id.nav_view);
|
NavigationView navigationView = findViewById(R.id.nav_view);
|
||||||
navigationView.setNavigationItemSelectedListener(this);
|
navigationView.setNavigationItemSelectedListener(this);
|
||||||
final View hView = navigationView.getHeaderView(0);
|
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,
|
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
|
||||||
R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||||
toggle.getDrawerArrowDrawable().setColor(getResources().getColor(R.color.darkGreen));
|
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,
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
|
||||||
new ExploreRepositoriesFragment()).commit();
|
new ExploreRepositoriesFragment()).commit();
|
||||||
break;
|
break;
|
||||||
|
case R.id.nav_administration:
|
||||||
|
toolbarTitle.setText(getResources().getString(R.string.pageTitleAdministration));
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
|
||||||
|
new AdministrationFragment()).commit();
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,6 +464,7 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
assert userDetails != null;
|
assert userDetails != null;
|
||||||
if(userDetails.getIs_admin() != null) {
|
if(userDetails.getIs_admin() != null) {
|
||||||
tinyDb.putBoolean("userIsAdmin", userDetails.getIs_admin());
|
tinyDb.putBoolean("userIsAdmin", userDetails.getIs_admin());
|
||||||
|
navigationView.getMenu().findItem(R.id.nav_administration).setVisible(userDetails.getIs_admin());
|
||||||
}
|
}
|
||||||
tinyDb.putString("userLogin", userDetails.getLogin());
|
tinyDb.putString("userLogin", userDetails.getLogin());
|
||||||
tinyDb.putInt("userId", userDetails.getId());
|
tinyDb.putInt("userId", userDetails.getId());
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
5
app/src/main/res/drawable/ic_admin.xml
Normal file
5
app/src/main/res/drawable/ic_admin.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<vector android:autoMirrored="true" android:height="24dp"
|
||||||
|
android:tint="#368F73" android:viewportHeight="24.0"
|
||||||
|
android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FF000000" android:pathData="M22.7,19l-9.1,-9.1c0.9,-2.3 0.4,-5 -1.5,-6.9 -2,-2 -5,-2.4 -7.4,-1.3L9,6 6,9 1.6,4.7C0.4,7.1 0.9,10.1 2.9,12.1c1.9,1.9 4.6,2.4 6.9,1.5l9.1,9.1c0.4,0.4 1,0.4 1.4,0l2.3,-2.3c0.5,-0.4 0.5,-1.1 0.1,-1.4z"/>
|
||||||
|
</vector>
|
@ -1,16 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:background="?attr/primaryBackgroundColor">
|
||||||
android:paddingBottom="8dp"
|
|
||||||
android:background="?attr/primaryBackgroundColor"
|
|
||||||
android:paddingTop="8dp">
|
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<ScrollView android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:background="?attr/primaryBackgroundColor">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -24,13 +20,18 @@
|
|||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:text="@string/adminUsers"
|
android:text="@string/adminUsers"
|
||||||
android:drawableStart="@drawable/ic_users"
|
android:drawableStart="@drawable/ic_users"
|
||||||
android:drawablePadding="24dp"
|
android:drawablePadding="32dp"
|
||||||
android:textColor="?attr/primaryTextColor"
|
android:textColor="?attr/primaryTextColor"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:padding="16dp" />
|
android:padding="16dp" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?attr/dividerColor" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</LinearLayout>
|
</RelativeLayout>
|
@ -50,16 +50,6 @@
|
|||||||
android:paddingStart="20dp"
|
android:paddingStart="20dp"
|
||||||
android:paddingEnd="5dp" />
|
android:paddingEnd="5dp" />
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/navSubMenu"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_weight="0.15"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:src="@drawable/ic_dotted_menu"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:scaleType="fitStart"
|
|
||||||
android:contentDescription="@string/menuContentDesc"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
@ -23,6 +23,10 @@
|
|||||||
<item android:id="@+id/nav_profile"
|
<item android:id="@+id/nav_profile"
|
||||||
android:icon="@drawable/ic_person_24dp"
|
android:icon="@drawable/ic_person_24dp"
|
||||||
android:title="@string/navProfile" />
|
android:title="@string/navProfile" />
|
||||||
|
<item android:id="@+id/nav_administration"
|
||||||
|
android:icon="@drawable/ic_admin"
|
||||||
|
android:title="@string/navAdministration"
|
||||||
|
android:visible="false" />
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<group android:checkableBehavior="single"
|
<group android:checkableBehavior="single"
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
<string name="navRate">Rate GitNex</string>
|
<string name="navRate">Rate GitNex</string>
|
||||||
<string name="navLogout">Logout</string>
|
<string name="navLogout">Logout</string>
|
||||||
<string name="navExplore">Explore</string>
|
<string name="navExplore">Explore</string>
|
||||||
|
<string name="navAdministration">Administration</string>
|
||||||
<!-- menu items -->
|
<!-- menu items -->
|
||||||
|
|
||||||
<!-- page titles -->
|
<!-- page titles -->
|
||||||
@ -56,6 +57,7 @@
|
|||||||
<string name="pageTitleAddEmail">Add Email Address</string>
|
<string name="pageTitleAddEmail">Add Email Address</string>
|
||||||
<string name="pageTitleNewFile">New File</string>
|
<string name="pageTitleNewFile">New File</string>
|
||||||
<string name="pageTitleExplore">Explore</string>
|
<string name="pageTitleExplore">Explore</string>
|
||||||
|
<string name="pageTitleAdministration">Gitea Administration</string>
|
||||||
<!-- page titles -->
|
<!-- page titles -->
|
||||||
|
|
||||||
<string name="appVersion">Version\u0020:\u0020</string>
|
<string name="appVersion">Version\u0020:\u0020</string>
|
||||||
@ -413,7 +415,7 @@
|
|||||||
|
|
||||||
<!-- admin -->
|
<!-- admin -->
|
||||||
<string name="adminCreateNewUser">Add New User</string>
|
<string name="adminCreateNewUser">Add New User</string>
|
||||||
<string name="adminUsers">Users</string>
|
<string name="adminUsers">System Users</string>
|
||||||
<string name="userRoleAdmin">Admin</string>
|
<string name="userRoleAdmin">Admin</string>
|
||||||
<!-- admin -->
|
<!-- admin -->
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user