Improves search with accounts + toots + tags
This commit is contained in:
parent
5b24293ad0
commit
b9dc450363
|
@ -61,7 +61,6 @@
|
|||
<activity android:name="fr.gouv.etalab.mastodon.activities.SearchResultActivity"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:noHistory="true"
|
||||
android:label="@string/app_name"
|
||||
/>
|
||||
<activity android:name="fr.gouv.etalab.mastodon.activities.ShowConversationActivity"
|
||||
|
|
|
@ -14,29 +14,24 @@
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
package fr.gouv.etalab.mastodon.activities;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.TabLayout;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveSearchAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||
import fr.gouv.etalab.mastodon.fragments.DisplayAccountsFragment;
|
||||
import fr.gouv.etalab.mastodon.fragments.DisplayStatusFragment;
|
||||
import fr.gouv.etalab.mastodon.drawers.SearchListAdapter;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearchInterface;
|
||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
||||
|
||||
|
@ -49,13 +44,8 @@ import mastodon.etalab.gouv.fr.mastodon.R;
|
|||
public class SearchResultActivity extends AppCompatActivity implements OnRetrieveSearchInterface {
|
||||
|
||||
|
||||
private static final int NUM_PAGES = 2;
|
||||
private ViewPager mPager;
|
||||
private TabLayout tabLayout;
|
||||
private boolean searchDone = false;
|
||||
private List<Account> accounts;
|
||||
private List<Status> statuses;
|
||||
private String search;
|
||||
private ListView lv_search;
|
||||
private RelativeLayout loader;
|
||||
|
||||
@Override
|
||||
|
@ -63,14 +53,9 @@ public class SearchResultActivity extends AppCompatActivity implements OnRetriev
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_search_result);
|
||||
|
||||
|
||||
statuses = new ArrayList<>();
|
||||
accounts = new ArrayList<>();
|
||||
|
||||
loader = (RelativeLayout) findViewById(R.id.loader);
|
||||
tabLayout = (TabLayout) findViewById(R.id.search_tabLayout);
|
||||
loader.setVisibility(View.VISIBLE);
|
||||
tabLayout.setVisibility(View.GONE);
|
||||
lv_search = (ListView) findViewById(R.id.lv_search);
|
||||
|
||||
Bundle b = getIntent().getExtras();
|
||||
if(b != null){
|
||||
search = b.getString("search");
|
||||
|
@ -85,8 +70,8 @@ public class SearchResultActivity extends AppCompatActivity implements OnRetriev
|
|||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
setTitle(search);
|
||||
|
||||
|
||||
loader.setVisibility(View.VISIBLE);
|
||||
lv_search.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
|
||||
|
@ -105,86 +90,24 @@ public class SearchResultActivity extends AppCompatActivity implements OnRetriev
|
|||
|
||||
@Override
|
||||
public void onRetrieveSearch(Results results) {
|
||||
if( results == null ){
|
||||
Toast.makeText(getApplicationContext(),R.string.toast_error,Toast.LENGTH_LONG).show();
|
||||
loader.setVisibility(View.GONE);
|
||||
tabLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
loader.setVisibility(View.GONE);
|
||||
if( results == null){
|
||||
RelativeLayout no_result = (RelativeLayout) findViewById(R.id.no_result);
|
||||
no_result.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
}
|
||||
accounts = results.getAccounts();
|
||||
statuses = results.getStatuses();
|
||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.toots)));
|
||||
tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.accounts)));
|
||||
loader.setVisibility(View.GONE);
|
||||
tabLayout.setVisibility(View.VISIBLE);
|
||||
mPager = (ViewPager) findViewById(R.id.search_viewpager);
|
||||
PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
|
||||
mPager.setAdapter(mPagerAdapter);
|
||||
lv_search.setVisibility(View.VISIBLE);
|
||||
List<String> tags = results.getHashtags();
|
||||
List<Account> accounts = results.getAccounts();
|
||||
List<Status> statuses = results.getStatuses();
|
||||
|
||||
mPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
TabLayout.Tab tab = tabLayout.getTabAt(position);
|
||||
if( tab != null)
|
||||
tab.select();
|
||||
}
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
mPager.setCurrentItem(tab.getPosition());
|
||||
}
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
|
||||
}
|
||||
});
|
||||
SearchListAdapter searchListAdapter = new SearchListAdapter(SearchResultActivity.this, statuses, accounts, tags);
|
||||
lv_search.setAdapter(searchListAdapter);
|
||||
searchListAdapter.notifyDataSetChanged();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Pager adapter for the 2 fragments (status and accounts) coming from search results
|
||||
*/
|
||||
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
|
||||
ScreenSlidePagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
}
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
Bundle bundle = new Bundle();
|
||||
switch (position){
|
||||
case 0:
|
||||
DisplayStatusFragment displayStatusFragment = new DisplayStatusFragment();
|
||||
bundle.putParcelableArrayList("statuses", new ArrayList<>(statuses));
|
||||
displayStatusFragment.setArguments(bundle);
|
||||
return displayStatusFragment;
|
||||
case 1:
|
||||
DisplayAccountsFragment displayAccountsFragment = new DisplayAccountsFragment();
|
||||
bundle.putParcelableArrayList("accounts", new ArrayList<>(accounts));
|
||||
displayAccountsFragment.setArguments(bundle);
|
||||
return displayAccountsFragment;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return NUM_PAGES;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -872,11 +872,27 @@ public class API {
|
|||
try {
|
||||
results.setAccounts(parseAccountResponse(resobj.getJSONArray("accounts")));
|
||||
results.setStatuses(parseStatuses(resobj.getJSONArray("statuses")));
|
||||
results.setHashtags(parseTags(resobj.getJSONArray("hashtags")));
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse Tags
|
||||
* @param jsonArray JSONArray
|
||||
* @return List<String> of tags
|
||||
*/
|
||||
private List<String> parseTags(JSONArray jsonArray){
|
||||
List<String> list_tmp = new ArrayList<>();
|
||||
for(int i = 0; i < jsonArray.length(); i++){
|
||||
try {
|
||||
list_tmp.add(jsonArray.getString(i));
|
||||
} catch (JSONException ignored) {}
|
||||
}
|
||||
return list_tmp;
|
||||
}
|
||||
/**
|
||||
* Parse json response for several status
|
||||
* @param jsonArray JSONArray
|
||||
|
|
|
@ -0,0 +1,302 @@
|
|||
package fr.gouv.etalab.mastodon.drawers;
|
||||
/* Copyright 2017 Thomas Schneider
|
||||
*
|
||||
* This file is a part of Mastodon Etalab for mastodon.etalab.gouv.fr
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Mastodon Etalab 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>. */
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.Html;
|
||||
import android.text.util.Linkify;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
|
||||
import fr.gouv.etalab.mastodon.activities.ShowConversationActivity;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Thomas on 26/05/2017.
|
||||
* Adapter for Search results
|
||||
*/
|
||||
public class SearchListAdapter extends BaseAdapter {
|
||||
|
||||
private Context context;
|
||||
private List<Status> statuses;
|
||||
private List<Account> accounts;
|
||||
private List<String> tags;
|
||||
|
||||
|
||||
private static final int STATUS_TYPE = 0;
|
||||
private static final int ACCOUNT_TYPE = 1;
|
||||
private static final int TAG_TYPE = 2;
|
||||
private LayoutInflater layoutInflater;
|
||||
private ImageLoader imageLoader;
|
||||
private DisplayImageOptions options;
|
||||
|
||||
|
||||
public SearchListAdapter(Context context, List<Status> statuses, List<Account> accounts, List<String> tags){
|
||||
this.context = context;
|
||||
this.statuses = ( statuses != null)?statuses:new ArrayList<Status>();
|
||||
this.accounts = ( accounts != null)?accounts:new ArrayList<Account>();
|
||||
this.tags = ( tags != null)?tags:new ArrayList<String>();
|
||||
layoutInflater = LayoutInflater.from(context);
|
||||
imageLoader = ImageLoader.getInstance();
|
||||
options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
|
||||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position){
|
||||
if( position < statuses.size())
|
||||
return STATUS_TYPE;
|
||||
else if( position < statuses.size() + accounts.size() )
|
||||
return ACCOUNT_TYPE;
|
||||
else
|
||||
return TAG_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return statuses.size() + accounts.size() + tags.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
if( position < statuses.size())
|
||||
return statuses.get(position);
|
||||
else if( position < statuses.size() + accounts.size() )
|
||||
return accounts.get(position - statuses.size());
|
||||
else
|
||||
return tags.get(position - (statuses.size() + accounts.size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewTypeCount(){
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
|
||||
int type = getItemViewType(position);
|
||||
if( type == STATUS_TYPE){
|
||||
View v = convertView;
|
||||
final Status status = (Status) getItem(position);
|
||||
final ViewHolderStatus holder;
|
||||
if (v == null) {
|
||||
v = layoutInflater.inflate(R.layout.drawer_status_main_search, parent, false);
|
||||
holder = new ViewHolderStatus();
|
||||
holder.status_content = (TextView) v.findViewById(R.id.status_content);
|
||||
holder.status_account_username = (TextView) v.findViewById(R.id.status_account_username);
|
||||
holder.status_account_displayname = (TextView) v.findViewById(R.id.status_account_displayname);
|
||||
holder.status_account_profile = (ImageView) v.findViewById(R.id.status_account_profile);
|
||||
holder.status_toot_date = (TextView) v.findViewById(R.id.status_toot_date);
|
||||
holder.status_reblog_user = (TextView) v.findViewById(R.id.status_reblog_user);
|
||||
holder.main_container = (LinearLayout) v.findViewById(R.id.main_container);
|
||||
v.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolderStatus) v.getTag();
|
||||
}
|
||||
|
||||
final float scale = context.getResources().getDisplayMetrics().density;
|
||||
if( !status.getIn_reply_to_account_id().equals("null") || !status.getIn_reply_to_id().equals("null") ){
|
||||
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_reply);
|
||||
img.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (15 * scale + 0.5f));
|
||||
holder.status_account_displayname.setCompoundDrawables( img, null, null, null);
|
||||
}else if( status.getReblog() != null){
|
||||
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_retweet_header);
|
||||
img.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (15 * scale + 0.5f));
|
||||
holder.status_account_displayname.setCompoundDrawables( img, null, null, null);
|
||||
}else{
|
||||
holder.status_account_displayname.setCompoundDrawables( null, null, null, null);
|
||||
}
|
||||
//Click on a conversation
|
||||
holder.status_content.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, ShowConversationActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("statusId", status.getId()); //Your id
|
||||
intent.putExtras(b); //Put your id to your next Intent
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
final String content, displayName, username, ppurl;
|
||||
if( status.getReblog() != null){
|
||||
content = status.getReblog().getContent();
|
||||
displayName = status.getReblog().getAccount().getDisplay_name();
|
||||
username = status.getReblog().getAccount().getUsername();
|
||||
holder.status_reblog_user.setText(displayName + " " +String.format("@%s",username));
|
||||
ppurl = status.getReblog().getAccount().getAvatar();
|
||||
holder.status_reblog_user.setVisibility(View.VISIBLE);
|
||||
holder.status_account_displayname.setText(context.getResources().getString(R.string.reblog_by, status.getAccount().getAcct()));
|
||||
holder.status_account_username.setText( "");
|
||||
}else {
|
||||
ppurl = status.getAccount().getAvatar();
|
||||
content = status.getContent();
|
||||
displayName = status.getAccount().getDisplay_name();
|
||||
username = status.getAccount().getUsername();
|
||||
holder.status_reblog_user.setVisibility(View.GONE);
|
||||
holder.status_account_displayname.setText(displayName);
|
||||
holder.status_account_username.setText( String.format("@%s",username));
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
holder.status_content.setText(Html.fromHtml(content, Html.FROM_HTML_MODE_COMPACT));
|
||||
else
|
||||
//noinspection deprecation
|
||||
holder.status_content.setText(Html.fromHtml(content));
|
||||
holder.status_content.setAutoLinkMask(Linkify.WEB_URLS);
|
||||
holder.status_toot_date.setText(Helper.dateDiff(context, status.getCreated_at()));
|
||||
|
||||
imageLoader.displayImage(ppurl, holder.status_account_profile, options);
|
||||
|
||||
|
||||
holder.status_account_profile.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
if( status.getReblog() == null)
|
||||
b.putString("accountId", status.getAccount().getId());
|
||||
else
|
||||
b.putString("accountId", status.getReblog().getAccount().getId());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
return v;
|
||||
}else if( type == ACCOUNT_TYPE ){
|
||||
View v = convertView;
|
||||
final Account account = (Account) getItem(position);
|
||||
final ViewHolderAccounts holder;
|
||||
if (v == null) {
|
||||
v = layoutInflater.inflate(R.layout.drawer_account_main_search, parent, false);
|
||||
holder = new ViewHolderAccounts();
|
||||
holder.account_pp = (ImageView) v.findViewById(R.id.account_pp);
|
||||
holder.account_dn = (TextView) v.findViewById(R.id.account_dn);
|
||||
holder.account_ac = (TextView) v.findViewById(R.id.account_ac);
|
||||
holder.account_un = (TextView) v.findViewById(R.id.account_un);
|
||||
|
||||
holder.account_sc = (TextView) v.findViewById(R.id.account_sc);
|
||||
holder.account_fgc = (TextView) v.findViewById(R.id.account_fgc);
|
||||
holder.account_frc = (TextView) v.findViewById(R.id.account_frc);
|
||||
|
||||
v.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolderAccounts) v.getTag();
|
||||
}
|
||||
|
||||
|
||||
holder.account_dn.setText(account.getDisplay_name());
|
||||
holder.account_un.setText(String.format("@%s",account.getUsername()));
|
||||
holder.account_ac.setText(account.getAcct());
|
||||
if( account.getDisplay_name().equals(account.getAcct()))
|
||||
holder.account_ac.setVisibility(View.GONE);
|
||||
else
|
||||
holder.account_ac.setVisibility(View.VISIBLE);
|
||||
holder.account_sc.setText(String.valueOf(account.getStatuses_count()));
|
||||
holder.account_fgc.setText(String.valueOf(account.getFollowing_count()));
|
||||
holder.account_frc.setText(String.valueOf(account.getFollowers_count()));
|
||||
//Profile picture
|
||||
imageLoader.displayImage(account.getAvatar(), holder.account_pp, options);
|
||||
|
||||
|
||||
holder.account_pp.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("accountId", account.getId());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
return v;
|
||||
}else{
|
||||
final String tag = (String) getItem(position);
|
||||
final ViewHolderTag holder;
|
||||
View v = convertView;
|
||||
if (v == null) {
|
||||
v = layoutInflater.inflate(R.layout.drawer_tag, parent, false);
|
||||
holder = new ViewHolderTag();
|
||||
holder.tag_name = (TextView) v.findViewById(R.id.tag_name);
|
||||
v.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolderTag) v.getTag();
|
||||
}
|
||||
holder.tag_name.setText(String.format("#%s",tag));
|
||||
holder.tag_name.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
});
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class ViewHolderStatus {
|
||||
TextView status_content;
|
||||
TextView status_account_username;
|
||||
TextView status_account_displayname;
|
||||
ImageView status_account_profile;
|
||||
TextView status_toot_date;
|
||||
TextView status_reblog_user;
|
||||
LinearLayout main_container;
|
||||
}
|
||||
|
||||
|
||||
private class ViewHolderAccounts {
|
||||
ImageView account_pp;
|
||||
TextView account_ac;
|
||||
TextView account_dn;
|
||||
TextView account_un;
|
||||
TextView account_sc;
|
||||
TextView account_fgc;
|
||||
TextView account_frc;
|
||||
}
|
||||
|
||||
private class ViewHolderTag {
|
||||
TextView tag_name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package fr.gouv.etalab.mastodon.drawers;
|
||||
/* Copyright 2017 Thomas Schneider
|
||||
*
|
||||
* This file is a part of Mastodon Etalab for mastodon.etalab.gouv.fr
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Mastodon Etalab 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>. */
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;;
|
||||
import android.widget.TextView;
|
||||
import java.util.List;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Tag;
|
||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Thomas on 26/05/2017.
|
||||
* Adapter for tags when searching
|
||||
*/
|
||||
public class TagsListAdapter extends BaseAdapter {
|
||||
|
||||
private List<String> tags;
|
||||
private LayoutInflater layoutInflater;
|
||||
private Context context;
|
||||
|
||||
public TagsListAdapter(Context context, List<String> tags){
|
||||
this.tags = tags;
|
||||
layoutInflater = LayoutInflater.from(context);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return tags.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return tags.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
|
||||
final String tag = tags.get(position);
|
||||
final ViewHolder holder;
|
||||
if (convertView == null) {
|
||||
convertView = layoutInflater.inflate(R.layout.drawer_tag, parent, false);
|
||||
holder = new ViewHolder();
|
||||
holder.tag_name = (TextView) convertView.findViewById(R.id.tag_name);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
holder.tag_name.setText(tag);
|
||||
holder.tag_name.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
});
|
||||
return convertView;
|
||||
}
|
||||
|
||||
|
||||
private class ViewHolder {
|
||||
TextView tag_name;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -19,31 +19,34 @@
|
|||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<android.support.design.widget.AppBarLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<ListView
|
||||
android:id="@+id/lv_search"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none"
|
||||
>
|
||||
</ListView>
|
||||
<RelativeLayout
|
||||
android:id="@+id/no_result"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@android:color/white"
|
||||
android:layout_height="wrap_content">
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/search_tabLayout"
|
||||
<TextView
|
||||
android:padding="10dp"
|
||||
android:gravity="center"
|
||||
android:textSize="25sp"
|
||||
android:layout_gravity="center"
|
||||
android:textStyle="italic|bold"
|
||||
android:typeface="serif"
|
||||
android:text="@string/no_result"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/white"
|
||||
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
|
||||
app:tabMode="fixed"
|
||||
app:tabGravity="fill"
|
||||
/>
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/search_viewpager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/white"
|
||||
/>
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
android:layout_height="match_parent" />
|
||||
</RelativeLayout>
|
||||
<!-- Main Loader -->
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/loader"
|
||||
|
|
|
@ -0,0 +1,125 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2017 Thomas Schneider
|
||||
|
||||
This file is a part of Mastodon Etalab for mastodon.etalab.gouv.fr
|
||||
|
||||
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.
|
||||
|
||||
Mastodon Etalab 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"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:id="@+id/main_container"
|
||||
android:paddingLeft="@dimen/drawer_padding"
|
||||
android:paddingRight="@dimen/drawer_padding"
|
||||
android:orientation="horizontal">
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<ImageView
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/account_pp"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/account_container"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:id="@+id/account_dn"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
|
||||
<TextView
|
||||
android:id="@+id/account_un"
|
||||
android:layout_width="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_marginTop="10dp"
|
||||
android:visibility="gone"
|
||||
android:id="@+id/account_ac"
|
||||
android:textSize="16sp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<LinearLayout
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:baselineAligned="false">
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:text="@string/status"
|
||||
android:maxLines="1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:id="@+id/account_sc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:maxLines="1"
|
||||
android:text="@string/following"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:id="@+id/account_fgc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:maxLines="1"
|
||||
android:text="@string/followers"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:id="@+id/account_frc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,89 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2017 Thomas Schneider
|
||||
|
||||
This file is a part of Mastodon Etalab for mastodon.etalab.gouv.fr
|
||||
|
||||
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.
|
||||
|
||||
Mastodon Etalab 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:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/drawer_padding"
|
||||
android:paddingRight="@dimen/drawer_padding"
|
||||
android:layout_marginTop="5dp"
|
||||
android:id="@+id/main_container"
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:id="@+id/status_account_profile"
|
||||
android:layout_height="50dp"
|
||||
android:layout_width="50dp"
|
||||
android:layout_gravity="center_horizontal|top"
|
||||
android:gravity="center_horizontal|top"
|
||||
tools:ignore="ContentDescription" />
|
||||
<LinearLayout
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:id="@+id/status_account_displayname"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:maxLines="1"
|
||||
android:drawablePadding="2dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
android:maxLines="1"
|
||||
android:id="@+id/status_account_username"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:visibility="gone"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:textSize="14sp"
|
||||
android:maxLines="1"
|
||||
android:id="@+id/status_reblog_user"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:id="@+id/status_toot_date"
|
||||
android:layout_width="match_parent"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:layout_gravity="end"
|
||||
android:gravity="end"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:id="@+id/status_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:autoLink="web"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2017 Thomas Schneider
|
||||
|
||||
This file is a part of Mastodon Etalab for mastodon.etalab.gouv.fr
|
||||
|
||||
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.
|
||||
|
||||
Mastodon Etalab 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="20dp"
|
||||
android:id="@+id/account_container"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:id="@+id/tag_name"
|
||||
android:textSize="16sp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
|
@ -23,6 +23,7 @@
|
|||
<string name="toots">Pouets</string>
|
||||
<string name="token">Jeton</string>
|
||||
<string name="two_factor_authentification">Authentification en deux étapes ?</string>
|
||||
<string name="no_result">Aucun résultat !</string>
|
||||
<!--- Menu -->
|
||||
<string name="home_menu">Accueil</string>
|
||||
<string name="home_timeline">Accueil</string>
|
||||
|
|
Loading…
Reference in New Issue