layout fix

This commit is contained in:
NudeDude 2019-05-19 14:28:22 +02:00
parent d86507a4f7
commit c925db0d6c
19 changed files with 107 additions and 74 deletions

View File

@ -186,6 +186,7 @@ public class MainActivity extends AppCompatActivity implements TabLayout.OnTabSe
@Override
public void onTabUnselected(TabLayout.Tab tab) {
adapter.scrollToTop(tab.getPosition());
}

View File

@ -154,14 +154,22 @@ public class FragmentAdapter extends FragmentPagerAdapter {
public void notifySettingsChanged() {
for (Fragment fragment : fragments) {
if (fragment instanceof OnSettingsChanged)
((OnSettingsChanged) fragment).onSettingsChange();
if (fragment instanceof OnStateChange)
((OnStateChange) fragment).onSettingsChange();
}
}
public interface OnSettingsChanged {
public void scrollToTop(int index) {
if (fragments[index] instanceof OnStateChange)
((OnStateChange) fragments[index]).onTabChange();
}
public interface OnStateChange {
void onSettingsChange();
void onTabChange();
}
}

View File

@ -15,7 +15,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener;
import org.nuclearfog.twidda.R;
import org.nuclearfog.twidda.adapter.FragmentAdapter.OnSettingsChanged;
import org.nuclearfog.twidda.adapter.FragmentAdapter.OnStateChange;
import org.nuclearfog.twidda.adapter.OnItemClickListener;
import org.nuclearfog.twidda.adapter.TrendAdapter;
import org.nuclearfog.twidda.database.GlobalSettings;
@ -24,10 +24,11 @@ import org.nuclearfog.twidda.fragment.backend.TrendLoader.Mode;
import org.nuclearfog.twidda.window.SearchPage;
public class TrendListFragment extends Fragment implements OnRefreshListener, OnItemClickListener, OnSettingsChanged {
public class TrendListFragment extends Fragment implements OnRefreshListener, OnItemClickListener, OnStateChange {
private TrendLoader trendTask;
private SwipeRefreshLayout reload;
private RecyclerView list;
private TrendAdapter adapter;
private View root;
@ -35,7 +36,7 @@ public class TrendListFragment extends Fragment implements OnRefreshListener, On
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent, Bundle param) {
super.onCreateView(inflater, parent, param);
View v = inflater.inflate(R.layout.fragment_list, parent, false);
RecyclerView list = v.findViewById(R.id.fragment_list);
list = v.findViewById(R.id.fragment_list);
reload = v.findViewById(R.id.fragment_reload);
reload.setOnRefreshListener(this);
@ -101,4 +102,10 @@ public class TrendListFragment extends Fragment implements OnRefreshListener, On
adapter.setColor(settings.getFontColor());
adapter.notifyDataSetChanged();
}
@Override
public void onTabChange() {
list.smoothScrollToPosition(0);
}
}

View File

@ -16,7 +16,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener;
import org.nuclearfog.twidda.BuildConfig;
import org.nuclearfog.twidda.R;
import org.nuclearfog.twidda.adapter.FragmentAdapter.OnSettingsChanged;
import org.nuclearfog.twidda.adapter.FragmentAdapter.OnStateChange;
import org.nuclearfog.twidda.adapter.OnItemClickListener;
import org.nuclearfog.twidda.adapter.TweetAdapter;
import org.nuclearfog.twidda.backend.items.Tweet;
@ -26,7 +26,7 @@ import org.nuclearfog.twidda.fragment.backend.TweetLoader.Mode;
import org.nuclearfog.twidda.window.TweetDetail;
public class TweetListFragment extends Fragment implements OnRefreshListener, OnItemClickListener, OnSettingsChanged {
public class TweetListFragment extends Fragment implements OnRefreshListener, OnItemClickListener, OnStateChange {
public enum TweetType {
HOME,
@ -39,6 +39,7 @@ public class TweetListFragment extends Fragment implements OnRefreshListener, On
private TweetLoader tweetTask;
private SwipeRefreshLayout reload;
private RecyclerView list;
private TweetAdapter adapter;
private View root;
@ -62,16 +63,15 @@ public class TweetListFragment extends Fragment implements OnRefreshListener, On
View v = inflater.inflate(R.layout.fragment_list, parent, false);
reload = v.findViewById(R.id.fragment_reload);
list = v.findViewById(R.id.fragment_list);
reload.setOnRefreshListener(this);
adapter = new TweetAdapter(this);
RecyclerView list = v.findViewById(R.id.fragment_list);
list.setLayoutManager(new LinearLayoutManager(getContext()));
list.setHasFixedSize(fixSize);
list.setAdapter(adapter);
onSettingsChange();
return v;
}
@ -186,4 +186,10 @@ public class TweetListFragment extends Fragment implements OnRefreshListener, On
adapter.toggleImage(settings.getImageLoad());
adapter.notifyDataSetChanged();
}
@Override
public void onTabChange() {
list.smoothScrollToPosition(0);
}
}

View File

@ -25,6 +25,7 @@ public class SearchPage extends AppCompatActivity implements OnTabSelectedListen
private static final int[] icons = {R.drawable.search, R.drawable.user};
private FragmentAdapter adapter;
private ViewPager pager;
private String search;
private int tabIndex = 0;
@ -53,7 +54,7 @@ public class SearchPage extends AppCompatActivity implements OnTabSelectedListen
root.setBackgroundColor(settings.getBackgroundColor());
tab.setSelectedTabIndicatorColor(settings.getHighlightColor());
FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager(), AdapterType.SEARCH_TAB, 0, search);
adapter = new FragmentAdapter(getSupportFragmentManager(), AdapterType.SEARCH_TAB, 0, search);
tab.setupWithViewPager(pager);
tab.addOnTabSelectedListener(this);
pager.setAdapter(adapter);
@ -121,6 +122,7 @@ public class SearchPage extends AppCompatActivity implements OnTabSelectedListen
@Override
public void onTabUnselected(TabLayout.Tab tab) {
adapter.scrollToTop(tab.getPosition());
}

