diff --git a/app/build.gradle b/app/build.gradle index e3aedd24..aad321f0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -123,6 +123,7 @@ dependencies { //iconics implementation "com.mikepenz:materialdrawer-iconics:8.0.3" + implementation "com.mikepenz:iconics-views:5.0.2" implementation 'com.mikepenz:google-material-typeface:3.0.1.4.original-kotlin@aar' diff --git a/app/src/androidTest/java/com/h/pixeldroid/PostCreationFragmentTest.kt b/app/src/androidTest/java/com/h/pixeldroid/PostCreationFragmentTest.kt index 819bfec1..061f4803 100644 --- a/app/src/androidTest/java/com/h/pixeldroid/PostCreationFragmentTest.kt +++ b/app/src/androidTest/java/com/h/pixeldroid/PostCreationFragmentTest.kt @@ -1,10 +1,10 @@ package com.h.pixeldroid -import android.content.Context import android.content.Intent import androidx.test.core.app.ActivityScenario import androidx.test.espresso.Espresso.onView -import androidx.test.espresso.action.ViewActions.* +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.action.ViewActions.swipeLeft import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.intent.Intents.intended import androidx.test.espresso.intent.Intents.intending @@ -12,7 +12,6 @@ import androidx.test.espresso.intent.matcher.IntentMatchers.hasAction import androidx.test.espresso.intent.rule.IntentsTestRule import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withId -import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry import androidx.test.rule.GrantPermissionRule @@ -22,7 +21,6 @@ import com.h.pixeldroid.db.UserDatabaseEntity import com.h.pixeldroid.testUtility.MockServer import com.h.pixeldroid.utils.DBUtils import kotlinx.android.synthetic.main.activity_main.* -import kotlinx.android.synthetic.main.camera_ui_container.* import org.hamcrest.Matcher import org.junit.Before import org.junit.Rule @@ -67,9 +65,6 @@ class PostFragmentUITests { @get:Rule var globalTimeout: Timeout = Timeout.seconds(30) - @get:Rule - var rule = ActivityScenarioRule(MainActivity::class.java) - private lateinit var db: AppDatabase diff --git a/app/src/androidTest/java/com/h/pixeldroid/testUtility/JsonValues.kt b/app/src/androidTest/java/com/h/pixeldroid/testUtility/JsonValues.kt index aed878d0..731bb1fe 100644 --- a/app/src/androidTest/java/com/h/pixeldroid/testUtility/JsonValues.kt +++ b/app/src/androidTest/java/com/h/pixeldroid/testUtility/JsonValues.kt @@ -1,5 +1,8 @@ package com.h.pixeldroid.testUtility +import com.google.gson.Gson +import com.h.pixeldroid.objects.Application + class JsonValues { companion object { const val likedJson = """{"id":"156491373246287872","created_at":"2020-04-16T20:00:50.000000Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"https:\/\/pixelfed.de\/p\/machintuck\/156491373246287872","url":"https:\/\/pixelfed.de\/p\/machintuck\/156491373246287872","replies_count":1,"reblogs_count":13,"favourites_count":3,"reblogged":false,"favourited":true,"muted":false,"bookmarked":false,"pinned":false,"content":"@Dobios<\/a> @Dante<\/a>","reblog":null,"application":{"name":"web","website":null},"mentions":[{"id":"136800034732773376","url":"https:\/\/pixelfed.de\/Dobios","username":"Dobios","acct":"Dobios"},{"id":"136453537340198912","url":"https:\/\/pixelfed.de\/dante","username":"dante","acct":"dante"}],"tags":[{"name":"mushroom","url":"https:\/\/pixelfed.de\/discover\/tags\/mushroom"},{"name":"commentsstillbroken","url":"https:\/\/pixelfed.de\/discover\/tags\/commentsstillbroken"},{"name":"fixyourapi","url":"https:\/\/pixelfed.de\/discover\/tags\/fixyourapi"},{"name":"pls","url":"https:\/\/pixelfed.de\/discover\/tags\/pls"}],"emojis":[],"card":null,"poll":null,"account":{"id":"145183325781364736","username":"machintuck","acct":"machintuck","display_name":"Arthur","locked":false,"created_at":"2020-03-16T15:06:42.000000Z","followers_count":4,"following_count":4,"statuses_count":5,"note":"","url":"https:\/\/pixelfed.de\/machintuck","avatar":"https:\/\/pixelfed.de\/storage\/avatars\/014\/518\/332\/578\/136\/473\/6\/gbdKtKOhTkNA5UxCzeAQ_avatar.jpeg?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","avatar_static":"https:\/\/pixelfed.de\/storage\/avatars\/014\/518\/332\/578\/136\/473\/6\/gbdKtKOhTkNA5UxCzeAQ_avatar.jpeg?v=d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35","header":"","header_static":"","emojis":[],"moved":null,"fields":null,"bot":false,"software":"pixelfed","is_admin":false},"media_attachments":[{"id":"19228","type":"image","url":"https:\/\/pixelfed.de\/storage\/m\/d0931bf747b992a1c83e055753526516f2706111\/9b4393bfd32c643a265bd1c557b981f167d60969\/lbOqQOMeHLGmhYgehhZUBJ4JvjtKulh83BA97LoP.jpeg","remote_url":null,"preview_url":"https:\/\/pixelfed.de\/storage\/m\/d0931bf747b992a1c83e055753526516f2706111\/9b4393bfd32c643a265bd1c557b981f167d60969\/lbOqQOMeHLGmhYgehhZUBJ4JvjtKulh83BA97LoP_thumb.jpeg","text_url":null,"meta":null,"description":null}]}""" @@ -175,5 +178,8 @@ class JsonValues { "version": "69.420", "registrations": true }""" + var applicationJson = Gson().toJson(Application(name="PixelDroid", + website=null, vapid_key=null, client_id="286", + client_secret="2q3dHY29U8GNZ2eY6cbcw010cWk3qVGmWXxAJzn7")) } } \ No newline at end of file diff --git a/app/src/androidTest/java/com/h/pixeldroid/testUtility/MockServer.kt b/app/src/androidTest/java/com/h/pixeldroid/testUtility/MockServer.kt index 4fe7089a..06bcd567 100644 --- a/app/src/androidTest/java/com/h/pixeldroid/testUtility/MockServer.kt +++ b/app/src/androidTest/java/com/h/pixeldroid/testUtility/MockServer.kt @@ -45,6 +45,11 @@ class MockServer { .setResponseCode(200).setBody(JsonValues.tokenJson) } when { + request.path?.startsWith("/api/v1/apps") == true -> { + return MockResponse() + .addHeader("Content-Type", "application/json; charset=utf-8") + .setResponseCode(200).setBody(JsonValues.applicationJson) + } request.path?.startsWith("/api/v1/notifications") == true -> { return MockResponse() .addHeader("Content-Type", "application/json; charset=utf-8") diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 485d0d14..8e4c6be8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -30,7 +30,8 @@ + tools:ignore="LockedOrientationActivity" + android:theme="@style/AppTheme.NoActionBar"/> diff --git a/app/src/main/java/com/h/pixeldroid/PostCreationActivity.kt b/app/src/main/java/com/h/pixeldroid/PostCreationActivity.kt index 369e453c..60f3f0b5 100644 --- a/app/src/main/java/com/h/pixeldroid/PostCreationActivity.kt +++ b/app/src/main/java/com/h/pixeldroid/PostCreationActivity.kt @@ -5,8 +5,9 @@ import android.graphics.Bitmap import android.graphics.BitmapFactory import android.net.Uri import android.os.Bundle -import android.os.Environment import android.util.Log +import android.view.View.GONE +import android.view.View.VISIBLE import android.widget.Button import android.widget.ImageView import android.widget.Toast @@ -15,25 +16,27 @@ import androidx.core.net.toUri import com.google.android.material.textfield.TextInputEditText import com.h.pixeldroid.api.PixelfedAPI import com.h.pixeldroid.db.UserDatabaseEntity -import com.h.pixeldroid.objects.Attachment import com.h.pixeldroid.objects.Instance import com.h.pixeldroid.objects.Status import com.h.pixeldroid.utils.DBUtils +import io.reactivex.Observable +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.disposables.Disposable +import io.reactivex.schedulers.Schedulers +import io.reactivex.subjects.PublishSubject +import kotlinx.android.synthetic.main.activity_post_creation.* +import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MultipartBody import okhttp3.RequestBody -import okhttp3.RequestBody.Companion.asRequestBody +import okio.BufferedSink import retrofit2.Call import retrofit2.Callback import retrofit2.Response -import java.io.ByteArrayOutputStream -import java.io.File -import java.io.FileOutputStream -import java.io.IOException -import java.text.SimpleDateFormat -import java.util.Date +import java.io.* -class PostCreationActivity : AppCompatActivity() { + +class PostCreationActivity : AppCompatActivity(){ private val TAG = "Post Creation Activity" @@ -43,6 +46,8 @@ class PostCreationActivity : AppCompatActivity() { private lateinit var image: File private var user: UserDatabaseEntity? = null + private var listOfIds: List = emptyList() + private var maxLength: Int = Instance.DEFAULT_MAX_TOOT_CHARS private var description: String = "" @@ -77,21 +82,28 @@ class PostCreationActivity : AppCompatActivity() { accessToken = user?.accessToken.orEmpty() pixelfedAPI = PixelfedAPI.create(domain) - // check if the picture is alright - // TODO + //upload the picture and display progress while doing so + upload() - // edit the picture - // TODO - - // get the description and send the post to PixelFed + // get the description and send the post findViewById