Improves layout for accounts

This commit is contained in:
tom79 2017-07-31 19:29:14 +02:00
parent 8a1be63a4e
commit 8aac521e0c
36 changed files with 220 additions and 151 deletions

View File

@ -24,6 +24,7 @@ import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.TabLayout; import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
@ -32,9 +33,13 @@ import android.support.v4.content.ContextCompat;
import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.view.PagerAdapter; import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.text.Html; import android.text.Html;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
@ -46,6 +51,7 @@ import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions; import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer; import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
@ -87,14 +93,14 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
private DisplayImageOptions options; private DisplayImageOptions options;
private List<Status> statuses; private List<Status> statuses;
private StatusListAdapter statusListAdapter; private StatusListAdapter statusListAdapter;
private Button account_follow; private FloatingActionButton account_follow;
private static final int NUM_PAGES = 3; private static final int NUM_PAGES = 3;
private ViewPager mPager; private ViewPager mPager;
private String accountId; private String accountId;
private TabLayout tabLayout; private TabLayout tabLayout;
private BroadcastReceiver hide_header; private BroadcastReceiver hide_header;
private TextView account_note; private TextView account_note, account_follow_request;
private String userId; private String userId;
private boolean isHiddingShowing = false; private boolean isHiddingShowing = false;
private static int instanceValue = 0; private static int instanceValue = 0;
@ -118,10 +124,12 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
}else { }else {
setTheme(R.style.AppThemeDark); setTheme(R.style.AppThemeDark);
} }
setTitle("");
setContentView(R.layout.activity_show_account); setContentView(R.layout.activity_show_account);
instanceValue += 1; instanceValue += 1;
Bundle b = getIntent().getExtras(); Bundle b = getIntent().getExtras();
account_follow = (Button) findViewById(R.id.account_follow); account_follow = (FloatingActionButton) findViewById(R.id.account_follow);
account_follow_request = (TextView) findViewById(R.id.account_follow_request);
account_follow.setEnabled(false); account_follow.setEnabled(false);
if(b != null){ if(b != null){
accountId = b.getString("accountId"); accountId = b.getString("accountId");
@ -148,7 +156,7 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
boolean isOnWifi = Helper.isOnWIFI(getApplicationContext()); boolean isOnWifi = Helper.isOnWIFI(getApplicationContext());
int behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS); int behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
statusListAdapter = new StatusListAdapter(getApplicationContext(), RetrieveFeedsAsyncTask.Type.USER, accountId, isOnWifi, behaviorWithAttachments, this.statuses); statusListAdapter = new StatusListAdapter(getApplicationContext(), RetrieveFeedsAsyncTask.Type.USER, accountId, isOnWifi, behaviorWithAttachments, this.statuses);
options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false) options = new DisplayImageOptions.Builder().displayer(new RoundedBitmapDisplayer(80)).cacheInMemory(false)
.cacheOnDisk(true).resetViewBeforeLoading(true).build(); .cacheOnDisk(true).resetViewBeforeLoading(true).build();
@ -210,13 +218,11 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
if( !isHiddingShowing ){ if( !isHiddingShowing ){
isHiddingShowing = true; isHiddingShowing = true;
ImageView account_pp = (ImageView) findViewById(R.id.account_pp); ImageView account_pp = (ImageView) findViewById(R.id.account_pp);
TextView account_ac = (TextView) findViewById(R.id.account_ac);
boolean hide = intent.getBooleanExtra("hide", false); boolean hide = intent.getBooleanExtra("hide", false);
if( hide){ if( hide){
account_follow.setVisibility(View.GONE); account_follow.setVisibility(View.GONE);
account_note.setVisibility(View.GONE); account_note.setVisibility(View.GONE);
tabLayout.setVisibility(View.GONE); tabLayout.setVisibility(View.GONE);
account_ac.setVisibility(View.GONE);
account_pp.getLayoutParams().width = (int) Helper.convertDpToPixel(50, context); account_pp.getLayoutParams().width = (int) Helper.convertDpToPixel(50, context);
account_pp.getLayoutParams().height = (int) Helper.convertDpToPixel(50, context); account_pp.getLayoutParams().height = (int) Helper.convertDpToPixel(50, context);
}else { }else {
@ -224,7 +230,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
if( accountId != null && accountId.equals(userId)){ if( accountId != null && accountId.equals(userId)){
account_follow.setVisibility(View.GONE); account_follow.setVisibility(View.GONE);
} }
account_ac.setVisibility(View.VISIBLE);
account_pp.getLayoutParams().width = (int) Helper.convertDpToPixel(80, context); account_pp.getLayoutParams().width = (int) Helper.convertDpToPixel(80, context);
account_pp.getLayoutParams().height = (int) Helper.convertDpToPixel(80, context); account_pp.getLayoutParams().height = (int) Helper.convertDpToPixel(80, context);
tabLayout.setVisibility(View.VISIBLE); tabLayout.setVisibility(View.VISIBLE);
@ -301,17 +306,26 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
ImageView account_pp = (ImageView) findViewById(R.id.account_pp); ImageView account_pp = (ImageView) findViewById(R.id.account_pp);
TextView account_dn = (TextView) findViewById(R.id.account_dn); TextView account_dn = (TextView) findViewById(R.id.account_dn);
TextView account_un = (TextView) findViewById(R.id.account_un); TextView account_un = (TextView) findViewById(R.id.account_un);
TextView account_ac = (TextView) findViewById(R.id.account_ac);
ActionBar actionBar = getSupportActionBar();
LayoutInflater mInflater = LayoutInflater.from(ShowAccountActivity.this);
if( actionBar != null){
View show_account_actionbar = mInflater.inflate(R.layout.showaccount_actionbar, null);
TextView actionbar_title = (TextView) show_account_actionbar.findViewById(R.id.show_account_title);
if( account != null && account.getAcct() != null)
actionbar_title.setText(account.getAcct());
actionBar.setCustomView(show_account_actionbar);
actionBar.setDisplayShowCustomEnabled(true);
}else {
if( account != null && account.getAcct() != null)
setTitle(account.getAcct());
}
if( account != null){ if( account != null){
setTitle(account.getAcct());
account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true)); account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
account_un.setText(String.format("@%s", account.getUsername())); account_un.setText(String.format("@%s", account.getUsername()));
if( account.getAcct() != null && account.getAcct().equals(account.getUsername())) SpannableString spannableString = Helper.clickableElementsDescription(ShowAccountActivity.this, account.getNote());
account_ac.setVisibility(View.GONE); account_note.setText(spannableString, TextView.BufferType.SPANNABLE);
else account_note.setMovementMethod(LinkMovementMethod.getInstance());
account_ac.setText(account.getAcct());
account_note = Helper.clickableElementsDescription(ShowAccountActivity.this, account_note,account.getNote());
tabLayout.getTabAt(0).setText(getString(R.string.status_cnt, account.getStatuses_count())); tabLayout.getTabAt(0).setText(getString(R.string.status_cnt, account.getStatuses_count()));
tabLayout.getTabAt(1).setText(getString(R.string.following_cnt, account.getFollowing_count())); tabLayout.getTabAt(1).setText(getString(R.string.following_cnt, account.getFollowing_count()));
tabLayout.getTabAt(2).setText(getString(R.string.followers_cnt, account.getFollowers_count())); tabLayout.getTabAt(2).setText(getString(R.string.followers_cnt, account.getFollowers_count()));
@ -347,21 +361,20 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
} }
account_follow.setEnabled(true); account_follow.setEnabled(true);
if( relationship.isBlocking()){ if( relationship.isBlocking()){
account_follow.setText(R.string.action_unblock); account_follow.setImageResource(R.drawable.ic_unlock_alt);
doAction = action.UNBLOCK; doAction = action.UNBLOCK;
}else if( relationship.isRequested()){ }else if( relationship.isRequested()){
account_follow.setText(R.string.request_sent); account_follow_request.setVisibility(View.VISIBLE);
account_follow.getBackground().setColorFilter(ContextCompat.getColor(this, R.color.colorPrimary), PorterDuff.Mode.MULTIPLY); account_follow.setVisibility(View.GONE);
doAction = action.NOTHING; doAction = action.NOTHING;
}else if( relationship.isFollowing()){ }else if( relationship.isFollowing()){
account_follow.setText(R.string.action_unfollow); account_follow.setImageResource(R.drawable.ic_user_times);
doAction = action.UNFOLLOW; doAction = action.UNFOLLOW;
}else if( !relationship.isFollowing()){ }else if( !relationship.isFollowing()){
account_follow.setText(R.string.action_follow); account_follow.setImageResource(R.drawable.ic_user_plus);
doAction = action.FOLLOW; doAction = action.FOLLOW;
}else{ }else{
account_follow.setText(R.string.action_no_action); account_follow.setVisibility(View.GONE);
account_follow.getBackground().setColorFilter(ContextCompat.getColor(this, R.color.red_1), PorterDuff.Mode.MULTIPLY);
doAction = action.NOTHING; doAction = action.NOTHING;
} }

View File

@ -109,7 +109,8 @@ public class AccountsListAdapter extends BaseAdapter implements OnPostActionInte
.denyCacheImageMultipleSizesInMemory() .denyCacheImageMultipleSizesInMemory()
.diskCache(new UnlimitedDiskCache(cacheDir)) .diskCache(new UnlimitedDiskCache(cacheDir))
.build(); .build();
imageLoader.init(configImg); if( !imageLoader.isInited())
imageLoader.init(configImg);
DisplayImageOptions options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false) DisplayImageOptions options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
.cacheOnDisk(true).resetViewBeforeLoading(true).build(); .cacheOnDisk(true).resetViewBeforeLoading(true).build();
final Account account = accounts.get(position); final Account account = accounts.get(position);

View File

@ -119,7 +119,6 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
holder.notification_status_content = (TextView) convertView.findViewById(R.id.notification_status_content); holder.notification_status_content = (TextView) convertView.findViewById(R.id.notification_status_content);
holder.notification_account_username = (TextView) convertView.findViewById(R.id.notification_account_username); holder.notification_account_username = (TextView) convertView.findViewById(R.id.notification_account_username);
holder.notification_type = (TextView) convertView.findViewById(R.id.notification_type); holder.notification_type = (TextView) convertView.findViewById(R.id.notification_type);
holder.notification_account_displayname = (TextView) convertView.findViewById(R.id.notification_account_displayname);
holder.notification_account_profile = (ImageView) convertView.findViewById(R.id.notification_account_profile); holder.notification_account_profile = (ImageView) convertView.findViewById(R.id.notification_account_profile);
holder.status_favorite_count = (TextView) convertView.findViewById(R.id.status_favorite_count); holder.status_favorite_count = (TextView) convertView.findViewById(R.id.status_favorite_count);
holder.status_reblog_count = (TextView) convertView.findViewById(R.id.status_reblog_count); holder.status_reblog_count = (TextView) convertView.findViewById(R.id.status_reblog_count);
@ -136,16 +135,28 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
String typeString = ""; String typeString = "";
switch (type){ switch (type){
case "mention": case "mention":
typeString = String.format("@%s %s", notification.getAccount().getAcct(),context.getString(R.string.notif_mention)); if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0)
typeString = String.format("%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),context.getString(R.string.notif_mention));
else
typeString = String.format("@%s %s", notification.getAccount().getAcct(),context.getString(R.string.notif_mention));
break; break;
case "reblog": case "reblog":
typeString = String.format("@%s %s", notification.getAccount().getAcct(),context.getString(R.string.notif_reblog)); if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0)
typeString = String.format("%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),context.getString(R.string.notif_reblog));
else
typeString = String.format("@%s %s", notification.getAccount().getAcct(),context.getString(R.string.notif_reblog));
break; break;
case "favourite": case "favourite":
typeString = String.format("@%s %s", notification.getAccount().getAcct(),context.getString(R.string.notif_favourite)); if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0)
typeString = String.format("%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),context.getString(R.string.notif_favourite));
else
typeString = String.format("@%s %s", notification.getAccount().getAcct(),context.getString(R.string.notif_favourite));
break; break;
case "follow": case "follow":
typeString = String.format("@%s %s", notification.getAccount().getAcct(),context.getString(R.string.notif_follow)); if( notification.getAccount().getDisplay_name() != null && notification.getAccount().getDisplay_name().length() > 0)
typeString = String.format("%s %s", Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true),context.getString(R.string.notif_follow));
else
typeString = String.format("@%s %s", notification.getAccount().getAcct(),context.getString(R.string.notif_follow));
break; break;
} }
holder.notification_type.setText(typeString); holder.notification_type.setText(typeString);
@ -191,13 +202,13 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
if( (status.getIn_reply_to_account_id() != null && !status.getIn_reply_to_account_id().equals("null")) || (status.getIn_reply_to_id() != null && !status.getIn_reply_to_id().equals("null")) ){ if( (status.getIn_reply_to_account_id() != null && !status.getIn_reply_to_account_id().equals("null")) || (status.getIn_reply_to_id() != null && !status.getIn_reply_to_id().equals("null")) ){
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_reply); Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_reply);
img.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (15 * scale + 0.5f)); img.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (15 * scale + 0.5f));
holder.notification_account_displayname.setCompoundDrawables( img, null, null, null); holder.notification_account_username.setCompoundDrawables( img, null, null, null);
}else if( status.isReblogged()){ }else if( status.isReblogged()){
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_retweet); Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_retweet);
img.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (15 * scale + 0.5f)); img.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (15 * scale + 0.5f));
holder.notification_account_displayname.setCompoundDrawables( img, null, null, null); holder.notification_account_username.setCompoundDrawables( img, null, null, null);
}else{ }else{
holder.notification_account_displayname.setCompoundDrawables( null, null, null, null); holder.notification_account_username.setCompoundDrawables( null, null, null, null);
} }
SpannableString spannableString = Helper.clickableElements(context, status.getContent(), SpannableString spannableString = Helper.clickableElements(context, status.getContent(),
@ -329,7 +340,6 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
displayConfirmationNotificationDialog(notification); displayConfirmationNotificationDialog(notification);
} }
}); });
holder.notification_account_displayname.setText(Helper.shortnameToUnicode(notification.getAccount().getDisplay_name(), true));
holder.notification_account_username.setText( String.format("@%s",notification.getAccount().getUsername())); holder.notification_account_username.setText( String.format("@%s",notification.getAccount().getUsername()));
//Profile picture //Profile picture
imageLoader.displayImage(notification.getAccount().getAvatar(), holder.notification_account_profile, options); imageLoader.displayImage(notification.getAccount().getAvatar(), holder.notification_account_profile, options);
@ -487,7 +497,6 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
TextView notification_status_content; TextView notification_status_content;
TextView notification_type; TextView notification_type;
TextView notification_account_username; TextView notification_account_username;
TextView notification_account_displayname;
ImageView notification_account_profile; ImageView notification_account_profile;
ImageView notification_delete; ImageView notification_delete;
TextView status_favorite_count; TextView status_favorite_count;

