From 45ac4fb949cf37661b568790d5c85cd7a95d3dd0 Mon Sep 17 00:00:00 2001 From: tom79 Date: Tue, 15 Aug 2017 18:07:23 +0200 Subject: [PATCH] Fixes alert dialog issue --- .../mastodon/activities/TootActivity.java | 17 +++++++-------- .../mastodon/drawers/AccountsListAdapter.java | 12 ++--------- .../mastodon/drawers/DraftsListAdapter.java | 11 +++------- .../drawers/NotificationsListAdapter.java | 21 ++++--------------- .../drawers/ScheduledTootsListAdapter.java | 18 +++------------- .../mastodon/drawers/StatusListAdapter.java | 14 ++++--------- .../mastodon/fragments/SettingsFragment.java | 10 ++------- .../fragments/SettingsProfileFragment.java | 2 +- .../gouv/etalab/mastodon/helper/Helper.java | 2 +- app/src/main/res/values-fr/strings.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- 11 files changed, 29 insertions(+), 82 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 9b43853d2..9d8811001 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 @@ -15,7 +15,7 @@ package fr.gouv.etalab.mastodon.activities; import android.app.Activity; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.DialogInterface; @@ -145,7 +145,6 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc private HorizontalScrollView picture_scrollview; private int currentCursorPosition, searchLength; private boolean canDisplayMessage; - private int style; @Override protected void onCreate(Bundle savedInstanceState) { @@ -154,10 +153,8 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc final int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); if( theme == Helper.THEME_LIGHT){ setTheme(R.style.AppTheme); - style = R.style.AlertDialog; }else { setTheme(R.style.AppThemeDark); - style = R.style.AlertDialogDark; } setContentView(R.layout.activity_toot); @@ -588,7 +585,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc Toast.makeText(getApplicationContext(), R.string.no_draft, Toast.LENGTH_LONG).show(); return true; } - AlertDialog.Builder builderSingle = new AlertDialog.Builder(TootActivity.this, style); + AlertDialog.Builder builderSingle = new AlertDialog.Builder(TootActivity.this); builderSingle.setTitle(getString(R.string.choose_toot)); final DraftsListAdapter draftsListAdapter = new DraftsListAdapter(TootActivity.this, drafts); final int[] ids = new int[drafts.size()]; @@ -606,7 +603,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc builderSingle.setPositiveButton(R.string.delete_all, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { - AlertDialog.Builder builder = new AlertDialog.Builder(TootActivity.this, style); + AlertDialog.Builder builder = new AlertDialog.Builder(TootActivity.this); builder.setTitle(R.string.delete_all); builder.setIcon(android.R.drawable.ic_dialog_alert) .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @@ -646,7 +643,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc Toast.makeText(getApplicationContext(),R.string.toot_error_no_content, Toast.LENGTH_LONG).show(); return true; } - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(TootActivity.this, style); + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(TootActivity.this); LayoutInflater inflater = this.getLayoutInflater(); View dialogView = inflater.inflate(R.layout.datetime_picker, null); dialogBuilder.setView(dialogView); @@ -804,7 +801,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc */ private void showRemove(final int viewId){ - AlertDialog.Builder dialog = new AlertDialog.Builder(TootActivity.this, style); + AlertDialog.Builder dialog = new AlertDialog.Builder(TootActivity.this); dialog.setMessage(R.string.toot_delete_media); dialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @@ -841,7 +838,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc private void tootVisibilityDialog(){ - AlertDialog.Builder dialog = new AlertDialog.Builder(TootActivity.this, style); + AlertDialog.Builder dialog = new AlertDialog.Builder(TootActivity.this); dialog.setTitle(R.string.toot_visibility_tilte); final String[] stringArray = getResources().getStringArray(R.array.toot_visibility); final ArrayAdapter arrayAdapter = new ArrayAdapter<>(TootActivity.this, android.R.layout.simple_list_item_1, stringArray); @@ -1104,7 +1101,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc ic_show.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - AlertDialog.Builder alert = new AlertDialog.Builder(TootActivity.this, style); + AlertDialog.Builder alert = new AlertDialog.Builder(TootActivity.this); alert.setTitle(R.string.toot_reply_content_title); final TextView input = new TextView(TootActivity.this); //Set the padding 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 18d4ecded..112601b9d 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 @@ -14,7 +14,7 @@ package fr.gouv.etalab.mastodon.drawers; * You should have received a copy of the GNU General Public License along with Mastalab; if not, * see . */ -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -25,7 +25,6 @@ import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.text.Html; import android.text.util.Linkify; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -69,7 +68,6 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte private Context context; private AccountsListAdapter accountsListAdapter; private String targetedId; - private int style; public AccountsListAdapter(Context context, RetrieveAccountsAsyncTask.Type action, String targetedId, List accounts){ this.context = context; @@ -252,13 +250,7 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte String[] stringArrayConf = context.getResources().getStringArray(R.array.more_action_confirm_account); final API.StatusAction doAction; final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); - int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_DARK){ - style = R.style.DialogDark; - }else { - style = R.style.Dialog; - } - AlertDialog.Builder dialog = new AlertDialog.Builder(context, style); + AlertDialog.Builder dialog = new AlertDialog.Builder(context); if( action == RetrieveAccountsAsyncTask.Type.BLOCKED) { dialog.setMessage(stringArrayConf[1]); 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 b7ee793f0..bdd6d9b74 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 @@ -15,7 +15,7 @@ package fr.gouv.etalab.mastodon.drawers; * see . */ -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; @@ -48,7 +48,6 @@ public class DraftsListAdapter extends BaseAdapter { private LayoutInflater layoutInflater; private Context context; private DraftsListAdapter draftsListAdapter; - private int style; public DraftsListAdapter(Context context, List storedStatuses){ this.storedStatuses = storedStatuses; @@ -106,12 +105,8 @@ public class DraftsListAdapter extends BaseAdapter { holder.draft_delete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if( theme == Helper.THEME_DARK){ - style = R.style.DialogDark; - }else { - style = R.style.Dialog; - } - AlertDialog.Builder builder = new AlertDialog.Builder(context, style); + + AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(draft.getStatus().getContent() + '\n' + Helper.dateToString(context, draft.getCreation_date())); builder.setIcon(android.R.drawable.ic_dialog_alert) .setTitle(R.string.remove_draft) 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 5b214f70d..850aace65 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 @@ -14,7 +14,7 @@ package fr.gouv.etalab.mastodon.drawers; * You should have received a copy of the GNU General Public License along with Mastalab; if not, * see . */ -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -82,7 +82,6 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio private NotificationsListAdapter notificationsListAdapter; private int behaviorWithAttachments; private boolean isOnWifi; - private int style; public NotificationsListAdapter(Context context, boolean isOnWifi, int behaviorWithAttachments, List notifications){ this.context = context; @@ -447,13 +446,8 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio title = context.getString(R.string.reblog_add); } final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); - int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_DARK){ - style = R.style.DialogDark; - }else { - style = R.style.Dialog; - } - AlertDialog.Builder builder = new AlertDialog.Builder(context, style); + + AlertDialog.Builder builder = new AlertDialog.Builder(context); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) builder.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY)); @@ -489,14 +483,7 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio private void displayConfirmationNotificationDialog(final Notification notification){ final ArrayList seletedItems = new ArrayList(); final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); - - int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_DARK){ - style = R.style.DialogDark; - }else { - style = R.style.Dialog; - } - AlertDialog dialog = new AlertDialog.Builder(context, style) + AlertDialog dialog = new AlertDialog.Builder(context) .setTitle(R.string.delete_notification_ask) .setMultiChoiceItems(new String[]{context.getString(R.string.delete_notification_ask_all)}, null, new DialogInterface.OnMultiChoiceClickListener() { @Override 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 864362407..a8ba8994c 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 @@ -14,7 +14,7 @@ package fr.gouv.etalab.mastodon.drawers; * You should have received a copy of the GNU General Public License along with Mastalab; if not, * see . */ -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -43,7 +43,6 @@ import java.util.List; import fr.gouv.etalab.mastodon.activities.MainActivity; import fr.gouv.etalab.mastodon.activities.TootActivity; -import fr.gouv.etalab.mastodon.client.Entities.Application; import fr.gouv.etalab.mastodon.client.Entities.Status; import fr.gouv.etalab.mastodon.client.Entities.StoredStatus; import fr.gouv.etalab.mastodon.helper.Helper; @@ -67,7 +66,6 @@ public class ScheduledTootsListAdapter extends BaseAdapter { private LayoutInflater layoutInflater; private ScheduledTootsListAdapter scheduledTootsListAdapter; private RelativeLayout textviewNoAction; - private int style; public ScheduledTootsListAdapter(Context context, List storedStatuses, RelativeLayout textviewNoAction){ this.context = context; @@ -155,12 +153,7 @@ public class ScheduledTootsListAdapter extends BaseAdapter { holder.scheduled_toot_delete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if( theme == Helper.THEME_DARK){ - style = R.style.DialogDark; - }else { - style = R.style.Dialog; - } - AlertDialog.Builder builder = new AlertDialog.Builder(context, style); + AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(status.getContent() + '\n' + Helper.dateToString(context, storedStatus.getCreation_date())); builder.setIcon(android.R.drawable.ic_dialog_alert) .setTitle(R.string.remove_scheduled) @@ -201,12 +194,7 @@ public class ScheduledTootsListAdapter extends BaseAdapter { holder.scheduled_toot_date.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if( theme == Helper.THEME_DARK){ - style = R.style.DialogDark; - }else { - style = R.style.Dialog; - } - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context, style); + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context); LayoutInflater inflater = ((MainActivity)context).getLayoutInflater(); View dialogView = inflater.inflate(R.layout.datetime_picker, null); SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); 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 f5b4c1902..61b3584dc 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 @@ -14,7 +14,7 @@ package fr.gouv.etalab.mastodon.drawers; * You should have received a copy of the GNU General Public License along with Mastalab; if not, * see . */ -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; @@ -30,11 +30,8 @@ import android.os.CountDownTimer; import android.support.v4.content.ContextCompat; import android.support.v7.widget.CardView; import android.text.Html; -import android.text.Selection; import android.text.SpannableString; import android.text.method.LinkMovementMethod; -import android.util.Log; -import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -105,7 +102,6 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf private final int FAVOURITE = 2; private RetrieveFeedsAsyncTask.Type type; private String targetedId; - private int style; public StatusListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, int behaviorWithAttachments, List statuses){ this.context = context; @@ -281,7 +277,6 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf changeDrawableColor(context, R.drawable.ic_photo,R.color.dark_text); changeDrawableColor(context, R.drawable.ic_remove_red_eye,R.color.dark_text); changeDrawableColor(context, R.drawable.ic_translate,R.color.dark_text); - style = R.style.AlertDialogDark; }else { changeDrawableColor(context, R.drawable.ic_reply,R.color.black); changeDrawableColor(context, R.drawable.ic_action_more,R.color.black); @@ -294,7 +289,6 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf changeDrawableColor(context, R.drawable.ic_photo,R.color.white); changeDrawableColor(context, R.drawable.ic_remove_red_eye,R.color.white); changeDrawableColor(context, R.drawable.ic_translate,R.color.white); - style = R.style.AlertDialog; } //Redraws top icons (boost/reply) @@ -905,7 +899,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf else title = context.getString(R.string.reblog_add); } - AlertDialog.Builder builder = new AlertDialog.Builder(context, style); + AlertDialog.Builder builder = new AlertDialog.Builder(context); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) builder.setMessage(Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY)); @@ -944,7 +938,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); final boolean isOwner = status.getAccount().getId().equals(userId); - AlertDialog.Builder builderSingle = new AlertDialog.Builder(context, style); + AlertDialog.Builder builderSingle = new AlertDialog.Builder(context); //builderSingle.setTitle(R.string.make_a_choice); final String[] stringArray, stringArrayConf; final API.StatusAction[] doAction; @@ -969,7 +963,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - AlertDialog.Builder builderInner = new AlertDialog.Builder(context, style); + AlertDialog.Builder builderInner = new AlertDialog.Builder(context); builderInner.setTitle(stringArrayConf[which]); if( isOwner) { if( which == 0) { 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 42971e806..d86d569d1 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 @@ -16,7 +16,7 @@ package fr.gouv.etalab.mastodon.fragments; import android.annotation.SuppressLint; import android.annotation.TargetApi; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.ContentUris; import android.content.Context; import android.content.DialogInterface; @@ -70,7 +70,6 @@ public class SettingsFragment extends Fragment { private Context context; private static final int ACTIVITY_CHOOSE_FILE = 411; private TextView set_folder; - private int style; int count = 0; @Override @@ -81,11 +80,6 @@ public class SettingsFragment extends Fragment { final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_DARK){ - style = R.style.DialogDark; - }else { - style = R.style.Dialog; - } boolean auto_store = sharedpreferences.getBoolean(Helper.SET_AUTO_STORE, true); @@ -279,7 +273,7 @@ public class SettingsFragment extends Fragment { set_toot_visibility.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - AlertDialog.Builder dialog = new AlertDialog.Builder(context, style); + AlertDialog.Builder dialog = new AlertDialog.Builder(context); dialog.setTitle(R.string.toot_visibility_tilte); final String[] stringArray = getResources().getStringArray(R.array.toot_visibility); final ArrayAdapter arrayAdapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, stringArray); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsProfileFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsProfileFragment.java index 221d4144e..1a32cd2b2 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsProfileFragment.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsProfileFragment.java @@ -14,7 +14,7 @@ package fr.gouv.etalab.mastodon.fragments; * You should have received a copy of the GNU General Public License along with Mastalab; if not, * see . */ import android.app.Activity; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; 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 d5a918554..cb2428293 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 @@ -18,7 +18,7 @@ package fr.gouv.etalab.mastodon.helper; import android.app.Activity; -import android.app.AlertDialog; +import android.support.v7.app.AlertDialog; import android.app.DownloadManager; import android.app.PendingIntent; import android.content.Context; diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 148129430..999690f0c 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -208,7 +208,7 @@ Aucune notification à afficher - a mentionné votre pouet + vous a mentionné a partagé votre pouet a ajouté votre pouet à ses favoris vous a suivi diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d5e23d99b..fcf26bef6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -214,7 +214,7 @@ Battery saver is enabled! It might not work as expected. No notification to display - mentioned your status + mentioned you boosted your status favourited your status followed you