Merged in remote_follow (pull request #71)

Remote follow
This commit is contained in:
tom79 2017-08-22 16:25:28 +00:00
commit 6d98f0131e
19 changed files with 849 additions and 1 deletions

View File

@ -33,4 +33,5 @@ dependencies {
compile 'com.evernote:android-job:1.1.11'
compile 'com.github.chrisbanes:PhotoView:2.0.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'org.jsoup:jsoup:1.10.3'
}

View File

@ -90,6 +90,11 @@
android:launchMode="singleTask"
android:noHistory="true"
/>
<activity android:name="fr.gouv.etalab.mastodon.activities.RemoteFollowActivity"
android:windowSoftInputMode="stateAlwaysHidden"
android:configChanges="orientation|screenSize"
android:label="@string/app_name"
/>
<activity android:name="fr.gouv.etalab.mastodon.activities.SearchResultActivity"
android:windowSoftInputMode="stateAlwaysHidden"
android:configChanges="orientation|screenSize"

View File

@ -755,6 +755,11 @@ public class MainActivity extends AppCompatActivity
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if( id == R.id.nav_remote_follow){
Intent remoteFollow = new Intent(getApplicationContext(), RemoteFollowActivity.class);
startActivity(remoteFollow);
return false;
}
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
unCheckAllMenuItems(navigationView);
item.setChecked(true);

View File

@ -0,0 +1,281 @@
/* Copyright 2017 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>. */
package fr.gouv.etalab.mastodon.activities;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import cz.msebera.android.httpclient.Header;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRemoteAccountsAsyncTask;
import fr.gouv.etalab.mastodon.client.Entities.Account;
import fr.gouv.etalab.mastodon.client.KinrarClient;
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
import fr.gouv.etalab.mastodon.drawers.AccountSearchWebAdapter;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRemoteAccountInterface;
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
import mastodon.etalab.gouv.fr.mastodon.R;
/**
* Created by Thomas on 22/08/2017.
* Remote follow activity class
*/
public class RemoteFollowActivity extends AppCompatActivity implements OnRetrieveRemoteAccountInterface {
private ImageView pp_actionBar;
private AutoCompleteTextView rf_instance;
private EditText rf_username;
private TextView rf_no_result;
private Button rf_search;
private ListView lv_account;
private RelativeLayout loader;
private boolean isLoadingInstance;
private String instance_name, screen_name;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
if( theme == Helper.THEME_LIGHT){
setTheme(R.style.AppTheme);
}else {
setTheme(R.style.AppThemeDark);
}
setContentView(R.layout.activity_remote_follow);
rf_instance = (AutoCompleteTextView) findViewById(R.id.rf_instance);
rf_username = (EditText) findViewById(R.id.rf_username);
rf_search = (Button) findViewById(R.id.rf_search);
loader = (RelativeLayout) findViewById(R.id.loader);
lv_account = (ListView) findViewById(R.id.lv_account);
rf_no_result = (TextView) findViewById(R.id.rf_no_result);
isLoadingInstance = false;
ActionBar actionBar = getSupportActionBar();
if( actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(android.content.Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.conversation_action_bar, null);
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
TextView title = (TextView) actionBar.getCustomView().findViewById(R.id.toolbar_title);
pp_actionBar = (ImageView) actionBar.getCustomView().findViewById(R.id.pp_actionBar);
title.setText(R.string.remote_follow_menu);
ImageView close_conversation = (ImageView) actionBar.getCustomView().findViewById(R.id.close_conversation);
if( close_conversation != null){
close_conversation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
}else{
setTitle(R.string.remote_follow_menu);
}
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
Account account = new AccountDAO(getApplicationContext(),db).getAccountByID(userId);
String url = account.getAvatar();
if( url.startsWith("/") ){
url = "https://" + Helper.getLiveInstance(getApplicationContext()) + account.getAvatar();
}
ImageLoader imageLoader = ImageLoader.getInstance();
File cacheDir = new File(getCacheDir(), getString(R.string.app_name));
ImageLoaderConfiguration configImg = new ImageLoaderConfiguration.Builder(this)
.imageDownloader(new PatchBaseImageDownloader(getApplicationContext()))
.threadPoolSize(5)
.threadPriority(Thread.MIN_PRIORITY + 3)
.denyCacheImageMultipleSizesInMemory()
.diskCache(new UnlimitedDiskCache(cacheDir))
.build();
imageLoader.init(configImg);
DisplayImageOptions options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
imageLoader.loadImage(url, options, new SimpleImageLoadingListener(){
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
super.onLoadingComplete(imageUri, view, loadedImage);
BitmapDrawable ppDrawable = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(loadedImage, (int) Helper.convertDpToPixel(25, getApplicationContext()), (int) Helper.convertDpToPixel(25, getApplicationContext()), true));
if( pp_actionBar != null){
pp_actionBar.setImageDrawable(ppDrawable);
} else if( getSupportActionBar() != null){
getSupportActionBar().setIcon(ppDrawable);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason){
}});
rf_instance.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if( s.length() > 2 && !isLoadingInstance && 1 ==2){
String action = "/instances/search";
RequestParams parameters = new RequestParams();
parameters.add("q", s.toString().trim());
parameters.add("count", String.valueOf(10));
parameters.add("name", String.valueOf(true));
isLoadingInstance = true;
new KinrarClient().get(action, parameters, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
isLoadingInstance = false;
String response = new String(responseBody);
String[] instances;
try {
JSONObject jsonObject = new JSONObject(response);
JSONArray jsonArray = jsonObject.getJSONArray("instances");
if( jsonArray != null){
instances = new String[jsonArray.length()];
for(int i = 0 ; i < jsonArray.length() ; i++){
instances[i] = jsonArray.getJSONObject(i).get("name").toString();
}
}else {
instances = new String[]{};
}
rf_instance.setAdapter(null);
ArrayAdapter<String> adapter =
new ArrayAdapter<>(RemoteFollowActivity.this, android.R.layout.simple_list_item_1, instances);
rf_instance.setAdapter(adapter);
if( rf_instance.hasFocus() && !RemoteFollowActivity.this.isFinishing())
rf_instance.showDropDown();
} catch (JSONException ignored) {isLoadingInstance = false;}
}
@Override
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
isLoadingInstance = false;
}
});
}
}
});
rf_search.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if( rf_instance.getText().toString().trim().equals("") || rf_username.getText().toString().trim().equals("")){
Toast.makeText(getApplicationContext(),R.string.toast_empty_search,Toast.LENGTH_LONG).show();
return;
}
rf_search.setEnabled(false);
screen_name = rf_username.getText().toString().trim();
instance_name = rf_instance.getText().toString().trim();
lv_account.setVisibility(View.GONE);
loader.setVisibility(View.VISIBLE);
rf_no_result.setVisibility(View.GONE);
if( screen_name.startsWith("@"))
screen_name = screen_name.substring(1);
new RetrieveRemoteAccountsAsyncTask(screen_name, instance_name, RemoteFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onRetrieveRemoteAccount(boolean error, String name, String username, boolean locked, String avatar, String bio, int statusCount, int followingCount, int followersCount) {
loader.setVisibility(View.GONE);
if( error){
rf_no_result.setVisibility(View.VISIBLE);
Toast.makeText(getApplicationContext(), R.string.toast_error,Toast.LENGTH_LONG).show();
return;
}
Account account = new Account();
account.setInstance(instance_name);
account.setAcct(screen_name + "@" + instance_name);
account.setAvatar(avatar);
account.setDisplay_name(username);
account.setStatuses_count(statusCount);
account.setFollowers_count(followersCount);
account.setFollowing_count(followingCount);
account.setUsername(name);
account.setLocked(locked);
account.setNote(bio);
List<Account> selectedAccount = new ArrayList<>();
selectedAccount.add(account);
AccountSearchWebAdapter accountSearchWebAdapter = new AccountSearchWebAdapter(RemoteFollowActivity.this, selectedAccount);
lv_account.setAdapter(accountSearchWebAdapter);
lv_account.setVisibility(View.VISIBLE);
}
}

