mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-01-31 19:34:55 +01:00
poll dialog layout fix, added close button
This commit is contained in:
parent
6492cd311a
commit
7fbe672e74
@ -36,7 +36,9 @@ public class PollDialog extends Dialog implements OnClickListener {
|
||||
private PollUpdateCallback callback;
|
||||
private PollUpdate poll;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public PollDialog(@NonNull Context context, PollUpdateCallback callback) {
|
||||
super(context, R.style.PollDialog);
|
||||
this.callback = callback;
|
||||
@ -44,6 +46,7 @@ public class PollDialog extends Dialog implements OnClickListener {
|
||||
ViewGroup root = findViewById(R.id.dialog_poll_root);
|
||||
RecyclerView optionsList = findViewById(R.id.dialog_poll_option_list);
|
||||
Button confirm = findViewById(R.id.dialog_poll_create);
|
||||
View close = findViewById(R.id.dialog_poll_close);
|
||||
durationInput = findViewById(R.id.dialog_poll_duration_input);
|
||||
timeUnitSelector = findViewById(R.id.dialog_poll_duration_timeunit);
|
||||
multiple_choice = findViewById(R.id.dialog_poll_mul_choice);
|
||||
@ -61,6 +64,7 @@ public class PollDialog extends Dialog implements OnClickListener {
|
||||
AppStyles.setTheme(root);
|
||||
|
||||
confirm.setOnClickListener(this);
|
||||
close.setOnClickListener(this);
|
||||
}
|
||||
|
||||
|
||||
@ -95,10 +99,16 @@ public class PollDialog extends Dialog implements OnClickListener {
|
||||
poll.setOptions(optionAdapter.getOptions());
|
||||
callback.onPollUpdate(poll);
|
||||
dismiss();
|
||||
} else if (v.getId() == R.id.dialog_poll_close) {
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* show dialog
|
||||
*
|
||||
* @param poll previous poll information if any
|
||||
*/
|
||||
public void show(@Nullable PollUpdate poll) {
|
||||
if (!isShowing()) {
|
||||
if (poll != null) {
|
||||
@ -113,9 +123,14 @@ public class PollDialog extends Dialog implements OnClickListener {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* callback used to return poll information
|
||||
*/
|
||||
public interface PollUpdateCallback {
|
||||
|
||||
void onPollUpdate(@Nullable PollUpdate update);
|
||||
/**
|
||||
* @param update updated poll information
|
||||
*/
|
||||
void onPollUpdate(PollUpdate update);
|
||||
}
|
||||
}
|
@ -1,145 +1,129 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/dialog_poll_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/dialog_poll_root_layout_padding">
|
||||
android:padding="@dimen/dialog_poll_root_layout_padding"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialog_poll_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/dialog_poll_layout_margins"
|
||||
android:layout_marginEnd="@dimen/dialog_poll_layout_margins"
|
||||
android:text="@string/dialog_poll_title"
|
||||
android:textSize="@dimen/dialog_poll_title_textsize"
|
||||
android:textSize="@dimen/dialog_poll_textsize_big"
|
||||
android:lines="1"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/dialog_poll_option_list"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dialog_poll_close"
|
||||
android:layout_width="@dimen/dialog_poll_button_close_size"
|
||||
android:layout_height="@dimen/dialog_poll_button_close_size"
|
||||
android:src="@drawable/cross"
|
||||
android:contentDescription="@string/dialog_poll_close" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/dialog_poll_option_list"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dialog_poll_list_height"
|
||||
android:layout_marginBottom="@dimen/dialog_poll_layout_margins"
|
||||
android:layout_marginTop="@dimen/dialog_poll_layout_margins"
|
||||
android:orientation="vertical"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/dialog_poll_title"
|
||||
app:layout_constraintBottom_toTopOf="@id/dialog_poll_switch_barrier"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/dialog_poll_switch_barrier"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="top"
|
||||
app:constraint_referenced_ids="dialog_poll_mul_choice, dialog_poll_mul_choice_label, dialog_poll_hide_total, dialog_poll_hide_total_label"/>
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialog_poll_mul_choice_label"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="2"
|
||||
android:text="@string/dialog_poll_mc"
|
||||
android:lines="1"
|
||||
android:gravity="end"
|
||||
android:textSize="@dimen/dialog_poll_textsize_small"
|
||||
android:layout_marginEnd="@dimen/dialog_poll_layout_margins"
|
||||
app:layout_constraintHorizontal_weight="4"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/dialog_poll_mul_choice"
|
||||
app:layout_constraintBottom_toBottomOf="@id/dialog_poll_mul_choice"
|
||||
app:layout_constraintEnd_toStartOf="@id/dialog_poll_mul_choice" />
|
||||
android:layout_marginEnd="@dimen/dialog_poll_layout_margins"/>
|
||||
|
||||
<com.kyleduo.switchbutton.SwitchButton
|
||||
android:id="@+id/dialog_poll_mul_choice"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toEndOf="@id/dialog_poll_mul_choice_label"
|
||||
app:layout_constraintBottom_toTopOf="@id/dialog_poll_list_barrier"
|
||||
app:layout_constraintEnd_toStartOf="@id/dialog_poll_hide_total_label"/>
|
||||
android:layout_marginEnd="@dimen/dialog_poll_layout_margins"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialog_poll_hide_total_label"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/dialog_poll_hide"
|
||||
android:lines="1"
|
||||
android:gravity="end"
|
||||
android:textSize="@dimen/dialog_poll_textsize_small"
|
||||
android:layout_marginEnd="@dimen/dialog_poll_layout_margins"
|
||||
app:layout_constraintHorizontal_weight="3"
|
||||
app:layout_constraintStart_toEndOf="@id/dialog_poll_mul_choice"
|
||||
app:layout_constraintTop_toTopOf="@id/dialog_poll_hide_total"
|
||||
app:layout_constraintBottom_toBottomOf="@id/dialog_poll_hide_total"
|
||||
app:layout_constraintEnd_toStartOf="@id/dialog_poll_hide_total"/>
|
||||
android:textSize="@dimen/dialog_poll_textsize_small" />
|
||||
|
||||
<com.kyleduo.switchbutton.SwitchButton
|
||||
android:id="@+id/dialog_poll_hide_total"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toEndOf="@id/dialog_poll_hide_total_label"
|
||||
app:layout_constraintBottom_toTopOf="@id/dialog_poll_list_barrier"
|
||||
app:layout_constraintEnd_toStartOf="@id/dialog_poll_switch_placeholder"/>
|
||||
android:layout_marginStart="@dimen/dialog_poll_layout_margins"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/dialog_poll_switch_placeholder"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintHorizontal_weight="1"
|
||||
app:layout_constraintStart_toEndOf="@id/dialog_poll_hide_total"
|
||||
app:layout_constraintTop_toTopOf="@id/dialog_poll_hide_total"
|
||||
app:layout_constraintBottom_toTopOf="@id/dialog_poll_list_barrier"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"/>
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/dialog_poll_list_barrier"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="top"
|
||||
app:constraint_referenced_ids="dialog_poll_duration_input,dialog_poll_duration_timeunit,dialog_poll_create"/>
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/dialog_poll_duration_input"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@android:color/transparent"
|
||||
android:inputType="numberDecimal"
|
||||
android:maxLength="3"
|
||||
android:autofillHints=""
|
||||
android:hint="@string/dialog_poll_duration_hint"
|
||||
android:layout_marginStart="@dimen/dialog_poll_layout_margins"
|
||||
android:layout_marginEnd="@dimen/dialog_poll_layout_margins"
|
||||
android:textSize="@dimen/dialog_poll_textsize_medium"
|
||||
android:lines="1"
|
||||
app:layout_constraintHorizontal_weight="2"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/dialog_poll_list_barrier"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/dialog_poll_duration_timeunit" />
|
||||
android:gravity="end"/>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/dialog_poll_duration_timeunit"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintHorizontal_weight="3"
|
||||
app:layout_constraintStart_toEndOf="@id/dialog_poll_duration_input"
|
||||
app:layout_constraintTop_toBottomOf="@id/dialog_poll_list_barrier"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/dialog_poll_create" />
|
||||
android:layout_height="@dimen/dialog_poll_spinner_height"
|
||||
android:layout_weight="2"
|
||||
android:layout_marginEnd="@dimen/dialog_poll_layout_margins"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/dialog_poll_create"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/dialog_poll_button_height"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/dialog_poll_button"
|
||||
android:lines="1"
|
||||
app:layout_constraintHorizontal_weight="2"
|
||||
app:layout_constraintStart_toEndOf="@id/dialog_poll_duration_timeunit"
|
||||
app:layout_constraintTop_toBottomOf="@id/dialog_poll_list_barrier"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
style="@style/FeedbackButton" />
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
@ -246,8 +246,11 @@
|
||||
<dimen name="dialog_poll_root_layout_padding">5dp</dimen>
|
||||
<dimen name="dialog_poll_layout_margins">3dp</dimen>
|
||||
<dimen name="dialog_poll_textsize_small">12sp</dimen>
|
||||
<dimen name="dialog_poll_title_textsize">18sp</dimen>
|
||||
<dimen name="dialog_poll_textsize_medium">16sp</dimen>
|
||||
<dimen name="dialog_poll_textsize_big">18sp</dimen>
|
||||
<dimen name="dialog_poll_button_close_size">24sp</dimen>
|
||||
<dimen name="dialog_poll_button_height">20sp</dimen>
|
||||
<dimen name="dialog_poll_spinner_height">22sp</dimen>
|
||||
|
||||
<!--dimens of tabitem.xml-->
|
||||
<dimen name="tabitem_icon_size">22sp</dimen>
|
||||
|
@ -312,6 +312,7 @@
|
||||
<string name="login_network_selector_label">select network</string>
|
||||
<string name="login_network_settings">connection settings</string>
|
||||
<string name="poll_option_edit_button">add/remove</string>
|
||||
<string name="dialog_poll_close">close dialog</string>
|
||||
<string name="selector_minutes">Minutes</string>
|
||||
<string name="selector_hours">Hours</string>
|
||||
<string name="selector_days">Days</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user