diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index c489d6b85..d87ba5e4e 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -24,9 +24,10 @@
+
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- = Build.VERSION_CODES.N) {
+ assert account != null;
holder.account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
holder.account_un.setText(String.format("@%s",account.getAcct()));
}else {
+ assert account != null;
holder.account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
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
imageLoader.displayImage(account.getAvatar(), holder.account_pp, options);
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsFollowRequestAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsFollowRequestAdapter.java
index b4923afa6..5a281009e 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsFollowRequestAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsFollowRequestAdapter.java
@@ -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.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
-import mastodon.etalab.gouv.fr.mastodon.R;
+import fr.gouv.etalab.mastodon.R;
/**
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsListAdapter.java
index cafb12e3d..c90207606 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsListAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsListAdapter.java
@@ -39,6 +39,8 @@ import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
+
+import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
import fr.gouv.etalab.mastodon.client.API;
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.helper.Helper;
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.asynctasks.PostActionAsyncTask;
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsReplyAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsReplyAdapter.java
index b1dcf27ec..947d767d9 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsReplyAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsReplyAdapter.java
@@ -30,9 +30,10 @@ import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
import java.util.List;
+
+import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.TootActivity;
import fr.gouv.etalab.mastodon.client.Entities.Account;
-import mastodon.etalab.gouv.fr.mastodon.R;
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsSearchAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsSearchAdapter.java
index 9dabde5e0..87cba4582 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsSearchAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsSearchAdapter.java
@@ -35,12 +35,14 @@ import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
import java.util.ArrayList;
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.Mention;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
-import mastodon.etalab.gouv.fr.mastodon.R;
+
/**
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/CustomEmojiAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/CustomEmojiAdapter.java
index 80c501f0c..9bcf4be5e 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/CustomEmojiAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/CustomEmojiAdapter.java
@@ -38,7 +38,7 @@ import java.util.List;
import fr.gouv.etalab.mastodon.client.Entities.Emojis;
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.
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/DraftsListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/DraftsListAdapter.java
index e2bfb5f42..02ccea719 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/DraftsListAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/DraftsListAdapter.java
@@ -38,7 +38,7 @@ import fr.gouv.etalab.mastodon.client.Entities.StoredStatus;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
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;
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/EmojisSearchAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/EmojisSearchAdapter.java
index 79d738b96..6e1ea2d87 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/EmojisSearchAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/EmojisSearchAdapter.java
@@ -33,8 +33,9 @@ import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
import java.util.ArrayList;
import java.util.List;
+import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.client.Entities.Emojis;
-import mastodon.etalab.gouv.fr.mastodon.R;
+
/**
@@ -47,12 +48,10 @@ public class EmojisSearchAdapter extends ArrayAdapter implements Filtera
private LayoutInflater layoutInflater;
private ImageLoader imageLoader;
private DisplayImageOptions options;
- private Context context;
public EmojisSearchAdapter(Context context, List emojis){
super(context, android.R.layout.simple_list_item_1, emojis);
this.emojis = emojis;
- this.context = context;
this.tempEmojis = new ArrayList<>(emojis);
this.suggestions = new ArrayList<>(emojis);
layoutInflater = LayoutInflater.from(context);
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java
index a1c1b518b..1c3b44c86 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java
@@ -57,6 +57,7 @@ import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;
+import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.MediaActivity;
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
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.OnPostNotificationsActionInterface;
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.Status;
import fr.gouv.etalab.mastodon.helper.Helper;
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/ScheduledTootsListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/ScheduledTootsListAdapter.java
index caeb334de..b6d0eed00 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/ScheduledTootsListAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/ScheduledTootsListAdapter.java
@@ -51,7 +51,7 @@ import fr.gouv.etalab.mastodon.jobs.ApplicationJob;
import fr.gouv.etalab.mastodon.jobs.ScheduledTootsSyncJob;
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
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;
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/SearchListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/SearchListAdapter.java
index 6ad22d594..06c495f03 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/SearchListAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/SearchListAdapter.java
@@ -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.PatchBaseImageDownloader;
import fr.gouv.etalab.mastodon.helper.Helper;
-import mastodon.etalab.gouv.fr.mastodon.R;
+import fr.gouv.etalab.mastodon.R;
/**
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java
index a94fe79f6..560a7356f 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java
@@ -71,6 +71,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.MediaActivity;
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
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.OnRetrieveRepliesInterface;
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.helper.Helper.THEME_DARK;
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/TagsListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/TagsListAdapter.java
index d587c2439..3990686c5 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/TagsListAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/TagsListAdapter.java
@@ -23,7 +23,7 @@ import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.List;
-import mastodon.etalab.gouv.fr.mastodon.R;
+import fr.gouv.etalab.mastodon.R;
/**
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/TagsSearchAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/TagsSearchAdapter.java
index bc7739110..4bc81fec9 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/TagsSearchAdapter.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/TagsSearchAdapter.java
@@ -26,7 +26,8 @@ import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
-import mastodon.etalab.gouv.fr.mastodon.R;
+
+import fr.gouv.etalab.mastodon.R;
/**
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayAccountsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayAccountsFragment.java
index 7a132a963..8ea0952e9 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayAccountsFragment.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayAccountsFragment.java
@@ -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.helper.Helper;
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.drawers.AccountsListAdapter;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountsInterface;
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayDraftsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayDraftsFragment.java
index 25a05e050..3db43874d 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayDraftsFragment.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayDraftsFragment.java
@@ -37,7 +37,7 @@ import fr.gouv.etalab.mastodon.drawers.DraftsListAdapter;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
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;
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayFollowRequestSentFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayFollowRequestSentFragment.java
index 8471a40d8..34e31096d 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayFollowRequestSentFragment.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayFollowRequestSentFragment.java
@@ -38,7 +38,7 @@ import fr.gouv.etalab.mastodon.client.Entities.Account;
import fr.gouv.etalab.mastodon.drawers.AccountsFollowRequestAdapter;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountsInterface;
-import mastodon.etalab.gouv.fr.mastodon.R;
+import fr.gouv.etalab.mastodon.R;
/**
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayNotificationsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayNotificationsFragment.java
index 2f816aa92..83dec2708 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayNotificationsFragment.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayNotificationsFragment.java
@@ -33,13 +33,13 @@ import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
+import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveMissingNotificationsAsyncTask;
import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.drawers.NotificationsListAdapter;
import fr.gouv.etalab.mastodon.helper.Helper;
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.client.Entities.Notification;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveNotificationsInterface;
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayScheduledTootsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayScheduledTootsFragment.java
index 560f7baaa..9a3911035 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayScheduledTootsFragment.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayScheduledTootsFragment.java
@@ -42,7 +42,7 @@ import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveScheduledTootsInterface;
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
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;
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java
index 7e18449e0..78c9ccc1b 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java
@@ -35,6 +35,7 @@ import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
+import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveMissingFeedsAsyncTask;
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.services.StreamingFederatedTimelineService;
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.client.Entities.Status;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsFragment.java
index cc6ef2685..33c571375 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsFragment.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsFragment.java
@@ -52,7 +52,7 @@ import fr.gouv.etalab.mastodon.client.Entities.Account;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
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 fr.gouv.etalab.mastodon.helper.Helper.CHANGE_THEME_INTENT;
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsNotificationsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsNotificationsFragment.java
index 92415b8c3..7be076a75 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsNotificationsFragment.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsNotificationsFragment.java
@@ -16,10 +16,8 @@ package fr.gouv.etalab.mastodon.fragments;
import android.app.TimePickerDialog;
import android.content.Context;
-import android.content.Intent;
import android.content.SharedPreferences;
-import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
@@ -41,15 +39,8 @@ import android.widget.TimePicker;
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.services.StreamingService;
-import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
-import fr.gouv.etalab.mastodon.sqlite.Sqlite;
-import mastodon.etalab.gouv.fr.mastodon.R;
+import fr.gouv.etalab.mastodon.R;
import static fr.gouv.etalab.mastodon.helper.Helper.compareDate;
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsOptimizationFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsOptimizationFragment.java
index 74ce6cccb..957617b1f 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsOptimizationFragment.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsOptimizationFragment.java
@@ -25,7 +25,7 @@ import android.widget.SeekBar;
import android.widget.TextView;
import fr.gouv.etalab.mastodon.helper.Helper;
-import mastodon.etalab.gouv.fr.mastodon.R;
+import fr.gouv.etalab.mastodon.R;
/**
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/TabLayoutSettingsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/TabLayoutSettingsFragment.java
index 769f45ba0..cfc5bd7e2 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/TabLayoutSettingsFragment.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/TabLayoutSettingsFragment.java
@@ -24,7 +24,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import mastodon.etalab.gouv.fr.mastodon.R;
+import fr.gouv.etalab.mastodon.R;
/**
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/CrossActions.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/CrossActions.java
index 5d2487571..04b5d2f62 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/CrossActions.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/CrossActions.java
@@ -41,7 +41,7 @@ import fr.gouv.etalab.mastodon.drawers.AccountsSearchAdapter;
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
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
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java
index ffab82d35..7ca2cfe13 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java
@@ -123,6 +123,7 @@ import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.HashTagActivity;
import fr.gouv.etalab.mastodon.activities.LoginActivity;
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.CustomEmojiDAO;
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
-import mastodon.etalab.gouv.fr.mastodon.R;
import static android.content.Context.DOWNLOAD_SERVICE;
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/jobs/HomeTimelineSyncJob.java b/app/src/main/java/fr/gouv/etalab/mastodon/jobs/HomeTimelineSyncJob.java
index 5b3379404..916155fff 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/jobs/HomeTimelineSyncJob.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/jobs/HomeTimelineSyncJob.java
@@ -40,6 +40,7 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
+import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveHomeTimelineServiceAsyncTask;
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.sqlite.AccountDAO;
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.INTENT_ACTION;
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java b/app/src/main/java/fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java
index acc58cd8d..6043fd573 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java
@@ -44,7 +44,7 @@ import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
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.client.Entities.Account;
import fr.gouv.etalab.mastodon.client.Entities.Notification;
@@ -167,9 +167,9 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications
if( notificationUrl == null){
notificationUrl = notification.getAccount().getAvatar();
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0 )
- title = String.format("@%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getContext().getString(R.string.notif_mention));
+ title = String.format("%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getContext().getString(R.string.notif_mention));
else
- title = String.format("@%s %s", notification.getAccount().getUsername(),getContext().getString(R.string.notif_mention));
+ title = String.format("@%s %s", notification.getAccount().getAcct(),getContext().getString(R.string.notif_mention));
}
}
break;
@@ -179,9 +179,9 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications
if( notificationUrl == null){
notificationUrl = notification.getAccount().getAvatar();
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0 )
- title = String.format("@%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getContext().getString(R.string.notif_reblog));
+ title = String.format("%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getContext().getString(R.string.notif_reblog));
else
- title = String.format("@%s %s", notification.getAccount().getUsername(),getContext().getString(R.string.notif_reblog));
+ title = String.format("@%s %s", notification.getAccount().getAcct(),getContext().getString(R.string.notif_reblog));
}
}
@@ -192,9 +192,9 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications
if( notificationUrl == null){
notificationUrl = notification.getAccount().getAvatar();
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0 )
- title = String.format("@%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getContext().getString(R.string.notif_favourite));
+ title = String.format("%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getContext().getString(R.string.notif_favourite));
else
- title = String.format("@%s %s", notification.getAccount().getUsername(),getContext().getString(R.string.notif_favourite));
+ title = String.format("@%s %s", notification.getAccount().getAcct(),getContext().getString(R.string.notif_favourite));
}
}
break;
@@ -204,9 +204,9 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications
if( notificationUrl == null){
notificationUrl = notification.getAccount().getAvatar();
if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0 )
- title = String.format("@%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getContext().getString(R.string.notif_follow));
+ title = String.format("%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),getContext().getString(R.string.notif_follow));
else
- title = String.format("@%s %s", notification.getAccount().getUsername(),getContext().getString(R.string.notif_follow));
+ title = String.format("@%s %s", notification.getAccount().getAcct(),getContext().getString(R.string.notif_follow));
}
}
break;
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/services/LiveNotificationService.java b/app/src/main/java/fr/gouv/etalab/mastodon/services/LiveNotificationService.java
new file mode 100644
index 000000000..d9c332f18
--- /dev/null
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/services/LiveNotificationService.java
@@ -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 . */
+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 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().getAcct(),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().getAcct(),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().getAcct(),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().getAcct(),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.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);
+ }
+
+}
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/services/RestartLiveNotificationReceiver.java b/app/src/main/java/fr/gouv/etalab/mastodon/services/RestartLiveNotificationReceiver.java
new file mode 100644
index 000000000..2c03fa8ff
--- /dev/null
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/services/RestartLiveNotificationReceiver.java
@@ -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 . */
+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);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingFederatedTimelineService.java b/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingFederatedTimelineService.java
index bf259dfb3..210bc2807 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingFederatedTimelineService.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingFederatedTimelineService.java
@@ -40,7 +40,6 @@ import javax.net.ssl.HttpsURLConnection;
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.TLSSocketFactory;
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.
*/
+ @SuppressWarnings("unused")
public StreamingFederatedTimelineService(String name) {
super(name);
}
+ @SuppressWarnings("unused")
public StreamingFederatedTimelineService() {
super("StreamingFederatedTimelineService");
}
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingLocalTimelineService.java b/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingLocalTimelineService.java
index 1fba974e0..e850661e5 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingLocalTimelineService.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingLocalTimelineService.java
@@ -59,9 +59,11 @@ public class StreamingLocalTimelineService extends IntentService {
*
* @param name Used to name the worker thread, important only for debugging.
*/
+ @SuppressWarnings("unused")
public StreamingLocalTimelineService(String name) {
super(name);
}
+ @SuppressWarnings("unused")
public StreamingLocalTimelineService() {
super("StreamingLocalTimelineService");
}
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingService.java b/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingService.java
index 1f465fa7f..0ba245706 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingService.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingService.java
@@ -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,
* see . */
-import android.app.Service;
+import android.app.IntentService;
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.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 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
*/
-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{
UPDATE,
NOTIFICATION,
@@ -86,62 +78,32 @@ public class StreamingService extends Service {
}
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 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();
- }
- }
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
+ editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING+userId, true);
+ editor.apply();
}
+
@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;
+ protected void onHandleIntent(@Nullable Intent intent) {
+ SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
+ String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
+ InputStream inputStream;
BufferedReader reader = null;
- SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
- EventStreaming lastEvent = null;
+ Account accountStream = 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){
try {
+
URL url = new URL("https://" + accountStream.getInstance() + "/api/v1/streaming/user");
httpsURLConnection = (HttpsURLConnection) url.openConnection();
httpsURLConnection.setRequestProperty("Content-Type", "application/json");
@@ -158,11 +120,8 @@ public class StreamingService extends Service {
String event;
EventStreaming eventStreaming;
while((event = reader.readLine()) != null) {
- if( !sharedpreferences.getBoolean(Helper.SHOULD_CONTINUE_STREAMING, true) ) {
+ if( !sharedpreferences.getBoolean(Helper.SHOULD_CONTINUE_STREAMING + accountStream.getId(), true) )
stopSelf();
- return;
- }
-
if ((lastEvent == EventStreaming.NONE || lastEvent == null) && !event.startsWith("data: ")) {
switch (event.trim()) {
case "event: update":
@@ -208,144 +167,29 @@ public class StreamingService extends Service {
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();
+ }catch (IOException e){
+ e.printStackTrace();
+ }
}
+ 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 )
return;
//No previous notifications in cache, so no notification will be sent
Status status ;
- final Notification notification;
+ Notification notification;
+ //noinspection unused
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());
@@ -353,6 +197,7 @@ public class StreamingService extends Service {
b.putParcelable("data", status);
}else if( event == EventStreaming.DELETE){
try {
+ //noinspection UnusedAssignment
dataId = response.getString("id");
} catch (JSONException e) {
e.printStackTrace();
@@ -366,4 +211,4 @@ public class StreamingService extends Service {
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentBC);
}
-}
+}
\ No newline at end of file
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/translation/Translate.java b/app/src/main/java/fr/gouv/etalab/mastodon/translation/Translate.java
index 9140e806b..4a5c24cca 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/translation/Translate.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/translation/Translate.java
@@ -32,10 +32,10 @@ import java.util.Iterator;
import java.util.Map;
import java.util.regex.Matcher;
+import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.client.Entities.Status;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnTranslatedInterface;
-import mastodon.etalab.gouv.fr.mastodon.R;
import static fr.gouv.etalab.mastodon.activities.BaseMainActivity.currentLocale;
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/webview/MastalabWebChromeClient.java b/app/src/main/java/fr/gouv/etalab/mastodon/webview/MastalabWebChromeClient.java
index dabd78c3a..a7a00eeec 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/webview/MastalabWebChromeClient.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/webview/MastalabWebChromeClient.java
@@ -30,7 +30,7 @@ import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
-import mastodon.etalab.gouv.fr.mastodon.R;
+import fr.gouv.etalab.mastodon.R;
/**
* Created by Thomas on 25/06/2017.
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/webview/MastalabWebViewClient.java b/app/src/main/java/fr/gouv/etalab/mastodon/webview/MastalabWebViewClient.java
index dced8229c..5285336f0 100644
--- a/app/src/main/java/fr/gouv/etalab/mastodon/webview/MastalabWebViewClient.java
+++ b/app/src/main/java/fr/gouv/etalab/mastodon/webview/MastalabWebViewClient.java
@@ -25,7 +25,7 @@ import android.webkit.WebViewClient;
import android.widget.TextView;
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.