Skip to content

Commit

Permalink
custom home (fixes issue #350)
Browse files Browse the repository at this point in the history
  • Loading branch information
cvan committed Dec 14, 2018
1 parent 91d4710 commit 6f0bf44
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,12 @@ void loadFromIntent(final Intent intent) {
uri = Uri.parse(intent.getExtras().getString("url"));
}

Uri homepageUri = intent.getData();
if (uri == null && intent.getExtras() != null && intent.getExtras().containsKey("homepage")) {
homepageUri = Uri.parse(intent.getExtras().getString("homepage"));
SessionStore.get().setHomepage(homepage.toString());
}

if (SessionStore.get().getCurrentSession() == null) {
String url = (uri != null ? uri.toString() : null);
int id = SessionStore.get().createSession();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static SessionStore get() {
return mInstance;
}
// You can test a local file using: "resource://android/assets/webvr/index.html"
private static final String HOME_WITHOUT_REGION_ORIGIN = "https://webxr.today/";
public static String HOME_WITHOUT_REGION_ORIGIN = null;
public static final String PRIVATE_BROWSING_URI = "about:privatebrowsing";
public static final int NO_SESSION_ID = -1;

Expand Down Expand Up @@ -342,6 +342,7 @@ int createSession(SessionSettings aSettings) {

int result = state.mSession.hashCode();
mSessions.put(result, state);

state.mSession.getSettings().setBoolean(GeckoSessionSettings.USE_MULTIPROCESS, aSettings.multiprocess);
state.mSession.getSettings().setBoolean(GeckoSessionSettings.USE_PRIVATE_MODE, aSettings.privateMode);
state.mSession.getSettings().setBoolean(GeckoSessionSettings.USE_TRACKING_PROTECTION, aSettings.trackingProtection);
Expand Down Expand Up @@ -492,15 +493,17 @@ public void setRegion(String aRegion) {
}

public String getHomeUri() {
String result = SessionStore.HOME_WITHOUT_REGION_ORIGIN;
String result = SettingsStore.getInstance(mContext).getHomepage();
if (mRegion != null) {
result = SessionStore.HOME_WITHOUT_REGION_ORIGIN + "?region=" + mRegion;
result = result + "?region=" + mRegion;
}
return result;
}

public Boolean isHomeUri(String aUri) {
return aUri != null && aUri.toLowerCase().startsWith(SessionStore.HOME_WITHOUT_REGION_ORIGIN);
return aUri != null && aUri.toLowerCase().startsWith(
SettingsStore.getInstance(mContext).getHomepage()
);
}

public String getCurrentUri() {
Expand Down Expand Up @@ -725,6 +728,7 @@ private void vrPrefsWorkAround(Context aContext, Bundle aExtras) {
}

private void addOptionalPref(FileOutputStream out, String aKey, Bundle aExtras) throws IOException {
aKey
if (aExtras != null && aExtras.containsKey(aKey)) {
boolean value = aExtras.getBoolean(aKey);
out.write(String.format("pref(\"%s\", %s);\n", aKey, value ? "true" : "false").getBytes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ SettingsStore getInstance(final @NonNull Context aContext) {
private SharedPreferences mPrefs;

// Developer options default values
public final static int HOMEPAGE_DEFAULT = "https://webxr.today/";
public final static boolean REMOTE_DEBUGGING_DEFAULT = false;
public final static boolean CONSOLE_LOGS_DEFAULT = false;
public final static boolean ENV_OVERRIDE_DEFAULT = false;
Expand Down Expand Up @@ -187,6 +188,15 @@ public void setInputMode(int aTouchMode) {
editor.commit();
}

public string getHomepage() {
return mPrefs.getString(mContext.getString(R.string.settings_key_homepage), HOMEPAGE_DEFAULT);
}

public void setHomepage(string aHomepage) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString(mContext.getString(R.string.settings_key_homepage), aHomepage);
editor.commit();
}

public float getDisplayDensity() {
return mPrefs.getFloat(
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/non_L10n.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<resources>
<string name="app_name" translatable="false">Firefox Reality</string>
<string name="bug_report_url" translatable="false">mzl.la/fxr</string>
<string name="settings_key_homepage" translatable="false">https://webxr.today/</string>
<string name="settings_key_crash" translatable="false">settings_crash</string>
<string name="settings_key_locale" translatable="false">settings_locale</string>
<string name="settings_key_telemetry" translatable="false">settings_telemetry</string>
Expand Down

0 comments on commit 6f0bf44

Please sign in to comment.