Merge branch 'develop'

# Conflicts:
#	app/build.gradle
This commit is contained in:
stom79 2018-08-24 18:13:54 +02:00
commit 533b99e267
49 changed files with 291 additions and 153 deletions

View File

@ -7,8 +7,8 @@ android {
applicationId "fr.gouv.etalab.mastodon"
minSdkVersion 15
targetSdkVersion 27
versionCode 129
versionName "1.10.4"
versionCode 130
versionName "1.10.5"
}
flavorDimensions "default"
buildTypes {
@ -70,7 +70,7 @@ dependencies {
implementation 'com.github.stom79:country-picker-android:1.2.0'
implementation 'com.github.stom79:mytransl:1.5'
playstoreImplementation "io.github.kobakei:ratethisapp:$ratethisappLibraryVersion"

View File

@ -58,6 +58,7 @@ import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
@ -104,6 +105,8 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRemoteAccountInterface;
import fr.gouv.etalab.mastodon.interfaces.OnUpdateAccountInfoInterface;
import fr.gouv.etalab.mastodon.services.BackupStatusService;
import fr.gouv.etalab.mastodon.services.LiveNotificationService;
import fr.gouv.etalab.mastodon.sqlite.InstancesDAO;
import fr.gouv.etalab.mastodon.sqlite.SearchDAO;
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
@ -480,11 +483,18 @@ public abstract class BaseMainActivity extends BaseActivity
updateNotifCounter();
displayNotificationsFragment.scrollToTop();
break;
default:
displayStatusFragment = ((DisplayStatusFragment) fragment);
displayStatusFragment.scrollToTop();
}
}
}
});
refreshSearchTab();
int tabCount = tabLayout.getTabCount();
for( int j = countPage ; j < tabCount ; j++){
attacheDelete(j);
}
final NavigationView navigationView = findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
@ -857,6 +867,8 @@ public abstract class BaseMainActivity extends BaseActivity
});
// Asked once for notification opt-in
boolean popupShown = sharedpreferences.getBoolean(Helper.SET_POPUP_PUSH, false);
if(!popupShown){
@ -1690,6 +1702,63 @@ public abstract class BaseMainActivity extends BaseActivity
}
private void attacheDelete(int position){
LinearLayout tabStrip = (LinearLayout) tabLayout.getChildAt(0);
String title = tabLayout.getTabAt(position).getText().toString().trim();
SQLiteDatabase db = Sqlite.getInstance(BaseMainActivity.this, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
tabStrip.getChildAt(position).setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(BaseMainActivity.this);
dialogBuilder.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
new SearchDAO(BaseMainActivity.this, db).remove(title);
String tag;
if( position > 0)
tag = tabLayout.getTabAt(position -1).getText().toString();
else if( tabLayout.getTabCount() > 1 )
tag = tabLayout.getTabAt(1).getText().toString();
else //Last element
tag = "";
Helper.removeTab(tabLayout, adapter, position);
adapter = new BaseMainActivity.PagerAdapter
(getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(adapter);
for(int i = 0; i < tabLayout.getTabCount() ; i++ ){
if( tabLayout.getTabAt(i).getText() != null && tabLayout.getTabAt(i).getText().equals(tag.trim())){
tabLayout.getTabAt(i).select();
break;
}
}
}
});
dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
dialogBuilder.setMessage(getString(R.string.delete) + ": " + title);
AlertDialog alertDialog = dialogBuilder.create();
alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
//Hide keyboard
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
assert imm != null;
imm.hideSoftInputFromWindow(viewPager.getWindowToken(), 0);
}
});
if( alertDialog.getWindow() != null )
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
alertDialog.show();
return false;
}
});
}
public void updateHomeCounter(){
if( tabLayout.getTabAt(0) == null )
return;

View File

@ -326,6 +326,11 @@ public class InstanceFederatedActivity extends BaseActivity {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
if( viewPager != null && viewPager.getAdapter() != null){
Fragment fragment = (Fragment) viewPager.getAdapter().instantiateItem(viewPager, tab.getPosition());
DisplayStatusFragment displayStatusFragment = ((DisplayStatusFragment) fragment);
displayStatusFragment.scrollToTop();
}
}
});

View File

