Fix delete repo selection area, fix follow/unfollow layout

This commit is contained in:
M M Arif
2022-04-30 15:47:10 +05:00
parent d11ca79b77
commit ab959557a0
5 changed files with 34 additions and 25 deletions

View File

@@ -23,11 +23,12 @@ import org.mian.gitnex.databinding.CustomRepositoryEditPropertiesDialogBinding;
import org.mian.gitnex.databinding.CustomRepositoryTransferDialogBinding;
import org.mian.gitnex.helpers.Toasty;
import org.mian.gitnex.helpers.contexts.RepositoryContext;
import java.util.Objects;
import retrofit2.Call;
import retrofit2.Callback;
/**
* Author M M Arif
* @author M M Arif
*/
public class RepositorySettingsActivity extends BaseActivity {
@@ -58,15 +59,9 @@ public class RepositorySettingsActivity extends BaseActivity {
initCloseListener();
closeActivity.setOnClickListener(onClickListener);
// require gitea 1.12 or higher
if(getAccount().requiresVersion("1.12.0")) {
viewBinding.transferOwnerFrame.setVisibility(View.VISIBLE);
}
viewBinding.editProperties.setOnClickListener(editProperties -> showRepositoryProperties());
viewBinding.deleteRepository.setOnClickListener(deleteRepository -> showDeleteRepository());
viewBinding.deleteRepositoryFrame.setOnClickListener(deleteRepository -> showDeleteRepository());
viewBinding.transferOwnerFrame.setOnClickListener(transferRepositoryOwnership -> showTransferRepository());
}
@@ -133,7 +128,7 @@ public class RepositorySettingsActivity extends BaseActivity {
Toasty.success(ctx, getString(R.string.repoTransferSuccess));
finish();
BaseApi.getInstance(ctx, RepositoriesApi.class).deleteRepository(repository.getRepositoryId());
Objects.requireNonNull(BaseApi.getInstance(ctx, RepositoriesApi.class)).deleteRepository(repository.getRepositoryId());
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
RepositorySettingsActivity.this.startActivity(intent);
}
@@ -214,7 +209,7 @@ public class RepositorySettingsActivity extends BaseActivity {
Toasty.success(ctx, getString(R.string.repoDeletionSuccess));
finish();
BaseApi.getInstance(ctx, RepositoriesApi.class).deleteRepository(repository.getRepositoryId());
Objects.requireNonNull(BaseApi.getInstance(ctx, RepositoriesApi.class)).deleteRepository(repository.getRepositoryId());
Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
RepositorySettingsActivity.this.startActivity(intent);
}
@@ -346,7 +341,8 @@ public class RepositorySettingsActivity extends BaseActivity {
repository.setRepository(response.body());
if(!repository.getName().equals(repoName)) {
BaseApi.getInstance(ctx, RepositoriesApi.class).updateRepositoryOwnerAndName(repository.getOwner(), repoName, repository.getRepositoryId());
Objects.requireNonNull(BaseApi.getInstance(ctx, RepositoriesApi.class))
.updateRepositoryOwnerAndName(repository.getOwner(), repoName, repository.getRepositoryId());
Intent result = new Intent();
result.putExtra("nameChanged", true);
setResult(200, result);

View File

@@ -1,16 +1,13 @@
package org.mian.gitnex.fragments;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import org.mian.gitnex.R;
import org.mian.gitnex.databinding.BottomSheetUserProfileBinding;
import org.mian.gitnex.structs.BottomSheetListener;
@@ -36,19 +33,22 @@ public class BottomSheetUserProfileFragment extends BottomSheetDialogFragment {
BottomSheetUserProfileBinding bottomSheetUserProfileBinding = BottomSheetUserProfileBinding.inflate(inflater, container, false);
if(following) {
bottomSheetUserProfileBinding.followUnfollowUser.setText(R.string.unfollowUser);
Drawable drawable = AppCompatResources.getDrawable(requireContext(), R.drawable.ic_person_remove); assert drawable != null;
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
bottomSheetUserProfileBinding.followUnfollowUser.setCompoundDrawablesRelative(drawable, null, null, null);
bottomSheetUserProfileBinding.unfollowUser.setVisibility(View.VISIBLE);
bottomSheetUserProfileBinding.followUser.setVisibility(View.GONE);
}
bottomSheetUserProfileBinding.followUnfollowUser.setOnClickListener(v1 -> {
bottomSheetUserProfileBinding.followUser.setOnClickListener(v1 -> {
bmListener.onButtonClicked("follow");
dismiss();
});
bottomSheetUserProfileBinding.unfollowUser.setOnClickListener(v1 -> {
bmListener.onButtonClicked("follow");
dismiss();
});
return bottomSheetUserProfileBinding.getRoot();
}
@@ -60,8 +60,7 @@ public class BottomSheetUserProfileFragment extends BottomSheetDialogFragment {
bmListener = (BottomSheetListener) context;
}
catch (ClassCastException e) {
throw new ClassCastException(context.toString() + " must implement BottomSheetListener");
throw new ClassCastException(context + " must implement BottomSheetListener");
}
}
}

View File

@@ -85,7 +85,6 @@
android:orientation="vertical"
android:focusable="true"
android:clickable="true"
android:visibility="gone"
tools:visibility="visible">
<TextView
@@ -122,6 +121,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/deleteRepositoryFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"

View File

@@ -46,7 +46,7 @@
app:alignContent="stretch" >
<TextView
android:id="@+id/followUnfollowUser"
android:id="@+id/followUser"
android:layout_width="98dp"
android:layout_height="100dp"
android:padding="8dp"
@@ -58,6 +58,20 @@
android:textColor="?attr/primaryTextColor"
android:textSize="16sp" />
<TextView
android:id="@+id/unfollowUser"
android:layout_width="98dp"
android:layout_height="100dp"
android:padding="8dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:gravity="center"
app:layout_alignSelf="flex_start"
app:drawableTopCompat="@drawable/ic_person_remove"
android:text="@string/unfollowUser"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:visibility="gone" />
</com.google.android.flexbox.FlexboxLayout>
</LinearLayout>

View File

@@ -469,7 +469,7 @@
<string name="menuEditText">Edit</string>
<string name="menuDeleteText">Delete</string>
<string name="menuCopyText">Copy</string>
<string name="menuQuoteText">Quote and Reply</string>
<string name="menuQuoteText">Quote Reply</string>
<string name="colorfulBulletSpan" translatable="false">\u0020\u0020\u0020\u25CF\u0020\u0020\u0020</string>
<string name="modifiedText">edited</string>
<string name="saveButton">Save</string>