View File

@ -40,6 +40,7 @@ import java.text.NumberFormat;
public class UserProfile extends AppCompatActivity implements OnClickListener, OnTagClickListener, OnTabSelectedListener {
private ProfileLoader profileAsync;
private FragmentAdapter adapter;
private ViewPager pager;
private TextView lnkTxt;
private View[] icons;
@ -91,7 +92,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
icons[0] = inflater.inflate(R.layout.tab_tw, null);
icons[1] = inflater.inflate(R.layout.tab_fa, null);
FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager(), AdapterType.PROFILE_TAB, userId, "");
adapter = new FragmentAdapter(getSupportFragmentManager(), AdapterType.PROFILE_TAB, userId, "");
pager.setOffscreenPageLimit(2);
pager.setAdapter(adapter);
tab.setupWithViewPager(pager);
@ -310,6 +311,7 @@ public class UserProfile extends AppCompatActivity implements OnClickListener, O
@Override
public void onTabUnselected(TabLayout.Tab tab) {
adapter.scrollToTop(tab.getPosition());
}

View File

@ -41,7 +41,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginBottom="@dimen/margin_layout"
android:orientation="horizontal">
<TextView
@ -51,7 +51,7 @@
android:layout_weight="2"
android:drawablePadding="@dimen/padding_drawable"
android:singleLine="true"
android:textSize="12sp" />
android:textSize="@dimen/textsize_name" />
<TextView
android:id="@+id/dm_time"
@ -61,7 +61,7 @@
android:gravity="end"
android:singleLine="true"
android:textAlignment="gravity"
android:textSize="12sp" />
android:textSize="@dimen/textsize_date" />
</LinearLayout>
@ -71,7 +71,7 @@
android:layout_height="wrap_content"
android:drawablePadding="@dimen/padding_drawable"
android:singleLine="true"
android:textSize="12sp" />
android:textSize="@dimen/textsize_name" />
</LinearLayout>
@ -98,14 +98,14 @@
android:layout_marginEnd="@dimen/padding_side"
android:layout_marginRight="@dimen/padding_side"
android:text="@string/answer"
android:textSize="12sp" />
android:textSize="@dimen/textsize_button" />
<TextView
android:id="@+id/dm_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/delete_dm"
android:textSize="12sp" />
android:textSize="@dimen/textsize_button" />
</LinearLayout>

