mirror of
https://github.com/gitnex-org/gitnex.git
synced 2026-03-22 13:05:25 -05:00
Add milestone FAB, move logout to settings
This commit is contained in:
@@ -196,9 +196,7 @@ public class CreateMilestoneActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
if (response.code() == 201) {
|
||||
|
||||
Intent result = new Intent();
|
||||
result.putExtra("milestoneCreated", true);
|
||||
setResult(201, result);
|
||||
RepoDetailActivity.updateFABActions = true;
|
||||
Toasty.success(ctx, getString(R.string.milestoneCreated));
|
||||
enableProcessButton();
|
||||
finish();
|
||||
|
||||
@@ -638,10 +638,6 @@ public class MainActivity extends BaseActivity
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container, new SettingsFragment())
|
||||
.commit();
|
||||
} else if (id == R.id.nav_logout) {
|
||||
|
||||
AppUtil.logout(ctx);
|
||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||
} else if (id == R.id.nav_starred_repos) {
|
||||
|
||||
toolbarTitle.setText(getResources().getString(R.string.pageTitleStarredRepos));
|
||||
|
||||
@@ -86,7 +86,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
private FragmentRefreshListener fragmentRefreshListener;
|
||||
private FragmentRefreshListener fragmentRefreshListenerPr;
|
||||
private FragmentRefreshListener fragmentRefreshListenerMilestone;
|
||||
private final ActivityResultLauncher<Intent> createMilestoneLauncher =
|
||||
/*private final ActivityResultLauncher<Intent> createMilestoneLauncher =
|
||||
registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
@@ -99,7 +99,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});*/
|
||||
private FragmentRefreshListener fragmentRefreshListenerFiles;
|
||||
private final ActivityResultLauncher<Intent> editFileLauncher =
|
||||
registerForActivityResult(
|
||||
@@ -295,8 +295,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
startActivity(repository.getIntent(ctx, CreateIssueActivity.class));
|
||||
break;
|
||||
case "newMilestone":
|
||||
createMilestoneLauncher.launch(
|
||||
repository.getIntent(ctx, CreateMilestoneActivity.class));
|
||||
/*createMilestoneLauncher.launch(
|
||||
repository.getIntent(ctx, CreateMilestoneActivity.class));*/
|
||||
break;
|
||||
case "addCollaborator":
|
||||
startActivity(repository.getIntent(ctx, AddCollaboratorToRepositoryActivity.class));
|
||||
@@ -810,8 +810,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetListe
|
||||
break;
|
||||
case "milestonesNew":
|
||||
viewPager.setCurrentItem(6);
|
||||
createMilestoneLauncher.launch(
|
||||
repository.getIntent(ctx, CreateMilestoneActivity.class));
|
||||
startActivity(repository.getIntent(ctx, CreateMilestoneActivity.class));
|
||||
break;
|
||||
case "labels":
|
||||
viewPager.setCurrentItem(7);
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.gitnex.tea4j.v2.models.Milestone;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.activities.CreateMilestoneActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.adapters.MilestonesAdapter;
|
||||
import org.mian.gitnex.databinding.FragmentMilestonesBinding;
|
||||
@@ -62,6 +63,9 @@ public class MilestonesFragment extends Fragment {
|
||||
Context ctx = getContext();
|
||||
milestonesViewModel = new ViewModelProvider(this).get(MilestonesViewModel.class);
|
||||
|
||||
boolean canPush = repository.getPermissions().isPush();
|
||||
boolean archived = repository.getRepository().isArchived();
|
||||
|
||||
milestoneId = requireActivity().getIntent().getStringExtra("milestoneId");
|
||||
requireActivity().getIntent().removeExtra("milestoneId");
|
||||
|
||||
@@ -107,10 +111,27 @@ public class MilestonesFragment extends Fragment {
|
||||
repository.getOwner(), repository.getName(), milestoneState);
|
||||
});
|
||||
|
||||
if (!canPush || archived) {
|
||||
viewBinding.createNewMilestone.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
viewBinding.createNewMilestone.setOnClickListener(
|
||||
v13 -> startActivity(repository.getIntent(ctx, CreateMilestoneActivity.class)));
|
||||
|
||||
fetchDataAsync(repository.getOwner(), repository.getName(), state);
|
||||
return viewBinding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (RepoDetailActivity.updateFABActions) {
|
||||
fetchDataAsync(repository.getOwner(), repository.getName(), state);
|
||||
RepoDetailActivity.updateFABActions = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchDataAsync(String repoOwner, String repoName, String state) {
|
||||
|
||||
milestonesViewModel
|
||||
|
||||
@@ -82,6 +82,11 @@ public class SettingsFragment extends Fragment {
|
||||
|
||||
fragmentSettingsBinding.aboutAppFrame.setOnClickListener(aboutApp -> showAboutAppDialog());
|
||||
|
||||
fragmentSettingsBinding.navLogout.setOnClickListener(logout -> {
|
||||
AppUtil.logout(ctx);
|
||||
requireActivity().overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||
});
|
||||
|
||||
return fragmentSettingsBinding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
android:id="@+id/nav_view"
|
||||
app:headerLayout="@layout/nav_header"
|
||||
android:background="?attr/primaryBackgroundColor"
|
||||
app:itemIconTint="?attr/primaryTextColor"
|
||||
app:itemIconTint="?attr/iconsColor"
|
||||
app:itemTextColor="?attr/primaryTextColor"
|
||||
app:menu="@menu/drawer_menu"/>
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -20,7 +21,9 @@
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="@dimen/dimen72dp"/>
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
@@ -47,11 +50,24 @@
|
||||
android:id="@+id/noDataMilestone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="15dp"
|
||||
android:layout_margin="@dimen/dimen16dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/noDataFound"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="18sp"
|
||||
android:textSize="@dimen/dimen18sp"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</RelativeLayout>
|
||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
android:id="@+id/createNewMilestone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:layout_margin="@dimen/dimen16dp"
|
||||
android:text="@string/pageTitleCreateMilestone"
|
||||
android:contentDescription="@string/pageTitleCreateMilestone"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:backgroundTint="?attr/fabColor"
|
||||
app:iconTint="?attr/primaryTextColor"
|
||||
app:icon="@drawable/ic_add" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
@@ -456,11 +456,11 @@
|
||||
android:id="@+id/aboutAppFrame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginBottom="@dimen/dimen6dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="15dp">
|
||||
android:padding="@dimen/dimen16dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
@@ -471,8 +471,8 @@
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginStart="@dimen/dimen10dp"
|
||||
android:layout_marginEnd="@dimen/dimen10dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
@@ -480,22 +480,60 @@
|
||||
android:id="@+id/aboutApp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingStart="@dimen/dimen12dp"
|
||||
android:paddingEnd="@dimen/dimen12dp"
|
||||
android:text="@string/navAbout"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="18sp"/>
|
||||
android:textSize="@dimen/dimen18sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/aboutAppHintText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingStart="@dimen/dimen12dp"
|
||||
android:paddingEnd="@dimen/dimen12dp"
|
||||
android:text="@string/aboutAppHintText"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="12sp"/>
|
||||
android:textSize="@dimen/dimen12sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/logoutFrame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/dimen6dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="@dimen/dimen16dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/generalImgContentText"
|
||||
app:srcCompat="@drawable/ic_logout"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dimen10dp"
|
||||
android:layout_marginEnd="@dimen/dimen10dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nav_logout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/dimen12dp"
|
||||
android:paddingEnd="@dimen/dimen12dp"
|
||||
android:text="@string/navLogout"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="@dimen/dimen18sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -68,10 +68,6 @@
|
||||
android:icon="@drawable/ic_settings"
|
||||
android:title="@string/navSettings"/>
|
||||
|
||||
<item android:id="@+id/nav_logout"
|
||||
android:icon="@drawable/ic_logout"
|
||||
android:title="@string/navLogout"/>
|
||||
|
||||
</group>
|
||||
|
||||
</menu>
|
||||
|
||||
Reference in New Issue
Block a user