Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Thomas
Fedilab
Commits
e0c2d586
Commit
e0c2d586
authored
May 07, 2020
by
Thomas
Browse files
Merge branch 'l10n_develop_new' of framagit.org:tom79/fedilab into l10n_develop_new
parents
bd22949e
b40a064c
Changes
46
Expand all
Hide whitespace changes
Inline
Side-by-side
app/build.gradle
View file @
e0c2d586
...
...
@@ -2,12 +2,12 @@ apply plugin: 'com.android.application'
android
{
compileSdkVersion
29
buildToolsVersion
"29.0.
2
"
buildToolsVersion
"29.0.
3
"
defaultConfig
{
minSdkVersion
19
targetSdkVersion
29
versionCode
36
3
versionName
"2.35.
0
"
versionCode
36
5
versionName
"2.35.
2
"
multiDexEnabled
true
renderscriptTargetApi
28
as
int
renderscriptSupportModeEnabled
true
...
...
app/src/main/assets/changelogs/364.txt
0 → 100644
View file @
e0c2d586
Added:
- Simple click on reactions to add them
Fixed:
- Recent crashes (connection, when scrolling)
\ No newline at end of file
app/src/main/assets/changelogs/365.txt
0 → 100644
View file @
e0c2d586
Fixed:
- Fix last remaining issues
\ No newline at end of file
app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java
View file @
e0c2d586
...
...
@@ -179,6 +179,7 @@ public abstract class BaseMainActivity extends BaseActivity
public
static
String
regex_home
,
regex_local
,
regex_public
;
public
static
boolean
show_boosts
,
show_replies
,
show_art_nsfw
;
public
static
iconLauncher
mLauncher
=
iconLauncher
.
BUBBLES
;
public
static
boolean
isAttached
=
false
;
private
static
boolean
notificationChecked
=
false
;
private
final
int
PICK_IMPORT
=
5556
;
private
FloatingActionButton
toot
,
delete_all
,
add_new
;
...
...
@@ -2374,6 +2375,18 @@ public abstract class BaseMainActivity extends BaseActivity
}
}
@Override
public
void
onAttachedToWindow
()
{
super
.
onAttachedToWindow
();
isAttached
=
true
;
}
@Override
public
void
onDetachedFromWindow
()
{
super
.
onDetachedFromWindow
();
isAttached
=
false
;
}
public
enum
iconLauncher
{
BUBBLES
,
FEDIVERSE
,
...
...
@@ -2521,6 +2534,7 @@ public abstract class BaseMainActivity extends BaseActivity
}
}
@Override
public
void
destroyItem
(
@NonNull
ViewGroup
container
,
int
position
,
@NonNull
Object
object
)
{
if
(
mPageReferenceMap
!=
null
)
{
...
...
app/src/main/java/app/fedilab/android/activities/EditProfileActivity.java
View file @
e0c2d586
...
...
@@ -16,6 +16,7 @@ package app.fedilab.android.activities;
import
android.Manifest
;
import
android.annotation.SuppressLint
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.content.pm.PackageManager
;
...
...
@@ -185,6 +186,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
}
@SuppressLint
(
"CutPasteId"
)
@Override
public
void
onRetrieveAccount
(
Account
account
,
Error
error
)
{
if
(
error
!=
null
)
{
...
...
@@ -312,36 +314,33 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
Intent
getIntent
=
new
Intent
(
Intent
.
ACTION_GET_CONTENT
);
getIntent
.
setType
(
"image/*"
);
Intent
pickIntent
=
new
Intent
(
Intent
.
ACTION_PICK
,
android
.
provider
.
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
);
pickIntent
.
set
Type
(
"image/*"
);
Intent
pickIntent
=
new
Intent
(
Intent
.
ACTION_PICK
);
pickIntent
.
set
DataAndType
(
android
.
provider
.
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
,
"image/*"
);
Intent
chooserIntent
=
Intent
.
createChooser
(
getIntent
,
getString
(
R
.
string
.
toot_select_image
));
chooserIntent
.
putExtra
(
Intent
.
EXTRA_INITIAL_INTENTS
,
new
Intent
[]{
pickIntent
});
startActivityForResult
(
chooserIntent
,
PICK_IMAGE_HEADER
);
});
set_change_profile_picture
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
if
(
ContextCompat
.
checkSelfPermission
(
EditProfileActivity
.
this
,
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
ActivityCompat
.
requestPermissions
(
EditProfileActivity
.
this
,
new
String
[]{
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
},
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE_PICTURE
);
return
;
}
set_change_profile_picture
.
setOnClickListener
(
v
->
{
if
(
ContextCompat
.
checkSelfPermission
(
EditProfileActivity
.
this
,
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
ActivityCompat
.
requestPermissions
(
EditProfileActivity
.
this
,
new
String
[]{
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
},
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE_PICTURE
);
return
;
}
Intent
getIntent
=
new
Intent
(
Intent
.
ACTION_GET_CONTENT
);
getIntent
.
setType
(
"image/*"
);
Intent
getIntent
=
new
Intent
(
Intent
.
ACTION_GET_CONTENT
);
getIntent
.
setType
(
"image/*"
);
Intent
pickIntent
=
new
Intent
(
Intent
.
ACTION_PICK
,
android
.
provider
.
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
);
pickIntent
.
set
Type
(
"image/*"
);
Intent
pickIntent
=
new
Intent
(
Intent
.
ACTION_PICK
);
pickIntent
.
set
DataAndType
(
android
.
provider
.
MediaStore
.
Images
.
Media
.
EXTERNAL_CONTENT_URI
,
"image/*"
);
Intent
chooserIntent
=
Intent
.
createChooser
(
getIntent
,
getString
(
R
.
string
.
toot_select_image
));
chooserIntent
.
putExtra
(
Intent
.
EXTRA_INITIAL_INTENTS
,
new
Intent
[]{
pickIntent
});
startActivityForResult
(
chooserIntent
,
PICK_IMAGE_PROFILE
);
}
Intent
chooserIntent
=
Intent
.
createChooser
(
getIntent
,
getString
(
R
.
string
.
toot_select_image
));
chooserIntent
.
putExtra
(
Intent
.
EXTRA_INITIAL_INTENTS
,
new
Intent
[]{
pickIntent
});
startActivityForResult
(
chooserIntent
,
PICK_IMAGE_PROFILE
);
});
if
(!
EditProfileActivity
.
this
.
isFinishing
())
{
...
...
app/src/main/java/app/fedilab/android/activities/LoginActivity.java
View file @
e0c2d586
...
...
@@ -589,8 +589,7 @@ public class LoginActivity extends BaseActivity {
String
refresh_token
=
null
;
if
(
resobj
.
has
(
"refresh_token"
))
refresh_token
=
resobj
.
getString
(
"refresh_token"
);
SharedPreferences
sharedpreferences1
=
getSharedPreferences
(
Helper
.
APP_PREFS
,
MODE_PRIVATE
);
SharedPreferences
.
Editor
editor
=
sharedpreferences1
.
edit
();
SharedPreferences
.
Editor
editor
=
sharedpreferences
.
edit
();
editor
.
putString
(
Helper
.
PREF_KEY_OAUTH_TOKEN
,
token
);
editor
.
apply
();
//Update the account with the token;
...
...
@@ -601,10 +600,9 @@ public class LoginActivity extends BaseActivity {
}
else
{
try
{
resobj
=
new
JSONObject
(
response
);
Account
account
=
GNUAPI
.
parseAccountResponse
(
LoginActivity
.
this
,
resobj
);
Account
account
=
GNUAPI
.
parseAccountResponse
(
resobj
);
account
.
setToken
(
basicAuth
);
SharedPreferences
sharedpreferences1
=
getSharedPreferences
(
Helper
.
APP_PREFS
,
MODE_PRIVATE
);
SharedPreferences
.
Editor
editor
=
sharedpreferences1
.
edit
();
SharedPreferences
.
Editor
editor
=
sharedpreferences
.
edit
();
editor
.
putString
(
Helper
.
PREF_KEY_OAUTH_TOKEN
,
basicAuth
);
account
.
setInstance
(
instance
);
...
...
app/src/main/java/app/fedilab/android/activities/PeertubeActivity.java
View file @
e0c2d586
...
...
@@ -40,7 +40,6 @@ import android.view.View;
import
android.view.ViewGroup
;
import
android.view.WindowManager
;
import
android.view.inputmethod.InputMethodManager
;
import
android.webkit.WebView
;
import
android.widget.ArrayAdapter
;
import
android.widget.EditText
;
import
android.widget.FrameLayout
;
...
...
@@ -106,6 +105,7 @@ import app.fedilab.android.interfaces.OnRetrievePeertubeInterface;
import
app.fedilab.android.sqlite.AccountDAO
;
import
app.fedilab.android.sqlite.PeertubeFavoritesDAO
;
import
app.fedilab.android.sqlite.Sqlite
;
import
app.fedilab.android.webview.CustomWebview
;
import
app.fedilab.android.webview.MastalabWebChromeClient
;
import
app.fedilab.android.webview.MastalabWebViewClient
;
import
es.dmoral.toasty.Toasty
;
...
...
@@ -183,7 +183,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
peertube_description
=
findViewById
(
R
.
id
.
peertube_description
);
peertube_title
=
findViewById
(
R
.
id
.
peertube_title
);
peertube_information_container
=
findViewById
(
R
.
id
.
peertube_information_container
);
Web
V
iew
webview_video
=
findViewById
(
R
.
id
.
webview_video
);
Custom
Web
v
iew
webview_video
=
findViewById
(
R
.
id
.
webview_video
);
playerView
=
findViewById
(
R
.
id
.
media_video
);
write_comment_container
=
findViewById
(
R
.
id
.
write_comment_container
);
ImageView
my_pp
=
findViewById
(
R
.
id
.
my_pp
);
...
...
app/src/main/java/app/fedilab/android/activities/PhotoEditorActivity.java
View file @
e0c2d586
...
...
@@ -56,6 +56,7 @@ import app.fedilab.android.imageeditor.filters.FilterListener;
import
app.fedilab.android.imageeditor.filters.FilterViewAdapter
;
import
app.fedilab.android.imageeditor.tools.EditingToolsAdapter
;
import
app.fedilab.android.imageeditor.tools.ToolType
;
import
es.dmoral.toasty.Toasty
;
import
ja.burhanrashid52.photoeditor.OnPhotoEditorListener
;
import
ja.burhanrashid52.photoeditor.PhotoEditor
;
import
ja.burhanrashid52.photoeditor.PhotoEditorView
;
...
...
@@ -163,8 +164,11 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorLi
mPhotoEditor
.
setOnPhotoEditorListener
(
this
);
//Set Image Dynamically
mPhotoEditorView
.
getSource
().
setImageURI
(
uri
);
try
{
mPhotoEditorView
.
getSource
().
setImageURI
(
uri
);
}
catch
(
Exception
e
)
{
Toasty
.
error
(
PhotoEditorActivity
.
this
,
getString
(
R
.
string
.
error
)).
show
();
}
if
(
uri
!=
null
)
{
try
(
InputStream
inputStream
=
getContentResolver
().
openInputStream
(
uri
))
{
...
...
app/src/main/java/app/fedilab/android/activities/ShowConversationActivity.java
View file @
e0c2d586
...
...
@@ -36,6 +36,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import
androidx.recyclerview.widget.RecyclerView
;
import
androidx.swiperefreshlayout.widget.SwipeRefreshLayout
;
import
java.lang.ref.WeakReference
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -109,11 +110,11 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
loader
.
setVisibility
(
View
.
VISIBLE
);
detailsStatus
.
setFocused
(
true
);
//Some spannable
Status
.
fillSpan
(
ShowConversationActivity
.
this
,
detailsStatus
);
Status
.
fillSpan
(
new
WeakReference
<>(
ShowConversationActivity
.
this
)
,
detailsStatus
);
if
(
detailsStatus
.
getPoll
()
!=
null
)
{
Status
.
makeEmojiPoll
(
ShowConversationActivity
.
this
,
detailsStatus
.
getPoll
());
Status
.
makeEmojiPoll
(
new
WeakReference
<>(
ShowConversationActivity
.
this
)
,
detailsStatus
.
getPoll
());
}
Account
.
makeAccountNameEmoji
(
ShowConversationActivity
.
this
,
detailsStatus
.
getAccount
());
Account
.
makeAccountNameEmoji
(
new
WeakReference
<>(
ShowConversationActivity
.
this
)
,
detailsStatus
.
getAccount
());
if
(
MainActivity
.
social
==
UpdateAccountInfoAsyncTask
.
SOCIAL
.
MASTODON
)
{
...
...
app/src/main/java/app/fedilab/android/activities/SlideMediaActivity.java
View file @
e0c2d586
...
...
@@ -316,7 +316,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
public
void
togglePlaying
(
View
v
)
{
if
(
mCurrentFragment
!=
null
)
{
mCurrentFragment
.
togglePlaying
(
v
);
mCurrentFragment
.
togglePlaying
();
}
}
...
...
app/src/main/java/app/fedilab/android/activities/WebviewActivity.java
View file @
e0c2d586
...
...
@@ -34,7 +34,6 @@ import android.view.MenuItem;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.WindowManager
;
import
android.webkit.WebView
;
import
android.widget.ArrayAdapter
;
import
android.widget.FrameLayout
;
import
android.widget.Toast
;
...
...
@@ -56,6 +55,7 @@ import app.fedilab.android.helper.CountDrawable;
import
app.fedilab.android.helper.Helper
;
import
app.fedilab.android.sqlite.DomainBlockDAO
;
import
app.fedilab.android.sqlite.Sqlite
;
import
app.fedilab.android.webview.CustomWebview
;
import
app.fedilab.android.webview.MastalabWebChromeClient
;
import
app.fedilab.android.webview.MastalabWebViewClient
;
import
es.dmoral.toasty.Toasty
;
...
...
@@ -72,7 +72,7 @@ public class WebviewActivity extends BaseActivity {
private
String
url
;
private
String
peertubeLinkToFetch
;
private
boolean
peertubeLink
;
private
Web
V
iew
webView
;
private
Custom
Web
v
iew
webView
;
private
Menu
defaultMenu
;
private
MastalabWebViewClient
mastalabWebViewClient
;
...
...
app/src/main/java/app/fedilab/android/activities/WebviewConnectActivity.java
View file @
e0c2d586
...
...
@@ -51,6 +51,7 @@ import app.fedilab.android.R;
import
app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask
;
import
app.fedilab.android.client.HttpsConnection
;
import
app.fedilab.android.helper.Helper
;
import
app.fedilab.android.webview.CustomWebview
;
import
es.dmoral.toasty.Toasty
;
/**
...
...
@@ -60,7 +61,7 @@ import es.dmoral.toasty.Toasty;
public
class
WebviewConnectActivity
extends
BaseActivity
{
private
Web
V
iew
webView
;
private
Custom
Web
v
iew
webView
;
private
AlertDialog
alert
;
private
String
clientId
,
clientSecret
;
private
String
instance
;
...
...
app/src/main/java/app/fedilab/android/asynctasks/RetrieveFeedsAsyncTask.java
View file @
e0c2d586
...
...
@@ -369,9 +369,9 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
List
<
app
.
fedilab
.
android
.
client
.
Entities
.
Status
>
statuses
=
new
StatusCacheDAO
(
contextReference
.
get
(),
db
).
getAllStatus
(
StatusCacheDAO
.
BOOKMARK_CACHE
);
if
(
statuses
!=
null
)
{
for
(
app
.
fedilab
.
android
.
client
.
Entities
.
Status
status
:
statuses
)
{
app
.
fedilab
.
android
.
client
.
Entities
.
Status
.
fillSpan
(
contextReference
.
get
()
,
status
);
app
.
fedilab
.
android
.
client
.
Entities
.
Status
.
makeEmojiPoll
(
contextReference
.
get
()
,
status
.
getReblog
()
!=
null
?
status
.
getReblog
().
getPoll
()
:
status
.
getPoll
());
Account
.
makeAccountNameEmoji
(
contextReference
.
get
()
,
status
.
getReblog
()
!=
null
?
status
.
getReblog
().
getAccount
()
:
status
.
getAccount
());
app
.
fedilab
.
android
.
client
.
Entities
.
Status
.
fillSpan
(
contextReference
,
status
);
app
.
fedilab
.
android
.
client
.
Entities
.
Status
.
makeEmojiPoll
(
contextReference
,
status
.
getReblog
()
!=
null
?
status
.
getReblog
().
getPoll
()
:
status
.
getPoll
());
Account
.
makeAccountNameEmoji
(
contextReference
,
status
.
getReblog
()
!=
null
?
status
.
getReblog
().
getAccount
()
:
status
.
getAccount
());
}
}
else
{
statuses
=
new
ArrayList
<>();
...
...
app/src/main/java/app/fedilab/android/client/API.java
View file @
e0c2d586
This diff is collapsed.
Click to expand it.
app/src/main/java/app/fedilab/android/client/Entities/Account.java
View file @
e0c2d586
...
...
@@ -47,6 +47,7 @@ import com.bumptech.glide.request.transition.Transition;
import
org.jetbrains.annotations.NotNull
;
import
java.lang.ref.WeakReference
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Iterator
;
...
...
@@ -199,7 +200,8 @@ public class Account implements Parcelable {
this
.
invited_by_account_id
=
in
.
readString
();
}
public
static
void
makeAccountNameEmoji
(
final
Context
context
,
Account
account
)
{
public
static
void
makeAccountNameEmoji
(
final
WeakReference
<
Context
>
contextWeakReference
,
Account
account
)
{
Context
context
=
contextWeakReference
.
get
();
if
((
context
instanceof
Activity
&&
((
Activity
)
context
).
isFinishing
())
||
account
.
getDisplay_name
()
==
null
)
return
;
...
...
@@ -225,13 +227,16 @@ public class Account implements Parcelable {
//emojis can be used several times so we have to loop
for
(
int
startPosition
=
-
1
;
(
startPosition
=
displayNameSpan
.
toString
().
indexOf
(
targetedEmoji
,
startPosition
+
1
))
!=
-
1
;
startPosition
++)
{
final
int
endPosition
=
startPosition
+
targetedEmoji
.
length
();
if
(
endPosition
<=
displayNameSpan
.
toString
().
length
()
&&
endPosition
>=
startPosition
)
{
resource
.
setBounds
(
0
,
0
,
(
int
)
Helper
.
convertDpToPixel
(
20
,
context
),
(
int
)
Helper
.
convertDpToPixel
(
20
,
context
));
resource
.
setVisible
(
true
,
true
);
ImageSpan
imageSpan
=
new
ImageSpan
(
resource
);
displayNameSpan
.
setSpan
(
imageSpan
,
startPosition
,
endPosition
,
Spannable
.
SPAN_INCLUSIVE_EXCLUSIVE
);
if
(
resource
!=
null
&&
endPosition
<=
displayNameSpan
.
toString
().
length
()
&&
endPosition
>=
startPosition
)
{
try
{
resource
.
setBounds
(
0
,
0
,
(
int
)
Helper
.
convertDpToPixel
(
20
,
context
),
(
int
)
Helper
.
convertDpToPixel
(
20
,
context
));
resource
.
setVisible
(
true
,
true
);
ImageSpan
imageSpan
=
new
ImageSpan
(
resource
);
displayNameSpan
.
setSpan
(
imageSpan
,
startPosition
,
endPosition
,
Spannable
.
SPAN_INCLUSIVE_EXCLUSIVE
);
}
catch
(
Exception
ignored
)
{
}
return
;
}
}
...
...
app/src/main/java/app/fedilab/android/client/Entities/ManageTimelines.java
View file @
e0c2d586
...
...
@@ -571,7 +571,7 @@ public class ManageTimelines {
}
popup
.
setOnDismissListener
(
menu12
->
{
if
(
displayStatusFragment
!=
null
&&
displayStatusFragment
.
getUser
Visible
Hint
())
if
(
displayStatusFragment
!=
null
&&
displayStatusFragment
.
is
Visible
())
displayStatusFragment
.
refreshFilter
();
});
int
theme
=
sharedpreferences
.
getInt
(
Helper
.
SET_THEME
,
Helper
.
THEME_DARK
);
...
...
app/src/main/java/app/fedilab/android/client/Entities/Status.java
View file @
e0c2d586
...
...
@@ -59,6 +59,7 @@ import com.bumptech.glide.request.target.CustomTarget;
import
com.bumptech.glide.request.target.Target
;
import
com.bumptech.glide.request.transition.Transition
;
import
java.lang.ref.WeakReference
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.util.ArrayList
;
...
...
@@ -263,15 +264,15 @@ public class Status implements Parcelable {
}
public
static
void
fillSpan
(
Context
context
,
Status
status
)
{
Status
.
transform
(
context
,
status
);
Status
.
makeEmojis
(
context
,
status
);
Status
.
makeImage
(
context
,
status
);
public
static
void
fillSpan
(
WeakReference
<
Context
>
context
WeakReference
,
Status
status
)
{
Status
.
transform
(
context
WeakReference
,
status
);
Status
.
makeEmojis
(
context
WeakReference
,
status
);
Status
.
makeImage
(
context
WeakReference
,
status
);
}
private
static
void
transform
(
Context
context
,
Status
status
)
{
private
static
void
transform
(
WeakReference
<
Context
>
context
WeakReference
,
Status
status
)
{
Context
context
=
contextWeakReference
.
get
();
if
(
status
==
null
)
return
;
SpannableString
spannableStringContent
,
spannableStringCW
;
...
...
@@ -849,8 +850,8 @@ public class Status implements Parcelable {
status
.
setContentSpanTranslated
(
contentSpanTranslated
);
}
private
static
void
makeEmojis
(
final
Context
context
,
Status
status
)
{
private
static
void
makeEmojis
(
final
WeakReference
<
Context
>
context
WeakReference
,
Status
status
)
{
Context
context
=
contextWeakReference
.
get
();
if
(
context
instanceof
Activity
&&
((
Activity
)
context
).
isFinishing
())
return
;
if
(
status
.
getReblog
()
!=
null
&&
status
.
getReblog
().
getEmojis
()
==
null
)
...
...
@@ -890,14 +891,17 @@ public class Status implements Parcelable {
//emojis can be used several times so we have to loop
for
(
int
startPosition
=
-
1
;
(
startPosition
=
contentSpan
.
toString
().
indexOf
(
targetedEmoji
,
startPosition
+
1
))
!=
-
1
;
startPosition
++)
{
final
int
endPosition
=
startPosition
+
targetedEmoji
.
length
();
if
(
endPosition
<=
contentSpan
.
toString
().
length
()
&&
endPosition
>=
startPosition
)
{
if
(
resource
!=
null
&&
endPosition
<=
contentSpan
.
toString
().
length
()
&&
endPosition
>=
startPosition
)
{
ImageSpan
imageSpan
;
resource
.
setBounds
(
0
,
0
,
(
int
)
Helper
.
convertDpToPixel
(
20
,
context
),
(
int
)
Helper
.
convertDpToPixel
(
20
,
context
));
resource
.
setVisible
(
true
,
true
);
imageSpan
=
new
ImageSpan
(
resource
);
contentSpan
.
setSpan
(
imageSpan
,
startPosition
,
endPosition
,
Spannable
.
SPAN_INCLUSIVE_EXCLUSIVE
);
try
{
resource
.
setBounds
(
0
,
0
,
(
int
)
Helper
.
convertDpToPixel
(
20
,
context
),
(
int
)
Helper
.
convertDpToPixel
(
20
,
context
));
resource
.
setVisible
(
true
,
true
);
imageSpan
=
new
ImageSpan
(
resource
);
contentSpan
.
setSpan
(
imageSpan
,
startPosition
,
endPosition
,
Spannable
.
SPAN_INCLUSIVE_EXCLUSIVE
);
}
catch
(
Exception
ignored
)
{
}
}
}
}
...
...
@@ -928,7 +932,8 @@ public class Status implements Parcelable {
}
}
public
static
void
makeEmojiPoll
(
final
Context
context
,
Poll
poll
)
{
public
static
void
makeEmojiPoll
(
final
WeakReference
<
Context
>
contextWeakReference
,
Poll
poll
)
{
Context
context
=
contextWeakReference
.
get
();
if
((
context
instanceof
Activity
&&
((
Activity
)
context
).
isFinishing
())
||
poll
==
null
||
poll
.
getOptionsList
()
==
null
)
return
;
final
List
<
Emojis
>
emojis
=
poll
.
getEmojis
();
...
...
@@ -988,8 +993,8 @@ public class Status implements Parcelable {
}
}
private
static
void
makeImage
(
final
Context
context
,
Status
status
)
{
private
static
void
makeImage
(
final
WeakReference
<
Context
>
context
WeakReference
,
Status
status
)
{
Context
context
=
contextWeakReference
.
get
();
if
(
context
instanceof
Activity
&&
((
Activity
)
context
).
isFinishing
())
return
;
if
(
status
.
getAccount
()
==
null
)
...
...
app/src/main/java/app/fedilab/android/client/GNUAPI.java
View file @
e0c2d586
...
...
@@ -28,6 +28,7 @@ import org.json.JSONObject;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.lang.ref.WeakReference
;
import
java.net.URLEncoder
;
import
java.security.KeyManagementException
;
import
java.security.NoSuchAlgorithmException
;
...
...
@@ -133,7 +134,7 @@ public class GNUAPI {
* @param jsonArray JSONArray
* @return List<Account>
*/
private
static
List
<
Account
>
parseGroups
(
Context
context
,
JSONArray
jsonArray
)
{
private
static
List
<
Account
>
parseGroups
(
JSONArray
jsonArray
)
{
List
<
Account
>
groups
=
new
ArrayList
<>();
try
{
...
...
@@ -141,7 +142,7 @@ public class GNUAPI {
while
(
i
<
jsonArray
.
length
())
{
JSONObject
resobj
=
jsonArray
.
getJSONObject
(
i
);
Account
group
=
parseGroups
(
context
,
resobj
);
Account
group
=
parseGroups
(
resobj
);
i
++;
groups
.
add
(
group
);
}
...
...
@@ -158,7 +159,7 @@ public class GNUAPI {
* @param resobj JSONObject
* @return Account
*/
private
static
Account
parseGroups
(
Context
context
,
JSONObject
resobj
)
{
private
static
Account
parseGroups
(
JSONObject
resobj
)
{
Account
group
=
new
Account
();
try
{
group
.
setId
(
resobj
.
get
(
"id"
).
toString
());
...
...
@@ -293,9 +294,9 @@ public class GNUAPI {
}
status
.
setApplication
(
application
);
if
(
resobj
.
has
(
"user"
))
status
.
setAccount
(
parseAccountResponse
(
context
,
resobj
.
getJSONObject
(
"user"
)));
status
.
setAccount
(
parseAccountResponse
(
resobj
.
getJSONObject
(
"user"
)));
else
if
(
resobj
.
has
(
"sender"
))
status
.
setAccount
(
parseAccountResponse
(
context
,
resobj
.
getJSONObject
(
"sender"
)));
status
.
setAccount
(
parseAccountResponse
(
resobj
.
getJSONObject
(
"sender"
)));
if
(
resobj
.
has
(
"statusnet_html"
))
status
.
setContent
(
context
,
resobj
.
get
(
"statusnet_html"
).
toString
());
else
if
(
resobj
.
has
(
"text"
))
...
...
@@ -346,7 +347,7 @@ public class GNUAPI {
e
.
printStackTrace
();
}
status
.
setViewType
(
context
);
Status
.
fillSpan
(
context
,
status
);
Status
.
fillSpan
(
new
WeakReference
<>(
context
)
,
status
);
return
status
;
}
...
...
@@ -357,7 +358,7 @@ public class GNUAPI {
* @param resobj JSONObject
* @return Account
*/
public
static
Account
parseAccountResponse
(
Context
context
,
JSONObject
resobj
)
{
public
static
Account
parseAccountResponse
(
JSONObject
resobj
)
{
Account
account
=
new
Account
();
try
{
...
...
@@ -553,7 +554,7 @@ public class GNUAPI {
}
try
{
String
response
=
new
HttpsConnection
(
context
,
this
.
instance
).
get
(
getAbsoluteUrl
(
"/account/verify_credentials.json"
),
60
,
null
,
prefKeyOauthTokenT
);
account
=
parseAccountResponse
(
context
,
new
JSONObject
(
response
));
account
=
parseAccountResponse
(
new
JSONObject
(
response
));
if
(
social
!=
null
)
{
account
.
setSocial
(
social
.
toUpperCase
());
}
...
...
@@ -579,7 +580,7 @@ public class GNUAPI {
params
.
put
(
"user_id"
,
accountId
);
try
{
String
response
=
new
HttpsConnection
(
context
,
this
.
instance
).
get
(
getAbsoluteUrl
(
"/users/show.json"
),
60
,
params
,
prefKeyOauthTokenT
);
account
=
parseAccountResponse
(
context
,
new
JSONObject
(
response
));
account
=
parseAccountResponse
(
new
JSONObject
(
response
));
}
catch
(
HttpsConnection
.
HttpsConnectionException
e
)
{
setError
(
e
.
getStatusCode
(),
e
);
e
.
printStackTrace
();
...
...
@@ -619,7 +620,7 @@ public class GNUAPI {
try
{
HttpsConnection
httpsConnection
=
new
HttpsConnection
(
context
,
this
.
instance
);
String
response
=
httpsConnection
.
get
(
getAbsoluteUrl
(
"/statusnet/groups/list.json"
),
60
,
params
,
prefKeyOauthTokenT
);
accounts
=
parseGroups
(
context
,
new
JSONArray
(
response
));
accounts
=
parseGroups
(
new
JSONArray
(
response
));
if
(
accounts
.
size
()
>
0
)
{
apiResponse
.
setSince_id
(
accounts
.
get
(
0
).
getId
());
apiResponse
.
setMax_id
(
accounts
.
get
(
accounts
.
size
()
-
1
).
getId
());
...
...
@@ -1771,7 +1772,7 @@ public class GNUAPI {
Notification
notification
=
new
Notification
();
notification
.
setType
(
stringType
);
notification
.
setId
(
st
.
getId
());
Status
.
fillSpan
(
context
,
st
);
Status
.
fillSpan
(
new
WeakReference
<>(
context
)
,
st
);
notification
.
setStatus
(
st
);
notification
.
setAccount
(
st
.
getAccount
());
notifications
.
add
(
notification
);
...
...
@@ -1934,7 +1935,7 @@ public class GNUAPI {
int
i
=
0
;
while
(
i
<
jsonArray
.
length
())
{
JSONObject
resobj
=
jsonArray
.
getJSONObject
(
i
);
Account
account
=
parseAccountResponse
(
context
,
resobj
);
Account
account
=
parseAccountResponse
(
resobj
);
accounts
.
add
(
account
);
i
++;
}
...
...
app/src/main/java/app/fedilab/android/client/PeertubeAPI.java
View file @
e0c2d586
...
...
@@ -125,7 +125,7 @@ public class PeertubeAPI {
* @param resobj JSONObject
* @return Peertube
*/
private
static
PeertubeNotification
parsePeertubeNotifications
(
Context
context
,
JSONObject
resobj
)
{
private
static
PeertubeNotification
parsePeertubeNotifications
(
JSONObject
resobj
)
{
PeertubeNotification
peertubeNotification
=
new
PeertubeNotification
();
try
{
peertubeNotification
.
setId
(
resobj
.
get
(
"id"
).
toString
());
...
...
@@ -230,7 +230,7 @@ public class PeertubeAPI {
* @param resobj JSONObject
* @return Peertube
*/
private
static
Peertube
parsePeertube
(
Context
context
,
JSONObject
resobj
)
{
private
static
Peertube
parsePeertube
(
JSONObject
resobj
)
{
Peertube
peertube
=
new
Peertube
();
if
(
resobj
.
has
(
"video"
))
{
try
{
...
...
@@ -248,9 +248,9 @@ public class PeertubeAPI {
peertube
.
setEmbedPath
(
resobj
.
get
(
"embedPath"
).
toString
());
peertube
.
setPreviewPath
(
resobj
.
get
(
"previewPath"
).
toString
());
peertube
.
setThumbnailPath
(
resobj
.
get
(
"thumbnailPath"
).
toString
());
peertube
.
setAccount
(
parseAccountResponsePeertube
(
context
,
resobj
.
getJSONObject
(
"account"
)));
peertube
.
setAccount
(
parseAccountResponsePeertube
(
resobj
.
getJSONObject
(
"account"
)));
try
{
peertube
.
setChannel
(
parseAccountResponsePeertube
(
context
,
resobj
.
getJSONObject
(
"channel"
)));
peertube
.
setChannel
(
parseAccountResponsePeertube
(
resobj
.
getJSONObject
(
"channel"
)));
}
catch
(
Exception
ignored
)
{
}
peertube
.
setView
(
Integer
.
parseInt
(
resobj
.
get
(
"views"
).
toString
()));
...
...
@@ -298,7 +298,7 @@ publi