View File

@ -27,7 +27,7 @@
android:layout_height="match_parent"
android:layout_weight="8"
android:singleLine="true"
android:textSize="20sp" />
android:textSize="@dimen/textsize_trend" />
</LinearLayout>

View File

@ -61,7 +61,7 @@
android:layout_weight="1"
android:gravity="end"
android:textAlignment="gravity"
android:textSize="12sp" />
android:textSize="@dimen/textsize_date" />
</LinearLayout>
@ -94,7 +94,7 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:singleLine="true"
android:textSize="12sp" />
android:textSize="@dimen/textsize_button" />
<TextView
android:id="@+id/retweet_number"
@ -103,7 +103,7 @@
android:drawablePadding="@dimen/padding_drawable"
android:layout_weight="1"
android:singleLine="true"
android:textSize="12sp" />
android:textSize="@dimen/textsize_button" />
<TextView
android:id="@+id/favorite_number"
@ -112,7 +112,7 @@
android:drawablePadding="@dimen/padding_drawable"
android:layout_weight="1"
android:singleLine="true"
android:textSize="12sp" />
android:textSize="@dimen/textsize_button" />
</LinearLayout>

View File

@ -15,6 +15,7 @@
style="@style/ProfileImageCardView"
android:layout_width="@dimen/profile_middle"
android:layout_height="@dimen/profile_middle"
android:layout_marginEnd="@dimen/margin_layout"
android:layout_marginRight="@dimen/margin_layout">
<ImageView

View File

@ -30,7 +30,7 @@
android:layout_marginBottom="@dimen/margin_layout"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="10dp">
android:padding="@dimen/padding_side">
<ImageView
android:id="@+id/edit_pb"
@ -42,8 +42,8 @@
android:id="@+id/edit_upload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="@dimen/margin_layout"
android:layout_marginLeft="@dimen/margin_layout"
android:contentDescription="@string/upload_button"
app:srcCompat="@drawable/upload" />
@ -51,8 +51,8 @@
android:id="@+id/pb_path"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp" />
android:layout_marginStart="@dimen/margin_layout"
android:layout_marginLeft="@dimen/margin_layout" />
</LinearLayout>
@ -67,11 +67,10 @@
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_layout"
android:background="@android:color/transparent"
android:hint="@string/tweet"
android:inputType="text"
android:singleLine="true"
android:textSize="18sp" />
android:textSize="@dimen/textsize_profileedit" />
<TextView
android:layout_width="match_parent"
@ -87,7 +86,7 @@
android:ems="10"
android:inputType="text"
android:singleLine="true"
android:textSize="18sp" />
android:textSize="@dimen/textsize_profileedit" />
<TextView
android:layout_width="match_parent"
@ -103,7 +102,7 @@
android:ems="10"
android:inputType="text"
android:singleLine="true"
android:textSize="18sp" />
android:textSize="@dimen/textsize_profileedit" />
<TextView
android:layout_width="match_parent"
@ -118,7 +117,7 @@
android:ems="10"
android:gravity="top"
android:inputType="textMultiLine"
android:textSize="18sp" />
android:textSize="@dimen/textsize_profileedit" />
</LinearLayout>

View File

