Browse Source

Restore activity restart when tab mode changes

master
Stefano Pacifici 9 years ago
parent
commit
61b57cd992
  1. 3
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 15
      app/src/main/java/acr/browser/lightning/activity/ThemableBrowserActivity.java
  3. 3
      app/src/main/java/acr/browser/lightning/app/AppComponent.java
  4. 12
      app/src/main/java/acr/browser/lightning/bus/BrowserEvents.java

3
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -191,8 +191,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -191,8 +191,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
@Inject
TabsManager tabsManager;
@Inject
PreferenceManager mPreferences;
// Preference manager was moved on ThemeableBrowserActivity
@Inject
HistoryDatabase mHistoryDatabase;

15
app/src/main/java/acr/browser/lightning/activity/ThemableBrowserActivity.java

@ -5,18 +5,25 @@ import android.content.res.Configuration; @@ -5,18 +5,25 @@ import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import javax.inject.Inject;
import acr.browser.lightning.R;
import acr.browser.lightning.app.BrowserApp;
import acr.browser.lightning.preference.PreferenceManager;
public abstract class ThemableBrowserActivity extends AppCompatActivity {
@Inject
PreferenceManager mPreferences;
private int mTheme;
private boolean mShowTabsInDrawer;
@Override
protected void onCreate(Bundle savedInstanceState) {
mTheme = 0; //PreferenceManager.getInstance().getUseTheme();
mShowTabsInDrawer = false; // PreferenceManager.getInstance().getShowTabsInDrawer(!isTablet());
BrowserApp.getAppComponent().inject(this);
mTheme = mPreferences.getUseTheme();
mShowTabsInDrawer = mPreferences.getShowTabsInDrawer(!isTablet());
// set the theme
if (mTheme == 1) {
@ -30,8 +37,8 @@ public abstract class ThemableBrowserActivity extends AppCompatActivity { @@ -30,8 +37,8 @@ public abstract class ThemableBrowserActivity extends AppCompatActivity {
@Override
protected void onResume() {
super.onResume();
int theme = 0; // PreferenceManager.getInstance().getUseTheme();
boolean drawerTabs = false; // PreferenceManager.getInstance().getShowTabsInDrawer(!isTablet());
int theme = mPreferences.getUseTheme();
boolean drawerTabs = mPreferences.getShowTabsInDrawer(!isTablet());
if (theme != mTheme || mShowTabsInDrawer != drawerTabs) {
restart();
}

3
app/src/main/java/acr/browser/lightning/app/AppComponent.java

@ -7,6 +7,7 @@ import com.squareup.otto.Bus; @@ -7,6 +7,7 @@ import com.squareup.otto.Bus;
import javax.inject.Singleton;
import acr.browser.lightning.activity.BrowserActivity;
import acr.browser.lightning.activity.ThemableBrowserActivity;
import acr.browser.lightning.constant.BookmarkPage;
import acr.browser.lightning.database.HistoryDatabase;
import acr.browser.lightning.dialog.LightningDialogBuilder;
@ -53,4 +54,6 @@ public interface AppComponent { @@ -53,4 +54,6 @@ public interface AppComponent {
Context getApplicationContext();
void inject(LightningView lightningView);
void inject(ThemableBrowserActivity activity);
}

12
app/src/main/java/acr/browser/lightning/bus/BrowserEvents.java

@ -17,9 +17,9 @@ public final class BrowserEvents { @@ -17,9 +17,9 @@ public final class BrowserEvents {
* result is a new bookmark added.
*/
public static class AddBookmark {
public final java.lang.String title, url;
public final String title, url;
public AddBookmark(final java.lang.String title, final java.lang.String url) {
public AddBookmark(final String title, final String url) {
this.title = title;
this.url = url;
}
@ -30,9 +30,9 @@ public final class BrowserEvents { @@ -30,9 +30,9 @@ public final class BrowserEvents {
* {@link acr.browser.lightning.fragment.BookmarksFragment} interface.
*/
public static class CurrentPageUrl {
public final java.lang.String url;
public final String url;
public CurrentPageUrl(final java.lang.String url) {
public CurrentPageUrl(final String url) {
this.url = url;
}
}
@ -57,11 +57,11 @@ public final class BrowserEvents { @@ -57,11 +57,11 @@ public final class BrowserEvents {
* Notify the Browser to display a SnackBar in the main activity
*/
public static class ShowSnackBarMessage {
public final java.lang.String message;
public final String message;
@StringRes
public final int stringRes;
public ShowSnackBarMessage(final java.lang.String message) {
public ShowSnackBarMessage(final String message) {
this.message = message;
this.stringRes = -1;
}

Loading…
Cancel
Save