From d7268c1ad0ddfdd70debc57b328c980826d4a4bb Mon Sep 17 00:00:00 2001 From: stom79 Date: Sat, 4 Nov 2017 12:43:15 +0100 Subject: [PATCH 01/20] Fixes an issue with dividers when toots are filtered --- .../gouv/etalab/mastodon/fragments/DisplayStatusFragment.java | 1 - app/src/main/res/layout/drawer_status.xml | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) 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 9183818c4..36535e15c 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 @@ -124,7 +124,6 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn if( type == RetrieveFeedsAsyncTask.Type.HOME) lastReadStatus = sharedpreferences.getString(Helper.LAST_HOMETIMELINE_MAX_ID + userId, null); lv_status = rootView.findViewById(R.id.lv_status); - lv_status.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); mainLoader = rootView.findViewById(R.id.loader); nextElementLoader = rootView.findViewById(R.id.loading_next_status); textviewNoAction = rootView.findViewById(R.id.no_action); diff --git a/app/src/main/res/layout/drawer_status.xml b/app/src/main/res/layout/drawer_status.xml index 68d8d0c1c..dbc010e40 100644 --- a/app/src/main/res/layout/drawer_status.xml +++ b/app/src/main/res/layout/drawer_status.xml @@ -21,6 +21,8 @@ android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/main_container" + android:divider="?android:dividerHorizontal" + android:showDividers="end" android:orientation="vertical"> Date: Sat, 4 Nov 2017 19:04:04 +0100 Subject: [PATCH 02/20] Fixes issue #20 --- .../mastodon/drawers/NotificationsListAdapter.java | 5 ++--- .../gouv/etalab/mastodon/drawers/StatusListAdapter.java | 9 ++++----- .../main/java/fr/gouv/etalab/mastodon/helper/Helper.java | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) 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 cfe9692c9..a1c1b518b 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 @@ -300,7 +300,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On holder.status_document_container.setVisibility(View.GONE); holder.notification_status_content.setVisibility(View.VISIBLE); holder.status_show_more.setVisibility(View.GONE); - holder.status_action_container.setVisibility(View.GONE); + holder.status_action_container.setVisibility(View.INVISIBLE); }else { holder.status_action_container.setVisibility(View.VISIBLE); @@ -591,7 +591,6 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On notificationsListAdapter.notifyDataSetChanged(); Handler handler = new Handler(); handler.postDelayed(new Runnable() { - @Override public void run() { Bitmap bitmap = Helper.convertTootIntoBitmap(context, holder.getView()); @@ -618,7 +617,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On context.startActivity(intent); } - }, 1000); + }, 500); return true; default: return true; 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 b89b728fb..a94fe79f6 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 @@ -607,7 +607,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct holder.status_content_container.setVisibility(View.VISIBLE); holder.status_translate.setVisibility(View.GONE); holder.status_show_more.setVisibility(View.GONE); - holder.status_action_container.setVisibility(View.GONE); + holder.status_action_container.setVisibility(View.INVISIBLE); }else { holder.status_action_container.setVisibility(View.VISIBLE); if( trans_forced || (translator != Helper.TRANS_NONE && currentLocale != null && status.getLanguage() != null && !status.getLanguage().trim().equals(currentLocale))){ @@ -1052,9 +1052,9 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct case R.id.action_mention: status.setTakingScreenShot(true); statusListAdapter.notifyDataSetChanged(); - Handler handler = new Handler(); + // Get a handler that can be used to post to the main thread + final Handler handler = new Handler(); handler.postDelayed(new Runnable() { - @Override public void run() { Bitmap bitmap = Helper.convertTootIntoBitmap(context, holder.getView()); @@ -1080,8 +1080,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct intent.putExtras(b); context.startActivity(intent); } - - }, 1000); + }, 500); return true; default: return true; 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 22236aedb..349b682be 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 @@ -1696,7 +1696,7 @@ public class Helper { paint.setStrokeWidth(12); paint.setTextSize(30); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER)); - canvas.drawText("Via #Mastalab", view.getWidth()-230, view.getHeight() - 5, paint); + canvas.drawText("Via #Mastalab", view.getWidth()-230, view.getHeight() -50, paint); if( new_element != null) new_element.setVisibility(new_element_v); From 82c5b4badd5e721e948ccfaba12fff81185e15d9 Mon Sep 17 00:00:00 2001 From: SuperMeepBoy Date: Sat, 4 Nov 2017 23:47:29 +0100 Subject: [PATCH 03/20] Correct typo --- app/src/main/res/values-fr/strings.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 8ea92f0a6..09f4891e3 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -256,9 +256,9 @@ Le pouet a été signalé ! Le pouet a été supprimé ! Oups ! Une erreur s\'est produite ! - Une erreur s\'est produite ! L\'instance n\'a retourné aucun code d\authorisation ! + Une erreur s\'est produite ! L\'instance n\'a retourné aucun code d\autorisation ! Le nom de l\'instance ne semble pas être valide ! - Une erreur s\'est produite en chargeant le compte ! + Une erreur s\'est produite pendant le chargement du compte ! Une erreur s\'est produite lors de la recherche ! Impossible de vous connecter ! Les données du profil ont été sauvegardées ! @@ -438,4 +438,4 @@ Les données ci-dessous peuvent ne pas refléter ce profil dans sa totalité. Insérer un émoji L\'application n\'a pas encore collecté d\'emojis personnalisés - \ No newline at end of file + From b2767716b1ad94a3a932c981924ed062a50d6c51 Mon Sep 17 00:00:00 2001 From: stom79 Date: Sun, 5 Nov 2017 08:06:23 +0100 Subject: [PATCH 04/20] Fixes issue #21 Adds a mention button in profile page --- .../mastodon/activities/ShowAccountActivity.java | 9 +++++++++ .../etalab/mastodon/activities/TootActivity.java | 12 ++++++++++-- app/src/main/res/menu/main_showaccount.xml | 5 +++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java index 630df723a..ad2f70a98 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java @@ -312,10 +312,12 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi if( isOwner) { popup.getMenu().findItem(R.id.action_block).setVisible(false); popup.getMenu().findItem(R.id.action_mute).setVisible(false); + popup.getMenu().findItem(R.id.action_mention).setVisible(false); stringArrayConf = getResources().getStringArray(R.array.more_action_owner_confirm); }else { popup.getMenu().findItem(R.id.action_block).setVisible(true); popup.getMenu().findItem(R.id.action_mute).setVisible(true); + popup.getMenu().findItem(R.id.action_mention).setVisible(true); stringArrayConf = getResources().getStringArray(R.array.more_action_confirm); } popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @@ -349,6 +351,13 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi startActivity(intent); } return true; + case R.id.action_mention: + Intent intent = new Intent(getApplicationContext(), TootActivity.class); + Bundle b = new Bundle(); + b.putString("mentionAccount", account.getAcct()); + intent.putExtras(b); + startActivity(intent); + return true; case R.id.action_mute: builderInner = new AlertDialog.Builder(ShowAccountActivity.this); builderInner.setTitle(stringArrayConf[0]); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java index 56169345b..adb418bbf 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java @@ -192,6 +192,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc private View popup_trans; private AlertDialog dialogTrans; private AlertDialog alertDialogEmoji; + private String mentionAccount; @Override protected void onCreate(Bundle savedInstanceState) { @@ -289,6 +290,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc sharedContent = b.getString("sharedContent", null); sharedContentIni = b.getString("sharedContent", null); sharedSubject = b.getString("sharedSubject", null); + mentionAccount = b.getString("mentionAccount", null); restoredScheduled = b.getBoolean("restoredScheduled", false); // ACTION_SEND route if (b.getInt("uriNumber", 0) == 1) { @@ -307,7 +309,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc } restored = b.getLong("restored", -1); } - initialContent = toot_content.getText().toString(); + if(restoredScheduled){ toot_it.setVisibility(View.GONE); invalidateOptionsMenu(); @@ -327,6 +329,11 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc else userId = accountReply.getId(); + if( mentionAccount != null){ + toot_content.setText(String.format("@%s\n", mentionAccount)); + toot_content.setSelection(toot_content.getText().length()); + toot_space_left.setText(String.valueOf(toot_content.length())); + } if( tootMention != null && urlMention != null && fileMention != null) { Bitmap pictureMention = BitmapFactory.decodeFile(getCacheDir() + "/" + fileMention); if (pictureMention != null) { @@ -342,6 +349,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc toot_content.setText(String.format("\n\nvia @%s\n\n%s\n\n", tootMention, urlMention)); toot_space_left.setText(String.valueOf(toot_content.length())); } + initialContent = toot_content.getText().toString(); Account account; if( accountReply == null) account = new AccountDAO(getApplicationContext(),db).getAccountByID(userId); @@ -1736,7 +1744,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc //Nothing to store here.... if(toot_content.getText().toString().trim().length() == 0 && (attachments == null || attachments.size() <1) && toot_cw_content.getText().toString().trim().length() == 0) return; - if( initialContent.equals(toot_content.getText().toString())) + if( initialContent.trim().equals(toot_content.getText().toString().trim())) return; Status toot = new Status(); toot.setSensitive(isSensitive); diff --git a/app/src/main/res/menu/main_showaccount.xml b/app/src/main/res/menu/main_showaccount.xml index 622079edd..630515833 100644 --- a/app/src/main/res/menu/main_showaccount.xml +++ b/app/src/main/res/menu/main_showaccount.xml @@ -26,4 +26,9 @@ android:title="@string/more_action_2" android:icon="@drawable/ic_block" app:showAsAction="ifRoom" /> + From c48112e3ee56568ae6d6d4c1f3c34c36bbe51e2d Mon Sep 17 00:00:00 2001 From: stom79 Date: Sun, 5 Nov 2017 08:20:19 +0100 Subject: [PATCH 05/20] Fixes issue #18 Allows to select a different app for media --- .../etalab/mastodon/activities/TootActivity.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java index adb418bbf..727444bfa 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java @@ -533,7 +533,6 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc public void onClick(View v) { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - if (ContextCompat.checkSelfPermission(TootActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(TootActivity.this, @@ -543,21 +542,17 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc } } Intent intent; + intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { - intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); - intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("*/*"); String[] mimetypes = {"image/*", "video/*"}; intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes); startActivityForResult(intent, PICK_IMAGE); }else { - Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT); - getIntent.setType("image/*"); - + intent.setType("image/* video/*"); Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); - pickIntent.setType("image/*"); - - Intent chooserIntent = Intent.createChooser(getIntent, getString(R.string.toot_select_image)); + Intent chooserIntent = Intent.createChooser(intent, getString(R.string.toot_select_image)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] {pickIntent}); startActivityForResult(chooserIntent, PICK_IMAGE); } From bc2882bbbd6bf7c78191ff665884a7cb0d9f7e73 Mon Sep 17 00:00:00 2001 From: stom79 Date: Sun, 5 Nov 2017 11:48:38 +0100 Subject: [PATCH 06/20] Adds some badges in readme --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 269e85487..275f51bc1 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,14 @@ The number of libraries is minimized and it does not use tracking tools. The source code is free (GPLv3). Any help would be greatly appreciated to fix spelling or for any other suggestions. +[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) +[Get it on Google Play](https://play.google.com/store/apps/details?id=fr.gouv.etalab.mastodon) +[Get it on Google Play](https://f-droid.org/app/fr.gouv.etalab.mastodon) + + + +[Release notes](https://github.com/stom79/mastalab/releases) + ### Features **Multi-accounts management** From bd0e711142c3e39e374544b8dda16b9a523bb414 Mon Sep 17 00:00:00 2001 From: stom79 Date: Sun, 5 Nov 2017 11:50:58 +0100 Subject: [PATCH 07/20] Adds badge GPL in header --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 275f51bc1..46724026d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ -## Mastalab is a multi-accounts client for Mastodon +## Mastalab is a multi-accounts client for Mastodon [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) The number of libraries is minimized and it does not use tracking tools. The source code is free (GPLv3). Any help would be greatly appreciated to fix spelling or for any other suggestions. -[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [Get it on Google Play](https://play.google.com/store/apps/details?id=fr.gouv.etalab.mastodon) [Get it on Google Play](https://f-droid.org/app/fr.gouv.etalab.mastodon) @@ -10,6 +9,7 @@ The number of libraries is minimized and it does not use tracking tools. The sou [Release notes](https://github.com/stom79/mastalab/releases) + ### Features **Multi-accounts management** From fecb850f5cc97ca82cd1e24bc0f88794eb05a131 Mon Sep 17 00:00:00 2001 From: stom79 Date: Sun, 5 Nov 2017 17:53:16 +0100 Subject: [PATCH 08/20] Update custom lib + move some apk --- app/build.gradle | 2 +- .../release}/app-fdroid-release-1.4.9-beta-4.apk | Bin .../release}/app-fdroid-release-1.4.9-beta-6.apk | Bin .../release}/app-fdroid-release-1.4.9-beta-7.apk | Bin .../release}/app-fdroid-release-1.4.9-rc-1.apk | Bin .../release}/app-fdroid-release-1.5.0.apk | Bin .../app-fdroid-release-federatedtm-stream.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.0.1.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.0.2.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.0.3.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.0.4.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.0.5.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.0.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.1.0.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.1.1.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.1.2.1.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.1.2.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.1.3.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.1.4.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.1.5.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.1.6.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.1.7.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.1.8.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.1.9.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.2.0.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.2.1.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.2.2.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.2.3.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.2.4.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.2.5.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.2.6.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.2.7.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.2.8.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.2.9.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.3.0.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.3.1.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.3.2.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.3.3.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.3.4.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.3.5.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.3.6.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.3.7.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.3.8.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.3.9.1.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.3.9.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.4.0.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.4.1.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.4.2.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.4.3.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.4.4.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.4.5.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.4.6.apk | Bin app/{ => old/releases}/mastodon-etalab-v1.4.7.apk | Bin .../release}/app-safetynet-release-1.4.9-beta-6.apk | Bin .../release}/app-safetynet-release-1.4.9-beta-7.apk | Bin .../etalab/mastodon/activities/TootActivity.java | 6 +++--- 56 files changed, 4 insertions(+), 4 deletions(-) rename app/{ => fdroid/release}/app-fdroid-release-1.4.9-beta-4.apk (100%) rename app/{ => fdroid/release}/app-fdroid-release-1.4.9-beta-6.apk (100%) rename app/{ => fdroid/release}/app-fdroid-release-1.4.9-beta-7.apk (100%) rename app/{ => fdroid/release}/app-fdroid-release-1.4.9-rc-1.apk (100%) rename app/{ => fdroid/release}/app-fdroid-release-1.5.0.apk (100%) rename app/{ => fdroid/release}/app-fdroid-release-federatedtm-stream.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.0.1.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.0.2.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.0.3.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.0.4.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.0.5.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.0.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.1.0.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.1.1.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.1.2.1.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.1.2.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.1.3.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.1.4.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.1.5.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.1.6.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.1.7.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.1.8.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.1.9.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.2.0.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.2.1.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.2.2.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.2.3.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.2.4.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.2.5.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.2.6.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.2.7.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.2.8.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.2.9.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.3.0.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.3.1.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.3.2.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.3.3.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.3.4.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.3.5.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.3.6.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.3.7.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.3.8.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.3.9.1.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.3.9.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.4.0.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.4.1.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.4.2.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.4.3.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.4.4.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.4.5.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.4.6.apk (100%) rename app/{ => old/releases}/mastodon-etalab-v1.4.7.apk (100%) rename app/{ => safetynet/release}/app-safetynet-release-1.4.9-beta-6.apk (100%) rename app/{ => safetynet/release}/app-safetynet-release-1.4.9-beta-7.apk (100%) diff --git a/app/build.gradle b/app/build.gradle index 659244dc2..9038632a2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -43,7 +43,7 @@ dependencies { implementation 'com.google.code.gson:gson:2.8.0' implementation 'org.jsoup:jsoup:1.10.3' implementation 'de.hdodenhof:circleimageview:2.2.0' - implementation 'com.github.stom79:country-picker-android:1.2.0-beta-1' + implementation 'com.github.stom79:country-picker-android:1.2.0' safetynetImplementation 'com.google.android.gms:play-services-safetynet:11.4.2' safetynetImplementation 'io.github.kobakei:ratethisapp:1.2.0' } diff --git a/app/app-fdroid-release-1.4.9-beta-4.apk b/app/fdroid/release/app-fdroid-release-1.4.9-beta-4.apk similarity index 100% rename from app/app-fdroid-release-1.4.9-beta-4.apk rename to app/fdroid/release/app-fdroid-release-1.4.9-beta-4.apk diff --git a/app/app-fdroid-release-1.4.9-beta-6.apk b/app/fdroid/release/app-fdroid-release-1.4.9-beta-6.apk similarity index 100% rename from app/app-fdroid-release-1.4.9-beta-6.apk rename to app/fdroid/release/app-fdroid-release-1.4.9-beta-6.apk diff --git a/app/app-fdroid-release-1.4.9-beta-7.apk b/app/fdroid/release/app-fdroid-release-1.4.9-beta-7.apk similarity index 100% rename from app/app-fdroid-release-1.4.9-beta-7.apk rename to app/fdroid/release/app-fdroid-release-1.4.9-beta-7.apk diff --git a/app/app-fdroid-release-1.4.9-rc-1.apk b/app/fdroid/release/app-fdroid-release-1.4.9-rc-1.apk similarity index 100% rename from app/app-fdroid-release-1.4.9-rc-1.apk rename to app/fdroid/release/app-fdroid-release-1.4.9-rc-1.apk diff --git a/app/app-fdroid-release-1.5.0.apk b/app/fdroid/release/app-fdroid-release-1.5.0.apk similarity index 100% rename from app/app-fdroid-release-1.5.0.apk rename to app/fdroid/release/app-fdroid-release-1.5.0.apk diff --git a/app/app-fdroid-release-federatedtm-stream.apk b/app/fdroid/release/app-fdroid-release-federatedtm-stream.apk similarity index 100% rename from app/app-fdroid-release-federatedtm-stream.apk rename to app/fdroid/release/app-fdroid-release-federatedtm-stream.apk diff --git a/app/mastodon-etalab-v1.0.1.apk b/app/old/releases/mastodon-etalab-v1.0.1.apk similarity index 100% rename from app/mastodon-etalab-v1.0.1.apk rename to app/old/releases/mastodon-etalab-v1.0.1.apk diff --git a/app/mastodon-etalab-v1.0.2.apk b/app/old/releases/mastodon-etalab-v1.0.2.apk similarity index 100% rename from app/mastodon-etalab-v1.0.2.apk rename to app/old/releases/mastodon-etalab-v1.0.2.apk diff --git a/app/mastodon-etalab-v1.0.3.apk b/app/old/releases/mastodon-etalab-v1.0.3.apk similarity index 100% rename from app/mastodon-etalab-v1.0.3.apk rename to app/old/releases/mastodon-etalab-v1.0.3.apk diff --git a/app/mastodon-etalab-v1.0.4.apk b/app/old/releases/mastodon-etalab-v1.0.4.apk similarity index 100% rename from app/mastodon-etalab-v1.0.4.apk rename to app/old/releases/mastodon-etalab-v1.0.4.apk diff --git a/app/mastodon-etalab-v1.0.5.apk b/app/old/releases/mastodon-etalab-v1.0.5.apk similarity index 100% rename from app/mastodon-etalab-v1.0.5.apk rename to app/old/releases/mastodon-etalab-v1.0.5.apk diff --git a/app/mastodon-etalab-v1.0.apk b/app/old/releases/mastodon-etalab-v1.0.apk similarity index 100% rename from app/mastodon-etalab-v1.0.apk rename to app/old/releases/mastodon-etalab-v1.0.apk diff --git a/app/mastodon-etalab-v1.1.0.apk b/app/old/releases/mastodon-etalab-v1.1.0.apk similarity index 100% rename from app/mastodon-etalab-v1.1.0.apk rename to app/old/releases/mastodon-etalab-v1.1.0.apk diff --git a/app/mastodon-etalab-v1.1.1.apk b/app/old/releases/mastodon-etalab-v1.1.1.apk similarity index 100% rename from app/mastodon-etalab-v1.1.1.apk rename to app/old/releases/mastodon-etalab-v1.1.1.apk diff --git a/app/mastodon-etalab-v1.1.2.1.apk b/app/old/releases/mastodon-etalab-v1.1.2.1.apk similarity index 100% rename from app/mastodon-etalab-v1.1.2.1.apk rename to app/old/releases/mastodon-etalab-v1.1.2.1.apk diff --git a/app/mastodon-etalab-v1.1.2.apk b/app/old/releases/mastodon-etalab-v1.1.2.apk similarity index 100% rename from app/mastodon-etalab-v1.1.2.apk rename to app/old/releases/mastodon-etalab-v1.1.2.apk diff --git a/app/mastodon-etalab-v1.1.3.apk b/app/old/releases/mastodon-etalab-v1.1.3.apk similarity index 100% rename from app/mastodon-etalab-v1.1.3.apk rename to app/old/releases/mastodon-etalab-v1.1.3.apk diff --git a/app/mastodon-etalab-v1.1.4.apk b/app/old/releases/mastodon-etalab-v1.1.4.apk similarity index 100% rename from app/mastodon-etalab-v1.1.4.apk rename to app/old/releases/mastodon-etalab-v1.1.4.apk diff --git a/app/mastodon-etalab-v1.1.5.apk b/app/old/releases/mastodon-etalab-v1.1.5.apk similarity index 100% rename from app/mastodon-etalab-v1.1.5.apk rename to app/old/releases/mastodon-etalab-v1.1.5.apk diff --git a/app/mastodon-etalab-v1.1.6.apk b/app/old/releases/mastodon-etalab-v1.1.6.apk similarity index 100% rename from app/mastodon-etalab-v1.1.6.apk rename to app/old/releases/mastodon-etalab-v1.1.6.apk diff --git a/app/mastodon-etalab-v1.1.7.apk b/app/old/releases/mastodon-etalab-v1.1.7.apk similarity index 100% rename from app/mastodon-etalab-v1.1.7.apk rename to app/old/releases/mastodon-etalab-v1.1.7.apk diff --git a/app/mastodon-etalab-v1.1.8.apk b/app/old/releases/mastodon-etalab-v1.1.8.apk similarity index 100% rename from app/mastodon-etalab-v1.1.8.apk rename to app/old/releases/mastodon-etalab-v1.1.8.apk diff --git a/app/mastodon-etalab-v1.1.9.apk b/app/old/releases/mastodon-etalab-v1.1.9.apk similarity index 100% rename from app/mastodon-etalab-v1.1.9.apk rename to app/old/releases/mastodon-etalab-v1.1.9.apk diff --git a/app/mastodon-etalab-v1.2.0.apk b/app/old/releases/mastodon-etalab-v1.2.0.apk similarity index 100% rename from app/mastodon-etalab-v1.2.0.apk rename to app/old/releases/mastodon-etalab-v1.2.0.apk diff --git a/app/mastodon-etalab-v1.2.1.apk b/app/old/releases/mastodon-etalab-v1.2.1.apk similarity index 100% rename from app/mastodon-etalab-v1.2.1.apk rename to app/old/releases/mastodon-etalab-v1.2.1.apk diff --git a/app/mastodon-etalab-v1.2.2.apk b/app/old/releases/mastodon-etalab-v1.2.2.apk similarity index 100% rename from app/mastodon-etalab-v1.2.2.apk rename to app/old/releases/mastodon-etalab-v1.2.2.apk diff --git a/app/mastodon-etalab-v1.2.3.apk b/app/old/releases/mastodon-etalab-v1.2.3.apk similarity index 100% rename from app/mastodon-etalab-v1.2.3.apk rename to app/old/releases/mastodon-etalab-v1.2.3.apk diff --git a/app/mastodon-etalab-v1.2.4.apk b/app/old/releases/mastodon-etalab-v1.2.4.apk similarity index 100% rename from app/mastodon-etalab-v1.2.4.apk rename to app/old/releases/mastodon-etalab-v1.2.4.apk diff --git a/app/mastodon-etalab-v1.2.5.apk b/app/old/releases/mastodon-etalab-v1.2.5.apk similarity index 100% rename from app/mastodon-etalab-v1.2.5.apk rename to app/old/releases/mastodon-etalab-v1.2.5.apk diff --git a/app/mastodon-etalab-v1.2.6.apk b/app/old/releases/mastodon-etalab-v1.2.6.apk similarity index 100% rename from app/mastodon-etalab-v1.2.6.apk rename to app/old/releases/mastodon-etalab-v1.2.6.apk diff --git a/app/mastodon-etalab-v1.2.7.apk b/app/old/releases/mastodon-etalab-v1.2.7.apk similarity index 100% rename from app/mastodon-etalab-v1.2.7.apk rename to app/old/releases/mastodon-etalab-v1.2.7.apk diff --git a/app/mastodon-etalab-v1.2.8.apk b/app/old/releases/mastodon-etalab-v1.2.8.apk similarity index 100% rename from app/mastodon-etalab-v1.2.8.apk rename to app/old/releases/mastodon-etalab-v1.2.8.apk diff --git a/app/mastodon-etalab-v1.2.9.apk b/app/old/releases/mastodon-etalab-v1.2.9.apk similarity index 100% rename from app/mastodon-etalab-v1.2.9.apk rename to app/old/releases/mastodon-etalab-v1.2.9.apk diff --git a/app/mastodon-etalab-v1.3.0.apk b/app/old/releases/mastodon-etalab-v1.3.0.apk similarity index 100% rename from app/mastodon-etalab-v1.3.0.apk rename to app/old/releases/mastodon-etalab-v1.3.0.apk diff --git a/app/mastodon-etalab-v1.3.1.apk b/app/old/releases/mastodon-etalab-v1.3.1.apk similarity index 100% rename from app/mastodon-etalab-v1.3.1.apk rename to app/old/releases/mastodon-etalab-v1.3.1.apk diff --git a/app/mastodon-etalab-v1.3.2.apk b/app/old/releases/mastodon-etalab-v1.3.2.apk similarity index 100% rename from app/mastodon-etalab-v1.3.2.apk rename to app/old/releases/mastodon-etalab-v1.3.2.apk diff --git a/app/mastodon-etalab-v1.3.3.apk b/app/old/releases/mastodon-etalab-v1.3.3.apk similarity index 100% rename from app/mastodon-etalab-v1.3.3.apk rename to app/old/releases/mastodon-etalab-v1.3.3.apk diff --git a/app/mastodon-etalab-v1.3.4.apk b/app/old/releases/mastodon-etalab-v1.3.4.apk similarity index 100% rename from app/mastodon-etalab-v1.3.4.apk rename to app/old/releases/mastodon-etalab-v1.3.4.apk diff --git a/app/mastodon-etalab-v1.3.5.apk b/app/old/releases/mastodon-etalab-v1.3.5.apk similarity index 100% rename from app/mastodon-etalab-v1.3.5.apk rename to app/old/releases/mastodon-etalab-v1.3.5.apk diff --git a/app/mastodon-etalab-v1.3.6.apk b/app/old/releases/mastodon-etalab-v1.3.6.apk similarity index 100% rename from app/mastodon-etalab-v1.3.6.apk rename to app/old/releases/mastodon-etalab-v1.3.6.apk diff --git a/app/mastodon-etalab-v1.3.7.apk b/app/old/releases/mastodon-etalab-v1.3.7.apk similarity index 100% rename from app/mastodon-etalab-v1.3.7.apk rename to app/old/releases/mastodon-etalab-v1.3.7.apk diff --git a/app/mastodon-etalab-v1.3.8.apk b/app/old/releases/mastodon-etalab-v1.3.8.apk similarity index 100% rename from app/mastodon-etalab-v1.3.8.apk rename to app/old/releases/mastodon-etalab-v1.3.8.apk diff --git a/app/mastodon-etalab-v1.3.9.1.apk b/app/old/releases/mastodon-etalab-v1.3.9.1.apk similarity index 100% rename from app/mastodon-etalab-v1.3.9.1.apk rename to app/old/releases/mastodon-etalab-v1.3.9.1.apk diff --git a/app/mastodon-etalab-v1.3.9.apk b/app/old/releases/mastodon-etalab-v1.3.9.apk similarity index 100% rename from app/mastodon-etalab-v1.3.9.apk rename to app/old/releases/mastodon-etalab-v1.3.9.apk diff --git a/app/mastodon-etalab-v1.4.0.apk b/app/old/releases/mastodon-etalab-v1.4.0.apk similarity index 100% rename from app/mastodon-etalab-v1.4.0.apk rename to app/old/releases/mastodon-etalab-v1.4.0.apk diff --git a/app/mastodon-etalab-v1.4.1.apk b/app/old/releases/mastodon-etalab-v1.4.1.apk similarity index 100% rename from app/mastodon-etalab-v1.4.1.apk rename to app/old/releases/mastodon-etalab-v1.4.1.apk diff --git a/app/mastodon-etalab-v1.4.2.apk b/app/old/releases/mastodon-etalab-v1.4.2.apk similarity index 100% rename from app/mastodon-etalab-v1.4.2.apk rename to app/old/releases/mastodon-etalab-v1.4.2.apk diff --git a/app/mastodon-etalab-v1.4.3.apk b/app/old/releases/mastodon-etalab-v1.4.3.apk similarity index 100% rename from app/mastodon-etalab-v1.4.3.apk rename to app/old/releases/mastodon-etalab-v1.4.3.apk diff --git a/app/mastodon-etalab-v1.4.4.apk b/app/old/releases/mastodon-etalab-v1.4.4.apk similarity index 100% rename from app/mastodon-etalab-v1.4.4.apk rename to app/old/releases/mastodon-etalab-v1.4.4.apk diff --git a/app/mastodon-etalab-v1.4.5.apk b/app/old/releases/mastodon-etalab-v1.4.5.apk similarity index 100% rename from app/mastodon-etalab-v1.4.5.apk rename to app/old/releases/mastodon-etalab-v1.4.5.apk diff --git a/app/mastodon-etalab-v1.4.6.apk b/app/old/releases/mastodon-etalab-v1.4.6.apk similarity index 100% rename from app/mastodon-etalab-v1.4.6.apk rename to app/old/releases/mastodon-etalab-v1.4.6.apk diff --git a/app/mastodon-etalab-v1.4.7.apk b/app/old/releases/mastodon-etalab-v1.4.7.apk similarity index 100% rename from app/mastodon-etalab-v1.4.7.apk rename to app/old/releases/mastodon-etalab-v1.4.7.apk diff --git a/app/app-safetynet-release-1.4.9-beta-6.apk b/app/safetynet/release/app-safetynet-release-1.4.9-beta-6.apk similarity index 100% rename from app/app-safetynet-release-1.4.9-beta-6.apk rename to app/safetynet/release/app-safetynet-release-1.4.9-beta-6.apk diff --git a/app/app-safetynet-release-1.4.9-beta-7.apk b/app/safetynet/release/app-safetynet-release-1.4.9-beta-7.apk similarity index 100% rename from app/app-safetynet-release-1.4.9-beta-7.apk rename to app/safetynet/release/app-safetynet-release-1.4.9-beta-7.apk diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java index 727444bfa..2c1b20961 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java @@ -74,10 +74,10 @@ import android.widget.TextView; import android.widget.TimePicker; import android.widget.Toast; +import com.github.stom79.localepicker.CountryPicker; +import com.github.stom79.localepicker.CountryPickerListener; import com.loopj.android.http.AsyncHttpClient; import com.loopj.android.http.BinaryHttpResponseHandler; -import com.mukesh.countrypicker.CountryPicker; -import com.mukesh.countrypicker.CountryPickerListener; import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache; import com.nostra13.universalimageloader.core.DisplayImageOptions; import com.nostra13.universalimageloader.core.ImageLoader; @@ -815,7 +815,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc picker.setListener(new CountryPickerListener() { @SuppressLint("InflateParams") @Override - public void onSelectCountry(String name, String code, String dialCode, String locale, int flagDrawableResID) { + public void onSelectCountry(String name, String locale, int flagDrawableResID) { picker.dismiss(); AlertDialog.Builder transAlert = new AlertDialog.Builder(TootActivity.this); transAlert.setTitle(R.string.translate_toot); From a4136c496eda493518d8cdd471d18d05e47a85b1 Mon Sep 17 00:00:00 2001 From: stom79 Date: Sun, 5 Nov 2017 18:12:58 +0100 Subject: [PATCH 09/20] Fixes notification issue --- .../fr/gouv/etalab/mastodon/client/API.java | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java index 23788bb89..d2bd5c79f 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java @@ -1228,25 +1228,20 @@ public class API { final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); boolean notif_follow, notif_add, notif_mention, notif_share; - if( !display) { - notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true); - notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true); - notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true); - notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true); - }else { + if( display) { notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW_FILTER, true); notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD_FILTER, true); notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION_FILTER, true); notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE_FILTER, true); + if( !notif_follow ) + params.add("exclude_types[]", "follow"); + if( !notif_add ) + params.add("exclude_types[]", "favourite"); + if( !notif_share ) + params.add("exclude_types[]", "reblog"); + if( !notif_mention ) + params.add("exclude_types[]", "mention"); } - if( !notif_follow ) - params.add("exclude_types[]", "follow"); - if( !notif_add ) - params.add("exclude_types[]", "favourite"); - if( !notif_share ) - params.add("exclude_types[]", "reblog"); - if( !notif_mention ) - params.add("exclude_types[]", "mention"); notifications = new ArrayList<>(); get("/notifications", params, new JsonHttpResponseHandler() { From 4ed8525e7e648cd25cc7ef23732728ad9a418fe2 Mon Sep 17 00:00:00 2001 From: stom79 Date: Sun, 5 Nov 2017 20:04:38 +0100 Subject: [PATCH 10/20] Fixes notification issue --- .../fr/gouv/etalab/mastodon/activities/BaseMainActivity.java | 2 +- .../mastodon/asynctasks/RetrieveNotificationsAsyncTask.java | 1 - app/src/main/java/fr/gouv/etalab/mastodon/client/API.java | 5 ++--- .../fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java | 3 +-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java index 1a59a575d..1cca79fbf 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java @@ -809,7 +809,7 @@ public abstract class BaseMainActivity extends AppCompatActivity }); - + // Asked once for notification opt-in boolean popupShown = sharedpreferences.getBoolean(Helper.SET_POPUP_PUSH, false); if(!popupShown){ AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(BaseMainActivity.this); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveNotificationsAsyncTask.java b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveNotificationsAsyncTask.java index 5e1c91b4c..326b2ec5c 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveNotificationsAsyncTask.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveNotificationsAsyncTask.java @@ -57,7 +57,6 @@ public class RetrieveNotificationsAsyncTask extends AsyncTask @Override protected Void doInBackground(Void... params) { - API api = new API(this.contextReference.get(), instance, token); if( acct == null) apiResponse = api.getNotifications(max_id, display); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java index d2bd5c79f..4f86cbc38 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java @@ -16,7 +16,6 @@ package fr.gouv.etalab.mastodon.client; import android.content.Context; import android.content.SharedPreferences; - import android.widget.Toast; import com.loopj.android.http.AsyncHttpClient; @@ -1222,8 +1221,8 @@ public class API { params.put("max_id", max_id); if( since_id != null ) params.put("since_id", since_id); - if( 0 > limit || limit > 40) - limit = 40; + if( 0 > limit || limit > 30) + limit = 30; params.put("limit",String.valueOf(limit)); final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); 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 cae69b09f..7dc06f645 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 @@ -107,11 +107,10 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications //Check which notifications the user wants to see boolean notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true); boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true); - boolean notif_ask = sharedpreferences.getBoolean(Helper.SET_NOTIF_ASK, true); boolean notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true); boolean notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true); //User disagree with all notifications - if( !notif_follow && !notif_add && !notif_ask && !notif_mention && !notif_share) + if( !notif_follow && !notif_add && !notif_mention && !notif_share) return; //Nothing is done //No account connected, the service is stopped if(!Helper.isLoggedIn(getContext())) From ada656e4ec0e6a96109fd146bf338ce79afccbca Mon Sep 17 00:00:00 2001 From: stom79 Date: Mon, 6 Nov 2017 07:20:52 +0100 Subject: [PATCH 11/20] Fixes notification issue --- .../fr/gouv/etalab/mastodon/client/API.java | 21 +++++++---- .../mastodon/jobs/NotificationsSyncJob.java | 37 +++++++++++-------- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java index 4f86cbc38..b9b1f76b5 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java @@ -1232,15 +1232,20 @@ public class API { notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD_FILTER, true); notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION_FILTER, true); notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE_FILTER, true); - if( !notif_follow ) - params.add("exclude_types[]", "follow"); - if( !notif_add ) - params.add("exclude_types[]", "favourite"); - if( !notif_share ) - params.add("exclude_types[]", "reblog"); - if( !notif_mention ) - params.add("exclude_types[]", "mention"); + }else{ + notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true); + notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true); + notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true); + notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true); } + if( !notif_follow ) + params.add("exclude_types[]", "follow"); + if( !notif_add ) + params.add("exclude_types[]", "favourite"); + if( !notif_share ) + params.add("exclude_types[]", "reblog"); + if( !notif_mention ) + params.add("exclude_types[]", "mention"); notifications = new ArrayList<>(); get("/notifications", params, new JsonHttpResponseHandler() { 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 7dc06f645..cfd62c2da 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 @@ -36,6 +36,7 @@ import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer; import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener; import java.io.File; +import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -123,8 +124,7 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications return; //Retrieve users in db that owner has. for (Account account: accounts) { - String max_id = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId(), null); - new RetrieveNotificationsAsyncTask(getContext(), false, account.getInstance(), account.getToken(), max_id, account.getAcct(), account.getId(), NotificationsSyncJob.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + new RetrieveNotificationsAsyncTask(getContext(), false, account.getInstance(), account.getToken(), null, account.getAcct(), account.getId(), NotificationsSyncJob.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } } @@ -133,10 +133,9 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications @Override public void onRetrieveNotifications(APIResponse apiResponse, String acct, final String userId, boolean refreshData) { - final List notifications = apiResponse.getNotifications(); - if( apiResponse.getError() != null || notifications == null || notifications.size() == 0) + List notificationsReceived = apiResponse.getNotifications(); + if( apiResponse.getError() != null || notificationsReceived == null || notificationsReceived.size() == 0) return; - Bitmap icon_notification = null; final SharedPreferences sharedpreferences = getContext().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); boolean notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true); boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true); @@ -144,20 +143,24 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications boolean notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true); final String max_id = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + userId, null); + final List notifications = new ArrayList<>(); + int pos = 0; + for(Notification notif: notificationsReceived){ + if( Long.parseLong(notif.getId()) > Long.parseLong(max_id) ) { + notifications.add(pos, notif); + pos++; + } + } //No previous notifications in cache, so no notification will be sent int newFollows = 0; int newAdds = 0; - int newAsks = 0; int newMentions = 0; int newShare = 0; String notificationUrl = null; String title = null; final String message; for(Notification notification: notifications){ - //The notification associated to max_id is discarded as it is supposed to have already been sent - if( max_id != null && notification.getId().equals(max_id)) - continue; switch (notification.getType()){ case "mention": if(notif_mention){ @@ -212,7 +215,7 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications } } - int allNotifCount = newFollows + newAdds + newAsks + newMentions + newShare; + int allNotifCount = newFollows + newAdds + newMentions + newShare; if( allNotifCount > 0){ //Some others notification int other = allNotifCount -1; @@ -227,7 +230,7 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications long notif_id = Long.parseLong(userId); final int notificationId = ((notif_id + 1) > 2147483647) ? (int) (2147483647 - notif_id - 1) : (int) (notif_id + 1); - if( notificationUrl != null && icon_notification == null){ + if( notificationUrl != null ){ ImageLoader imageLoaderNoty = ImageLoader.getInstance(); File cacheDir = new File(getContext().getCacheDir(), getContext().getString(R.string.app_name)); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getContext()) @@ -246,8 +249,9 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { super.onLoadingComplete(imageUri, view, loadedImage); - if( max_id != null) { - notify_user(getContext(), intent, notificationId, loadedImage, finalTitle, message); + notify_user(getContext(), intent, notificationId, loadedImage, finalTitle, message); + String lastNotif = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + userId, null); + if( Long.parseLong(notifications.get(0).getId()) > Long.parseLong(lastNotif)){ SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + userId, notifications.get(0).getId()); editor.apply(); @@ -255,9 +259,10 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications } @Override public void onLoadingFailed(java.lang.String imageUri, android.view.View view, FailReason failReason){ - if( max_id != null) { - notify_user(getContext(), intent, notificationId, BitmapFactory.decodeResource(getContext().getResources(), - R.drawable.mastodonlogo), finalTitle, message); + notify_user(getContext(), intent, notificationId, BitmapFactory.decodeResource(getContext().getResources(), + R.drawable.mastodonlogo), finalTitle, message); + String lastNotif = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + userId, null); + if( Long.parseLong(notifications.get(0).getId()) > Long.parseLong(lastNotif)){ SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + userId, notifications.get(0).getId()); editor.apply(); From c31791ea807ea5e3aefe1d7ff563cce66cdd313f Mon Sep 17 00:00:00 2001 From: stom79 Date: Mon, 6 Nov 2017 12:59:42 +0100 Subject: [PATCH 12/20] Fixes notification issue --- .../mastodon/asynctasks/RetrieveNotificationsAsyncTask.java | 1 + .../fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveNotificationsAsyncTask.java b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveNotificationsAsyncTask.java index 326b2ec5c..0b9031184 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveNotificationsAsyncTask.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/RetrieveNotificationsAsyncTask.java @@ -24,6 +24,7 @@ import fr.gouv.etalab.mastodon.client.APIResponse; import fr.gouv.etalab.mastodon.interfaces.OnRetrieveNotificationsInterface; + /** * Created by Thomas on 28/04/2017. * Retrieves notifications on the instance 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 cfd62c2da..365923ce6 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 @@ -88,7 +88,6 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications .setPeriodic(TimeUnit.MINUTES.toMillis(Helper.MINUTES_BETWEEN_NOTIFICATIONS_REFRESH), TimeUnit.MINUTES.toMillis(5)) .setUpdateCurrent(updateCurrent) .setRequiredNetworkType(JobRequest.NetworkType.METERED) - .setRequiresBatteryNotLow(true) .setRequirementsEnforced(false) .build() .schedule(); @@ -142,16 +141,14 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications boolean notif_mention = sharedpreferences.getBoolean(Helper.SET_NOTIF_MENTION, true); boolean notif_share = sharedpreferences.getBoolean(Helper.SET_NOTIF_SHARE, true); final String max_id = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + userId, null); - final List notifications = new ArrayList<>(); int pos = 0; for(Notification notif: notificationsReceived){ - if( Long.parseLong(notif.getId()) > Long.parseLong(max_id) ) { + if( max_id == null || Long.parseLong(notif.getId()) > Long.parseLong(max_id) ) { notifications.add(pos, notif); pos++; } } - //No previous notifications in cache, so no notification will be sent int newFollows = 0; int newAdds = 0; @@ -229,7 +226,6 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications intent.putExtra(PREF_KEY_ID, userId); long notif_id = Long.parseLong(userId); final int notificationId = ((notif_id + 1) > 2147483647) ? (int) (2147483647 - notif_id - 1) : (int) (notif_id + 1); - if( notificationUrl != null ){ ImageLoader imageLoaderNoty = ImageLoader.getInstance(); File cacheDir = new File(getContext().getCacheDir(), getContext().getString(R.string.app_name)); From 99ef945be2ca5fb6708354baca31b9ddff4e0d3a Mon Sep 17 00:00:00 2001 From: stom79 Date: Mon, 6 Nov 2017 18:08:22 +0100 Subject: [PATCH 13/20] Avoids null pointer --- .../fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 365923ce6..855b3595b 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 @@ -247,7 +247,7 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications super.onLoadingComplete(imageUri, view, loadedImage); notify_user(getContext(), intent, notificationId, loadedImage, finalTitle, message); String lastNotif = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + userId, null); - if( Long.parseLong(notifications.get(0).getId()) > Long.parseLong(lastNotif)){ + if( lastNotif == null || Long.parseLong(notifications.get(0).getId()) > Long.parseLong(lastNotif)){ SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + userId, notifications.get(0).getId()); editor.apply(); @@ -258,7 +258,7 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications notify_user(getContext(), intent, notificationId, BitmapFactory.decodeResource(getContext().getResources(), R.drawable.mastodonlogo), finalTitle, message); String lastNotif = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + userId, null); - if( Long.parseLong(notifications.get(0).getId()) > Long.parseLong(lastNotif)){ + if( lastNotif == null || Long.parseLong(notifications.get(0).getId()) > Long.parseLong(lastNotif)){ SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + userId, notifications.get(0).getId()); editor.apply(); From b3e63f190cb388dac118510c39f877d7d033378b Mon Sep 17 00:00:00 2001 From: stom79 Date: Mon, 6 Nov 2017 18:30:52 +0100 Subject: [PATCH 14/20] No need to go further --- .../java/fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java | 2 ++ 1 file changed, 2 insertions(+) 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 855b3595b..acc58cd8d 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 @@ -149,6 +149,8 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications pos++; } } + if( notifications.size() == 0 ) + return; //No previous notifications in cache, so no notification will be sent int newFollows = 0; int newAdds = 0; From e2b0fbbe5a59158e3108aa43237503eba0c701e6 Mon Sep 17 00:00:00 2001 From: stom79 Date: Mon, 6 Nov 2017 18:36:00 +0100 Subject: [PATCH 15/20] Fixes some padding --- app/src/main/res/layout/drawer_status.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/layout/drawer_status.xml b/app/src/main/res/layout/drawer_status.xml index dbc010e40..6fbdc4227 100644 --- a/app/src/main/res/layout/drawer_status.xml +++ b/app/src/main/res/layout/drawer_status.xml @@ -23,6 +23,7 @@ android:id="@+id/main_container" android:divider="?android:dividerHorizontal" android:showDividers="end" + android:paddingTop="5dp" android:orientation="vertical"> Date: Mon, 6 Nov 2017 19:38:04 +0100 Subject: [PATCH 16/20] Fixes issue #27 --- .../mastodon/activities/MediaActivity.java | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java index dde4c7ad2..4ac4ac061 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java @@ -100,12 +100,16 @@ public class MediaActivity extends AppCompatActivity { private File fileVideo; private TextView progress; private boolean canSwipe; + + + private enum actionSwipe{ RIGHT_TO_LEFT, LEFT_TO_RIGHT, POP } + @SuppressLint("ClickableViewAccessibility") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -123,8 +127,7 @@ public class MediaActivity extends AppCompatActivity { mediaPosition = getIntent().getExtras().getInt("position", 1); if( attachments == null || attachments.size() == 0) finish(); - if( getSupportActionBar() != null) - getSupportActionBar().setDisplayHomeAsUpEnabled(true); + RelativeLayout main_container_media = findViewById(R.id.main_container_media); if( theme == Helper.THEME_LIGHT){ @@ -133,6 +136,21 @@ public class MediaActivity extends AppCompatActivity { main_container_media.setBackgroundResource(R.color.mastodonC1); } + if( getSupportActionBar() != null) { + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + Handler h = new Handler(); + + h.postDelayed(new Runnable() { + + @Override + public void run() { + // DO DELAYED STUFF + if(canSwipe) + getSupportActionBar().hide(); + } + }, 2000); + } + canSwipe = true; loader = findViewById(R.id.loader); @@ -160,6 +178,9 @@ public class MediaActivity extends AppCompatActivity { @Override public void onMatrixChanged(RectF rect) { canSwipe = (imageView.getScale() == 1 ); + if( !canSwipe && getSupportActionBar() != null && getSupportActionBar().isShowing()){ + getSupportActionBar().hide(); + } } }); @@ -212,8 +233,6 @@ public class MediaActivity extends AppCompatActivity { return true; } - - /** * Manage touch event * Allows to swipe from timelines @@ -222,6 +241,20 @@ public class MediaActivity extends AppCompatActivity { */ @Override public boolean dispatchTouchEvent(MotionEvent event) { + + if( event.getAction() == MotionEvent.ACTION_DOWN){ + if( getSupportActionBar() != null && !getSupportActionBar().isShowing() && canSwipe) { + getSupportActionBar().show(); + Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + @Override + public void run() { + getSupportActionBar().hide(); + } + }, 2000); + return super.dispatchTouchEvent(event); + } + } if( !canSwipe || mediaPosition > attachments.size() || mediaPosition < 1 || attachments.size() <= 1) return super.dispatchTouchEvent(event); switch(event.getAction()){ From bddb6d86727f3b546aad71561756fa1dd0c0a7c4 Mon Sep 17 00:00:00 2001 From: stom79 Date: Tue, 7 Nov 2017 11:09:09 +0100 Subject: [PATCH 17/20] Improves media --- .../mastodon/activities/MediaActivity.java | 79 +++++++++---------- app/src/main/res/layout/activity_media.xml | 18 ++++- app/src/main/res/layout/picture_actionbar.xml | 46 +++++++++-- 3 files changed, 95 insertions(+), 48 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java index 4ac4ac061..7fa0d9368 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java @@ -30,11 +30,11 @@ import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; +import android.view.ViewGroup; import android.webkit.URLUtil; import android.widget.ImageView; import android.widget.MediaController; @@ -102,7 +102,6 @@ public class MediaActivity extends AppCompatActivity { private boolean canSwipe; - private enum actionSwipe{ RIGHT_TO_LEFT, LEFT_TO_RIGHT, @@ -117,9 +116,9 @@ public class MediaActivity extends AppCompatActivity { SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); if( theme == Helper.THEME_LIGHT){ - setTheme(R.style.AppTheme); + setTheme(R.style.AppTheme_NoActionBar); }else { - setTheme(R.style.AppThemeDark); + setTheme(R.style.AppThemeDark_NoActionBar); } setContentView(R.layout.activity_media); attachments = getIntent().getParcelableArrayListExtra("mediaArray"); @@ -128,7 +127,6 @@ public class MediaActivity extends AppCompatActivity { if( attachments == null || attachments.size() == 0) finish(); - RelativeLayout main_container_media = findViewById(R.id.main_container_media); if( theme == Helper.THEME_LIGHT){ main_container_media.setBackgroundResource(R.color.mastodonC2); @@ -136,8 +134,41 @@ public class MediaActivity extends AppCompatActivity { main_container_media.setBackgroundResource(R.color.mastodonC1); } + Toolbar toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); if( getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); + LayoutInflater inflater = (LayoutInflater) this.getSystemService(android.content.Context.LAYOUT_INFLATER_SERVICE); + assert inflater != null; + @SuppressLint("InflateParams") View view = inflater.inflate(R.layout.picture_actionbar, null); + getSupportActionBar().setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); + + + ImageView action_save = getSupportActionBar().getCustomView().findViewById(R.id.action_save); + ImageView close = getSupportActionBar().getCustomView().findViewById(R.id.close); + if( close != null){ + close.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + } + action_save.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(Build.VERSION.SDK_INT >= 23 ){ + if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED ) { + ActivityCompat.requestPermissions(MediaActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, EXTERNAL_STORAGE_REQUEST_CODE); + } else { + Helper.manageMoveFileDownload(MediaActivity.this, preview_url, finalUrlDownload, downloadedImage, fileVideo); + } + }else{ + Helper.manageMoveFileDownload(MediaActivity.this, preview_url, finalUrlDownload, downloadedImage, fileVideo); + } + } + }); Handler h = new Handler(); h.postDelayed(new Runnable() { @@ -204,34 +235,6 @@ public class MediaActivity extends AppCompatActivity { displayMediaAtPosition(actionSwipe.POP); } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - finish(); - return true; - case R.id.action_download: - if(Build.VERSION.SDK_INT >= 23 ){ - if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED ) { - ActivityCompat.requestPermissions(MediaActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, EXTERNAL_STORAGE_REQUEST_CODE); - } else { - Helper.manageMoveFileDownload(MediaActivity.this, preview_url, finalUrlDownload, downloadedImage, fileVideo); - } - }else{ - Helper.manageMoveFileDownload(MediaActivity.this, preview_url, finalUrlDownload, downloadedImage, fileVideo); - } - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.main_media, menu); - return true; - } /** * Manage touch event @@ -252,7 +255,6 @@ public class MediaActivity extends AppCompatActivity { getSupportActionBar().hide(); } }, 2000); - return super.dispatchTouchEvent(event); } } if( !canSwipe || mediaPosition > attachments.size() || mediaPosition < 1 || attachments.size() <= 1) @@ -429,15 +431,10 @@ public class MediaActivity extends AppCompatActivity { filename = url; if( attachments.size() > 1 ) filename = String.format("%s (%s/%s)",filename, mediaPosition, attachments.size()); - - LayoutInflater mInflater = LayoutInflater.from(MediaActivity.this); ActionBar actionBar = getSupportActionBar(); if( actionBar != null){ - @SuppressLint("InflateParams") View picture_actionbar = mInflater.inflate(R.layout.picture_actionbar, null); - TextView picture_actionbar_title = picture_actionbar.findViewById(R.id.picture_actionbar); + TextView picture_actionbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title); picture_actionbar_title.setText(filename); - actionBar.setCustomView(picture_actionbar); - actionBar.setDisplayShowCustomEnabled(true); }else { setTitle(url); } diff --git a/app/src/main/res/layout/activity_media.xml b/app/src/main/res/layout/activity_media.xml index 93b06ec06..227a23d0c 100644 --- a/app/src/main/res/layout/activity_media.xml +++ b/app/src/main/res/layout/activity_media.xml @@ -19,8 +19,22 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:id="@+id/main_container_media" - > + xmlns:app="http://schemas.android.com/apk/res-auto" + android:id="@+id/main_container_media"> + + + . --> - + android:background="?attr/colorPrimary" + app:popupTheme="?attr/popupOverlay" + tools:ignore="UnusedAttribute"> + + - \ No newline at end of file + + + \ No newline at end of file From 3deec52707bf84d1427afcc0623ebc812245bc04 Mon Sep 17 00:00:00 2001 From: stom79 Date: Tue, 7 Nov 2017 16:08:31 +0100 Subject: [PATCH 18/20] Fixes issue #23 --- .../fr/gouv/etalab/mastodon/activities/TootActivity.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java index 2c1b20961..1ea9e28dd 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java @@ -1707,6 +1707,10 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc } //If toot is not restored if( restored == -1 ){ + if( tootReply.getSpoiler_text() != null && tootReply.getSpoiler_text().length() > 0) { + toot_cw_content.setText(tootReply.getSpoiler_text()); + toot_cw_content.setVisibility(View.VISIBLE); + } //Retrieves mentioned accounts + OP and adds them at the beginin of the toot ArrayList mentionedAccountsAdded = new ArrayList<>(); if( tootReply.getAccount() != null && tootReply.getAccount().getAcct() != null && !tootReply.getAccount().getId().equals(userId)) { @@ -1722,12 +1726,13 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc } } } + toot_content.setText(toot_content.getText().toString().trim()); if (toot_content.getText().toString().startsWith("@")) { - //Put a "dot" at the end of all mentioned account to force capitalization toot_content.append("\n"); } toot_space_left.setText(String.valueOf(toot_content.length())); + toot_content.requestFocus(); toot_content.setSelection(toot_content.getText().length()); //Put cursor at the end } initialContent = toot_content.getText().toString(); From 11550b6a13c93bf3c57b5a45f00a39bb55333e42 Mon Sep 17 00:00:00 2001 From: stom79 Date: Tue, 7 Nov 2017 18:13:08 +0100 Subject: [PATCH 19/20] Prepares release 1.5.8 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9038632a2..897b6d502 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "fr.gouv.etalab.mastodon" minSdkVersion 15 targetSdkVersion 26 - versionCode 67 - versionName "1.5.7" + versionCode 68 + versionName "1.5.8" } flavorDimensions "default" buildTypes { From 61f8b7ae5b1f37d1da5cb6d5ba433cf204c0a990 Mon Sep 17 00:00:00 2001 From: stom79 Date: Tue, 7 Nov 2017 19:04:02 +0100 Subject: [PATCH 20/20] Prepares release 1.5.8 --- .../etalab/mastodon/activities/MediaActivity.java | 3 +-- .../fragments/DisplayNotificationsFragment.java | 13 ++++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java index 7fa0d9368..b25b03d1c 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java @@ -108,7 +108,6 @@ public class MediaActivity extends AppCompatActivity { POP } - @SuppressLint("ClickableViewAccessibility") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -131,7 +130,7 @@ public class MediaActivity extends AppCompatActivity { if( theme == Helper.THEME_LIGHT){ main_container_media.setBackgroundResource(R.color.mastodonC2); }else { - main_container_media.setBackgroundResource(R.color.mastodonC1); + main_container_media.setBackgroundResource(R.color.mastodonC1_); } Toolbar toolbar = findViewById(R.id.toolbar); 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 f0b94bfa4..5c03ac605 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 @@ -260,7 +260,18 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve flag_loading = true; swiped = true; MainActivity.countNewNotifications = 0; - asyncTask = new RetrieveNotificationsAsyncTask(context, true, null, null, max_id, null, null, DisplayNotificationsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + if( context != null) + asyncTask = new RetrieveNotificationsAsyncTask(context, true, null, null, max_id, null, null, DisplayNotificationsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + else { + new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { + @Override + public void run() { + if( context != null){ + asyncTask = new RetrieveNotificationsAsyncTask(context, true, null, null, max_id, null, null, DisplayNotificationsFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } + } + }, 500); + } }