@ -16,7 +16,7 @@
android:layout_marginBottom="@dimen/button_size"
android:background="@drawable/button"
android:text="@string/register_link"
android:textSize="12sp" />
android:textSize="@dimen/textsize_button" />
<LinearLayout
android:layout_width="wrap_content"
@ -33,7 +33,7 @@
android:hint="@string/pin"
android:inputType="numberPassword"
android:singleLine="true"
android:textSize="24sp"
android:textSize="@dimen/textsize_login_key"
app:drawableEndCompat="@drawable/copy"
app:drawableLeftCompat="@drawable/key"
app:drawableRightCompat="@drawable/copy"
@ -49,6 +49,6 @@
android:layout_margin="@dimen/button_size"
android:background="@drawable/button"
android:text="@string/verifierbutton"
android:textSize="12sp" />
android:textSize="@dimen/textsize_button" />
</LinearLayout>

View File

@ -154,7 +154,7 @@
android:layout_marginTop="@dimen/margin_layout"
android:drawablePadding="@dimen/padding_drawable"
android:singleLine="true"
android:textSize="12sp"
android:textSize="@dimen/textsize_profile"
app:drawableLeftCompat="@drawable/location"
app:drawableStartCompat="@drawable/location" />
@ -166,7 +166,7 @@
android:drawablePadding="@dimen/padding_drawable"
android:linksClickable="true"
android:singleLine="true"
android:textSize="12sp"
android:textSize="@dimen/textsize_profile"
app:drawableLeftCompat="@drawable/link"
app:drawableStartCompat="@drawable/link" />
@ -177,7 +177,7 @@
android:layout_marginTop="@dimen/margin_layout"
android:drawablePadding="@dimen/padding_drawable"
android:singleLine="true"
android:textSize="12sp"
android:textSize="@dimen/textsize_profile"
app:drawableLeftCompat="@drawable/calendar"
app:drawableStartCompat="@drawable/calendar" />

View File

@ -26,7 +26,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/color_settings"
android:textSize="18sp" />
android:textSize="@dimen/textsize_settings" />
<View
android:layout_width="match_parent"
@ -91,7 +91,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/data_load"
android:textSize="18sp" />
android:textSize="@dimen/textsize_settings" />
<View
android:layout_width="match_parent"
@ -111,7 +111,7 @@
android:layout_height="@dimen/button_dm"
android:layout_weight="1"
android:text="@string/load_factor"
android:textSize="10sp" />
android:textSize="@dimen/textsize_checkbox" />
<CheckBox
android:id="@+id/toggleImg"
@ -121,7 +121,7 @@
android:layout_marginLeft="@dimen/padding_side"
android:layout_weight="1"
android:text="@string/image"
android:textSize="10sp" />
android:textSize="@dimen/textsize_checkbox" />
<CheckBox
android:id="@+id/toggleAns"
@ -131,7 +131,7 @@
android:layout_marginLeft="@dimen/padding_side"
android:layout_weight="1"
android:text="@string/toggle_answer"
android:textSize="10sp" />
android:textSize="@dimen/textsize_checkbox" />
</LinearLayout>
@ -140,7 +140,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/text_settings"
android:text="@string/trend_setting"
android:textSize="18sp" />
android:textSize="@dimen/textsize_settings" />
<View
android:layout_width="match_parent"
@ -179,7 +179,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/button_margin"
android:text="@string/user_data"
android:textSize="18sp" />
android:textSize="@dimen/textsize_settings" />
<View
android:layout_width="match_parent"
@ -220,7 +220,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/button_margin"
android:text="@string/settings_info"
android:textSize="18sp" />
android:textSize="@dimen/textsize_settings" />
<View
android:layout_width="match_parent"
@ -231,7 +231,7 @@
android:id="@+id/settings_link"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginTop="@dimen/margin_layout"
android:autoLink="web"
android:linksClickable="true"
android:text="@string/github_link" />

View File

