Merge branch 'develop' into 'develop'
add option for compose: user can disable retrieve metadata when URL from other app See merge request tom79/mastalab!2029
This commit is contained in:
commit
e93d024276
|
@ -55,6 +55,7 @@ import android.support.v7.widget.Toolbar;
|
|||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.util.Patterns;
|
||||
import android.util.SparseArray;
|
||||
import android.view.Gravity;
|
||||
|
@ -1908,6 +1909,8 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
String url = null;
|
||||
String sharedSubject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
|
||||
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
boolean shouldRetrieveMetaData = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE).getBoolean(Helper.SET_RETRIEVE_METADATA_IF_URL_FROM_EXTERAL, true);
|
||||
|
||||
if (sharedText != null) {
|
||||
/* Some apps don't send the URL as the first part of the EXTRA_TEXT,
|
||||
the BBC News app being one such, in this case find where the URL
|
||||
|
@ -1924,7 +1927,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
if(matchStart < matchEnd && sharedText.length() >= matchEnd)
|
||||
url = sharedText.substring(matchStart, matchEnd);
|
||||
}
|
||||
new RetrieveMetaDataAsyncTask(BaseMainActivity.this, sharedSubject, sharedText, url,BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
new RetrieveMetaDataAsyncTask(BaseMainActivity.this, shouldRetrieveMetaData, sharedSubject, sharedText, url,BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
} else if (type.startsWith("image/") || type.startsWith("video/")) {
|
||||
|
|
|
@ -975,7 +975,7 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
|
|||
if (extras != null && extras.getString("imageUri") != null) {
|
||||
Uri imageUri = Uri.parse(extras.getString("imageUri"));
|
||||
picture_scrollview.setVisibility(View.VISIBLE);
|
||||
if( imageUri == null) {
|
||||
if( imageUri == null) {
|
||||
Toasty.error(getApplicationContext(),getString(R.string.toot_select_image_error),Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -43,17 +43,25 @@ public class RetrieveMetaDataAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
private boolean error = false;
|
||||
private String image, title, description, sharedSubject, sharedText;
|
||||
private WeakReference<Context> contextWeakReference;
|
||||
|
||||
public RetrieveMetaDataAsyncTask(Context context, String sharedSubject, String sharedText,String url, OnRetrieveMetaDataInterface onRetrieveRemoteAccountInterface){
|
||||
private boolean shouldFetchMetaData = true;
|
||||
public RetrieveMetaDataAsyncTask(Context context,boolean shouldFetchMetaData, String sharedSubject, String sharedText,String url, OnRetrieveMetaDataInterface onRetrieveRemoteAccountInterface){
|
||||
this.url = url;
|
||||
this.listener = onRetrieveRemoteAccountInterface;
|
||||
this.sharedText = sharedText;
|
||||
this.sharedSubject = sharedSubject;
|
||||
this.contextWeakReference = new WeakReference<>(context);
|
||||
this.shouldFetchMetaData = shouldFetchMetaData;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
if(shouldFetchMetaData)
|
||||
return execRetrieveMetaDataInBackground();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
private Void execRetrieveMetaDataInBackground(){
|
||||
|
||||
String potentialUrl = "";
|
||||
if (url == null) {
|
||||
error = true;
|
||||
|
@ -118,7 +126,6 @@ public class RetrieveMetaDataAsyncTask extends AsyncTask<Void, Void, Void> {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
listener.onRetrieveMetaData(error, sharedSubject, sharedText, image, title, description);
|
||||
|
|
|
@ -625,6 +625,7 @@ public class SettingsFragment extends Fragment {
|
|||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
int truncate_toots_size = sharedpreferences.getInt(Helper.SET_TRUNCATE_TOOTS_SIZE, 0);
|
||||
SeekBar set_truncate_size = rootView.findViewById(R.id.set_truncate_size);
|
||||
set_truncate_size.setMax(20);
|
||||
|
@ -735,6 +736,20 @@ public class SettingsFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
// retrieve metadata if URL from external apps when composing
|
||||
boolean should_retrieve_metadata = sharedpreferences.getBoolean(Helper.SET_RETRIEVE_METADATA_IF_URL_FROM_EXTERAL, true);
|
||||
final CheckBox set_retrieve_metadata = rootView.findViewById(R.id.set_retrieve_metadata_share_from_extras);
|
||||
set_retrieve_metadata.setChecked(should_retrieve_metadata);
|
||||
|
||||
set_retrieve_metadata.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(Helper.SET_RETRIEVE_METADATA_IF_URL_FROM_EXTERAL, set_retrieve_metadata.isChecked());
|
||||
editor.apply();
|
||||
}
|
||||
});
|
||||
|
||||
// Custom Sharing
|
||||
final EditText edit_custom_sharing_url = rootView.findViewById(R.id.custom_sharing_url);
|
||||
boolean custom_sharing = sharedpreferences.getBoolean(Helper.SET_CUSTOM_SHARING, false);
|
||||
|
|
|
@ -308,6 +308,7 @@ public class Helper {
|
|||
public static final String SET_FEATURED_TAGS ="set_featured_tags";
|
||||
public static final String SET_FEATURED_TAG_ACTION ="set_featured_tag_action";
|
||||
public static final String SET_HIDE_DELETE_BUTTON_ON_TAB = "set_hide_delete_notification_on_tab";
|
||||
public static final String SET_RETRIEVE_METADATA_IF_URL_FROM_EXTERAL = "set_retrieve_metadata_share_from_extras";
|
||||
public static final int S_NO = 0;
|
||||
static final int S_512KO = 1;
|
||||
public static final int S_1MO = 2;
|
||||
|
|
|
@ -378,6 +378,15 @@
|
|||
android:text="@string/set_share_details"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<!-- RETRIEVE METADATA -->
|
||||
<CheckBox
|
||||
android:id="@+id/set_retrieve_metadata_share_from_extras"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginTop="@dimen/settings_checkbox_margin"
|
||||
android:layout_marginBottom="@dimen/settings_checkbox_margin"
|
||||
android:text="@string/set_retrieve_metadata_share_from_extras"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<!-- CUSTOM SHARING -->
|
||||
<CheckBox
|
||||
android:id="@+id/set_custom_sharing"
|
||||
|
|
|
@ -902,6 +902,7 @@
|
|||
<string name="filter_timeline_with_a_tag">Filter timeline with tags</string>
|
||||
<string name="no_tags">No tags</string>
|
||||
<string name="set_hide_delete_notification_on_tab">Hide delete notifcation button on notification tab</string>
|
||||
<string name="set_retrieve_metadata_share_from_extras">Retrieve metadata if URL that share from other apps</string>
|
||||
<!-- end languages -->
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue