Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #1179 - Supported adding custom region using deep-links #1182

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions onebusaway-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">

<permission
android:name="${applicationId}.permission.TRIP_SERVICE"
Expand Down Expand Up @@ -203,7 +204,19 @@
<!-- ActionBarCompat library doesn't have an ActionBarPreferenceActivity, so define parent here-->
<activity
android:name="org.onebusaway.android.ui.PreferencesActivity"
android:parentActivityName="org.onebusaway.android.ui.HomeActivity">
android:parentActivityName="org.onebusaway.android.ui.HomeActivity"
android:exported="true"
tools:ignore="ExportedPreferenceActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

android:host="add-region"
android:scheme="onebusaway" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.onebusaway.android.ui.HomeActivity"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ public void onCreate(Bundle savedInstanceState) {
if (showCheckRegionDialog) {
showCheckRegionDialog();
}

onAddCustomRegion();
}

@Override
Expand Down Expand Up @@ -526,7 +528,7 @@ protected void onDestroy() {
boolean currentValue = settings
.getBoolean(getString(R.string.preference_key_auto_select_region), true);

//If the use has selected to auto-select region, and the previous state of the setting was false,
//If the use has selected to auto-select region, and the previous state of the setting was false,
//then run the auto-select by going to HomeFragment
if ((currentValue && !mAutoSelectInitialValue)) {
Log.d(TAG,
Expand Down Expand Up @@ -679,4 +681,27 @@ public void onRegionTaskFinished(boolean currentRegionChanged) {
NavHelp.goHome(this, false);
}
}

/**
* The function will process deep links used for adding custom regions
*/
void onAddCustomRegion(){
Uri deepLink = getIntent().getData();
if (deepLink != null) {
amrhossamdev marked this conversation as resolved.
Show resolved Hide resolved
String obaCustomUrl = deepLink.getQueryParameter("oba-url");
String otpCustomURl = deepLink.getQueryParameter("otp-url");

// onPreferenceChange is responsible for checking changes if it's valid
if(obaCustomUrl != null && onPreferenceChange(mCustomApiUrlPref,obaCustomUrl)){
Application.get().setCustomApiUrl(obaCustomUrl);
}

if(otpCustomURl != null && onPreferenceChange(mCustomOtpApiUrlPref,otpCustomURl)){
Application.get().setCustomOtpApiUrl(otpCustomURl);
}
Intent i = new Intent(this,HomeActivity.class);
startActivity(i);
finish();
}
}
}
Loading