Augmented dialogs, added options to dialogs, improved dialog UI
This commit is contained in:
parent
6d6de156c6
commit
6387d98d5d
@ -858,11 +858,11 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
if (position < 0) {
|
||||
return;
|
||||
}
|
||||
BrowserDialog.show(this,
|
||||
new BrowserDialog.Item(R.string.close_all_tabs) {
|
||||
BrowserDialog.show(this, R.string.dialog_title_close_browser,
|
||||
new BrowserDialog.Item(R.string.close_tab) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
closeBrowser();
|
||||
deleteTab(position);
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.close_other_tabs) {
|
||||
@ -871,10 +871,10 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
mPresenter.closeAllOtherTabs();
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.close_tab) {
|
||||
new BrowserDialog.Item(R.string.close_all_tabs) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
deleteTab(position);
|
||||
closeBrowser();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -2132,8 +2132,17 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
*/
|
||||
@Subscribe
|
||||
public void loadUrlInNewTab(final BrowserEvents.OpenUrlInNewTab event) {
|
||||
BrowserActivity.this.newTab(event.url, true);
|
||||
mDrawerLayout.closeDrawers();
|
||||
if (event.location == BrowserEvents.OpenUrlInNewTab.Location.NEW_TAB) {
|
||||
BrowserActivity.this.newTab(event.url, true);
|
||||
} else if (event.location == BrowserEvents.OpenUrlInNewTab.Location.BACKGROUND) {
|
||||
BrowserActivity.this.newTab(event.url, false);
|
||||
} else if (event.location == BrowserEvents.OpenUrlInNewTab.Location.INCOGNITO) {
|
||||
Intent intent = new Intent(BrowserActivity.this, IncognitoActivity.class);
|
||||
intent.setData(Uri.parse(event.url));
|
||||
startActivity(intent);
|
||||
overridePendingTransition(R.anim.slide_up_in, R.anim.fade_out_scale);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,18 +115,18 @@ public class TabsManager {
|
||||
// Make sure we start with a clean tab list
|
||||
shutdown();
|
||||
|
||||
// If incognito, only create one tab, do not handle intent
|
||||
// in order to protect user privacy
|
||||
if (incognito) {
|
||||
newTab(activity, null, true);
|
||||
subscriber.onComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
String url = null;
|
||||
if (intent != null) {
|
||||
url = intent.getDataString();
|
||||
}
|
||||
|
||||
// If incognito, only create one tab
|
||||
if (incognito) {
|
||||
newTab(activity, url, true);
|
||||
subscriber.onComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d(TAG, "URL from intent: " + url);
|
||||
mCurrentTab = null;
|
||||
if (mPreferenceManager.getRestoreLostTabsEnabled()) {
|
||||
|
@ -2,6 +2,8 @@ package acr.browser.lightning.app;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.StrictMode;
|
||||
@ -116,4 +118,10 @@ public class BrowserApp extends Application {
|
||||
return !BuildConfig.DEBUG || BuildConfig.BUILD_TYPE.toLowerCase().equals("release");
|
||||
}
|
||||
|
||||
public static void copyToClipboard(@NonNull Context context, @NonNull String string) {
|
||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("URL", string);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -81,10 +81,25 @@ public final class BrowserEvents {
|
||||
* The user ask to open the given url as new tab
|
||||
*/
|
||||
public final static class OpenUrlInNewTab {
|
||||
|
||||
public enum Location {
|
||||
NEW_TAB,
|
||||
BACKGROUND,
|
||||
INCOGNITO
|
||||
}
|
||||
|
||||
public final String url;
|
||||
|
||||
public final Location location;
|
||||
|
||||
public OpenUrlInNewTab(final String url) {
|
||||
this.url = url;
|
||||
this.location = Location.NEW_TAB;
|
||||
}
|
||||
|
||||
public OpenUrlInNewTab(final String url, Location location) {
|
||||
this.url = url;
|
||||
this.location = location;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,29 @@
|
||||
package acr.browser.lightning.dialog;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import acr.browser.lightning.R;
|
||||
import acr.browser.lightning.utils.DeviceUtils;
|
||||
import acr.browser.lightning.utils.ResourceUtils;
|
||||
import acr.browser.lightning.utils.Utils;
|
||||
|
||||
/**
|
||||
@ -45,6 +54,12 @@ public class BrowserDialog {
|
||||
public static abstract class Item {
|
||||
|
||||
private int mTitle;
|
||||
private boolean mCondition = true;
|
||||
|
||||
public Item(@StringRes int title, boolean condition) {
|
||||
this(title);
|
||||
mCondition = condition;
|
||||
}
|
||||
|
||||
public Item(@StringRes int title) {
|
||||
mTitle = title;
|
||||
@ -55,6 +70,10 @@ public class BrowserDialog {
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
private boolean isConditionMet() {
|
||||
return mCondition;
|
||||
}
|
||||
|
||||
public abstract void onClick();
|
||||
}
|
||||
|
||||
@ -69,13 +88,25 @@ public class BrowserDialog {
|
||||
|
||||
public static void show(@NonNull Activity activity, @Nullable String title, @NonNull Item item, @Nullable Item... items) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
|
||||
View layout = LayoutInflater.from(activity).inflate(R.layout.list_dialog, null);
|
||||
|
||||
TextView titleView = (TextView) layout.findViewById(R.id.dialog_title);
|
||||
ListView listView = (ListView) layout.findViewById(R.id.dialog_list);
|
||||
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(activity,
|
||||
android.R.layout.simple_list_item_1);
|
||||
|
||||
final List<Item> itemList = new ArrayList<>(1);
|
||||
itemList.add(item);
|
||||
if (item.isConditionMet()) {
|
||||
itemList.add(item);
|
||||
}
|
||||
if (items != null) {
|
||||
itemList.addAll(Arrays.asList(items));
|
||||
for (Item it : items) {
|
||||
if (it.isConditionMet()) {
|
||||
itemList.add(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Item it : itemList) {
|
||||
@ -83,16 +114,31 @@ public class BrowserDialog {
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(title)) {
|
||||
builder.setTitle(title);
|
||||
titleView.setText(title);
|
||||
}
|
||||
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
|
||||
|
||||
listView.setAdapter(adapter);
|
||||
|
||||
listView.setDivider(null);
|
||||
builder.setView(layout);
|
||||
|
||||
int maxWidth = ResourceUtils.dimen(activity, R.dimen.dialog_max_size);
|
||||
int padding = ResourceUtils.dimen(activity, R.dimen.dialog_padding);
|
||||
int screenSize = DeviceUtils.getScreenWidth(activity);
|
||||
if (maxWidth > screenSize - 2 * padding) {
|
||||
maxWidth = screenSize - 2 * padding;
|
||||
}
|
||||
|
||||
final Dialog dialog = builder.show();
|
||||
dialog.getWindow().setLayout(maxWidth, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
itemList.get(which).onClick();
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
itemList.get(position).onClick();
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
|
||||
public static void showEditText(@NonNull Activity activity, @StringRes int title,
|
||||
|
@ -22,6 +22,7 @@ import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import acr.browser.lightning.R;
|
||||
import acr.browser.lightning.activity.MainActivity;
|
||||
import acr.browser.lightning.app.BrowserApp;
|
||||
import acr.browser.lightning.bus.BookmarkEvents;
|
||||
import acr.browser.lightning.bus.BrowserEvents;
|
||||
@ -81,15 +82,33 @@ public class LightningDialogBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public void showLongPressedDialogForBookmarkUrl(@NonNull final Activity context, @NonNull final HistoryItem item) {
|
||||
BrowserDialog.show(context, R.string.action_bookmarks,
|
||||
new BrowserDialog.Item(R.string.action_new_tab) {
|
||||
public void showLongPressedDialogForBookmarkUrl(@NonNull final Activity activity, @NonNull final HistoryItem item) {
|
||||
BrowserDialog.show(activity, R.string.action_bookmarks,
|
||||
new BrowserDialog.Item(R.string.dialog_open_new_tab) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
mEventBus.post(new BrowserEvents.OpenUrlInNewTab(item.getUrl()));
|
||||
mEventBus.post(new BrowserEvents.OpenUrlInNewTab(item.getUrl(), BrowserEvents.OpenUrlInNewTab.Location.NEW_TAB));
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.action_delete) {
|
||||
new BrowserDialog.Item(R.string.dialog_open_background_tab) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
mEventBus.post(new BrowserEvents.OpenUrlInNewTab(item.getUrl(), BrowserEvents.OpenUrlInNewTab.Location.BACKGROUND));
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.dialog_open_incognito_tab, activity instanceof MainActivity) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
mEventBus.post(new BrowserEvents.OpenUrlInNewTab(item.getUrl(), BrowserEvents.OpenUrlInNewTab.Location.INCOGNITO));
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.dialog_copy_link) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
BrowserApp.copyToClipboard(activity, item.getUrl());
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.dialog_remove_bookmark) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
if (mBookmarkManager.deleteBookmark(item)) {
|
||||
@ -97,18 +116,18 @@ public class LightningDialogBuilder {
|
||||
}
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.action_edit) {
|
||||
new BrowserDialog.Item(R.string.dialog_edit_bookmark) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
showEditBookmarkDialog(context, item);
|
||||
showEditBookmarkDialog(activity, item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showEditBookmarkDialog(@NonNull final Context context, @NonNull final HistoryItem item) {
|
||||
final AlertDialog.Builder editBookmarkDialog = new AlertDialog.Builder(context);
|
||||
private void showEditBookmarkDialog(@NonNull final Activity activity, @NonNull final HistoryItem item) {
|
||||
final AlertDialog.Builder editBookmarkDialog = new AlertDialog.Builder(activity);
|
||||
editBookmarkDialog.setTitle(R.string.title_edit_bookmark);
|
||||
final View dialogLayout = View.inflate(context, R.layout.dialog_edit_bookmark, null);
|
||||
final View dialogLayout = View.inflate(activity, R.layout.dialog_edit_bookmark, null);
|
||||
final EditText getTitle = (EditText) dialogLayout.findViewById(R.id.bookmark_title);
|
||||
getTitle.setText(item.getTitle());
|
||||
final EditText getUrl = (EditText) dialogLayout.findViewById(R.id.bookmark_url);
|
||||
@ -118,12 +137,12 @@ public class LightningDialogBuilder {
|
||||
getFolder.setHint(R.string.folder);
|
||||
getFolder.setText(item.getFolder());
|
||||
final List<String> folders = mBookmarkManager.getFolderTitles();
|
||||
final ArrayAdapter<String> suggestionsAdapter = new ArrayAdapter<>(context,
|
||||
final ArrayAdapter<String> suggestionsAdapter = new ArrayAdapter<>(activity,
|
||||
android.R.layout.simple_dropdown_item_1line, folders);
|
||||
getFolder.setThreshold(1);
|
||||
getFolder.setAdapter(suggestionsAdapter);
|
||||
editBookmarkDialog.setView(dialogLayout);
|
||||
editBookmarkDialog.setPositiveButton(context.getString(R.string.action_ok),
|
||||
editBookmarkDialog.setPositiveButton(activity.getString(R.string.action_ok),
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
@ -140,16 +159,16 @@ public class LightningDialogBuilder {
|
||||
editBookmarkDialog.show();
|
||||
}
|
||||
|
||||
public void showBookmarkFolderLongPressedDialog(@NonNull final Activity context, @NonNull final HistoryItem item) {
|
||||
public void showBookmarkFolderLongPressedDialog(@NonNull final Activity activity, @NonNull final HistoryItem item) {
|
||||
|
||||
BrowserDialog.show(context, R.string.action_folder,
|
||||
new BrowserDialog.Item(R.string.action_rename) {
|
||||
BrowserDialog.show(activity, R.string.action_folder,
|
||||
new BrowserDialog.Item(R.string.dialog_rename_folder) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
showRenameFolderDialog(context, item);
|
||||
showRenameFolderDialog(activity, item);
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.action_delete) {
|
||||
new BrowserDialog.Item(R.string.dialog_remove_folder) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
mBookmarkManager.deleteFolder(item.getTitle());
|
||||
@ -158,8 +177,8 @@ public class LightningDialogBuilder {
|
||||
});
|
||||
}
|
||||
|
||||
private void showRenameFolderDialog(@NonNull final Activity context, @NonNull final HistoryItem item) {
|
||||
BrowserDialog.showEditText(context, R.string.title_rename_folder,
|
||||
private void showRenameFolderDialog(@NonNull final Activity activity, @NonNull final HistoryItem item) {
|
||||
BrowserDialog.showEditText(activity, R.string.title_rename_folder,
|
||||
R.string.hint_title, item.getTitle(),
|
||||
R.string.action_ok, new BrowserDialog.EditorListener() {
|
||||
@Override
|
||||
@ -178,15 +197,33 @@ public class LightningDialogBuilder {
|
||||
});
|
||||
}
|
||||
|
||||
public void showLongPressedHistoryLinkDialog(final Activity context, @NonNull final String url) {
|
||||
BrowserDialog.show(context, R.string.action_history,
|
||||
new BrowserDialog.Item(R.string.action_new_tab) {
|
||||
public void showLongPressedHistoryLinkDialog(@NonNull final Activity activity, @NonNull final String url) {
|
||||
BrowserDialog.show(activity, R.string.action_history,
|
||||
new BrowserDialog.Item(R.string.dialog_open_new_tab) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
mEventBus.post(new BrowserEvents.OpenUrlInNewTab(url));
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.action_delete) {
|
||||
new BrowserDialog.Item(R.string.dialog_open_background_tab) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
mEventBus.post(new BrowserEvents.OpenUrlInNewTab(url, BrowserEvents.OpenUrlInNewTab.Location.BACKGROUND));
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.dialog_open_incognito_tab, activity instanceof MainActivity) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
mEventBus.post(new BrowserEvents.OpenUrlInNewTab(url, BrowserEvents.OpenUrlInNewTab.Location.INCOGNITO));
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.dialog_copy_link) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
BrowserApp.copyToClipboard(activity, url);
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.dialog_remove_from_history) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
BrowserApp.getIOThread().execute(new Runnable() {
|
||||
@ -203,12 +240,6 @@ public class LightningDialogBuilder {
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.action_open) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
mEventBus.post(new BrowserEvents.OpenUrlInCurrentTab(url));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -216,19 +247,31 @@ public class LightningDialogBuilder {
|
||||
public void showLongPressImageDialog(@NonNull final Activity activity, @NonNull final String url,
|
||||
@NonNull final String userAgent) {
|
||||
BrowserDialog.show(activity, url.replace(Constants.HTTP, ""),
|
||||
new BrowserDialog.Item(R.string.action_new_tab) {
|
||||
new BrowserDialog.Item(R.string.dialog_open_new_tab) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
mEventBus.post(new BrowserEvents.OpenUrlInNewTab(url));
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.action_open) {
|
||||
new BrowserDialog.Item(R.string.dialog_open_background_tab) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
mEventBus.post(new BrowserEvents.OpenUrlInCurrentTab(url));
|
||||
mEventBus.post(new BrowserEvents.OpenUrlInNewTab(url, BrowserEvents.OpenUrlInNewTab.Location.BACKGROUND));
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.action_download) {
|
||||
new BrowserDialog.Item(R.string.dialog_open_incognito_tab, activity instanceof MainActivity) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
mEventBus.post(new BrowserEvents.OpenUrlInNewTab(url, BrowserEvents.OpenUrlInNewTab.Location.INCOGNITO));
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.dialog_copy_link) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
BrowserApp.copyToClipboard(activity, url);
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.dialog_download_image) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
Utils.downloadFile(activity, mPreferenceManager, url, userAgent, "attachment");
|
||||
@ -236,26 +279,30 @@ public class LightningDialogBuilder {
|
||||
});
|
||||
}
|
||||
|
||||
public void showLongPressLinkDialog(@NonNull final Activity context, final String url) {
|
||||
BrowserDialog.show(context, url,
|
||||
new BrowserDialog.Item(R.string.action_new_tab) {
|
||||
public void showLongPressLinkDialog(@NonNull final Activity activity, final String url) {
|
||||
BrowserDialog.show(activity, url,
|
||||
new BrowserDialog.Item(R.string.dialog_open_new_tab) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
mEventBus.post(new BrowserEvents.OpenUrlInNewTab(url));
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.action_open) {
|
||||
new BrowserDialog.Item(R.string.dialog_open_background_tab) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
mEventBus.post(new BrowserEvents.OpenUrlInCurrentTab(url));
|
||||
mEventBus.post(new BrowserEvents.OpenUrlInNewTab(url, BrowserEvents.OpenUrlInNewTab.Location.BACKGROUND));
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.action_copy) {
|
||||
new BrowserDialog.Item(R.string.dialog_open_incognito_tab, activity instanceof MainActivity) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("label", url);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
mEventBus.post(new BrowserEvents.OpenUrlInNewTab(url, BrowserEvents.OpenUrlInNewTab.Location.INCOGNITO));
|
||||
}
|
||||
},
|
||||
new BrowserDialog.Item(R.string.dialog_copy_link) {
|
||||
@Override
|
||||
public void onClick() {
|
||||
BrowserApp.copyToClipboard(activity, url);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
package acr.browser.lightning.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Display;
|
||||
import android.view.WindowManager;
|
||||
|
||||
public final class DeviceUtils {
|
||||
|
||||
private DeviceUtils() {}
|
||||
|
||||
public static int getScreenWidth(@NonNull Context context) {
|
||||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
Display display = wm.getDefaultDisplay();
|
||||
Point point = new Point();
|
||||
display.getSize(point);
|
||||
return point.x;
|
||||
}
|
||||
|
||||
public static int getAvailableScreenWidth(@NonNull Context context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
Display display = wm.getDefaultDisplay();
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
display.getRealMetrics(metrics);
|
||||
return metrics.widthPixels;
|
||||
} else {
|
||||
return getScreenWidth(context);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package acr.browser.lightning.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.DimenRes;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
public final class ResourceUtils {
|
||||
|
||||
private ResourceUtils() {}
|
||||
|
||||
public static int dimen(@NonNull Context context, @DimenRes int res) {
|
||||
return Math.round(context.getResources().getDimension(res));
|
||||
}
|
||||
}
|
30
app/src/main/res/layout/list_dialog.xml
Normal file
30
app/src/main/res/layout/list_dialog.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxHeight="300dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialog_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="start"
|
||||
android:maxLines="2"
|
||||
android:paddingBottom="@dimen/default_padding"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
|
||||
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingTop="@dimen/extra_padding"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Title"/>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/dialog_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:listSelector="?attr/listChoiceBackgroundIndicator"/>
|
||||
|
||||
</LinearLayout>
|
@ -4,4 +4,10 @@
|
||||
<dimen name="navigation_width">260dp</dimen>
|
||||
<dimen name="search_bar_height">48dp</dimen>
|
||||
|
||||
<dimen name="dialog_max_size">350dp</dimen>
|
||||
<dimen name="dialog_padding">24dp</dimen>
|
||||
|
||||
<dimen name="default_padding">8dp</dimen>
|
||||
<dimen name="extra_padding">16dp</dimen>
|
||||
|
||||
</resources>
|
||||
|
@ -194,7 +194,7 @@
|
||||
<string name="settings_privacy">Privacy Settings</string>
|
||||
<string name="settings_about">About</string>
|
||||
<string name="settings_about_explain">Details about version, author and license.</string>
|
||||
<string name="close_tab">Close tab</string>
|
||||
<string name="close_tab">Close current tab</string>
|
||||
<string name="close_all_tabs">Close all tabs</string>
|
||||
<string name="close_other_tabs">Close other tabs</string>
|
||||
<string name="third_party">Block 3rd Party Cookies</string>
|
||||
@ -242,4 +242,17 @@
|
||||
<string name="debug_title">Debug Settings</string>
|
||||
<string name="debug_leak_canary">LeakCanary</string>
|
||||
<string name="app_restart">Please restart the app for the change to take effect.</string>
|
||||
|
||||
<!-- Dialogs -->
|
||||
<string name="dialog_open_new_tab">Open in new tab</string>
|
||||
<string name="dialog_open_background_tab">Open in background tab</string>
|
||||
<string name="dialog_open_incognito_tab">Open in incognito tab</string>
|
||||
<string name="dialog_remove_bookmark">Remove bookmark</string>
|
||||
<string name="dialog_edit_bookmark">Edit bookmark</string>
|
||||
<string name="dialog_remove_from_history">Remove from history</string>
|
||||
<string name="dialog_download_image">Download image</string>
|
||||
<string name="dialog_copy_link">Copy link</string>
|
||||
<string name="dialog_rename_folder">Rename folder</string>
|
||||
<string name="dialog_remove_folder">Remove folder</string>
|
||||
<string name="dialog_title_close_browser">Close browser</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user