removed hardcoded strings

This commit is contained in:
NudeDude 2018-08-12 14:26:29 +02:00
parent 01f9adc466
commit 693b0124dc
5 changed files with 73 additions and 55 deletions

View File

@ -225,6 +225,9 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
txtFollower.setText(follower); txtFollower.setText(follower);
txtFollowing.setText(following); txtFollowing.setText(following);
txtCreated.setText(dateString); txtCreated.setText(dateString);
txtFollower.setVisibility(View.VISIBLE);
txtFollowing.setVisibility(View.VISIBLE);
txtCreated.setVisibility(View.VISIBLE);
if(location!= null && !location.isEmpty()) { if(location!= null && !location.isEmpty()) {
txtLocation.setText(location); txtLocation.setText(location);
txtLocation.setVisibility(View.VISIBLE); txtLocation.setVisibility(View.VISIBLE);
@ -265,20 +268,20 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
favoritsReload.setRefreshing(false); favoritsReload.setRefreshing(false);
} }
else if(mode == ACTION_FOLLOW) { else if(mode == ACTION_FOLLOW) {
String text; int textId;
if(isFollowing) if(isFollowing)
text = "gefolgt!"; textId = R.string.followed;
else else
text = "entfolgt!"; textId = R.string.unfollowed;
Toast.makeText(ui.get(),text,Toast.LENGTH_LONG).show(); Toast.makeText(ui.get(), textId, Toast.LENGTH_SHORT).show();
} }
else if(mode == ACTION_MUTE) { else if(mode == ACTION_MUTE) {
String text; int textId;
if(blocked) if(blocked)
text = "gesperrt!"; textId = R.string.blocked;
else else
text = "entsperrt!"; textId = R.string.unblocked;
Toast.makeText(ui.get(),text,Toast.LENGTH_LONG).show(); Toast.makeText(ui.get(), textId, Toast.LENGTH_SHORT).show();
} }
else if(mode == FAILURE) else if(mode == FAILURE)
{ {
@ -300,18 +303,18 @@ public class ProfileLoader extends AsyncTask<Long,Void,Long> {
MenuItem blockIcon = tool.getMenu().getItem(2); MenuItem blockIcon = tool.getMenu().getItem(2);
if (isFollowing) { if (isFollowing) {
followIcon.setIcon(R.drawable.follow_enabled); followIcon.setIcon(R.drawable.follow_enabled);
followIcon.setTitle("entfolgen"); followIcon.setTitle(R.string.unfollow);
} else { } else {
followIcon.setIcon(R.drawable.follow); followIcon.setIcon(R.drawable.follow);
followIcon.setTitle("folgen"); followIcon.setTitle(R.string.follow);
} }
if (blocked) { if (blocked) {
blockIcon.setIcon(R.drawable.block_enabled); blockIcon.setIcon(R.drawable.block_enabled);
blockIcon.setTitle("entblocken"); blockIcon.setTitle(R.string.unblock);
followIcon.setVisible(false); followIcon.setVisible(false);
} else { } else {
blockIcon.setIcon(R.drawable.block); blockIcon.setIcon(R.drawable.block);
blockIcon.setTitle("block"); blockIcon.setTitle(R.string.block);
followIcon.setVisible(true); followIcon.setVisible(true);
} }
} }

View File

@ -3,7 +3,6 @@ package org.nuclearfog.twidda.backend;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.text.Spannable; import android.text.Spannable;
@ -53,11 +52,11 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
private String usernameStr, scrNameStr, tweetStr, dateString; private String usernameStr, scrNameStr, tweetStr, dateString;
private String repliedUsername, apiName, profile_pb; private String repliedUsername, apiName, profile_pb;
private String medialinks[]; private String medialinks[];
private String errorMessage = "Status load: ";
private boolean retweeted, favorited, toggleImg, verified; private boolean retweeted, favorited, toggleImg, verified;
private long tweetReplyID, replyUserId; private long tweetReplyID, replyUserId;
private int rtCount, favCount; private int rtCount, favCount;
private int highlight, font; private int highlight, font;
private String errorMessage = "Status load: ";
private int returnCode = 0; private int returnCode = 0;
private WeakReference<TweetDetail> ui; private WeakReference<TweetDetail> ui;
@ -218,21 +217,18 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
txtAns.setText(ansStr); txtAns.setText(ansStr);
if(tweetReplyID > 1) { if(tweetReplyID > 1) {
String reply = "antwort @"+repliedUsername; String reply = connect.getString(R.string.answering);
reply += repliedUsername;
replyName.setText(reply); replyName.setText(reply);
replyName.setVisibility(View.VISIBLE); replyName.setVisibility(View.VISIBLE);
replyName.setOnClickListener(new View.OnClickListener() { replyName.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(ui.get(),TweetDetail.class); Intent intent = new Intent(ui.get(),TweetDetail.class);
Bundle bundle = new Bundle(); intent.putExtra("tweetID", tweetReplyID);
intent.putExtra("userID", replyUserId);
bundle.putLong("tweetID",tweetReplyID); intent.putExtra("username", repliedUsername);
bundle.putLong("userID",replyUserId); connect.startActivity(intent);
bundle.putString("username",repliedUsername);
intent.putExtras(bundle);
ui.get().startActivity(intent);
} }
}); });
} }
@ -258,33 +254,33 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
setIcons(favoriteButton, retweetButton); setIcons(favoriteButton, retweetButton);
} }
else if(mode == RETWEET) { else if(mode == RETWEET) {
String toastMsg;
TextView txtRet = connect.findViewById(R.id.no_rt_detail); TextView txtRet = connect.findViewById(R.id.no_rt_detail);
Button retweetButton = connect.findViewById(R.id.rt_button_detail); Button retweetButton = connect.findViewById(R.id.rt_button_detail);
Button favoriteButton = connect.findViewById(R.id.fav_button_detail); Button favoriteButton = connect.findViewById(R.id.fav_button_detail);
setIcons(favoriteButton, retweetButton); setIcons(favoriteButton, retweetButton);
String rtStr = Integer.toString(rtCount); String rtStr = Integer.toString(rtCount);
txtRet.setText(rtStr); txtRet.setText(rtStr);
int textId;
if(retweeted) { if(retweeted) {
toastMsg = "retweeted"; textId = R.string.retweeted;
} else { } else {
toastMsg = "retweet entfernt!"; textId = R.string.unretweet;
} }
Toast.makeText(ui.get(), toastMsg, Toast.LENGTH_SHORT).show(); Toast.makeText(ui.get(), textId, Toast.LENGTH_SHORT).show();
} }
else if(mode == FAVORITE) { else if(mode == FAVORITE) {
String toastMsg;
Button retweetButton = connect.findViewById(R.id.rt_button_detail); Button retweetButton = connect.findViewById(R.id.rt_button_detail);
Button favoriteButton = connect.findViewById(R.id.fav_button_detail); Button favoriteButton = connect.findViewById(R.id.fav_button_detail);
TextView txtFav = connect.findViewById(R.id.no_fav_detail); TextView txtFav = connect.findViewById(R.id.no_fav_detail);
setIcons(favoriteButton, retweetButton); setIcons(favoriteButton, retweetButton);
String favStr = Integer.toString(favCount); String favStr = Integer.toString(favCount);
txtFav.setText(favStr); txtFav.setText(favStr);
int textId;
if(favorited) if(favorited)
toastMsg = "zu favoriten hinzugefügt!"; textId = R.string.favorited;
else else
toastMsg = "aus favoriten entfernt!"; textId = R.string.unfavorited;
Toast.makeText(ui.get(), toastMsg, Toast.LENGTH_SHORT).show(); Toast.makeText(ui.get(), textId, Toast.LENGTH_SHORT).show();
} }
else if(mode == LOAD_REPLY) { else if(mode == LOAD_REPLY) {
SwipeRefreshLayout ansReload = connect.findViewById(R.id.answer_reload); SwipeRefreshLayout ansReload = connect.findViewById(R.id.answer_reload);
@ -295,7 +291,7 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
txtAns.setText(ansStr); txtAns.setText(ansStr);
} }
else if(mode == DELETE) { else if(mode == DELETE) {
Toast.makeText(ui.get(), "Tweet gelöscht", Toast.LENGTH_LONG).show(); Toast.makeText(ui.get(), R.string.tweet_removed, Toast.LENGTH_SHORT).show();
ui.get().finish(); ui.get().finish();
} }
else if(mode == ERROR) { else if(mode == ERROR) {
@ -314,20 +310,11 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
} }
private String formatString(String input) { private String formatString(String text) {
StringBuilder output = new StringBuilder("gesendet von: "); String prefix = ui.get().getString(R.string.sent_from);
boolean openTag = false; text = text.substring(text.indexOf('>') + 1);
for(int i = 0 ; i < input.length() ; i++){ text = text.substring(0, text.indexOf('<'));
char current = input.charAt(i); return prefix + text;
if(current == '>' && !openTag){
openTag = true;
} else if(current == '<'){
openTag = false;
} else if(openTag) {
output.append(current);
}
}
return output.toString();
} }
@ -377,15 +364,13 @@ public class StatusLoader extends AsyncTask<Long, Void, Long> {
Spanned s = (Spanned) tv.getText(); Spanned s = (Spanned) tv.getText();
String search = s.subSequence(start, end).toString(); String search = s.subSequence(start, end).toString();
Intent intent = new Intent(ui.get(), SearchPage.class); Intent intent = new Intent(ui.get(), SearchPage.class);
Bundle bundle = new Bundle();
if(search.startsWith("#")) if(search.startsWith("#"))
bundle.putString("Addition", search); intent.putExtra("Addition", search);
bundle.putString("search", search); intent.putExtra("search", search);
intent.putExtras(bundle);
ui.get().startActivity(intent); ui.get().startActivity(intent);
} }
@Override @Override
public void updateDrawState(TextPaint ds){ public void updateDrawState(TextPaint ds) {
ds.setColor(highlight); ds.setColor(highlight);
ds.setUnderlineText(false); ds.setUnderlineText(false);
} }