View File

@ -0,0 +1,78 @@
/* Copyright 2017 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>. */
package fr.gouv.etalab.mastodon.asynctasks;
import android.os.AsyncTask;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import java.io.IOException;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRemoteAccountInterface;
/**
* Created by Thomas on 22/07/2017.
* Retrieves a remote account via its webpage
*/
public class RetrieveRemoteAccountsAsyncTask extends AsyncTask<Void, Void, Void> {
private OnRetrieveRemoteAccountInterface listener;
private String url;
private String avatar, name, username, bio;
private int statusCount, followingCount, followersCount;
private boolean islocked;
private boolean error = false;
private String instance;
public RetrieveRemoteAccountsAsyncTask(String username, String instance, OnRetrieveRemoteAccountInterface onRetrieveRemoteAccountInterface){
this.url = "https://" + instance + "/@" + username;
this.listener = onRetrieveRemoteAccountInterface;
this.instance = instance;
}
@Override
protected Void doInBackground(Void... params) {
String userAgent = "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36";
try {
Document document = Jsoup.connect(url).userAgent(userAgent).get();
Elements avatarElement = document.getElementsByClass("avatar");
avatar = avatarElement.get(0).getElementsByClass("u-photo").get(0).attr("src");
avatar = "https://" + instance + avatar;
Elements nameElement = document.getElementsByClass("name");
name = nameElement.get(0).getElementsByClass("p-name").get(0).html();
username = nameElement.get(0).getElementsByTag("span").get(1).html();
islocked = nameElement.get(0).getElementsByClass("fa-lock") != null;
Elements bioElement = document.getElementsByClass("bio");
bio = bioElement.get(0).html();;
Elements countElement = document.getElementsByClass("counter-number");
statusCount = Integer.parseInt(countElement.get(0).html());
followingCount = Integer.parseInt(countElement.get(1).html());
followersCount = Integer.parseInt(countElement.get(2).html());
} catch (IOException | IndexOutOfBoundsException e) {
error = true;
}
return null;
}
@Override
protected void onPostExecute(Void result) {
listener.onRetrieveRemoteAccount(error, name, username, islocked, avatar, bio, statusCount, followingCount, followersCount);
}
}

