diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java index 60fea8d3..2444bf95 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java @@ -19,6 +19,7 @@ import android.text.SpannableString; import android.text.Spanned; import android.text.style.ForegroundColorSpan; import android.text.style.RelativeSizeSpan; +import android.util.Log; import android.view.View; import android.widget.ImageView; import android.widget.ProgressBar; @@ -243,14 +244,15 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment try { Response response = client.newCall(request).execute(); profilePage = Jsoup.parse(response.body().string()); - Elements contentsTable = profilePage.select(".bordercolor > tbody:nth-child(1) > tr:nth-child(2)"); + Elements contentsTable = profilePage. + select(".bordercolor > tbody:nth-child(1) > tr:nth-child(2) tbody"); //Finds username if missing if (username == null || Objects.equals(username, "")) { username = contentsTable.select("tr").first().select("td").last().text(); } if (thumbnailUrl == null || Objects.equals(thumbnailUrl, "")) { //Maybe there is an avatar - Element profileAvatar = contentsTable.select("img.avatar").first(); + Element profileAvatar = profilePage.select("img.avatar").first(); if (profileAvatar != null) thumbnailUrl = profileAvatar.attr("abs:src"); } { //Finds personal text @@ -291,8 +293,8 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment protected void onPostExecute(Boolean result) { if (!result) { //Parse failed! Report.d(TAG, "Parse failed!"); - Toast.makeText(getBaseContext() - , "Fatal error!\n Aborting...", Toast.LENGTH_LONG).show(); + Toast.makeText(getBaseContext(), "Fatal error!\n Aborting..." + , Toast.LENGTH_LONG).show(); finish(); } //Parse was successful diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java index a2a0eea9..f876b6ff 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java @@ -6,6 +6,8 @@ import android.os.Build; import android.os.Bundle; import android.support.v4.app.Fragment; import android.text.Html; +import android.text.method.LinkMovementMethod; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -189,6 +191,16 @@ public class SummaryFragment extends Fragment { } TextView entry = new TextView(this.getContext()); + if (profileSummaryRow.contains("@") && + (profileSummaryRow.contains("Email") || profileSummaryRow.contains("E-mail"))) { + Log.d(TAG, "mpika"); + Log.d(TAG, profileSummaryRow); + String email = profileSummaryRow.substring(profileSummaryRow.indexOf(": ") + 6); + profileSummaryRow = profileSummaryRow.replace(email, + "" + email + ""); + entry.setMovementMethod(LinkMovementMethod.getInstance()); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) entry.setTextColor(getResources().getColor(R.color.primary_text, null)); else diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/CenterVerticalSpan.java b/app/src/main/java/gr/thmmy/mthmmy/utils/CenterVerticalSpan.java index 949a9736..cc98fe90 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/CenterVerticalSpan.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/CenterVerticalSpan.java @@ -1,20 +1,23 @@ package gr.thmmy.mthmmy.utils; -import android.text.TextPaint; -import android.text.style.SuperscriptSpan; -import android.util.Log; - -public class CenterVerticalSpan extends SuperscriptSpan { - public CenterVerticalSpan() { - } +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Rect; +import android.support.annotation.NonNull; +import android.text.style.ReplacementSpan; +public class CenterVerticalSpan extends ReplacementSpan { @Override - public void updateDrawState(TextPaint textPaint) { - textPaint.baselineShift -= 7f; + public int getSize(@NonNull Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) { + text = text.subSequence(start, end); + return (int) paint.measureText(text.toString()); } @Override - public void updateMeasureState(TextPaint tp) { - updateDrawState(tp); + public void draw(@NonNull Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) { + text = text.subSequence(start, end); + Rect charSize = new Rect(); + paint.getTextBounds(text.toString(), 0, 1, charSize); + canvas.drawText(text.toString(), x, (bottom + charSize.height()) / 2f, paint); } } \ No newline at end of file