View File

@ -120,7 +120,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:drawablePadding="4dp" android:drawablePadding="4dp"
android:drawableStart="@drawable/following" /> android:drawableStart="@drawable/following"
android:visibility="invisible" />
<TextView <TextView
android:id="@+id/follower" android:id="@+id/follower"
@ -128,7 +129,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:drawablePadding="4dp" android:drawablePadding="4dp"
android:drawableStart="@drawable/follower" /> android:drawableStart="@drawable/follower"
android:visibility="invisible" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
@ -171,7 +173,8 @@
android:drawablePadding="4dp" android:drawablePadding="4dp"
android:drawableStart="@drawable/calendar" android:drawableStart="@drawable/calendar"
android:singleLine="true" android:singleLine="true"
android:textSize="12sp" /> android:textSize="12sp"
android:visibility="invisible" />
</LinearLayout> </LinearLayout>

View File

@ -43,4 +43,18 @@
<string name="tweet_delete">Tweet löschen</string> <string name="tweet_delete">Tweet löschen</string>
<string name="get_tweetlink">Im Browser öffnen</string> <string name="get_tweetlink">Im Browser öffnen</string>
<string name="tweet_not_found">Tweet wurde nicht gefunden</string> <string name="tweet_not_found">Tweet wurde nicht gefunden</string>
<string name="unfollow">entfolgen</string>
<string name="block" translatable="false">blocken</string>
<string name="unblock">entblocken</string>
<string name="followed">gefolgt!</string>
<string name="unfollowed">entfolgt!</string>
<string name="blocked">geblockt!</string>
<string name="unblocked">entblockt!</string>
<string name="favorited">favoriziert!</string>
<string name="unfavorited">favorit entfernt!</string>
<string name="retweeted">retweetet!</string>
<string name="unretweet">retweet entfernt!</string>
<string name="tweet_removed">Tweet gelöscht!</string>
<string name="answering">antwort @</string>
<string name="sent_from">"gesendet von: "</string>
</resources> </resources>

