From 165c308f585fa11b715eb01722d40413bd36fd21 Mon Sep 17 00:00:00 2001 From: stom79 Date: Wed, 26 Sep 2018 14:53:41 +0200 Subject: [PATCH] Fix some layout issues --- .../mastodon/activities/BaseMainActivity.java | 52 +++++++++---------- .../activities/EditProfileActivity.java | 3 +- .../mastodon/activities/InstanceActivity.java | 2 +- .../mastodon/activities/MediaActivity.java | 12 ++--- .../activities/RemoteFollowActivity.java | 12 ++--- .../drawers/AccountSearchDevAdapter.java | 6 +-- .../mastodon/drawers/AccountsListAdapter.java | 14 ++--- .../mastodon/drawers/StatusListAdapter.java | 2 +- .../main/res/layout/activity_federated.xml | 5 +- app/src/main/res/layout/activity_main.xml | 4 +- app/src/main/res/layout/activity_media.xml | 8 +-- .../main/res/layout/activity_show_account.xml | 8 +-- app/src/main/res/layout/drawer_account.xml | 8 +-- .../res/layout/drawer_account_search_html.xml | 4 +- app/src/main/res/layout/drawer_filters.xml | 8 +-- app/src/main/res/layout/drawer_status.xml | 31 ++++++----- .../main/res/layout/drawer_status_compact.xml | 32 +++++++----- .../main/res/layout/drawer_status_focused.xml | 31 ++++++----- .../layout/drawer_who_to_follow_account.xml | 4 +- .../main/res/layout/user_search_result.xml | 8 +-- 20 files changed, 136 insertions(+), 118 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java index 86fd9315f..b9ff9768e 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java @@ -265,7 +265,7 @@ public abstract class BaseMainActivity extends BaseActivity boolean displayFollowInstance = sharedpreferences.getBoolean(Helper.SET_DISPLAY_FOLLOW_INSTANCE, true); if( !displayFollowInstance) - federatedTimelines.setVisibility(View.GONE); + federatedTimelines.hide(); federatedTimelines.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -427,9 +427,9 @@ public abstract class BaseMainActivity extends BaseActivity viewPager.setVisibility(View.VISIBLE); Helper.switchLayout(BaseMainActivity.this); if( tab.getPosition() != 1 ) - toot.setVisibility(View.VISIBLE); + toot.show(); else - toot.setVisibility(View.GONE); + toot.hide(); DrawerLayout drawer = findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); if( tab.getCustomView() != null) { @@ -462,9 +462,9 @@ public abstract class BaseMainActivity extends BaseActivity drawer.closeDrawer(GravityCompat.START); } if( tab.getPosition() != 1 ) - toot.setVisibility(View.VISIBLE); + toot.show(); else - toot.setVisibility(View.GONE); + toot.hide(); if( viewPager.getAdapter() != null) { Fragment fragment = (Fragment) viewPager.getAdapter().instantiateItem(viewPager, tab.getPosition()); switch (tab.getPosition()) { @@ -1318,14 +1318,14 @@ public abstract class BaseMainActivity extends BaseActivity viewPager.setVisibility(View.VISIBLE); tabLayout.setVisibility(View.VISIBLE); toolbarTitle.setVisibility(View.GONE); - delete_all.setVisibility(View.GONE); - add_new.setVisibility(View.GONE); + delete_all.hide(); + add_new.hide(); final NavigationView navigationView = findViewById(R.id.nav_view); unCheckAllMenuItems(navigationView); - toot.setVisibility(View.VISIBLE); + toot.show(); switch (viewPager.getCurrentItem()){ case 1: - toot.setVisibility(View.GONE); + toot.hide(); break; } } @@ -1455,24 +1455,24 @@ public abstract class BaseMainActivity extends BaseActivity toolbarTitle.setVisibility(View.VISIBLE); appBar.setExpanded(true); if (id != R.id.nav_drafts && id != R.id.nav_bookmarks ) { - delete_all.setVisibility(View.GONE); + delete_all.hide(); }else{ - delete_all.setVisibility(View.VISIBLE); + delete_all.show(); } if( id != R.id.nav_list && id != R.id.nav_filters){ - add_new.setVisibility(View.GONE); + add_new.hide(); }else{ - add_new.setVisibility(View.VISIBLE); + add_new.show(); } if (id == R.id.nav_settings) { - toot.setVisibility(View.GONE); + toot.hide(); TabLayoutSettingsFragment tabLayoutSettingsFragment= new TabLayoutSettingsFragment(); fragmentTag = "TABLAYOUT_SETTINGS"; fragmentManager.beginTransaction() .replace(R.id.main_app_container, tabLayoutSettingsFragment, fragmentTag).commit(); }else if (id == R.id.nav_favorites) { - toot.setVisibility(View.GONE); + toot.hide(); statusFragment = new DisplayStatusFragment(); bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.FAVOURITES); statusFragment.setArguments(bundle); @@ -1480,7 +1480,7 @@ public abstract class BaseMainActivity extends BaseActivity fragmentManager.beginTransaction() .replace(R.id.main_app_container, statusFragment, fragmentTag).commit(); } else if (id == R.id.nav_blocked) { - toot.setVisibility(View.GONE); + toot.hide(); accountsFragment = new DisplayAccountsFragment(); bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.BLOCKED); accountsFragment.setArguments(bundle); @@ -1488,7 +1488,7 @@ public abstract class BaseMainActivity extends BaseActivity fragmentManager.beginTransaction() .replace(R.id.main_app_container, accountsFragment, fragmentTag).commit(); }else if (id == R.id.nav_muted) { - toot.setVisibility(View.GONE); + toot.hide(); accountsFragment = new DisplayAccountsFragment(); bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.MUTED); accountsFragment.setArguments(bundle); @@ -1496,7 +1496,7 @@ public abstract class BaseMainActivity extends BaseActivity fragmentManager.beginTransaction() .replace(R.id.main_app_container, accountsFragment, fragmentTag).commit(); }else if (id == R.id.nav_scheduled) { - toot.setVisibility(View.VISIBLE); + toot.show(); DisplayScheduledTootsFragment displayScheduledTootsFragment = new DisplayScheduledTootsFragment(); fragmentTag = "SCHEDULED"; fragmentManager.beginTransaction() @@ -1506,33 +1506,33 @@ public abstract class BaseMainActivity extends BaseActivity fragmentTag = "DRAFTS"; fragmentManager.beginTransaction() .replace(R.id.main_app_container, displayDraftsFragment, fragmentTag).commit(); - toot.setVisibility(View.GONE); + toot.hide(); }else if (id == R.id.nav_bookmarks) { DisplayBookmarksFragment displayBookmarksFragment = new DisplayBookmarksFragment(); fragmentTag = "BOOKMARKS"; fragmentManager.beginTransaction() .replace(R.id.main_app_container, displayBookmarksFragment, fragmentTag).commit(); - toot.setVisibility(View.GONE); + toot.hide(); }else if( id == R.id.nav_follow_request){ - toot.setVisibility(View.GONE); + toot.hide(); DisplayFollowRequestSentFragment followRequestSentFragment = new DisplayFollowRequestSentFragment(); fragmentTag = "FOLLOW_REQUEST_SENT"; fragmentManager.beginTransaction() .replace(R.id.main_app_container, followRequestSentFragment, fragmentTag).commit(); }else if(id == R.id.nav_list){ - toot.setVisibility(View.GONE); + toot.hide(); DisplayListsFragment displayListsFragment = new DisplayListsFragment(); fragmentTag = "LISTS"; fragmentManager.beginTransaction() .replace(R.id.main_app_container, displayListsFragment, fragmentTag).commit(); }else if(id == R.id.nav_filters){ - toot.setVisibility(View.GONE); + toot.hide(); DisplayFiltersFragment displayFiltersFragment = new DisplayFiltersFragment(); fragmentTag = "FILTERS"; fragmentManager.beginTransaction() .replace(R.id.main_app_container, displayFiltersFragment, fragmentTag).commit(); }else if(id == R.id.nav_who_to_follow){ - toot.setVisibility(View.GONE); + toot.hide(); WhoToFollowFragment whoToFollowFragment = new WhoToFollowFragment(); fragmentTag = "WHO_TO_FOLLOW"; fragmentManager.beginTransaction() @@ -1927,9 +1927,9 @@ public abstract class BaseMainActivity extends BaseActivity FloatingActionButton federatedTimelines = findViewById(R.id.federated_timeline); boolean displayFollowInstance = sharedpreferences.getBoolean(Helper.SET_DISPLAY_FOLLOW_INSTANCE, true); if( !displayFollowInstance) - federatedTimelines.setVisibility(View.GONE); + federatedTimelines.hide(); else - federatedTimelines.setVisibility(View.VISIBLE); + federatedTimelines.show(); } public DisplayStatusFragment getHomeFragment(){ return homeFragment; diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/EditProfileActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/EditProfileActivity.java index 98d2378fe..83d516183 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/EditProfileActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/EditProfileActivity.java @@ -108,7 +108,6 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou private final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE_HEADER = 754; private final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE_PICTURE = 755; private String avatarName, headerName; - private HashMap fields; @Override protected void onCreate(Bundle savedInstanceState) { @@ -267,7 +266,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou } }); if ( account.getFields() != null && account.getFields().size() > 0){ - fields = account.getFields(); + HashMap fields = account.getFields(); Iterator it = fields.entrySet().iterator(); int i = 1; while (it.hasNext()) { diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/InstanceActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/InstanceActivity.java index edf8b8325..14758883a 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/InstanceActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/InstanceActivity.java @@ -122,7 +122,7 @@ public class InstanceActivity extends BaseActivity implements OnRetrieveInstance instance_version.setText(instance.getVersion()); instance_uri.setText(instance.getUri()); if( instance.getEmail() == null){ - instance_contact.setVisibility(View.GONE); + instance_contact.hide(); } instance_contact.setOnClickListener(new View.OnClickListener() { diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java index a113a2e1c..52811f29c 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java @@ -181,8 +181,8 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface { @Override public void run() { // DO DELAYED STUFF - media_close.setVisibility(View.GONE); - media_save.setVisibility(View.GONE); + media_close.hide(); + media_save.hide(); media_description.setVisibility(View.GONE); scheduleHidden = false; } @@ -243,8 +243,8 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface { if( event.getAction() == MotionEvent.ACTION_DOWN && !scheduleHidden){ scheduleHidden = true; - media_close.setVisibility(View.VISIBLE); - media_save.setVisibility(View.VISIBLE); + media_close.show(); + media_save.show(); if( attachment != null && attachment.getDescription() != null && !attachment.getDescription().equals("null")){ media_description.setText(attachment.getDescription()); media_description.setVisibility(View.VISIBLE); @@ -256,8 +256,8 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface { handler.postDelayed(new Runnable() { @Override public void run() { - media_close.setVisibility(View.GONE); - media_save.setVisibility(View.GONE); + media_close.hide(); + media_save.hide(); media_description.setVisibility(View.GONE); scheduleHidden = false; } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/RemoteFollowActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/RemoteFollowActivity.java index eac11dfc8..7f8434b24 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/RemoteFollowActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/RemoteFollowActivity.java @@ -304,24 +304,24 @@ public class RemoteFollowActivity extends BaseActivity implements OnRetrieveRemo String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); final String accountId = relationship.getId(); if( accountId != null && accountId.equals(userId)){ - account_follow.setVisibility(View.GONE); + account_follow.hide(); }else if( relationship.isBlocking()){ account_follow.setImageResource(R.drawable.ic_lock_open); doAction = ShowAccountActivity.action.UNBLOCK; - account_follow.setVisibility(View.VISIBLE); + account_follow.show(); }else if( relationship.isRequested()){ - account_follow.setVisibility(View.GONE); + account_follow.hide(); doAction = ShowAccountActivity.action.NOTHING; }else if( relationship.isFollowing()){ account_follow.setImageResource(R.drawable.ic_user_times); doAction = ShowAccountActivity.action.UNFOLLOW; - account_follow.setVisibility(View.VISIBLE); + account_follow.show(); }else if( !relationship.isFollowing()){ account_follow.setImageResource(R.drawable.ic_user_plus); doAction = ShowAccountActivity.action.FOLLOW; - account_follow.setVisibility(View.VISIBLE); + account_follow.show(); }else{ - account_follow.setVisibility(View.GONE); + account_follow.hide(); doAction = ShowAccountActivity.action.NOTHING; } final ShowAccountActivity.action finalDoAction = doAction; diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountSearchDevAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountSearchDevAdapter.java index b3a71a851..b217eecb9 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountSearchDevAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountSearchDevAdapter.java @@ -128,9 +128,9 @@ public class AccountSearchDevAdapter extends BaseAdapter implements OnPostAction .load(account.getAvatar()) .into(holder.account_pp); if( account.isFollowing()){ - holder.account_follow.setVisibility(View.GONE); + holder.account_follow.hide(); }else{ - holder.account_follow.setVisibility(View.VISIBLE); + holder.account_follow.show(); } holder.account_follow.setOnClickListener(new View.OnClickListener() { @@ -168,7 +168,7 @@ public class AccountSearchDevAdapter extends BaseAdapter implements OnPostAction break; } } - holder.account_follow.setVisibility(View.GONE); + holder.account_follow.hide(); Toast.makeText(context, R.string.toast_follow, Toast.LENGTH_LONG).show(); } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsListAdapter.java index 480a5b672..95e18eacd 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsListAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/AccountsListAdapter.java @@ -91,27 +91,27 @@ public class AccountsListAdapter extends RecyclerView.Adapter implements OnPostA account.setFollowType(Account.followAction.MUTE); if (account.getFollowType() == Account.followAction.NOTHING){ - holder.account_follow.setVisibility(View.GONE); + holder.account_follow.hide(); holder.account_follow_request.setVisibility(View.GONE); doAction = null; }else if( account.getFollowType() == Account.followAction.REQUEST_SENT){ - holder.account_follow.setVisibility(View.GONE); + holder.account_follow.hide(); holder.account_follow_request.setVisibility(View.VISIBLE); doAction = null; }else if( account.getFollowType() == Account.followAction.FOLLOW){ holder.account_follow.setImageResource(R.drawable.ic_user_times); doAction = API.StatusAction.UNFOLLOW; - holder.account_follow.setVisibility(View.VISIBLE); + holder.account_follow.show(); holder.account_follow_request.setVisibility(View.GONE); }else if( account.getFollowType() == Account.followAction.NOT_FOLLOW){ holder.account_follow.setImageResource(R.drawable.ic_user_plus); doAction = API.StatusAction.FOLLOW; - holder.account_follow.setVisibility(View.VISIBLE); + holder.account_follow.show(); holder.account_follow_request.setVisibility(View.GONE); }else if( account.getFollowType() == Account.followAction.BLOCK){ holder.account_follow.setImageResource(R.drawable.ic_lock_open); doAction = API.StatusAction.UNBLOCK; - holder.account_follow.setVisibility(View.VISIBLE); + holder.account_follow.show(); holder.account_follow_request.setVisibility(View.GONE); }else if( account.getFollowType() == Account.followAction.MUTE){ @@ -120,10 +120,10 @@ public class AccountsListAdapter extends RecyclerView.Adapter implements OnPostA else holder.account_mute_notification.setImageResource(R.drawable.ic_notifications_off); - holder.account_mute_notification.setVisibility(View.VISIBLE); + holder.account_mute_notification.show(); holder.account_follow.setImageResource(R.drawable.ic_volume_up); doAction = API.StatusAction.UNMUTE; - holder.account_follow.setVisibility(View.VISIBLE); + holder.account_follow.show(); holder.account_follow_request.setVisibility(View.GONE); final int positionFinal = position; holder.account_mute_notification.setOnClickListener(new View.OnClickListener() { diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java index 95ba72bf4..a57342fe9 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java @@ -282,7 +282,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct TextView status_reply; ImageView status_pin; ImageView status_privacy; - FloatingActionButton status_translate, status_bookmark; + ImageButton status_translate, status_bookmark; LinearLayout status_container2; LinearLayout status_container3; LinearLayout main_container; diff --git a/app/src/main/res/layout/activity_federated.xml b/app/src/main/res/layout/activity_federated.xml index 9dfc11584..3aba9e308 100644 --- a/app/src/main/res/layout/activity_federated.xml +++ b/app/src/main/res/layout/activity_federated.xml @@ -110,8 +110,9 @@ @@ -142,8 +142,8 @@ android:layout_marginRight="10dp" android:layout_marginTop="5dp" app:backgroundTint="?colorAccent" - android:layout_width="30dp" - android:layout_height="30dp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" android:src="@drawable/ic_save_white" /> diff --git a/app/src/main/res/layout/activity_show_account.xml b/app/src/main/res/layout/activity_show_account.xml index 9a978d987..04dc769ab 100644 --- a/app/src/main/res/layout/activity_show_account.xml +++ b/app/src/main/res/layout/activity_show_account.xml @@ -72,8 +72,8 @@ android:layout_centerVertical="true" android:layout_marginEnd="10dp" android:layout_marginRight="10dp" - android:layout_width="40dp" - android:layout_height="40dp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> \ No newline at end of file diff --git a/app/src/main/res/layout/drawer_status.xml b/app/src/main/res/layout/drawer_status.xml index 5470ced9c..ef18602b2 100644 --- a/app/src/main/res/layout/drawer_status.xml +++ b/app/src/main/res/layout/drawer_status.xml @@ -81,23 +81,28 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" tools:ignore="ContentDescription" /> - - + + android:layout_gravity="center_horizontal" + /> - - + /> + - - + + android:layout_gravity="center_horizontal" + /> + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> \ No newline at end of file diff --git a/app/src/main/res/layout/user_search_result.xml b/app/src/main/res/layout/user_search_result.xml index feabbff94..e8c3e34d0 100644 --- a/app/src/main/res/layout/user_search_result.xml +++ b/app/src/main/res/layout/user_search_result.xml @@ -2,6 +2,7 @@ + app:srcCompat="@drawable/ic_close" + tools:ignore="VectorDrawableCompat" /> \ No newline at end of file