Enable and disable group link options with first switch.
This commit is contained in:
parent
e3ce18fa3e
commit
20fe837022
8 changed files with 50 additions and 6 deletions
|
@ -18,6 +18,7 @@ import androidx.lifecycle.ViewModelProviders;
|
|||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.util.ThemeUtil;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
import org.thoughtcrime.securesms.util.views.SimpleProgressDialog;
|
||||
|
||||
public final class ShareableGroupLinkDialogFragment extends DialogFragment {
|
||||
|
@ -78,6 +79,8 @@ public final class ShareableGroupLinkDialogFragment extends DialogFragment {
|
|||
View shareRow = view.findViewById(R.id.shareable_group_link_share_row);
|
||||
View resetLinkRow = view.findViewById(R.id.shareable_group_link_reset_link_row);
|
||||
View approveNewMembersRow = view.findViewById(R.id.shareable_group_link_approve_new_members_row);
|
||||
View membersSectionHeader = view.findViewById(R.id.shareable_group_link_member_requests_section_header);
|
||||
View descriptionRow = view.findViewById(R.id.shareable_group_link_display_row2);
|
||||
|
||||
Toolbar toolbar = view.findViewById(R.id.shareable_group_link_toolbar);
|
||||
|
||||
|
@ -87,6 +90,13 @@ public final class ShareableGroupLinkDialogFragment extends DialogFragment {
|
|||
shareableGroupLinkSwitch.setChecked(groupLink.isEnabled());
|
||||
approveNewMembersSwitch.setChecked(groupLink.isRequiresApproval());
|
||||
shareableGroupLinkDisplay.setText(formatForFullWidthWrapping(groupLink.getUrl()));
|
||||
|
||||
ViewUtil.setEnabledRecursive(shareableGroupLinkDisplay, groupLink.isEnabled());
|
||||
ViewUtil.setEnabledRecursive(shareRow, groupLink.isEnabled());
|
||||
ViewUtil.setEnabledRecursive(resetLinkRow, groupLink.isEnabled());
|
||||
ViewUtil.setEnabledRecursive(membersSectionHeader, groupLink.isEnabled());
|
||||
ViewUtil.setEnabledRecursive(approveNewMembersRow, groupLink.isEnabled());
|
||||
ViewUtil.setEnabledRecursive(descriptionRow, groupLink.isEnabled());
|
||||
});
|
||||
|
||||
shareRow.setOnClickListener(v -> GroupLinkBottomSheetDialogFragment.show(requireFragmentManager(), groupId));
|
||||
|
|
|
@ -263,4 +263,17 @@ public final class ViewUtil {
|
|||
InputMethodManager inputManager = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||
inputManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables a view and all child views recursively.
|
||||
*/
|
||||
public static void setEnabledRecursive(@NonNull View view, boolean enabled) {
|
||||
view.setEnabled(enabled);
|
||||
if (view instanceof ViewGroup) {
|
||||
ViewGroup viewGroup = (ViewGroup) view;
|
||||
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
||||
setEnabledRecursive(viewGroup.getChildAt(i), enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="?title_text_color_disabled" android:state_enabled="false" />
|
||||
<item android:color="?colorAccent" />
|
||||
</selector>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="?title_text_color_disabled" android:state_enabled="false" />
|
||||
<item android:color="?title_text_color_primary" />
|
||||
</selector>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="?title_text_color_disabled" android:state_enabled="false" />
|
||||
<item android:color="?title_text_color_secondary" />
|
||||
</selector>
|
|
@ -90,7 +90,7 @@
|
|||
android:text="@string/ShareableGroupLinkDialogFragment__share"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAppearance="@style/TextAppearance.Signal.Body2"
|
||||
android:textColor="?title_text_color_secondary"
|
||||
android:textColor="@color/text_color_secondary_enabled_selector"
|
||||
tools:text="https://signal.group/#CjQKIKUBM1ER-gTjdWwktuuHJk4t-2Iujh0zkXl2VBB3bASIEhDwi34i-5OMAl5sFYt9VElW" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -115,12 +115,13 @@
|
|||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:drawablePadding="8dp"
|
||||
android:drawableTint="@color/text_color_primary_enabled_selector"
|
||||
android:enabled="false"
|
||||
android:gravity="center_vertical|start"
|
||||
android:text="@string/ShareableGroupLinkDialogFragment__share"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAppearance="@style/TextAppearance.Signal.Body2"
|
||||
android:textColor="?title_text_color_primary"
|
||||
android:textColor="@color/text_color_primary_enabled_selector"
|
||||
app:drawableStartCompat="?share_icon" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -145,12 +146,13 @@
|
|||
android:layout_gravity="center"
|
||||
android:layout_weight="1"
|
||||
android:drawablePadding="8dp"
|
||||
android:drawableTint="@color/text_color_primary_enabled_selector"
|
||||
android:enabled="false"
|
||||
android:gravity="center_vertical|start"
|
||||
android:text="@string/ShareableGroupLinkDialogFragment__reset_link"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAppearance="@style/TextAppearance.Signal.Body2"
|
||||
android:textColor="?title_text_color_primary"
|
||||
android:textColor="@color/text_color_primary_enabled_selector"
|
||||
app:drawableStartCompat="?reset_link_icon" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -163,7 +165,7 @@
|
|||
android:layout_marginTop="36dp"
|
||||
android:text="@string/ShareableGroupLinkDialogFragment__member_requests"
|
||||
android:textAppearance="@style/TextAppearance.Signal.Body2.Bold"
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:textColor="@color/text_color_accent_enabled_selector"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/shareable_group_link_reset_link_row" />
|
||||
|
@ -189,7 +191,8 @@
|
|||
android:gravity="center_vertical|start"
|
||||
android:text="@string/ShareableGroupLinkDialogFragment__approve_new_members"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAppearance="@style/TextAppearance.Signal.Body2" />
|
||||
android:textAppearance="@style/TextAppearance.Signal.Body2"
|
||||
android:textColor="@color/text_color_primary_enabled_selector" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/shareable_group_link_approve_new_members_switch"
|
||||
|
@ -226,7 +229,7 @@
|
|||
android:text="@string/ShareableGroupLinkDialogFragment__require_an_admin_to_approve_new_members_joining_via_the_group_link"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAppearance="@style/TextAppearance.Signal.Body2"
|
||||
android:textColor="?title_text_color_secondary" />
|
||||
android:textColor="@color/text_color_secondary_enabled_selector" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
<attr name="title_text_color_primary" format="color"/>
|
||||
<attr name="title_text_color_secondary" format="color"/>
|
||||
<attr name="title_text_color_disabled" format="color"/>
|
||||
|
||||
<attr name="attachment_type_selector_background" format="color"/>
|
||||
<attr name="attachment_document_icon_small" format="reference" />
|
||||
|
|
|
@ -172,6 +172,7 @@
|
|||
|
||||
<item name="title_text_color_primary">@color/core_grey_90</item>
|
||||
<item name="title_text_color_secondary">@color/core_grey_60</item>
|
||||
<item name="title_text_color_disabled">@color/core_grey_25</item>
|
||||
|
||||
<item name="bottomSheetDialogTheme">@style/Theme.Design.Light.BottomSheetDialog</item>
|
||||
|
||||
|
@ -510,6 +511,7 @@
|
|||
|
||||
<item name="title_text_color_primary">@color/core_grey_05</item>
|
||||
<item name="title_text_color_secondary">@color/core_grey_25</item>
|
||||
<item name="title_text_color_disabled">@color/core_grey_60</item>
|
||||
|
||||
<item name="bottomSheetDialogTheme">@style/Theme.Design.BottomSheetDialog</item>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue