mirror of
https://github.com/gsantner/dandelion
synced 2024-11-22 04:12:08 +01:00
removed ShareActivity, moved sharing code to MainActivity, made adding shared-by-notice toggleable
This commit is contained in:
parent
1a0e295aeb
commit
08e2849a36
8 changed files with 108 additions and 401 deletions
|
@ -42,27 +42,6 @@
|
||||||
android:label="@string/pref_title__personal_settings">
|
android:label="@string/pref_title__personal_settings">
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name="com.github.dfa.diaspora_android.activity.ShareActivity"
|
|
||||||
android:launchMode="singleInstance"
|
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
|
||||||
android:label="@string/new_post"
|
|
||||||
android:theme="@style/AppTheme.NoActionBar"
|
|
||||||
android:screenOrientation="portrait" >
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.SEND" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<data android:mimeType="text/plain" />
|
|
||||||
</intent-filter>
|
|
||||||
|
|
||||||
<!-- //TODO Handle single image being sent
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.SEND_MULTIPLE" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<data android:mimeType="image/*" />
|
|
||||||
</intent-filter>-->
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name="com.github.dfa.diaspora_android.task.GetPodsService"
|
android:name="com.github.dfa.diaspora_android.task.GetPodsService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
|
@ -76,6 +55,12 @@
|
||||||
android:theme="@style/AppTheme.NoActionBar"
|
android:theme="@style/AppTheme.NoActionBar"
|
||||||
android:label="@string/diaspora">
|
android:label="@string/diaspora">
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.SEND" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:mimeType="text/plain" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
<!-- Intent from Web Browser / Mail / IM / Clickable Link -->
|
<!-- Intent from Web Browser / Mail / IM / Clickable Link -->
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
|
|
@ -69,6 +69,7 @@ import android.webkit.ValueCallback;
|
||||||
import android.webkit.WebChromeClient;
|
import android.webkit.WebChromeClient;
|
||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
@ -381,7 +382,6 @@ public class MainActivity extends AppCompatActivity
|
||||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
|
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
|
||||||
|
|
||||||
startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);
|
startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -447,6 +447,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
|
String type = intent.getType();
|
||||||
String loadUrl = null;
|
String loadUrl = null;
|
||||||
|
|
||||||
|
|
||||||
|
@ -459,6 +460,20 @@ public class MainActivity extends AppCompatActivity
|
||||||
Helpers.animateToActivity(MainActivity.this, PodSelectionActivity.class, true);
|
Helpers.animateToActivity(MainActivity.this, PodSelectionActivity.class, true);
|
||||||
} else if (ACTION_CLEAR_CACHE.equals(action)) {
|
} else if (ACTION_CLEAR_CACHE.equals(action)) {
|
||||||
webView.clearCache(true);
|
webView.clearCache(true);
|
||||||
|
} else if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||||
|
switch (type) {
|
||||||
|
case "text/plain":
|
||||||
|
if (intent.hasExtra(Intent.EXTRA_SUBJECT)) {
|
||||||
|
handleSendSubject(intent);
|
||||||
|
} else {
|
||||||
|
handleSendText(intent);}
|
||||||
|
break;
|
||||||
|
case "image/*":
|
||||||
|
handleSendImage(intent); //TODO: Add intent filter to Manifest and implement method
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
|
||||||
|
//TODO: Implement and add filter to manifest
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loadUrl != null) {
|
if (loadUrl != null) {
|
||||||
|
@ -539,10 +554,8 @@ public class MainActivity extends AppCompatActivity
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
String url = intent.getStringExtra(EXTRA_URL);
|
String url = intent.getStringExtra(EXTRA_URL);
|
||||||
// Log.d(App.TAG, "BroadcastReceiver: Received setTitleIntent: "+url);
|
|
||||||
if (url != null && url.startsWith("https://" + podDomain)) {
|
if (url != null && url.startsWith("https://" + podDomain)) {
|
||||||
String subUrl = url.substring(("https://" + podDomain).length());
|
String subUrl = url.substring(("https://" + podDomain).length());
|
||||||
//Log.d(App.TAG, "LocalBroadcastReceiver: SubUrl: "+subUrl); // Spams!
|
|
||||||
if (subUrl.startsWith("/stream")) {
|
if (subUrl.startsWith("/stream")) {
|
||||||
setTitle(R.string.title_stream);
|
setTitle(R.string.title_stream);
|
||||||
} else if (subUrl.startsWith("/posts/")) {
|
} else if (subUrl.startsWith("/posts/")) {
|
||||||
|
@ -831,6 +844,77 @@ public class MainActivity extends AppCompatActivity
|
||||||
app.getAvatarImageLoader().startImageDownload(navheaderImage, avatarUrl);
|
app.getAvatarImageLoader().startImageDownload(navheaderImage, avatarUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleSendText(Intent intent) {
|
||||||
|
webView.loadUrl("https://"+podDomain+"/status_messages/new");
|
||||||
|
String content = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||||
|
if(appSettings.isAppendSharedViaApp()) {
|
||||||
|
//TODO: Make \n work
|
||||||
|
content = content + " \n" +getString(R.string.shared_by_diaspora_android);
|
||||||
|
}
|
||||||
|
final String sharedText = content;
|
||||||
|
if (sharedText != null) {
|
||||||
|
webView.setWebViewClient(new WebViewClient() {
|
||||||
|
public void onPageFinished(WebView view, String url) {
|
||||||
|
webView.loadUrl("javascript:(function() { " +
|
||||||
|
"document.getElementsByTagName('textarea')[0].style.height='110px'; " +
|
||||||
|
"document.getElementsByTagName('textarea')[0].innerHTML = '" + sharedText + "'; " +
|
||||||
|
" if(document.getElementById(\"main_nav\")) {" +
|
||||||
|
" document.getElementById(\"main_nav\").parentNode.removeChild(" +
|
||||||
|
" document.getElementById(\"main_nav\"));" +
|
||||||
|
" } else if (document.getElementById(\"main-nav\")) {" +
|
||||||
|
" document.getElementById(\"main-nav\").parentNode.removeChild(" +
|
||||||
|
" document.getElementById(\"main-nav\"));" +
|
||||||
|
" }" +
|
||||||
|
"})();");
|
||||||
|
webView.setWebViewClient(webViewClient);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle sent text + subject
|
||||||
|
* @param intent
|
||||||
|
*/
|
||||||
|
void handleSendSubject(Intent intent) {
|
||||||
|
webView.loadUrl("https://"+podDomain+"/status_messages/new");
|
||||||
|
String content = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||||
|
final String sharedSubject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
|
||||||
|
if (appSettings.isAppendSharedViaApp()) {
|
||||||
|
//TODO: Make \n work
|
||||||
|
content = content + " \n" + getString(R.string.shared_by_diaspora_android);
|
||||||
|
}
|
||||||
|
final String sharedText = content;
|
||||||
|
if (sharedSubject != null) {
|
||||||
|
webView.setWebViewClient(new WebViewClient() {
|
||||||
|
|
||||||
|
public void onPageFinished(WebView view, String url) {
|
||||||
|
webView.loadUrl("javascript:(function() { " +
|
||||||
|
"document.getElementsByTagName('textarea')[0].style.height='110px'; " +
|
||||||
|
"document.getElementsByTagName('textarea')[0].innerHTML = '**" + sharedSubject + "** " + sharedText + "'; " +
|
||||||
|
" if(document.getElementById(\"main_nav\")) {" +
|
||||||
|
" document.getElementById(\"main_nav\").parentNode.removeChild(" +
|
||||||
|
" document.getElementById(\"main_nav\"));" +
|
||||||
|
" } else if (document.getElementById(\"main-nav\")) {" +
|
||||||
|
" document.getElementById(\"main-nav\").parentNode.removeChild(" +
|
||||||
|
" document.getElementById(\"main-nav\"));" +
|
||||||
|
" }" +
|
||||||
|
"})();");
|
||||||
|
webView.setWebViewClient(webViewClient);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Implement?
|
||||||
|
private void handleSendImage(Intent intent) {
|
||||||
|
final Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||||
|
if (imageUri != null) {
|
||||||
|
// Update UI to reflect text being shared
|
||||||
|
}
|
||||||
|
Toast.makeText(this, "Not yet implemented.", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Move from Javascript interface
|
// TODO: Move from Javascript interface
|
||||||
@Override
|
@Override
|
||||||
public void onNotificationCountChanged(int notificationCount) {
|
public void onNotificationCountChanged(int notificationCount) {
|
||||||
|
|
|
@ -1,374 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of the Diaspora for Android.
|
|
||||||
|
|
||||||
Diaspora for Android is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Diaspora for Android is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with the Diaspora for Android.
|
|
||||||
|
|
||||||
If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.github.dfa.diaspora_android.activity;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.provider.MediaStore;
|
|
||||||
import android.support.design.widget.Snackbar;
|
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
import android.webkit.ValueCallback;
|
|
||||||
import android.webkit.WebChromeClient;
|
|
||||||
import android.webkit.WebSettings;
|
|
||||||
import android.webkit.WebView;
|
|
||||||
import android.webkit.WebViewClient;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
|
|
||||||
import com.github.dfa.diaspora_android.App;
|
|
||||||
import com.github.dfa.diaspora_android.R;
|
|
||||||
import com.github.dfa.diaspora_android.util.Helpers;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class ShareActivity extends MainActivity {
|
|
||||||
|
|
||||||
private static final String TAG = "Diaspora Share";
|
|
||||||
private WebView webView;
|
|
||||||
private String podDomain;
|
|
||||||
private ValueCallback<Uri[]> mFilePathCallback;
|
|
||||||
private String mCameraPhotoPath;
|
|
||||||
private ProgressBar progressBar;
|
|
||||||
private SwipeRefreshLayout swipeView;
|
|
||||||
|
|
||||||
@SuppressLint("SetJavaScriptEnabled")
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
setContentView(R.layout.main__activity);
|
|
||||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
if (toolbar != null) {
|
|
||||||
toolbar.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (Helpers.isOnline(ShareActivity.this)) {
|
|
||||||
Intent intent = new Intent(ShareActivity.this, MainActivity.class);
|
|
||||||
startActivityForResult(intent, 100);
|
|
||||||
overridePendingTransition(0, 0);
|
|
||||||
finish();
|
|
||||||
} else {
|
|
||||||
Snackbar.make(swipeView, R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
setTitle(R.string.new_post);
|
|
||||||
|
|
||||||
progressBar = (ProgressBar) findViewById(R.id.progressBar);
|
|
||||||
|
|
||||||
swipeView = (SwipeRefreshLayout) findViewById(R.id.swipe);
|
|
||||||
swipeView.setEnabled(false);
|
|
||||||
|
|
||||||
podDomain = ((App) getApplication()).getSettings().getPodDomain();
|
|
||||||
|
|
||||||
webView = (WebView) findViewById(R.id.webView);
|
|
||||||
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
|
|
||||||
|
|
||||||
WebSettings wSettings = webView.getSettings();
|
|
||||||
wSettings.setJavaScriptEnabled(true);
|
|
||||||
wSettings.setBuiltInZoomControls(true);
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 21)
|
|
||||||
wSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* WebViewClient
|
|
||||||
*/
|
|
||||||
webView.setWebViewClient(new WebViewClient() {
|
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
|
||||||
Log.d(TAG, url);
|
|
||||||
if (!url.contains(podDomain)) {
|
|
||||||
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
|
||||||
startActivity(i);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onPageFinished(WebView view, String url) {
|
|
||||||
Log.i(TAG, "Finished loading URL: " + url);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* WebChromeClient
|
|
||||||
*/
|
|
||||||
webView.setWebChromeClient(new WebChromeClient() {
|
|
||||||
|
|
||||||
public void onProgressChanged(WebView wv, int progress) {
|
|
||||||
progressBar.setProgress(progress);
|
|
||||||
|
|
||||||
if (progress > 0 && progress <= 60) {
|
|
||||||
Helpers.getNotificationCount(wv);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (progress > 60) {
|
|
||||||
Helpers.applyDiasporaMobileSiteChanges(wv);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (progress == 100) {
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
|
|
||||||
if (mFilePathCallback != null) mFilePathCallback.onReceiveValue(null);
|
|
||||||
|
|
||||||
mFilePathCallback = filePathCallback;
|
|
||||||
|
|
||||||
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
|
||||||
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
|
|
||||||
// Create the File where the photo should go
|
|
||||||
File photoFile = null;
|
|
||||||
try {
|
|
||||||
photoFile = createImageFile();
|
|
||||||
takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
// Error occurred while creating the File
|
|
||||||
Snackbar.make(getWindow().findViewById(R.id.main__layout), "Unable to get image", Snackbar.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Continue only if the File was successfully created
|
|
||||||
if (photoFile != null) {
|
|
||||||
mCameraPhotoPath = "file:" + photoFile.getAbsolutePath();
|
|
||||||
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
|
|
||||||
Uri.fromFile(photoFile));
|
|
||||||
} else {
|
|
||||||
takePictureIntent = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
||||||
contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
||||||
contentSelectionIntent.setType("image/*");
|
|
||||||
|
|
||||||
Intent[] intentArray;
|
|
||||||
if (takePictureIntent != null) {
|
|
||||||
intentArray = new Intent[]{takePictureIntent};
|
|
||||||
} else {
|
|
||||||
intentArray = new Intent[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
|
|
||||||
chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
|
|
||||||
chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser");
|
|
||||||
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
|
|
||||||
|
|
||||||
startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
|
||||||
if (Helpers.isOnline(ShareActivity.this)) {
|
|
||||||
webView.loadUrl("https://" + podDomain + "/status_messages/new");
|
|
||||||
} else {
|
|
||||||
Snackbar.make(getWindow().findViewById(R.id.main__layout), R.string.no_internet, Snackbar.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Intent intent = getIntent();
|
|
||||||
String action = intent.getAction();
|
|
||||||
String type = intent.getType();
|
|
||||||
|
|
||||||
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
|
||||||
if ("text/plain".equals(type)) {
|
|
||||||
if (intent.hasExtra(Intent.EXTRA_SUBJECT)) {
|
|
||||||
handleSendSubject(intent);
|
|
||||||
} else {
|
|
||||||
handleSendText(intent);}
|
|
||||||
} else if (type.startsWith("image/")) {
|
|
||||||
// TODO Handle single image being sent -> see manifest
|
|
||||||
handleSendImage(intent);
|
|
||||||
}
|
|
||||||
//} else {
|
|
||||||
// Handle other intents, such as being started from the home screen
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleSendText(Intent intent) {
|
|
||||||
final String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
|
||||||
final String sharedBy = getString(R.string.shared_by_diaspora_android);
|
|
||||||
|
|
||||||
if (sharedText != null) {
|
|
||||||
webView.setWebViewClient(new WebViewClient() {
|
|
||||||
|
|
||||||
public void onPageFinished(WebView view, String url) {
|
|
||||||
|
|
||||||
webView.setWebViewClient(new WebViewClient() {
|
|
||||||
@Override
|
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
|
||||||
|
|
||||||
finish();
|
|
||||||
|
|
||||||
Intent i = new Intent(ShareActivity.this, MainActivity.class);
|
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
startActivity(i);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
webView.loadUrl("javascript:(function() { " +
|
|
||||||
"document.getElementsByTagName('textarea')[0].style.height='110px'; " +
|
|
||||||
"document.getElementsByTagName('textarea')[0].innerHTML = '> " + sharedText + " " + sharedBy + "'; " +
|
|
||||||
" if(document.getElementById(\"main_nav\")) {" +
|
|
||||||
" document.getElementById(\"main_nav\").parentNode.removeChild(" +
|
|
||||||
" document.getElementById(\"main_nav\"));" +
|
|
||||||
" } else if (document.getElementById(\"main-nav\")) {" +
|
|
||||||
" document.getElementById(\"main-nav\").parentNode.removeChild(" +
|
|
||||||
" document.getElementById(\"main-nav\"));" +
|
|
||||||
" }" +
|
|
||||||
"})();");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleSendSubject(Intent intent) {
|
|
||||||
final String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
|
||||||
final String sharedSubject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
|
|
||||||
final String sharedBy = getString(R.string.shared_by_diaspora_android);
|
|
||||||
if (sharedSubject != null) {
|
|
||||||
webView.setWebViewClient(new WebViewClient() {
|
|
||||||
|
|
||||||
public void onPageFinished(WebView view, String url) {
|
|
||||||
|
|
||||||
webView.setWebViewClient(new WebViewClient() {
|
|
||||||
@Override
|
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
|
||||||
|
|
||||||
finish();
|
|
||||||
|
|
||||||
Intent i = new Intent(ShareActivity.this, MainActivity.class);
|
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
startActivity(i);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
webView.loadUrl("javascript:(function() { " +
|
|
||||||
"document.getElementsByTagName('textarea')[0].style.height='110px'; " +
|
|
||||||
"document.getElementsByTagName('textarea')[0].innerHTML = '**" + sharedSubject + "** " + sharedText + " " + sharedBy + "'; " +
|
|
||||||
" if(document.getElementById(\"main_nav\")) {" +
|
|
||||||
" document.getElementById(\"main_nav\").parentNode.removeChild(" +
|
|
||||||
" document.getElementById(\"main_nav\"));" +
|
|
||||||
" } else if (document.getElementById(\"main-nav\")) {" +
|
|
||||||
" document.getElementById(\"main-nav\").parentNode.removeChild(" +
|
|
||||||
" document.getElementById(\"main-nav\"));" +
|
|
||||||
" }" +
|
|
||||||
"})();");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO Handle single image being sent -> see manifest
|
|
||||||
|
|
||||||
void handleSendImage(Intent intent) {
|
|
||||||
final Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
|
||||||
if (imageUri != null) {
|
|
||||||
// Update UI to reflect text being shared
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
||||||
if (requestCode != INPUT_FILE_REQUEST_CODE || mFilePathCallback == null) {
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Uri[] results = null;
|
|
||||||
if (resultCode == RESULT_OK) {
|
|
||||||
if (data == null) {
|
|
||||||
if (mCameraPhotoPath != null) {
|
|
||||||
results = new Uri[]{Uri.parse(mCameraPhotoPath)};
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
String dataString = data.getDataString();
|
|
||||||
if (dataString != null) {
|
|
||||||
results = new Uri[]{Uri.parse(dataString)};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mFilePathCallback.onReceiveValue(results);
|
|
||||||
mFilePathCallback = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private File createImageFile() throws IOException {
|
|
||||||
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
|
|
||||||
String imageFileName = "JPEG_" + timeStamp + "_";
|
|
||||||
File storageDir = Environment.getExternalStoragePublicDirectory(
|
|
||||||
Environment.DIRECTORY_PICTURES);
|
|
||||||
return File.createTempFile(
|
|
||||||
imageFileName, /* prefix */
|
|
||||||
".jpg", /* suffix */
|
|
||||||
storageDir /* directory */
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
if (webView.canGoBack()) {
|
|
||||||
webView.goBack();
|
|
||||||
setTitle(R.string.app_name);
|
|
||||||
Snackbar snackbar = Snackbar
|
|
||||||
.make(swipeView, R.string.confirm_exit, Snackbar.LENGTH_LONG)
|
|
||||||
.setAction(android.R.string.yes, new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
snackbar.show();
|
|
||||||
} else {
|
|
||||||
Snackbar snackbar = Snackbar
|
|
||||||
.make(swipeView, R.string.confirm_exit, Snackbar.LENGTH_LONG)
|
|
||||||
.setAction(android.R.string.yes, new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
snackbar.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -174,6 +174,10 @@ public class AppSettings {
|
||||||
setStringArray(prefPod, R.string.pref_key__podprofile_followed_tags, tags);
|
setStringArray(prefPod, R.string.pref_key__podprofile_followed_tags, tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAppendSharedViaApp() {
|
||||||
|
return getBoolean(prefApp, R.string.pref_key__append_shared_via_app, true);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("CommitPrefEdits")
|
@SuppressLint("CommitPrefEdits")
|
||||||
public void setProxyEnabled(boolean enabled) {
|
public void setProxyEnabled(boolean enabled) {
|
||||||
//commit instead of apply because the app is likely to be killed before apply is called.
|
//commit instead of apply because the app is likely to be killed before apply is called.
|
||||||
|
|
|
@ -33,12 +33,10 @@ import android.net.Uri;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.github.dfa.diaspora_android.App;
|
|
||||||
import com.github.dfa.diaspora_android.R;
|
import com.github.dfa.diaspora_android.R;
|
||||||
import com.github.dfa.diaspora_android.activity.MainActivity;
|
import com.github.dfa.diaspora_android.activity.MainActivity;
|
||||||
import com.github.dfa.diaspora_android.task.ImageDownloadTask;
|
import com.github.dfa.diaspora_android.task.ImageDownloadTask;
|
||||||
|
|
|
@ -44,4 +44,6 @@
|
||||||
<string name="pref_title__intellihide_toolbars">Toolbars intelligent verstecken</string>
|
<string name="pref_title__intellihide_toolbars">Toolbars intelligent verstecken</string>
|
||||||
<string name="pref_desc__intellihide_toolbars">Obere und untere Toolbar verstecken während des Scrollens von Inhalt</string>
|
<string name="pref_desc__intellihide_toolbars">Obere und untere Toolbar verstecken während des Scrollens von Inhalt</string>
|
||||||
|
|
||||||
|
<string name="pref_title__append_shared_via_app">Verweise auf App</string>
|
||||||
|
<string name="pref_desc__append_shared_via_app">Füge beim Teilen von Texten Verweis auf diese App an ("geteilt durch…")</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<string name="pref_catkey__network" translatable="false">pref_key_category_network</string>
|
<string name="pref_catkey__network" translatable="false">pref_key_category_network</string>
|
||||||
<string name="pref_key__load_images" translatable="false">pref_key_load_images</string>
|
<string name="pref_key__load_images" translatable="false">pref_key_load_images</string>
|
||||||
<string name="pref_key__clear_cache" translatable="false">pref_key_clear_cache</string>
|
<string name="pref_key__clear_cache" translatable="false">pref_key_clear_cache</string>
|
||||||
|
<string name="pref_key__append_shared_via_app" translatable="false">pref_key_append_shared_via_app</string>
|
||||||
<string name="pref_key__proxy_enabled" translatable="false">pref_key_proxy_enabled</string>
|
<string name="pref_key__proxy_enabled" translatable="false">pref_key_proxy_enabled</string>
|
||||||
<string name="pref_key__proxy_host" translatable="false">pref_key_proxy_host</string>
|
<string name="pref_key__proxy_host" translatable="false">pref_key_proxy_host</string>
|
||||||
<string name="pref_key__proxy_port" translatable="false">pref_key_proxy_port</string>
|
<string name="pref_key__proxy_port" translatable="false">pref_key_proxy_port</string>
|
||||||
|
@ -81,4 +81,6 @@
|
||||||
<string name="pref_desc__intellihide_toolbars" translatable="false">Hide top and bottom toolbars automatically while scrolling</string>
|
<string name="pref_desc__intellihide_toolbars" translatable="false">Hide top and bottom toolbars automatically while scrolling</string>
|
||||||
<string name="pref_title__intellihide_toolbars">Intellihide Toolbars</string>
|
<string name="pref_title__intellihide_toolbars">Intellihide Toolbars</string>
|
||||||
|
|
||||||
|
<string name="pref_title__append_shared_via_app">Append shared-by-notice</string>
|
||||||
|
<string name="pref_desc__append_shared_via_app">Append a reference to this app ("shared by…") to shared texts</string>
|
||||||
</resources>
|
</resources>
|
|
@ -18,6 +18,12 @@
|
||||||
android:summary="@string/pref_desc__intellihide_toolbars"
|
android:summary="@string/pref_desc__intellihide_toolbars"
|
||||||
android:title="@string/pref_title__intellihide_toolbars"/>
|
android:title="@string/pref_title__intellihide_toolbars"/>
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="@string/pref_key__append_shared_via_app"
|
||||||
|
android:summary="@string/pref_desc__append_shared_via_app"
|
||||||
|
android:title="@string/pref_title__append_shared_via_app"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<!-- Diaspora Pod Settings -->
|
<!-- Diaspora Pod Settings -->
|
||||||
|
|
Loading…
Reference in a new issue