mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-22 07:39:53 +01:00
get argument with number of custodians to thresholdselectorfragment
This commit is contained in:
@@ -37,6 +37,7 @@ public class CustodianSelectorFragment extends ContactSelectorFragment {
|
|||||||
|
|
||||||
public static CustodianSelectorFragment newInstance() {
|
public static CustodianSelectorFragment newInstance() {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
|
|
||||||
CustodianSelectorFragment fragment = new CustodianSelectorFragment();
|
CustodianSelectorFragment fragment = new CustodianSelectorFragment();
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
|
|
||||||
@@ -51,6 +52,7 @@ public class CustodianSelectorFragment extends ContactSelectorFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
requireActivity().setTitle(R.string.title_select_custodians);
|
requireActivity().setTitle(R.string.title_select_custodians);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ public class DistributedBackupActivity extends BriarActivity implements
|
|||||||
Toast.makeText(this,
|
Toast.makeText(this,
|
||||||
String.format("selected %d contacts", contacts.size()),
|
String.format("selected %d contacts", contacts.size()),
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
|
ThresholdSelectorFragment fragment = ThresholdSelectorFragment.newInstance(contacts.size());
|
||||||
ThresholdSelectorFragment fragment = new ThresholdSelectorFragment();
|
|
||||||
showNextFragment(fragment);
|
showNextFragment(fragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,11 +31,24 @@ public class ThresholdSelectorFragment extends BaseFragment {
|
|||||||
protected ThresholdDefinedListener listener;
|
protected ThresholdDefinedListener listener;
|
||||||
|
|
||||||
// TODO this should be the actual number of custodians
|
// TODO this should be the actual number of custodians
|
||||||
private int numberOfCustodians = 5;
|
private int numberOfCustodians;
|
||||||
private SeekBar seekBar;
|
private SeekBar seekBar;
|
||||||
private TextView thresholdRepresentation;
|
private TextView thresholdRepresentation;
|
||||||
private TextView message;
|
private TextView message;
|
||||||
|
|
||||||
|
public static ThresholdSelectorFragment newInstance(int numberCustodians) {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putInt("numberCustodians", numberCustodians);
|
||||||
|
ThresholdSelectorFragment fragment = new ThresholdSelectorFragment();
|
||||||
|
fragment.setArguments(bundle);
|
||||||
|
fragment.setNumberCustodians(numberCustodians);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setNumberCustodians(int numberCustodians) {
|
||||||
|
numberOfCustodians = numberCustodians;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -47,7 +60,9 @@ public class ThresholdSelectorFragment extends BaseFragment {
|
|||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_select_threshold,
|
View view = inflater.inflate(R.layout.fragment_select_threshold,
|
||||||
container, false);
|
container, false);
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
numberOfCustodians = savedInstanceState.getInt("numberCustodians");
|
||||||
|
}
|
||||||
seekBar = view.findViewById(R.id.seekBar);
|
seekBar = view.findViewById(R.id.seekBar);
|
||||||
thresholdRepresentation = view.findViewById(R.id.textViewThresholdRepresentation);
|
thresholdRepresentation = view.findViewById(R.id.textViewThresholdRepresentation);
|
||||||
message = view.findViewById(R.id.textViewMessage);
|
message = view.findViewById(R.id.textViewMessage);
|
||||||
@@ -97,10 +112,12 @@ public class ThresholdSelectorFragment extends BaseFragment {
|
|||||||
private String buildThresholdRepresentationString (int threshold) {
|
private String buildThresholdRepresentationString (int threshold) {
|
||||||
String thresholdRepresentationText = "";
|
String thresholdRepresentationText = "";
|
||||||
for (int i = 0; i < threshold; i++) {
|
for (int i = 0; i < threshold; i++) {
|
||||||
thresholdRepresentationText += R.string.filled_bullet;
|
// thresholdRepresentationText += R.string.filled_bullet;
|
||||||
|
thresholdRepresentationText += "1";
|
||||||
}
|
}
|
||||||
for (int i = 0; i < (numberOfCustodians - threshold); i++) {
|
for (int i = 0; i < (numberOfCustodians - threshold); i++) {
|
||||||
thresholdRepresentationText += R.string.linear_bullet;
|
// thresholdRepresentationText += R.string.linear_bullet;
|
||||||
|
thresholdRepresentationText += "0";
|
||||||
}
|
}
|
||||||
return thresholdRepresentationText;
|
return thresholdRepresentationText;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user