Fixes alert dialog issue

This commit is contained in:
tom79 2017-08-15 18:07:23 +02:00
parent 914bdfefa4
commit 45ac4fb949
11 changed files with 29 additions and 82 deletions

View File

@ -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<String> 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

View File

@ -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 <http://www.gnu.org/licenses>. */
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<Account> 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]);

View File

@ -15,7 +15,7 @@ package fr.gouv.etalab.mastodon.drawers;
* see <http://www.gnu.org/licenses>. */
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<StoredStatus> 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)

View File

@ -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 <http://www.gnu.org/licenses>. */
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<Notification> 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

View File

@ -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 <http://www.gnu.org/licenses>. */
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<StoredStatus> 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);

View File

@ -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 <http://www.gnu.org/licenses>. */
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<Status> 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) {

View File

@ -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<String> arrayAdapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, stringArray);

View File

@ -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 <http://www.gnu.org/licenses>. */
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;

View File

@ -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;

View File

@ -208,7 +208,7 @@
<!-- Notifications -->
<string name="no_notifications">Aucune notification à afficher</string>
<string name="notif_mention">a mentionné votre pouet</string>
<string name="notif_mention">vous a mentionné</string>
<string name="notif_reblog">a partagé votre pouet</string>
<string name="notif_favourite">a ajouté votre pouet à ses favoris</string>
<string name="notif_follow">vous a suivi</string>

View File

@ -214,7 +214,7 @@
<string name="warning_battery">Battery saver is enabled! It might not work as expected.</string>
<!-- Notifications -->
<string name="no_notifications">No notification to display</string>
<string name="notif_mention">mentioned your status</string>
<string name="notif_mention">mentioned you</string>
<string name="notif_reblog">boosted your status</string>
<string name="notif_favourite">favourited your status</string>
<string name="notif_follow">followed you</string>