View File

@ -123,7 +123,8 @@ public class SearchListAdapter extends BaseAdapter {
.denyCacheImageMultipleSizesInMemory() .denyCacheImageMultipleSizesInMemory()
.diskCache(new UnlimitedDiskCache(cacheDir)) .diskCache(new UnlimitedDiskCache(cacheDir))
.build(); .build();
imageLoader.init(configImg); if( !imageLoader.isInited())
imageLoader.init(configImg);
DisplayImageOptions options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false) DisplayImageOptions options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
.cacheOnDisk(true).resetViewBeforeLoading(true).build(); .cacheOnDisk(true).resetViewBeforeLoading(true).build();
int type = getItemViewType(position); int type = getItemViewType(position);

View File

@ -142,7 +142,8 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
.denyCacheImageMultipleSizesInMemory() .denyCacheImageMultipleSizesInMemory()
.diskCache(new UnlimitedDiskCache(cacheDir)) .diskCache(new UnlimitedDiskCache(cacheDir))
.build(); .build();
imageLoader.init(configImg); if( !imageLoader.isInited())
imageLoader.init(configImg);
options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false) options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
.cacheOnDisk(true).resetViewBeforeLoading(true).build(); .cacheOnDisk(true).resetViewBeforeLoading(true).build();

View File

