~samwhited/oslp

18fb8dcaff1e30fefe1ca908c898ac5d6333b63c — Sam Whited 3 years ago fd506f5
Add popup about Conversations merger
M src/main/java/com/samwhited/opensharelocationplugin/activities/LocationActivity.java => src/main/java/com/samwhited/opensharelocationplugin/activities/LocationActivity.java +25 -0
@@ 3,6 3,7 @@ package com.samwhited.opensharelocationplugin.activities;
import android.Manifest;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;


@@ 11,11 12,13 @@ import android.graphics.BitmapFactory;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;


@@ 44,6 47,7 @@ import java.io.File;

public abstract class LocationActivity extends AppCompatActivity implements LocationListener {
    public static final String PREF_SHOW_PUBLIC_TRANSPORT = "pref_show_public_transport";
    public static final String PREF_SHOW_UPDATE_MESSAGE = "pref_show_update_message";
    public static final int REQUEST_CODE_CREATE = 0;
    public static final int REQUEST_CODE_FAB_PRESSED = 1;
    public static final int REQUEST_CODE_SNACKBAR_PRESSED = 2;


@@ 127,6 131,27 @@ public abstract class LocationActivity extends AppCompatActivity implements Loca
    }

    @Override
    protected void onStart() {
        super.onStart();

        final SharedPreferences prefs = getPreferences();
        if (prefs.getBoolean(PREF_SHOW_UPDATE_MESSAGE, true)) {
            new AlertDialog.Builder(this)
                    .setMessage(R.string.merge_dialog)
                    .setPositiveButton(R.string.buy_me_a_coffee, (dialog, id) -> {
                        Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.buymeacoffee.com/samwhited"));
                        startActivity(browserIntent);
                    })
                    .setNeutralButton(R.string.liberapay, (dialog, id) -> {
                        Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://liberapay.com/SamWhited"));
                        startActivity(browserIntent);
                    })
                    .create().show();
            prefs.edit().putBoolean(PREF_SHOW_UPDATE_MESSAGE, false).apply();
        }
    }

    @Override
    protected void onSaveInstanceState(@NonNull final Bundle outState) {
        super.onSaveInstanceState(outState);


M src/main/res/values/strings.xml => src/main/res/values/strings.xml +8 -0
@@ 26,6 26,14 @@
        <item>Topographic Map</item>
    </string-array>

    <string name="liberapay">Donate on Liberapay</string>
    <string name="buy_me_a_coffee">Buy me a coffee</string>
    <string name="merge_dialog">
        This plugin has been merged into Conversations 2.3!
        After you have updated Conversations you may wish to uninstall this plugin and use the built in version.
        If this plugin has been useful to you, please consider buying me a coffee!
    </string>

    <string name="about_text" translatable="false">
      <b>Open Show Location Plugin</b> for Conversations
      \nCopyright © 2015, Sam Whited\n