Add simple sharing to the app

This commit is contained in:
Peter Stuifzand 2018-02-24 21:43:25 +01:00
parent 7d4c8ea7b8
commit d0e9beef14
2 changed files with 21 additions and 0 deletions

View File

@ -33,6 +33,13 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
<data android:mimeType="image/*"/>
</intent-filter>
</activity>
<activity android:name=".eu.stuifzand.micropub.auth.WebSigninActivity" />
<activity android:name=".eu.stuifzand.micropub.auth.AuthenticationActivity" />

View File

@ -23,6 +23,7 @@ import android.widget.Toast;
import java.io.IOException;
import eu.stuifzand.micropub.databinding.ActivityMainBinding;
import okhttp3.HttpUrl;
public class MainActivity extends AppCompatActivity {
@ -37,6 +38,19 @@ public class MainActivity extends AppCompatActivity {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Intent intent = getIntent();
if (intent != null) {
String urlOrNote = intent.getStringExtra(Intent.EXTRA_TEXT);
if (urlOrNote != null) {
HttpUrl url = HttpUrl.parse(urlOrNote);
if (url != null) {
model.inReplyTo.set(urlOrNote);
} else {
model.content.set(urlOrNote);
}
}
}
// FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
// fab.setOnClickListener(new View.OnClickListener() {
// @Override