Down with Toast, all hail Snackbar
This commit is contained in:
parent
f061a35472
commit
dce29954e1
@ -89,7 +89,6 @@ import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TextView.OnEditorActionListener;
|
||||
import android.widget.Toast;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import java.io.File;
|
||||
@ -348,7 +347,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse
|
||||
String url = mPreferences.getSavedUrl();
|
||||
if (url != null) {
|
||||
newTab(url, true);
|
||||
Toast.makeText(mActivity, R.string.deleted_tab, Toast.LENGTH_SHORT).show();
|
||||
Utils.showSnackbar(mActivity, R.string.deleted_tab);
|
||||
}
|
||||
mPreferences.setSavedUrl(null);
|
||||
return true;
|
||||
|
@ -5,7 +5,6 @@ import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.os.Environment;
|
||||
import android.provider.Browser;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@ -154,7 +153,7 @@ public class BookmarkManager {
|
||||
* This method exports the stored bookmarks to a text file in the device's
|
||||
* external download directory
|
||||
*/
|
||||
public synchronized void exportBookmarks() {
|
||||
public synchronized void exportBookmarks(Activity activity) {
|
||||
List<HistoryItem> bookmarkList = getBookmarks(true);
|
||||
File bookmarksExport = new File(
|
||||
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
|
||||
@ -179,11 +178,8 @@ public class BookmarkManager {
|
||||
bookmarkWriter.write(object.toString());
|
||||
bookmarkWriter.newLine();
|
||||
}
|
||||
if (mContext != null)
|
||||
Toast.makeText(
|
||||
mContext,
|
||||
mContext.getString(R.string.bookmark_export_path) + ' '
|
||||
+ bookmarksExport.getPath(), Toast.LENGTH_SHORT).show();
|
||||
Utils.showSnackbar(activity, activity.getString(R.string.bookmark_export_path)
|
||||
+ ' ' + bookmarksExport.getPath());
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
@ -18,7 +18,6 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.URLUtil;
|
||||
import android.widget.Toast;
|
||||
|
||||
import acr.browser.lightning.R;
|
||||
import acr.browser.lightning.preference.PreferenceManager;
|
||||
@ -163,7 +162,7 @@ public class DownloadHandler {
|
||||
try {
|
||||
request = new DownloadManager.Request(uri);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Toast.makeText(activity, R.string.cannot_download, Toast.LENGTH_SHORT).show();
|
||||
Utils.showSnackbar(activity, R.string.cannot_download);
|
||||
return;
|
||||
}
|
||||
request.setMimeType(mimetype);
|
||||
@ -204,7 +203,7 @@ public class DownloadHandler {
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
Toast.makeText(activity, R.string.download_pending, Toast.LENGTH_SHORT).show();
|
||||
Utils.showSnackbar(activity, R.string.download_pending);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,18 +3,19 @@
|
||||
*/
|
||||
package acr.browser.lightning.download;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.DownloadManager;
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.webkit.URLUtil;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import acr.browser.lightning.R;
|
||||
import acr.browser.lightning.utils.Utils;
|
||||
|
||||
/**
|
||||
* This class is used to pull down the http headers of a given URL so that we
|
||||
@ -36,14 +37,14 @@ public class FetchUrlMimeType extends Thread {
|
||||
|
||||
private final String mUserAgent;
|
||||
|
||||
public FetchUrlMimeType(Context context, DownloadManager.Request request, String uri,
|
||||
public FetchUrlMimeType(Activity activity, DownloadManager.Request request, String uri,
|
||||
String cookies, String userAgent) {
|
||||
mContext = context.getApplicationContext();
|
||||
mContext = activity.getApplicationContext();
|
||||
mRequest = request;
|
||||
mUri = uri;
|
||||
mCookies = cookies;
|
||||
mUserAgent = userAgent;
|
||||
Toast.makeText(mContext, R.string.download_pending, Toast.LENGTH_SHORT).show();
|
||||
Utils.showSnackbar(activity, R.string.download_pending);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,7 +67,7 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
switch (preference.getKey()) {
|
||||
case SETTINGS_EXPORT:
|
||||
mBookmarkManager.exportBookmarks();
|
||||
mBookmarkManager.exportBookmarks(getActivity());
|
||||
return true;
|
||||
case SETTINGS_IMPORT:
|
||||
loadFileList(null);
|
||||
|
@ -23,7 +23,6 @@ import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.webkit.URLUtil;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
@ -76,14 +75,6 @@ public final class Utils {
|
||||
alert.show();
|
||||
}
|
||||
|
||||
public static void showToast(Context context, String message) {
|
||||
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public static void showToast(Context context, @StringRes int resource) {
|
||||
Toast.makeText(context, resource, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public static void showSnackbar(Activity activity, @StringRes int resource) {
|
||||
if (activity == null) return;
|
||||
View view = activity.findViewById(android.R.id.content);
|
||||
|
Loading…
Reference in New Issue
Block a user