improve toast messages

This commit is contained in:
stom79 2018-11-25 10:45:16 +01:00
parent 3d73928197
commit 21996e6ee8
45 changed files with 237 additions and 197 deletions

View File

@ -39,6 +39,7 @@ import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRelationshipAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRemoteDataAsyncTask;
@ -270,7 +271,7 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
public void onRetrieveRemoteAccount(Results results) {
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
if( results == null){
Toast.makeText(getApplicationContext(), R.string.toast_error,Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), getString(R.string.toast_error),Toast.LENGTH_LONG).show();
return;
}
List<Account> accounts = results.getAccounts();

View File

@ -91,6 +91,7 @@ import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.ManageFiltersAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.ManageListsAsyncTask;
@ -358,7 +359,7 @@ public abstract class BaseMainActivity extends BaseActivity
alertDialog.show();
}catch (Exception e){
Toast.makeText(BaseMainActivity.this, R.string.toast_error, Toast.LENGTH_SHORT).show();
Toasty.error(BaseMainActivity.this, getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
}
}
});
@ -540,7 +541,7 @@ public abstract class BaseMainActivity extends BaseActivity
e.printStackTrace();
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(), R.string.toast_instance_unavailable,Toast.LENGTH_LONG).show();
Toasty.warning(getApplicationContext(), getString(R.string.toast_instance_unavailable),Toast.LENGTH_LONG).show();
}
});
}
@ -1243,7 +1244,7 @@ public abstract class BaseMainActivity extends BaseActivity
new TimelineCacheDAO(BaseMainActivity.this, db).removeAllStatus(TimelineCacheDAO.HOME_TIMELINE);
}
});
Toast.makeText(BaseMainActivity.this, getString(R.string.toast_cache_clear,String.format("%s %s", String.format(Locale.getDefault(), "%.2f", finalCacheSize), getString(R.string.cache_units))), Toast.LENGTH_LONG).show();
Toasty.success(BaseMainActivity.this, getString(R.string.toast_cache_clear,String.format("%s %s", String.format(Locale.getDefault(), "%.2f", finalCacheSize), getString(R.string.cache_units))), Toast.LENGTH_LONG).show();
dialog.dismiss();
}
})
@ -1592,7 +1593,7 @@ public abstract class BaseMainActivity extends BaseActivity
@SuppressLint("InflateParams") View dialogView = inflater.inflate(R.layout.filter_regex, null);
dialogBuilder.setView(dialogView);
final EditText editText = dialogView.findViewById(R.id.filter_regex);
Toast alertRegex = Toast.makeText(BaseMainActivity.this, R.string.alert_regex, Toast.LENGTH_LONG);
Toast alertRegex = Toasty.warning(BaseMainActivity.this, getString(R.string.alert_regex), Toast.LENGTH_LONG);
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -1986,7 +1987,7 @@ public abstract class BaseMainActivity extends BaseActivity
try {
startActivity(Intent.createChooser(i, getString(R.string.bug_report_mail)));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getApplicationContext(), R.string.no_mail_client, Toast.LENGTH_SHORT).show();
Toasty.info(getApplicationContext(), getString(R.string.no_mail_client), Toast.LENGTH_SHORT).show();
}
return false;
}

View File

@ -64,6 +64,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountInfoAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.UpdateCredentialAsyncTask;
@ -210,7 +211,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
@Override
public void onRetrieveAccount(Account account, Error error) {
if( error != null ){
Toast.makeText(getApplicationContext(),R.string.toast_error, Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(),getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return;
}
set_profile_name.setText(account.getDisplay_name());
@ -245,7 +246,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
String content = s.toString().substring(0,160);
set_profile_description.setText(content);
set_profile_description.setSelection(set_profile_description.getText().length());
Toast.makeText(getApplicationContext(),R.string.note_no_space,Toast.LENGTH_LONG).show();
Toasty.info(getApplicationContext(),getString(R.string.note_no_space),Toast.LENGTH_LONG).show();
}
}
});
@ -303,7 +304,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
String content = s.toString().substring(0,30);
set_profile_name.setText(content);
set_profile_name.setSelection(set_profile_name.getText().length());
Toast.makeText(getApplicationContext(),R.string.username_no_space,Toast.LENGTH_LONG).show();
Toasty.info(getApplicationContext(),getString(R.string.username_no_space),Toast.LENGTH_LONG).show();
}
}
});
@ -514,7 +515,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMAGE_HEADER && resultCode == Activity.RESULT_OK) {
if (data == null || data.getData() == null) {
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(),getString(R.string.toot_select_image_error),Toast.LENGTH_LONG).show();
return;
}
Uri fileUri = data.getData();
@ -532,7 +533,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
header_picture = Helper.compressImage(EditProfileActivity.this, fileUri, Helper.MediaType.MEDIA);
}else if(requestCode == PICK_IMAGE_PROFILE && resultCode == Activity.RESULT_OK) {
if (data == null || data.getData() == null) {
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(),getString(R.string.toot_select_image_error),Toast.LENGTH_LONG).show();
return;
}
Uri fileUri = data.getData();
@ -555,10 +556,10 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
public void onUpdateCredential(APIResponse apiResponse) {
set_profile_save.setEnabled(true);
if( apiResponse.getError() != null){
Toast.makeText(getApplicationContext(), R.string.toast_error, Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return;
}
Toast.makeText(getApplicationContext(), R.string.toast_update_credential_ok, Toast.LENGTH_LONG).show();
Toasty.success(getApplicationContext(), getString(R.string.toast_update_credential_ok), Toast.LENGTH_LONG).show();
Intent mStartActivity = new Intent(EditProfileActivity.this, BaseMainActivity.class);
int mPendingIntentId = 45641;

View File

@ -15,7 +15,6 @@
package fr.gouv.etalab.mastodon.activities;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
@ -36,6 +35,7 @@ import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
import fr.gouv.etalab.mastodon.client.APIResponse;
@ -206,7 +206,7 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte
mainLoader.setVisibility(View.GONE);
nextElementLoader.setVisibility(View.GONE);
if( apiResponse.getError() != null){
Toast.makeText(getApplicationContext(), apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
return;
}
List<Status> statuses = apiResponse.getStatuses();

View File

@ -37,6 +37,7 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveInstanceAsyncTask;
import fr.gouv.etalab.mastodon.client.APIResponse;
@ -44,7 +45,6 @@ import fr.gouv.etalab.mastodon.client.Entities.Instance;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveInstanceInterface;
import static fr.gouv.etalab.mastodon.helper.Helper.THEME_LIGHT;
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
@ -130,7 +130,7 @@ public class InstanceActivity extends BaseActivity implements OnRetrieveInstance
instance_container.setVisibility(View.VISIBLE);
loader.setVisibility(View.GONE);
if( apiResponse.getError() != null){
Toast.makeText(getApplicationContext(), R.string.toast_error, Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return;
}
final Instance instance = apiResponse.getInstance();

View File

@ -38,10 +38,10 @@ import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.ManageListsAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
@ -130,7 +130,7 @@ public class ListActivity extends BaseActivity implements OnListActionInterface
title = b.getString("title");
listId = b.getString("id");
}else{
Toast.makeText(this,R.string.toast_error_search,Toast.LENGTH_LONG).show();
Toasty.error(this,getString(R.string.toast_error_search),Toast.LENGTH_LONG).show();
}
if( getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -277,7 +277,7 @@ public class ListActivity extends BaseActivity implements OnListActionInterface
//Discards 404 - error which can often happen due to toots which have been deleted
if (apiResponse.getError() != null) {
if ( !apiResponse.getError().getError().startsWith("404 -"))
Toast.makeText(ListActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
Toasty.error(ListActivity.this, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
swipeRefreshLayout.setRefreshing(false);
swiped = false;
flag_loading = false;

View File

@ -24,7 +24,6 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.design.widget.TextInputLayout;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
@ -46,15 +45,18 @@ import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoAsyncTask;
import fr.gouv.etalab.mastodon.client.HttpsConnection;
@ -340,7 +342,7 @@ public class LoginActivity extends BaseActivity {
try {
instance = URLEncoder.encode(login_instance.getText().toString().trim(), "utf-8");
} catch (UnsupportedEncodingException e) {
Toast.makeText(LoginActivity.this,R.string.client_error, Toast.LENGTH_LONG).show();
Toasty.error(LoginActivity.this,getString(R.string.client_error), Toast.LENGTH_LONG).show();
}
final String action = "/api/v1/apps";
final HashMap<String, String> parameters = new HashMap<>();
@ -395,7 +397,7 @@ public class LoginActivity extends BaseActivity {
message = e.getMessage();
else
message = getString(R.string.client_error);
Toast.makeText(getApplicationContext(), message,Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), message,Toast.LENGTH_LONG).show();
}
});
}
@ -463,7 +465,7 @@ public class LoginActivity extends BaseActivity {
message = e.getMessage();
else
message = getString(R.string.client_error);
Toast.makeText(getApplicationContext(), message,Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), message,Toast.LENGTH_LONG).show();
}
});
}

