mirror of
https://github.com/gsantner/dandelion
synced 2025-09-10 10:49:42 +02:00
Improve badge and podselection colors ; Update podlist
This commit is contained in:
parent
c988fc3bdd
commit
eb0e2b0997
16 changed files with 844 additions and 226 deletions
|
@ -447,7 +447,8 @@ public class MainActivity extends ThemedActivity
|
|||
navMenu.findItem(R.id.nav_stream).setVisible(true);
|
||||
navMenu.findItem(R.id.nav_statistics).setVisible(appSettings.isVisibleInNavStatistics());
|
||||
navMenu.findItem(R.id.nav_reports).setVisible(appSettings.isVisibleInNavReports());
|
||||
navMenu.findItem(R.id.nav_toggle_desktop_page).setVisible(appSettings.isVisibleToggleMobileDesktop());
|
||||
navMenu.findItem(R.id.nav_toggle_desktop_page).setVisible(appSettings.isVisibleInNavToggleMobileDesktop());
|
||||
navMenu.findItem(R.id.nav_dandelion).setVisible(appSettings.isVisibleInNavDandelionAccount());
|
||||
|
||||
|
||||
// Hide whole group (for logged in use) if no pod was selected
|
||||
|
@ -1122,6 +1123,11 @@ public class MainActivity extends ThemedActivity
|
|||
}
|
||||
break;
|
||||
|
||||
case R.id.nav_dandelion: {
|
||||
openDiasporaUrl(urls.getProfileUrl("48b78420923501341ef3782bcb452bd5"));
|
||||
}
|
||||
break;
|
||||
|
||||
case R.id.nav_exit: {
|
||||
moveTaskToBack(true);
|
||||
finish();
|
||||
|
|
|
@ -177,8 +177,13 @@ public class PodSelectionFragment extends ThemedFragment implements SearchView.O
|
|||
rootView.setBackgroundColor(appSettings.isAmoledColorMode() ? Color.BLACK : Color.WHITE);
|
||||
listViewPod.setDivider(new ColorDrawable(Color.GRAY));
|
||||
listViewPod.setDividerHeight(dividerHeight);
|
||||
buttonUseCustomPod.setSupportBackgroundTintList(ColorStateList.valueOf(appSettings.isAmoledColorMode() ? Color.DKGRAY : Color.WHITE));
|
||||
buttonUseCustomPod.setTextColor(appSettings.isAmoledColorMode() ? Color.WHITE : Color.BLACK);
|
||||
if (appSettings.isAmoledColorMode()) {
|
||||
buttonUseCustomPod.setSupportBackgroundTintList(ColorStateList.valueOf(Color.DKGRAY));
|
||||
buttonUseCustomPod.setTextColor(Color.WHITE);
|
||||
} else {
|
||||
buttonUseCustomPod.setSupportBackgroundTintList(ColorStateList.valueOf(appSettings.getAccentColor()));
|
||||
buttonUseCustomPod.setTextColor(Helpers.get().shouldColorOnTopBeLight(appSettings.getAccentColor()) ? Color.WHITE : Color.BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.json.JSONObject;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -18,8 +19,9 @@ import java.util.List;
|
|||
* DiasporaPodUrl - A Url of an DiasporaPod
|
||||
* For all Classes a loading and saving to JSON method is available
|
||||
*/
|
||||
@SuppressWarnings({"WeakerAccess", "unused", "SameParameterValue", "SpellCheckingInspection", "UnusedReturnValue", "JavaDoc", "FieldCanBeLocal"})
|
||||
public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, Serializable {
|
||||
private static final boolean EXPORT_TOJSON_ACTIVE6 = false;
|
||||
private static final boolean EXPORT_TOJSON_POST_COUNT_LOCAL = true;
|
||||
private List<DiasporaPod> pods = new ArrayList<>();
|
||||
private boolean trackMergeChanges = false;
|
||||
private Integer trackAddedIndexStart = -1;
|
||||
|
@ -88,8 +90,8 @@ public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, S
|
|||
if (updatePodBak.getId() != 0 && updatePod.getId() == 0) {
|
||||
updatePod.setId(updatePodBak.getId());
|
||||
}
|
||||
if (updatePodBak.getActive6() != 0 && updatePod.getActive6() == 0) {
|
||||
updatePod.setActive6(updatePodBak.getActive6());
|
||||
if (updatePodBak.getPostCountLocal() != 0 && updatePod.getPostCountLocal() == 0) {
|
||||
updatePod.setPostCountLocal(updatePodBak.getPostCountLocal());
|
||||
}
|
||||
if (updatePodBak.getScore() != 0 && updatePod.getScore() == 0) {
|
||||
updatePod.setScore(updatePodBak.getScore());
|
||||
|
@ -179,12 +181,12 @@ public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, S
|
|||
* ╚═╝ ╚═════╝ ╚═════╝
|
||||
*/
|
||||
public static class DiasporaPod implements Iterable<DiasporaPodList.DiasporaPod.DiasporaPodUrl>, Comparable<DiasporaPod>, Serializable {
|
||||
private List<DiasporaPodUrl> podUrls = new ArrayList<>();
|
||||
private List<String> mainLangs = new ArrayList<>();
|
||||
private String name = "";
|
||||
private int score = 0;
|
||||
private int id = 0;
|
||||
private long active6 = 0;
|
||||
private List<DiasporaPodUrl> _podUrls = new ArrayList<>();
|
||||
private List<String> _mainLangs = new ArrayList<>();
|
||||
private String _name = "";
|
||||
private int _score = 0;
|
||||
private int _id = 0;
|
||||
private long _postCountLocal = 0;
|
||||
|
||||
|
||||
public DiasporaPod() {
|
||||
|
@ -199,14 +201,14 @@ public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, S
|
|||
JSONArray jarr;
|
||||
|
||||
if (json.has("name")) {
|
||||
name = json.getString("name");
|
||||
_name = json.getString("name");
|
||||
}
|
||||
if (json.has("mainLangs")) {
|
||||
jarr = json.getJSONArray("mainLangs");
|
||||
for (int i = 0; i < jarr.length(); i++) {
|
||||
String val = jarr.getString(i);
|
||||
if (!mainLangs.contains(val)) {
|
||||
mainLangs.add(val);
|
||||
if (!_mainLangs.contains(val)) {
|
||||
_mainLangs.add(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -214,19 +216,19 @@ public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, S
|
|||
jarr = json.getJSONArray("podUrls");
|
||||
for (int i = 0; i < jarr.length(); i++) {
|
||||
DiasporaPodUrl podUrl = new DiasporaPodUrl().fromJson(jarr.getJSONObject(i));
|
||||
if (!podUrls.contains(podUrl)) {
|
||||
podUrls.add(podUrl);
|
||||
if (!_podUrls.contains(podUrl)) {
|
||||
_podUrls.add(podUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (json.has("score")) {
|
||||
score = json.getInt("score");
|
||||
_score = json.getInt("score");
|
||||
}
|
||||
if (json.has("active6")) {
|
||||
active6 = json.getLong("active6");
|
||||
if (json.has("postCountLocal")) {
|
||||
_postCountLocal = json.getLong("postCountLocal");
|
||||
}
|
||||
if (json.has("id")) {
|
||||
id = json.getInt("id");
|
||||
_id = json.getInt("id");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -236,25 +238,28 @@ public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, S
|
|||
*/
|
||||
public JSONObject toJson() throws JSONException {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("name", name);
|
||||
json.put("score", score);
|
||||
json.put("id", id);
|
||||
json.put("name", _name);
|
||||
json.put("id", _id);
|
||||
|
||||
if (_score != 0) {
|
||||
json.put("score", _score);
|
||||
}
|
||||
|
||||
// Only export active6 (frequently changing if told to do)
|
||||
if (EXPORT_TOJSON_ACTIVE6) {
|
||||
json.put("active6", active6);
|
||||
if (EXPORT_TOJSON_POST_COUNT_LOCAL && _postCountLocal > 0) {
|
||||
json.put("postCountLocal", _postCountLocal);
|
||||
}
|
||||
|
||||
// Pod urls
|
||||
JSONArray jarr = new JSONArray();
|
||||
for (DiasporaPodUrl value : podUrls) {
|
||||
for (DiasporaPodUrl value : _podUrls) {
|
||||
jarr.put(value.toJson());
|
||||
}
|
||||
json.put("podUrls", jarr);
|
||||
|
||||
// main langs
|
||||
jarr = new JSONArray();
|
||||
for (String value : mainLangs) {
|
||||
for (String value : _mainLangs) {
|
||||
jarr.put(value);
|
||||
}
|
||||
json.put("mainLangs", jarr);
|
||||
|
@ -268,11 +273,11 @@ public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, S
|
|||
DiasporaPod otherPod = (DiasporaPod) o;
|
||||
|
||||
// Check if id is equal
|
||||
ret = this.id != 0 && this.id == otherPod.id;
|
||||
ret = _id != 0 && _id == otherPod._id;
|
||||
|
||||
// Check if host is the same (fallback if id is 0)
|
||||
// Check if _host is the same (fallback if id is 0)
|
||||
if (!ret) {
|
||||
for (DiasporaPodUrl podUrl : podUrls) {
|
||||
for (DiasporaPodUrl podUrl : _podUrls) {
|
||||
for (DiasporaPodUrl otherPodUrl : otherPod.getPodUrls()) {
|
||||
if (podUrl.getBaseUrl().equals(otherPodUrl.getBaseUrl())) {
|
||||
ret = true;
|
||||
|
@ -292,45 +297,46 @@ public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, S
|
|||
if (!myPodUrls.isEmpty() && !otherPodUrls.isEmpty()) {
|
||||
return myPodUrls.get(0).getHost().compareTo(otherPodUrls.get(0).getHost());
|
||||
}
|
||||
return _name.compareTo(otherPod.getName());
|
||||
}
|
||||
return name.compareTo(otherPod.getName());
|
||||
return _name.compareTo("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name + "(" + id + ")";
|
||||
return _name + "(" + _id + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterator for Iterable interface (forEach, ..)
|
||||
*/
|
||||
public Iterator<DiasporaPodUrl> iterator() {
|
||||
return podUrls.iterator();
|
||||
return _podUrls.iterator();
|
||||
}
|
||||
|
||||
/*
|
||||
* Getter & Setter
|
||||
*/
|
||||
public List<DiasporaPodUrl> getPodUrls() {
|
||||
return podUrls;
|
||||
return _podUrls;
|
||||
}
|
||||
|
||||
public DiasporaPod setPodUrls(List<DiasporaPodUrl> podUrls) {
|
||||
this.podUrls = podUrls;
|
||||
_podUrls = podUrls;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getMainLangs() {
|
||||
return mainLangs;
|
||||
return _mainLangs;
|
||||
}
|
||||
|
||||
public DiasporaPod setMainLangs(List<String> mainLangs) {
|
||||
this.mainLangs = mainLangs;
|
||||
_mainLangs = mainLangs;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DiasporaPod appendMainLangs(String... values) {
|
||||
Collections.addAll(this.mainLangs, values);
|
||||
_mainLangs.addAll(Arrays.asList(values));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -338,50 +344,50 @@ public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, S
|
|||
* Returns the first DiasporaPodUrl in the list
|
||||
*/
|
||||
public DiasporaPodUrl getPodUrl() {
|
||||
if (podUrls.size() > 0) {
|
||||
return podUrls.get(0);
|
||||
if (_podUrls.size() > 0) {
|
||||
return _podUrls.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public DiasporaPod appendPodUrls(DiasporaPodUrl... values) {
|
||||
Collections.addAll(this.podUrls, values);
|
||||
_podUrls.addAll(Arrays.asList(values));
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return _name;
|
||||
}
|
||||
|
||||
public DiasporaPod setName(String name) {
|
||||
this.name = name;
|
||||
_name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
return score;
|
||||
return _score;
|
||||
}
|
||||
|
||||
public DiasporaPod setScore(int score) {
|
||||
this.score = score;
|
||||
_score = score;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getActive6() {
|
||||
return active6;
|
||||
public long getPostCountLocal() {
|
||||
return _postCountLocal;
|
||||
}
|
||||
|
||||
public DiasporaPod setActive6(long active6) {
|
||||
this.active6 = active6;
|
||||
public DiasporaPod setPostCountLocal(long postCountLocal) {
|
||||
_postCountLocal = postCountLocal;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
return _id;
|
||||
}
|
||||
|
||||
public DiasporaPod setId(int id) {
|
||||
this.id = id;
|
||||
_id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -393,9 +399,9 @@ public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, S
|
|||
* ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
|
||||
*/
|
||||
public static class DiasporaPodUrl implements Serializable {
|
||||
private String host = "";
|
||||
private String protocol = "https";
|
||||
private Integer port = 443;
|
||||
private String _host = "";
|
||||
private String _protocol = "https";
|
||||
private Integer _port = 443;
|
||||
|
||||
public DiasporaPodUrl() {
|
||||
}
|
||||
|
@ -407,10 +413,10 @@ public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, S
|
|||
/**
|
||||
* Get the base url
|
||||
*
|
||||
* @return base url with port
|
||||
* @return
|
||||
*/
|
||||
public String getBaseUrl() {
|
||||
return protocol + "://" + host + (isPortNeeded() ? port : "");
|
||||
return _protocol + "://" + _host + (isPortNeeded() ? _port : "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -420,13 +426,13 @@ public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, S
|
|||
*/
|
||||
public DiasporaPodUrl fromJson(JSONObject json) throws JSONException {
|
||||
if (json.has("host")) {
|
||||
host = json.getString("host");
|
||||
_host = json.getString("host");
|
||||
}
|
||||
if (json.has("protocol")) {
|
||||
protocol = json.getString("protocol");
|
||||
_protocol = json.getString("protocol");
|
||||
}
|
||||
if (json.has("port")) {
|
||||
port = json.getInt("port");
|
||||
_port = json.getInt("port");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -436,12 +442,12 @@ public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, S
|
|||
*/
|
||||
public JSONObject toJson() throws JSONException {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("host", host);
|
||||
if (!protocol.equals("https")) {
|
||||
json.put("protocol", protocol);
|
||||
json.put("host", _host);
|
||||
if (!_protocol.equals("https")) {
|
||||
json.put("protocol", _protocol);
|
||||
}
|
||||
if (port != 443) {
|
||||
json.put("port", port);
|
||||
if (_port != 443) {
|
||||
json.put("port", _port);
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
@ -467,7 +473,7 @@ public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, S
|
|||
* Tells if the ports needs to shown
|
||||
*/
|
||||
public boolean isPortNeeded() {
|
||||
return !((port == 80 && protocol.equals("http")) || (port == 443 && protocol.equals("https")));
|
||||
return !((_port == 80 && _protocol.equals("http")) || (_port == 443 && _protocol.equals("https")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -476,6 +482,7 @@ public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, S
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("SimplifiableIfStatement")
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof DiasporaPodUrl) {
|
||||
return getBaseUrl().equals(((DiasporaPodUrl) o).getBaseUrl());
|
||||
|
@ -487,29 +494,29 @@ public class DiasporaPodList implements Iterable<DiasporaPodList.DiasporaPod>, S
|
|||
* GETTER & SETTER
|
||||
*/
|
||||
public String getHost() {
|
||||
return host;
|
||||
return _host;
|
||||
}
|
||||
|
||||
public DiasporaPodUrl setHost(String host) {
|
||||
this.host = host;
|
||||
_host = host;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
return _protocol;
|
||||
}
|
||||
|
||||
public DiasporaPodUrl setProtocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
_protocol = protocol;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPort() {
|
||||
return port;
|
||||
return _port;
|
||||
}
|
||||
|
||||
public DiasporaPodUrl setPort(Integer port) {
|
||||
this.port = port;
|
||||
_port = port;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,95 +28,80 @@ import android.graphics.Rect;
|
|||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.github.dfa.diaspora_android.R;
|
||||
import com.github.dfa.diaspora_android.util.AppSettings;
|
||||
import com.github.dfa.diaspora_android.util.Helpers;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class BadgeDrawable extends Drawable {
|
||||
// Source: http://mobikul.com/adding-badge-count-on-menu-items-like-cart-notification-etc/
|
||||
private static final String BADGE_VALUE_OVERFLOW = "*";
|
||||
|
||||
private Paint badgeBackground;
|
||||
private Paint badgeStroke;
|
||||
private Paint badgeText;
|
||||
private Rect textRect = new Rect();
|
||||
private Paint _badgeBackground;
|
||||
private Paint _badgeText;
|
||||
private Rect _textRect = new Rect();
|
||||
|
||||
private String badgeValue = "";
|
||||
private boolean shouldDraw;
|
||||
private String _badgeValue = "";
|
||||
private boolean _shouldDraw;
|
||||
|
||||
public BadgeDrawable(Context context) {
|
||||
float textSize = context.getResources().getDimension(R.dimen.textsize_badge_count);
|
||||
|
||||
AppSettings settings = AppSettings.get();
|
||||
badgeBackground = new Paint();
|
||||
badgeBackground.setColor(settings.getAccentColor());
|
||||
badgeBackground.setAntiAlias(true);
|
||||
badgeBackground.setStyle(Paint.Style.FILL);
|
||||
badgeStroke = new Paint();
|
||||
badgeStroke.setColor(ContextCompat.getColor(context.getApplicationContext(), R.color.colorPrimaryDark));
|
||||
badgeStroke.setAntiAlias(true);
|
||||
badgeStroke.setStyle(Paint.Style.FILL);
|
||||
_badgeBackground = new Paint();
|
||||
_badgeBackground.setColor(settings.getAccentColor());
|
||||
_badgeBackground.setAntiAlias(true);
|
||||
_badgeBackground.setStyle(Paint.Style.FILL);
|
||||
|
||||
badgeText = new Paint();
|
||||
badgeText.setColor(Color.WHITE);
|
||||
badgeText.setTypeface(Typeface.DEFAULT);
|
||||
badgeText.setTextSize(textSize);
|
||||
badgeText.setAntiAlias(true);
|
||||
badgeText.setTextAlign(Paint.Align.CENTER);
|
||||
_badgeText = new Paint();
|
||||
_badgeText.setColor(Helpers.get().shouldColorOnTopBeLight(settings.getAccentColor()) ? Color.WHITE : Color.BLACK);
|
||||
_badgeText.setTypeface(Typeface.DEFAULT);
|
||||
_badgeText.setTextSize(textSize);
|
||||
_badgeText.setAntiAlias(true);
|
||||
_badgeText.setTextAlign(Paint.Align.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
if (!shouldDraw) {
|
||||
public void draw(@NonNull Canvas canvas) {
|
||||
if (!_shouldDraw) {
|
||||
return;
|
||||
}
|
||||
Rect bounds = getBounds();
|
||||
float width = bounds.right - bounds.left;
|
||||
float height = bounds.bottom - bounds.top;
|
||||
float oneDp = Helpers.get().dp2px(1);
|
||||
|
||||
// Position the badge in the top-right quadrant of the icon.
|
||||
float radius = ((Math.max(width, height) / 2)) / 2;
|
||||
float centerX = (width - radius - 1) + 5;
|
||||
float centerY = radius - 5;
|
||||
if (badgeValue.length() <= 2) {
|
||||
// Draw badge circle.
|
||||
canvas.drawCircle(centerX, centerY, (int) (radius + 7.5), badgeStroke);
|
||||
canvas.drawCircle(centerX, centerY, (int) (radius + 5.5), badgeBackground);
|
||||
} else {
|
||||
canvas.drawCircle(centerX, centerY, (int) (radius + 8.5), badgeStroke);
|
||||
canvas.drawCircle(centerX, centerY, (int) (radius + 6.5), badgeBackground);
|
||||
//canvas.drawRoundRect(radius, radius, radius, radius, 10, 10, badgeBackground);
|
||||
}
|
||||
float centerX = (width - radius - 1) + oneDp * 2;
|
||||
float centerY = radius - 2 * oneDp;
|
||||
canvas.drawCircle(centerX, centerY, (int) (radius + oneDp * 5), _badgeBackground);
|
||||
|
||||
// Draw badge count message inside the circle.
|
||||
badgeText.getTextBounds(badgeValue, 0, badgeValue.length(), textRect);
|
||||
float textHeight = textRect.bottom - textRect.top;
|
||||
_badgeText.getTextBounds(_badgeValue, 0, _badgeValue.length(), _textRect);
|
||||
float textHeight = _textRect.bottom - _textRect.top;
|
||||
float textY = centerY + (textHeight / 2f);
|
||||
if (badgeValue.length() > 2)
|
||||
canvas.drawText(BADGE_VALUE_OVERFLOW, centerX, textY, badgeText);
|
||||
else
|
||||
canvas.drawText(badgeValue, centerX, textY, badgeText);
|
||||
canvas.drawText(_badgeValue.length() > 2 ? BADGE_VALUE_OVERFLOW : _badgeValue,
|
||||
centerX, textY, _badgeText);
|
||||
}
|
||||
|
||||
/*
|
||||
Sets the count (i.e notifications) to display.
|
||||
*/
|
||||
public void setCount(String count) {
|
||||
badgeValue = count;
|
||||
// Sets the text to display. Badge displays a '*' if more than 2 characters
|
||||
private void setBadgeText(String text) {
|
||||
_badgeValue = text;
|
||||
|
||||
// Only draw a badge if there are notifications.
|
||||
shouldDraw = !count.equalsIgnoreCase("0");
|
||||
// Only draw a badge if the value isn't a zero
|
||||
_shouldDraw = !text.equalsIgnoreCase("0");
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -125,11 +110,11 @@ public class BadgeDrawable extends Drawable {
|
|||
}
|
||||
|
||||
public static void setBadgeCount(Context context, LayerDrawable icon, Integer count) {
|
||||
setBadgeCount(context, icon, count.toString());
|
||||
setBadgeText(context, icon, count.toString());
|
||||
}
|
||||
|
||||
public static void setBadgeCount(Context context, LayerDrawable icon, String count) {
|
||||
|
||||
// Max of 2 characters
|
||||
public static void setBadgeText(Context context, LayerDrawable icon, String text) {
|
||||
BadgeDrawable badge;
|
||||
|
||||
// Reuse drawable if possible
|
||||
|
@ -140,7 +125,7 @@ public class BadgeDrawable extends Drawable {
|
|||
badge = new BadgeDrawable(context);
|
||||
}
|
||||
|
||||
badge.setCount(count);
|
||||
badge.setBadgeText(text);
|
||||
icon.mutate();
|
||||
icon.setDrawableByLayerId(R.id.ic_badge, badge);
|
||||
}
|
||||
|
|
|
@ -341,7 +341,11 @@ public class AppSettings extends AppSettingsBase {
|
|||
return getBool(_prefApp, R.string.pref_key__visibility_nav__reports, false);
|
||||
}
|
||||
|
||||
public boolean isVisibleToggleMobileDesktop() {
|
||||
public boolean isVisibleInNavDandelionAccount() {
|
||||
return getBool(_prefApp, R.string.pref_key__visibility_nav__dandelion_account, false);
|
||||
}
|
||||
|
||||
public boolean isVisibleInNavToggleMobileDesktop() {
|
||||
return getBool(_prefApp, R.string.pref_key__visibility_nav__toggle_mobile_desktop, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import com.github.dfa.diaspora_android.data.DiasporaPodList.DiasporaPod;
|
|||
* Helper class that provides easy access to specific urls related to diaspora
|
||||
* Created by vanitasvitae on 10.08.16.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@SuppressWarnings({"unused", "SpellCheckingInspection", "SameParameterValue", "WeakerAccess"})
|
||||
public class DiasporaUrlHelper {
|
||||
private final AppSettings settings;
|
||||
|
||||
|
@ -151,7 +151,7 @@ public class DiasporaUrlHelper {
|
|||
* @param profileId Id of the profile to be shown
|
||||
* @return https://(pod-domain.tld)/people/(profileId)
|
||||
*/
|
||||
public String getProfileUrl(long profileId) {
|
||||
public String getProfileUrl(String profileId) {
|
||||
return getPodUrl() + SUBURL_PEOPLE + profileId;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.content.pm.PackageInfo;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
|
@ -298,6 +299,13 @@ public class Helpers {
|
|||
_context.getResources().updateConfiguration(config, null);
|
||||
}
|
||||
|
||||
// Find out if color above the given color should be light or dark. true if light
|
||||
public boolean shouldColorOnTopBeLight(int colorOnBottomInt) {
|
||||
return 186 > (((0.299 * Color.red(colorOnBottomInt))
|
||||
+ ((0.587 * Color.green(colorOnBottomInt))
|
||||
+ (0.114 * Color.blue(colorOnBottomInt)))));
|
||||
}
|
||||
|
||||
public float px2dp(final float px) {
|
||||
return px / _context.getResources().getDisplayMetrics().density;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue