View repo fork information (#1123)

(see the screenshot above the size information)

Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1123
Reviewed-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
qwerty287 2022-05-04 19:25:32 +02:00 committed by M M Arif
parent 7d6a92b5a8
commit 7d271a236e
3 changed files with 44 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package org.mian.gitnex.fragments;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
@ -229,6 +230,17 @@ public class RepoInfoFragment extends Fragment {
binding.repoIsArchived.setVisibility(View.GONE);
}
if(repoInfo.isFork()) {
binding.repoForkFrame.setVisibility(View.VISIBLE);
binding.repoForkFrame.setOnClickListener((v) -> {
Intent parent = new RepositoryContext(repoInfo.getParent(), requireContext()).getIntent(requireContext(), RepoDetailActivity.class);
startActivity(parent);
});
binding.repoFork.setText(getString(R.string.repoForkOf, repoInfo.getParent().getFullName()));
} else {
binding.repoForkFrame.setVisibility(View.GONE);
}
getFileContents(repository.getOwner(), repository.getName(), getResources().getString(R.string.defaultFilename), repoInfo.getDefaultBranch());
pageContent.setVisibility(View.VISIBLE);
@ -242,12 +254,12 @@ public class RepoInfoFragment extends Fragment {
.getWebInterface(getContext())
.getFileContents(owner, repo, defBranch, filename);
call.enqueue(new Callback<ResponseBody>() {
call.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<ResponseBody> call, @NonNull retrofit2.Response<ResponseBody> response) {
if (isAdded()) {
if(isAdded()) {
switch(response.code()) {
@ -288,6 +300,7 @@ public class RepoInfoFragment extends Fragment {
@Override
public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) {
Log.e("onFailure", t.toString());
}

View File

@ -203,12 +203,39 @@
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="25dp"
android:layout_marginBottom="25dp"
android:layout_marginBottom="12dp"
android:background="?attr/dividerColor" />
<LinearLayout
android:id="@+id/repo_fork_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="?android:attr/selectableItemBackground"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingLeft="15dp"
android:paddingRight="15dp">
<ImageView
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_fork" />
<TextView
android:id="@+id/repo_fork"
android:layout_marginStart="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginBottom="20dp"
android:orientation="horizontal"
android:paddingLeft="15dp"

View File

@ -757,4 +757,5 @@
<string name="notLoggedIn">%s \u25CF not logged in</string>
<string name="followSystem">Follow system (Light/Dark)</string>
<string name="followSystemBlack">Follow system (Light/Pitch Black)</string>
<string name="repoForkOf">Fork of: %s</string>
</resources>