View File

@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.jobs.ApplicationJob;
import fr.gouv.etalab.mastodon.jobs.HomeTimelineSyncJob;
@ -55,5 +56,6 @@ public class MainApplication extends Application{
SUPPORTED_LOCALES.add(defaultLocale);
LocaleChanger.initialize(getApplicationContext(), SUPPORTED_LOCALES);
}catch (Exception ignored){ignored.printStackTrace();}
Toasty.Config.getInstance().apply();
}
}

View File

@ -34,9 +34,9 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.ManageListsAsyncTask;
import fr.gouv.etalab.mastodon.client.APIResponse;
@ -96,7 +96,7 @@ public class ManageAccountsInListActivity extends BaseActivity implements OnList
title = b.getString("title");
listId = b.getString("id");
}else{
Toast.makeText(this,R.string.toast_error,Toast.LENGTH_LONG).show();
Toasty.error(this,getString(R.string.toast_error),Toast.LENGTH_LONG).show();
}
main_account_container = findViewById(R.id.main_account_container);
@ -182,7 +182,7 @@ public class ManageAccountsInListActivity extends BaseActivity implements OnList
loader.setVisibility(View.GONE);
main_account_container.setVisibility(View.VISIBLE);
if( apiResponse.getError() != null){
Toast.makeText(ManageAccountsInListActivity.this, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
Toasty.error(ManageAccountsInListActivity.this, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
return;
}
if( actionType == ManageListsAsyncTask.action.GET_LIST_ACCOUNT){

View File

@ -55,6 +55,7 @@ import java.util.Calendar;
import java.util.Date;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
import fr.gouv.etalab.mastodon.client.APIResponse;
@ -428,7 +429,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
nextElementLoader.setVisibility(View.GONE);
//Discards 404 - error which can often happen due to toots which have been deleted
if( apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 404 ){
Toast.makeText(OwnerStatusActivity.this, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
Toasty.error(OwnerStatusActivity.this, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
swipeRefreshLayout.setRefreshing(false);
swiped = false;
flag_loading = false;

View File

@ -15,7 +15,6 @@
package fr.gouv.etalab.mastodon.activities;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -29,7 +28,6 @@ import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
@ -37,6 +35,7 @@ import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRelationshipAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRemoteDataAsyncTask;
@ -150,7 +149,7 @@ public class PartnerShipActivity extends BaseActivity implements OnRetrieveRemot
public void onRetrieveRemoteAccount(Results results) {
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
if( results == null){
Toast.makeText(getApplicationContext(), R.string.toast_error,Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), getString(R.string.toast_error),Toast.LENGTH_LONG).show();
return;
}
List<Account> accounts = results.getAccounts();

View File

@ -34,7 +34,6 @@ import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.Html;
@ -45,13 +44,13 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.VideoView;
import java.lang.ref.WeakReference;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
@ -60,6 +59,7 @@ import java.util.Objects;
import javax.net.ssl.HttpsURLConnection;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.RetrievePeertubeSingleAsyncTask;
@ -200,7 +200,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
finish();
return true;
case R.id.action_comment:
Toast.makeText(PeertubeActivity.this, R.string.retrieve_remote_status, Toast.LENGTH_LONG).show();
Toasty.info(PeertubeActivity.this, getString(R.string.retrieve_remote_status), Toast.LENGTH_LONG).show();
new AsyncTask<Void, Void, Void>() {
private List<fr.gouv.etalab.mastodon.client.Entities.Status> remoteStatuses;
@ -223,7 +223,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
Intent intent = new Intent(contextReference.get(), TootActivity.class);
Bundle b = new Bundle();
if( remoteStatuses == null || remoteStatuses.size() == 0){
Toast.makeText(contextReference.get(), R.string.toast_error, Toast.LENGTH_SHORT).show();
Toasty.error(contextReference.get(), getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
return;
}
if( remoteStatuses.get(0).getReblog() != null ) {
@ -253,12 +253,12 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
public void onRetrievePeertube(APIResponse apiResponse) {
if( apiResponse == null || (apiResponse.getError() != null) || apiResponse.getPeertubes() == null || apiResponse.getPeertubes().size() == 0){
Toast.makeText(PeertubeActivity.this, R.string.toast_error,Toast.LENGTH_LONG).show();
Toasty.error(PeertubeActivity.this, getString(R.string.toast_error),Toast.LENGTH_LONG).show();
loader.setVisibility(View.GONE);
return;
}
if( apiResponse.getPeertubes() == null || apiResponse.getPeertubes().get(0) == null || apiResponse.getPeertubes().get(0).getFileUrl(null) == null){
Toast.makeText(PeertubeActivity.this, R.string.toast_error,Toast.LENGTH_LONG).show();
Toasty.error(PeertubeActivity.this, getString(R.string.toast_error),Toast.LENGTH_LONG).show();
loader.setVisibility(View.GONE);
return;
}
@ -336,10 +336,10 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
List<Peertube> peertubes = new PeertubeFavoritesDAO(PeertubeActivity.this, db).getSinglePeertube(peertube);
if( peertubes == null || peertubes.size() == 0){
new PeertubeFavoritesDAO(PeertubeActivity.this, db).insert(peertube);
Toast.makeText(PeertubeActivity.this,R.string.bookmark_add_peertube, Toast.LENGTH_SHORT).show();
Toasty.success(PeertubeActivity.this,getString(R.string.bookmark_add_peertube), Toast.LENGTH_SHORT).show();
}else{
new PeertubeFavoritesDAO(PeertubeActivity.this, db).remove(peertube);
Toast.makeText(PeertubeActivity.this,R.string.bookmark_remove_peertube, Toast.LENGTH_SHORT).show();
Toasty.success(PeertubeActivity.this,getString(R.string.bookmark_remove_peertube), Toast.LENGTH_SHORT).show();
}
if( peertubes != null && peertubes.size() > 0) //Was initially in cache
peertube_bookmark.setCompoundDrawablesWithIntrinsicBounds( null, ContextCompat.getDrawable(PeertubeActivity.this, R.drawable.ic_bookmark_peertube_border), null ,null);
@ -383,9 +383,9 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
public void onRetrievePeertubeComments(APIResponse apiResponse) {
if( apiResponse == null || (apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 404) ){
if( apiResponse == null)
Toast.makeText(PeertubeActivity.this, R.string.toast_error,Toast.LENGTH_LONG).show();
Toasty.error(PeertubeActivity.this, getString(R.string.toast_error),Toast.LENGTH_LONG).show();
else
Toast.makeText(PeertubeActivity.this, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
Toasty.error(PeertubeActivity.this, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
return;
}
List<Status> statuses = apiResponse.getStatuses();

View File

@ -34,6 +34,7 @@ import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveSearchAsyncTask;
import fr.gouv.etalab.mastodon.client.APIResponse;
@ -91,9 +92,9 @@ public class SearchResultActivity extends BaseActivity implements OnRetrieveSear
if( search != null)
new RetrieveSearchAsyncTask(getApplicationContext(), search.trim(), SearchResultActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else
Toast.makeText(this,R.string.toast_error_search,Toast.LENGTH_LONG).show();
Toasty.error(this,getString(R.string.toast_error_search),Toast.LENGTH_LONG).show();
}else{
Toast.makeText(this,R.string.toast_error_search,Toast.LENGTH_LONG).show();
Toasty.error(this,getString(R.string.toast_error_search),Toast.LENGTH_LONG).show();
}
if( getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -141,7 +142,7 @@ public class SearchResultActivity extends BaseActivity implements OnRetrieveSear
public void onRetrieveSearch(Results results, Error error) {
loader.setVisibility(View.GONE);
if( error != null){
Toast.makeText(getApplicationContext(), error.getError(),Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), error.getError(),Toast.LENGTH_LONG).show();
return;
}
if( results == null || (results.getAccounts().size() == 0 && results.getStatuses().size() == 0 && results.getHashtags().size() == 0)){
@ -165,7 +166,7 @@ public class SearchResultActivity extends BaseActivity implements OnRetrieveSear
public void onRetrieveSearchStatus(APIResponse apiResponse, Error error) {
loader.setVisibility(View.GONE);
if( apiResponse.getError() != null){
Toast.makeText(getApplicationContext(), error.getError(),Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), error.getError(),Toast.LENGTH_LONG).show();
return;
}
lv_search.setVisibility(View.VISIBLE);

View File

@ -67,6 +67,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountAsyncTask;
@ -190,7 +191,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
}else{
Toast.makeText(this,R.string.toast_error_loading_account,Toast.LENGTH_LONG).show();
Toasty.error(this,getString(R.string.toast_error_loading_account),Toast.LENGTH_LONG).show();
}
accountUrl = null;
show_boosts = true;
@ -316,7 +317,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
final SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
List<RemoteInstance> remoteInstances = new InstancesDAO(ShowAccountActivity.this, db).getInstanceByName(finalInstanceName);
if( remoteInstances != null && remoteInstances.size() > 0 ){
Toast.makeText(getApplicationContext(), R.string.toast_instance_already_added,Toast.LENGTH_LONG).show();
Toasty.info(getApplicationContext(), getString(R.string.toast_instance_already_added),Toast.LENGTH_LONG).show();
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
Bundle bundle = new Bundle();
bundle.putInt(INTENT_ACTION, SEARCH_INSTANCE);
@ -348,7 +349,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
new InstancesDAO(ShowAccountActivity.this, db).insertInstance(finalInstanceName, "MASTODON");
else
new InstancesDAO(ShowAccountActivity.this, db).insertInstance(finalInstanceName, "PEERTUBE");
Toast.makeText(getApplicationContext(), R.string.toast_instance_followed,Toast.LENGTH_LONG).show();
Toasty.success(getApplicationContext(), getString(R.string.toast_instance_followed),Toast.LENGTH_LONG).show();
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
Bundle bundle = new Bundle();
bundle.putInt(INTENT_ACTION, SEARCH_INSTANCE);
@ -361,7 +362,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
e.printStackTrace();
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(), R.string.toast_instance_unavailable,Toast.LENGTH_LONG).show();
Toasty.warning(getApplicationContext(), getString(R.string.toast_instance_unavailable),Toast.LENGTH_LONG).show();
}
});
}
@ -453,7 +454,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
@Override
public void onPostAction(int statusCode,API.StatusAction statusAction, String targetedId, Error error) {
if( error != null){
Toast.makeText(getApplicationContext(), error.getError(),Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), error.getError(),Toast.LENGTH_LONG).show();
return;
}
Helper.manageMessageStatusCode(getApplicationContext(), statusCode, statusAction);
@ -466,9 +467,9 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
public void onRetrieveAccount(final Account account, Error error) {
if( error != null || account.getAcct() == null){
if( error == null)
Toast.makeText(ShowAccountActivity.this, R.string.toast_error,Toast.LENGTH_LONG).show();
Toasty.error(ShowAccountActivity.this, getString(R.string.toast_error),Toast.LENGTH_LONG).show();
else
Toast.makeText(ShowAccountActivity.this, error.getError(),Toast.LENGTH_LONG).show();
Toasty.error(ShowAccountActivity.this, error.getError(),Toast.LENGTH_LONG).show();
return;
}
this.account = account;
@ -580,7 +581,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
@Override
public void onClick(View view) {
new TempMuteDAO(getApplicationContext(), db).remove(authenticatedAccount, account.getId());
Toast.makeText(getApplicationContext(), R.string.toast_unmute, Toast.LENGTH_LONG).show();
Toasty.success(getApplicationContext(), getString(R.string.toast_unmute), Toast.LENGTH_LONG).show();
temp_mute.setVisibility(View.GONE);
}
});
@ -817,7 +818,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
if( account_id.split("@").length == 1)
account_id += "@" + Helper.getLiveInstance(getApplicationContext());
ClipData clip = ClipData.newPlainText("mastodon_account_id", "@"+account_id);
Toast.makeText(getApplicationContext(),R.string.account_id_clipbloard, Toast.LENGTH_SHORT).show();
Toasty.info(getApplicationContext(),getString(R.string.account_id_clipbloard), Toast.LENGTH_SHORT).show();
assert clipboard != null;
clipboard.setPrimaryClip(clip);
return false;
@ -954,7 +955,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
@Override
public void onClick(View v) {
if( doAction == action.NOTHING){
Toast.makeText(getApplicationContext(), R.string.nothing_to_do, Toast.LENGTH_LONG).show();
Toasty.info(getApplicationContext(), getString(R.string.nothing_to_do), Toast.LENGTH_LONG).show();
}else if( doAction == action.FOLLOW){
account_follow.setEnabled(false);
new PostActionAsyncTask(getApplicationContext(), API.StatusAction.FOLLOW, accountId, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
@ -990,7 +991,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
@Override
public void onRetrieveFeeds(APIResponse apiResponse) {
if( apiResponse.getError() != null){
Toast.makeText(getApplicationContext(), apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
return;
}
@ -1010,7 +1011,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
public void onRetrieveRelationship(Relationship relationship, Error error) {
if( error != null){
Toast.makeText(getApplicationContext(), error.getError(),Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), error.getError(),Toast.LENGTH_LONG).show();
return;
}
this.relationship = relationship;

View File

@ -39,6 +39,7 @@ import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveContextAsyncTask;
import fr.gouv.etalab.mastodon.client.Entities.Account;
@ -187,7 +188,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetriev
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
Account account = new AccountDAO(getApplicationContext(),db).getAccountByID(userId);
if( account.getAvatar() == null){
Toast.makeText(ShowConversationActivity.this,R.string.toast_error, Toast.LENGTH_LONG).show();
Toasty.error(ShowConversationActivity.this,getString(R.string.toast_error), Toast.LENGTH_LONG).show();
finish();
}
String url = account.getAvatar();
@ -277,7 +278,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetriev
public void onRetrieveContext(Context context, Error error) {
swipeRefreshLayout.setRefreshing(false);
if( error != null ){
Toast.makeText(getApplicationContext(), error.getError(),Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), error.getError(),Toast.LENGTH_LONG).show();
return;
}
if( context.getAncestors() == null ){

View File

@ -100,6 +100,7 @@ import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.PostStatusAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsForReplyAsyncTask;
@ -500,7 +501,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
public void onClick(View v) {
toot_it.setEnabled(false);
if(toot_content.getText().toString().trim().length() == 0 && attachments.size() == 0){
Toast.makeText(getApplicationContext(),R.string.toot_error_no_content, Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(),getString(R.string.toot_select_image_error),Toast.LENGTH_LONG).show();
toot_it.setEnabled(true);
return;
}
@ -686,7 +687,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
if (mToast != null) {
mToast.cancel();
}
mToast = Toast.makeText(this, message, Toast.LENGTH_SHORT);
mToast = Toasty.error(this, message, Toast.LENGTH_SHORT);
mToast.show();
}
@ -706,12 +707,12 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
count++;
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), R.string.toot_select_image_error, Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(),getString(R.string.toot_select_image_error),Toast.LENGTH_LONG).show();
toot_picture.setEnabled(true);
toot_it.setEnabled(true);
}
} else {
Toast.makeText(getApplicationContext(), R.string.toot_select_image_error, Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(),getString(R.string.toot_select_image_error),Toast.LENGTH_LONG).show();
}
}
}
@ -728,7 +729,8 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
// Create the File where the photo should go
try {
photoFile = createImageFile();
} catch (IOException ignored) {Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();}
} catch (IOException ignored) {
Toasty.error(getApplicationContext(),getString(R.string.toot_select_image_error),Toast.LENGTH_LONG).show();}
// Continue only if the File was successfully created
if (photoFile != null) {
photoFileUri = FileProvider.getUriForFile(this,
@ -762,7 +764,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
if (requestCode == PICK_IMAGE && resultCode == Activity.RESULT_OK) {
picture_scrollview.setVisibility(View.VISIBLE);
if (data == null || data.getData() == null) {
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(),getString(R.string.toot_select_image_error),Toast.LENGTH_LONG).show();
return;
}
try {
@ -775,10 +777,10 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
} else if(mime != null && mime.toLowerCase().contains("image")) {
new asyncPicture(TootActivity.this, accountReply, data.getData()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}else {
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(),getString(R.string.toot_select_image_error),Toast.LENGTH_LONG).show();
}
} catch (FileNotFoundException e) {
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(),getString(R.string.toot_select_image_error),Toast.LENGTH_LONG).show();
toot_picture.setEnabled(true);
toot_it.setEnabled(true);
}
@ -814,7 +816,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
if( uriFile == null) {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(activityWeakReference.get(), R.string.toast_error, Toast.LENGTH_SHORT).show();
Toasty.error(activityWeakReference.get(), getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
}
});
return null;
@ -851,7 +853,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
Uri imageUri = Uri.parse(extras.getString("imageUri"));
picture_scrollview.setVisibility(View.VISIBLE);
if( imageUri == null) {
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(),getString(R.string.toot_select_image_error),Toast.LENGTH_LONG).show();
return;
}
try {
@ -864,10 +866,10 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
} else if(mime != null && mime.toLowerCase().contains("image")) {
new asyncPicture(TootActivity.this, accountReply, intent.getData()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}else {
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(),getString(R.string.toot_select_image_error),Toast.LENGTH_LONG).show();
}
} catch (FileNotFoundException e) {
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(),getString(R.string.toot_select_image_error),Toast.LENGTH_LONG).show();
toot_picture.setEnabled(true);
toot_it.setEnabled(true);
}
@ -926,7 +928,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
Date dateCompare = Helper.stringToDate(getApplicationContext(), dateString);
Date date = new Date();
if( date.before(dateCompare)) {
Toast.makeText(getApplicationContext(), R.string.please_wait, Toast.LENGTH_SHORT).show();
Toasty.info(getApplicationContext(), getString(R.string.please_wait), Toast.LENGTH_SHORT).show();
return true;
}
}
@ -975,14 +977,14 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
cw_trans.setText(translate.getTranslatedContent());
}
}else {
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(),getString(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();
Toasty.error(getApplicationContext(),getString(R.string.toast_error_translate),Toast.LENGTH_LONG).show();
}
}
@ -1016,14 +1018,14 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
toot_trans.setText(translate.getTranslatedContent());
}
}else {
Toast.makeText(getApplicationContext(), R.string.toast_error_translate, Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(),getString(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();
Toasty.error(getApplicationContext(),getString(R.string.toast_error_translate),Toast.LENGTH_LONG).show();
}
}
@ -1116,7 +1118,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
try {
startActivityForResult(intent, Helper.REQ_CODE_SPEECH_INPUT);
} catch (ActivityNotFoundException a) {
Toast.makeText(getApplicationContext(),
Toasty.info(getApplicationContext(),
getString(R.string.speech_not_supported),
Toast.LENGTH_SHORT).show();
}
@ -1128,7 +1130,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
try{
final List<StoredStatus> drafts = new StatusStoredDAO(TootActivity.this, db).getAllDrafts();
if( drafts == null || drafts.size() == 0){
Toast.makeText(getApplicationContext(), R.string.no_draft, Toast.LENGTH_LONG).show();
Toasty.info(getApplicationContext(), getString(R.string.no_draft), Toast.LENGTH_LONG).show();
return true;
}
AlertDialog.Builder builderSingle = new AlertDialog.Builder(TootActivity.this, style);
@ -1180,13 +1182,13 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
});
builderSingle.show();
}catch (Exception e){
Toast.makeText(getApplicationContext(), R.string.toast_error, Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show();
}
return true;
case R.id.action_schedule:
if(toot_content.getText().toString().trim().length() == 0 ){
Toast.makeText(getApplicationContext(),R.string.toot_error_no_content, Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(),getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
return true;
}
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(TootActivity.this, style);
@ -1250,7 +1252,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
minute);
long time = calendar.getTimeInMillis();
if( (time - new Date().getTime()) < 60000 ){
Toast.makeText(getApplicationContext(), R.string.toot_scheduled_date, Toast.LENGTH_LONG).show();
Toasty.warning(getApplicationContext(), getString(R.string.toot_scheduled_date), Toast.LENGTH_LONG).show();
}else {
//Store the toot as draft first
storeToot(false, false);
@ -1274,7 +1276,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
isSensitive = false;
toot_sensitive.setVisibility(View.GONE);
currentToId = -1;
Toast.makeText(TootActivity.this,R.string.toot_scheduled, Toast.LENGTH_LONG).show();
Toasty.info(TootActivity.this,getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
alertDialog.dismiss();
}
}
@ -1337,9 +1339,9 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
public void onRetrieveAttachment(final Attachment attachment, Error error) {
if( error != null || attachment == null){
if( error != null)
Toast.makeText(getApplicationContext(), error.getError(), Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), error.getError(), Toast.LENGTH_LONG).show();
else
Toast.makeText(getApplicationContext(), R.string.toast_error, Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show();
if( attachments.size() == 0 )
toot_picture_container.setVisibility(View.GONE);
toot_picture.setEnabled(true);
@ -1670,7 +1672,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
isSensitive = false;
toot_sensitive.setVisibility(View.GONE);
currentToId = -1;
Toast.makeText(TootActivity.this,R.string.toot_sent, Toast.LENGTH_LONG).show();
Toasty.success(TootActivity.this, getString(R.string.toot_sent), Toast.LENGTH_LONG).show();
toot_it.setEnabled(true);
//It's a reply, so the user will be redirect to its answer
if( tootReply != null){
@ -2166,10 +2168,10 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
}
}
if( message )
Toast.makeText(getApplicationContext(), R.string.toast_toot_saved, Toast.LENGTH_LONG).show();
Toasty.success(getApplicationContext(), getString(R.string.toast_toot_saved), Toast.LENGTH_LONG).show();
}catch (Exception e){
if( message)
Toast.makeText(getApplicationContext(), R.string.toast_error, Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show();
}
}

View File

@ -27,6 +27,7 @@ import android.view.ViewGroup;
import android.view.Window;
import android.widget.Toast;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
import fr.gouv.etalab.mastodon.fragments.DisplayAccountsFragment;
@ -79,7 +80,7 @@ public class TootInfoActivity extends BaseActivity {
toot_favorites_count = b.getInt("toot_favorites_count", 0);
}
if( toot_id == null){
Toast.makeText(this, R.string.toast_error, Toast.LENGTH_SHORT).show();
Toasty.error(this, getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
finish();
}
userID = sharedpreferences.getString(Helper.PREF_KEY_ID, null);

View File

@ -26,7 +26,6 @@ import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@ -40,12 +39,13 @@ import android.widget.Toast;
import java.lang.ref.WeakReference;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.client.API;
import fr.gouv.etalab.mastodon.client.Entities.Results;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.webview.MastalabWebChromeClient;
import fr.gouv.etalab.mastodon.webview.MastalabWebViewClient;
import fr.gouv.etalab.mastodon.R;
import static fr.gouv.etalab.mastodon.helper.Helper.EXTERNAL_STORAGE_REQUEST_CODE;
import static fr.gouv.etalab.mastodon.helper.Helper.THEME_LIGHT;
@ -168,11 +168,11 @@ public class WebviewActivity extends BaseActivity {
try {
startActivity(browserIntent);
}catch (Exception e){
Toast.makeText(WebviewActivity.this, R.string.toast_error, Toast.LENGTH_LONG).show();
Toasty.error(WebviewActivity.this,getString(R.string.toast_error),Toast.LENGTH_LONG).show();
}
return true;
case R.id.action_comment:
Toast.makeText(WebviewActivity.this, R.string.retrieve_remote_status, Toast.LENGTH_LONG).show();
Toasty.info(WebviewActivity.this, getString(R.string.retrieve_remote_status), Toast.LENGTH_LONG).show();
new AsyncTask<Void, Void, Void>() {
private List<fr.gouv.etalab.mastodon.client.Entities.Status> remoteStatuses;
@ -195,7 +195,7 @@ public class WebviewActivity extends BaseActivity {
Intent intent = new Intent(contextReference.get(), TootActivity.class);
Bundle b = new Bundle();
if( remoteStatuses == null || remoteStatuses.size() == 0){
Toast.makeText(contextReference.get(), R.string.toast_error, Toast.LENGTH_SHORT).show();
Toasty.error(contextReference.get(),getString(R.string.toast_error),Toast.LENGTH_LONG).show();
return;
}
if( remoteStatuses.get(0).getReblog() != null ) {

View File

@ -20,7 +20,6 @@ import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
@ -40,16 +39,16 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoAsyncTask;
import fr.gouv.etalab.mastodon.client.HttpsConnection;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.R;
import static fr.gouv.etalab.mastodon.helper.Helper.THEME_LIGHT;
@ -138,7 +137,7 @@ public class WebviewConnectActivity extends BaseActivity {
String val[] = url.split("code=");
if (val.length< 2){
Toast.makeText(getApplicationContext(), R.string.toast_code_error, Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), getString(R.string.toast_code_error), Toast.LENGTH_LONG).show();
Intent myIntent = new Intent(WebviewConnectActivity.this, LoginActivity.class);
startActivity(myIntent);
finish();

View File

@ -29,10 +29,13 @@ import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.ManageListsAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
@ -142,7 +145,7 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
return;
}
}else{
Toast.makeText(WhoToFollowActivity.this, R.string.toast_error, Toast.LENGTH_SHORT).show();
Toasty.error(WhoToFollowActivity.this, getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
return;
}
@ -187,7 +190,7 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
account.setInstance(val[1]);
new PostActionAsyncTask(WhoToFollowActivity.this, null, account, API.StatusAction.FOLLOW, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}else {
Toast.makeText(WhoToFollowActivity.this,R.string.toast_impossible_to_follow, Toast.LENGTH_LONG).show();
Toasty.error(WhoToFollowActivity.this,getString(R.string.toast_impossible_to_follow), Toast.LENGTH_LONG).show();
follow_accounts.setEnabled(true);
follow_accounts_select.setEnabled(true);
progess_action.setVisibility(View.GONE);

View File

@ -16,7 +16,6 @@ package fr.gouv.etalab.mastodon.drawers;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Build;
@ -32,11 +31,11 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
@ -157,7 +156,7 @@ public class AccountSearchDevAdapter extends BaseAdapter implements OnPostAction
@Override
public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) {
if( error != null){
Toast.makeText(context, error.getError(),Toast.LENGTH_LONG).show();
Toasty.error(context, error.getError(),Toast.LENGTH_LONG).show();
holder.account_follow.setEnabled(true);
return;
}
@ -169,7 +168,7 @@ public class AccountSearchDevAdapter extends BaseAdapter implements OnPostAction
}
}
holder.account_follow.hide();
Toast.makeText(context, R.string.toast_follow, Toast.LENGTH_LONG).show();
Toasty.success(context, context.getString(R.string.toast_follow), Toast.LENGTH_LONG).show();
}

View File

@ -31,12 +31,13 @@ import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import java.util.ArrayList;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
import fr.gouv.etalab.mastodon.client.API;
@ -44,7 +45,6 @@ import fr.gouv.etalab.mastodon.client.Entities.Account;
import fr.gouv.etalab.mastodon.client.Entities.Error;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface;
import fr.gouv.etalab.mastodon.R;
/**
@ -136,7 +136,7 @@ public class AccountsFollowRequestAdapter extends RecyclerView.Adapter implement
@Override
public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) {
if( error != null){
Toast.makeText(context, error.getError(),Toast.LENGTH_LONG).show();
Toasty.error(context, error.getError(),Toast.LENGTH_LONG).show();
return;
}
Helper.manageMessageStatusCode(context, statusCode, statusAction);

View File

@ -30,6 +30,7 @@ import android.widget.Toast;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.ManageAccountsInListActivity;
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
@ -125,7 +126,7 @@ public class AccountsInAListAdapter extends RecyclerView.Adapter implements OnLi
@Override
public void onActionDone(ManageListsAsyncTask.action actionType, APIResponse apiResponse, int statusCode) {
if( actionType == ManageListsAsyncTask.action.DELETE_USERS && statusCode != 200){
Toast.makeText(context, context.getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
}
}

View File

@ -36,6 +36,7 @@ import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
import fr.gouv.etalab.mastodon.asynctasks.PostActionAsyncTask;
@ -248,7 +249,7 @@ public class AccountsListAdapter extends RecyclerView.Adapter implements OnPostA
@Override
public void onPostAction(int statusCode, API.StatusAction statusAction, String targetedId, Error error) {
if( error != null){
Toast.makeText(context, error.getError(),Toast.LENGTH_LONG).show();
Toasty.error(context, error.getError(),Toast.LENGTH_LONG).show();
return;
}
Helper.manageMessageStatusCode(context, statusCode, statusAction);

View File

@ -31,6 +31,7 @@ import android.widget.Toast;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.DeleteDomainsAsyncTask;
import fr.gouv.etalab.mastodon.client.APIResponse;
@ -142,10 +143,12 @@ public class DomainsListAdapter extends RecyclerView.Adapter implements OnRetrie
String message;
if( response == 200){
message = context.getString(R.string.toast_unblock_domain);
Toasty.success(context, message, Toast.LENGTH_LONG).show();
}else{
message = context.getString(R.string.toast_error);
Toasty.error(context, message, Toast.LENGTH_LONG).show();
}
Toast.makeText(context, message, Toast.LENGTH_LONG).show();
}
private class ViewHolder extends RecyclerView.ViewHolder{

View File

@ -40,6 +40,7 @@ import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.BaseMainActivity;
import fr.gouv.etalab.mastodon.asynctasks.ManageFiltersAsyncTask;
@ -280,7 +281,7 @@ public class FilterAdapter extends BaseAdapter implements OnFilterActionInterfac
public void onActionDone(ManageFiltersAsyncTask.action actionType, APIResponse apiResponse, int statusCode) {
if( apiResponse != null) {
if (apiResponse.getError() != null) {
Toast.makeText(context, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
Toasty.error(context, apiResponse.getError().getError(), Toast.LENGTH_LONG).show();
return;
}
List<Filters> filtersRes = apiResponse.getFilters();

View File

@ -56,6 +56,7 @@ import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.MediaActivity;
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
@ -697,7 +698,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
ClipData clip = ClipData.newPlainText(Helper.CLIP_BOARD, content);
assert clipboard != null;
clipboard.setPrimaryClip(clip);
Toast.makeText(context,R.string.clipboard,Toast.LENGTH_LONG).show();
Toasty.info(context,context.getString(R.string.clipboard),Toast.LENGTH_LONG).show();
return true;
case R.id.action_share:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
@ -873,7 +874,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
@Override
public void onPostAction(int statusCode, API.StatusAction statusAction, String targetedId, Error error) {
if( error != null){
Toast.makeText(context, error.getError(),Toast.LENGTH_LONG).show();
Toasty.error(context, error.getError(),Toast.LENGTH_LONG).show();
return;
}
Helper.manageMessageStatusCode(context, statusCode, statusAction);
@ -937,7 +938,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
@Override
public void onPostNotificationsAction(APIResponse apiResponse, String targetedId) {
if(apiResponse.getError() != null){
Toast.makeText(context, R.string.toast_error,Toast.LENGTH_LONG).show();
Toasty.error(context, context.getString(R.string.toast_error),Toast.LENGTH_LONG).show();
return;
}
if( targetedId != null){
@ -950,12 +951,12 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
}
position++;
}
Toast.makeText(context,R.string.delete_notification,Toast.LENGTH_LONG).show();
Toasty.success(context,context.getString(R.string.delete_notification),Toast.LENGTH_LONG).show();
}else{
int size = notifications.size();
notifications.clear();
notificationsListAdapter.notifyItemRangeRemoved(0, size);
Toast.makeText(context,R.string.delete_notification_all,Toast.LENGTH_LONG).show();
Toasty.success(context,context.getString(R.string.delete_notification_all),Toast.LENGTH_LONG).show();
}
}

View File

@ -15,7 +15,6 @@ package fr.gouv.etalab.mastodon.drawers;
* see <http://www.gnu.org/licenses>. */
import android.annotation.SuppressLint;
import android.support.v7.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@ -23,6 +22,7 @@ import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -42,6 +42,8 @@ import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.activities.TootActivity;
import fr.gouv.etalab.mastodon.client.Entities.Status;
@ -51,7 +53,6 @@ import fr.gouv.etalab.mastodon.jobs.ApplicationJob;
import fr.gouv.etalab.mastodon.jobs.ScheduledTootsSyncJob;
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
import fr.gouv.etalab.mastodon.sqlite.StatusStoredDAO;
import fr.gouv.etalab.mastodon.R;
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
@ -273,7 +274,7 @@ public class ScheduledTootsListAdapter extends BaseAdapter {
minute);
long time = calendar.getTimeInMillis();
if( (time - new Date().getTime()) < 60000 ){
Toast.makeText(context, R.string.toot_scheduled_date, Toast.LENGTH_LONG).show();
Toasty.error(context, context.getString(R.string.toot_scheduled_date), Toast.LENGTH_LONG).show();
}else {
//Schedules the toot to the new date
try {
@ -286,7 +287,7 @@ public class ScheduledTootsListAdapter extends BaseAdapter {
storedStatus.setScheduled_date(storedStatusnew.getScheduled_date());
scheduledTootsListAdapter.notifyDataSetChanged();
//Notifiy all is ok
Toast.makeText(context,R.string.toot_scheduled, Toast.LENGTH_LONG).show();
Toasty.success(context,context.getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
}catch (Exception ignored){}
alertDialog.dismiss();
}

View File

@ -86,6 +86,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.BaseMainActivity;
import fr.gouv.etalab.mastodon.activities.MediaActivity;
@ -737,15 +738,15 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
try {
if (status.isBookmarked()) {
new StatusCacheDAO(context, db).insertStatus(StatusCacheDAO.BOOKMARK_CACHE, status);
Toast.makeText(context, R.string.status_bookmarked, Toast.LENGTH_LONG).show();
Toasty.success(context, context.getString(R.string.status_bookmarked), Toast.LENGTH_LONG).show();
} else {
new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, status);
Toast.makeText(context, R.string.status_unbookmarked, Toast.LENGTH_LONG).show();
Toasty.success(context, context.getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show();
}
notifyStatusChanged(status);
}catch (Exception e){
e.printStackTrace();
Toast.makeText(context, R.string.toast_error, Toast.LENGTH_LONG).show();
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
}
}else {
int position = 0;
@ -754,7 +755,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
statuses.remove(status);
statusListAdapter.notifyItemRemoved(position);
new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, statustmp);
Toast.makeText(context, R.string.status_unbookmarked, Toast.LENGTH_LONG).show();
Toasty.success(context, context.getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show();
break;
}
position++;
@ -1524,15 +1525,15 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
try {
if (status.isBookmarked()) {
new StatusCacheDAO(context, db).insertStatus(StatusCacheDAO.BOOKMARK_CACHE, status);
Toast.makeText(context, R.string.status_bookmarked, Toast.LENGTH_LONG).show();
Toasty.success(context, context.getString(R.string.status_bookmarked), Toast.LENGTH_LONG).show();
} else {
new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, status);
Toast.makeText(context, R.string.status_unbookmarked, Toast.LENGTH_LONG).show();
Toasty.success(context, context.getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show();
}
notifyStatusChanged(status);
}catch (Exception e){
e.printStackTrace();
Toast.makeText(context, R.string.toast_error, Toast.LENGTH_LONG).show();
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
}
}else {
int position = 0;
@ -1541,7 +1542,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
statuses.remove(status);
statusListAdapter.notifyItemRemoved(position);
new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, statustmp);
Toast.makeText(context, R.string.status_unbookmarked, Toast.LENGTH_LONG).show();
Toasty.success(context, context.getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show();
break;
}
position++;
@ -1609,7 +1610,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
minute);
long time = calendar.getTimeInMillis();
if( (time - new Date().getTime()) < 60000 ){
Toast.makeText(context, R.string.timed_mute_date_error, Toast.LENGTH_LONG).show();
Toasty.error(context, context.getString(R.string.timed_mute_date_error), Toast.LENGTH_LONG).show();
}else {
//Store the toot as draft first
String targeted_id = status.getAccount().getId();
@ -1624,7 +1625,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
timedMute = new ArrayList<>();
timedMute.add(targeted_id);
}
Toast.makeText(context,context.getString(R.string.timed_mute_date,status.getAccount().getAcct(),Helper.dateToString(date_mute)), Toast.LENGTH_LONG).show();
Toasty.success(context,context.getString(R.string.timed_mute_date,status.getAccount().getAcct(),Helper.dateToString(date_mute)), Toast.LENGTH_LONG).show();
alertDialog.dismiss();
notifyDataSetChanged();
}
@ -1661,7 +1662,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
ClipData clip = ClipData.newPlainText(Helper.CLIP_BOARD, content);
if( clipboard != null) {
clipboard.setPrimaryClip(clip);
Toast.makeText(context, R.string.clipboard, Toast.LENGTH_LONG).show();
Toasty.info(context, context.getString(R.string.clipboard), Toast.LENGTH_LONG).show();
}
return true;
case R.id.action_share:
@ -2121,7 +2122,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
if( error != null){
Toast.makeText(context, error.getError(),Toast.LENGTH_LONG).show();
Toasty.error(context, error.getError(),Toast.LENGTH_LONG).show();
return;
}
Helper.manageMessageStatusCode(context, statusCode, statusAction);
@ -2291,13 +2292,13 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
Status.makeEmojisTranslation(context, StatusListAdapter.this, status);
notifyStatusChanged(status);
}else {
Toast.makeText(context, R.string.toast_error_translate, Toast.LENGTH_LONG).show();
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
}
}
@Override
public void onFail(HttpsConnectionException e) {
e.printStackTrace();
Toast.makeText(context, R.string.toast_error_translate, Toast.LENGTH_LONG).show();
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
}
});
}else {

View File

@ -13,6 +13,7 @@ package fr.gouv.etalab.mastodon.fragments;
*
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
* see <http://www.gnu.org/licenses>. */
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
@ -33,17 +34,17 @@ import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import fr.gouv.etalab.mastodon.activities.ListActivity;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveManyRelationshipsAsyncTask;
import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.client.Entities.Account;
import fr.gouv.etalab.mastodon.client.Entities.Relationship;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveManyRelationshipsInterface;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsAsyncTask;
import fr.gouv.etalab.mastodon.drawers.AccountsListAdapter;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountsInterface;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveManyRelationshipsInterface;
/**
@ -203,7 +204,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
mainLoader.setVisibility(View.GONE);
nextElementLoader.setVisibility(View.GONE);
if( apiResponse.getError() != null){
Toast.makeText(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
Toasty.error(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
swipeRefreshLayout.setRefreshing(false);
swiped = false;
flag_loading = false;
@ -234,7 +235,7 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
@Override
public void onRetrieveRelationship(APIResponse apiResponse) {
if( apiResponse.getError() != null){
Toast.makeText(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
Toasty.error(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
return;
}
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);

View File

@ -42,6 +42,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.asynctasks.ManageFiltersAsyncTask;
@ -231,7 +232,7 @@ public class DisplayFiltersFragment extends Fragment implements OnFilterActionIn
mainLoader.setVisibility(View.GONE);
add_new.setEnabled(true);
if( apiResponse.getError() != null){
Toast.makeText(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
Toasty.error(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
return;
}
if( actionType == ManageFiltersAsyncTask.action.GET_ALL_FILTER) {
@ -251,7 +252,7 @@ public class DisplayFiltersFragment extends Fragment implements OnFilterActionIn
textviewNoAction.setVisibility(View.GONE);
lv_filters.setVisibility(View.VISIBLE);
}else{
Toast.makeText(context, R.string.toast_error,Toast.LENGTH_LONG).show();
Toasty.error(context, context.getString(R.string.toast_error),Toast.LENGTH_LONG).show();
}
}
MainActivity.filters = apiResponse.getFilters();

View File

@ -31,16 +31,18 @@ import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFollowRequestSentAsyncTask;
import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.client.Entities.Account;
import fr.gouv.etalab.mastodon.drawers.AccountsFollowRequestAdapter;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountsInterface;
import fr.gouv.etalab.mastodon.R;
/**
@ -178,7 +180,7 @@ public class DisplayFollowRequestSentFragment extends Fragment implements OnRetr
mainLoader.setVisibility(View.GONE);
nextElementLoader.setVisibility(View.GONE);
if( apiResponse.getError() != null){
Toast.makeText(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
Toasty.error(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
flag_loading = false;
swipeRefreshLayout.setRefreshing(false);
swiped = false;

View File

@ -25,7 +25,10 @@ import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.Toast;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveHowToAsyncTask;
import fr.gouv.etalab.mastodon.client.APIResponse;
@ -93,12 +96,12 @@ public class DisplayHowToFragment extends Fragment implements OnRetrieveHowToInt
public void onRetrieveHowTo(APIResponse apiResponse) {
mainLoader.setVisibility(View.GONE);
if( apiResponse.getError() != null){
Toast.makeText(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
Toasty.error(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
return;
}
List<HowToVideo> howToVideos = apiResponse.getHowToVideos();
if( howToVideos == null || howToVideos.size() == 0 ){
Toast.makeText(context, R.string.toast_error,Toast.LENGTH_LONG).show();
Toasty.error(context, context.getString(R.string.toast_error),Toast.LENGTH_LONG).show();
return;
}
HowToVideosAdapter howToVideosAdapter = new HowToVideosAdapter(context, howToVideos);

View File

@ -34,12 +34,12 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.ListActivity;
import fr.gouv.etalab.mastodon.activities.MainActivity;
@ -171,7 +171,7 @@ public class DisplayListsFragment extends Fragment implements OnListActionInterf
mainLoader.setVisibility(View.GONE);
add_new.setEnabled(true);
if( apiResponse.getError() != null){
Toast.makeText(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
Toasty.error(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
return;
}
if( actionType == ManageListsAsyncTask.action.GET_LIST) {
@ -196,7 +196,7 @@ public class DisplayListsFragment extends Fragment implements OnListActionInterf
listAdapter.notifyDataSetChanged();
textviewNoAction.setVisibility(View.GONE);
}else{
Toast.makeText(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
Toasty.error(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
}
}else if( actionType == ManageListsAsyncTask.action.DELETE_LIST){
if( this.lists.size() == 0)

View File

@ -29,8 +29,11 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask;
import fr.gouv.etalab.mastodon.client.APIResponse;
@ -168,7 +171,7 @@ public class DisplayMediaFragment extends Fragment implements OnRetrieveFeedsInt
nextElementLoader.setVisibility(View.GONE);
//Discards 404 - error which can often happen due to toots which have been deleted
if( apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 404 ){
Toast.makeText(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
Toasty.error(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
flag_loading = false;
return;
}

View File

@ -34,6 +34,7 @@ import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveDomainsAsyncTask;
import fr.gouv.etalab.mastodon.client.APIResponse;
@ -174,7 +175,7 @@ public class DisplayMutedInstanceFragment extends Fragment implements OnRetrieve
mainLoader.setVisibility(View.GONE);
nextElementLoader.setVisibility(View.GONE);
if( apiResponse.getError() != null){
Toast.makeText(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
Toasty.error(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
swipeRefreshLayout.setRefreshing(false);
swiped = false;
flag_loading = false;

View File

@ -13,6 +13,7 @@ package fr.gouv.etalab.mastodon.fragments;
*
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
* see <http://www.gnu.org/licenses>. */
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
@ -31,19 +32,21 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveMissingNotificationsAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveNotificationsAsyncTask;
import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.client.Entities.Account;
import fr.gouv.etalab.mastodon.client.Entities.Notification;
import fr.gouv.etalab.mastodon.drawers.NotificationsListAdapter;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveMissingNotificationsInterface;
import fr.gouv.etalab.mastodon.asynctasks.RetrieveNotificationsAsyncTask;
import fr.gouv.etalab.mastodon.client.Entities.Notification;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveNotificationsInterface;
@ -197,7 +200,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
nextElementLoader.setVisibility(View.GONE);
String lastReadNotifications = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + userId + instance, null);
if( apiResponse.getError() != null){
Toast.makeText(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
Toasty.error(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
flag_loading = false;
swipeRefreshLayout.setRefreshing(false);
swiped = false;

View File

@ -39,6 +39,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.BaseMainActivity;
import fr.gouv.etalab.mastodon.activities.MainActivity;
@ -376,9 +377,9 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
//Discards 404 - error which can often happen due to toots which have been deleted
if( apiResponse == null || (apiResponse.getError() != null && apiResponse.getError().getStatusCode() != 404) ){
if( apiResponse == null)
Toast.makeText(context, R.string.toast_error,Toast.LENGTH_LONG).show();
Toasty.error(context, context.getString(R.string.toast_error),Toast.LENGTH_LONG).show();
else
Toast.makeText(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
Toasty.error(context, apiResponse.getError().getError(),Toast.LENGTH_LONG).show();
swipeRefreshLayout.setRefreshing(false);
flag_loading = false;
return;

View File

@ -54,6 +54,7 @@ import android.widget.Toast;
import java.util.Locale;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.client.Entities.Account;
@ -809,9 +810,9 @@ public class SettingsFragment extends Fragment {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.SET_TOOT_VISIBILITY + "@" + account.getAcct() + "@" + account.getInstance(), visibility);
editor.apply();
Toast.makeText(context, context.getString(R.string.toast_visibility_changed, "@" + account.getAcct() + "@" + account.getInstance()), Toast.LENGTH_SHORT).show();
Toasty.info(context, context.getString(R.string.toast_visibility_changed, "@" + account.getAcct() + "@" + account.getInstance()), Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(context, R.string.toast_error,Toast.LENGTH_SHORT).show();
Toasty.error(context, context.getString(R.string.toast_error),Toast.LENGTH_LONG).show();
}
dialog.dismiss();
@ -965,7 +966,7 @@ public class SettingsFragment extends Fragment {
editor.apply();
set_folder.setText(path);
}catch (Exception e){
Toast.makeText(context, R.string.toast_error, Toast.LENGTH_LONG).show();
Toasty.error(context, context.getString(R.string.toast_error),Toast.LENGTH_LONG).show();
}
}

View File

@ -18,16 +18,12 @@ import android.app.TimePickerDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -36,16 +32,15 @@ import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import fr.gouv.etalab.mastodon.helper.Helper;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.helper.Helper;
import static android.app.Activity.RESULT_OK;
import static fr.gouv.etalab.mastodon.helper.Helper.compareDate;
@ -179,7 +174,7 @@ public class SettingsNotificationsFragment extends Fragment {
settings_time_from.setText(newDate);
}else {
String ateRef = sharedpreferences.getString(Helper.SET_TIME_TO, "22:00");
Toast.makeText(context, context.getString(R.string.settings_time_lower, ateRef), Toast.LENGTH_LONG).show();
Toasty.error(context, context.getString(R.string.settings_time_lower, ateRef), Toast.LENGTH_LONG).show();
}
}
}, Integer.valueOf(datetime[0]), Integer.valueOf(datetime[1]), true);
@ -205,7 +200,7 @@ public class SettingsNotificationsFragment extends Fragment {
settings_time_to.setText(newDate);
} else {
String ateRef = sharedpreferences.getString(Helper.SET_TIME_FROM, "07:00");
Toast.makeText(context, context.getString(R.string.settings_time_greater, ateRef), Toast.LENGTH_LONG).show();
Toasty.error(context, context.getString(R.string.settings_time_greater, ateRef), Toast.LENGTH_LONG).show();
}
}
}, Integer.valueOf(datetime[0]), Integer.valueOf(datetime[1]), true);
@ -359,7 +354,7 @@ public class SettingsNotificationsFragment extends Fragment {
editor.putString(Helper.SET_NOTIF_SOUND, uri.toString());
editor.apply();
}catch (Exception e){
Toast.makeText(context, R.string.toast_error, Toast.LENGTH_LONG).show();
Toasty.error(context, context.getString(R.string.toast_error),Toast.LENGTH_LONG).show();
}
}
}

