0
0
mirror of https://github.com/mediathekview/zapp.git synced 2024-09-20 04:12:14 +02:00

Fix crash when url intent cannot be handled

For example on android tv devices without browser installed
This commit is contained in:
Christine Emrich 2017-07-27 13:09:06 +02:00
parent 9b69da4ca6
commit 373b9d306a
5 changed files with 69 additions and 6 deletions

View File

@ -1,6 +1,41 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="JavaDoc" enabled="false" level="WARNING" enabled_by_default="false">
<option name="TOP_LEVEL_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="INNER_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="METHOD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="@return@throws or @exception" />
</value>
</option>
<option name="FIELD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="IGNORE_DEPRECATED" value="false" />
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
<option name="myAdditionalJavadocTags" value="" />
</inspection_tool>
<inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
<option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
<option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />
</inspection_tool>
<inspection_tool class="SameParameterValue" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />

View File

@ -1,8 +1,6 @@
package de.christinecoenen.code.zapp.app.mediathek.ui.detail;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
@ -15,6 +13,7 @@ import butterknife.ButterKnife;
import butterknife.OnClick;
import de.christinecoenen.code.zapp.R;
import de.christinecoenen.code.zapp.app.mediathek.model.MediathekShow;
import de.christinecoenen.code.zapp.utils.system.IntentHelper;
public class MediathekDetailFragment extends Fragment {
@ -87,7 +86,6 @@ public class MediathekDetailFragment extends Fragment {
@OnClick(R.id.btn_website)
protected void onWebsiteClick() {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(show.getWebsiteUrl()));
startActivity(browserIntent);
IntentHelper.openUrl(getContext(), show.getWebsiteUrl());
}
}

View File

@ -37,6 +37,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import de.christinecoenen.code.zapp.R;
import de.christinecoenen.code.zapp.app.mediathek.model.MediathekShow;
import de.christinecoenen.code.zapp.utils.system.IntentHelper;
import de.christinecoenen.code.zapp.utils.system.MultiWindowHelper;
import de.christinecoenen.code.zapp.utils.video.VideoBufferingHandler;
import de.christinecoenen.code.zapp.utils.video.VideoErrorHandler;
@ -196,8 +197,7 @@ public class MediathekPlayerActivity extends AppCompatActivity implements
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_share:
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(show.getVideoUrl()));
startActivity(browserIntent);
IntentHelper.openUrl(this, show.getVideoUrl());
return true;
case android.R.id.home:
finish();

View File

@ -0,0 +1,29 @@
package de.christinecoenen.code.zapp.utils.system;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.Toast;
import de.christinecoenen.code.zapp.R;
public class IntentHelper {
/**
* Open the given url in a new (external) activity. If no app is found
* that can handle this intent, a Toast is shown.
* @param context
* @param url
*/
public static void openUrl(Context context, String url) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
try {
context.startActivity(browserIntent);
} catch (ActivityNotFoundException e) {
Toast.makeText(context, R.string.error_no_app_for_link, Toast.LENGTH_LONG).show();
}
}
}

View File

@ -32,6 +32,7 @@
<string name="error_stream_unknown">Das Video kann wegen eines unbekannten Fehlers nicht wiedergegeben werden.</string>
<string name="error_stream_io">Das Video konnte nicht geladen werden. Vielleicht besteht keine Internet-Verbindung oder das Video ist in deinem Land nicht verfügbar.</string>
<string name="error_stream_unsupported">Das Video ist beschädigt oder das Format wird nicht unterstützt.</string>
<string name="error_no_app_for_link">Keine App zum Öffnen von Links gefunden.</string>
<string name="error_mediathek_info_not_available">Es gab einen Fehler beim Laden der Mediathek. Bitte prüfe deine Internet-Verbindung.</string>
<string name="error_mediathek_called_without_show">Fehler: Keine Sendung übergeben.</string>