Skip to content

Commit

Permalink
Merge pull request #164 from geckour/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
geckour authored Aug 29, 2017
2 parents 72810c4 + 737823f commit 4d2c233
Show file tree
Hide file tree
Showing 62 changed files with 2,138 additions and 671 deletions.
11 changes: 7 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

androidExtensions {
experimental = true
}

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
Expand Down Expand Up @@ -96,10 +101,6 @@ dependencies {
compile 'com.jakewharton.timber:timber:4.5.1'

// Misc
compile 'nz.bradcampbell:paperparcel:2.0.1'
compile 'nz.bradcampbell:paperparcel-kotlin:2.0.1'
kapt 'nz.bradcampbell:paperparcel-compiler:2.0.1'

compile('com.mikepenz:materialdrawer:5.9.0@aar') {
transitive = true
}
Expand All @@ -109,6 +110,8 @@ dependencies {
compile 'uk.co.chrisjenx:calligraphy:2.2.0'

compile 'com.vanniktech:emoji-one:0.5.1'

compile 'commons-io:commons-io:2.5'
}
repositories {
jcenter()
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@
android:name=".view.activity.SettingActivity"
android:label="@string/title_activity_setting"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".view.activity.ShareActivity"
android:label="@string/app_name"
android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>
</activity>

<service android:name=".NotificationService" />

Expand Down
Binary file added app/src/main/assets/fonts/Ricty-Regular.ttf
Binary file not shown.
3 changes: 0 additions & 3 deletions app/src/main/java/com/geckour/egret/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.vanniktech.emoji.EmojiManager
import com.vanniktech.emoji.one.EmojiOneProvider
import paperparcel.Adapter
import paperparcel.ProcessorConfig
import timber.log.Timber

@ProcessorConfig(adapters = arrayOf(Adapter(SpannedTypeAdapter::class)))
class App: Application() {

companion object {
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/java/com/geckour/egret/api/MastodonClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ class MastodonClient(baseUrl: String) {
password: String
): Single<InstanceAccess> = service.authUser(clientId, clientSecret, username, password)

fun getSelfAccount(): Single<Account> = service.getSelfAccount()
fun getOwnAccount(): Single<Account> = service.getOwnAccount()

fun getAccount(accountId: Long): Observable<Account> = service.getAccount(accountId)
fun getAccount(accountId: Long): Single<Account> = service.getAccount(accountId)

fun updateOwnAccount(displayName: String? = null, note: String? = null, avatarUrl: String? = null, headerUrl: String? = null): Single<Any> = service.updateOwnAccount(displayName, note, avatarUrl, headerUrl)

fun getPublicTimelineAsStream(): Observable<ResponseBody> = streamService.getPublicTimelineAsStream()

Expand All @@ -63,6 +65,8 @@ class MastodonClient(baseUrl: String) {

fun getNotificationTimeline(maxId: Long? = null, sinceId: Long? = null): Single<Result<List<Notification>>> = service.getNotificationTimeline(maxId, sinceId)

fun getFavouriteTimeline(maxId: Long? = null, sinceId: Long? = null): Single<Result<List<Status>>> = service.getFavouriteTimeline(maxId, sinceId)

fun getAccountAllToots(accountId: Long, maxId: Long? = null, sinceId: Long? = null): Single<Result<List<Status>>> = service.getAccountAllToots(accountId, maxId, sinceId)

fun favoriteByStatusId(statusId: Long): Single<Status> = service.favoriteStatusById(statusId)
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/geckour/egret/api/model/Account.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ data class Account(
@SerializedName("statuses_count")
var statusesCount: Long,

val note: String,
var note: String,

val url: URL,

@SerializedName("avatar")
val avatarUrl: String,
var avatarUrl: String,

@SerializedName("avatar_static")
val avatarImg: String,
var avatarUrlStatic: String,

@SerializedName("header")
val headerUrl: String,
var headerUrl: String,

@SerializedName("header_static")
val headerImg: String
var headerUrlStatic: String
): Serializable
13 changes: 7 additions & 6 deletions app/src/main/java/com/geckour/egret/api/model/Attachment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.google.gson.annotations.SerializedName
data class Attachment(
val id: Long,

var type: String,
var type: Type,

var url: String,

Expand All @@ -18,9 +18,10 @@ data class Attachment(
@SerializedName("text_url")
var urlInText: String?
) {
enum class Type(val rowValue: Int) {
image(0),
video(1),
gifv(2)
}

enum class Type {
image,
video,
gifv
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ data class Relationship(
var muting: Boolean,

@SerializedName("requested")
var requestedAllowToFollow: Boolean
var hasSendFollowRequest: Boolean
)
32 changes: 30 additions & 2 deletions app/src/main/java/com/geckour/egret/api/service/MastodonService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,29 @@ interface MastodonService {
): Single<InstanceAccess>

@GET("api/v1/accounts/verify_credentials")
fun getSelfAccount(): Single<Account>
fun getOwnAccount(): Single<Account>

@GET("api/v1/accounts/{id}")
fun getAccount(
@Path("id")
accountId: Long
): Observable<Account>
): Single<Account>

@FormUrlEncoded
@PATCH("api/v1/accounts/update_credentials")
fun updateOwnAccount(
@Field("display_name")
displayName: String? = null,

@Field("note")
note: String? = null,

@Field("avatar")
avatar: String? = null,

@Field("header")
headeer: String? = null
): Single<Any>

@GET("api/v1/streaming/public")
@Streaming
Expand Down Expand Up @@ -131,6 +147,18 @@ interface MastodonService {
limit: Long? = 30
): Single<Result<List<Notification>>>

@GET("api/v1/favourites")
fun getFavouriteTimeline(
@Query("max_id")
maxId: Long? = null,

@Query("since_id")
sinceId: Long? = null,

@Query("limit")
limit: Long? = 40
): Single<Result<List<Status>>>

@GET("api/v1/accounts/{id}/statuses")
fun getAccountAllToots(
@Path("id")
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/geckour/egret/model/AccessToken.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.github.gfx.android.orma.annotation.*
import java.util.*

@Table
class AccessToken(
data class AccessToken(
@Setter("id") @PrimaryKey(autoincrement = true) val id: Long = -1L,
@Setter("access_token") @Column val token: String = "",
@Setter("instance_id") @Column val instanceId: Long = -1L,
Expand Down
27 changes: 27 additions & 0 deletions app/src/main/java/com/geckour/egret/model/Draft.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.geckour.egret.model

import com.geckour.egret.api.model.Attachment
import com.geckour.egret.api.service.MastodonService
import com.github.gfx.android.orma.annotation.Column
import com.github.gfx.android.orma.annotation.PrimaryKey
import com.github.gfx.android.orma.annotation.Setter
import com.github.gfx.android.orma.annotation.Table

@Table
data class Draft(
@Setter("id") @PrimaryKey(autoincrement = true) val id: Long = -1L,
@Setter("tokenId") @Column(indexed = true) var tokenId: Long = -1L,
@Setter("body") @Column var body: String = "",
@Setter("alertBody") @Column var alertBody: String = "",
@Setter("inReplyToId") @Column var inReplyToId: Long? = null,
@Setter("inReplyToName") @Column var inReplyToName: String? = null,
@Setter("attachments") @Column var attachments: Attachments,
@Setter("warning") @Column var warning: Boolean = false,
@Setter("sensitive") @Column var sensitive: Boolean = false,
@Setter("visibility") @Column var visibility: Int = MastodonService.Visibility.public.ordinal,
@Setter("createdAt") @Column(indexed = true) var createdAt: Long = System.currentTimeMillis()
) {
data class Attachments(
val value: List<Attachment> = ArrayList()
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.github.gfx.android.orma.annotation.Table
import java.util.*

@Table
class InstanceAuthInfo(
data class InstanceAuthInfo(
@Setter("id") @PrimaryKey(autoincrement = true) val id: Long = -1L,
@Setter("instance") @Column val instance: String = "",
@Setter("auth_id") @Column var authId: Long = -1L,
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/geckour/egret/model/MuteHashTag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.github.gfx.android.orma.annotation.Setter
import com.github.gfx.android.orma.annotation.Table

@Table
class MuteHashTag(
data class MuteHashTag(
@Setter("id") @PrimaryKey(autoincrement = true) val id: Long = -1L,
@Setter("hashTag") @Column var hashTag: String = ""
)
2 changes: 1 addition & 1 deletion app/src/main/java/com/geckour/egret/model/MuteInstance.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.github.gfx.android.orma.annotation.Setter
import com.github.gfx.android.orma.annotation.Table

@Table
class MuteInstance(
data class MuteInstance(
@Setter("id") @PrimaryKey(autoincrement = true) val id: Long = -1L,
@Setter("instance") @Column var instance: String = ""
)
2 changes: 1 addition & 1 deletion app/src/main/java/com/geckour/egret/model/MuteKeyword.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.github.gfx.android.orma.annotation.Setter
import com.github.gfx.android.orma.annotation.Table

@Table
class MuteKeyword(
data class MuteKeyword(
@Setter("id") @PrimaryKey(autoincrement = true) val id: Long = -1L,
@Setter("is_regex") @Column var isRegex: Boolean = false,
@Setter("hashTag") @Column var keyword: String = ""
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/java/com/geckour/egret/util/Common.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ import android.text.Spanned
import android.text.format.DateFormat
import android.text.method.LinkMovementMethod
import android.text.method.MovementMethod
import android.util.DisplayMetrics
import android.util.TypedValue
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import android.widget.TextView
import com.emojione.Emojione
import com.geckour.egret.App
import com.geckour.egret.NotificationService
import com.geckour.egret.R
import com.geckour.egret.api.MastodonClient
import com.geckour.egret.api.model.Account
Expand Down Expand Up @@ -57,7 +54,7 @@ class Common {
}

private fun requestWeatherCertified(domain: String, callback: (hasCertified: Boolean, accountId: Long) -> Any) {
MastodonClient(domain).getSelfAccount()
MastodonClient(domain).getOwnAccount()
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ account ->
Expand Down Expand Up @@ -104,6 +101,7 @@ class Common {
status.url,
status.account.id,
status.account.avatarUrl,
status.account.isLocked,
Emojione.shortnameToUnicode(status.account.displayName),
"@${status.account.acct}",
Date(status.createdAt.time),
Expand All @@ -128,6 +126,7 @@ class Common {
it.id,
it.type,
it.account.id,
it.account.isLocked,
it.account.avatarUrl,
it.account.displayName,
"@${it.account.acct}",
Expand All @@ -139,8 +138,12 @@ class Common {
else TimelineContent()

fun getProfileContent(account: Account): ProfileContent = ProfileContent(
account.id,
account.avatarUrl,
null,
account.headerUrl,
null,
account.isLocked,
account.displayName,
"@${account.acct}",
getSpannedWithoutExtraMarginFromHtml("<a href=\"${account.url}\">${account.url}</a>"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.geckour.egret.util;

import com.geckour.egret.App;
import com.geckour.egret.model.Draft;
import com.github.gfx.android.orma.annotation.StaticTypeAdapter;

@StaticTypeAdapter(
targetType = Draft.Attachments.class,
serializedType = String.class
)
public class OrmaAttachmentsAdapter {
public static String serialize(Draft.Attachments attachments) {
return App.Companion.getGson().toJson(attachments);
}

public static Draft.Attachments deserialize(String string) {
return App.Companion.getGson().fromJson(string, Draft.Attachments.class);
}
}
Loading

0 comments on commit 4d2c233

Please sign in to comment.