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