View File

@ -92,7 +92,8 @@ public class API {
UNSTATUS,
AUTHORIZE,
REJECT,
REPORT
REPORT,
REMOTE_FOLLOW
}
public API(Context context) {
@ -814,6 +815,11 @@ public class API {
case FOLLOW:
action = String.format("/accounts/%s/follow", targetedId);
break;
case REMOTE_FOLLOW:
action = "/follows";
params = new RequestParams();
params.put("uri", targetedId);
break;
case UNFOLLOW:
action = String.format("/accounts/%s/unfollow", targetedId);
break;

View File

@ -0,0 +1,191 @@
package fr.gouv.etalab.mastodon.drawers;
/* Copyright 2017 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>. */
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Build;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.text.Html;
import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
import java.io.File;
import java.util.List;
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
import fr.gouv.etalab.mastodon.client.API;
import fr.gouv.etalab.mastodon.client.Entities.Account;
import fr.gouv.etalab.mastodon.client.Entities.Error;
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
import mastodon.etalab.gouv.fr.mastodon.R;
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
/**
* Created by Thomas on 22/08/2017.
* Adapter for accounts from web
*/
public class AccountSearchWebAdapter extends BaseAdapter implements OnPostActionInterface {
private List<Account> accounts;
private LayoutInflater layoutInflater;
private Context context;
private ViewHolder holder;
public AccountSearchWebAdapter(Context context, List<Account> accounts){
this.context = context;
this.accounts = accounts;
layoutInflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return accounts.size();
}
@Override
public Object getItem(int position) {
return accounts.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ImageLoader imageLoader = ImageLoader.getInstance();
File cacheDir = new File(context.getCacheDir(), context.getString(R.string.app_name));
ImageLoaderConfiguration configImg = new ImageLoaderConfiguration.Builder(context)
.imageDownloader(new PatchBaseImageDownloader(context))
.threadPoolSize(5)
.threadPriority(Thread.MIN_PRIORITY + 3)
.denyCacheImageMultipleSizesInMemory()
.diskCache(new UnlimitedDiskCache(cacheDir))
.build();
if( !imageLoader.isInited())
imageLoader.init(configImg);
DisplayImageOptions options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false)
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
final Account account = accounts.get(position);
if (convertView == null) {
convertView = layoutInflater.inflate(R.layout.drawer_account_search_html, parent, false);
holder = new ViewHolder();
holder.account_pp = (ImageView) convertView.findViewById(R.id.account_pp);
holder.account_dn = (TextView) convertView.findViewById(R.id.account_dn);
holder.account_un = (TextView) convertView.findViewById(R.id.account_un);
holder.account_ds = (TextView) convertView.findViewById(R.id.account_ds);
holder.account_sc = (TextView) convertView.findViewById(R.id.account_sc);
holder.account_fgc = (TextView) convertView.findViewById(R.id.account_fgc);
holder.account_frc = (TextView) convertView.findViewById(R.id.account_frc);
holder.account_follow = (FloatingActionButton) convertView.findViewById(R.id.account_follow);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
//Redraws icon for locked accounts
final float scale = context.getResources().getDisplayMetrics().density;
if( account != null && account.isLocked()){
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_action_lock_closed);
img.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (20 * scale + 0.5f));
holder.account_dn.setCompoundDrawables( null, null, img, null);
}else{
holder.account_dn.setCompoundDrawables( null, null, null, null);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
holder.account_ds.setText(Html.fromHtml(account.getNote(), Html.FROM_HTML_MODE_LEGACY));
holder.account_dn.setText(Html.fromHtml(Helper.shortnameToUnicode(account.getDisplay_name(), true), Html.FROM_HTML_MODE_LEGACY));
holder.account_un.setText(Html.fromHtml(Helper.shortnameToUnicode(account.getUsername(), true), Html.FROM_HTML_MODE_LEGACY));
}else {
//noinspection deprecation
holder.account_ds.setText(Html.fromHtml(account.getNote()));
holder.account_dn.setText(Html.fromHtml(Helper.shortnameToUnicode(account.getDisplay_name(), true)));
holder.account_un.setText(Html.fromHtml(Helper.shortnameToUnicode(account.getUsername(), true)));
}
changeDrawableColor(context, R.drawable.ic_action_lock_closed,R.color.mastodonC4);
holder.account_ds.setAutoLinkMask(Linkify.WEB_URLS);
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_follow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
holder.account_follow.setEnabled(false);
new PostActionAsyncTask(context, API.StatusAction.REMOTE_FOLLOW, account.getAcct(), AccountSearchWebAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
return convertView;
}
@Override
public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) {
if( error != null){
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean show_error_messages = sharedpreferences.getBoolean(Helper.SET_SHOW_ERROR_MESSAGES, true);
if( show_error_messages)
Toast.makeText(context, error.getError(),Toast.LENGTH_LONG).show();
holder.account_follow.setEnabled(true);
return;
}
holder.account_follow.setVisibility(View.GONE);
Toast.makeText(context, R.string.toast_follow, Toast.LENGTH_LONG).show();
}
private class ViewHolder {
ImageView account_pp;
TextView account_dn;
TextView account_un;
TextView account_ds;
TextView account_sc;
TextView account_fgc;
TextView account_frc;
FloatingActionButton account_follow;
}
}