@ -450,25 +450,25 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
if( account.getAcct() != null)
actionbar_title.setText(account.getAcct());
pp_actionBar = findViewById(R.id.pp_actionBar);
String url = account.getAvatar();
if( url.startsWith("/") ){
url = Helper.getLiveInstanceWithProtocol(getApplicationContext()) + account.getAvatar();
}
Glide.with(getApplicationContext())
.asBitmap()
.load(url)
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
BitmapDrawable ppDrawable = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(resource, (int) Helper.convertDpToPixel(25, getApplicationContext()), (int) Helper.convertDpToPixel(25, getApplicationContext()), true));
if( pp_actionBar != null){
pp_actionBar.setImageDrawable(ppDrawable);
if( account.getAvatar() != null){
String url = account.getAvatar();
if( url.startsWith("/") ){
url = Helper.getLiveInstanceWithProtocol(getApplicationContext()) + account.getAvatar();
}
Glide.with(getApplicationContext())
.asBitmap()
.load(url)
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
BitmapDrawable ppDrawable = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(resource, (int) Helper.convertDpToPixel(25, getApplicationContext()), (int) Helper.convertDpToPixel(25, getApplicationContext()), true));
if( pp_actionBar != null){
pp_actionBar.setImageDrawable(ppDrawable);
}
}
}
});
});
}
final AppBarLayout appBar = findViewById(R.id.appBar);
maxScrollSize = appBar.getTotalScrollRange();

View File

