mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-01-31 03:17:19 +01:00
layout fix, code cleanup
This commit is contained in:
parent
bac6f4940e
commit
40405ba5f2
1
.idea/inspectionProfiles/Project_Default.xml
generated
1
.idea/inspectionProfiles/Project_Default.xml
generated
@ -1,6 +1,7 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="AndroidLintClickableViewAccessibility" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="BooleanMethodIsAlwaysInverted" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
@ -7,10 +7,7 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextPaint;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
@ -51,10 +48,8 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static android.os.AsyncTask.Status.RUNNING;
|
||||
import static android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
|
||||
import static android.view.MotionEvent.ACTION_DOWN;
|
||||
import static android.view.MotionEvent.ACTION_UP;
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static org.nuclearfog.twidda.activity.MediaViewer.KEY_MEDIA_LINK;
|
||||
@ -79,12 +74,11 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
public static final Pattern linkPattern = Pattern.compile(".*/@?[\\w_]+/status/\\d{1,20}/?.*");
|
||||
|
||||
private View header, footer, videoButton, imageButton;
|
||||
private TextView tweet_api, tweetDate, tweetText, scrName, usrName, tweetLoc;
|
||||
private Button rtwButton, favButton, replyName;
|
||||
private TextView tweet_api, tweetDate, tweetText, scrName, usrName, tweetLocName;
|
||||
private Button rtwButton, favButton, replyName, tweetLocGPS;
|
||||
private ImageView profile_img;
|
||||
|
||||
private GlobalSettings settings;
|
||||
private NumberFormat format;
|
||||
private StatusLoader statusAsync;
|
||||
|
||||
@Nullable
|
||||
@ -100,8 +94,6 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
Bundle param = getIntent().getExtras();
|
||||
Uri link = getIntent().getData();
|
||||
settings = GlobalSettings.getInstance(this);
|
||||
format = NumberFormat.getIntegerInstance();
|
||||
|
||||
if (param != null && param.containsKey(KEY_TWEET_ID) && param.containsKey(KEY_TWEET_NAME)) {
|
||||
tweetID = param.getLong(KEY_TWEET_ID);
|
||||
username = param.getString(KEY_TWEET_NAME);
|
||||
@ -123,7 +115,8 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
tweetText = findViewById(R.id.tweet_detailed);
|
||||
tweetDate = findViewById(R.id.timedetail);
|
||||
tweet_api = findViewById(R.id.used_api);
|
||||
tweetLoc = findViewById(R.id.tweet_location);
|
||||
tweetLocName = findViewById(R.id.tweet_location_name);
|
||||
tweetLocGPS = findViewById(R.id.tweet_location_coordinate);
|
||||
imageButton = findViewById(R.id.image_attach);
|
||||
videoButton = findViewById(R.id.video_attach);
|
||||
|
||||
@ -131,9 +124,8 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
if (getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
||||
|
||||
FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager(), AdapterType.TWEET_PAGE, tweetID, username);
|
||||
FontTool.setViewFont(settings, root);
|
||||
tweetLoc.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager(), AdapterType.TWEET_PAGE, tweetID, username);
|
||||
tweetText.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
tweetText.setLinkTextColor(settings.getHighlightColor());
|
||||
root.setBackgroundColor(settings.getBackgroundColor());
|
||||
@ -148,6 +140,9 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
rtwButton.setOnLongClickListener(this);
|
||||
favButton.setOnLongClickListener(this);
|
||||
profile_img.setOnClickListener(this);
|
||||
tweetLocGPS.setOnClickListener(this);
|
||||
videoButton.setOnClickListener(this);
|
||||
imageButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
|
||||
@ -263,10 +258,44 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
|
||||
case R.id.answer_reference_detail:
|
||||
if (tweet != null) {
|
||||
Intent intent = new Intent(getApplicationContext(), TweetDetail.class);
|
||||
intent.putExtra(KEY_TWEET_ID, tweet.getReplyId());
|
||||
intent.putExtra(KEY_TWEET_NAME, tweet.getReplyName());
|
||||
startActivity(intent);
|
||||
Intent answerIntent = new Intent(getApplicationContext(), TweetDetail.class);
|
||||
answerIntent.putExtra(KEY_TWEET_ID, tweet.getReplyId());
|
||||
answerIntent.putExtra(KEY_TWEET_NAME, tweet.getReplyName());
|
||||
startActivity(answerIntent);
|
||||
}
|
||||
break;
|
||||
|
||||
case R.id.tweet_location_coordinate:
|
||||
if (tweet != null) {
|
||||
Intent locationIntent = new Intent(Intent.ACTION_VIEW);
|
||||
locationIntent.setData(Uri.parse("geo:" + tweet.getLocationCoordinates()));
|
||||
if (locationIntent.resolveActivity(getPackageManager()) != null)
|
||||
startActivity(locationIntent);
|
||||
else
|
||||
Toast.makeText(getApplicationContext(), R.string.error_no_card_app, LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
|
||||
case R.id.image_attach:
|
||||
if (tweet != null) {
|
||||
Intent mediaIntent = new Intent(getApplicationContext(), MediaViewer.class);
|
||||
mediaIntent.putExtra(KEY_MEDIA_LINK, tweet.getMediaLinks());
|
||||
mediaIntent.putExtra(KEY_MEDIA_TYPE, MEDIAVIEWER_IMAGE);
|
||||
startActivity(mediaIntent);
|
||||
}
|
||||
break;
|
||||
|
||||
case R.id.video_attach:
|
||||
if (tweet != null) {
|
||||
String[] links = tweet.getMediaLinks();
|
||||
StringTools.FileType ext = StringTools.getFileType(links[0]);
|
||||
Intent mediaIntent = new Intent(getApplicationContext(), MediaViewer.class);
|
||||
if (ext == StringTools.FileType.VIDEO)
|
||||
mediaIntent.putExtra(KEY_MEDIA_TYPE, MEDIAVIEWER_ANGIF);
|
||||
else
|
||||
mediaIntent.putExtra(KEY_MEDIA_TYPE, MEDIAVIEWER_VIDEO);
|
||||
mediaIntent.putExtra(KEY_MEDIA_LINK, links);
|
||||
startActivity(mediaIntent);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -332,11 +361,12 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
}
|
||||
|
||||
|
||||
public void setTweet(final Tweet tweet) {
|
||||
public void setTweet(Tweet tweet) {
|
||||
this.tweet = tweet;
|
||||
invalidateOptionsMenu();
|
||||
|
||||
TwitterUser author = tweet.getUser();
|
||||
NumberFormat buttonNumber = NumberFormat.getIntegerInstance();
|
||||
int rtwDraw = tweet.retweeted() ? R.drawable.retweet_enabled : R.drawable.retweet;
|
||||
int favDraw = tweet.favored() ? R.drawable.favorite_enabled : R.drawable.favorite;
|
||||
int verDraw = author.isVerified() ? R.drawable.verify : 0;
|
||||
@ -347,24 +377,22 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
scrName.setCompoundDrawablesWithIntrinsicBounds(locDraw, 0, 0, 0);
|
||||
usrName.setText(author.getUsername());
|
||||
scrName.setText(author.getScreenname());
|
||||
usrName.setTextColor(settings.getFontColor());
|
||||
scrName.setTextColor(settings.getFontColor());
|
||||
tweetDate.setText(SimpleDateFormat.getDateTimeInstance().format(tweet.getTime()));
|
||||
tweetDate.setTextColor(settings.getFontColor());
|
||||
tweet_api.setTextColor(settings.getFontColor());
|
||||
favButton.setText(format.format(tweet.getFavorCount()));
|
||||
rtwButton.setText(format.format(tweet.getRetweetCount()));
|
||||
favButton.setText(buttonNumber.format(tweet.getFavorCount()));
|
||||
rtwButton.setText(buttonNumber.format(tweet.getRetweetCount()));
|
||||
tweet_api.setText(R.string.sent_from);
|
||||
tweet_api.append(tweet.getSource());
|
||||
header.setVisibility(VISIBLE);
|
||||
footer.setVisibility(VISIBLE);
|
||||
|
||||
if (header.getVisibility() != VISIBLE) {
|
||||
header.setVisibility(VISIBLE);
|
||||
footer.setVisibility(VISIBLE);
|
||||
}
|
||||
if (!tweet.getTweet().trim().isEmpty()) {
|
||||
Spannable sTweet = Tagger.makeTextWithLinks(tweet.getTweet(), settings.getHighlightColor(), this);
|
||||
tweetText.setVisibility(VISIBLE);
|
||||
tweetText.setText(sTweet);
|
||||
}
|
||||
if (tweet.getReplyId() > 1) {
|
||||
if (tweet.getReplyId() > 0) {
|
||||
replyName.setText(R.string.tweet_answering);
|
||||
replyName.append(tweet.getReplyName());
|
||||
replyName.setVisibility(VISIBLE);
|
||||
@ -372,84 +400,23 @@ public class TweetDetail extends AppCompatActivity implements OnClickListener, O
|
||||
if (tweet.hasMedia()) {
|
||||
String[] links = tweet.getMediaLinks();
|
||||
StringTools.FileType ext = StringTools.getFileType(links[0]);
|
||||
switch (ext) {
|
||||
case IMAGE:
|
||||
videoButton.setVisibility(GONE);
|
||||
imageButton.setVisibility(VISIBLE);
|
||||
imageButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent media = new Intent(getApplicationContext(), MediaViewer.class);
|
||||
media.putExtra(KEY_MEDIA_LINK, tweet.getMediaLinks());
|
||||
media.putExtra(KEY_MEDIA_TYPE, MEDIAVIEWER_IMAGE);
|
||||
startActivity(media);
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case VIDEO:
|
||||
imageButton.setVisibility(GONE);
|
||||
videoButton.setVisibility(VISIBLE);
|
||||
videoButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent media = new Intent(getApplicationContext(), MediaViewer.class);
|
||||
media.putExtra(KEY_MEDIA_LINK, tweet.getMediaLinks());
|
||||
media.putExtra(KEY_MEDIA_TYPE, MEDIAVIEWER_ANGIF);
|
||||
startActivity(media);
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case STREAM:
|
||||
imageButton.setVisibility(GONE);
|
||||
videoButton.setVisibility(VISIBLE);
|
||||
videoButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent media = new Intent(getApplicationContext(), MediaViewer.class);
|
||||
media.putExtra(KEY_MEDIA_LINK, tweet.getMediaLinks());
|
||||
media.putExtra(KEY_MEDIA_TYPE, MEDIAVIEWER_VIDEO);
|
||||
startActivity(media);
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
if (ext == StringTools.FileType.IMAGE)
|
||||
imageButton.setVisibility(VISIBLE);
|
||||
else
|
||||
videoButton.setVisibility(VISIBLE);
|
||||
}
|
||||
if (settings.getImageLoad())
|
||||
if (settings.getImageLoad()) {
|
||||
Picasso.get().load(author.getImageLink() + "_bigger").into(profile_img);
|
||||
|
||||
final String placeName = tweet.getLocationName();
|
||||
final String location = tweet.getLocationCoordinates();
|
||||
SpannableStringBuilder locationText = new SpannableStringBuilder("");
|
||||
if (placeName != null && !placeName.isEmpty()) {
|
||||
locationText.append(placeName);
|
||||
locationText.append(" ");
|
||||
tweetLoc.setText(locationText);
|
||||
tweetLoc.setVisibility(VISIBLE);
|
||||
}
|
||||
String placeName = tweet.getLocationName();
|
||||
if (placeName != null && !placeName.isEmpty()) {
|
||||
tweetLocName.setVisibility(VISIBLE);
|
||||
tweetLocName.setText(placeName);
|
||||
}
|
||||
String location = tweet.getLocationCoordinates();
|
||||
if (location != null && !location.isEmpty()) {
|
||||
final int start = locationText.length();
|
||||
locationText.append(location);
|
||||
final int end = locationText.length();
|
||||
locationText.setSpan(new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
Intent locationIntent = new Intent(Intent.ACTION_VIEW);
|
||||
locationIntent.setData(Uri.parse("geo:" + location));
|
||||
if (locationIntent.resolveActivity(getPackageManager()) != null)
|
||||
startActivity(locationIntent);
|
||||
else
|
||||
Toast.makeText(getApplicationContext(), R.string.error_no_card_app, LENGTH_SHORT).show();
|
||||
}
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
ds.setColor(settings.getHighlightColor());
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
}, start, end, SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
tweetLoc.setText(locationText);
|
||||
tweetLoc.setVisibility(VISIBLE);
|
||||
tweetLocGPS.setVisibility(VISIBLE);
|
||||
tweetLocGPS.setText(location);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package org.nuclearfog.twidda.activity;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spanned;
|
||||
@ -133,8 +132,6 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||
bioTxt.setLinkTextColor(settings.getHighlightColor());
|
||||
lnkTxt.setLinkTextColor(settings.getHighlightColor());
|
||||
root.setBackgroundColor(settings.getBackgroundColor());
|
||||
tweetTabTxt.setTextColor(Color.WHITE);
|
||||
favorTabTxt.setTextColor(Color.WHITE);
|
||||
tweetTabTxt.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.home_profile, 0, 0);
|
||||
favorTabTxt.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.favorite_profile, 0, 0);
|
||||
tweetTabTxt.setGravity(CENTER);
|
||||
|
@ -85,7 +85,7 @@ public class Tweet {
|
||||
else
|
||||
locationName = "";
|
||||
if (geo != null)
|
||||
locationCoordinates = geo.getLatitude() + ", " + geo.getLongitude();
|
||||
locationCoordinates = geo.getLatitude() + "," + geo.getLongitude();
|
||||
else
|
||||
locationCoordinates = "";
|
||||
if (status.getInReplyToScreenName() != null)
|
||||
|
@ -61,14 +61,14 @@
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/username" />
|
||||
android:text="@string/username" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edit_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/margin_layout"
|
||||
android:background="@android:color/transparent"
|
||||
android:background="@color/half_transparent"
|
||||
android:hint="@string/tweet"
|
||||
android:inputType="text"
|
||||
android:singleLine="true"
|
||||
@ -84,7 +84,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/margin_layout"
|
||||
android:background="@android:color/transparent"
|
||||
android:background="@color/half_transparent"
|
||||
android:ems="10"
|
||||
android:hint="@string/edit_location_hint"
|
||||
android:inputType="text"
|
||||
@ -102,7 +102,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/margin_layout"
|
||||
android:background="@android:color/transparent"
|
||||
android:background="@color/half_transparent"
|
||||
android:ems="10"
|
||||
android:hint="@string/edit_hint_link"
|
||||
android:inputType="text"
|
||||
@ -118,7 +118,7 @@
|
||||
android:id="@+id/edit_bio"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/text_bio_height"
|
||||
android:background="@android:color/transparent"
|
||||
android:background="@color/half_transparent"
|
||||
android:ems="10"
|
||||
android:gravity="top"
|
||||
android:hint="@string/edit_hint_enter_descr"
|
||||
|
@ -133,15 +133,38 @@
|
||||
android:visibility="gone"
|
||||
app:srcCompat="@drawable/video" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tweet_location"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textSize="@dimen/textsize_tweet_locale"
|
||||
android:visibility="gone"
|
||||
app:drawableLeftCompat="@drawable/userlocation"
|
||||
app:drawableStartCompat="@drawable/userlocation" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tweet_location_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="@dimen/padding_drawable"
|
||||
android:singleLine="true"
|
||||
android:textSize="@dimen/textsize_tweet_locale"
|
||||
android:visibility="gone"
|
||||
app:drawableLeftCompat="@drawable/userlocation"
|
||||
app:drawableStartCompat="@drawable/userlocation" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/tweet_location_coordinate"
|
||||
style="@style/Widget.AppCompat.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/tweet_button_location"
|
||||
android:layout_marginLeft="@dimen/margin_layout"
|
||||
android:layout_marginRight="@dimen/margin_layout"
|
||||
android:background="@drawable/button"
|
||||
android:drawablePadding="@dimen/padding_drawable"
|
||||
android:paddingLeft="@dimen/button_padding"
|
||||
android:paddingRight="@dimen/button_padding"
|
||||
android:singleLine="true"
|
||||
android:textSize="@dimen/textsize_tweet_locale"
|
||||
android:visibility="gone" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/used_api"
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="halftrancparency">#40000000</color>
|
||||
<color name="brighttrancparency">#afffffff</color>
|
||||
</resources>
|
||||
<color name="half_transparent">#40000000</color>
|
||||
<color name="bright_transparent">#afffffff</color>
|
||||
</resources>
|
@ -63,4 +63,5 @@
|
||||
<dimen name="list_bar_padding">10dp</dimen>
|
||||
<dimen name="listitem_button_padding">5dp</dimen>
|
||||
<dimen name="loginpage_button_padding">24dp</dimen>
|
||||
<dimen name="tweet_button_location">16dp</dimen>
|
||||
</resources>
|
@ -15,7 +15,7 @@
|
||||
</style>
|
||||
|
||||
<style name="InfoDialog" parent="Theme.AppCompat.Dialog.Alert">
|
||||
<item name="android:colorBackground">@color/brighttrancparency</item>
|
||||
<item name="android:colorBackground">@color/bright_transparent</item>
|
||||
<item name="android:textColor">@android:color/holo_red_dark</item>
|
||||
<item name="android:textColorPrimary">@android:color/black</item>
|
||||
<item name="android:backgroundDimEnabled">true</item>
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
<style name="CardViewStyle" parent="CardView">
|
||||
<item name="cardPreventCornerOverlap">false</item>
|
||||
<item name="cardBackgroundColor">@color/halftrancparency</item>
|
||||
<item name="cardBackgroundColor">@color/half_transparent</item>
|
||||
<item name="cardCornerRadius">5dp</item>
|
||||
<item name="cardUseCompatPadding">true</item>
|
||||
</style>
|
||||
|
Loading…
x
Reference in New Issue
Block a user