Add support for guardian project panic/ripple app
This commit is contained in:
parent
19b6a5bfc5
commit
fd5c26cc52
@ -105,6 +105,11 @@
|
|||||||
<data android:scheme="http"/>
|
<data android:scheme="http"/>
|
||||||
<data android:scheme="https"/>
|
<data android:scheme="https"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="info.guardianproject.panic.action.TRIGGER"/>
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.SettingsActivity"
|
android:name=".activity.SettingsActivity"
|
||||||
|
@ -125,6 +125,8 @@ import butterknife.ButterKnife;
|
|||||||
|
|
||||||
public abstract class BrowserActivity extends ThemableBrowserActivity implements BrowserView, UIController, OnClickListener, OnLongClickListener {
|
public abstract class BrowserActivity extends ThemableBrowserActivity implements BrowserView, UIController, OnClickListener, OnLongClickListener {
|
||||||
|
|
||||||
|
private static final String INTENT_PANIC_TRIGGER = "info.guardianproject.panic.action.TRIGGER";
|
||||||
|
|
||||||
// Static Layout
|
// Static Layout
|
||||||
@Bind(R.id.drawer_layout)
|
@Bind(R.id.drawer_layout)
|
||||||
DrawerLayout mDrawerLayout;
|
DrawerLayout mDrawerLayout;
|
||||||
@ -171,12 +173,13 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
// Primatives
|
// Primatives
|
||||||
private boolean mFullScreen;
|
private boolean mFullScreen;
|
||||||
private boolean mDarkTheme;
|
private boolean mDarkTheme;
|
||||||
private boolean mIsNewIntent = false;
|
|
||||||
private boolean mIsFullScreen = false;
|
private boolean mIsFullScreen = false;
|
||||||
private boolean mIsImmersive = false;
|
private boolean mIsImmersive = false;
|
||||||
private boolean mShowTabsInDrawer;
|
private boolean mShowTabsInDrawer;
|
||||||
private int mOriginalOrientation, mBackgroundColor, mIdGenerator, mIconColor,
|
private int mOriginalOrientation;
|
||||||
mCurrentUiColor = Color.BLACK;
|
private int mBackgroundColor;
|
||||||
|
private int mIconColor;
|
||||||
|
private int mCurrentUiColor = Color.BLACK;
|
||||||
private String mSearchText;
|
private String mSearchText;
|
||||||
private String mUntitledTitle;
|
private String mUntitledTitle;
|
||||||
private String mCameraPhotoPath;
|
private String mCameraPhotoPath;
|
||||||
@ -356,9 +359,30 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());
|
WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isPanicTrigger(getIntent())) {
|
||||||
|
panicClean();
|
||||||
|
} else {
|
||||||
mPresenter.setupTabs(getIntent(), isIncognito());
|
mPresenter.setupTabs(getIntent(), isIncognito());
|
||||||
mProxyUtils.checkForProxy(BrowserActivity.this);
|
mProxyUtils.checkForProxy(BrowserActivity.this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isPanicTrigger(Intent intent) {
|
||||||
|
return intent != null && INTENT_PANIC_TRIGGER.equals(intent.getAction());
|
||||||
|
}
|
||||||
|
|
||||||
|
void panicClean() {
|
||||||
|
Log.d(Constants.TAG, "Closing browser");
|
||||||
|
mTabsManager.newTab(this, "", false);
|
||||||
|
mTabsManager.switchToTab(0);
|
||||||
|
mTabsManager.clearSavedState();
|
||||||
|
HistoryPage.deleteHistoryPage(getApplication());
|
||||||
|
closeBrowser();
|
||||||
|
// System exit needed in the case of receiving
|
||||||
|
// the panic intent since finish() isn't completely
|
||||||
|
// closing the browser
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
private class SearchListenerClass implements OnKeyListener, OnEditorActionListener, OnFocusChangeListener, OnTouchListener {
|
private class SearchListenerClass implements OnKeyListener, OnEditorActionListener, OnFocusChangeListener, OnTouchListener {
|
||||||
|
|
||||||
@ -806,8 +830,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
// Set the background color so the color mode color doesn't show through
|
// Set the background color so the color mode color doesn't show through
|
||||||
mBrowserFrame.setBackgroundColor(mBackgroundColor);
|
mBrowserFrame.setBackgroundColor(mBackgroundColor);
|
||||||
|
|
||||||
mIsNewIntent = false;
|
|
||||||
|
|
||||||
mBrowserFrame.removeAllViews();
|
mBrowserFrame.removeAllViews();
|
||||||
|
|
||||||
removeViewFromParent(mCurrentView);
|
removeViewFromParent(mCurrentView);
|
||||||
@ -842,8 +864,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
|||||||
// Set the background color so the color mode color doesn't show through
|
// Set the background color so the color mode color doesn't show through
|
||||||
mBrowserFrame.setBackgroundColor(mBackgroundColor);
|
mBrowserFrame.setBackgroundColor(mBackgroundColor);
|
||||||
|
|
||||||
mIsNewIntent = false;
|
|
||||||
|
|
||||||
final float translation = mToolbarLayout.getTranslationY();
|
final float translation = mToolbarLayout.getTranslationY();
|
||||||
mBrowserFrame.removeAllViews();
|
mBrowserFrame.removeAllViews();
|
||||||
|
|
||||||
|
@ -39,9 +39,13 @@ public class MainActivity extends BrowserActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
|
if (isPanicTrigger(intent)) {
|
||||||
|
panicClean();
|
||||||
|
} else {
|
||||||
handleNewIntent(intent);
|
handleNewIntent(intent);
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
|
@ -341,6 +341,15 @@ public class TabsManager {
|
|||||||
FileUtils.writeBundleToStorage(mApp, outState, BUNDLE_STORAGE);
|
FileUtils.writeBundleToStorage(mApp, outState, BUNDLE_STORAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to clear the saved
|
||||||
|
* state if you do not wish it to be
|
||||||
|
* restored when the browser next starts.
|
||||||
|
*/
|
||||||
|
public void clearSavedState() {
|
||||||
|
FileUtils.deleteBundleInStorage(mApp, BUNDLE_STORAGE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restores the previously saved tabs from the
|
* Restores the previously saved tabs from the
|
||||||
* bundle stored in peristent file storage.
|
* bundle stored in peristent file storage.
|
||||||
|
@ -106,4 +106,18 @@ public class HistoryPage extends AsyncTask<Void, Void, Void> {
|
|||||||
executeOnExecutor(BrowserApp.getIOThread());
|
executeOnExecutor(BrowserApp.getIOThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to immediately delete the history
|
||||||
|
* page on the current thread. This will clear the
|
||||||
|
* cached history page that was stored on file.
|
||||||
|
*
|
||||||
|
* @param application the application object needed to get the file.
|
||||||
|
*/
|
||||||
|
public static void deleteHistoryPage(@NonNull Application application) {
|
||||||
|
File historyWebPage = new File(application.getFilesDir(), FILENAME);
|
||||||
|
if (historyWebPage.exists()) {
|
||||||
|
historyWebPage.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -54,6 +54,21 @@ public class FileUtils {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to delete the bundle with the specified name.
|
||||||
|
* This is a blocking call and should be used within a worker
|
||||||
|
* thread unless immediate deletion is necessary.
|
||||||
|
*
|
||||||
|
* @param app the application object needed to get the file.
|
||||||
|
* @param name the name of the file.
|
||||||
|
*/
|
||||||
|
public static void deleteBundleInStorage(final @NonNull Application app, final @NonNull String name) {
|
||||||
|
File outputFile = new File(app.getFilesDir(), name);
|
||||||
|
if (outputFile.exists()) {
|
||||||
|
outputFile.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a bundle from the file with the specified
|
* Reads a bundle from the file with the specified
|
||||||
* name in the peristent storage files directory.
|
* name in the peristent storage files directory.
|
||||||
|
Loading…
Reference in New Issue
Block a user