View File

@ -21,7 +21,7 @@
<string name="fullimg">big image</string> <string name="fullimg">big image</string>
<string name="profile_locked">locked</string> <string name="profile_locked">locked</string>
<string name="load_factor">tweet count</string> <string name="load_factor">tweet count</string>
<string name="block" translatable="false">Block</string> <string name="block">Block</string>
<string name="follow">follow</string> <string name="follow">follow</string>
<string name="retry">retry</string> <string name="retry">retry</string>
<string name="cancel">cancel!</string> <string name="cancel">cancel!</string>
@ -51,4 +51,17 @@
<string name="tweet_delete">Delete</string> <string name="tweet_delete">Delete</string>
<string name="get_tweetlink">Open in Browser</string> <string name="get_tweetlink">Open in Browser</string>
<string name="tweet_not_found">Tweet not found</string> <string name="tweet_not_found">Tweet not found</string>
<string name="unfollow">unfollow</string>
<string name="unblock">unblock</string>
<string name="followed">followed</string>
<string name="unfollowed">unfollowed!</string>
<string name="blocked">blocked</string>
<string name="unblocked">unblocked</string>
<string name="favorited">favorited!</string>
<string name="unfavorited">favorite removed!</string>
<string name="retweeted">retweeted!</string>
<string name="unretweet">retweet removed!</string>
<string name="tweet_removed">Tweet removed!</string>
<string name="answering">answering @</string>
<string name="sent_from">sent from:</string>
</resources> </resources>