Move about dialog to a bottom sheet

This commit is contained in:
M M Arif
2025-06-23 22:26:19 +05:00
parent 10d69524e9
commit e2360dd9ab
5 changed files with 274 additions and 309 deletions

View File

@@ -11,7 +11,7 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import org.mian.gitnex.R;
import org.mian.gitnex.activities.BaseActivity;
import org.mian.gitnex.activities.SettingsAppearanceActivity;
@@ -20,19 +20,17 @@ import org.mian.gitnex.activities.SettingsCodeEditorActivity;
import org.mian.gitnex.activities.SettingsGeneralActivity;
import org.mian.gitnex.activities.SettingsNotificationsActivity;
import org.mian.gitnex.activities.SettingsSecurityActivity;
import org.mian.gitnex.databinding.CustomAboutDialogBinding;
import org.mian.gitnex.databinding.BottomSheetAboutBinding;
import org.mian.gitnex.databinding.FragmentSettingsBinding;
import org.mian.gitnex.helpers.AppUtil;
/**
* @author M M Arif
* @author mmarif
*/
public class SettingsFragment extends Fragment {
public static boolean refreshParent = false;
private Context ctx;
private MaterialAlertDialogBuilder materialAlertDialogBuilder;
@Nullable @Override
public View onCreateView(
@@ -45,8 +43,6 @@ public class SettingsFragment extends Fragment {
ctx = getContext();
assert ctx != null;
materialAlertDialogBuilder =
new MaterialAlertDialogBuilder(ctx, R.style.ThemeOverlay_Material3_Dialog_Alert);
fragmentSettingsBinding.notificationsFrame.setVisibility(View.VISIBLE);
@@ -75,54 +71,77 @@ public class SettingsFragment extends Fragment {
fragmentSettingsBinding.rateAppFrame.setOnClickListener(rateApp -> rateThisApp());
fragmentSettingsBinding.aboutAppFrame.setOnClickListener(aboutApp -> showAboutAppDialog());
fragmentSettingsBinding.aboutAppFrame.setOnClickListener(
aboutApp ->
new AboutBottomSheetFragment()
.show(getChildFragmentManager(), "AboutBottomSheet"));
return fragmentSettingsBinding.getRoot();
}
public void showAboutAppDialog() {
public static class AboutBottomSheetFragment extends BottomSheetDialogFragment {
CustomAboutDialogBinding aboutAppDialogBinding =
CustomAboutDialogBinding.inflate(LayoutInflater.from(ctx));
View view = aboutAppDialogBinding.getRoot();
private BottomSheetAboutBinding binding;
materialAlertDialogBuilder.setView(view);
@Nullable @Override
public View onCreateView(
@NonNull LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
binding = BottomSheetAboutBinding.inflate(inflater, container, false);
aboutAppDialogBinding.appVersionBuild.setText(
getString(
R.string.appVersionBuild,
AppUtil.getAppVersion(ctx),
AppUtil.getAppBuildNo(ctx)));
aboutAppDialogBinding.userServerVersion.setText(
((BaseActivity) requireActivity()).getAccount().getServerVersion().toString());
// Set app version and build
binding.appVersionBuild.setText(
getString(
R.string.appVersionBuild,
AppUtil.getAppVersion(requireContext()),
AppUtil.getAppBuildNo(requireContext())));
aboutAppDialogBinding.donationLinkPatreon.setOnClickListener(
v12 ->
// Set server version
binding.userServerVersion.setText(
((BaseActivity) requireActivity()).getAccount().getServerVersion().toString());
// Set up link click listeners
binding.donationLinkPatreon.setOnClickListener(
v -> {
AppUtil.openUrlInBrowser(
requireContext(),
getResources().getString(R.string.supportLinkPatreon)));
requireContext(), getString(R.string.supportLinkPatreon));
dismiss();
});
aboutAppDialogBinding.translateLink.setOnClickListener(
v13 ->
binding.translateLink.setOnClickListener(
v -> {
AppUtil.openUrlInBrowser(requireContext(), getString(R.string.crowdInLink));
dismiss();
});
binding.appWebsite.setOnClickListener(
v -> {
AppUtil.openUrlInBrowser(
requireContext(), getResources().getString(R.string.crowdInLink)));
requireContext(), getString(R.string.appWebsiteLink));
dismiss();
});
aboutAppDialogBinding.appWebsite.setOnClickListener(
v14 ->
binding.feedback.setOnClickListener(
v -> {
AppUtil.openUrlInBrowser(
requireContext(),
getResources().getString(R.string.appWebsiteLink)));
requireContext(), getString(R.string.feedbackLink));
dismiss();
});
aboutAppDialogBinding.feedback.setOnClickListener(
v14 ->
AppUtil.openUrlInBrowser(
requireContext(), getResources().getString(R.string.feedbackLink)));
// Hide donation link for pro users
if (AppUtil.isPro(requireContext())) {
binding.layoutFrame1.setVisibility(View.GONE);
}
if (AppUtil.isPro(requireContext())) {
aboutAppDialogBinding.layoutFrame1.setVisibility(View.GONE);
return binding.getRoot();
}
materialAlertDialogBuilder.show();
@Override
public void onDestroyView() {
super.onDestroyView();
binding = null; // Prevent memory leaks
}
}
public void rateThisApp() {

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="@dimen/dimen2dp" />
<solid android:color="?attr/iconsColor" />
</shape>

View File

@@ -0,0 +1,211 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottom_sheet_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:behavior_peekHeight="auto">
<View
android:layout_width="@dimen/dimen32dp"
android:layout_height="@dimen/dimen6dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/dimen8dp"
android:background="@drawable/bottom_sheet_handle"
android:backgroundTint="?attr/primaryTextColor" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/dimen16dp">
<!-- App Logo -->
<com.google.android.material.card.MaterialCardView
style="?attr/materialCardViewFilledStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:cardCornerRadius="@dimen/dimen16dp">
<ImageView
android:id="@+id/appLogo"
android:layout_width="@dimen/dimen72dp"
android:layout_height="@dimen/dimen72dp"
android:contentDescription="@string/appName"
android:src="@drawable/gitnex" />
</com.google.android.material.card.MaterialCardView>
<!-- App Name and Version -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/dimen6dp"
android:text="@string/appName"
android:textColor="?attr/primaryTextColor"
android:textSize="@dimen/dimen24sp" />
<com.google.android.material.card.MaterialCardView
style="?attr/materialCardViewFilledStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/dimen6dp"
android:layout_marginBottom="@dimen/dimen32dp"
app:cardBackgroundColor="@color/colorWhite"
app:cardCornerRadius="@dimen/dimen36dp">
<TextView
android:id="@+id/appVersionBuild"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/appVersionBuild"
android:textColor="@color/retroThemeInputTextColor"
android:textIsSelectable="true"
android:padding="@dimen/dimen8dp"
android:textSize="@dimen/dimen14sp" />
</com.google.android.material.card.MaterialCardView>
<!-- Server Version -->
<com.google.android.material.card.MaterialCardView
style="?attr/materialCardViewFilledStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="?attr/materialCardBackgroundColor"
android:layout_margin="@dimen/dimen4dp"
app:cardCornerRadius="@dimen/dimen16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/dimen12dp">
<TextView
android:id="@+id/userServerVersionHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/commitPage"
android:textColor="?attr/primaryTextColor"
android:textSize="@dimen/dimen16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/userServerVersion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen4dp"
android:textColor="?attr/primaryTextColor"
android:textIsSelectable="true"
android:textSize="@dimen/dimen14sp" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<!-- Donation Link -->
<LinearLayout
android:id="@+id/layoutFrame1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen12dp"
android:orientation="horizontal">
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/donationLinkPatreon"
android:layout_width="match_parent"
android:layout_height="@dimen/dimen60dp"
android:layout_marginHorizontal="@dimen/dimen4dp"
android:stateListAnimator="@null"
android:text="@string/supportTextPatreon"
android:textStyle="bold"
android:contentDescription="@string/supportTextPatreon"
android:textColor="?attr/materialCardBackgroundColor"
app:iconTint="?attr/materialCardBackgroundColor"
android:backgroundTint="?attr/fabColor"
app:icon="@drawable/ic_patreon" />
</LinearLayout>
<!-- Translate Link -->
<LinearLayout
android:id="@+id/layoutFrame2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen12dp"
android:orientation="horizontal">
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/translateLink"
android:layout_width="match_parent"
android:layout_height="@dimen/dimen60dp"
android:layout_marginHorizontal="@dimen/dimen4dp"
android:stateListAnimator="@null"
android:text="@string/translateWithCrowdin"
android:textStyle="bold"
android:contentDescription="@string/translateWithCrowdin"
android:textColor="?attr/materialCardBackgroundColor"
app:iconTint="?attr/materialCardBackgroundColor"
android:backgroundTint="?attr/fabColor"
app:icon="@drawable/ic_language" />
</LinearLayout>
<!-- Website Link -->
<LinearLayout
android:id="@+id/layoutFrame4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen12dp"
android:orientation="horizontal">
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/appWebsite"
android:layout_width="match_parent"
android:layout_height="@dimen/dimen60dp"
android:layout_marginHorizontal="@dimen/dimen4dp"
android:stateListAnimator="@null"
android:text="@string/websiteText"
android:textStyle="bold"
android:contentDescription="@string/websiteText"
android:textColor="?attr/materialCardBackgroundColor"
app:iconTint="?attr/materialCardBackgroundColor"
android:backgroundTint="?attr/fabColor"
app:icon="@drawable/ic_browser" />
</LinearLayout>
<!-- Feedback Link -->
<LinearLayout
android:id="@+id/layoutFrame3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen12dp"
android:visibility="gone"
android:orientation="horizontal">
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/feedback"
android:layout_width="match_parent"
android:layout_height="@dimen/dimen60dp"
android:layout_marginHorizontal="@dimen/dimen4dp"
android:stateListAnimator="@null"
android:text="@string/feedbackText"
android:textStyle="bold"
android:contentDescription="@string/feedbackText"
android:textColor="?attr/materialCardBackgroundColor"
app:iconTint="?attr/materialCardBackgroundColor"
android:backgroundTint="?attr/fabColor"
app:icon="@drawable/ic_feedback" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

View File

@@ -1,235 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="none">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dimen16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:orientation="vertical"
tools:ignore="UselessParent">
<com.google.android.material.card.MaterialCardView
style="?attr/materialCardViewFilledStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:cardCornerRadius="@dimen/dimen16dp">
<ImageView
android:id="@+id/appLogo"
android:layout_width="@dimen/dimen72dp"
android:layout_height="@dimen/dimen72dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:contentDescription="@string/appName"
android:src="@drawable/gitnex" />
</com.google.android.material.card.MaterialCardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen8dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/dimen6dp"
android:text="@string/appName"
android:textColor="?attr/primaryTextColor"
android:textSize="@dimen/dimen24sp" />
<com.google.android.material.card.MaterialCardView
style="?attr/materialCardViewFilledStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/dimen6dp"
app:cardBackgroundColor="@color/colorWhite"
app:cardCornerRadius="@dimen/dimen36dp">
<TextView
android:id="@+id/appVersionBuild"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/appVersionBuild"
android:textColor="@color/retroThemeInputTextColor"
android:textIsSelectable="true"
android:paddingTop="@dimen/dimen8dp"
android:paddingBottom="@dimen/dimen8dp"
android:paddingStart="@dimen/dimen10dp"
android:paddingEnd="@dimen/dimen10dp"
android:textSize="@dimen/dimen14sp" />
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen24dp"
android:orientation="vertical">
<!-- user server version -->
<com.google.android.material.card.MaterialCardView
style="?attr/materialCardViewFilledStyle"
android:layout_width="match_parent"
android:layout_height="@dimen/dimen72dp"
android:layout_gravity="center_horizontal"
app:cardBackgroundColor="?attr/materialCardBackgroundColor"
app:cardCornerRadius="@dimen/dimen16dp">
<TextView
android:id="@+id/userServerVersionHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/dimen12dp"
android:text="@string/commitPage"
android:textColor="?attr/primaryTextColor"
android:textSize="@dimen/dimen16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/userServerVersion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen28dp"
android:padding="@dimen/dimen12dp"
android:textColor="?attr/primaryTextColor"
android:textIsSelectable="true"
android:textSize="@dimen/dimen14sp" />
</com.google.android.material.card.MaterialCardView>
<!-- donate text -->
<LinearLayout
android:id="@+id/layout_frame_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen12dp"
android:orientation="horizontal">
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/donationLinkPatreon"
android:layout_width="match_parent"
android:layout_height="@dimen/dimen60dp"
android:layout_marginEnd="@dimen/dimen4dp"
android:layout_marginStart="@dimen/dimen4dp"
android:stateListAnimator="@null"
android:text="@string/supportTextPatreon"
android:textStyle="bold"
android:contentDescription="@string/supportTextPatreon"
android:textColor="?attr/materialCardBackgroundColor"
app:iconTint="?attr/materialCardBackgroundColor"
android:backgroundTint="?attr/fabColor"
app:icon="@drawable/ic_patreon" />
</LinearLayout>
<!-- translate text -->
<LinearLayout
android:id="@+id/layout_frame_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen12dp"
android:orientation="horizontal">
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/translateLink"
android:layout_width="match_parent"
android:layout_height="@dimen/dimen60dp"
android:layout_marginEnd="@dimen/dimen4dp"
android:layout_marginStart="@dimen/dimen4dp"
android:stateListAnimator="@null"
android:text="@string/translateWithCrowdin"
android:textStyle="bold"
android:contentDescription="@string/translateWithCrowdin"
android:textColor="?attr/materialCardBackgroundColor"
app:iconTint="?attr/materialCardBackgroundColor"
android:backgroundTint="?attr/fabColor"
app:icon="@drawable/ic_language" />
</LinearLayout>
<!-- website text -->
<LinearLayout
android:id="@+id/layout_frame_4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen12dp"
android:orientation="horizontal">
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/appWebsite"
android:layout_width="match_parent"
android:layout_height="@dimen/dimen60dp"
android:layout_marginEnd="@dimen/dimen4dp"
android:layout_marginStart="@dimen/dimen4dp"
android:stateListAnimator="@null"
android:text="@string/websiteText"
android:textStyle="bold"
android:contentDescription="@string/websiteText"
android:textColor="?attr/materialCardBackgroundColor"
app:iconTint="?attr/materialCardBackgroundColor"
android:backgroundTint="?attr/fabColor"
app:icon="@drawable/ic_browser" />
</LinearLayout>
<!-- feedback text -->
<LinearLayout
android:id="@+id/layout_frame_3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen12dp"
android:visibility="gone"
android:orientation="horizontal">
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/feedback"
android:layout_width="@dimen/dimen0dp"
android:layout_height="@dimen/dimen60dp"
android:layout_marginEnd="@dimen/dimen4dp"
android:layout_marginStart="@dimen/dimen0dp"
android:layout_weight=".5"
android:stateListAnimator="@null"
android:text="@string/feedbackText"
android:textStyle="bold"
android:contentDescription="@string/feedbackText"
android:textColor="?attr/materialCardBackgroundColor"
app:iconTint="?attr/materialCardBackgroundColor"
android:backgroundTint="?attr/fabColor"
app:icon="@drawable/ic_feedback" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_weight=".5" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>

View File

@@ -65,12 +65,6 @@
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_chevron_right"/>
</LinearLayout>
<LinearLayout
@@ -120,12 +114,6 @@
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_chevron_right"/>
</LinearLayout>
<LinearLayout
@@ -175,12 +163,6 @@
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_chevron_right" />
</LinearLayout>
<LinearLayout
@@ -230,12 +212,6 @@
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_chevron_right" />
</LinearLayout>
<LinearLayout
@@ -285,12 +261,6 @@
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_chevron_right" />
</LinearLayout>
<LinearLayout
@@ -340,12 +310,6 @@
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_chevron_right" />
</LinearLayout>
<LinearLayout