Search in sources :

Example 1 with ProviderApp

use of de.bahnhoefe.deutschlands.bahnhofsfotos.model.ProviderApp in project RSAndroidApp by RailwayStations.

the class DetailsActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    final int itemId = item.getItemId();
    if (itemId == R.id.nav_to_station) {
        startNavigation(DetailsActivity.this);
    } else if (itemId == R.id.timetable) {
        final Intent timetableIntent = new Timetable().createTimetableIntent(Country.getCountryByCode(countries, station.getCountry()), station);
        if (timetableIntent != null) {
            startActivity(timetableIntent);
        } else {
            Toast.makeText(this, R.string.timetable_missing, Toast.LENGTH_LONG).show();
        }
    } else if (itemId == R.id.share_photo) {
        final Intent shareIntent = createFotoSendIntent();
        shareIntent.putExtra(Intent.EXTRA_TEXT, Country.getCountryByCode(countries, station != null ? station.getCountry() : null).getTwitterTags() + " " + binding.details.etbahnhofname.getText());
        shareIntent.setType("image/jpeg");
        startActivity(createChooser(shareIntent, "send"));
    } else if (itemId == R.id.station_info) {
        showStationInfo(null);
    } else if (itemId == R.id.provider_android_app) {
        final List<ProviderApp> providerApps = Country.getCountryByCode(countries, station.getCountry()).getCompatibleProviderApps();
        if (providerApps.size() == 1) {
            providerApps.get(0).openAppOrPlayStore(this);
        } else if (providerApps.size() > 1) {
            final CharSequence[] appNames = providerApps.stream().map(ProviderApp::getName).toArray(CharSequence[]::new);
            new SimpleDialogs().simpleSelect(this, getResources().getString(R.string.choose_provider_app), appNames, (dialog, which) -> {
                if (which >= 0 && providerApps.size() > which) {
                    providerApps.get(which).openAppOrPlayStore(DetailsActivity.this);
                }
            });
        } else {
            Toast.makeText(this, R.string.provider_app_missing, Toast.LENGTH_LONG).show();
        }
    } else if (itemId == android.R.id.home) {
        navigateUp();
    } else {
        return super.onOptionsItemSelected(item);
    }
    return true;
}
Also used : ImageButton(android.widget.ImageButton) Timetable(de.bahnhoefe.deutschlands.bahnhofsfotos.util.Timetable) CheckedInputStream(java.util.zip.CheckedInputStream) Bundle(android.os.Bundle) ParcelFileDescriptor(android.os.ParcelFileDescriptor) ActivityDetailsBinding(de.bahnhoefe.deutschlands.bahnhofsfotos.databinding.ActivityDetailsBinding) PackageManager(android.content.pm.PackageManager) InboxResponse(de.bahnhoefe.deutschlands.bahnhofsfotos.model.InboxResponse) ProblemType(de.bahnhoefe.deutschlands.bahnhofsfotos.model.ProblemType) NonNull(androidx.annotation.NonNull) BitmapCache(de.bahnhoefe.deutschlands.bahnhofsfotos.util.BitmapCache) Uri(android.net.Uri) LinkMovementMethod(android.text.method.LinkMovementMethod) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) StringUtils(org.apache.commons.lang3.StringUtils) ConnectionUtil(de.bahnhoefe.deutschlands.bahnhofsfotos.util.ConnectionUtil) Gson(com.google.gson.Gson) Locale(java.util.Locale) MediaStore(android.provider.MediaStore) ContextThemeWrapper(android.view.ContextThemeWrapper) View(android.view.View) ContextCompat(androidx.core.content.ContextCompat) Log(android.util.Log) MediaType(okhttp3.MediaType) Station(de.bahnhoefe.deutschlands.bahnhofsfotos.model.Station) NavUtils(androidx.core.app.NavUtils) DbAdapter(de.bahnhoefe.deutschlands.bahnhofsfotos.db.DbAdapter) ProviderApp(de.bahnhoefe.deutschlands.bahnhofsfotos.model.ProviderApp) Set(java.util.Set) StationInfoBinding(de.bahnhoefe.deutschlands.bahnhofsfotos.databinding.StationInfoBinding) UploadBinding(de.bahnhoefe.deutschlands.bahnhofsfotos.databinding.UploadBinding) PorterDuff(android.graphics.PorterDuff) ViewGroup(android.view.ViewGroup) FileNotFoundException(java.io.FileNotFoundException) StandardCharsets(java.nio.charset.StandardCharsets) Objects(java.util.Objects) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) ListAdapter(android.widget.ListAdapter) RSAPIClient(de.bahnhoefe.deutschlands.bahnhofsfotos.rsapi.RSAPIClient) ActivityNotFoundException(android.content.ActivityNotFoundException) Html(android.text.Html) ActivityResultContracts(androidx.activity.result.contract.ActivityResultContracts) FileProvider(androidx.core.content.FileProvider) Constants(de.bahnhoefe.deutschlands.bahnhofsfotos.util.Constants) EditorInfo(android.view.inputmethod.EditorInfo) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Call(retrofit2.Call) Context(android.content.Context) AlertDialog(androidx.appcompat.app.AlertDialog) FileUtils(de.bahnhoefe.deutschlands.bahnhofsfotos.util.FileUtils) Intent(android.content.Intent) BitmapFactory(android.graphics.BitmapFactory) ProblemReport(de.bahnhoefe.deutschlands.bahnhofsfotos.model.ProblemReport) KeyValueSpinnerItem(de.bahnhoefe.deutschlands.bahnhofsfotos.util.KeyValueSpinnerItem) Response(retrofit2.Response) Intent.createChooser(android.content.Intent.createChooser) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) RequestBody(okhttp3.RequestBody) InboxStateQuery(de.bahnhoefe.deutschlands.bahnhofsfotos.model.InboxStateQuery) Country(de.bahnhoefe.deutschlands.bahnhofsfotos.model.Country) URLConnection(java.net.URLConnection) Toast(android.widget.Toast) Menu(android.view.Menu) BitmapAvailableHandler(de.bahnhoefe.deutschlands.bahnhofsfotos.util.BitmapAvailableHandler) ActionBar(android.app.ActionBar) TaskStackBuilder(android.app.TaskStackBuilder) NavItem(de.bahnhoefe.deutschlands.bahnhofsfotos.util.NavItem) ActivityResultLauncher(androidx.activity.result.ActivityResultLauncher) ComponentName(android.content.ComponentName) ActivityCompat(androidx.core.app.ActivityCompat) FileOutputStream(java.io.FileOutputStream) Point(android.graphics.Point) TextUtils(android.text.TextUtils) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) WHITE(android.graphics.Color.WHITE) File(java.io.File) Color(android.graphics.Color) ArrayAdapter(android.widget.ArrayAdapter) URLEncoder(java.net.URLEncoder) Callback(retrofit2.Callback) ReportProblemBinding(de.bahnhoefe.deutschlands.bahnhofsfotos.databinding.ReportProblemBinding) Bitmap(android.graphics.Bitmap) Upload(de.bahnhoefe.deutschlands.bahnhofsfotos.model.Upload) SimpleDialogs(de.bahnhoefe.deutschlands.bahnhofsfotos.dialogs.SimpleDialogs) CRC32(java.util.zip.CRC32) Activity(android.app.Activity) ValueAnimator(android.animation.ValueAnimator) Timetable(de.bahnhoefe.deutschlands.bahnhofsfotos.util.Timetable) SimpleDialogs(de.bahnhoefe.deutschlands.bahnhofsfotos.dialogs.SimpleDialogs) Intent(android.content.Intent) ProviderApp(de.bahnhoefe.deutschlands.bahnhofsfotos.model.ProviderApp) Point(android.graphics.Point)

Aggregations

ValueAnimator (android.animation.ValueAnimator)1 ActionBar (android.app.ActionBar)1 Activity (android.app.Activity)1 TaskStackBuilder (android.app.TaskStackBuilder)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 ComponentName (android.content.ComponentName)1 Context (android.content.Context)1 Intent (android.content.Intent)1 Intent.createChooser (android.content.Intent.createChooser)1 PackageManager (android.content.pm.PackageManager)1 Bitmap (android.graphics.Bitmap)1 BitmapFactory (android.graphics.BitmapFactory)1 Color (android.graphics.Color)1 WHITE (android.graphics.Color.WHITE)1 Point (android.graphics.Point)1 PorterDuff (android.graphics.PorterDuff)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 ParcelFileDescriptor (android.os.ParcelFileDescriptor)1 MediaStore (android.provider.MediaStore)1