Put back works for groups
This commit is contained in:
parent
3139de2e4d
commit
d660ebc07d
|
@ -326,6 +326,11 @@
|
||||||
android:configChanges="orientation|screenSize"
|
android:configChanges="orientation|screenSize"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
/>
|
/>
|
||||||
|
<activity android:name="app.fedilab.android.activities.GroupActivity"
|
||||||
|
android:windowSoftInputMode="stateAlwaysHidden"
|
||||||
|
android:configChanges="orientation|screenSize"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
/>
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="${applicationId}.fileProvider"
|
android:authorities="${applicationId}.fileProvider"
|
||||||
|
|
|
@ -1820,6 +1820,14 @@ public abstract class BaseMainActivity extends BaseActivity
|
||||||
fragmentTag = "LISTS";
|
fragmentTag = "LISTS";
|
||||||
fragmentManager.beginTransaction()
|
fragmentManager.beginTransaction()
|
||||||
.replace(R.id.main_app_container, displayListsFragment, fragmentTag).commit();
|
.replace(R.id.main_app_container, displayListsFragment, fragmentTag).commit();
|
||||||
|
}else if(id == R.id.nav_group){
|
||||||
|
toot.hide();
|
||||||
|
accountsFragment = new DisplayAccountsFragment();
|
||||||
|
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.GROUPS);
|
||||||
|
accountsFragment.setArguments(bundle);
|
||||||
|
fragmentTag = "GROUPS";
|
||||||
|
fragmentManager.beginTransaction()
|
||||||
|
.replace(R.id.main_app_container, accountsFragment, fragmentTag).commit();
|
||||||
}else if(id == R.id.nav_peertube_playlists){
|
}else if(id == R.id.nav_peertube_playlists){
|
||||||
toot.hide();
|
toot.hide();
|
||||||
DisplayPlaylistsFragment displayPlaylistsFragment = new DisplayPlaylistsFragment();
|
DisplayPlaylistsFragment displayPlaylistsFragment = new DisplayPlaylistsFragment();
|
||||||
|
|
|
@ -0,0 +1,208 @@
|
||||||
|
/* Copyright 2019 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of Fedilab
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Fedilab 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 Fedilab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
package app.fedilab.android.activities;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
import app.fedilab.android.R;
|
||||||
|
import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask;
|
||||||
|
import app.fedilab.android.client.APIResponse;
|
||||||
|
import app.fedilab.android.client.Entities.Status;
|
||||||
|
import app.fedilab.android.drawers.StatusListAdapter;
|
||||||
|
import app.fedilab.android.helper.Helper;
|
||||||
|
import app.fedilab.android.interfaces.OnRetrieveFeedsInterface;
|
||||||
|
import es.dmoral.toasty.Toasty;
|
||||||
|
|
||||||
|
import static app.fedilab.android.helper.Helper.THEME_BLACK;
|
||||||
|
import static app.fedilab.android.helper.Helper.THEME_LIGHT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Thomas on 22/02/2019.
|
||||||
|
* Show group timeline
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class GroupActivity extends BaseActivity implements OnRetrieveFeedsInterface {
|
||||||
|
|
||||||
|
|
||||||
|
public static int position;
|
||||||
|
private StatusListAdapter statusListAdapter;
|
||||||
|
private String max_id;
|
||||||
|
private List<Status> statuses;
|
||||||
|
private RelativeLayout mainLoader, nextElementLoader, textviewNoAction;
|
||||||
|
private boolean firstLoad;
|
||||||
|
private SwipeRefreshLayout swipeRefreshLayout;
|
||||||
|
private String groupname;
|
||||||
|
private int tootsPerPage;
|
||||||
|
private boolean flag_loading = false;
|
||||||
|
|
||||||
|
@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);
|
||||||
|
switch (theme){
|
||||||
|
case THEME_LIGHT:
|
||||||
|
setTheme(R.style.AppTheme_NoActionBar);
|
||||||
|
break;
|
||||||
|
case Helper.THEME_DARK:
|
||||||
|
setTheme(R.style.AppThemeDark_NoActionBar);
|
||||||
|
break;
|
||||||
|
case THEME_BLACK:
|
||||||
|
setTheme(R.style.AppThemeBlack_NoActionBar);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setTheme(R.style.AppThemeDark_NoActionBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
setContentView(R.layout.activity_group);
|
||||||
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
if( theme == THEME_BLACK)
|
||||||
|
toolbar.setBackgroundColor(ContextCompat.getColor(GroupActivity.this, R.color.black));
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
|
if( getSupportActionBar() != null)
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
Bundle b = getIntent().getExtras();
|
||||||
|
if(b != null)
|
||||||
|
groupname = b.getString("groupname", null);
|
||||||
|
if( groupname == null)
|
||||||
|
finish();
|
||||||
|
statuses = new ArrayList<>();
|
||||||
|
max_id = null;
|
||||||
|
flag_loading = true;
|
||||||
|
firstLoad = true;
|
||||||
|
boolean isOnWifi = Helper.isOnWIFI(getApplicationContext());
|
||||||
|
swipeRefreshLayout = findViewById(R.id.swipeContainer);
|
||||||
|
|
||||||
|
|
||||||
|
final RecyclerView lv_status = findViewById(R.id.lv_status);
|
||||||
|
//lv_status.addItemDecoration(new DividerItemDecoration(GroupActivity.this, DividerItemDecoration.VERTICAL));
|
||||||
|
tootsPerPage = Helper.TOOTS_PER_PAGE;
|
||||||
|
mainLoader = findViewById(R.id.loader);
|
||||||
|
nextElementLoader = findViewById(R.id.loading_next_status);
|
||||||
|
textviewNoAction = findViewById(R.id.no_action);
|
||||||
|
mainLoader.setVisibility(View.VISIBLE);
|
||||||
|
nextElementLoader.setVisibility(View.GONE);
|
||||||
|
statusListAdapter = new StatusListAdapter(GroupActivity.this, RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE, null, isOnWifi, this.statuses);
|
||||||
|
lv_status.setAdapter(statusListAdapter);
|
||||||
|
setTitle(String.format("!%s", groupname));
|
||||||
|
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||||
|
@Override
|
||||||
|
public void onRefresh() {
|
||||||
|
max_id = null;
|
||||||
|
statuses = new ArrayList<>();
|
||||||
|
firstLoad = true;
|
||||||
|
flag_loading = true;
|
||||||
|
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE, groupname,null, max_id, GroupActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
final LinearLayoutManager mLayoutManager;
|
||||||
|
mLayoutManager = new LinearLayoutManager(this);
|
||||||
|
lv_status.setLayoutManager(mLayoutManager);
|
||||||
|
lv_status.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||||
|
public void onScrolled(@NotNull RecyclerView recyclerView, int dx, int dy)
|
||||||
|
{
|
||||||
|
if(dy > 0){
|
||||||
|
int visibleItemCount = mLayoutManager.getChildCount();
|
||||||
|
int totalItemCount = mLayoutManager.getItemCount();
|
||||||
|
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
|
||||||
|
if(firstVisibleItem + visibleItemCount == totalItemCount ) {
|
||||||
|
if(!flag_loading ) {
|
||||||
|
flag_loading = true;
|
||||||
|
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE, groupname,null, max_id, GroupActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
|
||||||
|
nextElementLoader.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nextElementLoader.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
new RetrieveFeedsAsyncTask(getApplicationContext(), RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE, groupname,null, max_id, GroupActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||||
|
|
||||||
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||||
|
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||||
|
if( theme == THEME_LIGHT)
|
||||||
|
Helper.colorizeIconMenu(menu, R.color.black);
|
||||||
|
return super.onPrepareOptionsMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 onRetrieveFeeds(APIResponse apiResponse) {
|
||||||
|
|
||||||
|
mainLoader.setVisibility(View.GONE);
|
||||||
|
nextElementLoader.setVisibility(View.GONE);
|
||||||
|
if( apiResponse.getError() != null){
|
||||||
|
Toasty.error(getApplicationContext(), apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<Status> statuses = apiResponse.getStatuses();
|
||||||
|
if( firstLoad && (statuses == null || statuses.size() == 0))
|
||||||
|
textviewNoAction.setVisibility(View.VISIBLE);
|
||||||
|
else
|
||||||
|
textviewNoAction.setVisibility(View.GONE);
|
||||||
|
if( statuses != null && statuses.size() > 1)
|
||||||
|
max_id =statuses.get(statuses.size()-1).getId();
|
||||||
|
else
|
||||||
|
max_id = null;
|
||||||
|
if( statuses != null) {
|
||||||
|
this.statuses.addAll(statuses);
|
||||||
|
statusListAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
swipeRefreshLayout.setRefreshing(false);
|
||||||
|
firstLoad = false;
|
||||||
|
flag_loading = statuses != null && statuses.size() < tootsPerPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -49,7 +49,8 @@ public class RetrieveAccountsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
CHANNELS,
|
CHANNELS,
|
||||||
REBLOGGED,
|
REBLOGGED,
|
||||||
FAVOURITED,
|
FAVOURITED,
|
||||||
SEARCH
|
SEARCH,
|
||||||
|
GROUPS
|
||||||
}
|
}
|
||||||
|
|
||||||
public RetrieveAccountsAsyncTask(Context context, String instance, String name, OnRetrieveAccountsInterface onRetrieveAccountsInterface){
|
public RetrieveAccountsAsyncTask(Context context, String instance, String name, OnRetrieveAccountsInterface onRetrieveAccountsInterface){
|
||||||
|
@ -147,6 +148,10 @@ public class RetrieveAccountsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
assert api != null;
|
assert api != null;
|
||||||
apiResponse = api.getPeertubeChannel(instance, name);
|
apiResponse = api.getPeertubeChannel(instance, name);
|
||||||
break;
|
break;
|
||||||
|
case GROUPS:
|
||||||
|
assert gnuapi != null;
|
||||||
|
apiResponse = gnuapi.getGroups(max_id);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,6 +111,7 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
GNU_DM,
|
GNU_DM,
|
||||||
GNU_ART,
|
GNU_ART,
|
||||||
GNU_TAG,
|
GNU_TAG,
|
||||||
|
GNU_GROUP_TIMELINE,
|
||||||
|
|
||||||
SCHEDULED_TOOTS,
|
SCHEDULED_TOOTS,
|
||||||
CACHE_BOOKMARKS,
|
CACHE_BOOKMARKS,
|
||||||
|
|
|
@ -61,6 +61,7 @@ import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import app.fedilab.android.R;
|
import app.fedilab.android.R;
|
||||||
|
import app.fedilab.android.activities.GroupActivity;
|
||||||
import app.fedilab.android.activities.HashTagActivity;
|
import app.fedilab.android.activities.HashTagActivity;
|
||||||
import app.fedilab.android.activities.MainActivity;
|
import app.fedilab.android.activities.MainActivity;
|
||||||
import app.fedilab.android.activities.PeertubeActivity;
|
import app.fedilab.android.activities.PeertubeActivity;
|
||||||
|
@ -961,6 +962,40 @@ public class Status implements Parcelable{
|
||||||
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.GNU){
|
||||||
|
matcher = Helper.groupPattern.matcher(spannableStringT);
|
||||||
|
while (matcher.find()){
|
||||||
|
int matchStart = matcher.start(1);
|
||||||
|
int matchEnd = matcher.end();
|
||||||
|
final String groupname = spannableStringT.toString().substring(matchStart, matchEnd);
|
||||||
|
if( matchEnd <= spannableStringT.toString().length() && matchEnd >= matchStart)
|
||||||
|
spannableStringT.setSpan(new ClickableSpan() {
|
||||||
|
@Override
|
||||||
|
public void onClick(@NonNull View textView) {
|
||||||
|
if(MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
|
||||||
|
Intent intent = new Intent(context, GroupActivity.class);
|
||||||
|
Bundle b = new Bundle();
|
||||||
|
b.putString("groupname", groupname.substring(1));
|
||||||
|
intent.putExtras(b);
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void updateDrawState(@NonNull TextPaint ds) {
|
||||||
|
super.updateDrawState(ds);
|
||||||
|
ds.setUnderlineText(false);
|
||||||
|
if (theme == THEME_DARK)
|
||||||
|
ds.setColor(ContextCompat.getColor(context, R.color.dark_link_toot));
|
||||||
|
else if (theme == THEME_BLACK)
|
||||||
|
ds.setColor(ContextCompat.getColor(context, R.color.black_link_toot));
|
||||||
|
else if (theme == THEME_LIGHT)
|
||||||
|
ds.setColor(ContextCompat.getColor(context, R.color.light_link_toot));
|
||||||
|
}
|
||||||
|
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
return spannableStringT;
|
return spannableStringT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,6 +229,166 @@ public class GNUAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves group *synchronously*
|
||||||
|
* @param max_id String id max
|
||||||
|
* @return APIResponse
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
|
public APIResponse getGroups(String max_id){
|
||||||
|
return getGroups(max_id, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves group *synchronously*
|
||||||
|
* @param max_id String id max
|
||||||
|
* @param since_id String since the id
|
||||||
|
* @return APIResponse
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
|
private APIResponse getGroups(String max_id, String since_id){
|
||||||
|
|
||||||
|
HashMap<String, String> params = new HashMap<>();
|
||||||
|
if( max_id != null )
|
||||||
|
params.put("max_id", max_id);
|
||||||
|
if( since_id != null )
|
||||||
|
params.put("since_id", since_id);
|
||||||
|
accounts = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
|
||||||
|
String response = httpsConnection.get(getAbsoluteUrl("/statusnet/groups/list.json"), 60, params, prefKeyOauthTokenT);
|
||||||
|
accounts = parseGroups(context, new JSONArray(response));
|
||||||
|
if( accounts.size() > 0) {
|
||||||
|
apiResponse.setSince_id(String.valueOf(Long.parseLong(accounts.get(0).getId())+1));
|
||||||
|
apiResponse.setMax_id(String.valueOf(Long.parseLong(accounts.get(accounts.size() - 1).getId())-1));
|
||||||
|
}
|
||||||
|
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||||
|
setError(e.getStatusCode(), e);
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (KeyManagementException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
apiResponse.setAccounts(accounts);
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse json response for several groups
|
||||||
|
* @param jsonArray JSONArray
|
||||||
|
* @return List<Account>
|
||||||
|
*/
|
||||||
|
private static List<Account> parseGroups(Context context, JSONArray jsonArray){
|
||||||
|
|
||||||
|
List<Account> groups = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
int i = 0;
|
||||||
|
while (i < jsonArray.length() ){
|
||||||
|
|
||||||
|
JSONObject resobj = jsonArray.getJSONObject(i);
|
||||||
|
Account group = parseGroups(context, resobj);
|
||||||
|
i++;
|
||||||
|
groups.add(group);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse json response for unique group
|
||||||
|
* @param resobj JSONObject
|
||||||
|
* @return Account
|
||||||
|
*/
|
||||||
|
private static Account parseGroups(Context context, JSONObject resobj){
|
||||||
|
Account group = new Account();
|
||||||
|
try {
|
||||||
|
group.setId(resobj.get("id").toString());
|
||||||
|
//group.setFollowers_count(resobj.getInt("admin_count"));
|
||||||
|
//group.setBlocked(resobj.getBoolean("blocked"));
|
||||||
|
group.setCreated_at(Helper.mstStringToDate(context, resobj.getString("created")));
|
||||||
|
group.setNote(resobj.getString("description"));
|
||||||
|
group.setDisplay_name(resobj.getString("fullname"));
|
||||||
|
//group.setHomepage(resobj.getString("homepage"));
|
||||||
|
group.setUsername(resobj.getString("nickname"));
|
||||||
|
|
||||||
|
group.setAvatar(resobj.getString("homepage_logo"));
|
||||||
|
//group.setLocation(resobj.getString("location"));
|
||||||
|
group.setFollowing(resobj.getBoolean("member"));
|
||||||
|
group.setFollowers_count(resobj.getInt("member_count"));
|
||||||
|
//group.setMini_logo(resobj.getString("mini_logo"));
|
||||||
|
//group.setModified(Helper.mstStringToDate(context, resobj.getString("modified")));
|
||||||
|
group.setAcct("!"+resobj.getString("nickname"));
|
||||||
|
group.setAvatar_static(resobj.getString("original_logo"));
|
||||||
|
group.setHeader(resobj.getString("stream_logo"));
|
||||||
|
group.setUrl(resobj.getString("url"));
|
||||||
|
} catch (JSONException ignored) {ignored.printStackTrace();} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
}
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves group timeline *synchronously*
|
||||||
|
* @param groupName String id group
|
||||||
|
* @param max_id String id max
|
||||||
|
* @return APIResponse
|
||||||
|
*/
|
||||||
|
public APIResponse getGroupTimeline(String groupName, String max_id){
|
||||||
|
return getGroupTimeline(groupName, max_id, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves group timeline *synchronously*
|
||||||
|
* @param groupName String id group
|
||||||
|
* @param max_id String id max
|
||||||
|
* @param since_id String since the id
|
||||||
|
* @return APIResponse
|
||||||
|
*/
|
||||||
|
private APIResponse getGroupTimeline(String groupName, String max_id, String since_id){
|
||||||
|
|
||||||
|
HashMap<String, String> params = new HashMap<>();
|
||||||
|
|
||||||
|
if( max_id != null )
|
||||||
|
params.put("max_id", max_id);
|
||||||
|
if( since_id != null )
|
||||||
|
params.put("since_id", since_id);
|
||||||
|
statuses = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
|
||||||
|
String url;
|
||||||
|
url = getAbsoluteUrl(String.format("/statusnet/groups/timeline/%s.json", groupName));
|
||||||
|
String response = httpsConnection.get(url, 60, params, prefKeyOauthTokenT);
|
||||||
|
statuses = parseStatuses(context, new JSONArray(response));
|
||||||
|
if( statuses.size() > 0) {
|
||||||
|
apiResponse.setSince_id(String.valueOf(Long.parseLong(statuses.get(0).getId())+1));
|
||||||
|
apiResponse.setMax_id(String.valueOf(Long.parseLong(statuses.get(statuses.size() - 1).getId())-1));
|
||||||
|
}
|
||||||
|
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||||
|
setError(e.getStatusCode(), e);
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (KeyManagementException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
apiResponse.setStatuses(statuses);
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a relationship between the authenticated account and an account
|
* Returns a relationship between the authenticated account and an account
|
||||||
* @param accountId String account fetched
|
* @param accountId String account fetched
|
||||||
|
|
|
@ -38,6 +38,7 @@ import android.widget.Toast;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import app.fedilab.android.activities.GroupActivity;
|
||||||
import app.fedilab.android.client.API;
|
import app.fedilab.android.client.API;
|
||||||
import app.fedilab.android.client.Entities.Account;
|
import app.fedilab.android.client.Entities.Account;
|
||||||
import app.fedilab.android.client.Entities.Error;
|
import app.fedilab.android.client.Entities.Error;
|
||||||
|
@ -219,29 +220,42 @@ public class AccountsListAdapter extends RecyclerView.Adapter implements OnPostA
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
holder.account_pp.setOnClickListener(new View.OnClickListener() {
|
if( action != RetrieveAccountsAsyncTask.Type.GROUPS ) {
|
||||||
@Override
|
holder.account_pp.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
@Override
|
||||||
if(MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE || action != RetrieveAccountsAsyncTask.Type.CHANNELS) {
|
public void onClick(View v) {
|
||||||
//Avoid to reopen details about the current account
|
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE || action != RetrieveAccountsAsyncTask.Type.CHANNELS) {
|
||||||
if (targetedId == null || !targetedId.equals(account.getId())) {
|
//Avoid to reopen details about the current account
|
||||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
if (targetedId == null || !targetedId.equals(account.getId())) {
|
||||||
Bundle b = new Bundle();
|
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||||
if(MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
|
Bundle b = new Bundle();
|
||||||
b.putBoolean("peertubeaccount", true);
|
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
|
||||||
b.putBoolean("ischannel", true);
|
b.putBoolean("peertubeaccount", true);
|
||||||
b.putString("targetedid", account.getAcct());
|
b.putBoolean("ischannel", true);
|
||||||
|
b.putString("targetedid", account.getAcct());
|
||||||
|
}
|
||||||
|
b.putParcelable("account", account);
|
||||||
|
intent.putExtras(b);
|
||||||
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
b.putParcelable("account", account);
|
} else {
|
||||||
intent.putExtras(b);
|
CrossActions.doCrossProfile(context, account);
|
||||||
context.startActivity(intent);
|
|
||||||
}
|
}
|
||||||
}else {
|
|
||||||
CrossActions.doCrossProfile(context, account);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}else{
|
||||||
|
holder.account_container.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(context, GroupActivity.class);
|
||||||
|
Bundle b = new Bundle();
|
||||||
|
b.putString("groupname", account.getUsername());
|
||||||
|
intent.putExtras(b);
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -502,6 +502,7 @@ public class Helper {
|
||||||
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||||
|
|
||||||
public static final Pattern hashtagPattern = Pattern.compile("(#[\\w_A-zÀ-ÿ]+)");
|
public static final Pattern hashtagPattern = Pattern.compile("(#[\\w_A-zÀ-ÿ]+)");
|
||||||
|
public static final Pattern groupPattern = Pattern.compile("(\\![\\w_]+(\\s|$))");
|
||||||
public static final Pattern twitterPattern = Pattern.compile("((@[\\w]+)@twitter\\.com)");
|
public static final Pattern twitterPattern = Pattern.compile("((@[\\w]+)@twitter\\.com)");
|
||||||
private static final Pattern mentionPattern = Pattern.compile("(@[\\w_]+(\\s|$))");
|
private static final Pattern mentionPattern = Pattern.compile("(@[\\w_]+(\\s|$))");
|
||||||
private static final Pattern mentionLongPattern = Pattern.compile("(@[\\w_-]+@[a-z0-9.\\-]+[.][a-z]{2,10})");
|
private static final Pattern mentionLongPattern = Pattern.compile("(@[\\w_-]+@[a-z0-9.\\-]+[.][a-z]{2,10})");
|
||||||
|
@ -1521,6 +1522,11 @@ public class Helper {
|
||||||
MenuItem nav_blocked_domains = menu.findItem(R.id.nav_blocked_domains);
|
MenuItem nav_blocked_domains = menu.findItem(R.id.nav_blocked_domains);
|
||||||
if( nav_blocked_domains != null)
|
if( nav_blocked_domains != null)
|
||||||
nav_blocked_domains.setVisible(false);
|
nav_blocked_domains.setVisible(false);
|
||||||
|
if(BaseMainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.GNU ){
|
||||||
|
MenuItem nav_group = menu.findItem(R.id.nav_group);
|
||||||
|
if( nav_group != null)
|
||||||
|
nav_group.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||||
|
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FF000000" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM8,17.5c-1.38,0 -2.5,-1.12 -2.5,-2.5s1.12,-2.5 2.5,-2.5 2.5,1.12 2.5,2.5 -1.12,2.5 -2.5,2.5zM9.5,8c0,-1.38 1.12,-2.5 2.5,-2.5s2.5,1.12 2.5,2.5 -1.12,2.5 -2.5,2.5S9.5,9.38 9.5,8zM16,17.5c-1.38,0 -2.5,-1.12 -2.5,-2.5s1.12,-2.5 2.5,-2.5 2.5,1.12 2.5,2.5 -1.12,2.5 -2.5,2.5z"/>
|
||||||
|
</vector>
|
|
@ -0,0 +1,111 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright 2019 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.v4.widget.DrawerLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/drawer_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
>
|
||||||
|
|
||||||
|
<android.support.design.widget.CoordinatorLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="fr.gouv.etalab.mastodon.activities.GroupActivity">
|
||||||
|
|
||||||
|
<android.support.design.widget.AppBarLayout
|
||||||
|
android:id="@+id/appBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
>
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:layout_scrollFlags="scroll|enterAlways"
|
||||||
|
app:popupTheme="?attr/popupOverlay"/>
|
||||||
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
<RelativeLayout
|
||||||
|
android:paddingLeft="@dimen/fab_margin"
|
||||||
|
android:paddingRight="@dimen/fab_margin"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<!-- Listview status -->
|
||||||
|
<android.support.v4.widget.SwipeRefreshLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:id="@+id/swipeContainer"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<android.support.v7.widget.RecyclerView
|
||||||
|
android:id="@+id/lv_status"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:scrollbars="none"
|
||||||
|
android:divider="@null"
|
||||||
|
>
|
||||||
|
</android.support.v7.widget.RecyclerView>
|
||||||
|
</android.support.v4.widget.SwipeRefreshLayout>
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/no_action"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<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_messages"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
</RelativeLayout>
|
||||||
|
<!-- Main Loader -->
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/loader"
|
||||||
|
android:visibility="gone"
|
||||||
|
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>
|
||||||
|
<!-- Loader for next status -->
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/loading_next_status"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_gravity="bottom|center_horizontal"
|
||||||
|
android:gravity="bottom|center_horizontal"
|
||||||
|
android:layout_height="20dp">
|
||||||
|
<ProgressBar
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:indeterminate="true" />
|
||||||
|
</RelativeLayout>
|
||||||
|
</RelativeLayout>
|
||||||
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
|
</android.support.v4.widget.DrawerLayout>
|
|
@ -22,6 +22,11 @@
|
||||||
android:id="@+id/nav_list"
|
android:id="@+id/nav_list"
|
||||||
android:icon="@drawable/ic_list"
|
android:icon="@drawable/ic_list"
|
||||||
android:title="@string/action_lists" />
|
android:title="@string/action_lists" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/nav_group"
|
||||||
|
android:visible="false"
|
||||||
|
android:icon="@drawable/ic_group_work"
|
||||||
|
android:title="@string/action_groups" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/nav_scheduled"
|
android:id="@+id/nav_scheduled"
|
||||||
android:icon="@drawable/ic_schedule"
|
android:icon="@drawable/ic_schedule"
|
||||||
|
|
|
@ -1137,6 +1137,7 @@
|
||||||
<string name="frequency">Frequency</string>
|
<string name="frequency">Frequency</string>
|
||||||
<string name="toot_per_day">%s statuses per day</string>
|
<string name="toot_per_day">%s statuses per day</string>
|
||||||
<string name="date_range">Date range</string>
|
<string name="date_range">Date range</string>
|
||||||
|
<string name="action_groups">Groups</string>
|
||||||
<plurals name="number_of_vote">
|
<plurals name="number_of_vote">
|
||||||
<item quantity="one">%d vote</item>
|
<item quantity="one">%d vote</item>
|
||||||
<item quantity="other">%d votes</item>
|
<item quantity="other">%d votes</item>
|
||||||
|
|
Loading…
Reference in New Issue