View File

@ -31,6 +31,7 @@ import java.util.Calendar;
import java.util.Date;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.asynctasks.WhoToFollowAsyncTask;
import fr.gouv.etalab.mastodon.client.Entities.TrunkAccount;
@ -96,7 +97,7 @@ public class WhoToFollowFragment extends Fragment implements OnRetrieveWhoToFoll
WhoToFollowAdapter whoToFollowAdapter = new WhoToFollowAdapter(context, list);
lv_list.setAdapter(whoToFollowAdapter);
}else{
Toast.makeText(context, R.string.toast_error, Toast.LENGTH_SHORT).show();
Toasty.error(context, context.getString(R.string.toast_error),Toast.LENGTH_LONG).show();
}
}

View File

@ -32,6 +32,7 @@ import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.BaseActivity;
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
@ -216,7 +217,7 @@ public class CrossActions {
@Override
protected void onPreExecute() {
Toast.makeText(contextReference.get(), R.string.retrieve_remote_account, Toast.LENGTH_SHORT).show();
Toasty.info(contextReference.get(), contextReference.get().getString(R.string.retrieve_remote_account), Toast.LENGTH_SHORT).show();
}
@Override
@ -252,7 +253,7 @@ public class CrossActions {
@Override
protected void onPreExecute() {
Toast.makeText(contextReference.get(), R.string.retrieve_remote_account, Toast.LENGTH_SHORT).show();
Toasty.info(contextReference.get(), contextReference.get().getString(R.string.retrieve_remote_account), Toast.LENGTH_SHORT).show();
}
@Override
@ -298,7 +299,7 @@ public class CrossActions {
@Override
protected void onPreExecute() {
Toast.makeText(contextReference.get(), R.string.retrieve_remote_conversation, Toast.LENGTH_SHORT).show();
Toasty.info(contextReference.get(), contextReference.get().getString(R.string.retrieve_remote_conversation), Toast.LENGTH_SHORT).show();
}
@Override
@ -334,15 +335,15 @@ public class CrossActions {
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
if (status.isBookmarked()) {
new StatusCacheDAO(context, db).insertStatus(StatusCacheDAO.BOOKMARK_CACHE, status);
Toast.makeText(context, R.string.status_bookmarked, Toast.LENGTH_LONG).show();
Toasty.success(context, context.getString(R.string.status_bookmarked), Toast.LENGTH_LONG).show();
} else {
new StatusCacheDAO(context, db).remove(StatusCacheDAO.BOOKMARK_CACHE, status);
Toast.makeText(context, R.string.status_unbookmarked, Toast.LENGTH_LONG).show();
Toasty.success(context, context.getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show();
}
statusListAdapter.notifyStatusChanged(status);
}catch (Exception e){
e.printStackTrace();
Toast.makeText(context, R.string.toast_error, Toast.LENGTH_LONG).show();
Toasty.error(context, context.getString(R.string.toast_error),Toast.LENGTH_LONG).show();
}
}else {
AlertDialog.Builder builderSingle = new AlertDialog.Builder(context, style);
@ -370,7 +371,7 @@ public class CrossActions {
@Override
protected void onPreExecute() {
Toast.makeText(contextReference.get(), R.string.retrieve_remote_status, Toast.LENGTH_SHORT).show();
Toasty.info(contextReference.get(), contextReference.get().getString(R.string.retrieve_remote_status), Toast.LENGTH_SHORT).show();
}
@Override
@ -382,7 +383,7 @@ public class CrossActions {
@Override
protected void onPostExecute(Void result) {
if( response == null){
Toast.makeText(contextReference.get(),R.string.toast_error,Toast.LENGTH_LONG).show();
Toasty.error(contextReference.get(),context.getString(R.string.toast_error),Toast.LENGTH_LONG).show();
return;
}
List<fr.gouv.etalab.mastodon.client.Entities.Status> statuses = response.getStatuses();
@ -391,10 +392,10 @@ public class CrossActions {
fr.gouv.etalab.mastodon.client.Entities.Status statusBookmarked = new StatusCacheDAO(contextReference.get(), db).getStatus(StatusCacheDAO.BOOKMARK_CACHE, statuses.get(0).getId(), account.getId(), account.getInstance());
if (statusBookmarked == null) {
new StatusCacheDAO(contextReference.get(), db).insertStatus(StatusCacheDAO.BOOKMARK_CACHE, statuses.get(0), account.getId(), account.getInstance());
Toast.makeText(contextReference.get(), R.string.status_bookmarked, Toast.LENGTH_LONG).show();
Toasty.success(contextReference.get(), contextReference.get().getString(R.string.status_bookmarked), Toast.LENGTH_LONG).show();
} else {
new StatusCacheDAO(contextReference.get(), db).remove(StatusCacheDAO.BOOKMARK_CACHE, statuses.get(0), account.getId(), account.getInstance());
Toast.makeText(contextReference.get(), R.string.status_unbookmarked, Toast.LENGTH_LONG).show();
Toasty.success(contextReference.get(), contextReference.get().getString(R.string.status_unbookmarked), Toast.LENGTH_LONG).show();
}
statusListAdapter.notifyStatusChanged(statuses.get(0));
}

View File

@ -149,6 +149,7 @@ import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.BuildConfig;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.BaseMainActivity;
@ -753,7 +754,7 @@ public class Helper {
message = context.getString(R.string.toast_error);
}
if( !message.trim().equals(""))
Toast.makeText(context, message, Toast.LENGTH_LONG).show();
Toasty.success(context, message, Toast.LENGTH_LONG).show();
}
@ -782,7 +783,7 @@ public class Helper {
try {
request = new DownloadManager.Request(Uri.parse(url.trim()));
}catch (Exception e){
Toast.makeText(context,R.string.toast_error,Toast.LENGTH_LONG).show();
Toasty.error(context,context.getString(R.string.toast_error),Toast.LENGTH_LONG).show();
return;
}
final String fileName = URLUtil.guessFileName(url, null, null);
@ -993,7 +994,7 @@ public class Helper {
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
notify_user(context, intent, notificationIdTmp, BitmapFactory.decodeResource(context.getResources(),
R.mipmap.ic_launcher), NotifType.STORE, context.getString(R.string.save_over), context.getString(R.string.download_from, fileName));
Toast.makeText(context, R.string.toast_saved,Toast.LENGTH_LONG).show();
Toasty.success(context, context.getString(R.string.toast_saved),Toast.LENGTH_LONG).show();
return false;
}
})
@ -1001,7 +1002,7 @@ public class Helper {
@Override
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
notify_user(context, intent, notificationIdTmp, resource, NotifType.STORE, context.getString(R.string.save_over), context.getString(R.string.download_from, fileName));
Toast.makeText(context, R.string.toast_saved,Toast.LENGTH_LONG).show();
Toasty.success(context, context.getString(R.string.toast_saved),Toast.LENGTH_LONG).show();
}
});
} catch (Exception ignored) {}
@ -1146,7 +1147,7 @@ public class Helper {
if( ! activity.isFinishing() ) {
menuAccountsOpened = false;
String userId = account.getId();
Toast.makeText(activity, activity.getString(R.string.toast_account_changed, "@" + account.getAcct() + "@" + account.getInstance()), Toast.LENGTH_LONG).show();
Toasty.info(activity, activity.getString(R.string.toast_account_changed, "@" + account.getAcct() + "@" + account.getInstance()), Toast.LENGTH_LONG).show();
changeUser(activity, userId, true);
arrow.setImageResource(R.drawable.ic_arrow_drop_down);
return true;
@ -1480,7 +1481,7 @@ public class Helper {
if( account == null ) {
Helper.logout(activity);
Intent myIntent = new Intent(activity, LoginActivity.class);
Toast.makeText(activity,R.string.toast_error, Toast.LENGTH_LONG).show();
Toasty.error(activity,activity.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
activity.startActivity(myIntent);
activity.finish(); //User is logged out to get a new token
}else {
@ -2235,7 +2236,7 @@ public class Helper {
public static Bitmap convertTootIntoBitmap(Context context, String name, View view) {
if( view.getWidth() == 0 || view.getHeight() == 0){
Toast.makeText(context, R.string.toast_error, Toast.LENGTH_SHORT).show();
Toasty.error(context, context.getString(R.string.toast_error),Toast.LENGTH_LONG).show();
return null;
}
Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth()+(int)Helper.convertDpToPixel(10, context), view.getHeight()+(int)Helper.convertDpToPixel(30, context), Bitmap.Config.ARGB_8888);
@ -2394,7 +2395,7 @@ public class Helper {
try {
context.startActivity(intent);
}catch (Exception e){
Toast.makeText(context, R.string.toast_error, Toast.LENGTH_SHORT).show();
Toasty.error(context, context.getString(R.string.toast_error),Toast.LENGTH_LONG).show();
}
}
@ -2418,7 +2419,7 @@ public class Helper {
try {
takenImage = MediaStore.Images.Media.getBitmap(context.getContentResolver(), uriFile);
} catch (IOException e) {
Toast.makeText(context, R.string.toast_error, Toast.LENGTH_SHORT).show();
Toasty.error(context, context.getString(R.string.toast_error),Toast.LENGTH_LONG).show();
return null;
}
ExifInterface exif = null;

View File

@ -25,11 +25,13 @@ import android.os.Looper;
import android.support.annotation.Nullable;
import android.support.v4.content.LocalBroadcastManager;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.activities.OwnerStatusActivity;
import fr.gouv.etalab.mastodon.client.API;
import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.client.Entities.Account;
@ -78,14 +80,14 @@ public class BackupStatusInDataBaseService extends IntentService {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), R.string.data_export_start, Toast.LENGTH_LONG).show();
Toasty.info(getApplicationContext(), getString(R.string.data_export_start), Toast.LENGTH_LONG).show();
}
});
}else {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), R.string.data_export_running, Toast.LENGTH_LONG).show();
Toasty.info(getApplicationContext(), getString(R.string.data_export_running), Toast.LENGTH_LONG).show();
}
});
return;
@ -136,7 +138,7 @@ public class BackupStatusInDataBaseService extends IntentService {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), finalMessage, Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), finalMessage, Toast.LENGTH_LONG).show();
}
});
}

View File

@ -37,6 +37,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import es.dmoral.toasty.Toasty;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.client.API;
import fr.gouv.etalab.mastodon.client.APIResponse;
@ -86,14 +87,14 @@ public class BackupStatusService extends IntentService {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), R.string.data_export_start, Toast.LENGTH_LONG).show();
Toasty.info(getApplicationContext(), getString(R.string.data_export_start), Toast.LENGTH_LONG).show();
}
});
}else {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), R.string.data_export_running, Toast.LENGTH_LONG).show();
Toasty.info(getApplicationContext(), getString(R.string.data_export_running), Toast.LENGTH_LONG).show();
}
});
return;
@ -194,7 +195,7 @@ public class BackupStatusService extends IntentService {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), finalMessage, Toast.LENGTH_LONG).show();
Toasty.error(getApplicationContext(), finalMessage, Toast.LENGTH_LONG).show();
}
});
}