@ -118,7 +118,11 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
@Override @Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (view.getId() == lv_accounts.getId() && totalItemCount > visibleItemCount) { if(firstVisibleItem == 0 && Helper.listIsAtTop(lv_accounts)){
Intent intent = new Intent(Helper.HEADER_ACCOUNT+instanceValue);
intent.putExtra("hide", false);
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
}else if (view.getId() == lv_accounts.getId() && totalItemCount > visibleItemCount) {
final int currentFirstVisibleItem = lv_accounts.getFirstVisiblePosition(); final int currentFirstVisibleItem = lv_accounts.getFirstVisiblePosition();
if (currentFirstVisibleItem > lastFirstVisibleItem) { if (currentFirstVisibleItem > lastFirstVisibleItem) {

View File

@ -128,9 +128,13 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
@Override @Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (view.getId() == lv_status.getId() && totalItemCount > visibleItemCount) {
final int currentFirstVisibleItem = lv_status.getFirstVisiblePosition();
if(firstVisibleItem == 0 && Helper.listIsAtTop(lv_status)){
Intent intent = new Intent(Helper.HEADER_ACCOUNT+instanceValue);
intent.putExtra("hide", false);
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
}else if (view.getId() == lv_status.getId() && totalItemCount > visibleItemCount) {
final int currentFirstVisibleItem = lv_status.getFirstVisiblePosition();
if (currentFirstVisibleItem > lastFirstVisibleItem) { if (currentFirstVisibleItem > lastFirstVisibleItem) {
Intent intent = new Intent(Helper.HEADER_ACCOUNT+instanceValue); Intent intent = new Intent(Helper.HEADER_ACCOUNT+instanceValue);
intent.putExtra("hide", true); intent.putExtra("hide", true);
@ -231,7 +235,6 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
} }
@Override @Override
public void onCreate(Bundle saveInstance) public void onCreate(Bundle saveInstance)
{ {

View File

@ -56,6 +56,7 @@ import android.text.method.ArrowKeyMovementMethod;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan; import android.text.style.ClickableSpan;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Patterns;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.SubMenu; import android.view.SubMenu;
@ -67,6 +68,7 @@ import android.webkit.URLUtil;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -226,7 +228,7 @@ public class Helper {
private static final Pattern SHORTNAME_PATTERN = Pattern.compile(":([-+\\w]+):"); private static final Pattern SHORTNAME_PATTERN = Pattern.compile(":([-+\\w]+):");
private static final Pattern urlPattern = Pattern.compile( private static final Pattern urlPattern = Pattern.compile(
"(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))", "(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,10}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))",
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
private static final Pattern hashtagPattern = Pattern.compile("(#[\\w_À-ú-]{1,})"); private static final Pattern hashtagPattern = Pattern.compile("(#[\\w_À-ú-]{1,})");
@ -1023,7 +1025,7 @@ public class Helper {
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean embedded_browser = sharedpreferences.getBoolean(Helper.SET_EMBEDDED_BROWSER, true); boolean embedded_browser = sharedpreferences.getBoolean(Helper.SET_EMBEDDED_BROWSER, true);
if( embedded_browser){ if( embedded_browser){
Matcher matcher = urlPattern.matcher(spannableString); Matcher matcher = Patterns.WEB_URL.matcher(spannableString);
while (matcher.find()){ while (matcher.find()){
int matchStart = matcher.start(1); int matchStart = matcher.start(1);
int matchEnd = matcher.end(); int matchEnd = matcher.end();
@ -1033,7 +1035,10 @@ public class Helper {
public void onClick(View textView) { public void onClick(View textView) {
Intent intent = new Intent(context, WebviewActivity.class); Intent intent = new Intent(context, WebviewActivity.class);
Bundle b = new Bundle(); Bundle b = new Bundle();
b.putString("url", url); String finalUrl = url;
if( !url.startsWith("http://") && ! url.startsWith("https://"))
finalUrl = "http://" + url;
b.putString("url", finalUrl);
intent.putExtras(b); intent.putExtras(b);
context.startActivity(intent); context.startActivity(intent);
} }
@ -1098,14 +1103,6 @@ public class Helper {
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); }, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
} }
return spannableString; return spannableString;
/*
statusTV.setText(spannableString, TextView.BufferType.SPANNABLE);
statusTV.setMovementMethod(null);
statusTV.setMovementMethod(LinkMovementMethod.getInstance());
statusTV.setMovementMethod(ArrowKeyMovementMethod.getInstance());
statusTV.setFocusable(true);
statusTV.setFocusableInTouchMode(true);
return statusTV;*/
} }
@ -1115,11 +1112,10 @@ public class Helper {
* Click on url => webview or external app * Click on url => webview or external app
* Click on tag => HashTagActivity * Click on tag => HashTagActivity
* @param context Context * @param context Context
* @param statusTV Textview
* @param fullContent String, should be the st * @param fullContent String, should be the st
* @return TextView * @return TextView
*/ */
public static TextView clickableElementsDescription(final Context context, TextView statusTV, String fullContent) { public static SpannableString clickableElementsDescription(final Context context, String fullContent) {
SpannableString spannableString; SpannableString spannableString;
fullContent = Helper.shortnameToUnicode(fullContent, true); fullContent = Helper.shortnameToUnicode(fullContent, true);
@ -1131,7 +1127,7 @@ public class Helper {
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean embedded_browser = sharedpreferences.getBoolean(Helper.SET_EMBEDDED_BROWSER, true); boolean embedded_browser = sharedpreferences.getBoolean(Helper.SET_EMBEDDED_BROWSER, true);
if( embedded_browser){ if( embedded_browser){
Matcher matcher = urlPattern.matcher(spannableString); Matcher matcher = Patterns.WEB_URL.matcher(spannableString);
while (matcher.find()){ while (matcher.find()){
int matchStart = matcher.start(1); int matchStart = matcher.start(1);
int matchEnd = matcher.end(); int matchEnd = matcher.end();
@ -1172,11 +1168,7 @@ public class Helper {
} }
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); }, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
} }
return spannableString;
statusTV.setText(spannableString, TextView.BufferType.SPANNABLE);
statusTV.setMovementMethod(null);
statusTV.setMovementMethod(LinkMovementMethod.getInstance());
return statusTV;
} }
@ -1398,4 +1390,13 @@ public class Helper {
} }
} }
} }
/**
* Returns true if a ListView is at its top position
* @param listView ListView
* @return boolean
*/
public static boolean listIsAtTop(ListView listView) {
return listView.getChildCount() == 0 || listView.getChildAt(0).getTop() == 0;
}
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 855 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 939 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -17,96 +17,108 @@
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout" android:id="@+id/drawer_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:animateLayoutChanges="true" android:animateLayoutChanges="true"
android:orientation="vertical" android:orientation="vertical">
>
<LinearLayout <LinearLayout
android:layout_marginTop="5dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:gravity="center"
android:orientation="horizontal"
android:layout_height="wrap_content" android:layout_height="wrap_content"
> android:orientation="vertical">
<ImageView
android:padding="10dp"
android:id="@+id/account_pp"
android:layout_width="80dp"
android:layout_height="80dp"
tools:ignore="ContentDescription" />
<LinearLayout <LinearLayout
android:layout_width="0dp" android:id="@+id/header_container"
android:layout_weight="1" android:layout_marginTop="5dp"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:gravity="center"
android:orientation="horizontal"
android:layout_height="wrap_content"
>
<ImageView
android:padding="10dp"
android:id="@+id/account_pp"
android:layout_width="80dp"
android:layout_height="80dp"
tools:ignore="ContentDescription" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_weight="1"
android:gravity="center" android:orientation="vertical"
android:layout_marginTop="10dp" android:layout_height="wrap_content">
android:orientation="horizontal"> <LinearLayout
<TextView android:layout_width="match_parent"
android:id="@+id/account_dn"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:maxLines="1" android:gravity="center"
android:textSize="18sp" android:layout_marginTop="5dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> android:orientation="horizontal">
<TextView
android:id="@+id/account_dn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textSize="16sp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
<TextView
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:id="@+id/account_un"
android:maxLines="1"
android:layout_width="0dp"
android:layout_weight="1"
android:textSize="14sp"
android:layout_height="wrap_content"
/>
<android.support.design.widget.FloatingActionButton
android:layout_gravity="top|end"
app:fabSize="mini"
android:id="@+id/account_follow"
android:textAllCaps="false"
android:gravity="center"
android:layout_marginRight="5dp"
android:layout_marginEnd="5dp"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="5dp"
/>
</LinearLayout>
<TextView <TextView
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:id="@+id/account_un" android:layout_marginLeft="10dp"
android:visibility="gone"
android:id="@+id/account_followed_by"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:textColor="?attr/colorAccent"
android:text="@string/followed_by"
android:maxLines="1" android:maxLines="1"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:textSize="14sp" android:layout_height="wrap_content" />
<TextView
android:id="@+id/account_follow_request"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:visibility="gone"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:textColor="?attr/colorAccent"
android:text="@string/request_sent"
android:maxLines="1"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
/> />
</LinearLayout> </LinearLayout>
<TextView
android:visibility="gone"
android:id="@+id/account_followed_by"
android:layout_gravity="center"
android:gravity="center"
android:textColor="?attr/colorAccent"
android:text="@string/followed_by"
android:maxLines="1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_marginTop="5dp"
android:id="@+id/account_ac"
android:gravity="center"
android:maxLines="1"
android:textSize="16sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:layout_marginTop="10dp"
android:id="@+id/account_follow"
android:textAllCaps="false"
android:gravity="center"
android:layout_gravity="end"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:maxLines="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_marginBottom="10dp"
style="@style/Base.Widget.AppCompat.Button.Colored"
android:text="@string/action_follow" />
</LinearLayout> </LinearLayout>
<TextView
android:id="@+id/account_note"
android:padding="10dp"
android:gravity="center"
android:layout_width="match_parent"
android:maxLines="4"
android:autoLink="web"
android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
<TextView
android:id="@+id/account_note"
android:padding="5dp"
android:gravity="center"
android:layout_width="match_parent"
android:maxLines="3"
android:autoLink="web"
android:layout_height="wrap_content" />
<android.support.design.widget.AppBarLayout <android.support.design.widget.AppBarLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"

View File

@ -64,29 +64,19 @@
<TextView <TextView
android:padding="5dp" android:padding="5dp"
android:id="@+id/notification_type" android:id="@+id/notification_type"
android:textStyle="bold" android:textSize="14sp"
android:textSize="16sp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<LinearLayout <TextView
android:orientation="horizontal" android:layout_marginLeft="5dp"
android:layout_width="match_parent" android:layout_marginStart="5dp"
android:layout_height="wrap_content"> android:id="@+id/notification_account_username"
<TextView android:layout_width="wrap_content"
android:id="@+id/notification_account_displayname" android:layout_height="wrap_content" />
android:drawablePadding="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:id="@+id/notification_account_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView <TextView
android:id="@+id/status_date" android:id="@+id/status_date"
android:layout_width="match_parent" android:layout_width="match_parent"
android:textSize="12sp"
android:paddingRight="10dp" android:paddingRight="10dp"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:layout_gravity="end" android:layout_gravity="end"

View File

@ -101,7 +101,7 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<TextView <TextView
android:id="@+id/status_account_displayname" android:id="@+id/status_account_displayname"
android:textSize="16sp" android:textSize="14sp"
android:textStyle="bold" android:textStyle="bold"
android:maxLines="1" android:maxLines="1"
android:drawablePadding="2dp" android:drawablePadding="2dp"
@ -110,8 +110,7 @@
<TextView <TextView
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:layout_marginStart="5dp" android:layout_marginStart="5dp"
android:textSize="14sp" android:textSize="12sp"
android:textStyle="bold"
android:maxLines="1" android:maxLines="1"
android:id="@+id/status_account_username" android:id="@+id/status_account_username"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -130,6 +129,7 @@
android:id="@+id/status_toot_date" android:id="@+id/status_toot_date"
android:layout_width="match_parent" android:layout_width="match_parent"
android:paddingRight="10dp" android:paddingRight="10dp"
android:textSize="12sp"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:layout_gravity="end" android:layout_gravity="end"
android:gravity="end" android:gravity="end"

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2017 Thomas Schneider
This file is a part of Mastalab
This program is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version.
Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along with Thomas Schneider; if not,
see <http://www.gnu.org/licenses>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<TextView
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_gravity="center_vertical"
android:id="@+id/show_account_title"
android:maxLines="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
/>
</LinearLayout>