@ -79,10 +79,10 @@
android:id="@+id/timedetail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:layout_marginTop="@dimen/margin_layout_tweet"
android:layout_marginBottom="@dimen/margin_layout_tweet"
android:singleLine="true"
android:textSize="12sp" />
android:textSize="@dimen/textsize_date" />
</LinearLayout>
@ -93,7 +93,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:singleLine="true"
android:textSize="12sp"
android:textSize="@dimen/textsize_refer"
android:visibility="gone" />
<TextView
@ -104,7 +104,7 @@
android:linksClickable="true"
android:maxLines="@integer/text_tweet_lines"
android:scrollbars="vertical"
android:textSize="18sp" />
android:textSize="@dimen/textsize_tweet" />
<TextView
android:id="@+id/used_api"
@ -112,12 +112,12 @@
android:layout_height="wrap_content"
android:linksClickable="false"
android:singleLine="true"
android:textSize="12sp" />
android:textSize="@dimen/textsize_refer" />
<ImageButton
android:id="@+id/image_attach"
android:layout_width="64dp"
android:layout_height="36dp"
android:layout_width="@dimen/button_media_width"
android:layout_height="@dimen/button_media_height"
android:layout_margin="@dimen/margin_tweet_icon"
android:contentDescription="@string/image_preview_button"
android:background="@drawable/button"

View File

@ -35,7 +35,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/holo_red_dark"
android:textSize="18sp" />
android:textSize="@dimen/textsize_count" />
<ImageButton
android:id="@+id/img_preview"

View File

@ -8,8 +8,8 @@
android:paddingTop="@dimen/padding_tab">
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_width="@dimen/image_tab_ico"
android:layout_height="@dimen/image_tab_ico"
android:contentDescription="@string/profile_tweets"
app:srcCompat="@drawable/favorite" />
@ -17,11 +17,6 @@
android:id="@+id/profile_favor_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10sp" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="2dp" />
android:textSize="@dimen/textsize_tab" />
</LinearLayout>

View File

@ -8,8 +8,8 @@
android:paddingTop="@dimen/padding_tab">
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_width="@dimen/image_tab_ico"
android:layout_height="@dimen/image_tab_ico"
android:contentDescription="@string/profile_tweets"
app:srcCompat="@drawable/home" />
@ -17,11 +17,6 @@
android:id="@+id/profile_tweet_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10sp" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="2dp" />
android:textSize="@dimen/textsize_tab" />
</LinearLayout>

View File

@ -9,10 +9,12 @@
<dimen name="image_height">300dp</dimen>
<dimen name="tweet_profile">56dp</dimen>
<dimen name="tweet_page_icon">20dp</dimen>
<dimen name="image_tab_ico">18dp</dimen>
<dimen name="margin_dm_icon">5dp</dimen>
<dimen name="margin_tweet_icon">16dp</dimen>
<dimen name="margin_layout">5dp</dimen>
<dimen name="margin_layout_tweet">2dp</dimen>
<dimen name="padding_side">10dp</dimen>
<dimen name="padding_editprofile">20dp</dimen>
@ -24,6 +26,19 @@
<dimen name="text_settings">5dp</dimen>
<dimen name="text_input_width">300dp</dimen>
<dimen name="text_input_height">200dp</dimen>
<dimen name="textsize_login_key">24sp</dimen>
<dimen name="textsize_trend">20sp</dimen>
<dimen name="textsize_profileedit">18sp</dimen>
<dimen name="textsize_count">18sp</dimen>
<dimen name="textsize_tweet">18sp</dimen>
<dimen name="textsize_settings">18sp</dimen>
<dimen name="textsize_profile">12sp</dimen>
<dimen name="textsize_button">12sp</dimen>
<dimen name="textsize_date">12sp</dimen>
<dimen name="textsize_name">12sp</dimen>
<dimen name="textsize_refer">12sp</dimen>
<dimen name="textsize_checkbox">10sp</dimen>
<dimen name="textsize_tab">10sp</dimen>
<integer name="text_tweet_lines">10</integer>
<integer name="text_bio_lines">5</integer>
@ -35,5 +50,7 @@
<dimen name="button_height">20dp</dimen>
<dimen name="button_size">40dp</dimen>
<dimen name="button_tweet_size">40dp</dimen>
<dimen name="button_media_height">36dp</dimen>
<dimen name="button_media_width">64dp</dimen>
</resources>