From d8bb009dc3360c93e4995c7492551f3a5781f6d1 Mon Sep 17 00:00:00 2001 From: stom79 Date: Mon, 10 Sep 2018 19:21:42 +0200 Subject: [PATCH] Adds layouts --- app/src/main/AndroidManifest.xml | 5 + .../mastodon/activities/BaseMainActivity.java | 9 +- .../activities/WhoToFollowActivity.java | 123 +++++++++++++++++ .../asynctasks/WhoToFollowAsyncTask.java | 58 ++++++++ .../fr/gouv/etalab/mastodon/client/API.java | 6 +- .../drawers/WhoToFollowAccountsAdapter.java | 103 +++++++++++++++ .../mastodon/drawers/WhoToFollowAdapter.java | 124 ++++++++++++++++++ .../fragments/WhoToFollowFragment.java | 113 ++++++++++++++++ .../gouv/etalab/mastodon/helper/Helper.java | 29 ++++ .../OnRetrieveWhoToFollowInterface.java | 26 ++++ app/src/main/res/drawable-hdpi/ic_people.png | Bin 0 -> 287 bytes app/src/main/res/drawable-ldpi/ic_people.png | Bin 0 -> 342 bytes app/src/main/res/drawable-mdpi/ic_people.png | Bin 0 -> 182 bytes app/src/main/res/drawable-xhdpi/ic_people.png | Bin 0 -> 299 bytes .../main/res/drawable-xxhdpi/ic_people.png | Bin 0 -> 400 bytes .../main/res/drawable-xxxhdpi/ic_people.png | Bin 0 -> 500 bytes .../res/layout/activity_who_to_follow.xml | 95 ++++++++++++++ .../layout/drawer_who_to_follow_account.xml | 46 +++++++ .../res/layout/fragment_who_to_follow.xml | 47 +++++++ .../main/res/menu/activity_main_drawer.xml | 4 + app/src/main/res/values/strings.xml | 1 + 21 files changed, 785 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/fr/gouv/etalab/mastodon/activities/WhoToFollowActivity.java create mode 100644 app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/WhoToFollowAsyncTask.java create mode 100644 app/src/main/java/fr/gouv/etalab/mastodon/drawers/WhoToFollowAccountsAdapter.java create mode 100644 app/src/main/java/fr/gouv/etalab/mastodon/drawers/WhoToFollowAdapter.java create mode 100644 app/src/main/java/fr/gouv/etalab/mastodon/fragments/WhoToFollowFragment.java create mode 100644 app/src/main/java/fr/gouv/etalab/mastodon/interfaces/OnRetrieveWhoToFollowInterface.java create mode 100644 app/src/main/res/drawable-hdpi/ic_people.png create mode 100644 app/src/main/res/drawable-ldpi/ic_people.png create mode 100644 app/src/main/res/drawable-mdpi/ic_people.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_people.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_people.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_people.png create mode 100644 app/src/main/res/layout/activity_who_to_follow.xml create mode 100644 app/src/main/res/layout/drawer_who_to_follow_account.xml create mode 100644 app/src/main/res/layout/fragment_who_to_follow.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 01915eeef..7c6cb7e15 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -161,6 +161,11 @@ android:configChanges="orientation|screenSize" android:label="@string/app_name" /> + . */ +package fr.gouv.etalab.mastodon.activities; + +import android.content.Context; +import android.content.SharedPreferences; +import android.os.AsyncTask; +import android.os.Bundle; +import android.support.v4.content.ContextCompat; +import android.support.v7.widget.Toolbar; +import android.view.View; +import android.widget.ListView; +import android.widget.RelativeLayout; +import android.widget.Toast; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import fr.gouv.etalab.mastodon.R; +import fr.gouv.etalab.mastodon.asynctasks.WhoToFollowAsyncTask; +import fr.gouv.etalab.mastodon.drawers.WhoToFollowAccountsAdapter; +import fr.gouv.etalab.mastodon.helper.Helper; +import fr.gouv.etalab.mastodon.interfaces.OnRetrieveWhoToFollowInterface; + +import static fr.gouv.etalab.mastodon.helper.Helper.THEME_BLACK; + + +/** + * Created by Thomas on 10/09/2018. + * Display Who to follow accounts + */ + +public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoToFollowInterface { + + + + private String item; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); + int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); + switch (theme){ + case Helper.THEME_LIGHT: + setTheme(R.style.AppTheme_NoActionBar); + break; + case Helper.THEME_DARK: + setTheme(R.style.AppThemeDark_NoActionBar); + break; + case Helper.THEME_BLACK: + setTheme(R.style.AppThemeBlack_NoActionBar); + break; + default: + setTheme(R.style.AppThemeDark_NoActionBar); + } + setContentView(R.layout.activity_who_to_follow); + Toolbar toolbar = findViewById(R.id.toolbar); + 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); + Bundle b = getIntent().getExtras(); + if(b != null){ + item = b.getString("item"); + } + String lastDateListNameRefresh = sharedpreferences.getString(Helper.LAST_DATE_LIST_NAME_REFRESH+item, null); + Calendar cal = Calendar.getInstance(); + cal.setTime(new Date( )); + cal.add(Calendar.MINUTE, -5); + Date dateAllowed = cal.getTime(); + if( lastDateListNameRefresh == null || Helper.stringToDate(WhoToFollowActivity.this, lastDateListNameRefresh).after(dateAllowed)) + new WhoToFollowAsyncTask(WhoToFollowActivity.this, item, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + else { + String lastList = sharedpreferences.getString(Helper.LAST_LIST_NAME + item, null); + List list = Helper.restoreArrayFromString(lastList); + displayResults(list); + } + mainLoader.setVisibility(View.VISIBLE); + setTitle(item); + } + + + @Override + public void onRetrieveWhoToFollow(List 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 list){ + + RelativeLayout mainLoader = findViewById(R.id.loader); + mainLoader.setVisibility(View.GONE); + if( list != null){ + ListView lv_list = findViewById(R.id.lv_list); + WhoToFollowAccountsAdapter whoToFollowAccountsAdapter = new WhoToFollowAccountsAdapter(WhoToFollowActivity.this, list); + lv_list.setAdapter(whoToFollowAccountsAdapter); + }else{ + Toast.makeText(WhoToFollowActivity.this, R.string.toast_error, Toast.LENGTH_SHORT).show(); + } + } +} diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/WhoToFollowAsyncTask.java b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/WhoToFollowAsyncTask.java new file mode 100644 index 000000000..3118213a6 --- /dev/null +++ b/app/src/main/java/fr/gouv/etalab/mastodon/asynctasks/WhoToFollowAsyncTask.java @@ -0,0 +1,58 @@ +/* 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 . */ +package fr.gouv.etalab.mastodon.asynctasks; +import android.content.Context; +import android.os.AsyncTask; +import java.lang.ref.WeakReference; +import java.util.List; +import fr.gouv.etalab.mastodon.client.API; +import fr.gouv.etalab.mastodon.interfaces.OnRetrieveWhoToFollowInterface; + + +/** + * Created by Thomas on 10/09/2018. + * Retrieves who to follow list + */ + +public class WhoToFollowAsyncTask extends AsyncTask { + + private String name; + private List response; + private OnRetrieveWhoToFollowInterface listener; + private WeakReference contextReference; + + public WhoToFollowAsyncTask(Context context, String name, OnRetrieveWhoToFollowInterface onRetrieveWhoToFollowInterface){ + this.contextReference = new WeakReference<>(context); + this.name = name; + this.listener = onRetrieveWhoToFollowInterface; + } + + + @Override + protected Void doInBackground(Void... params) { + API api = new API(this.contextReference.get()); + if( name != null) + response = api.getCommunitywikiList(name); + else + response = api.getCommunitywikiList(); + return null; + } + + @Override + protected void onPostExecute(Void result) { + listener.onRetrieveWhoToFollow(response); + } + +} diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java index 0840ad4a7..2954e4850 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/API.java @@ -1893,7 +1893,7 @@ public class API { * Retrieves list from Communitywiki *synchronously* * @return APIResponse */ - private ArrayList getCommunitywikiList() { + public ArrayList getCommunitywikiList() { ArrayList list = new ArrayList<>(); try { HttpsConnection httpsConnection = new HttpsConnection(context); @@ -1923,7 +1923,7 @@ public class API { * Retrieves list from Communitywiki *synchronously* * @return APIResponse */ - private ArrayList getCommunitywikiList(String name) { + public ArrayList getCommunitywikiList(String name) { ArrayList list = new ArrayList<>(); try { name = URLEncoder.encode(name, "UTF-8"); @@ -1935,7 +1935,7 @@ public class API { JSONArray jsonArray = new JSONArray(response); for(int i = 0; i < jsonArray.length(); i++){ try { - list.add(jsonArray.getString(i)); + list.add(jsonArray.getJSONObject(i).getString("acct")); } catch (JSONException ignored) {} } } catch (HttpsConnection.HttpsConnectionException e) { diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/WhoToFollowAccountsAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/WhoToFollowAccountsAdapter.java new file mode 100644 index 000000000..a522d5452 --- /dev/null +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/WhoToFollowAccountsAdapter.java @@ -0,0 +1,103 @@ +package fr.gouv.etalab.mastodon.drawers; +/* 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 . */ + + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.CheckBox; +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.helper.CrossActions; + + +/** + * Created by Thomas on 10/09/2018. + * Adapter for who to follow list + */ +public class WhoToFollowAccountsAdapter extends BaseAdapter { + + private List lists; + private LayoutInflater layoutInflater; + private Context context; + + public WhoToFollowAccountsAdapter(Context context, List lists){ + this.lists = lists; + layoutInflater = LayoutInflater.from(context); + this.context = context; + } + + @Override + public int getCount() { + return lists.size(); + } + + @Override + public Object getItem(int position) { + return lists.get(position); + } + + @Override + public long getItemId(int position) { + return position; + } + + + @Override + public View getView(final int position, View convertView, ViewGroup parent) { + + String item = 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 = convertView.findViewById(R.id.account_to_follow); + holder.account_to_follow = convertView.findViewById(R.id.account_to_follow); + convertView.setTag(holder); + } else { + holder = (ViewHolder) convertView.getTag(); + } + + holder.account_to_follow.setText(item); + + holder.account_to_follow.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Account account = new Account(); + String[] val = item.split("@"); + if( val.length > 1){ + account.setAcct(val[0]); + account.setInstance(val[1]); + CrossActions.doCrossProfile(context, account); + } + } + }); + + return convertView; + } + + + private class ViewHolder { + CheckBox account_to_follow_check; + TextView account_to_follow; + } + + +} \ No newline at end of file diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/WhoToFollowAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/WhoToFollowAdapter.java new file mode 100644 index 000000000..6260b7090 --- /dev/null +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/WhoToFollowAdapter.java @@ -0,0 +1,124 @@ +package fr.gouv.etalab.mastodon.drawers; +/* 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 . */ + + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.support.v4.content.ContextCompat; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.LinearLayout; +import android.widget.TextView; +import java.util.List; +import fr.gouv.etalab.mastodon.R; +import fr.gouv.etalab.mastodon.activities.WhoToFollowActivity; +import fr.gouv.etalab.mastodon.helper.Helper; +import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor; + + +/** + * Created by Thomas on 10/09/2018. + * Adapter for who to follow list + */ +public class WhoToFollowAdapter extends BaseAdapter { + + private List lists; + private LayoutInflater layoutInflater; + private Context context; + + public WhoToFollowAdapter(Context context, List lists){ + this.lists = lists; + layoutInflater = LayoutInflater.from(context); + this.context = context; + } + + @Override + public int getCount() { + return lists.size(); + } + + @Override + public Object getItem(int position) { + return lists.get(position); + } + + @Override + public long getItemId(int position) { + return position; + } + + + @Override + public View getView(final int position, View convertView, ViewGroup parent) { + + String item = lists.get(position); + final ViewHolder holder; + if (convertView == null) { + convertView = layoutInflater.inflate(R.layout.drawer_search, parent, false); + holder = new ViewHolder(); + holder.search_title = convertView.findViewById(R.id.search_keyword); + holder.search_container = convertView.findViewById(R.id.search_container); + convertView.setTag(holder); + } else { + holder = (ViewHolder) convertView.getTag(); + } + SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); + int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); + + if( theme == Helper.THEME_LIGHT){ + holder.search_container.setBackgroundResource(R.color.mastodonC3__); + changeDrawableColor(context, R.drawable.ic_keyboard_arrow_right,R.color.black); + }else if(theme == Helper.THEME_DARK){ + holder.search_container.setBackgroundResource(R.color.mastodonC1_); + changeDrawableColor(context, R.drawable.ic_keyboard_arrow_right,R.color.dark_text); + }else if(theme == Helper.THEME_BLACK) { + holder.search_container.setBackgroundResource(R.color.black_2); + changeDrawableColor(context, R.drawable.ic_keyboard_arrow_right,R.color.dark_text); + } + Drawable next = ContextCompat.getDrawable(context, R.drawable.ic_keyboard_arrow_right); + holder.search_title.setText(item); + assert next != null; + final float scale = context.getResources().getDisplayMetrics().density; + next.setBounds(0,0,(int) (30 * scale + 0.5f),(int) (30 * scale + 0.5f)); + holder.search_title.setCompoundDrawables(null, null, next, null); + + holder.search_container.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(context, WhoToFollowActivity.class); + Bundle b = new Bundle(); + b.putString("item", item); + intent.putExtras(b); + context.startActivity(intent); + } + }); + + return convertView; + } + + + private class ViewHolder { + LinearLayout search_container; + TextView search_title; + } + + +} \ No newline at end of file diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/WhoToFollowFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/WhoToFollowFragment.java new file mode 100644 index 000000000..6f0e146fa --- /dev/null +++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/WhoToFollowFragment.java @@ -0,0 +1,113 @@ +package fr.gouv.etalab.mastodon.fragments; +/* 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 . */ + +import android.content.Context; +import android.content.SharedPreferences; +import android.os.AsyncTask; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ListView; +import android.widget.RelativeLayout; +import android.widget.Toast; + +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import fr.gouv.etalab.mastodon.R; +import fr.gouv.etalab.mastodon.asynctasks.WhoToFollowAsyncTask; +import fr.gouv.etalab.mastodon.drawers.WhoToFollowAdapter; +import fr.gouv.etalab.mastodon.helper.Helper; +import fr.gouv.etalab.mastodon.interfaces.OnRetrieveWhoToFollowInterface; + + + +/** + * Created by Thomas on 10/09/2018. + * Fragment to display who to follow list + */ +public class WhoToFollowFragment extends Fragment implements OnRetrieveWhoToFollowInterface { + + + private Context context; + private View rootView; + + @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); + SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); + String lastDateListRefresh = sharedpreferences.getString(Helper.LAST_DATE_LIST_REFRESH, null); + Calendar cal = Calendar.getInstance(); + cal.setTime(new Date( )); + cal.add(Calendar.MINUTE, -15); + Date dateAllowed = cal.getTime(); + if( lastDateListRefresh == null || Helper.stringToDate(context, lastDateListRefresh).after(dateAllowed)) + new WhoToFollowAsyncTask(context, null, WhoToFollowFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + else { + String lastList = sharedpreferences.getString(Helper.LAST_LIST, null); + List list = Helper.restoreArrayFromString(lastList); + displayResults(list); + } + mainLoader.setVisibility(View.VISIBLE); + return rootView; + } + + @Override + public void onCreate(Bundle saveInstance) + { + super.onCreate(saveInstance); + } + + @Override + public void onAttach(Context context) { + super.onAttach(context); + this.context = context; + } + + @Override + public void onRetrieveWhoToFollow(List 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 list){ + + RelativeLayout mainLoader = rootView.findViewById(R.id.loader); + mainLoader.setVisibility(View.GONE); + if( list != null){ + ListView lv_list = rootView.findViewById(R.id.lv_list); + WhoToFollowAdapter whoToFollowAdapter = new WhoToFollowAdapter(context, list); + lv_list.setAdapter(whoToFollowAdapter); + }else{ + Toast.makeText(context, R.string.toast_error, Toast.LENGTH_SHORT).show(); + } + } + +} diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java index 5ac2a9277..dd767f65a 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java @@ -217,6 +217,11 @@ public class Helper { public static final String SEARCH_URL = "search_url"; public static final String CLIP_BOARD = "clipboard"; public static final String INSTANCE_NAME = "instance_name"; + public static final String LAST_DATE_LIST_REFRESH = "last_date_list_refresh"; + public static final String LAST_DATE_LIST_NAME_REFRESH = "last_date_list_name_refresh"; + public static final String LAST_LIST = "last_list"; + public static final String LAST_LIST_NAME = "last_list_name"; + //Notifications public static final int NOTIFICATION_INTENT = 1; public static final int HOME_TIMELINE_INTENT = 2; @@ -1657,6 +1662,30 @@ public class Helper { } + /** + * Serialized a List + * @param list List to serialize + * @return String serialized List + */ + public static String arrayToStringStorage(List list){ + Gson gson = new Gson(); + return gson.toJson(list); + } + + /** + * Unserialized a List + * @param serializedArray String serialized array + * @return List list + */ + public static List restoreArrayFromString(String serializedArray){ + Gson gson = new Gson(); + try { + return gson.fromJson(serializedArray, List.class); + }catch (Exception e){ + return null; + } + } + /** * Serialized an Application class * @param application Application to serialize diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/interfaces/OnRetrieveWhoToFollowInterface.java b/app/src/main/java/fr/gouv/etalab/mastodon/interfaces/OnRetrieveWhoToFollowInterface.java new file mode 100644 index 000000000..811b9b09b --- /dev/null +++ b/app/src/main/java/fr/gouv/etalab/mastodon/interfaces/OnRetrieveWhoToFollowInterface.java @@ -0,0 +1,26 @@ +/* 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 . */ +package fr.gouv.etalab.mastodon.interfaces; + + +import java.util.List; + +/** + * Created by Thomas on 10/09/2018. + * Interface for who to follow + */ +public interface OnRetrieveWhoToFollowInterface { + void onRetrieveWhoToFollow(List list); +} diff --git a/app/src/main/res/drawable-hdpi/ic_people.png b/app/src/main/res/drawable-hdpi/ic_people.png new file mode 100644 index 0000000000000000000000000000000000000000..daae683dc968d4c0825373b23809a1b153972770 GIT binary patch literal 287 zcmV+)0pR|LP)D%8y3_I8AFpvU4(e%f>wrv=;W^ySDpz_=14`X*$Uv-FsZx(4Ihsn& zl*Ff-6oySrp@S8K6zpIro#HImK?0)f;Ob;=K)Q;TVHZXBf*?9Nb?eZJ$kKMwDIE$5 zYL}$XTfP)Ur#A3#&U?;#PQLsk692gz#}P+hgJo)#(W>tc_`ZJ}1VJ83f%t&PU8gb|yI#Iey@RFZFd$kI`0YV(-9!JRV1 zJM;tw>c`I-51n8-W!oi`$+Of_#5DREu9VC7JH(bIjUF3^FeQJ42k_9ML*B)A|1%Ip zQJLZ!tY8CQu!aRZK@DDve#c+YPzy1G&jY+d-3))ohrg|%ETRgx2dHqYGhzX5}1CrBK5Q2*fn^#AdH zzO!#`{=fg<|5x=4%N9-l@A$xS#$Ty3b)73;uufVOp74#^$MxU;`OFLTr|@pN)z9P3 z{rCKj{eS*@D#U!Vf4g5HK!xpKn?~o4|3B@GetfZiWB>U7Wdk!8!Bs*VL;|*m9%R!z i#MH2em*d+6RtBLnizSk;&UgcK2!p4qpUXO@geCyr4NsE* literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_people.png b/app/src/main/res/drawable-xhdpi/ic_people.png new file mode 100644 index 0000000000000000000000000000000000000000..15d22bb1a9255ba9abfe08e0c25e579bcb26ef13 GIT binary patch literal 299 zcmV+`0o4A9P)51C5gef^Sg^v5V_0$)?jW&aTPb=5v0~vMt^O_LHR;coVcHHM5$XFST|D#7 zlV)ZLg*^_tWOOOb&%Nq0I+$RFIhiTO zXrsie_Qd>AGQ^5G(EEWeF^C#PEJU1@v~WOL_GkvZ3eF-PYx)n*O%xa1pgR)tP;`P! xjzPC7=Aq~+CAvoK1TI=iNK*UrqC9#2E;knCZq?IJKYRcH002ovPDHLkV1h$|fb;+W literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_people.png b/app/src/main/res/drawable-xxhdpi/ic_people.png new file mode 100644 index 0000000000000000000000000000000000000000..00da6757331ab6900fe430ca1dad08c004089d33 GIT binary patch literal 400 zcmV;B0dM|^P)mx*E;Lm`a_q{Am?#IFE!nXvs~Cf-0jDNAc4cj2P$%GYWyh|pJIJzY zW6)Jn$F8hw3@Rmc?8ax$L;&N9wY7 uFXLEtT=5@x83(eXW&JBt6h%>#e)A3E)MK$MiK{gL0000N5CM&G zk@!1Pxx4HzzMX+kyl+ds_s^dRWM+xQ7=~dOhG9k#j3JEzYUsd)gFI4peQKQ*R1oAI zOSXJ!odiA*MjM+peERN$$4gpRH1+AO=HsZTGojCW;x z6APw(luB{M5-n`l@T2WgxhKA;J}9Yvv{Jh`#|ys1^NcejZTk$vjLsX`H1?3i1xl!k z_lB-`+Tt2k6hG>$_++ZjWJZ|yzppDYA;wQo)gG2r9E&4$TyZ1+r1&S_7heA_K ztc4^c6?aI59}A5rBPt~%dh!lvzJGWgS1{!gbAi-rn(y7425j((?ZCV255@nx>vdoY z7dyV}8=5aiX7L7_G%({y->3O< + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/drawer_who_to_follow_account.xml b/app/src/main/res/layout/drawer_who_to_follow_account.xml new file mode 100644 index 000000000..9d488a824 --- /dev/null +++ b/app/src/main/res/layout/drawer_who_to_follow_account.xml @@ -0,0 +1,46 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_who_to_follow.xml b/app/src/main/res/layout/fragment_who_to_follow.xml new file mode 100644 index 000000000..426fc13e9 --- /dev/null +++ b/app/src/main/res/layout/fragment_who_to_follow.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/menu/activity_main_drawer.xml b/app/src/main/res/menu/activity_main_drawer.xml index 061771842..ab9d3dbf2 100644 --- a/app/src/main/res/menu/activity_main_drawer.xml +++ b/app/src/main/res/menu/activity_main_drawer.xml @@ -39,6 +39,10 @@ android:id="@+id/nav_follow_request" android:icon="@drawable/ic_group_add" android:title="@string/follow_request" /> + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d5629df8d..a847e1a8a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -585,6 +585,7 @@ Delete filter? Update filter Create filter + Who to follow