mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Add ability to add private group test data in settings
This commit is contained in:
committed by
ialokim
parent
f8015272f4
commit
0eb0bbdc99
@@ -24,9 +24,10 @@ public class TestDataActivity extends BriarActivity {
|
||||
@Inject
|
||||
TestDataCreator testDataCreator;
|
||||
|
||||
private TextView contactsTextView, forumsTextView;
|
||||
private TextView contactsTextView, forumsTextView, privateGroupsTextView;
|
||||
private SeekBar contactsSeekBar, messagesSeekBar, avatarsSeekBar,
|
||||
blogPostsSeekBar, forumsSeekBar, forumPostsSeekBar;
|
||||
blogPostsSeekBar, forumsSeekBar, forumPostsSeekBar,
|
||||
privateGroupsSeekBar, privateGroupPostsSeekBar;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
@@ -46,28 +47,26 @@ public class TestDataActivity extends BriarActivity {
|
||||
forumsTextView = findViewById(R.id.TextViewForumsSb);
|
||||
TextView forumPostsTextView =
|
||||
findViewById(R.id.TextViewForumMessagesSb);
|
||||
privateGroupsTextView = findViewById(R.id.TextViewPrivateGroupsSb);
|
||||
TextView privateGroupPostsTextView =
|
||||
findViewById(R.id.TextViewPrivateGroupMessagesSb);
|
||||
contactsSeekBar = findViewById(R.id.seekBarContacts);
|
||||
messagesSeekBar = findViewById(R.id.seekBarMessages);
|
||||
avatarsSeekBar = findViewById(R.id.seekBarAvatars);
|
||||
blogPostsSeekBar = findViewById(R.id.seekBarBlogPosts);
|
||||
forumsSeekBar = findViewById(R.id.seekBarForums);
|
||||
forumPostsSeekBar = findViewById(R.id.seekBarForumMessages);
|
||||
privateGroupsSeekBar = findViewById(R.id.seekBarPrivateGroups);
|
||||
privateGroupPostsSeekBar =
|
||||
findViewById(R.id.seekBarPrivateGroupMessages);
|
||||
|
||||
contactsSeekBar
|
||||
.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
||||
contactsSeekBar.setOnSeekBarChangeListener(
|
||||
new AbstractOnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar,
|
||||
int progress, boolean fromUser) {
|
||||
public void onProgressChanged(SeekBar seekBar, int progress,
|
||||
boolean fromUser) {
|
||||
contactsTextView.setText(String.valueOf(progress + 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
});
|
||||
|
||||
messagesSeekBar.setOnSeekBarChangeListener(
|
||||
@@ -76,35 +75,39 @@ public class TestDataActivity extends BriarActivity {
|
||||
new OnSeekBarChangeUpdateProgress(avatarsTextView));
|
||||
blogPostsSeekBar.setOnSeekBarChangeListener(
|
||||
new OnSeekBarChangeUpdateProgress(blogPostsTextView));
|
||||
forumsSeekBar
|
||||
.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
||||
forumsSeekBar.setOnSeekBarChangeListener(
|
||||
new AbstractOnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar,
|
||||
int progress, boolean fromUser) {
|
||||
public void onProgressChanged(SeekBar seekBar, int progress,
|
||||
boolean fromUser) {
|
||||
forumsTextView.setText(String.valueOf(progress));
|
||||
forumPostsSeekBar.setEnabled(progress > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
});
|
||||
forumPostsSeekBar.setOnSeekBarChangeListener(
|
||||
new OnSeekBarChangeUpdateProgress(forumPostsTextView));
|
||||
|
||||
findViewById(R.id.buttonZeroValues).setOnClickListener(
|
||||
v -> {
|
||||
contactsSeekBar.setProgress(0);
|
||||
messagesSeekBar.setProgress(0);
|
||||
avatarsSeekBar.setProgress(0);
|
||||
blogPostsSeekBar.setProgress(0);
|
||||
forumsSeekBar.setProgress(0);
|
||||
forumPostsSeekBar.setProgress(0);
|
||||
privateGroupsSeekBar.setOnSeekBarChangeListener(
|
||||
new AbstractOnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress,
|
||||
boolean fromUser) {
|
||||
privateGroupsTextView.setText(String.valueOf(progress));
|
||||
privateGroupPostsSeekBar.setEnabled(progress > 0);
|
||||
}
|
||||
});
|
||||
privateGroupPostsSeekBar.setOnSeekBarChangeListener(
|
||||
new OnSeekBarChangeUpdateProgress(privateGroupPostsTextView));
|
||||
|
||||
findViewById(R.id.buttonZeroValues).setOnClickListener(v -> {
|
||||
contactsSeekBar.setProgress(0);
|
||||
messagesSeekBar.setProgress(0);
|
||||
avatarsSeekBar.setProgress(0);
|
||||
blogPostsSeekBar.setProgress(0);
|
||||
forumsSeekBar.setProgress(0);
|
||||
forumPostsSeekBar.setProgress(0);
|
||||
privateGroupsSeekBar.setProgress(0);
|
||||
privateGroupPostsSeekBar.setProgress(0);
|
||||
});
|
||||
|
||||
findViewById(R.id.buttonCreateTestData).setOnClickListener(
|
||||
v -> createTestData());
|
||||
@@ -114,7 +117,9 @@ public class TestDataActivity extends BriarActivity {
|
||||
testDataCreator.createTestData(contactsSeekBar.getProgress() + 1,
|
||||
messagesSeekBar.getProgress(), avatarsSeekBar.getProgress(),
|
||||
blogPostsSeekBar.getProgress(), forumsSeekBar.getProgress(),
|
||||
forumPostsSeekBar.getProgress());
|
||||
forumPostsSeekBar.getProgress(),
|
||||
privateGroupsSeekBar.getProgress(),
|
||||
privateGroupPostsSeekBar.getProgress());
|
||||
Intent intent = new Intent(this, ENTRY_ACTIVITY);
|
||||
intent.addFlags(FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
@@ -136,7 +141,7 @@ public class TestDataActivity extends BriarActivity {
|
||||
}
|
||||
|
||||
private static class OnSeekBarChangeUpdateProgress
|
||||
implements OnSeekBarChangeListener {
|
||||
extends AbstractOnSeekBarChangeListener {
|
||||
private final TextView textView;
|
||||
|
||||
private OnSeekBarChangeUpdateProgress(TextView textView) {
|
||||
@@ -148,7 +153,10 @@ public class TestDataActivity extends BriarActivity {
|
||||
boolean fromUser) {
|
||||
textView.setText(String.valueOf(progress));
|
||||
}
|
||||
}
|
||||
|
||||
private abstract static class AbstractOnSeekBarChangeListener
|
||||
implements OnSeekBarChangeListener {
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
@@ -157,5 +165,4 @@ public class TestDataActivity extends BriarActivity {
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -191,6 +191,66 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textViewForumMessages" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewPrivateGroups"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin_medium"
|
||||
android:text="Number of private groups"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/seekBarForumMessages" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/seekBarPrivateGroups"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:max="50"
|
||||
android:paddingTop="5dp"
|
||||
android:progress="5"
|
||||
app:layout_constraintEnd_toStartOf="@+id/TextViewPrivateGroupsSb"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textViewPrivateGroups" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/TextViewPrivateGroupsSb"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="2"
|
||||
android:text="5"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/seekBarPrivateGroups"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textViewPrivateGroups" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewPrivateGroupMessages"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin_medium"
|
||||
android:text="Number of private group messages"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/seekBarPrivateGroups" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/seekBarPrivateGroupMessages"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:max="50"
|
||||
android:paddingTop="5dp"
|
||||
android:progress="20"
|
||||
app:layout_constraintEnd_toStartOf="@+id/TextViewPrivateGroupMessagesSb"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textViewPrivateGroupMessages" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/TextViewPrivateGroupMessagesSb"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="2"
|
||||
android:text="20"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/seekBarPrivateGroupMessages"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textViewPrivateGroupMessages" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonZeroValues"
|
||||
style="@style/BriarButton"
|
||||
@@ -201,7 +261,7 @@
|
||||
android:text="Zero values"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/seekBarForumMessages"
|
||||
app:layout_constraintTop_toBottomOf="@+id/seekBarPrivateGroupMessages"
|
||||
app:layout_constraintVertical_bias="1.0" />
|
||||
|
||||
<Button
|
||||
|
||||
@@ -470,10 +470,6 @@ public class TestDataCreatorImpl implements TestDataCreator {
|
||||
|
||||
private void createRandomForumPosts(Forum forum, List<Contact> contacts,
|
||||
int numForumPosts) throws DbException {
|
||||
if (contacts.isEmpty() && LOG.isLoggable(INFO)) {
|
||||
LOG.info("No forum posts created due to missing contacts.");
|
||||
return;
|
||||
}
|
||||
List<ForumPost> posts = new ArrayList<>();
|
||||
for (int i = 0; i < numForumPosts; i++) {
|
||||
Contact contact = contacts.get(random.nextInt(contacts.size()));
|
||||
@@ -522,11 +518,6 @@ public class TestDataCreatorImpl implements TestDataCreator {
|
||||
|
||||
private void createRandomPrivateGroupMessages(PrivateGroup group,
|
||||
List<Contact> contacts, int amount) throws DbException {
|
||||
if (contacts.isEmpty() && LOG.isLoggable(INFO)) {
|
||||
LOG.info("No private group messages created " +
|
||||
"due to missing contacts.");
|
||||
return;
|
||||
}
|
||||
List<GroupMessage> messages = new ArrayList<>();
|
||||
PrivateKey creatorPrivateKey =
|
||||
identityManager.getLocalAuthor().getPrivateKey();
|
||||
|
||||
Reference in New Issue
Block a user