Fixed bug where multiple processes caused incognito to nor respond to preference changes.
Possibly in the future I should explore gong back to multiprocess for incognito mode but right now it causes bugs. Also tweaked UI color in color mode
This commit is contained in:
parent
f90ab177d5
commit
bd8c439161
@ -129,7 +129,6 @@
|
|||||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:process=":incognito"
|
|
||||||
android:theme="@style/Theme.DarkTheme"
|
android:theme="@style/Theme.DarkTheme"
|
||||||
android:windowSoftInputMode="stateHidden">
|
android:windowSoftInputMode="stateHidden">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -4,9 +4,6 @@
|
|||||||
|
|
||||||
package acr.browser.lightning.activity;
|
package acr.browser.lightning.activity;
|
||||||
|
|
||||||
import android.animation.ArgbEvaluator;
|
|
||||||
import android.animation.ValueAnimator;
|
|
||||||
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
@ -191,7 +188,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
|
|
||||||
@Inject LightningDialogBuilder mBookmarksDialogBuilder;
|
@Inject LightningDialogBuilder mBookmarksDialogBuilder;
|
||||||
|
|
||||||
@Inject TabsManager mTabsManager;
|
private TabsManager mTabsManager;
|
||||||
|
|
||||||
@Inject HistoryDatabase mHistoryDatabase;
|
@Inject HistoryDatabase mHistoryDatabase;
|
||||||
|
|
||||||
@ -244,6 +241,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
mTabsManager = new TabsManager();
|
||||||
mPresenter = new BrowserPresenter(this, isIncognito());
|
mPresenter = new BrowserPresenter(this, isIncognito());
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
@ -815,6 +813,11 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
quit.setOnClickListener(this);
|
quit.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TabsManager getTabModel() {
|
||||||
|
return mTabsManager;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showCloseDialog(final int position) {
|
public void showCloseDialog(final int position) {
|
||||||
if (position < 0) {
|
if (position < 0) {
|
||||||
@ -1284,7 +1287,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
if (requestedColor == defaultColor) {
|
if (requestedColor == defaultColor) {
|
||||||
return mDarkTheme ? DrawableUtils.mixColor(0.25f, defaultColor, Color.WHITE): Color.WHITE;
|
return mDarkTheme ? DrawableUtils.mixColor(0.25f, defaultColor, Color.WHITE): Color.WHITE;
|
||||||
} else {
|
} else {
|
||||||
return DrawableUtils.mixColor(0.5f, requestedColor, Color.WHITE);
|
return DrawableUtils.mixColor(0.25f, requestedColor, Color.WHITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import javax.inject.Inject;
|
|||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import acr.browser.lightning.R;
|
import acr.browser.lightning.R;
|
||||||
|
import acr.browser.lightning.app.BrowserApp;
|
||||||
import acr.browser.lightning.constant.Constants;
|
import acr.browser.lightning.constant.Constants;
|
||||||
import acr.browser.lightning.preference.PreferenceManager;
|
import acr.browser.lightning.preference.PreferenceManager;
|
||||||
import acr.browser.lightning.react.Action;
|
import acr.browser.lightning.react.Action;
|
||||||
@ -36,7 +37,6 @@ import acr.browser.lightning.view.LightningView;
|
|||||||
* and tracks the current tab. It handles creation, deletion,
|
* and tracks the current tab. It handles creation, deletion,
|
||||||
* restoration, state saving, and switching of tabs.
|
* restoration, state saving, and switching of tabs.
|
||||||
*/
|
*/
|
||||||
@Singleton
|
|
||||||
public class TabsManager {
|
public class TabsManager {
|
||||||
|
|
||||||
private static final String TAG = TabsManager.class.getSimpleName();
|
private static final String TAG = TabsManager.class.getSimpleName();
|
||||||
@ -54,8 +54,9 @@ public class TabsManager {
|
|||||||
@Inject Bus mEventBus;
|
@Inject Bus mEventBus;
|
||||||
@Inject Application mApp;
|
@Inject Application mApp;
|
||||||
|
|
||||||
@Inject
|
public TabsManager() {
|
||||||
public TabsManager() {}
|
BrowserApp.getAppComponent().inject(this);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO remove and make presenter call new tab methods so it always knows
|
// TODO remove and make presenter call new tab methods so it always knows
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -4,6 +4,7 @@ import javax.inject.Singleton;
|
|||||||
|
|
||||||
import acr.browser.lightning.activity.BrowserActivity;
|
import acr.browser.lightning.activity.BrowserActivity;
|
||||||
import acr.browser.lightning.activity.ReadingActivity;
|
import acr.browser.lightning.activity.ReadingActivity;
|
||||||
|
import acr.browser.lightning.activity.TabsManager;
|
||||||
import acr.browser.lightning.activity.ThemableBrowserActivity;
|
import acr.browser.lightning.activity.ThemableBrowserActivity;
|
||||||
import acr.browser.lightning.activity.ThemableSettingsActivity;
|
import acr.browser.lightning.activity.ThemableSettingsActivity;
|
||||||
import acr.browser.lightning.browser.BrowserPresenter;
|
import acr.browser.lightning.browser.BrowserPresenter;
|
||||||
@ -64,4 +65,6 @@ public interface AppComponent {
|
|||||||
|
|
||||||
void inject(BrowserPresenter presenter);
|
void inject(BrowserPresenter presenter);
|
||||||
|
|
||||||
|
void inject(TabsManager manager);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import acr.browser.lightning.activity.TabsManager;
|
|||||||
import acr.browser.lightning.app.BrowserApp;
|
import acr.browser.lightning.app.BrowserApp;
|
||||||
import acr.browser.lightning.bus.BrowserEvents;
|
import acr.browser.lightning.bus.BrowserEvents;
|
||||||
import acr.browser.lightning.constant.Constants;
|
import acr.browser.lightning.constant.Constants;
|
||||||
|
import acr.browser.lightning.controller.UIController;
|
||||||
import acr.browser.lightning.preference.PreferenceManager;
|
import acr.browser.lightning.preference.PreferenceManager;
|
||||||
import acr.browser.lightning.react.OnSubscribe;
|
import acr.browser.lightning.react.OnSubscribe;
|
||||||
import acr.browser.lightning.utils.UrlUtils;
|
import acr.browser.lightning.utils.UrlUtils;
|
||||||
@ -30,7 +31,7 @@ public class BrowserPresenter {
|
|||||||
|
|
||||||
private static final String TAG = BrowserPresenter.class.getSimpleName();
|
private static final String TAG = BrowserPresenter.class.getSimpleName();
|
||||||
|
|
||||||
@Inject TabsManager mTabsModel;
|
private TabsManager mTabsModel;
|
||||||
@Inject PreferenceManager mPreferences;
|
@Inject PreferenceManager mPreferences;
|
||||||
@Inject Bus mEventBus;
|
@Inject Bus mEventBus;
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ public class BrowserPresenter {
|
|||||||
|
|
||||||
public BrowserPresenter(@NonNull BrowserView view, boolean isIncognito) {
|
public BrowserPresenter(@NonNull BrowserView view, boolean isIncognito) {
|
||||||
BrowserApp.getAppComponent().inject(this);
|
BrowserApp.getAppComponent().inject(this);
|
||||||
|
mTabsModel = ((UIController) view).getTabModel();
|
||||||
mView = view;
|
mView = view;
|
||||||
mIsIncognito = isIncognito;
|
mIsIncognito = isIncognito;
|
||||||
mTabsModel.setTabNumberChangedListener(new TabsManager.TabNumberChangedListener() {
|
mTabsModel.setTabNumberChangedListener(new TabsManager.TabNumberChangedListener() {
|
||||||
|
@ -14,6 +14,7 @@ import android.view.View;
|
|||||||
import android.webkit.ValueCallback;
|
import android.webkit.ValueCallback;
|
||||||
import android.webkit.WebChromeClient.CustomViewCallback;
|
import android.webkit.WebChromeClient.CustomViewCallback;
|
||||||
|
|
||||||
|
import acr.browser.lightning.activity.TabsManager;
|
||||||
import acr.browser.lightning.view.LightningView;
|
import acr.browser.lightning.view.LightningView;
|
||||||
|
|
||||||
public interface UIController {
|
public interface UIController {
|
||||||
@ -61,4 +62,6 @@ public interface UIController {
|
|||||||
|
|
||||||
void tabChanged(LightningView tab);
|
void tabChanged(LightningView tab);
|
||||||
|
|
||||||
|
TabsManager getTabModel();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ import acr.browser.lightning.async.AsyncExecutor;
|
|||||||
import acr.browser.lightning.bus.BookmarkEvents;
|
import acr.browser.lightning.bus.BookmarkEvents;
|
||||||
import acr.browser.lightning.bus.BrowserEvents;
|
import acr.browser.lightning.bus.BrowserEvents;
|
||||||
import acr.browser.lightning.constant.Constants;
|
import acr.browser.lightning.constant.Constants;
|
||||||
|
import acr.browser.lightning.controller.UIController;
|
||||||
import acr.browser.lightning.database.BookmarkManager;
|
import acr.browser.lightning.database.BookmarkManager;
|
||||||
import acr.browser.lightning.database.HistoryItem;
|
import acr.browser.lightning.database.HistoryItem;
|
||||||
import acr.browser.lightning.dialog.LightningDialogBuilder;
|
import acr.browser.lightning.dialog.LightningDialogBuilder;
|
||||||
@ -72,7 +73,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
|
|||||||
|
|
||||||
@Inject PreferenceManager mPreferenceManager;
|
@Inject PreferenceManager mPreferenceManager;
|
||||||
|
|
||||||
@Inject TabsManager mTabsManager;
|
private TabsManager mTabsManager;
|
||||||
|
|
||||||
// Adapter
|
// Adapter
|
||||||
private BookmarkViewAdapter mBookmarkAdapter;
|
private BookmarkViewAdapter mBookmarkAdapter;
|
||||||
@ -107,6 +108,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
|
|||||||
BrowserApp.getAppComponent().inject(this);
|
BrowserApp.getAppComponent().inject(this);
|
||||||
final Bundle arguments = getArguments();
|
final Bundle arguments = getArguments();
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
|
mTabsManager = ((UIController) context).getTabModel();
|
||||||
boolean isIncognito = arguments.getBoolean(INCOGNITO_MODE, false);
|
boolean isIncognito = arguments.getBoolean(INCOGNITO_MODE, false);
|
||||||
boolean darkTheme = mPreferenceManager.getUseTheme() != 0 || isIncognito;
|
boolean darkTheme = mPreferenceManager.getUseTheme() != 0 || isIncognito;
|
||||||
mWebpageBitmap = ThemeUtils.getThemedBitmap(context, R.drawable.ic_webpage, darkTheme);
|
mWebpageBitmap = ThemeUtils.getThemedBitmap(context, R.drawable.ic_webpage, darkTheme);
|
||||||
|
@ -31,7 +31,6 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.squareup.otto.Bus;
|
import com.squareup.otto.Bus;
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@ -39,7 +38,6 @@ import acr.browser.lightning.R;
|
|||||||
import acr.browser.lightning.activity.TabsManager;
|
import acr.browser.lightning.activity.TabsManager;
|
||||||
import acr.browser.lightning.app.BrowserApp;
|
import acr.browser.lightning.app.BrowserApp;
|
||||||
import acr.browser.lightning.browser.TabsView;
|
import acr.browser.lightning.browser.TabsView;
|
||||||
import acr.browser.lightning.bus.BrowserEvents;
|
|
||||||
import acr.browser.lightning.bus.NavigationEvents;
|
import acr.browser.lightning.bus.NavigationEvents;
|
||||||
import acr.browser.lightning.bus.TabEvents;
|
import acr.browser.lightning.bus.TabEvents;
|
||||||
import acr.browser.lightning.controller.UIController;
|
import acr.browser.lightning.controller.UIController;
|
||||||
@ -77,7 +75,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
|||||||
private UIController mUiController;
|
private UIController mUiController;
|
||||||
private RecyclerView mRecyclerView;
|
private RecyclerView mRecyclerView;
|
||||||
|
|
||||||
@Inject TabsManager tabsManager;
|
private TabsManager mTabsManager;
|
||||||
@Inject Bus mBus;
|
@Inject Bus mBus;
|
||||||
@Inject PreferenceManager mPreferences;
|
@Inject PreferenceManager mPreferences;
|
||||||
|
|
||||||
@ -91,6 +89,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
|||||||
final Bundle arguments = getArguments();
|
final Bundle arguments = getArguments();
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
mUiController = (UIController) getActivity();
|
mUiController = (UIController) getActivity();
|
||||||
|
mTabsManager = mUiController.getTabModel();
|
||||||
mIsIncognito = arguments.getBoolean(IS_INCOGNITO, false);
|
mIsIncognito = arguments.getBoolean(IS_INCOGNITO, false);
|
||||||
mShowInNavigationDrawer = arguments.getBoolean(VERTICAL_MODE, true);
|
mShowInNavigationDrawer = arguments.getBoolean(VERTICAL_MODE, true);
|
||||||
mDarkTheme = mPreferences.getUseTheme() != 0 || mIsIncognito;
|
mDarkTheme = mPreferences.getUseTheme() != 0 || mIsIncognito;
|
||||||
@ -187,7 +186,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
|||||||
public void onClick(@NonNull View v) {
|
public void onClick(@NonNull View v) {
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.tab_header_button:
|
case R.id.tab_header_button:
|
||||||
mUiController.showCloseDialog(tabsManager.indexOfCurrentTab());
|
mUiController.showCloseDialog(mTabsManager.indexOfCurrentTab());
|
||||||
break;
|
break;
|
||||||
case R.id.new_tab_button:
|
case R.id.new_tab_button:
|
||||||
mBus.post(new TabEvents.NewTab());
|
mBus.post(new TabEvents.NewTab());
|
||||||
@ -220,7 +219,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
|||||||
@Override
|
@Override
|
||||||
public void tabAdded() {
|
public void tabAdded() {
|
||||||
if (mTabsAdapter != null) {
|
if (mTabsAdapter != null) {
|
||||||
mTabsAdapter.notifyItemInserted(tabsManager.last());
|
mTabsAdapter.notifyItemInserted(mTabsManager.last());
|
||||||
mRecyclerView.postDelayed(new Runnable() {
|
mRecyclerView.postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -292,7 +291,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
|||||||
|
|
||||||
ViewCompat.jumpDrawablesToCurrentState(holder.exitButton);
|
ViewCompat.jumpDrawablesToCurrentState(holder.exitButton);
|
||||||
|
|
||||||
LightningView web = tabsManager.getTabAtPosition(position);
|
LightningView web = mTabsManager.getTabAtPosition(position);
|
||||||
if (web == null) {
|
if (web == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -340,7 +339,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return tabsManager.size();
|
return mTabsManager.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap getDesaturatedBitmap(@NonNull Bitmap favicon) {
|
public Bitmap getDesaturatedBitmap(@NonNull Bitmap favicon) {
|
||||||
|
Loading…
Reference in New Issue
Block a user