View File

@ -0,0 +1,24 @@
/* Copyright 2017 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>. */
package fr.gouv.etalab.mastodon.interfaces;
/**
* Created by Thomas on 22/08/2017.
* Interface for retrieving a remote account
*/
public interface OnRetrieveRemoteAccountInterface {
void onRetrieveRemoteAccount(boolean error, String name, String username, boolean locked, String avatar, String bio, int statusCount, int followingCount, int followersCount);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

View File

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2017 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>.
-->
<ScrollView android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/fab_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/fab_margin"
android:paddingRight="@dimen/fab_margin"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<AutoCompleteTextView
android:id="@+id/rf_instance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textWebEmailAddress"
android:hint="@string/instance_example"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:id="@+id/rf_username"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:hint="@string/username"
/>
<Button
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:id="@+id/rf_search"
android:textAllCaps="false"
android:drawableLeft="@drawable/ic_action_search"
android:drawableStart="@drawable/ic_action_search"
android:drawablePadding="5dp"
android:maxLines="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:text="@string/action_search" />
</LinearLayout>
<ListView
android:visibility="gone"
android:layout_marginTop="30dp"
android:id="@+id/lv_account"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:divider="@null"
/>
<TextView
android:visibility="gone"
android:layout_marginTop="30dp"
android:id="@+id/rf_no_result"
android:padding="10dp"
android:gravity="center"
android:textSize="25sp"
android:layout_gravity="center"
android:textStyle="italic|bold"
android:typeface="serif"
android:text="@string/no_accounts"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- Main Loader -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loader"
android:visibility="gone"
android:layout_marginTop="30dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true" />
</RelativeLayout>
</LinearLayout>
</ScrollView>

View File

@ -0,0 +1,142 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2017 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>.
-->
<android.support.v7.widget.CardView 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:card_view="http://schemas.android.com/tools"
style="?attr/cardStyle"
android:layout_marginTop="10dp"
card_view:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true">
<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:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/main_container"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_gravity="center_horizontal"
android:id="@+id/account_pp"
android:layout_margin="10dp"
android:layout_width="60dp"
android:layout_height="60dp"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_marginTop="10dp"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/account_dn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="@+id/account_un"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:layout_gravity="center"
app:fabSize="mini"
android:id="@+id/account_follow"
android:textAllCaps="false"
android:src="@drawable/ic_user_plus"
android:gravity="center"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:layout_width="40dp"
android:layout_height="40dp"
/>
</LinearLayout>
<TextView
android:animateLayoutChanges="true"
android:id="@+id/account_ds"
android:autoLink="web"
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/toots"
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>
</android.support.v7.widget.CardView>

View File

@ -31,6 +31,10 @@
android:id="@+id/nav_scheduled"
android:icon="@drawable/ic_schedule_black"
android:title="@string/scheduled_toots" />
<item
android:id="@+id/nav_remote_follow"
android:icon="@drawable/ic_remote_follow"
android:title="@string/remote_follow_menu" />
<item
android:id="@+id/nav_follow_request"
android:icon="@drawable/ic_group_add"

View File

@ -56,6 +56,7 @@
<string name="share_with">Partager avec</string>
<string name="shared_via">Partagé via Mastalab</string>
<string name="replies">Réponses</string>
<string name="username">Screen name</string>
<!--- Menu -->
<string name="home_menu">Accueil</string>
<string name="local_menu">Fil public local</string>
@ -65,6 +66,7 @@
<string name="communication_menu_title">Communication</string>
<string name="muted_menu">Utilisateurs muets</string>
<string name="blocked_menu">Utilisateurs bloqués</string>
<string name="remote_follow_menu">Suivre à distance</string>
<string name="notifications">Notifications</string>
<string name="follow_request">Demandes d\'abonnements</string>
<string name="optimization">Optimisation</string>
@ -265,6 +267,7 @@
<string name="toast_toot_saved">Brouillon enregistré !</string>
<string name="toast_visibility_changed">La visibilité des pouets a été changée pour le compte %1$s</string>
<string name="toast_error_char_limit">Etes-vous sûr que cette instance autorise ce nombre de caractères ? Habituellement, cette valeur est proche de 500 caractères.</string>
<string name="toast_empty_search">Il faut renseigner une instance et un nom d\'utilisateur !</string>
<!-- Settings -->
<string name="settings_title_optimisation">Optimisation du chargement</string>
<string name="set_toots_page">Nombre de pouets par chargement</string>

View File

@ -58,6 +58,7 @@
<string name="share_with">Share with</string>
<string name="shared_via">Shared via Mastalab</string>
<string name="replies">Replies</string>
<string name="username">Nom d\'utilsateur</string>
<!--- Menu -->
<string name="home_menu">Home</string>
<string name="local_menu">Local timeline</string>
@ -67,6 +68,7 @@
<string name="communication_menu_title">Communication</string>
<string name="muted_menu">Muted users</string>
<string name="blocked_menu">Blocked users</string>
<string name="remote_follow_menu">Remote follow</string>
<string name="notifications">Notifications</string>
<string name="follow_request">Follow requests</string>
<string name="optimization">Optimization</string>
@ -271,6 +273,7 @@
<string name="toast_toot_saved">Draft saved!</string>
<string name="toast_error_char_limit">Are you sure this instance allows this number of characters? Usually, this value is close to 500 characters.</string>
<string name="toast_visibility_changed">Visibility of the toots has been changed for the account %1$s</string>
<string name="toast_empty_search">Instance name and screen name cannot be blank!</string>
<!-- Settings -->
<string name="settings_title_optimisation">Optimisation of loading</string>
<string name="set_toots_page">Number of toots per load</string>