Merge branch 'improve_polls' into develop
This commit is contained in:
commit
c50bd79cb7
|
@ -1517,11 +1517,11 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
|
|||
toot_it.setEnabled(true);
|
||||
return;
|
||||
}
|
||||
if( poll != null && visibility.equals("direct")){
|
||||
/*if( poll != null && visibility.equals("direct")){
|
||||
Toasty.error(getApplicationContext(),getString(R.string.poll_not_private),Toast.LENGTH_LONG).show();
|
||||
toot_it.setEnabled(true);
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
boolean split_toot = sharedpreferences.getBoolean(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS, false);
|
||||
int split_toot_size = sharedpreferences.getInt(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS_SIZE, Helper.SPLIT_TOOT_SIZE);
|
||||
|
|
|
@ -574,46 +574,23 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
holder.choices.init(context).hasAnimation(true).addAll(items).build();
|
||||
}else {
|
||||
if( poll.isMultiple()){
|
||||
if((holder.multiple_choice).getChildCount() > 0)
|
||||
(holder.multiple_choice).removeAllViews();
|
||||
for(PollOptions pollOption: poll.getOptionsList()){
|
||||
CheckBox cb = new CheckBox(context);
|
||||
cb.setText(pollOption.getTitle());
|
||||
holder.multiple_choice.addView(cb);
|
||||
}
|
||||
holder.multiple_choice.setVisibility(View.VISIBLE);
|
||||
holder.c_choice_3.setVisibility(View.GONE);
|
||||
holder.c_choice_4.setVisibility(View.GONE);
|
||||
if( choiceCount > 2)
|
||||
holder.c_choice_3.setVisibility(View.VISIBLE);
|
||||
if( choiceCount > 3)
|
||||
holder.c_choice_4.setVisibility(View.VISIBLE);
|
||||
int j = 1;
|
||||
for(PollOptions pollOption: status.getPoll().getOptionsList()){
|
||||
if( j == 1 )
|
||||
holder.c_choice_1.setText(pollOption.getTitle());
|
||||
else if( j == 2 )
|
||||
holder.c_choice_2.setText(pollOption.getTitle());
|
||||
else if( j == 3 )
|
||||
holder.c_choice_3.setText(pollOption.getTitle());
|
||||
else if( j == 4 )
|
||||
holder.c_choice_4.setText(pollOption.getTitle());
|
||||
j++;
|
||||
}
|
||||
|
||||
}else {
|
||||
holder.single_choice.setVisibility(View.VISIBLE);
|
||||
holder.r_choice_3.setVisibility(View.GONE);
|
||||
holder.r_choice_4.setVisibility(View.GONE);
|
||||
if( choiceCount > 2)
|
||||
holder.r_choice_3.setVisibility(View.VISIBLE);
|
||||
if( choiceCount > 3)
|
||||
holder.r_choice_4.setVisibility(View.VISIBLE);
|
||||
int j = 1;
|
||||
for(PollOptions pollOption: status.getPoll().getOptionsList()){
|
||||
if( j == 1 )
|
||||
holder.r_choice_1.setText(pollOption.getTitle());
|
||||
else if( j == 2 )
|
||||
holder.r_choice_2.setText(pollOption.getTitle());
|
||||
else if( j == 3 )
|
||||
holder.r_choice_3.setText(pollOption.getTitle());
|
||||
else if( j == 4 )
|
||||
holder.r_choice_4.setText(pollOption.getTitle());
|
||||
j++;
|
||||
if((holder.radio_group).getChildCount() > 0)
|
||||
(holder.radio_group).removeAllViews();
|
||||
for(PollOptions pollOption: poll.getOptionsList()){
|
||||
RadioButton rb = new RadioButton(context);
|
||||
rb.setText(pollOption.getTitle());
|
||||
holder.radio_group.addView(rb);
|
||||
}
|
||||
holder.single_choice.setVisibility(View.VISIBLE);
|
||||
}
|
||||
holder.submit_vote.setVisibility(View.VISIBLE);
|
||||
holder.submit_vote.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -622,14 +599,14 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
int [] choice;
|
||||
if( poll.isMultiple()){
|
||||
ArrayList<Integer> choices = new ArrayList<>();
|
||||
if( holder.c_choice_1.isChecked())
|
||||
choices.add(0);
|
||||
if( holder.c_choice_2.isChecked())
|
||||
choices.add(1);
|
||||
if( holder.c_choice_3.isChecked())
|
||||
choices.add(2);
|
||||
if( holder.c_choice_4.isChecked())
|
||||
choices.add(3);
|
||||
int choicesCount = holder.multiple_choice.getChildCount();
|
||||
for( int i = 0 ; i < choicesCount ; i++){
|
||||
if( holder.multiple_choice.getChildAt(i) != null && holder.multiple_choice.getChildAt(i) instanceof CheckBox){
|
||||
if(((CheckBox) holder.multiple_choice.getChildAt(i)).isChecked()){
|
||||
choices.add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
choice = new int[choices.size()];
|
||||
Iterator<Integer> iterator = choices.iterator();
|
||||
for (int i = 0; i < choice.length; i++) {
|
||||
|
@ -640,15 +617,14 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
}else{
|
||||
choice = new int[1];
|
||||
choice[0] = -1;
|
||||
int checkedId = holder.radio_group.getCheckedRadioButtonId();
|
||||
if( checkedId == R.id.r_choice_1)
|
||||
choice[0] = 0;
|
||||
if( checkedId == R.id.r_choice_2)
|
||||
choice[0] = 1;
|
||||
if( checkedId == R.id.r_choice_3)
|
||||
choice[0] = 2;
|
||||
if( checkedId == R.id.r_choice_4)
|
||||
choice[0] = 3;
|
||||
int choicesCount = holder.radio_group.getChildCount();
|
||||
for( int i = 0 ; i < choicesCount ; i++){
|
||||
if( holder.radio_group.getChildAt(i) != null && holder.radio_group.getChildAt(i) instanceof RadioButton){
|
||||
if(((RadioButton) holder.radio_group.getChildAt(i)).isChecked()){
|
||||
choice[0] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( choice[0] == -1)
|
||||
return;
|
||||
}
|
||||
|
@ -1371,8 +1347,6 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
//Poll
|
||||
LinearLayout poll_container, single_choice, multiple_choice, rated;
|
||||
RadioGroup radio_group;
|
||||
RadioButton r_choice_1, r_choice_2, r_choice_3, r_choice_4;
|
||||
CheckBox c_choice_1, c_choice_2, c_choice_3, c_choice_4;
|
||||
HorizontalBar choices;
|
||||
TextView number_votes, remaining_time;
|
||||
Button submit_vote, refresh_poll;
|
||||
|
@ -1425,14 +1399,6 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
multiple_choice = itemView.findViewById(R.id.multiple_choice);
|
||||
rated = itemView.findViewById(R.id.rated);
|
||||
radio_group = itemView.findViewById(R.id.radio_group);
|
||||
r_choice_1 = itemView.findViewById(R.id.r_choice_1);
|
||||
r_choice_2 = itemView.findViewById(R.id.r_choice_2);
|
||||
r_choice_3 = itemView.findViewById(R.id.r_choice_3);
|
||||
r_choice_4 = itemView.findViewById(R.id.r_choice_4);
|
||||
c_choice_1 = itemView.findViewById(R.id.c_choice_1);
|
||||
c_choice_2 = itemView.findViewById(R.id.c_choice_2);
|
||||
c_choice_3 = itemView.findViewById(R.id.c_choice_3);
|
||||
c_choice_4 = itemView.findViewById(R.id.c_choice_4);
|
||||
choices = itemView.findViewById(R.id.choices);
|
||||
number_votes = itemView.findViewById(R.id.number_votes);
|
||||
remaining_time = itemView.findViewById(R.id.remaining_time);
|
||||
|
|
|
@ -355,8 +355,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
//Poll
|
||||
LinearLayout poll_container, single_choice, multiple_choice, rated;
|
||||
RadioGroup radio_group;
|
||||
RadioButton r_choice_1, r_choice_2, r_choice_3, r_choice_4;
|
||||
CheckBox c_choice_1, c_choice_2, c_choice_3, c_choice_4;
|
||||
|
||||
HorizontalBar choices;
|
||||
TextView number_votes, remaining_time;
|
||||
Button submit_vote, refresh_poll;
|
||||
|
@ -454,14 +453,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
multiple_choice = itemView.findViewById(R.id.multiple_choice);
|
||||
rated = itemView.findViewById(R.id.rated);
|
||||
radio_group = itemView.findViewById(R.id.radio_group);
|
||||
r_choice_1 = itemView.findViewById(R.id.r_choice_1);
|
||||
r_choice_2 = itemView.findViewById(R.id.r_choice_2);
|
||||
r_choice_3 = itemView.findViewById(R.id.r_choice_3);
|
||||
r_choice_4 = itemView.findViewById(R.id.r_choice_4);
|
||||
c_choice_1 = itemView.findViewById(R.id.c_choice_1);
|
||||
c_choice_2 = itemView.findViewById(R.id.c_choice_2);
|
||||
c_choice_3 = itemView.findViewById(R.id.c_choice_3);
|
||||
c_choice_4 = itemView.findViewById(R.id.c_choice_4);
|
||||
choices = itemView.findViewById(R.id.choices);
|
||||
number_votes = itemView.findViewById(R.id.number_votes);
|
||||
remaining_time = itemView.findViewById(R.id.remaining_time);
|
||||
|
@ -605,46 +596,25 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
holder.choices.init(context).hasAnimation(true).addAll(items).build();
|
||||
}else {
|
||||
if( poll.isMultiple()){
|
||||
holder.multiple_choice.setVisibility(View.VISIBLE);
|
||||
holder.c_choice_3.setVisibility(View.GONE);
|
||||
holder.c_choice_4.setVisibility(View.GONE);
|
||||
if( choiceCount > 2)
|
||||
holder.c_choice_3.setVisibility(View.VISIBLE);
|
||||
if( choiceCount > 3)
|
||||
holder.c_choice_4.setVisibility(View.VISIBLE);
|
||||
int j = 1;
|
||||
|
||||
if((holder.multiple_choice).getChildCount() > 0)
|
||||
(holder.multiple_choice).removeAllViews();
|
||||
for(PollOptions pollOption: poll.getOptionsList()){
|
||||
if( j == 1 )
|
||||
holder.c_choice_1.setText(pollOption.getTitle());
|
||||
else if( j == 2 )
|
||||
holder.c_choice_2.setText(pollOption.getTitle());
|
||||
else if( j == 3 )
|
||||
holder.c_choice_3.setText(pollOption.getTitle());
|
||||
else if( j == 4 )
|
||||
holder.c_choice_4.setText(pollOption.getTitle());
|
||||
j++;
|
||||
CheckBox cb = new CheckBox(context);
|
||||
cb.setText(pollOption.getTitle());
|
||||
holder.multiple_choice.addView(cb);
|
||||
}
|
||||
holder.multiple_choice.setVisibility(View.VISIBLE);
|
||||
|
||||
}else {
|
||||
holder.single_choice.setVisibility(View.VISIBLE);
|
||||
holder.r_choice_3.setVisibility(View.GONE);
|
||||
holder.r_choice_4.setVisibility(View.GONE);
|
||||
if( choiceCount > 2)
|
||||
holder.r_choice_3.setVisibility(View.VISIBLE);
|
||||
if( choiceCount > 3)
|
||||
holder.r_choice_4.setVisibility(View.VISIBLE);
|
||||
int j = 1;
|
||||
if((holder.radio_group).getChildCount() > 0)
|
||||
(holder.radio_group).removeAllViews();
|
||||
for(PollOptions pollOption: poll.getOptionsList()){
|
||||
if( j == 1 )
|
||||
holder.r_choice_1.setText(pollOption.getTitle());
|
||||
else if( j == 2 )
|
||||
holder.r_choice_2.setText(pollOption.getTitle());
|
||||
else if( j == 3 )
|
||||
holder.r_choice_3.setText(pollOption.getTitle());
|
||||
else if( j == 4 )
|
||||
holder.r_choice_4.setText(pollOption.getTitle());
|
||||
j++;
|
||||
RadioButton rb = new RadioButton(context);
|
||||
rb.setText(pollOption.getTitle());
|
||||
holder.radio_group.addView(rb);
|
||||
}
|
||||
holder.single_choice.setVisibility(View.VISIBLE);
|
||||
}
|
||||
holder.submit_vote.setVisibility(View.VISIBLE);
|
||||
holder.submit_vote.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -653,14 +623,14 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
int [] choice;
|
||||
if( poll.isMultiple()){
|
||||
ArrayList<Integer> choices = new ArrayList<>();
|
||||
if( holder.c_choice_1.isChecked())
|
||||
choices.add(0);
|
||||
if( holder.c_choice_2.isChecked())
|
||||
choices.add(1);
|
||||
if( holder.c_choice_3.isChecked())
|
||||
choices.add(2);
|
||||
if( holder.c_choice_4.isChecked())
|
||||
choices.add(3);
|
||||
int choicesCount = holder.multiple_choice.getChildCount();
|
||||
for( int i = 0 ; i < choicesCount ; i++){
|
||||
if( holder.multiple_choice.getChildAt(i) != null && holder.multiple_choice.getChildAt(i) instanceof CheckBox){
|
||||
if(((CheckBox) holder.multiple_choice.getChildAt(i)).isChecked()){
|
||||
choices.add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
choice = new int[choices.size()];
|
||||
Iterator<Integer> iterator = choices.iterator();
|
||||
for (int i = 0; i < choice.length; i++) {
|
||||
|
@ -670,16 +640,15 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
return;
|
||||
}else{
|
||||
choice = new int[1];
|
||||
int checkedId = holder.radio_group.getCheckedRadioButtonId();
|
||||
choice[0] = -1;
|
||||
if( checkedId == R.id.r_choice_1)
|
||||
choice[0] = 0;
|
||||
if( checkedId == R.id.r_choice_2)
|
||||
choice[0] = 1;
|
||||
if( checkedId == R.id.r_choice_3)
|
||||
choice[0] = 2;
|
||||
if( checkedId == R.id.r_choice_4)
|
||||
choice[0] = 3;
|
||||
int choicesCount = holder.radio_group.getChildCount();
|
||||
for( int i = 0 ; i < choicesCount ; i++){
|
||||
if( holder.radio_group.getChildAt(i) != null && holder.radio_group.getChildAt(i) instanceof RadioButton){
|
||||
if(((RadioButton) holder.radio_group.getChildAt(i)).isChecked()){
|
||||
choice[0] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( choice[0] == -1)
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -37,32 +37,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="UselessParent">
|
||||
<RadioButton
|
||||
android:id="@+id/r_choice_1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="false"
|
||||
/>
|
||||
<RadioButton
|
||||
android:id="@+id/r_choice_2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="false"
|
||||
/>
|
||||
<RadioButton
|
||||
android:id="@+id/r_choice_3"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="false"
|
||||
/>
|
||||
<RadioButton
|
||||
android:id="@+id/r_choice_4"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="false"
|
||||
/>
|
||||
|
||||
</RadioGroup>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
|
@ -71,24 +46,6 @@
|
|||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<CheckBox
|
||||
android:id="@+id/c_choice_1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<CheckBox
|
||||
android:id="@+id/c_choice_2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<CheckBox
|
||||
android:id="@+id/c_choice_3"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<CheckBox
|
||||
android:id="@+id/c_choice_4"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
Loading…
Reference in New Issue