Some cleaning and adds previous streaming service if user wants to stop the new one.
This commit is contained in:
parent
bf8d5eb734
commit
5bf0472d18
|
@ -38,15 +38,19 @@
|
||||||
<service
|
<service
|
||||||
android:name=".services.StreamingService"
|
android:name=".services.StreamingService"
|
||||||
android:exported="false"/>
|
android:exported="false"/>
|
||||||
|
<service
|
||||||
|
android:name=".services.LiveNotificationService"
|
||||||
|
android:exported="false"/>
|
||||||
<receiver android:name=".services.RestartServiceReceiver"
|
<receiver android:name=".services.RestartServiceReceiver"
|
||||||
android:exported="false">
|
android:exported="false">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="RestartStreamingService" />
|
<action android:name="RestartStreamingService" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
<receiver android:name=".services.RestartServiceReceiver" >
|
<receiver android:name=".services.RestartLiveNotificationReceiver"
|
||||||
<!-- This intent filter receives the boot completed event -->
|
android:exported="false">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
<action android:name="RestartStreamingService" />
|
||||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
|
@ -32,6 +32,7 @@ import android.widget.Toast;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRelationshipAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRelationshipAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRemoteAccountsAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRemoteAccountsAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||||
|
@ -43,7 +44,6 @@ import fr.gouv.etalab.mastodon.helper.ExpandableHeightListView;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRelationshipInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRelationshipInterface;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRemoteAccountInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRemoteAccountInterface;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -50,12 +50,13 @@ import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.UnrecoverableKeyException;
|
import java.security.UnrecoverableKeyException;
|
||||||
|
|
||||||
import cz.msebera.android.httpclient.Header;
|
import cz.msebera.android.httpclient.Header;
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.KinrarClient;
|
import fr.gouv.etalab.mastodon.client.KinrarClient;
|
||||||
import fr.gouv.etalab.mastodon.client.MastalabSSLSocketFactory;
|
import fr.gouv.etalab.mastodon.client.MastalabSSLSocketFactory;
|
||||||
import fr.gouv.etalab.mastodon.client.OauthClient;
|
import fr.gouv.etalab.mastodon.client.OauthClient;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.USER_AGENT;
|
import static fr.gouv.etalab.mastodon.helper.Helper.USER_AGENT;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
||||||
|
|
|
@ -74,6 +74,7 @@ import java.util.Locale;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveInstanceAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveInstanceAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveMetaDataAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveMetaDataAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoByIDAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoByIDAsyncTask;
|
||||||
|
@ -92,6 +93,7 @@ import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveInstanceInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveInstanceInterface;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveMetaDataInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveMetaDataInterface;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnUpdateAccountInfoInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnUpdateAccountInfoInterface;
|
||||||
|
import fr.gouv.etalab.mastodon.services.LiveNotificationService;
|
||||||
import fr.gouv.etalab.mastodon.services.StreamingService;
|
import fr.gouv.etalab.mastodon.services.StreamingService;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
|
||||||
|
@ -1057,22 +1059,22 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
Bundle b = intent.getExtras();
|
Bundle b = intent.getExtras();
|
||||||
StreamingService.EventStreaming eventStreaming = (StreamingService.EventStreaming) intent.getSerializableExtra("eventStreaming");
|
LiveNotificationService.EventStreaming eventStreaming = (LiveNotificationService.EventStreaming) intent.getSerializableExtra("eventStreaming");
|
||||||
assert b != null;
|
assert b != null;
|
||||||
userIdService = b.getString("userIdService", null);
|
userIdService = b.getString("userIdService", null);
|
||||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
if( userIdService != null && userIdService.equals(userId)) {
|
if( userIdService != null && userIdService.equals(userId)) {
|
||||||
if (eventStreaming == StreamingService.EventStreaming.NOTIFICATION) {
|
if (eventStreaming == LiveNotificationService.EventStreaming.NOTIFICATION) {
|
||||||
Notification notification = b.getParcelable("data");
|
Notification notification = b.getParcelable("data");
|
||||||
if (notificationsFragment != null) {
|
if (notificationsFragment != null) {
|
||||||
notificationsFragment.refresh(notification);
|
notificationsFragment.refresh(notification);
|
||||||
}
|
}
|
||||||
} else if (eventStreaming == StreamingService.EventStreaming.UPDATE) {
|
} else if (eventStreaming == LiveNotificationService.EventStreaming.UPDATE) {
|
||||||
Status status = b.getParcelable("data");
|
Status status = b.getParcelable("data");
|
||||||
if (homeFragment != null) {
|
if (homeFragment != null) {
|
||||||
homeFragment.refresh(status);
|
homeFragment.refresh(status);
|
||||||
}
|
}
|
||||||
} else if (eventStreaming == StreamingService.EventStreaming.DELETE) {
|
} else if (eventStreaming == LiveNotificationService.EventStreaming.DELETE) {
|
||||||
//noinspection unused
|
//noinspection unused
|
||||||
String id = b.getString("id");
|
String id = b.getString("id");
|
||||||
if (notificationsFragment != null) {
|
if (notificationsFragment != null) {
|
||||||
|
@ -1460,9 +1462,17 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
return activityPaused;
|
return activityPaused;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void startSreaming(boolean restart){
|
public void startSreaming(boolean restart){
|
||||||
streamingIntent = new Intent(this, StreamingService.class);
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||||
streamingIntent.putExtra("restart",restart);
|
boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
|
||||||
|
boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true);
|
||||||
|
if( notify && liveNotifications) {
|
||||||
|
streamingIntent = new Intent(this, LiveNotificationService.class);
|
||||||
|
streamingIntent.putExtra("restart", restart);
|
||||||
|
}else {
|
||||||
|
streamingIntent = new Intent(this, StreamingService.class);
|
||||||
|
}
|
||||||
startService(streamingIntent);
|
startService(streamingIntent);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -58,6 +58,8 @@ import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountInfoAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountInfoAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.UpdateCredentialAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.UpdateCredentialAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||||
|
@ -69,7 +71,7 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountInterface;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnUpdateCredentialInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnUpdateCredentialInterface;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,13 +33,14 @@ import android.widget.Toast;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||||
import fr.gouv.etalab.mastodon.drawers.StatusListAdapter;
|
import fr.gouv.etalab.mastodon.drawers.StatusListAdapter;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -31,12 +31,13 @@ import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveInstanceAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveInstanceAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Instance;
|
import fr.gouv.etalab.mastodon.client.Entities.Instance;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveInstanceInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveInstanceInterface;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
||||||
|
|
||||||
|
|
|
@ -63,11 +63,12 @@ import java.security.UnrecoverableKeyException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import cz.msebera.android.httpclient.Header;
|
import cz.msebera.android.httpclient.Header;
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Attachment;
|
import fr.gouv.etalab.mastodon.client.Entities.Attachment;
|
||||||
import fr.gouv.etalab.mastodon.client.MastalabSSLSocketFactory;
|
import fr.gouv.etalab.mastodon.client.MastalabSSLSocketFactory;
|
||||||
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.EXTERNAL_STORAGE_REQUEST_CODE;
|
import static fr.gouv.etalab.mastodon.helper.Helper.EXTERNAL_STORAGE_REQUEST_CODE;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.USER_AGENT;
|
import static fr.gouv.etalab.mastodon.helper.Helper.USER_AGENT;
|
||||||
|
|
|
@ -19,8 +19,10 @@ import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -63,6 +63,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cz.msebera.android.httpclient.Header;
|
import cz.msebera.android.httpclient.Header;
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRelationshipAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRelationshipAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRemoteAccountsAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRemoteAccountsAsyncTask;
|
||||||
|
@ -81,7 +82,7 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRelationshipInterface;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRemoteAccountInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRemoteAccountInterface;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -26,6 +26,7 @@ import android.widget.RelativeLayout;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveSearchAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveSearchAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
||||||
|
@ -34,7 +35,7 @@ import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||||
import fr.gouv.etalab.mastodon.drawers.SearchListAdapter;
|
import fr.gouv.etalab.mastodon.drawers.SearchListAdapter;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearchInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearchInterface;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -70,6 +70,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.hdodenhof.circleimageview.CircleImageView;
|
import de.hdodenhof.circleimageview.CircleImageView;
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
|
||||||
|
@ -90,7 +91,6 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountInterface;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsAccountInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsAccountInterface;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRelationshipInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRelationshipInterface;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Relationship;
|
import fr.gouv.etalab.mastodon.client.Entities.Relationship;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveContextAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveContextAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||||
|
@ -65,7 +66,6 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveContextInterface;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -143,7 +143,7 @@ import fr.gouv.etalab.mastodon.jobs.ScheduledTootsSyncJob;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.StatusStoredDAO;
|
import fr.gouv.etalab.mastodon.sqlite.StatusStoredDAO;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.HOME_TIMELINE_INTENT;
|
import static fr.gouv.etalab.mastodon.helper.Helper.HOME_TIMELINE_INTENT;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION;
|
import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION;
|
||||||
|
|
|
@ -37,7 +37,7 @@ import android.widget.FrameLayout;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.webview.MastalabWebChromeClient;
|
import fr.gouv.etalab.mastodon.webview.MastalabWebChromeClient;
|
||||||
import fr.gouv.etalab.mastodon.webview.MastalabWebViewClient;
|
import fr.gouv.etalab.mastodon.webview.MastalabWebViewClient;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.EXTERNAL_STORAGE_REQUEST_CODE;
|
import static fr.gouv.etalab.mastodon.helper.Helper.EXTERNAL_STORAGE_REQUEST_CODE;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.manageDownloads;
|
import static fr.gouv.etalab.mastodon.helper.Helper.manageDownloads;
|
||||||
|
|
|
@ -43,7 +43,7 @@ import cz.msebera.android.httpclient.Header;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.OauthClient;
|
import fr.gouv.etalab.mastodon.client.OauthClient;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Thomas on 24/04/2017.
|
* Created by Thomas on 24/04/2017.
|
||||||
|
|
|
@ -45,11 +45,12 @@ import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import cz.msebera.android.httpclient.Header;
|
import cz.msebera.android.httpclient.Header;
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.*;
|
import fr.gouv.etalab.mastodon.client.Entities.*;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAttachmentInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAttachmentInterface;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.USER_AGENT;
|
import static fr.gouv.etalab.mastodon.helper.Helper.USER_AGENT;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.text.Html;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -42,6 +41,7 @@ import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
|
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.API;
|
import fr.gouv.etalab.mastodon.client.API;
|
||||||
|
@ -50,9 +50,7 @@ import fr.gouv.etalab.mastodon.client.Entities.Error;
|
||||||
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,11 +109,11 @@ public class AccountSearchDevAdapter extends BaseAdapter implements OnPostAction
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = layoutInflater.inflate(R.layout.drawer_account_search_dev, parent, false);
|
convertView = layoutInflater.inflate(R.layout.drawer_account_search_dev, parent, false);
|
||||||
holder = new ViewHolder();
|
holder = new ViewHolder();
|
||||||
holder.account_pp = (ImageView) convertView.findViewById(R.id.account_pp);
|
holder.account_pp = convertView.findViewById(R.id.account_pp);
|
||||||
holder.account_dn = (TextView) convertView.findViewById(R.id.account_dn);
|
holder.account_dn = convertView.findViewById(R.id.account_dn);
|
||||||
holder.account_un = (TextView) convertView.findViewById(R.id.account_un);
|
holder.account_un = convertView.findViewById(R.id.account_un);
|
||||||
holder.account_follow = (FloatingActionButton) convertView.findViewById(R.id.account_follow);
|
holder.account_follow = convertView.findViewById(R.id.account_follow);
|
||||||
holder.acccount_container = (LinearLayout) convertView.findViewById(R.id.acccount_container);
|
holder.acccount_container = convertView.findViewById(R.id.acccount_container);
|
||||||
convertView.setTag(holder);
|
convertView.setTag(holder);
|
||||||
} else {
|
} else {
|
||||||
holder = (ViewHolder) convertView.getTag();
|
holder = (ViewHolder) convertView.getTag();
|
||||||
|
@ -124,6 +122,7 @@ public class AccountSearchDevAdapter extends BaseAdapter implements OnPostAction
|
||||||
final float scale = context.getResources().getDisplayMetrics().density;
|
final float scale = context.getResources().getDisplayMetrics().density;
|
||||||
if( account != null && account.isLocked()){
|
if( account != null && account.isLocked()){
|
||||||
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_lock_outline);
|
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_lock_outline);
|
||||||
|
assert img != null;
|
||||||
img.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (20 * scale + 0.5f));
|
img.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (20 * scale + 0.5f));
|
||||||
holder.account_dn.setCompoundDrawables( null, null, img, null);
|
holder.account_dn.setCompoundDrawables( null, null, img, null);
|
||||||
}else{
|
}else{
|
||||||
|
@ -132,13 +131,15 @@ public class AccountSearchDevAdapter extends BaseAdapter implements OnPostAction
|
||||||
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
assert account != null;
|
||||||
holder.account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
|
holder.account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
|
||||||
holder.account_un.setText(String.format("@%s",account.getAcct()));
|
holder.account_un.setText(String.format("@%s",account.getAcct()));
|
||||||
}else {
|
}else {
|
||||||
|
assert account != null;
|
||||||
holder.account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
|
holder.account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
|
||||||
holder.account_un.setText(String.format("@%s",account.getAcct()));
|
holder.account_un.setText(String.format("@%s",account.getAcct()));
|
||||||
}
|
}
|
||||||
changeDrawableColor(context, R.drawable.ic_lock_outline,R.color.mastodonC4);
|
Helper.changeDrawableColor(context, R.drawable.ic_lock_outline,R.color.mastodonC4);
|
||||||
//Profile picture
|
//Profile picture
|
||||||
imageLoader.displayImage(account.getAvatar(), holder.account_pp, options);
|
imageLoader.displayImage(account.getAvatar(), holder.account_pp, options);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,6 +39,8 @@ import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.API;
|
import fr.gouv.etalab.mastodon.client.API;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||||
|
@ -46,7 +48,6 @@ import fr.gouv.etalab.mastodon.client.Entities.Error;
|
||||||
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
|
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,10 @@ import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||||
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
|
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.activities.TootActivity;
|
import fr.gouv.etalab.mastodon.activities.TootActivity;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,12 +35,14 @@ import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Mention;
|
import fr.gouv.etalab.mastodon.client.Entities.Mention;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -38,7 +38,7 @@ import java.util.List;
|
||||||
|
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Emojis;
|
import fr.gouv.etalab.mastodon.client.Entities.Emojis;
|
||||||
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Thomas on 03/11/2017.
|
* Created by Thomas on 03/11/2017.
|
||||||
|
|
|
@ -38,7 +38,7 @@ import fr.gouv.etalab.mastodon.client.Entities.StoredStatus;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.StatusStoredDAO;
|
import fr.gouv.etalab.mastodon.sqlite.StatusStoredDAO;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,9 @@ import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Emojis;
|
import fr.gouv.etalab.mastodon.client.Entities.Emojis;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -57,6 +57,7 @@ import java.io.FileOutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.activities.MediaActivity;
|
import fr.gouv.etalab.mastodon.activities.MediaActivity;
|
||||||
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
|
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
|
||||||
import fr.gouv.etalab.mastodon.activities.ShowConversationActivity;
|
import fr.gouv.etalab.mastodon.activities.ShowConversationActivity;
|
||||||
|
@ -73,7 +74,6 @@ import fr.gouv.etalab.mastodon.helper.CrossActions;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnPostNotificationsActionInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnPostNotificationsActionInterface;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveEmojiInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveEmojiInterface;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Notification;
|
import fr.gouv.etalab.mastodon.client.Entities.Notification;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
|
|
|
@ -51,7 +51,7 @@ import fr.gouv.etalab.mastodon.jobs.ApplicationJob;
|
||||||
import fr.gouv.etalab.mastodon.jobs.ScheduledTootsSyncJob;
|
import fr.gouv.etalab.mastodon.jobs.ScheduledTootsSyncJob;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.StatusStoredDAO;
|
import fr.gouv.etalab.mastodon.sqlite.StatusStoredDAO;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||||
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -71,6 +71,7 @@ import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.activities.MediaActivity;
|
import fr.gouv.etalab.mastodon.activities.MediaActivity;
|
||||||
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
|
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
|
||||||
import fr.gouv.etalab.mastodon.activities.ShowConversationActivity;
|
import fr.gouv.etalab.mastodon.activities.ShowConversationActivity;
|
||||||
|
@ -93,7 +94,6 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveEmojiInterface;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRepliesInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRepliesInterface;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnTranslatedInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnTranslatedInterface;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
import static fr.gouv.etalab.mastodon.activities.MainActivity.currentLocale;
|
import static fr.gouv.etalab.mastodon.activities.MainActivity.currentLocale;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.THEME_DARK;
|
import static fr.gouv.etalab.mastodon.helper.Helper.THEME_DARK;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import android.widget.BaseAdapter;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -26,7 +26,8 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -40,7 +40,7 @@ import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Relationship;
|
import fr.gouv.etalab.mastodon.client.Entities.Relationship;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveManyRelationshipsInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveManyRelationshipsInterface;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.drawers.AccountsListAdapter;
|
import fr.gouv.etalab.mastodon.drawers.AccountsListAdapter;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountsInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountsInterface;
|
||||||
|
|
|
@ -37,7 +37,7 @@ import fr.gouv.etalab.mastodon.drawers.DraftsListAdapter;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.StatusStoredDAO;
|
import fr.gouv.etalab.mastodon.sqlite.StatusStoredDAO;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||||
import fr.gouv.etalab.mastodon.drawers.AccountsFollowRequestAdapter;
|
import fr.gouv.etalab.mastodon.drawers.AccountsFollowRequestAdapter;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountsInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountsInterface;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,13 +33,13 @@ import android.widget.Toast;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveMissingNotificationsAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveMissingNotificationsAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||||
import fr.gouv.etalab.mastodon.drawers.NotificationsListAdapter;
|
import fr.gouv.etalab.mastodon.drawers.NotificationsListAdapter;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveMissingNotificationsInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveMissingNotificationsInterface;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveNotificationsAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveNotificationsAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Notification;
|
import fr.gouv.etalab.mastodon.client.Entities.Notification;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveNotificationsInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveNotificationsInterface;
|
||||||
|
|
|
@ -42,7 +42,7 @@ import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveScheduledTootsInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveScheduledTootsInterface;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.StatusStoredDAO;
|
import fr.gouv.etalab.mastodon.sqlite.StatusStoredDAO;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ import android.widget.Toast;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveMissingFeedsAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveMissingFeedsAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||||
|
@ -43,7 +44,6 @@ import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveMissingFeedsInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveMissingFeedsInterface;
|
||||||
import fr.gouv.etalab.mastodon.services.StreamingFederatedTimelineService;
|
import fr.gouv.etalab.mastodon.services.StreamingFederatedTimelineService;
|
||||||
import fr.gouv.etalab.mastodon.services.StreamingLocalTimelineService;
|
import fr.gouv.etalab.mastodon.services.StreamingLocalTimelineService;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
|
||||||
|
|
|
@ -52,7 +52,7 @@ import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
import static android.app.Activity.RESULT_OK;
|
import static android.app.Activity.RESULT_OK;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.CHANGE_THEME_INTENT;
|
import static fr.gouv.etalab.mastodon.helper.Helper.CHANGE_THEME_INTENT;
|
||||||
|
|
|
@ -16,10 +16,8 @@ package fr.gouv.etalab.mastodon.fragments;
|
||||||
|
|
||||||
import android.app.TimePickerDialog;
|
import android.app.TimePickerDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
@ -41,15 +39,8 @@ import android.widget.TimePicker;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import fr.gouv.etalab.mastodon.activities.BaseMainActivity;
|
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.services.StreamingService;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.compareDate;
|
import static fr.gouv.etalab.mastodon.helper.Helper.compareDate;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import android.widget.SeekBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,7 +24,7 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,7 +41,7 @@ import fr.gouv.etalab.mastodon.drawers.AccountsSearchAdapter;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will handle cross actions between accounts boost/favourites/pin and replies
|
* Will handle cross actions between accounts boost/favourites/pin and replies
|
||||||
|
|
|
@ -123,6 +123,7 @@ import java.util.TimeZone;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.activities.HashTagActivity;
|
import fr.gouv.etalab.mastodon.activities.HashTagActivity;
|
||||||
import fr.gouv.etalab.mastodon.activities.LoginActivity;
|
import fr.gouv.etalab.mastodon.activities.LoginActivity;
|
||||||
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
||||||
|
@ -140,7 +141,6 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveEmojiInterface;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.CustomEmojiDAO;
|
import fr.gouv.etalab.mastodon.sqlite.CustomEmojiDAO;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
import static android.content.Context.DOWNLOAD_SERVICE;
|
import static android.content.Context.DOWNLOAD_SERVICE;
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveHomeTimelineServiceAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveHomeTimelineServiceAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||||
|
@ -50,7 +51,7 @@ import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveHomeTimelineServiceInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveHomeTimelineServiceInterface;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.HOME_TIMELINE_INTENT;
|
import static fr.gouv.etalab.mastodon.helper.Helper.HOME_TIMELINE_INTENT;
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION;
|
import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION;
|
||||||
|
|
|
@ -44,7 +44,7 @@ import fr.gouv.etalab.mastodon.activities.MainActivity;
|
||||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||||
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveNotificationsAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveNotificationsAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Notification;
|
import fr.gouv.etalab.mastodon.client.Entities.Notification;
|
||||||
|
|
|
@ -0,0 +1,369 @@
|
||||||
|
package fr.gouv.etalab.mastodon.services;
|
||||||
|
/* Copyright 2017 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of Mastalab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
import android.app.Service;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.os.SystemClock;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
|
||||||
|
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
|
||||||
|
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||||
|
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||||
|
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
||||||
|
import com.nostra13.universalimageloader.core.assist.FailReason;
|
||||||
|
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
|
||||||
|
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
import fr.gouv.etalab.mastodon.activities.BaseMainActivity;
|
||||||
|
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
||||||
|
import fr.gouv.etalab.mastodon.client.API;
|
||||||
|
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||||
|
import fr.gouv.etalab.mastodon.client.Entities.Notification;
|
||||||
|
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||||
|
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
||||||
|
import fr.gouv.etalab.mastodon.client.TLSSocketFactory;
|
||||||
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
|
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||||
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
|
|
||||||
|
import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION;
|
||||||
|
import static fr.gouv.etalab.mastodon.helper.Helper.NOTIFICATION_INTENT;
|
||||||
|
import static fr.gouv.etalab.mastodon.helper.Helper.PREF_KEY_ID;
|
||||||
|
import static fr.gouv.etalab.mastodon.helper.Helper.notify_user;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Thomas on 28/08/2017.
|
||||||
|
* Manage service for streaming api and new notifications
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LiveNotificationService extends Service {
|
||||||
|
|
||||||
|
|
||||||
|
public enum EventStreaming{
|
||||||
|
UPDATE,
|
||||||
|
NOTIFICATION,
|
||||||
|
DELETE,
|
||||||
|
NONE
|
||||||
|
}
|
||||||
|
protected Account account;
|
||||||
|
|
||||||
|
private boolean restartCalled;
|
||||||
|
|
||||||
|
public void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
restartCalled = false;
|
||||||
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
|
||||||
|
boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true);
|
||||||
|
if( liveNotifications && notify){
|
||||||
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
|
List<Account> accountStreams = new AccountDAO(getApplicationContext(), db).getAllAccount();
|
||||||
|
for(final Account accountStream: accountStreams){
|
||||||
|
Thread thread = new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
streamOnUser(accountStream);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
Bundle extras = intent.getExtras();
|
||||||
|
if(extras != null) {
|
||||||
|
boolean restart = (boolean) extras.get("restart");
|
||||||
|
if( restart) {
|
||||||
|
SystemClock.sleep(1000);
|
||||||
|
sendBroadcast(new Intent("RestartStreamingService"));
|
||||||
|
stopSelf();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return START_STICKY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public IBinder onBind(Intent intent) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void streamOnUser(Account accountStream){
|
||||||
|
InputStream inputStream = null;
|
||||||
|
HttpsURLConnection httpsURLConnection = null;
|
||||||
|
BufferedReader reader = null;
|
||||||
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
EventStreaming lastEvent = null;
|
||||||
|
if( accountStream != null){
|
||||||
|
try {
|
||||||
|
URL url = new URL("https://" + accountStream.getInstance() + "/api/v1/streaming/user");
|
||||||
|
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
||||||
|
httpsURLConnection.setRequestProperty("Content-Type", "application/json");
|
||||||
|
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + accountStream.getToken());
|
||||||
|
httpsURLConnection.setRequestProperty("Connection", "Keep-Alive");
|
||||||
|
httpsURLConnection.setRequestProperty("Keep-Alive", "header");
|
||||||
|
httpsURLConnection.setRequestProperty("Connection", "close");
|
||||||
|
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
|
||||||
|
httpsURLConnection.setRequestMethod("GET");
|
||||||
|
httpsURLConnection.setConnectTimeout(70000);
|
||||||
|
httpsURLConnection.setReadTimeout(70000);
|
||||||
|
inputStream = new BufferedInputStream(httpsURLConnection.getInputStream());
|
||||||
|
reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||||
|
String event;
|
||||||
|
EventStreaming eventStreaming;
|
||||||
|
while((event = reader.readLine()) != null) {
|
||||||
|
if( !sharedpreferences.getBoolean(Helper.SHOULD_CONTINUE_STREAMING, true) ) {
|
||||||
|
stopSelf();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((lastEvent == EventStreaming.NONE || lastEvent == null) && !event.startsWith("data: ")) {
|
||||||
|
switch (event.trim()) {
|
||||||
|
case "event: update":
|
||||||
|
lastEvent = EventStreaming.UPDATE;
|
||||||
|
break;
|
||||||
|
case "event: notification":
|
||||||
|
lastEvent = EventStreaming.NOTIFICATION;
|
||||||
|
break;
|
||||||
|
case "event: delete":
|
||||||
|
lastEvent = EventStreaming.DELETE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
lastEvent = EventStreaming.NONE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!event.startsWith("data: ")) {
|
||||||
|
lastEvent = EventStreaming.NONE;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
event = event.substring(6);
|
||||||
|
if (lastEvent == EventStreaming.UPDATE) {
|
||||||
|
eventStreaming = EventStreaming.UPDATE;
|
||||||
|
} else if (lastEvent == EventStreaming.NOTIFICATION) {
|
||||||
|
eventStreaming = EventStreaming.NOTIFICATION;
|
||||||
|
} else if (lastEvent == EventStreaming.DELETE) {
|
||||||
|
eventStreaming = EventStreaming.DELETE;
|
||||||
|
event = "{id:" + event + "}";
|
||||||
|
} else {
|
||||||
|
eventStreaming = EventStreaming.UPDATE;
|
||||||
|
}
|
||||||
|
lastEvent = EventStreaming.NONE;
|
||||||
|
try {
|
||||||
|
JSONObject eventJson = new JSONObject(event);
|
||||||
|
onRetrieveStreaming(eventStreaming, accountStream, eventJson);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}finally {
|
||||||
|
if(reader != null){
|
||||||
|
try{
|
||||||
|
reader.close();
|
||||||
|
}catch (IOException ignored){}
|
||||||
|
}
|
||||||
|
if (inputStream != null) {
|
||||||
|
try {
|
||||||
|
inputStream.close();
|
||||||
|
} catch (IOException ignored) {}
|
||||||
|
}
|
||||||
|
if( httpsURLConnection != null)
|
||||||
|
httpsURLConnection.disconnect();
|
||||||
|
if( !restartCalled ) {
|
||||||
|
restartCalled = true;
|
||||||
|
SystemClock.sleep(1000);
|
||||||
|
sendBroadcast(new Intent("RestartStreamingService"));
|
||||||
|
stopSelf();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onRetrieveStreaming(EventStreaming event, final Account account, JSONObject response) {
|
||||||
|
if( response == null )
|
||||||
|
return;
|
||||||
|
//No previous notifications in cache, so no notification will be sent
|
||||||
|
Status status ;
|
||||||
|
final Notification notification;
|
||||||
|
String dataId = null;
|
||||||
|
|
||||||
|
Bundle b = new Bundle();
|
||||||
|
if( event == EventStreaming.NOTIFICATION){
|
||||||
|
notification = API.parseNotificationResponse(getApplicationContext(), response);
|
||||||
|
b.putParcelable("data", notification);
|
||||||
|
boolean activityPaused;
|
||||||
|
try {
|
||||||
|
activityPaused = BaseMainActivity.activityState();
|
||||||
|
}catch (Exception e){
|
||||||
|
activityPaused = true;
|
||||||
|
}
|
||||||
|
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
|
||||||
|
boolean canNotify = Helper.canNotify(getApplicationContext());
|
||||||
|
boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true);
|
||||||
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
|
|
||||||
|
if((userId == null || !userId.equals(account.getId()) || activityPaused) && liveNotifications && canNotify && notify) {
|
||||||
|
boolean notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true);
|
||||||
|
boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true);
|
||||||
|
boolean notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true);
|
||||||
|
boolean notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true);
|
||||||
|
boolean somethingToPush = (notif_follow || notif_add || notif_mention || notif_share);
|
||||||
|
String title = null;
|
||||||
|
if( somethingToPush && notification != null){
|
||||||
|
switch (notification.getType()){
|
||||||
|
case "mention":
|
||||||
|
if(notif_mention){
|
||||||
|
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0 )
|
||||||
|
title = String.format("@%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getApplicationContext().getString(R.string.notif_mention));
|
||||||
|
else
|
||||||
|
title = String.format("@%s %s", notification.getAccount().getUsername(),getApplicationContext().getString(R.string.notif_mention));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "reblog":
|
||||||
|
if(notif_share){
|
||||||
|
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0 )
|
||||||
|
title = String.format("@%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getApplicationContext().getString(R.string.notif_reblog));
|
||||||
|
else
|
||||||
|
title = String.format("@%s %s", notification.getAccount().getUsername(),getApplicationContext().getString(R.string.notif_reblog));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "favourite":
|
||||||
|
if(notif_add){
|
||||||
|
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0 )
|
||||||
|
title = String.format("@%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getApplicationContext().getString(R.string.notif_favourite));
|
||||||
|
else
|
||||||
|
title = String.format("@%s %s", notification.getAccount().getUsername(),getApplicationContext().getString(R.string.notif_favourite));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "follow":
|
||||||
|
if(notif_follow){
|
||||||
|
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0 )
|
||||||
|
title = String.format("@%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getApplicationContext().getString(R.string.notif_follow));
|
||||||
|
else
|
||||||
|
title = String.format("@%s %s", notification.getAccount().getUsername(),getApplicationContext().getString(R.string.notif_follow));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
//Some others notification
|
||||||
|
final Intent intent = new Intent(getApplicationContext(), MainActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK );
|
||||||
|
intent.putExtra(INTENT_ACTION, NOTIFICATION_INTENT);
|
||||||
|
intent.putExtra(PREF_KEY_ID, account.getId());
|
||||||
|
long notif_id = Long.parseLong(account.getId());
|
||||||
|
final int notificationId = ((notif_id + 1) > 2147483647) ? (int) (2147483647 - notif_id - 1) : (int) (notif_id + 1);
|
||||||
|
if( notification.getAccount().getAvatar() != null ) {
|
||||||
|
ImageLoader imageLoaderNoty = ImageLoader.getInstance();
|
||||||
|
File cacheDir = new File(getApplicationContext().getCacheDir(), getApplicationContext().getString(R.string.app_name));
|
||||||
|
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
|
||||||
|
.imageDownloader(new PatchBaseImageDownloader(getApplicationContext()))
|
||||||
|
.threadPoolSize(5)
|
||||||
|
.threadPriority(Thread.MIN_PRIORITY + 3)
|
||||||
|
.denyCacheImageMultipleSizesInMemory()
|
||||||
|
.diskCache(new UnlimitedDiskCache(cacheDir))
|
||||||
|
.build();
|
||||||
|
imageLoaderNoty.init(config);
|
||||||
|
DisplayImageOptions options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
|
||||||
|
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||||
|
|
||||||
|
final String finalTitle = title;
|
||||||
|
if( title != null) {
|
||||||
|
imageLoaderNoty.loadImage(notification.getAccount().getAvatar(), options, new SimpleImageLoadingListener() {
|
||||||
|
@Override
|
||||||
|
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||||
|
super.onLoadingComplete(imageUri, view, loadedImage);
|
||||||
|
notify_user(getApplicationContext(), intent, notificationId, loadedImage, finalTitle, "@"+account.getAcct()+"@"+account.getInstance());
|
||||||
|
String lastNotif = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId(), null);
|
||||||
|
if (lastNotif == null || Long.parseLong(notification.getId()) > Long.parseLong(lastNotif)) {
|
||||||
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
|
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId(), notification.getId());
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadingFailed(java.lang.String imageUri, android.view.View view, FailReason failReason) {
|
||||||
|
notify_user(getApplicationContext(), intent, notificationId, BitmapFactory.decodeResource(getApplicationContext().getResources(),
|
||||||
|
R.drawable.mastodonlogo), finalTitle, "@"+account.getAcct()+"@"+account.getInstance());
|
||||||
|
String lastNotif = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId(), null);
|
||||||
|
if (lastNotif == null || Long.parseLong(notification.getId()) > Long.parseLong(lastNotif)) {
|
||||||
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
|
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId(), notification.getId());
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else if ( event == EventStreaming.UPDATE){
|
||||||
|
status = API.parseStatuses(getApplicationContext(), response);
|
||||||
|
status.setReplies(new ArrayList<Status>());
|
||||||
|
status.setNew(true);
|
||||||
|
b.putParcelable("data", status);
|
||||||
|
}else if( event == EventStreaming.DELETE){
|
||||||
|
try {
|
||||||
|
dataId = response.getString("id");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( account != null)
|
||||||
|
b.putString("userIdService",account.getId());
|
||||||
|
Intent intentBC = new Intent(Helper.RECEIVE_DATA);
|
||||||
|
intentBC.putExtra("eventStreaming", event);
|
||||||
|
intentBC.putExtras(b);
|
||||||
|
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentBC);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package fr.gouv.etalab.mastodon.services;
|
||||||
|
/* Copyright 2017 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of Mastalab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Thomas on 22/09/2017.
|
||||||
|
* BroadcastReceiver for restarting the service
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class RestartLiveNotificationReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
|
@SuppressLint("UnsafeProtectedBroadcastReceiver")
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
|
||||||
|
boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true);
|
||||||
|
if( notify && liveNotifications) {
|
||||||
|
Intent streamingServiceIntent = new Intent(context.getApplicationContext(), LiveNotificationService.class);
|
||||||
|
context.startService(streamingServiceIntent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -13,13 +13,9 @@ package fr.gouv.etalab.mastodon.services;
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
|
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Thomas on 22/09/2017.
|
* Created by Thomas on 22/09/2017.
|
||||||
|
@ -28,16 +24,10 @@ import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
|
|
||||||
public class RestartServiceReceiver extends BroadcastReceiver {
|
public class RestartServiceReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
@SuppressLint("UnsafeProtectedBroadcastReceiver")
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
Intent streamingServiceIntent = new Intent(context.getApplicationContext(), StreamingService.class);
|
||||||
boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
|
context.startService(streamingServiceIntent);
|
||||||
boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true);
|
|
||||||
if( notify && liveNotifications) {
|
|
||||||
Intent streamingServiceIntent = new Intent(context.getApplicationContext(), StreamingService.class);
|
|
||||||
context.startService(streamingServiceIntent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -40,7 +40,6 @@ import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
import fr.gouv.etalab.mastodon.client.API;
|
import fr.gouv.etalab.mastodon.client.API;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Notification;
|
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||||
import fr.gouv.etalab.mastodon.client.TLSSocketFactory;
|
import fr.gouv.etalab.mastodon.client.TLSSocketFactory;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
|
@ -61,9 +60,11 @@ public class StreamingFederatedTimelineService extends IntentService {
|
||||||
*
|
*
|
||||||
* @param name Used to name the worker thread, important only for debugging.
|
* @param name Used to name the worker thread, important only for debugging.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public StreamingFederatedTimelineService(String name) {
|
public StreamingFederatedTimelineService(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public StreamingFederatedTimelineService() {
|
public StreamingFederatedTimelineService() {
|
||||||
super("StreamingFederatedTimelineService");
|
super("StreamingFederatedTimelineService");
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,9 +59,11 @@ public class StreamingLocalTimelineService extends IntentService {
|
||||||
*
|
*
|
||||||
* @param name Used to name the worker thread, important only for debugging.
|
* @param name Used to name the worker thread, important only for debugging.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public StreamingLocalTimelineService(String name) {
|
public StreamingLocalTimelineService(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public StreamingLocalTimelineService() {
|
public StreamingLocalTimelineService() {
|
||||||
super("StreamingLocalTimelineService");
|
super("StreamingLocalTimelineService");
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,61 +13,37 @@ package fr.gouv.etalab.mastodon.services;
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
import android.app.Service;
|
import android.app.IntentService;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
|
|
||||||
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
|
|
||||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
|
||||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
|
||||||
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
|
||||||
import com.nostra13.universalimageloader.core.assist.FailReason;
|
|
||||||
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
|
|
||||||
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
import fr.gouv.etalab.mastodon.activities.BaseMainActivity;
|
|
||||||
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
|
||||||
import fr.gouv.etalab.mastodon.client.API;
|
import fr.gouv.etalab.mastodon.client.API;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Notification;
|
import fr.gouv.etalab.mastodon.client.Entities.Notification;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||||
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
|
||||||
import fr.gouv.etalab.mastodon.client.TLSSocketFactory;
|
import fr.gouv.etalab.mastodon.client.TLSSocketFactory;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||||
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION;
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.NOTIFICATION_INTENT;
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.PREF_KEY_ID;
|
|
||||||
import static fr.gouv.etalab.mastodon.helper.Helper.notify_user;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,9 +51,25 @@ import static fr.gouv.etalab.mastodon.helper.Helper.notify_user;
|
||||||
* Manage service for streaming api and new notifications
|
* Manage service for streaming api and new notifications
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class StreamingService extends Service {
|
public class StreamingService extends IntentService {
|
||||||
|
|
||||||
|
|
||||||
|
private EventStreaming lastEvent;
|
||||||
|
/**
|
||||||
|
* Creates an IntentService. Invoked by your subclass's constructor.
|
||||||
|
*
|
||||||
|
* @param name Used to name the worker thread, important only for debugging.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public StreamingService(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public StreamingService() {
|
||||||
|
super("StreamingService");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HttpsURLConnection httpsURLConnection;
|
||||||
public enum EventStreaming{
|
public enum EventStreaming{
|
||||||
UPDATE,
|
UPDATE,
|
||||||
NOTIFICATION,
|
NOTIFICATION,
|
||||||
|
@ -86,62 +78,32 @@ public class StreamingService extends Service {
|
||||||
}
|
}
|
||||||
protected Account account;
|
protected Account account;
|
||||||
|
|
||||||
private boolean restartCalled;
|
|
||||||
|
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
restartCalled = false;
|
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true);
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
if( liveNotifications && notify){
|
editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING+userId, true);
|
||||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
editor.apply();
|
||||||
List<Account> accountStreams = new AccountDAO(getApplicationContext(), db).getAllAccount();
|
|
||||||
for(final Account accountStream: accountStreams){
|
|
||||||
Thread thread = new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
streamOnUser(accountStream);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
thread.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
protected void onHandleIntent(@Nullable Intent intent) {
|
||||||
Bundle extras = intent.getExtras();
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
if(extras != null) {
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
boolean restart = (boolean) extras.get("restart");
|
InputStream inputStream;
|
||||||
if( restart) {
|
|
||||||
SystemClock.sleep(1000);
|
|
||||||
sendBroadcast(new Intent("RestartStreamingService"));
|
|
||||||
stopSelf();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return START_STICKY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public IBinder onBind(Intent intent) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void streamOnUser(Account accountStream){
|
|
||||||
InputStream inputStream = null;
|
|
||||||
HttpsURLConnection httpsURLConnection = null;
|
|
||||||
BufferedReader reader = null;
|
BufferedReader reader = null;
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
Account accountStream = null;
|
||||||
EventStreaming lastEvent = null;
|
if( httpsURLConnection != null)
|
||||||
|
httpsURLConnection.disconnect();
|
||||||
|
if( userId != null) {
|
||||||
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
|
accountStream = new AccountDAO(getApplicationContext(), db).getAccountByID(userId);
|
||||||
|
}
|
||||||
if( accountStream != null){
|
if( accountStream != null){
|
||||||
try {
|
try {
|
||||||
|
|
||||||
URL url = new URL("https://" + accountStream.getInstance() + "/api/v1/streaming/user");
|
URL url = new URL("https://" + accountStream.getInstance() + "/api/v1/streaming/user");
|
||||||
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
httpsURLConnection = (HttpsURLConnection) url.openConnection();
|
||||||
httpsURLConnection.setRequestProperty("Content-Type", "application/json");
|
httpsURLConnection.setRequestProperty("Content-Type", "application/json");
|
||||||
|
@ -158,11 +120,8 @@ public class StreamingService extends Service {
|
||||||
String event;
|
String event;
|
||||||
EventStreaming eventStreaming;
|
EventStreaming eventStreaming;
|
||||||
while((event = reader.readLine()) != null) {
|
while((event = reader.readLine()) != null) {
|
||||||
if( !sharedpreferences.getBoolean(Helper.SHOULD_CONTINUE_STREAMING, true) ) {
|
if( !sharedpreferences.getBoolean(Helper.SHOULD_CONTINUE_STREAMING + accountStream.getId(), true) )
|
||||||
stopSelf();
|
stopSelf();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((lastEvent == EventStreaming.NONE || lastEvent == null) && !event.startsWith("data: ")) {
|
if ((lastEvent == EventStreaming.NONE || lastEvent == null) && !event.startsWith("data: ")) {
|
||||||
switch (event.trim()) {
|
switch (event.trim()) {
|
||||||
case "event: update":
|
case "event: update":
|
||||||
|
@ -208,144 +167,29 @@ public class StreamingService extends Service {
|
||||||
if(reader != null){
|
if(reader != null){
|
||||||
try{
|
try{
|
||||||
reader.close();
|
reader.close();
|
||||||
}catch (IOException ignored){}
|
}catch (IOException e){
|
||||||
}
|
e.printStackTrace();
|
||||||
if (inputStream != null) {
|
}
|
||||||
try {
|
|
||||||
inputStream.close();
|
|
||||||
} catch (IOException ignored) {}
|
|
||||||
}
|
|
||||||
if( httpsURLConnection != null)
|
|
||||||
httpsURLConnection.disconnect();
|
|
||||||
if( !restartCalled ) {
|
|
||||||
restartCalled = true;
|
|
||||||
SystemClock.sleep(1000);
|
|
||||||
sendBroadcast(new Intent("RestartStreamingService"));
|
|
||||||
stopSelf();
|
|
||||||
}
|
}
|
||||||
|
SystemClock.sleep(1000);
|
||||||
|
sendBroadcast(new Intent("RestartStreamingService"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onRetrieveStreaming(EventStreaming event, final Account account, JSONObject response) {
|
public void onRetrieveStreaming(EventStreaming event, Account account, JSONObject response) {
|
||||||
if( response == null )
|
if( response == null )
|
||||||
return;
|
return;
|
||||||
//No previous notifications in cache, so no notification will be sent
|
//No previous notifications in cache, so no notification will be sent
|
||||||
Status status ;
|
Status status ;
|
||||||
final Notification notification;
|
Notification notification;
|
||||||
|
//noinspection unused
|
||||||
String dataId = null;
|
String dataId = null;
|
||||||
|
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
if( event == EventStreaming.NOTIFICATION){
|
if( event == EventStreaming.NOTIFICATION){
|
||||||
notification = API.parseNotificationResponse(getApplicationContext(), response);
|
notification = API.parseNotificationResponse(getApplicationContext(), response);
|
||||||
b.putParcelable("data", notification);
|
b.putParcelable("data", notification);
|
||||||
boolean activityPaused;
|
|
||||||
try {
|
|
||||||
activityPaused = BaseMainActivity.activityState();
|
|
||||||
}catch (Exception e){
|
|
||||||
activityPaused = true;
|
|
||||||
}
|
|
||||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
|
||||||
boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
|
|
||||||
boolean canNotify = Helper.canNotify(getApplicationContext());
|
|
||||||
boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true);
|
|
||||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
|
||||||
|
|
||||||
if((userId == null || !userId.equals(account.getId()) || activityPaused) && liveNotifications && canNotify && notify) {
|
|
||||||
boolean notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true);
|
|
||||||
boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true);
|
|
||||||
boolean notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true);
|
|
||||||
boolean notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true);
|
|
||||||
boolean somethingToPush = (notif_follow || notif_add || notif_mention || notif_share);
|
|
||||||
String title = null;
|
|
||||||
if( somethingToPush && notification != null){
|
|
||||||
switch (notification.getType()){
|
|
||||||
case "mention":
|
|
||||||
if(notif_mention){
|
|
||||||
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0 )
|
|
||||||
title = String.format("@%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getApplicationContext().getString(R.string.notif_mention));
|
|
||||||
else
|
|
||||||
title = String.format("@%s %s", notification.getAccount().getUsername(),getApplicationContext().getString(R.string.notif_mention));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "reblog":
|
|
||||||
if(notif_share){
|
|
||||||
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0 )
|
|
||||||
title = String.format("@%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getApplicationContext().getString(R.string.notif_reblog));
|
|
||||||
else
|
|
||||||
title = String.format("@%s %s", notification.getAccount().getUsername(),getApplicationContext().getString(R.string.notif_reblog));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "favourite":
|
|
||||||
if(notif_add){
|
|
||||||
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0 )
|
|
||||||
title = String.format("@%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getApplicationContext().getString(R.string.notif_favourite));
|
|
||||||
else
|
|
||||||
title = String.format("@%s %s", notification.getAccount().getUsername(),getApplicationContext().getString(R.string.notif_favourite));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "follow":
|
|
||||||
if(notif_follow){
|
|
||||||
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0 )
|
|
||||||
title = String.format("@%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getApplicationContext().getString(R.string.notif_follow));
|
|
||||||
else
|
|
||||||
title = String.format("@%s %s", notification.getAccount().getUsername(),getApplicationContext().getString(R.string.notif_follow));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
//Some others notification
|
|
||||||
final Intent intent = new Intent(getApplicationContext(), MainActivity.class);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK );
|
|
||||||
intent.putExtra(INTENT_ACTION, NOTIFICATION_INTENT);
|
|
||||||
intent.putExtra(PREF_KEY_ID, account.getId());
|
|
||||||
long notif_id = Long.parseLong(account.getId());
|
|
||||||
final int notificationId = ((notif_id + 1) > 2147483647) ? (int) (2147483647 - notif_id - 1) : (int) (notif_id + 1);
|
|
||||||
if( notification.getAccount().getAvatar() != null ) {
|
|
||||||
ImageLoader imageLoaderNoty = ImageLoader.getInstance();
|
|
||||||
File cacheDir = new File(getApplicationContext().getCacheDir(), getApplicationContext().getString(R.string.app_name));
|
|
||||||
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
|
|
||||||
.imageDownloader(new PatchBaseImageDownloader(getApplicationContext()))
|
|
||||||
.threadPoolSize(5)
|
|
||||||
.threadPriority(Thread.MIN_PRIORITY + 3)
|
|
||||||
.denyCacheImageMultipleSizesInMemory()
|
|
||||||
.diskCache(new UnlimitedDiskCache(cacheDir))
|
|
||||||
.build();
|
|
||||||
imageLoaderNoty.init(config);
|
|
||||||
DisplayImageOptions options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
|
|
||||||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
|
||||||
|
|
||||||
final String finalTitle = title;
|
|
||||||
if( title != null) {
|
|
||||||
imageLoaderNoty.loadImage(notification.getAccount().getAvatar(), options, new SimpleImageLoadingListener() {
|
|
||||||
@Override
|
|
||||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
|
||||||
super.onLoadingComplete(imageUri, view, loadedImage);
|
|
||||||
notify_user(getApplicationContext(), intent, notificationId, loadedImage, finalTitle, "@"+account.getAcct()+"@"+account.getInstance());
|
|
||||||
String lastNotif = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId(), null);
|
|
||||||
if (lastNotif == null || Long.parseLong(notification.getId()) > Long.parseLong(lastNotif)) {
|
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
|
||||||
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId(), notification.getId());
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoadingFailed(java.lang.String imageUri, android.view.View view, FailReason failReason) {
|
|
||||||
notify_user(getApplicationContext(), intent, notificationId, BitmapFactory.decodeResource(getApplicationContext().getResources(),
|
|
||||||
R.drawable.mastodonlogo), finalTitle, "@"+account.getAcct()+"@"+account.getInstance());
|
|
||||||
String lastNotif = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId(), null);
|
|
||||||
if (lastNotif == null || Long.parseLong(notification.getId()) > Long.parseLong(lastNotif)) {
|
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
|
||||||
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId(), notification.getId());
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else if ( event == EventStreaming.UPDATE){
|
}else if ( event == EventStreaming.UPDATE){
|
||||||
status = API.parseStatuses(getApplicationContext(), response);
|
status = API.parseStatuses(getApplicationContext(), response);
|
||||||
status.setReplies(new ArrayList<Status>());
|
status.setReplies(new ArrayList<Status>());
|
||||||
|
@ -353,6 +197,7 @@ public class StreamingService extends Service {
|
||||||
b.putParcelable("data", status);
|
b.putParcelable("data", status);
|
||||||
}else if( event == EventStreaming.DELETE){
|
}else if( event == EventStreaming.DELETE){
|
||||||
try {
|
try {
|
||||||
|
//noinspection UnusedAssignment
|
||||||
dataId = response.getString("id");
|
dataId = response.getString("id");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -366,4 +211,4 @@ public class StreamingService extends Service {
|
||||||
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentBC);
|
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentBC);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -32,10 +32,10 @@ import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
|
import fr.gouv.etalab.mastodon.R;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||||
import fr.gouv.etalab.mastodon.interfaces.OnTranslatedInterface;
|
import fr.gouv.etalab.mastodon.interfaces.OnTranslatedInterface;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
|
||||||
|
|
||||||
import static fr.gouv.etalab.mastodon.activities.BaseMainActivity.currentLocale;
|
import static fr.gouv.etalab.mastodon.activities.BaseMainActivity.currentLocale;
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Thomas on 25/06/2017.
|
* Created by Thomas on 25/06/2017.
|
||||||
|
|
|
@ -25,7 +25,7 @@ import android.webkit.WebViewClient;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import fr.gouv.etalab.mastodon.activities.WebviewActivity;
|
import fr.gouv.etalab.mastodon.activities.WebviewActivity;
|
||||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
import fr.gouv.etalab.mastodon.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Thomas on 25/06/2017.
|
* Created by Thomas on 25/06/2017.
|
||||||
|
|
Loading…
Reference in New Issue