fix text size in snackbars

This commit is contained in:
Daniel Gultsch 2018-04-21 20:38:14 +02:00
parent 12127a0b6e
commit 1118c4450b
3 changed files with 27 additions and 4 deletions

View File

@ -58,6 +58,7 @@ import eu.siacs.conversations.ui.util.Color;
import eu.siacs.conversations.ui.util.PendingActionHelper;
import eu.siacs.conversations.ui.util.PendingItem;
import eu.siacs.conversations.ui.util.ScrollState;
import eu.siacs.conversations.utils.ThemeHelper;
import static android.support.v7.widget.helper.ItemTouchHelper.LEFT;
import static android.support.v7.widget.helper.ItemTouchHelper.RIGHT;
@ -133,7 +134,7 @@ public class ConversationsOverviewFragment extends XmppFragment {
activity.xmppConnectionService.archiveConversation(c);
}
});
Snackbar.make(binding.list, title, 5000)
final Snackbar snackbar = Snackbar.make(binding.list, title, 5000)
.setAction(R.string.undo, v -> {
pendingActionHelper.undo();
Conversation c = swipedConversation.pop();
@ -158,8 +159,9 @@ public class ConversationsOverviewFragment extends XmppFragment {
break;
}
}
})
.show();
});
ThemeHelper.fixTextSize(snackbar);
snackbar.show();
}
};

View File

@ -22,6 +22,7 @@ import eu.siacs.conversations.databinding.ActivityShareLocationBinding;
import eu.siacs.conversations.ui.util.LocationHelper;
import eu.siacs.conversations.ui.widget.Marker;
import eu.siacs.conversations.ui.widget.MyLocation;
import eu.siacs.conversations.utils.ThemeHelper;
public class ShareLocationActivity extends LocationActivity implements LocationListener {
@ -71,6 +72,7 @@ public class ShareLocationActivity extends LocationActivity implements LocationL
startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}
});
ThemeHelper.fixTextSize(this.snackBar);
this.binding.shareButton.setOnClickListener(view -> {
final Intent result = new Intent();

View File

@ -29,13 +29,18 @@
package eu.siacs.conversations.utils;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.preference.PreferenceManager;
import android.support.annotation.StyleRes;
import android.support.design.widget.Snackbar;
import android.util.Log;
import android.util.TypedValue;
import android.widget.TextView;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.ui.SettingsActivity;
@ -66,4 +71,18 @@ public class ThemeHelper {
return false;
}
}
public static void fixTextSize(Snackbar snackbar) {
TypedArray typedArray = snackbar.getContext().obtainStyledAttributes(new int[]{R.attr.TextSizeBody1});
final float size = typedArray.getDimension(0,0f);
typedArray.recycle();
if (size != 0f) {
final TextView text = snackbar.getView().findViewById(android.support.design.R.id.snackbar_text);
final TextView action = snackbar.getView().findViewById(android.support.design.R.id.snackbar_action);
if (text != null && action != null) {
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
action.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
}
}
}
}