News
This commit is contained in:
parent
e84ab4da29
commit
a845b05b74
|
@ -237,7 +237,7 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
|
|||
about_website.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://tom79.bitbucket.io"));
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://fedilab.app"));
|
||||
startActivity(browserIntent);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1621,6 +1621,14 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
fragmentTag = "MY_HISTORY";
|
||||
fragmentManager.beginTransaction()
|
||||
.replace(R.id.main_app_container, fragment, fragmentTag).commit();
|
||||
} else if (id == R.id.nav_news) {
|
||||
toot.hide();
|
||||
statusFragment = new DisplayStatusFragment();
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.NEWS);
|
||||
statusFragment.setArguments(bundle);
|
||||
fragmentTag = "NEWS";
|
||||
fragmentManager.beginTransaction()
|
||||
.replace(R.id.main_app_container, statusFragment, fragmentTag).commit();
|
||||
} else if (id == R.id.nav_blocked || id == R.id.nav_pixelfed_blocked) {
|
||||
toot.hide();
|
||||
accountsFragment = new DisplayAccountsFragment();
|
||||
|
|
|
@ -85,6 +85,7 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
PEERTUBE,
|
||||
NOTIFICATION,
|
||||
SEARCH,
|
||||
NEWS,
|
||||
|
||||
PSUBSCRIPTIONS,
|
||||
POVERVIEW,
|
||||
|
@ -222,6 +223,9 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
case PUBLIC:
|
||||
apiResponse = api.getPublicTimeline(false, max_id);
|
||||
break;
|
||||
case NEWS:
|
||||
apiResponse = api.getNews(max_id);
|
||||
break;
|
||||
case SCHEDULED_TOOTS:
|
||||
apiResponse = api.scheduledAction("GET", null, max_id, null);
|
||||
break;
|
||||
|
|
|
@ -1524,6 +1524,59 @@ public class API {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves news coming from Fedilab's account *synchronously*
|
||||
* @param max_id String id max
|
||||
* @return APIResponse
|
||||
*/
|
||||
public APIResponse getNews(String max_id){
|
||||
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
if (max_id != null)
|
||||
params.put("max_id", max_id);
|
||||
|
||||
params.put("exclude_replies", "true");
|
||||
params.put("limit", "40");
|
||||
params.put("tagged", "Fedilab");
|
||||
statuses = new ArrayList<>();
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
String instance = Helper.getLiveInstance(context);
|
||||
|
||||
String accountID = sharedpreferences.getString(Helper.NEWS_ACCOUNT_ID+userId+instance, null);
|
||||
if( accountID == null){
|
||||
APIResponse response = search("https://framapiaf.org/@fedilab");
|
||||
Results res = response.getResults();
|
||||
if( res != null && res.getAccounts() != null && res.getAccounts().size() > 0 ){
|
||||
accountID = res.getAccounts().get(0).getId();
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.NEWS_ACCOUNT_ID+userId+instance, accountID);
|
||||
editor.apply();
|
||||
}
|
||||
}
|
||||
try {
|
||||
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
|
||||
String response = httpsConnection.get(getAbsoluteUrl(String.format("/accounts/%s/statuses", accountID)), 60, params, prefKeyOauthTokenT);
|
||||
statuses = parseStatuses(context, new JSONArray(response));
|
||||
apiResponse.setSince_id(httpsConnection.getSince_id());
|
||||
apiResponse.setMax_id(httpsConnection.getMax_id());
|
||||
} catch (HttpsConnection.HttpsConnectionException e) {
|
||||
setError(e.getStatusCode(), e);
|
||||
e.printStackTrace();
|
||||
} 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves discover timeline for the account *synchronously*
|
||||
* @param local boolean only local timeline
|
||||
|
|
|
@ -23,7 +23,6 @@ import android.support.annotation.NonNull;
|
|||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
|
@ -297,6 +297,7 @@ public class Helper {
|
|||
public static final String SET_SHOW_REPLIES = "set_show_replies";
|
||||
public static final String SET_VIDEO_NSFW = "set_video_nsfw";
|
||||
public static final String INSTANCE_VERSION = "instance_version";
|
||||
public static final String NEWS_ACCOUNT_ID = "news_account_id";
|
||||
public static final String SET_LIVE_NOTIFICATIONS = "set_live_notifications";
|
||||
public static final String SET_DISABLE_GIF = "set_disable_gif";
|
||||
public static final String SET_CAPITALIZE = "set_capitalize";
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
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>.
|
||||
-->
|
||||
<TextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/tab_counter_news"
|
||||
android:visibility="gone"
|
||||
android:paddingLeft="2dp"
|
||||
android:paddingRight="2dp"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/mastodonC1"
|
||||
android:background="@drawable/shape_counter"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<group>
|
||||
<!-- MASTODON MENU -->
|
||||
<item
|
||||
|
@ -13,10 +14,6 @@
|
|||
android:id="@+id/menu_none"
|
||||
android:title=""
|
||||
android:visible="false"/>
|
||||
<item
|
||||
android:id="@+id/nav_news"
|
||||
android:icon="@drawable/ic_new_releases_black"
|
||||
android:title="@string/action_news" />
|
||||
<item
|
||||
android:id="@+id/nav_list"
|
||||
android:icon="@drawable/ic_list"
|
||||
|
@ -37,6 +34,11 @@
|
|||
android:id="@+id/nav_bookmarks"
|
||||
android:icon="@drawable/ic_bookmark_menu"
|
||||
android:title="@string/bookmarks" />
|
||||
<item
|
||||
android:id="@+id/nav_news"
|
||||
android:icon="@drawable/ic_new_releases_black"
|
||||
app:actionLayout="@layout/item_menu_news"
|
||||
android:title="@string/action_news" />
|
||||
<item
|
||||
android:id="@+id/nav_peertube"
|
||||
android:icon="@drawable/ic_favorite_peertube_full"
|
||||
|
|
Loading…
Reference in New Issue