diff --git a/.gitignore b/.gitignore index 8e2753bcf7339dd8cf5880860594827cec1b8ade..b40390a313fdb0eb047714d6cb7f09ab4871227c 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ local.properties .idea/* !.idea/runConfigurations/ !.idea/codeStyleSettings.xml +!.idea/codeStyles .gradle build/ *.iml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 97782045652253a9ebb077918fa4386e243591b1..9cad7718f1e96e93d65773e17402c45acd54c642 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,8 +8,6 @@ cache: before_script: - set -e - export GRADLE_USER_HOME=$PWD/.gradle - # Accept the license for the Android build tools - - echo y | /opt/android-sdk/tools/bin/sdkmanager "build-tools;26.0.2" test: script: diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000000000000000000000000000000000000..20f76712ca3998d545f745bce1c0b7e9d33c0510 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,261 @@ +<component name="ProjectCodeStyleConfiguration"> + <code_scheme name="Project" version="173"> + <option name="RIGHT_MARGIN" value="100" /> + <AndroidXmlCodeStyleSettings> + <option name="USE_CUSTOM_SETTINGS" value="true" /> + </AndroidXmlCodeStyleSettings> + <JavaCodeStyleSettings> + <option name="ANNOTATION_PARAMETER_WRAP" value="1" /> + <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" /> + <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" /> + <option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND"> + <value /> + </option> + <option name="IMPORT_LAYOUT_TABLE"> + <value> + <package name="android" withSubpackages="true" static="false" /> + <emptyLine /> + <package name="com" withSubpackages="true" static="false" /> + <emptyLine /> + <package name="junit" withSubpackages="true" static="false" /> + <emptyLine /> + <package name="net" withSubpackages="true" static="false" /> + <emptyLine /> + <package name="org" withSubpackages="true" static="false" /> + <emptyLine /> + <package name="java" withSubpackages="true" static="false" /> + <emptyLine /> + <package name="javax" withSubpackages="true" static="false" /> + <emptyLine /> + <package name="" withSubpackages="true" static="false" /> + <emptyLine /> + <package name="" withSubpackages="true" static="true" /> + <emptyLine /> + </value> + </option> + <option name="JD_ALIGN_PARAM_COMMENTS" value="false" /> + <option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" /> + </JavaCodeStyleSettings> + <Objective-C-extensions> + <file> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" /> + </file> + <class> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" /> + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" /> + </class> + <extensions> + <pair source="cpp" header="h" fileNamingConvention="NONE" /> + <pair source="c" header="h" fileNamingConvention="NONE" /> + </extensions> + </Objective-C-extensions> + <XML> + <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" /> + </XML> + <codeStyleSettings language="Groovy"> + <indentOptions> + <option name="USE_TAB_CHARACTER" value="true" /> + <option name="SMART_TABS" value="true" /> + </indentOptions> + </codeStyleSettings> + <codeStyleSettings language="JAVA"> + <option name="RIGHT_MARGIN" value="80" /> + <option name="ALIGN_MULTILINE_PARAMETERS" value="false" /> + <option name="ALIGN_MULTILINE_RESOURCES" value="false" /> + <option name="ALIGN_MULTILINE_FOR" value="false" /> + <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" /> + <option name="CALL_PARAMETERS_WRAP" value="1" /> + <option name="METHOD_PARAMETERS_WRAP" value="1" /> + <option name="RESOURCE_LIST_WRAP" value="1" /> + <option name="EXTENDS_LIST_WRAP" value="1" /> + <option name="THROWS_LIST_WRAP" value="1" /> + <option name="EXTENDS_KEYWORD_WRAP" value="1" /> + <option name="THROWS_KEYWORD_WRAP" value="1" /> + <option name="METHOD_CALL_CHAIN_WRAP" value="1" /> + <option name="BINARY_OPERATION_WRAP" value="1" /> + <option name="TERNARY_OPERATION_WRAP" value="1" /> + <option name="FOR_STATEMENT_WRAP" value="1" /> + <option name="ARRAY_INITIALIZER_WRAP" value="1" /> + <option name="ASSIGNMENT_WRAP" value="1" /> + <option name="ASSERT_STATEMENT_WRAP" value="1" /> + <option name="PARAMETER_ANNOTATION_WRAP" value="1" /> + <option name="VARIABLE_ANNOTATION_WRAP" value="1" /> + <option name="ENUM_CONSTANTS_WRAP" value="1" /> + <indentOptions> + <option name="USE_TAB_CHARACTER" value="true" /> + <option name="SMART_TABS" value="true" /> + </indentOptions> + </codeStyleSettings> + <codeStyleSettings language="XML"> + <option name="FORCE_REARRANGE_MODE" value="1" /> + <indentOptions> + <option name="CONTINUATION_INDENT_SIZE" value="4" /> + <option name="USE_TAB_CHARACTER" value="true" /> + <option name="SMART_TABS" value="true" /> + </indentOptions> + <arrangement> + <rules> + <section> + <rule> + <match> + <AND> + <NAME>xmlns:android</NAME> + <XML_NAMESPACE>Namespace:</XML_NAMESPACE> + </AND> + </match> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>xmlns:.*</NAME> + <XML_NAMESPACE>Namespace:</XML_NAMESPACE> + </AND> + </match> + <order>BY_NAME</order> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*:id</NAME> + <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> + </AND> + </match> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*:name</NAME> + <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> + </AND> + </match> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>name</NAME> + <XML_NAMESPACE>^$</XML_NAMESPACE> + </AND> + </match> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>style</NAME> + <XML_NAMESPACE>^$</XML_NAMESPACE> + </AND> + </match> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*</NAME> + <XML_NAMESPACE>^$</XML_NAMESPACE> + </AND> + </match> + <order>BY_NAME</order> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*:layout_width</NAME> + <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> + </AND> + </match> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*:layout_height</NAME> + <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> + </AND> + </match> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*:layout_.*</NAME> + <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> + </AND> + </match> + <order>BY_NAME</order> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*:width</NAME> + <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> + </AND> + </match> + <order>BY_NAME</order> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*:height</NAME> + <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> + </AND> + </match> + <order>BY_NAME</order> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*</NAME> + <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> + </AND> + </match> + <order>BY_NAME</order> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*</NAME> + <XML_NAMESPACE>.*</XML_NAMESPACE> + </AND> + </match> + <order>BY_NAME</order> + </rule> + </section> + </rules> + </arrangement> + </codeStyleSettings> + </code_scheme> +</component> \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000000000000000000000000000000000000..79ee123c2b23e069e35ed634d687e17f731cc702 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ +<component name="ProjectCodeStyleConfiguration"> + <state> + <option name="USE_PER_PROJECT_SETTINGS" value="true" /> + </state> +</component> \ No newline at end of file diff --git a/briar-android/src/main/java/org/briarproject/briar/android/test/TestDataActivity.java b/briar-android/src/main/java/org/briarproject/briar/android/test/TestDataActivity.java index 375a9a4a495ae91a6469f364e9a4774f450e8140..fad48f249df13cae41dc012aa74f0099bdc98090 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/test/TestDataActivity.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/test/TestDataActivity.java @@ -23,8 +23,20 @@ public class TestDataActivity extends BriarActivity { @Inject TestDataCreator testDataCreator; - private TextView[] textViews = new TextView[5]; - private SeekBar[] seekBars = new SeekBar[5]; + private TextView contactsTextView; + private SeekBar contactsSeekBar; + + private TextView messagesTextView; + private SeekBar messagesSeekBar; + + private TextView blogPostsTextView; + private SeekBar blogPostsSeekBar; + + private TextView forumsTextView; + private SeekBar forumsSeekBar; + + private TextView forumPostsTextView; + private SeekBar forumPostsSeekBar; @Override public void onCreate(Bundle bundle) { @@ -37,45 +49,111 @@ public class TestDataActivity extends BriarActivity { } setContentView(R.layout.activity_test_data); - textViews[0] = findViewById(R.id.textViewContactsSb); - textViews[1] = findViewById(R.id.textViewMessagesSb); - textViews[2] = findViewById(R.id.TextViewBlogPostsSb); - textViews[3] = findViewById(R.id.TextViewForumsSb); - textViews[4] = findViewById(R.id.TextViewForumMessagesSb); - seekBars[0] = findViewById(R.id.seekBarContacts); - seekBars[1] = findViewById(R.id.seekBarMessages); - seekBars[2] = findViewById(R.id.seekBarBlogPosts); - seekBars[3] = findViewById(R.id.seekBarForums); - seekBars[4] = findViewById(R.id.seekBarForumMessages); - - for (int i = 0; i < 5; i++) { - final TextView textView = textViews[i]; - seekBars[i].setOnSeekBarChangeListener( - new OnSeekBarChangeListener() { - @Override - public void onProgressChanged(SeekBar seekBar, - int progress, boolean fromUser) { - textView.setText(String.valueOf(progress)); - } - - @Override - public void onStartTrackingTouch(SeekBar seekBar) { - } - - @Override - public void onStopTrackingTouch(SeekBar seekBar) { - } - }); - } + contactsTextView = findViewById(R.id.textViewContactsSb); + messagesTextView = findViewById(R.id.textViewMessagesSb); + blogPostsTextView = findViewById(R.id.TextViewBlogPostsSb); + forumsTextView = findViewById(R.id.TextViewForumsSb); + forumPostsTextView = findViewById(R.id.TextViewForumMessagesSb); + contactsSeekBar = findViewById(R.id.seekBarContacts); + messagesSeekBar = findViewById(R.id.seekBarMessages); + blogPostsSeekBar = findViewById(R.id.seekBarBlogPosts); + forumsSeekBar = findViewById(R.id.seekBarForums); + forumPostsSeekBar = findViewById(R.id.seekBarForumMessages); + + contactsSeekBar + .setOnSeekBarChangeListener(new OnSeekBarChangeListener() { + @Override + 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(new OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, + int progress, boolean fromUser) { + messagesTextView.setText(String.valueOf(progress)); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + } + }); + + blogPostsSeekBar + .setOnSeekBarChangeListener(new OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, + int progress, boolean fromUser) { + blogPostsTextView.setText(String.valueOf(progress)); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + } + }); + + forumsSeekBar + .setOnSeekBarChangeListener(new OnSeekBarChangeListener() { + @Override + 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 OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, + int progress, boolean fromUser) { + forumPostsTextView.setText(String.valueOf(progress)); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + } + }); findViewById(R.id.buttonCreateTestData).setOnClickListener( v -> createTestData()); } private void createTestData() { - testDataCreator.createTestData(seekBars[0].getProgress(), - seekBars[1].getProgress(), seekBars[2].getProgress(), - seekBars[3].getProgress(), seekBars[4].getProgress()); + testDataCreator.createTestData(contactsSeekBar.getProgress() + 1, + messagesSeekBar.getProgress(), blogPostsSeekBar.getProgress(), + forumsSeekBar.getProgress(), forumPostsSeekBar.getProgress()); Intent intent = new Intent(this, NavDrawerActivity.class); intent.addFlags(FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); diff --git a/briar-android/src/main/res/layout/activity_test_data.xml b/briar-android/src/main/res/layout/activity_test_data.xml index c0d6c68334499744fd3270823fb61995c331c6b3..18ce6ac856c32ea84b2de5c7faad380ee886890e 100644 --- a/briar-android/src/main/res/layout/activity_test_data.xml +++ b/briar-android/src/main/res/layout/activity_test_data.xml @@ -28,7 +28,7 @@ android:id="@+id/seekBarContacts" android:layout_width="0dp" android:layout_height="wrap_content" - android:max="50" + android:max="49" android:progress="20" app:layout_constraintEnd_toStartOf="@+id/textViewContactsSb" app:layout_constraintStart_toStartOf="parent" diff --git a/briar-api/src/main/java/org/briarproject/briar/api/test/TestDataCreator.java b/briar-api/src/main/java/org/briarproject/briar/api/test/TestDataCreator.java index 41ccb64341268564cbb30d0a20ff586554414541..fc210e5833baf22f27ba3330476c64fa4c8deca2 100644 --- a/briar-api/src/main/java/org/briarproject/briar/api/test/TestDataCreator.java +++ b/briar-api/src/main/java/org/briarproject/briar/api/test/TestDataCreator.java @@ -8,7 +8,7 @@ public interface TestDataCreator { /** * Create fake test data on the DatabaseExecutor * - * @param numContacts Number of contacts to create. + * @param numContacts Number of contacts to create. Must be >= 1 * @param numPrivateMsgs Number of private messages to create for each * contact. * @param numBlogPosts Number of blog posts to create. diff --git a/briar-core/src/main/java/org/briarproject/briar/test/TestDataCreatorImpl.java b/briar-core/src/main/java/org/briarproject/briar/test/TestDataCreatorImpl.java index a4f6ceb332c17a81980740206884598d55230a33..c89d05e1750d6636117259a17b50db55db1d0b21 100644 --- a/briar-core/src/main/java/org/briarproject/briar/test/TestDataCreatorImpl.java +++ b/briar-core/src/main/java/org/briarproject/briar/test/TestDataCreatorImpl.java @@ -115,6 +115,9 @@ public class TestDataCreatorImpl implements TestDataCreator { public void createTestData(int numContacts, int numPrivateMsgs, int numBlogPosts, int numForums, int numForumPosts) { + if (numContacts == 0) + throw new IllegalArgumentException( + "Number of contacts must be >= 1"); ioExecutor.execute(() -> { try { createTestDataOnIoExecutor(numContacts, numPrivateMsgs,