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
|
@Inject
|
||||||
TestDataCreator testDataCreator;
|
TestDataCreator testDataCreator;
|
||||||
|
|
||||||
private TextView contactsTextView, forumsTextView;
|
private TextView contactsTextView, forumsTextView, privateGroupsTextView;
|
||||||
private SeekBar contactsSeekBar, messagesSeekBar, avatarsSeekBar,
|
private SeekBar contactsSeekBar, messagesSeekBar, avatarsSeekBar,
|
||||||
blogPostsSeekBar, forumsSeekBar, forumPostsSeekBar;
|
blogPostsSeekBar, forumsSeekBar, forumPostsSeekBar,
|
||||||
|
privateGroupsSeekBar, privateGroupPostsSeekBar;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle bundle) {
|
public void onCreate(Bundle bundle) {
|
||||||
@@ -46,28 +47,26 @@ public class TestDataActivity extends BriarActivity {
|
|||||||
forumsTextView = findViewById(R.id.TextViewForumsSb);
|
forumsTextView = findViewById(R.id.TextViewForumsSb);
|
||||||
TextView forumPostsTextView =
|
TextView forumPostsTextView =
|
||||||
findViewById(R.id.TextViewForumMessagesSb);
|
findViewById(R.id.TextViewForumMessagesSb);
|
||||||
|
privateGroupsTextView = findViewById(R.id.TextViewPrivateGroupsSb);
|
||||||
|
TextView privateGroupPostsTextView =
|
||||||
|
findViewById(R.id.TextViewPrivateGroupMessagesSb);
|
||||||
contactsSeekBar = findViewById(R.id.seekBarContacts);
|
contactsSeekBar = findViewById(R.id.seekBarContacts);
|
||||||
messagesSeekBar = findViewById(R.id.seekBarMessages);
|
messagesSeekBar = findViewById(R.id.seekBarMessages);
|
||||||
avatarsSeekBar = findViewById(R.id.seekBarAvatars);
|
avatarsSeekBar = findViewById(R.id.seekBarAvatars);
|
||||||
blogPostsSeekBar = findViewById(R.id.seekBarBlogPosts);
|
blogPostsSeekBar = findViewById(R.id.seekBarBlogPosts);
|
||||||
forumsSeekBar = findViewById(R.id.seekBarForums);
|
forumsSeekBar = findViewById(R.id.seekBarForums);
|
||||||
forumPostsSeekBar = findViewById(R.id.seekBarForumMessages);
|
forumPostsSeekBar = findViewById(R.id.seekBarForumMessages);
|
||||||
|
privateGroupsSeekBar = findViewById(R.id.seekBarPrivateGroups);
|
||||||
|
privateGroupPostsSeekBar =
|
||||||
|
findViewById(R.id.seekBarPrivateGroupMessages);
|
||||||
|
|
||||||
contactsSeekBar
|
contactsSeekBar.setOnSeekBarChangeListener(
|
||||||
.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
new AbstractOnSeekBarChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(SeekBar seekBar,
|
public void onProgressChanged(SeekBar seekBar, int progress,
|
||||||
int progress, boolean fromUser) {
|
boolean fromUser) {
|
||||||
contactsTextView.setText(String.valueOf(progress + 1));
|
contactsTextView.setText(String.valueOf(progress + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
messagesSeekBar.setOnSeekBarChangeListener(
|
messagesSeekBar.setOnSeekBarChangeListener(
|
||||||
@@ -76,35 +75,39 @@ public class TestDataActivity extends BriarActivity {
|
|||||||
new OnSeekBarChangeUpdateProgress(avatarsTextView));
|
new OnSeekBarChangeUpdateProgress(avatarsTextView));
|
||||||
blogPostsSeekBar.setOnSeekBarChangeListener(
|
blogPostsSeekBar.setOnSeekBarChangeListener(
|
||||||
new OnSeekBarChangeUpdateProgress(blogPostsTextView));
|
new OnSeekBarChangeUpdateProgress(blogPostsTextView));
|
||||||
forumsSeekBar
|
forumsSeekBar.setOnSeekBarChangeListener(
|
||||||
.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
new AbstractOnSeekBarChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(SeekBar seekBar,
|
public void onProgressChanged(SeekBar seekBar, int progress,
|
||||||
int progress, boolean fromUser) {
|
boolean fromUser) {
|
||||||
forumsTextView.setText(String.valueOf(progress));
|
forumsTextView.setText(String.valueOf(progress));
|
||||||
forumPostsSeekBar.setEnabled(progress > 0);
|
forumPostsSeekBar.setEnabled(progress > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
forumPostsSeekBar.setOnSeekBarChangeListener(
|
forumPostsSeekBar.setOnSeekBarChangeListener(
|
||||||
new OnSeekBarChangeUpdateProgress(forumPostsTextView));
|
new OnSeekBarChangeUpdateProgress(forumPostsTextView));
|
||||||
|
privateGroupsSeekBar.setOnSeekBarChangeListener(
|
||||||
findViewById(R.id.buttonZeroValues).setOnClickListener(
|
new AbstractOnSeekBarChangeListener() {
|
||||||
v -> {
|
@Override
|
||||||
contactsSeekBar.setProgress(0);
|
public void onProgressChanged(SeekBar seekBar, int progress,
|
||||||
messagesSeekBar.setProgress(0);
|
boolean fromUser) {
|
||||||
avatarsSeekBar.setProgress(0);
|
privateGroupsTextView.setText(String.valueOf(progress));
|
||||||
blogPostsSeekBar.setProgress(0);
|
privateGroupPostsSeekBar.setEnabled(progress > 0);
|
||||||
forumsSeekBar.setProgress(0);
|
}
|
||||||
forumPostsSeekBar.setProgress(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(
|
findViewById(R.id.buttonCreateTestData).setOnClickListener(
|
||||||
v -> createTestData());
|
v -> createTestData());
|
||||||
@@ -114,7 +117,9 @@ public class TestDataActivity extends BriarActivity {
|
|||||||
testDataCreator.createTestData(contactsSeekBar.getProgress() + 1,
|
testDataCreator.createTestData(contactsSeekBar.getProgress() + 1,
|
||||||
messagesSeekBar.getProgress(), avatarsSeekBar.getProgress(),
|
messagesSeekBar.getProgress(), avatarsSeekBar.getProgress(),
|
||||||
blogPostsSeekBar.getProgress(), forumsSeekBar.getProgress(),
|
blogPostsSeekBar.getProgress(), forumsSeekBar.getProgress(),
|
||||||
forumPostsSeekBar.getProgress());
|
forumPostsSeekBar.getProgress(),
|
||||||
|
privateGroupsSeekBar.getProgress(),
|
||||||
|
privateGroupPostsSeekBar.getProgress());
|
||||||
Intent intent = new Intent(this, ENTRY_ACTIVITY);
|
Intent intent = new Intent(this, ENTRY_ACTIVITY);
|
||||||
intent.addFlags(FLAG_ACTIVITY_CLEAR_TOP);
|
intent.addFlags(FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
@@ -136,7 +141,7 @@ public class TestDataActivity extends BriarActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class OnSeekBarChangeUpdateProgress
|
private static class OnSeekBarChangeUpdateProgress
|
||||||
implements OnSeekBarChangeListener {
|
extends AbstractOnSeekBarChangeListener {
|
||||||
private final TextView textView;
|
private final TextView textView;
|
||||||
|
|
||||||
private OnSeekBarChangeUpdateProgress(TextView textView) {
|
private OnSeekBarChangeUpdateProgress(TextView textView) {
|
||||||
@@ -148,7 +153,10 @@ public class TestDataActivity extends BriarActivity {
|
|||||||
boolean fromUser) {
|
boolean fromUser) {
|
||||||
textView.setText(String.valueOf(progress));
|
textView.setText(String.valueOf(progress));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private abstract static class AbstractOnSeekBarChangeListener
|
||||||
|
implements OnSeekBarChangeListener {
|
||||||
@Override
|
@Override
|
||||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||||
}
|
}
|
||||||
@@ -157,5 +165,4 @@ public class TestDataActivity extends BriarActivity {
|
|||||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,6 +191,66 @@
|
|||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/textViewForumMessages" />
|
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
|
<Button
|
||||||
android:id="@+id/buttonZeroValues"
|
android:id="@+id/buttonZeroValues"
|
||||||
style="@style/BriarButton"
|
style="@style/BriarButton"
|
||||||
@@ -201,7 +261,7 @@
|
|||||||
android:text="Zero values"
|
android:text="Zero values"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/seekBarForumMessages"
|
app:layout_constraintTop_toBottomOf="@+id/seekBarPrivateGroupMessages"
|
||||||
app:layout_constraintVertical_bias="1.0" />
|
app:layout_constraintVertical_bias="1.0" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -470,10 +470,6 @@ public class TestDataCreatorImpl implements TestDataCreator {
|
|||||||
|
|
||||||
private void createRandomForumPosts(Forum forum, List<Contact> contacts,
|
private void createRandomForumPosts(Forum forum, List<Contact> contacts,
|
||||||
int numForumPosts) throws DbException {
|
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<>();
|
List<ForumPost> posts = new ArrayList<>();
|
||||||
for (int i = 0; i < numForumPosts; i++) {
|
for (int i = 0; i < numForumPosts; i++) {
|
||||||
Contact contact = contacts.get(random.nextInt(contacts.size()));
|
Contact contact = contacts.get(random.nextInt(contacts.size()));
|
||||||
@@ -522,11 +518,6 @@ public class TestDataCreatorImpl implements TestDataCreator {
|
|||||||
|
|
||||||
private void createRandomPrivateGroupMessages(PrivateGroup group,
|
private void createRandomPrivateGroupMessages(PrivateGroup group,
|
||||||
List<Contact> contacts, int amount) throws DbException {
|
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<>();
|
List<GroupMessage> messages = new ArrayList<>();
|
||||||
PrivateKey creatorPrivateKey =
|
PrivateKey creatorPrivateKey =
|
||||||
identityManager.getLocalAuthor().getPrivateKey();
|
identityManager.getLocalAuthor().getPrivateKey();
|
||||||
|
|||||||
Reference in New Issue
Block a user