some fixes

This commit is contained in:
tom79 2019-07-11 17:55:35 +02:00
parent 025daa8ea5
commit 1e3b91e7b3
6 changed files with 31 additions and 60 deletions

View File

@ -1119,7 +1119,7 @@ public abstract class BaseMainActivity extends BaseActivity
}
MenuItem news = navigationView.getMenu().findItem(R.id.nav_news);
if( news != null){
boolean display_news = sharedpreferences.getBoolean(Helper.SET_DISPLAY_NEWS_FROM_FEDILAB, false);
boolean display_news = sharedpreferences.getBoolean(Helper.SET_DISPLAY_NEWS_FROM_FEDILAB, true);
if( ! display_news ){
news.setVisible(false);
}

View File

@ -2019,64 +2019,35 @@ public class API {
*/
public APIResponse getNews(String max_id){
HashMap<String, String> params = new HashMap<>();
if (max_id != null)
HashMap<String, String> params = null;
if (max_id != null) {
params = new HashMap<>();
params.put("max_id", max_id);
params.put("exclude_replies", "true");
params.put("reblogs","false");
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){
HashMap<String, String> params2 = new HashMap<>();
try {
params2.put("q", URLEncoder.encode("https://framapiaf.org/@fedilab", "UTF-8"));
} catch (UnsupportedEncodingException e) {
params2.put("q", "https://framapiaf.org/@fedilab");
}
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
try {
String response = httpsConnection.get(getAbsoluteUrl("/search"), 60, params2, prefKeyOauthTokenT);
Results res = parseResultsResponse(new JSONObject(response));
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();
}
} catch (IOException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (HttpsConnection.HttpsConnectionException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
}
statuses = new ArrayList<>();
apiResponse = new APIResponse();
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));
String response = httpsConnection.get("https://framapiaf.org/api/v1/timelines/tag/fedilab", 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
List<Status> tmp_status = parseStatuses(context, new JSONArray(response));
if( tmp_status != null && tmp_status.size() > 0){
for(Status status: tmp_status){
if( status.getAccount().getAcct().equals("fedilab")){
statuses.add(status);
}
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (HttpsConnection.HttpsConnectionException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}

View File

@ -786,7 +786,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
boolean isConsoleMode = sharedpreferences.getBoolean(Helper.SET_CONSOLE_MODE, false);
if( !isConsoleMode && type == RetrieveFeedsAsyncTask.Type.CONTEXT && position == conversationPosition)
return FOCUSED_STATUS;
else if( type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && !Helper.filterToots(context, statuses.get(position), timedMute, type))
else if( type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS && !Helper.filterToots(context, statuses.get(position), timedMute, type))
return HIDDEN_STATUS;
else {
if( isCompactMode)
@ -1358,7 +1358,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
return false;
});
if (type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE){
if (type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE || type == RetrieveFeedsAsyncTask.Type.NEWS){
holder.custom_feature_timed_mute.setVisibility(View.GONE);
holder.custom_feature_schedule.setVisibility(View.GONE);
holder.custom_feature_cache.setVisibility(View.GONE);
@ -1480,7 +1480,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.status_spoiler.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE) {
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS) {
Intent intent = new Intent(context, ShowConversationActivity.class);
int position = closePanels();
if( holder.getAdapterPosition() == position)
@ -1505,7 +1505,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.status_content.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE) {
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS) {
Intent intent = new Intent(context, ShowConversationActivity.class);
int position = closePanels();
if( holder.getAdapterPosition() == position)
@ -1530,7 +1530,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.main_container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE) {
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS) {
Intent intent = new Intent(context, ShowConversationActivity.class);
int position = closePanels();
if( holder.getAdapterPosition() == position)
@ -2288,7 +2288,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.status_pin.setVisibility(View.GONE);
}
if( (isAdmin || isModerator) && !isCompactMode && !isConsoleMode && getItemViewType(viewHolder.getAdapterPosition()) != FOCUSED_STATUS && type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE){
if( (isAdmin || isModerator) && !isCompactMode && !isConsoleMode && getItemViewType(viewHolder.getAdapterPosition()) != FOCUSED_STATUS && type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS){
holder.status_remove.setVisibility(View.VISIBLE);
}else {
holder.status_remove.setVisibility(View.GONE);
@ -2465,7 +2465,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
@Override
public void onClick(View v) {
if (quick_reply && type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE) {
if (quick_reply && type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS) {
if( context instanceof BaseMainActivity){
FloatingActionButton toot = ((BaseMainActivity) context).findViewById(R.id.toot);
@ -2833,7 +2833,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
});
if (type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE)
if (type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE || type == RetrieveFeedsAsyncTask.Type.NEWS)
holder.status_more.setVisibility(View.GONE);
final View attached = holder.status_more;
@ -3207,7 +3207,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
});
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE) {
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && type != RetrieveFeedsAsyncTask.Type.NEWS) {
holder.status_account_profile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View File

@ -718,7 +718,7 @@ public class ContentSettingsFragment extends Fragment implements ScreenShotable
});
boolean display_news = sharedpreferences.getBoolean(Helper.SET_DISPLAY_NEWS_FROM_FEDILAB, false);
boolean display_news = sharedpreferences.getBoolean(Helper.SET_DISPLAY_NEWS_FROM_FEDILAB, true);
final CheckBox set_display_news = rootView.findViewById(R.id.set_display_news);
set_display_news.setChecked(display_news);

View File

@ -2919,7 +2919,7 @@ public class Helper {
}
MenuItem news = navigationView.getMenu().findItem(R.id.nav_news);
if( news != null){
boolean display_news = sharedpreferences.getBoolean(Helper.SET_DISPLAY_NEWS_FROM_FEDILAB, false);
boolean display_news = sharedpreferences.getBoolean(Helper.SET_DISPLAY_NEWS_FROM_FEDILAB, true);
if( ! display_news ){
news.setVisible(false);
}

View File

@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:3.4.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files