@ -49,6 +49,7 @@ import android.text.Html;
import android.text.InputFilter;
import android.text.InputType;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@ -853,7 +854,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
alert.show();
return true;
case R.id.action_translate:
final CountryPicker picker = CountryPicker.newInstance("Select Country"); // dialog title
final CountryPicker picker = CountryPicker.newInstance(getString(R.string.which_language)); // dialog title
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
final int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
if( theme == Helper.THEME_LIGHT){
@ -897,77 +898,84 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
myTransL.setYandexAPIKey(Helper.YANDEX_KEY);
myTransL.setObfuscation(true);
myTransL.setTimeout(60);
myTransL.translate(toot_cw_content.getText().toString(), myTransL.getLocale(), new com.github.stom79.mytransl.client.Results() {
@Override
public void onSuccess(Translate translate) {
try {
if( translate.getTranslatedContent() == null)
return;
if( popup_trans != null ) {
ProgressBar trans_progress_cw = popup_trans.findViewById(R.id.trans_progress_cw);
ProgressBar trans_progress_toot = popup_trans.findViewById(R.id.trans_progress_toot);
if( trans_progress_cw != null)
trans_progress_cw.setVisibility(View.GONE);
LinearLayout trans_container = popup_trans.findViewById(R.id.trans_container);
if( trans_container != null ){
TextView cw_trans = popup_trans.findViewById(R.id.cw_trans);
if( cw_trans != null) {
cw_trans.setVisibility(View.VISIBLE);
cw_trans.setText(translate.getTranslatedContent());
if( toot_cw_content.getText().toString().length() > 0)
myTransL.translate(toot_cw_content.getText().toString(), locale, new com.github.stom79.mytransl.client.Results() {
@Override
public void onSuccess(Translate translate) {
try {
if( translate.getTranslatedContent() == null)
return;
if( popup_trans != null ) {
ProgressBar trans_progress_cw = popup_trans.findViewById(R.id.trans_progress_cw);
ProgressBar trans_progress_toot = popup_trans.findViewById(R.id.trans_progress_toot);
if( trans_progress_cw != null)
trans_progress_cw.setVisibility(View.GONE);
LinearLayout trans_container = popup_trans.findViewById(R.id.trans_container);
if( trans_container != null ){
TextView cw_trans = popup_trans.findViewById(R.id.cw_trans);
if( cw_trans != null) {
cw_trans.setVisibility(View.VISIBLE);
cw_trans.setText(translate.getTranslatedContent());
}
}else {
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
}
}else {
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
if(trans_progress_cw != null && trans_progress_toot != null && trans_progress_cw.getVisibility() == View.GONE && trans_progress_toot.getVisibility() == View.GONE )
if( dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null)
dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
}
if(trans_progress_cw != null && trans_progress_toot != null && trans_progress_cw.getVisibility() == View.GONE && trans_progress_toot.getVisibility() == View.GONE )
if( dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null)
dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
} catch (IllegalArgumentException e) {
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
}
} catch (IllegalArgumentException e) {
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
}
}
@Override
public void onFail(HttpsConnectionException e) {
}
});
myTransL.translate(toot_content.getText().toString(), myTransL.getLocale(), new com.github.stom79.mytransl.client.Results() {
@Override
public void onSuccess(Translate translate) {
try {
if( translate.getTranslatedContent() == null)
return;
if( popup_trans != null ) {
ProgressBar trans_progress_cw = popup_trans.findViewById(R.id.trans_progress_cw);
ProgressBar trans_progress_toot = popup_trans.findViewById(R.id.trans_progress_toot);
if( trans_progress_toot != null)
trans_progress_toot.setVisibility(View.GONE);
LinearLayout trans_container = popup_trans.findViewById(R.id.trans_container);
if( trans_container != null ){
TextView toot_trans = popup_trans.findViewById(R.id.toot_trans);
if(toot_trans != null){
toot_trans.setVisibility(View.VISIBLE);
toot_trans.setText(translate.getTranslatedContent());
}
}else {
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
}
if(trans_progress_cw != null && trans_progress_toot != null && trans_progress_cw.getVisibility() == View.GONE && trans_progress_toot.getVisibility() == View.GONE )
if( dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null)
dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
}
} catch (IllegalArgumentException e) {
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
@Override
public void onFail(HttpsConnectionException e) {
e.printStackTrace();
}
});
else {
ProgressBar trans_progress_cw = popup_trans.findViewById(R.id.trans_progress_cw);
trans_progress_cw.setVisibility(View.GONE);
}
if( toot_content.getText().toString().length() > 0)
myTransL.translate(toot_content.getText().toString(), locale, new com.github.stom79.mytransl.client.Results() {
@Override
public void onSuccess(Translate translate) {
try {
if( translate.getTranslatedContent() == null)
return;
if( popup_trans != null ) {
ProgressBar trans_progress_cw = popup_trans.findViewById(R.id.trans_progress_cw);
ProgressBar trans_progress_toot = popup_trans.findViewById(R.id.trans_progress_toot);
if( trans_progress_toot != null)
trans_progress_toot.setVisibility(View.GONE);
LinearLayout trans_container = popup_trans.findViewById(R.id.trans_container);
if( trans_container != null ){
TextView toot_trans = popup_trans.findViewById(R.id.toot_trans);
if(toot_trans != null){
toot_trans.setVisibility(View.VISIBLE);
toot_trans.setText(translate.getTranslatedContent());
}
}else {
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
}
if(trans_progress_cw != null && trans_progress_toot != null && trans_progress_cw.getVisibility() == View.GONE && trans_progress_toot.getVisibility() == View.GONE )
if( dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null)
dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
}
} catch (IllegalArgumentException e) {
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
}
}
}
@Override
public void onFail(HttpsConnectionException e) {
@Override
public void onFail(HttpsConnectionException e) {
e.printStackTrace();
}
});
}
});
transAlert.setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.dismiss();

View File

@ -99,13 +99,11 @@ public class PostActionAsyncTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
Log.v(Helper.TAG,"account: " + account);
//Remote action
if (account != null)
api = new API(contextReference.get(), account.getInstance(), account.getToken());
else
api = new API(contextReference.get());
Log.v(Helper.TAG,"remoteStatus: " + remoteStatus);
if (remoteStatus != null) {
String uri;
if (remoteStatus.getReblog() != null) {
@ -119,9 +117,7 @@ public class PostActionAsyncTask extends AsyncTask<Void, Void, Void> {
else
uri = remoteStatus.getUrl();
}
Log.v(Helper.TAG,"uri: " + uri);
Results search = api.search(uri);
Log.v(Helper.TAG,"search: " + search);
if (search != null) {
List<fr.gouv.etalab.mastodon.client.Entities.Status> remoteStatuses = search.getStatuses();
if (remoteStatuses != null && remoteStatuses.size() > 0) {

View File

@ -38,6 +38,7 @@ public class RetrieveMissingFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
private List<fr.gouv.etalab.mastodon.client.Entities.Status> statuses = new ArrayList<>();
private RetrieveFeedsAsyncTask.Type type;
private WeakReference<Context> contextReference;
private String remoteInstance;
public RetrieveMissingFeedsAsyncTask(Context context, String since_id, RetrieveFeedsAsyncTask.Type type, OnRetrieveMissingFeedsInterface onRetrieveMissingFeedsInterface){
this.contextReference = new WeakReference<>(context);
@ -46,6 +47,14 @@ public class RetrieveMissingFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
this.type = type;
}
public RetrieveMissingFeedsAsyncTask(Context context, String remoteInstance, String since_id, RetrieveFeedsAsyncTask.Type type, OnRetrieveMissingFeedsInterface onRetrieveMissingFeedsInterface){
this.contextReference = new WeakReference<>(context);
this.since_id = since_id;
this.listener = onRetrieveMissingFeedsInterface;
this.type = type;
this.remoteInstance = remoteInstance;
}
@Override
protected Void doInBackground(Void... params) {
@ -58,6 +67,8 @@ public class RetrieveMissingFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
apiResponse = api.getPublicTimelineSinceId(true, since_id);
else if( type == RetrieveFeedsAsyncTask.Type.PUBLIC)
apiResponse = api.getPublicTimelineSinceId(false, since_id);
else if (type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE)
apiResponse = api.getInstanceTimelineSinceId(remoteInstance, since_id);
if (apiResponse != null) {
tempStatus = apiResponse.getStatuses();
if( tempStatus != null)

View File

@ -29,6 +29,7 @@ import java.lang.*;
import java.net.URLEncoder;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@ -561,7 +562,15 @@ public class API {
return getPublicTimeline(local, null, null, since_id, tootPerPage);
}
/**
* Retrieves instance timeline since an Id value *synchronously*
* @param instanceName String instance name
* @param since_id String id since
* @return APIResponse
*/
public APIResponse getInstanceTimelineSinceId(String instanceName, String since_id) {
return getPublicTimeline(true, null, null, since_id, tootPerPage);
}
/**
* Retrieves public timeline for the account *synchronously*
@ -1736,17 +1745,15 @@ public class API {
InstanceSocial instanceSocial = new InstanceSocial();
try {
instanceSocial.setAdded_at(Helper.mstStringToDate(context, resobj.get("added_at").toString()));
instanceSocial.setChecked_at(Helper.mstStringToDate(context, resobj.get("checked_at").toString()));
instanceSocial.setUpdated_at(Helper.mstStringToDate(context, resobj.get("updated_at").toString()));
instanceSocial.setUptime(Float.parseFloat(resobj.get("uptime").toString()));
instanceSocial.setUp(Boolean.parseBoolean(resobj.get("up").toString()));
instanceSocial.setConnections(Long.parseLong(resobj.get("connections").toString()));
instanceSocial.setDead(Boolean.parseBoolean(resobj.get("dead").toString()));
instanceSocial.setHttps_rank(resobj.get("https_rank").toString());
instanceSocial.setHttps_score(Integer.parseInt(resobj.get("https_score").toString()));
instanceSocial.setId(resobj.get("id").toString());
instanceSocial.setInfo(resobj.get("info").toString());
@ -1761,7 +1768,15 @@ public class API {
instanceSocial.setUsers(Long.parseLong(resobj.get("users").toString()));
instanceSocial.setStatuses(Long.parseLong(resobj.get("statuses").toString()));
} catch (JSONException ignored) {}
instanceSocial.setHttps_rank(resobj.get("https_rank").toString());
instanceSocial.setHttps_score(Integer.parseInt(resobj.get("https_score").toString()));
instanceSocial.setAdded_at(Helper.mstStringToDate(context, resobj.get("added_at").toString()));
instanceSocial.setChecked_at(Helper.mstStringToDate(context, resobj.get("checked_at").toString()));
instanceSocial.setUpdated_at(Helper.mstStringToDate(context, resobj.get("updated_at").toString()));
} catch (Exception e) {
e.printStackTrace();
}
return instanceSocial;
}
@ -1937,7 +1952,9 @@ public class API {
try{
status.setReblog(parseStatuses(context, resobj.getJSONObject("reblog")));
}catch (Exception ignored){}
} catch (JSONException ignored) {}
} catch (JSONException ignored) {} catch (ParseException e) {
e.printStackTrace();
}
return status;
}
@ -2092,7 +2109,9 @@ public class API {
}catch (Exception e){
account.setEmojis(new ArrayList<>());
}
} catch (JSONException ignored) {}
} catch (JSONException ignored) {} catch (ParseException e) {
e.printStackTrace();
}
return account;
}
@ -2236,7 +2255,9 @@ public class API {
notification.setStatus(parseStatuses(context, resobj.getJSONObject("status")));
}catch (Exception ignored){}
notification.setCreated_at(Helper.mstStringToDate(context, resobj.get("created_at").toString()));
} catch (JSONException ignored) {}
} catch (JSONException ignored) {} catch (ParseException e) {
e.printStackTrace();
}
return notification;
}

View File

@ -36,6 +36,7 @@ import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.ImageSpan;
import android.text.style.URLSpan;
import android.util.Log;
import android.util.Patterns;
import android.view.View;

View File

@ -19,6 +19,7 @@ import android.database.sqlite.SQLiteDatabase;
import android.os.Build;
import android.text.Html;
import android.text.SpannableString;
import android.util.Log;
import com.google.common.io.ByteStreams;
import org.json.JSONObject;
@ -499,12 +500,9 @@ public class HttpsConnection {
});
}
httpsURLConnection.disconnect();
} catch (IOException e) {
Error error = new Error();
error.setError(context.getString(R.string.toast_error));
if (httpsURLConnection != null)
httpsURLConnection.disconnect();
}
} else {
@ -589,12 +587,9 @@ public class HttpsConnection {
});
}
httpURLConnection.disconnect();
} catch (IOException e) {
Error error = new Error();
error.setError(context.getString(R.string.toast_error));
if (httpURLConnection != null)
httpURLConnection.disconnect();
}
}
@ -1611,12 +1606,14 @@ public class HttpsConnection {
return;
Map<String, List<String>> map = httpsURLConnection.getHeaderFields();
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
if (entry.toString().startsWith("Link")) {
Log.v(Helper.TAG, entry.toString() );
if (entry.toString().startsWith("Link") || entry.toString().startsWith("link") ) {
Pattern patternMaxId = Pattern.compile("max_id=([0-9]{1,}).*");
Matcher matcherMaxId = patternMaxId.matcher(entry.toString());
if (matcherMaxId.find()) {
max_id = matcherMaxId.group(1);
}
Log.v(Helper.TAG, "max_id -> " + max_id );
if (entry.toString().startsWith("Link")) {
Pattern patternSinceId = Pattern.compile("since_id=([0-9]{1,}).*");
Matcher matcherSinceId = patternSinceId.matcher(entry.toString());
@ -1625,6 +1622,7 @@ public class HttpsConnection {
}
}
Log.v(Helper.TAG, "since_id -> " + since_id );
}
}
}else {
@ -1632,7 +1630,7 @@ public class HttpsConnection {
return;
Map<String, List<String>> map = httpURLConnection.getHeaderFields();
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
if (entry.toString().startsWith("Link")) {
if (entry.toString().startsWith("Link") || entry.toString().startsWith("link")) {
Pattern patternMaxId = Pattern.compile("max_id=([0-9]{1,}).*");
Matcher matcherMaxId = patternMaxId.matcher(entry.toString());
if (matcherMaxId.find()) {
@ -1674,11 +1672,15 @@ public class HttpsConnection {
HttpsConnectionException(int statusCode, String message) {
this.statusCode = statusCode;
SpannableString spannableString;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
spannableString = new SpannableString(Html.fromHtml(message, Html.FROM_HTML_MODE_LEGACY));
else
//noinspection deprecation
spannableString = new SpannableString(Html.fromHtml(message));
if( message != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
spannableString = new SpannableString(Html.fromHtml(message, Html.FROM_HTML_MODE_LEGACY));
else
//noinspection deprecation
spannableString = new SpannableString(Html.fromHtml(message));
}else {
spannableString = new SpannableString(context.getString(R.string.toast_error));
}
this.message = spannableString.toString();
}

View File

@ -153,7 +153,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, showMediaOnly, showPinned, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else if( type == RetrieveFeedsAsyncTask.Type.TAG)
asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else if( remoteInstance != null)
else if( type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE )
asyncTask = new RetrieveFeedsAsyncTask(context, type, remoteInstance, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else
asyncTask = new RetrieveFeedsAsyncTask(context, type, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
@ -212,7 +212,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, showMediaOnly, showPinned, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else if (type == RetrieveFeedsAsyncTask.Type.TAG)
asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else if( remoteInstance != null)
else if( type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE )
asyncTask = new RetrieveFeedsAsyncTask(context, type, remoteInstance, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else {
if( type == RetrieveFeedsAsyncTask.Type.HOME ){
@ -236,7 +236,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, showMediaOnly, showPinned, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else if (type == RetrieveFeedsAsyncTask.Type.TAG)
asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else if( remoteInstance != null)
else if( type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE )
asyncTask = new RetrieveFeedsAsyncTask(context, type, remoteInstance, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else {
if( type == RetrieveFeedsAsyncTask.Type.HOME ){
@ -476,7 +476,13 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
* @param sinceId String
*/
public void retrieveMissingToots(String sinceId){
asyncTask = new RetrieveMissingFeedsAsyncTask(context, sinceId, type, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
if (type == RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE)
asyncTask = new RetrieveMissingFeedsAsyncTask(context, remoteInstance, sinceId, type, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else if( type == RetrieveFeedsAsyncTask.Type.TAG)
asyncTask = new RetrieveFeedsAsyncTask(context, type, tag, targetedId, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else
asyncTask = new RetrieveMissingFeedsAsyncTask(context, sinceId, type, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
/**

View File

@ -477,7 +477,7 @@ public class Helper {
* @param date String
* @return Date
*/
public static Date mstStringToDate(Context context, String date){
public static Date mstStringToDate(Context context, String date) throws ParseException {
Locale userLocale;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
userLocale = context.getResources().getConfiguration().getLocales().get(0);
@ -489,11 +489,7 @@ public class Helper {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(STRING_DATE_FORMAT, userLocale);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("gmt"));
simpleDateFormat.setLenient(true);
try {
return simpleDateFormat.parse(date);
} catch (ParseException e) {
return null;
}
return simpleDateFormat.parse(date);
}
@ -2208,6 +2204,14 @@ public class Helper {
}
}
public static void removeTab(TabLayout tableLayout, BaseMainActivity.PagerAdapter pagerAdapter, int position) {
if (tableLayout.getTabCount() >= position ) {
if(tableLayout.getTabCount() > 0)
tableLayout.removeTabAt(position);
pagerAdapter.removeTabPage();
}
}
public static void addTab(TabLayout tableLayout, InstanceFederatedActivity.PagerAdapter pagerAdapter, String title) {
tableLayout.addTab(tableLayout.newTab().setText(title));
pagerAdapter.addTabPage(title);
@ -2250,12 +2254,7 @@ public class Helper {
removeTab(tableLayout, pagerAdapter, selection);
}
private static void removeTab(TabLayout tableLayout, BaseMainActivity.PagerAdapter pagerAdapter, int position) {
if (tableLayout.getTabCount() >= position) {
tableLayout.removeTabAt(position);
pagerAdapter.removeTabPage();
}
}
private static void addTab(TabLayout tableLayout, BaseMainActivity.PagerAdapter pagerAdapter, String title) {
tableLayout.addTab(tableLayout.newTab().setText(title));

View File

@ -271,9 +271,6 @@ public class LiveNotificationService extends Service {
} catch (IOException ignored) {
}
}
if (inputStream != null) {
httpsURLConnection.disconnect();
}
SystemClock.sleep(5000);
Intent streamingIntent = new Intent(this, LiveNotificationService.class);
streamingIntent.putExtra("userId", account.getId());
@ -360,9 +357,6 @@ public class LiveNotificationService extends Service {
} catch (IOException ignored) {
}
}
if (inputStream != null) {
httpURLConnection.disconnect();
}
SystemClock.sleep(5000);
Intent streamingIntent = new Intent(this, LiveNotificationService.class);
streamingIntent.putExtra("userId", account.getId());

View File

@ -94,8 +94,6 @@ public class StreamingFederatedTimelineService extends IntentService {
InputStream inputStream;
BufferedReader reader = null;
Account accountStream = null;
if( httpsURLConnection != null)
httpsURLConnection.disconnect();
if( userId != null) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
accountStream = new AccountDAO(getApplicationContext(), db).getAccountByID(userId);
@ -119,7 +117,6 @@ public class StreamingFederatedTimelineService extends IntentService {
String event;
while((event = reader.readLine()) != null) {
if (!sharedpreferences.getBoolean(Helper.SHOULD_CONTINUE_STREAMING_FEDERATED + accountStream.getId() + accountStream.getInstance(), true)) {
httpsURLConnection.disconnect();
stopSelf();
return;
}

View File

@ -93,8 +93,6 @@ public class StreamingLocalTimelineService extends IntentService {
InputStream inputStream;
BufferedReader reader = null;
Account accountStream = null;
if( httpsURLConnection != null)
httpsURLConnection.disconnect();
if( userId != null) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
accountStream = new AccountDAO(getApplicationContext(), db).getAccountByID(userId);
@ -118,7 +116,6 @@ public class StreamingLocalTimelineService extends IntentService {
String event;
while((event = reader.readLine()) != null) {
if (!sharedpreferences.getBoolean(Helper.SHOULD_CONTINUE_STREAMING_LOCAL + accountStream.getId() + accountStream.getInstance(), true)) {
httpsURLConnection.disconnect();
stopSelf();
return;
}

View File

@ -29,13 +29,12 @@
tools:ignore="ContentDescription" />
<TextView
android:visibility="gone"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_marginLeft="15dp"
android:layout_marginStart="15dp"
android:id="@+id/tab_counter"
android:layout_alignRight="@+id/tab_icon"
android:layout_alignEnd="@+id/tab_icon"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:layout_alignBaseline="@+id/tab_icon"
android:layout_alignParentTop="true"
android:gravity="center"
android:textSize="12sp"

View File

@ -499,4 +499,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -507,4 +507,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -499,4 +499,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -505,4 +505,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -499,4 +499,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -488,4 +488,5 @@ Die Anwendung <b>nutzt keine Trackingwergzeuge</b>(Zielgruppenbestimmung, Fehler
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -499,4 +499,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -494,4 +494,5 @@ Gracias a: </string>
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -498,4 +498,5 @@ Eskerrik asko Stéphane logoagatik. </string>
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -499,4 +499,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -499,4 +499,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -497,4 +497,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -505,4 +505,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -499,4 +499,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -498,4 +498,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -498,4 +498,5 @@ https://yandex.ru/legal/confidential/?lang=en
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -499,4 +499,5 @@ Per favore, conferma le notifiche push che vuoi ricevere.
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -488,4 +488,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -496,4 +496,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -499,4 +499,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -491,4 +491,5 @@ Takk til: </string>
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -502,4 +502,5 @@ Podziękowania dla: </string>
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -499,4 +499,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -499,4 +499,5 @@ Vă mulțumesc:
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -503,4 +503,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -502,4 +502,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -52,17 +52,17 @@
<string name="next">Nästa</string>
<string name="previous">Föregående</string>
<string name="open_with">Öppna med</string>
<string name="validate">Validate</string>
<string name="validate">Bekräfta</string>
<string name="media">Media</string>
<string name="share_with">Share with</string>
<string name="shared_via">Shared via Mastalab</string>
<string name="replies">Replies</string>
<string name="username">User name</string>
<string name="drafts">Drafts</string>
<string name="new_data">New data are available! Do you want to display them?</string>
<string name="favourite">Favourites</string>
<string name="follow">New followers</string>
<string name="mention">Mentions</string>
<string name="share_with">Dela med</string>
<string name="shared_via">Delat via Mastalab</string>
<string name="replies">Svar</string>
<string name="username">Användarnamn</string>
<string name="drafts">Utkast</string>
<string name="new_data">Det finns nya data! Vill du visa dem?</string>
<string name="favourite">Favoriter</string>
<string name="follow">Nya följare</string>
<string name="mention">Omnämningar</string>
<string name="reblog">Boosts</string>
<string name="show_boosts">Show boosts</string>
<string name="show_replies">Show replies</string>
@ -499,4 +499,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -492,4 +492,5 @@ Teşekkürler: </string>
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -495,4 +495,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -494,4 +494,5 @@ Cảm ơn bạn: </string>
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -491,4 +491,5 @@ Yandex 有适当的隐私政策可以在这里找到https://yandex.ru/lega
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -491,4 +491,5 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
</resources>

View File

@ -547,6 +547,7 @@
<string name="toast_instance_unavailable">No timelines was found on this instance!</string>
<string name="delete_instance">Delete this instance?</string>
<string name="warning_delete_instance">You are going to delete %s from your followed instances.</string>
<string name="which_language">Translate in</string>
<string-array translatable="false" name="proxy_type_choice">
<item>HTTP</item>
<item>SOCKS</item>