Fix some issues
This commit is contained in:
parent
1f8707ed4f
commit
8b6459f86c
|
@ -15,24 +15,36 @@
|
|||
package fr.gouv.etalab.mastodon.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import fr.gouv.etalab.mastodon.R;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.ManageListsAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.WhoToFollowAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.APIResponse;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.TrunkAccount;
|
||||
import fr.gouv.etalab.mastodon.drawers.WhoToFollowAccountsAdapter;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnListActionInterface;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveWhoToFollowInterface;
|
||||
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.THEME_BLACK;
|
||||
|
@ -43,11 +55,18 @@ import static fr.gouv.etalab.mastodon.helper.Helper.THEME_BLACK;
|
|||
* Display Who to follow accounts
|
||||
*/
|
||||
|
||||
public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoToFollowInterface {
|
||||
public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoToFollowInterface, OnPostActionInterface, OnListActionInterface {
|
||||
|
||||
|
||||
|
||||
private String item;
|
||||
private List<String> followedId;
|
||||
private List<String> accountListId;
|
||||
private List<String> toFollowdId;
|
||||
private TextView progess_action;
|
||||
private List<TrunkAccount> trunkAccounts;
|
||||
private RelativeLayout mainLoader;
|
||||
private String listId, listTitle;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -69,17 +88,19 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
|
|||
}
|
||||
setContentView(R.layout.activity_who_to_follow);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
progess_action = findViewById(R.id.progess_action);
|
||||
if( theme == THEME_BLACK)
|
||||
toolbar.setBackgroundColor(ContextCompat.getColor(WhoToFollowActivity.this, R.color.black));
|
||||
setSupportActionBar(toolbar);
|
||||
if( getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
RelativeLayout mainLoader = findViewById(R.id.loader);
|
||||
mainLoader = findViewById(R.id.loader);
|
||||
Bundle b = getIntent().getExtras();
|
||||
if(b != null){
|
||||
item = b.getString("item");
|
||||
}
|
||||
followedId = new ArrayList<>();
|
||||
String lastDateListNameRefresh = sharedpreferences.getString(Helper.LAST_DATE_LIST_NAME_REFRESH+item, null);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(new Date( ));
|
||||
|
@ -90,44 +111,157 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
|
|||
mainLoader.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
String lastList = sharedpreferences.getString(Helper.LAST_LIST_NAME + item, null);
|
||||
List<String> list = Helper.restoreArrayFromString(lastList);
|
||||
displayResults(list);
|
||||
List<String> acctString = Helper.restoreArrayFromString(lastList);
|
||||
if( acctString != null) {
|
||||
trunkAccounts = new ArrayList<>();
|
||||
for (String acct : acctString) {
|
||||
TrunkAccount trunkAccount = new TrunkAccount();
|
||||
trunkAccount.setAcct(acct);
|
||||
trunkAccounts.add(trunkAccount);
|
||||
}
|
||||
}
|
||||
displayResults();
|
||||
}
|
||||
|
||||
setTitle(item);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRetrieveWhoToFollow(List<String> list) {
|
||||
if( list != null){
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.LAST_DATE_LIST_NAME_REFRESH + item, Helper.dateToString(new Date()));
|
||||
editor.putString(Helper.LAST_LIST_NAME + item, Helper.arrayToStringStorage(list));
|
||||
editor.apply();
|
||||
}
|
||||
displayResults(list);
|
||||
}
|
||||
|
||||
private void displayResults(List<String> list){
|
||||
|
||||
RelativeLayout mainLoader = findViewById(R.id.loader);
|
||||
private void displayResults(){
|
||||
mainLoader.setVisibility(View.GONE);
|
||||
if( list != null){
|
||||
WhoToFollowAccountsAdapter whoToFollowAccountsAdapter;
|
||||
if( trunkAccounts != null){
|
||||
ListView lv_list = findViewById(R.id.lv_list);
|
||||
WhoToFollowAccountsAdapter whoToFollowAccountsAdapter = new WhoToFollowAccountsAdapter(WhoToFollowActivity.this, list);
|
||||
whoToFollowAccountsAdapter = new WhoToFollowAccountsAdapter(WhoToFollowActivity.this, trunkAccounts);
|
||||
lv_list.setAdapter(whoToFollowAccountsAdapter);
|
||||
}else{
|
||||
Toast.makeText(WhoToFollowActivity.this, R.string.toast_error, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
Button follow_accounts_select = findViewById(R.id.follow_accounts_select);
|
||||
follow_accounts_select.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(follow_accounts_select.getText().equals(getString(R.string.select_all))){
|
||||
follow_accounts_select.setText(R.string.unselect_all);
|
||||
for(TrunkAccount trunkAccount: trunkAccounts){
|
||||
trunkAccount.setChecked(true);
|
||||
}
|
||||
whoToFollowAccountsAdapter.notifyDataSetChanged();
|
||||
}else {
|
||||
follow_accounts_select.setText(R.string.select_all);
|
||||
for(TrunkAccount trunkAccount: trunkAccounts){
|
||||
trunkAccount.setChecked(false);
|
||||
}
|
||||
whoToFollowAccountsAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
Button follow_accounts = findViewById(R.id.follow_accounts);
|
||||
follow_accounts.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
follow_accounts.setEnabled(false);
|
||||
follow_accounts_select.setEnabled(false);
|
||||
progess_action.setVisibility(View.VISIBLE);
|
||||
toFollowdId = new ArrayList<>();
|
||||
for(TrunkAccount trunkAccount: trunkAccounts){
|
||||
if( trunkAccount.isChecked()){
|
||||
toFollowdId.add(trunkAccount.getAcct());
|
||||
}
|
||||
}
|
||||
if(toFollowdId.size() > 0){
|
||||
Account account = new Account();
|
||||
String[] val = toFollowdId.get(0).split("@");
|
||||
progess_action.setText(getString(R.string.follow_trunk, toFollowdId.get(0)));
|
||||
if( val.length > 1){
|
||||
account.setAcct(val[0]);
|
||||
account.setInstance(val[1]);
|
||||
new PostActionAsyncTask(WhoToFollowActivity.this, null, account, API.StatusAction.FOLLOW, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRetrieveWhoToFollowList(List<String> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRetrieveWhoToFollowAccount(List<TrunkAccount> trunkAccounts) {
|
||||
if( trunkAccounts != null){
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.LAST_DATE_LIST_NAME_REFRESH + item, Helper.dateToString(new Date()));
|
||||
List<String> accounts = new ArrayList<>();
|
||||
for(TrunkAccount trunkAccount: trunkAccounts)
|
||||
accounts.add(trunkAccount.getAcct());
|
||||
editor.putString(Helper.LAST_LIST_NAME + item, Helper.arrayToStringStorage(accounts));
|
||||
editor.apply();
|
||||
this.trunkAccounts = trunkAccounts;
|
||||
}
|
||||
displayResults();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) {
|
||||
followedId.add(userId);
|
||||
if( followedId != null && followedId.size() >= toFollowdId.size()) {
|
||||
progess_action.setText(getString(R.string.create_list_trunk, item));
|
||||
new ManageListsAsyncTask(WhoToFollowActivity.this, ManageListsAsyncTask.action.CREATE_LIST, null, null, null, item, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}else {
|
||||
Account account = new Account();
|
||||
String[] val = toFollowdId.get(followedId.size()).split("@");
|
||||
progess_action.setText(getString(R.string.follow_trunk, toFollowdId.get(followedId.size())));
|
||||
if( val.length > 1){
|
||||
account.setAcct(val[0]);
|
||||
account.setInstance(val[1]);
|
||||
new PostActionAsyncTask(WhoToFollowActivity.this, null, account, API.StatusAction.FOLLOW, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionDone(ManageListsAsyncTask.action actionType, APIResponse apiResponse, int statusCode) {
|
||||
|
||||
List<fr.gouv.etalab.mastodon.client.Entities.List> lists = apiResponse.getLists();
|
||||
if( lists!= null && lists.size() > 0 && actionType == ManageListsAsyncTask.action.CREATE_LIST){
|
||||
String[] accountsId = followedId.toArray(new String[0]);
|
||||
progess_action.setText(R.string.add_account_list_trunk);
|
||||
listId = lists.get(0).getId();
|
||||
listTitle = lists.get(0).getTitle();
|
||||
new ManageListsAsyncTask(WhoToFollowActivity.this, ManageListsAsyncTask.action.ADD_USERS, new String[]{followedId.get(0)}, null, lists.get(0).getId(), null, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
accountListId = new ArrayList<>();
|
||||
}else if(accountListId != null){
|
||||
|
||||
if( accountListId.size() >= followedId.size() -1) {
|
||||
progess_action.setText(R.string.account_added_list_trunk);
|
||||
Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Intent intent = new Intent(WhoToFollowActivity.this, ListActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("id", listId);
|
||||
b.putString("title", listTitle);
|
||||
intent.putExtras(b);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
}, 1000);
|
||||
|
||||
}else {
|
||||
accountListId.add(followedId.get(accountListId.size()));
|
||||
progess_action.setText(R.string.adding_account_list_trunk);
|
||||
String userIdToAdd = followedId.get(accountListId.size());
|
||||
new ManageListsAsyncTask(WhoToFollowActivity.this, ManageListsAsyncTask.action.ADD_USERS, new String[]{userIdToAdd}, null, listId, null, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
|
|
@ -16,8 +16,10 @@ package fr.gouv.etalab.mastodon.asynctasks;
|
|||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.TrunkAccount;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveWhoToFollowInterface;
|
||||
|
||||
|
||||
|
@ -52,7 +54,21 @@ public class WhoToFollowAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
listener.onRetrieveWhoToFollow(response);
|
||||
if( name == null)
|
||||
listener.onRetrieveWhoToFollowList(response);
|
||||
else {
|
||||
List<TrunkAccount> trunkAccounts = null;
|
||||
if(response != null) {
|
||||
trunkAccounts = new ArrayList<>();
|
||||
for (String res : response) {
|
||||
TrunkAccount trunkAccount = new TrunkAccount();
|
||||
trunkAccount.setAcct(res);
|
||||
trunkAccounts.add(trunkAccount);
|
||||
}
|
||||
}
|
||||
listener.onRetrieveWhoToFollowAccount(trunkAccounts);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@ package fr.gouv.etalab.mastodon.client;
|
|||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package fr.gouv.etalab.mastodon.client.Entities;
|
||||
/* Copyright 2018 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 Mastalab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
/**
|
||||
* Created by Thomas on 11/09/2018.
|
||||
* Adapter for Trunk accounts
|
||||
*/
|
||||
public class TrunkAccount {
|
||||
|
||||
private String acct;
|
||||
private boolean isChecked = false;
|
||||
|
||||
public String getAcct() {
|
||||
return acct;
|
||||
}
|
||||
|
||||
public void setAcct(String acct) {
|
||||
this.acct = acct;
|
||||
}
|
||||
|
||||
|
||||
public boolean isChecked() {
|
||||
return isChecked;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
isChecked = checked;
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ package fr.gouv.etalab.mastodon.drawers;
|
|||
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -25,6 +26,7 @@ import android.widget.TextView;
|
|||
import java.util.List;
|
||||
import fr.gouv.etalab.mastodon.R;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.TrunkAccount;
|
||||
import fr.gouv.etalab.mastodon.helper.CrossActions;
|
||||
|
||||
|
||||
|
@ -34,11 +36,11 @@ import fr.gouv.etalab.mastodon.helper.CrossActions;
|
|||
*/
|
||||
public class WhoToFollowAccountsAdapter extends BaseAdapter {
|
||||
|
||||
private List<String> lists;
|
||||
private List<TrunkAccount> lists;
|
||||
private LayoutInflater layoutInflater;
|
||||
private Context context;
|
||||
|
||||
public WhoToFollowAccountsAdapter(Context context, List<String> lists){
|
||||
public WhoToFollowAccountsAdapter(Context context, List<TrunkAccount> lists){
|
||||
this.lists = lists;
|
||||
layoutInflater = LayoutInflater.from(context);
|
||||
this.context = context;
|
||||
|
@ -63,25 +65,35 @@ public class WhoToFollowAccountsAdapter extends BaseAdapter {
|
|||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
|
||||
String item = lists.get(position);
|
||||
TrunkAccount trunkAccount = lists.get(position);
|
||||
final ViewHolder holder;
|
||||
if (convertView == null) {
|
||||
convertView = layoutInflater.inflate(R.layout.drawer_who_to_follow_account, parent, false);
|
||||
holder = new ViewHolder();
|
||||
holder.account_to_follow_check = convertView.findViewById(R.id.account_to_follow_check);
|
||||
holder.account_to_follow = convertView.findViewById(R.id.account_to_follow);
|
||||
holder.account_to_follow = convertView.findViewById(R.id.account_to_follow);
|
||||
holder.account_to_follow_profile = convertView.findViewById(R.id.account_to_follow_profile);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
holder.account_to_follow.setText(item);
|
||||
holder.account_to_follow.setText(trunkAccount.getAcct());
|
||||
|
||||
holder.account_to_follow_check.setChecked(trunkAccount.isChecked());
|
||||
holder.account_to_follow.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
trunkAccount.setChecked(!trunkAccount.isChecked());
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
||||
holder.account_to_follow_profile.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Account account = new Account();
|
||||
String[] val = item.split("@");
|
||||
String[] val = trunkAccount.getAcct().split("@");
|
||||
if( val.length > 1){
|
||||
account.setAcct(val[0]);
|
||||
account.setInstance(val[1]);
|
||||
|
@ -97,6 +109,7 @@ public class WhoToFollowAccountsAdapter extends BaseAdapter {
|
|||
private class ViewHolder {
|
||||
CheckBox account_to_follow_check;
|
||||
TextView account_to_follow;
|
||||
FloatingActionButton account_to_follow_profile;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import android.os.AsyncTask;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -34,6 +33,7 @@ import java.util.List;
|
|||
|
||||
import fr.gouv.etalab.mastodon.R;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.WhoToFollowAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.TrunkAccount;
|
||||
import fr.gouv.etalab.mastodon.drawers.WhoToFollowAdapter;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveWhoToFollowInterface;
|
||||
|
@ -49,13 +49,14 @@ public class WhoToFollowFragment extends Fragment implements OnRetrieveWhoToFoll
|
|||
|
||||
private Context context;
|
||||
private View rootView;
|
||||
private RelativeLayout mainLoader;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
rootView = inflater.inflate(R.layout.fragment_who_to_follow, container, false);
|
||||
context = getContext();
|
||||
RelativeLayout mainLoader = rootView.findViewById(R.id.loader);
|
||||
mainLoader = rootView.findViewById(R.id.loader);
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String lastDateListRefresh = sharedpreferences.getString(Helper.LAST_DATE_LIST_REFRESH, null);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
@ -86,22 +87,9 @@ public class WhoToFollowFragment extends Fragment implements OnRetrieveWhoToFoll
|
|||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRetrieveWhoToFollow(List<String> list) {
|
||||
|
||||
if( list != null){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.LAST_DATE_LIST_REFRESH, Helper.dateToString(new Date()));
|
||||
editor.putString(Helper.LAST_LIST, Helper.arrayToStringStorage(list));
|
||||
editor.apply();
|
||||
}
|
||||
displayResults(list);
|
||||
}
|
||||
|
||||
private void displayResults(List<String> list){
|
||||
|
||||
RelativeLayout mainLoader = rootView.findViewById(R.id.loader);
|
||||
mainLoader.setVisibility(View.GONE);
|
||||
if( list != null){
|
||||
ListView lv_list = rootView.findViewById(R.id.lv_list);
|
||||
|
@ -112,4 +100,19 @@ public class WhoToFollowFragment extends Fragment implements OnRetrieveWhoToFoll
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRetrieveWhoToFollowList(List<String> list) {
|
||||
if( list != null){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.LAST_DATE_LIST_REFRESH, Helper.dateToString(new Date()));
|
||||
editor.putString(Helper.LAST_LIST, Helper.arrayToStringStorage(list));
|
||||
editor.apply();
|
||||
}
|
||||
displayResults(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRetrieveWhoToFollowAccount(List<TrunkAccount> trunkAccounts) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,10 +17,13 @@ package fr.gouv.etalab.mastodon.interfaces;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import fr.gouv.etalab.mastodon.client.Entities.TrunkAccount;
|
||||
|
||||
/**
|
||||
* Created by Thomas on 10/09/2018.
|
||||
* Interface for who to follow
|
||||
*/
|
||||
public interface OnRetrieveWhoToFollowInterface {
|
||||
void onRetrieveWhoToFollow(List<String> list);
|
||||
void onRetrieveWhoToFollowList(List<String> list);
|
||||
void onRetrieveWhoToFollowAccount(List<TrunkAccount> trunkAccounts);
|
||||
}
|
||||
|
|
|
@ -92,23 +92,36 @@
|
|||
android:indeterminate="true" />
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
<Button
|
||||
android:id="@+id/follow_accounts_select"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:gravity="center"
|
||||
style="@style/Base.Widget.AppCompat.Button.Colored"
|
||||
android:text="@string/select_all"
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/follow_accounts"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:orientation="horizontal">
|
||||
<Button
|
||||
android:id="@+id/follow_accounts_select"
|
||||
android:gravity="center"
|
||||
style="@style/Base.Widget.AppCompat.Button.Colored"
|
||||
android:text="@string/select_all"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/follow_accounts"
|
||||
android:gravity="center"
|
||||
style="@style/Base.Widget.AppCompat.Button.Colored"
|
||||
android:text="@string/follow_account"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/progess_action"
|
||||
android:visibility="gone"
|
||||
android:background="?colorPrimaryDark"
|
||||
android:layout_gravity="bottom"
|
||||
android:gravity="center"
|
||||
style="@style/Base.Widget.AppCompat.Button.Colored"
|
||||
android:text="@string/follow_account"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp" />
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
</android.support.v4.widget.DrawerLayout>
|
|
@ -18,6 +18,8 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/search_container"
|
||||
android:divider="?android:dividerHorizontal"
|
||||
android:showDividers="end"
|
||||
|
@ -43,4 +45,13 @@
|
|||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp" />
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:layout_width="30dp"
|
||||
app:fabSize="mini"
|
||||
android:layout_margin="5dp"
|
||||
android:id="@+id/account_to_follow_profile"
|
||||
app:backgroundTint="?colorAccent"
|
||||
app:srcCompat="@drawable/ic_remove_red_eye"
|
||||
tools:ignore="VectorDrawableCompat"
|
||||
android:layout_height="30dp"/>
|
||||
</LinearLayout>
|
|
@ -590,6 +590,11 @@
|
|||
<string name="follow_account">Follow</string>
|
||||
<string name="select_all">Select all</string>
|
||||
<string name="unselect_all">Unselect all</string>
|
||||
<string name="follow_trunk">%s is followed!</string>
|
||||
<string name="create_list_trunk">Creating the list %s</string>
|
||||
<string name="add_account_list_trunk">Adding accounts to the list</string>
|
||||
<string name="account_added_list_trunk">Accounts were added to the list</string>
|
||||
<string name="adding_account_list_trunk">Adding accounts to the list</string>
|
||||
|
||||
|
||||
<string-array translatable="false" name="proxy_type_choice">
|
||||
|
|
Loading…
Reference in New Issue