Prepare frontend 6 - Some fixes
This commit is contained in:
parent
907bbfe335
commit
b5030916c9
|
@ -885,13 +885,13 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
}else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED){
|
||||
TabLayout.Tab pfTabHome = tabLayout.newTab();
|
||||
TabLayout.Tab pfTabLocal = tabLayout.newTab();
|
||||
TabLayout.Tab pfTabDiscover = tabLayout.newTab();
|
||||
//TabLayout.Tab pfTabDiscover = tabLayout.newTab();
|
||||
|
||||
|
||||
|
||||
pfTabHome.setCustomView(R.layout.tab_badge);
|
||||
pfTabLocal.setCustomView(R.layout.tab_badge);
|
||||
pfTabDiscover.setCustomView(R.layout.tab_badge);
|
||||
//pfTabDiscover.setCustomView(R.layout.tab_badge);
|
||||
|
||||
|
||||
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
||||
|
@ -910,24 +910,24 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
iconLocal.setImageResource(R.drawable.ic_people);
|
||||
|
||||
|
||||
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
||||
/*@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
||||
ImageView iconDiscover = pfTabDiscover.getCustomView().findViewById(R.id.tab_icon);
|
||||
iconDiscover.setImageResource(R.drawable.ic_people);
|
||||
iconDiscover.setImageResource(R.drawable.ic_people);*/
|
||||
|
||||
|
||||
|
||||
iconHome.setContentDescription(getString(R.string.home_menu));
|
||||
iconDiscover.setContentDescription(getString(R.string.overview));
|
||||
// iconDiscover.setContentDescription(getString(R.string.overview));
|
||||
iconLocal.setContentDescription(getString(R.string.local));
|
||||
|
||||
|
||||
if (theme == THEME_LIGHT) {
|
||||
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
||||
iconDiscover.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
||||
// iconDiscover.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
||||
iconLocal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.action_light_header), PorterDuff.Mode.SRC_IN);
|
||||
} else {
|
||||
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
||||
iconDiscover.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
||||
// iconDiscover.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
||||
iconLocal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
|
||||
|
@ -935,7 +935,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
|
||||
tabLayout.addTab(pfTabHome);
|
||||
tabLayout.addTab(pfTabLocal);
|
||||
tabLayout.addTab(pfTabDiscover);
|
||||
// tabLayout.addTab(pfTabDiscover);
|
||||
|
||||
|
||||
|
||||
|
@ -2452,9 +2452,9 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PF_HOME);
|
||||
}else if( position == 1) {
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PF_LOCAL);
|
||||
}else if( position == 2) {
|
||||
}/*else if( position == 2) {
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PF_DISCOVER);
|
||||
}
|
||||
}*/
|
||||
bundle.putString("instanceType","PIXELFED");
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
|
|
|
@ -296,6 +296,17 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
peertubeAPI = new PeertubeAPI(this.contextReference.get());
|
||||
apiResponse = peertubeAPI.getLocalTL(max_id);
|
||||
break;
|
||||
case PF_HOME:
|
||||
api = new API(this.contextReference.get());
|
||||
apiResponse = api.getHomeTimeline(max_id);
|
||||
break;
|
||||
case PF_LOCAL:
|
||||
api = new API(this.contextReference.get());
|
||||
apiResponse = api.getPublicTimeline(true,max_id);
|
||||
case PF_DISCOVER:
|
||||
api = new API(this.contextReference.get());
|
||||
apiResponse = api.getDiscoverTimeline(true,max_id);
|
||||
break;
|
||||
case HASHTAG:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1179,6 +1179,62 @@ public class API {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves discover timeline for the account *synchronously*
|
||||
* @param local boolean only local timeline
|
||||
* @param max_id String id max
|
||||
* @return APIResponse
|
||||
*/
|
||||
public APIResponse getDiscoverTimeline(boolean local, String max_id){
|
||||
return getDiscoverTimeline(local, max_id, null, tootPerPage);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves discover timeline for the account *synchronously*
|
||||
* @param local boolean only local timeline
|
||||
* @param max_id String id max
|
||||
* @param since_id String since the id
|
||||
* @param limit int limit - max value 40
|
||||
* @return APIResponse
|
||||
*/
|
||||
private APIResponse getDiscoverTimeline(boolean local, String max_id, String since_id, int limit){
|
||||
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
if( local)
|
||||
params.put("local", Boolean.toString(true));
|
||||
if( max_id != null )
|
||||
params.put("max_id", max_id);
|
||||
if( since_id != null )
|
||||
params.put("since_id", since_id);
|
||||
if( 0 > limit || limit > 40)
|
||||
limit = 40;
|
||||
params.put("limit",String.valueOf(limit));
|
||||
statuses = new ArrayList<>();
|
||||
try {
|
||||
HttpsConnection httpsConnection = new HttpsConnection(context);
|
||||
String url;
|
||||
url = getAbsoluteUr2l("/discover/posts");
|
||||
String response = httpsConnection.get(url, 60, params, prefKeyOauthTokenT);
|
||||
apiResponse.setSince_id(httpsConnection.getSince_id());
|
||||
apiResponse.setMax_id(httpsConnection.getMax_id());
|
||||
statuses = parseStatuses(context, new JSONArray(response));
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public APIResponse getCustomArtTimeline(boolean local, String tag, String max_id, List<String> any, List<String> all, List<String> none){
|
||||
return getArtTimeline(local, tag, max_id, null, any, all, none);
|
||||
|
@ -3945,6 +4001,9 @@ public class API {
|
|||
private String getAbsoluteUrl(String action) {
|
||||
return Helper.instanceWithProtocol(this.instance) + "/api/v1" + action;
|
||||
}
|
||||
private String getAbsoluteUr2l(String action) {
|
||||
return Helper.instanceWithProtocol(this.instance) + "/api/v2" + action;
|
||||
}
|
||||
private String getAbsoluteUrlRemote(String remote, String action) {
|
||||
return "https://" + remote + "/api/v1" + action;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:id="@+id/pf_username"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in New Issue