mirror of
https://github.com/gsantner/dandelion
synced 2024-11-22 12:22:08 +01:00
Small changes, wanna pull
This commit is contained in:
parent
3c6558df9c
commit
b3498a6c2e
2 changed files with 8 additions and 7 deletions
|
@ -506,7 +506,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
registerReceiver(brLoadUrl, new IntentFilter(URL_MESSAGE));
|
//registerReceiver(brLoadUrl, new IntentFilter(URL_MESSAGE));
|
||||||
LocalBroadcastManager.getInstance(this).registerReceiver(brSetTitle, new IntentFilter(ACTION_UPDATE_TITLE_FROM_URL));
|
LocalBroadcastManager.getInstance(this).registerReceiver(brSetTitle, new IntentFilter(ACTION_UPDATE_TITLE_FROM_URL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,7 +571,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
unregisterReceiver(brLoadUrl);
|
//unregisterReceiver(brLoadUrl);
|
||||||
LocalBroadcastManager.getInstance(this).unregisterReceiver(brSetTitle);
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(brSetTitle);
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ import com.github.dfa.diaspora_android.activity.MainActivity;
|
||||||
import com.github.dfa.diaspora_android.task.ImageDownloadTask;
|
import com.github.dfa.diaspora_android.task.ImageDownloadTask;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.sql.Time;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclass of WebView which adds a context menu for long clicks on images or links to share, save
|
* Subclass of WebView which adds a context menu for long clicks on images or links to share, save
|
||||||
|
@ -112,7 +113,7 @@ public class ContextMenuWebView extends NestedWebView {
|
||||||
Uri source = Uri.parse(url);
|
Uri source = Uri.parse(url);
|
||||||
DownloadManager.Request request = new DownloadManager.Request(source);
|
DownloadManager.Request request = new DownloadManager.Request(source);
|
||||||
File destinationFile = new File(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora/"
|
File destinationFile = new File(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora/"
|
||||||
+ source.getLastPathSegment());
|
+ System.currentTimeMillis()+".png");
|
||||||
request.setDestinationUri(Uri.fromFile(destinationFile));
|
request.setDestinationUri(Uri.fromFile(destinationFile));
|
||||||
((DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);
|
((DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);
|
||||||
Toast.makeText(context, context.getText(R.string.toast_saved_image_to_location) + " " +
|
Toast.makeText(context, context.getText(R.string.toast_saved_image_to_location) + " " +
|
||||||
|
@ -124,15 +125,15 @@ public class ContextMenuWebView extends NestedWebView {
|
||||||
|
|
||||||
case ID_SHARE_IMAGE:
|
case ID_SHARE_IMAGE:
|
||||||
if(url != null) {
|
if(url != null) {
|
||||||
final Uri source = Uri.parse(url);
|
final Uri local = Uri.parse(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora/"+System.currentTimeMillis()+".png");
|
||||||
final Uri local = Uri.parse(Environment.getExternalStorageDirectory() + "/Pictures/Diaspora/"+source.getLastPathSegment());
|
|
||||||
new ImageDownloadTask(null, local.getPath()) {
|
new ImageDownloadTask(null, local.getPath()) {
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Bitmap result) {
|
protected void onPostExecute(Bitmap result) {
|
||||||
Uri myUri= Uri.fromFile(new File(local.getPath()));
|
Uri myUri= Uri.fromFile(new File(local.getPath()));
|
||||||
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
|
Intent sharingIntent = new Intent();
|
||||||
sharingIntent.setType("image/*");
|
sharingIntent.setAction(Intent.ACTION_SEND);
|
||||||
sharingIntent.putExtra(Intent.EXTRA_STREAM, myUri);
|
sharingIntent.putExtra(Intent.EXTRA_STREAM, myUri);
|
||||||
|
sharingIntent.setType("image/png");
|
||||||
sharingIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
sharingIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
context.startActivity(Intent.createChooser(sharingIntent, "Share image using"));
|
context.startActivity(Intent.createChooser(sharingIntent, "Share image using"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue