some improvements
This commit is contained in:
parent
35c8715a77
commit
2450f19ba2
|
@ -14,6 +14,7 @@
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
package fr.gouv.etalab.mastodon.activities;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
|
@ -50,9 +51,12 @@ import android.text.style.UnderlineSpan;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -67,6 +71,7 @@ import java.util.Iterator;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import es.dmoral.toasty.Toasty;
|
||||
import fr.gouv.etalab.mastodon.R;
|
||||
|
@ -1011,6 +1016,8 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
final boolean isOwner = account.getId().equals(userId);
|
||||
String[] splitAcct = account.getAcct().split("@");
|
||||
|
||||
if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON)
|
||||
popup.getMenu().findItem(R.id.action_filter).setVisible(true);
|
||||
if( splitAcct.length <= 1) {
|
||||
popup.getMenu().findItem(R.id.action_follow_instance).setVisible(false);
|
||||
popup.getMenu().findItem(R.id.action_block_instance).setVisible(false);
|
||||
|
@ -1130,6 +1137,41 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
}
|
||||
}).start();
|
||||
return true;
|
||||
case R.id.action_filter:
|
||||
AlertDialog.Builder filterTagDialog = new AlertDialog.Builder(ShowAccountActivity.this, style);
|
||||
Set<String> featuredTagsSet = sharedpreferences.getStringSet(Helper.SET_FEATURED_TAGS, null);
|
||||
List<String> tags = new ArrayList<>();
|
||||
if( featuredTagsSet != null){
|
||||
tags = new ArrayList<>(featuredTagsSet);
|
||||
}
|
||||
tags.add(0,getString(R.string.no_tags));
|
||||
String[] tagsString = tags.toArray(new String[tags.size()]);
|
||||
List<String> finalTags = tags;
|
||||
String tag = sharedpreferences.getString(Helper.SET_FEATURED_TAG_ACTION, null);
|
||||
int checkedposition = 0;
|
||||
int i = 0;
|
||||
for(String _t: tags){
|
||||
if( tag != null && _t.equals(tag))
|
||||
checkedposition = i;
|
||||
i++;
|
||||
}
|
||||
filterTagDialog.setSingleChoiceItems(tagsString, checkedposition, new DialogInterface
|
||||
.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int item) {
|
||||
String tag;
|
||||
if( item == 0){
|
||||
tag = null;
|
||||
}else {
|
||||
tag = finalTags.get(item);
|
||||
}
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(Helper.SET_FEATURED_TAG_ACTION, tag);
|
||||
editor.apply();
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
filterTagDialog.show();
|
||||
return true;
|
||||
case R.id.action_endorse:
|
||||
if( relationship != null)
|
||||
if(relationship.isEndorsed()){
|
||||
|
|
|
@ -549,17 +549,10 @@ public class API {
|
|||
params.put("pinned", Boolean.toString(true));
|
||||
params.put("exclude_replies", Boolean.toString(exclude_replies));
|
||||
params.put("limit", String.valueOf(limit));
|
||||
if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON){
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
Set<String> featuredTagsSet = sharedpreferences.getStringSet(Helper.SET_FEATURED_TAGS, null);
|
||||
if( featuredTagsSet != null && featuredTagsSet.size() > 0){
|
||||
List<String> tags = new ArrayList<>(featuredTagsSet);
|
||||
StringBuilder parameters = new StringBuilder();
|
||||
for(String tag: tags)
|
||||
parameters.append("tagged[]=").append(tag).append("&");
|
||||
parameters = new StringBuilder(parameters.substring(0, parameters.length() - 1).substring(9));
|
||||
params.put("tagged[]", parameters.toString());
|
||||
}
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String tag = sharedpreferences.getString(Helper.SET_FEATURED_TAG_ACTION, null);
|
||||
if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON && tag != null){
|
||||
params.put("tagged", tag);
|
||||
}
|
||||
statuses = new ArrayList<>();
|
||||
try {
|
||||
|
|
|
@ -305,6 +305,7 @@ public class Helper {
|
|||
public static final String SET_NOTIFICATION_ACTION = "set_notification_action";
|
||||
public static final String SET_DISPLAY_CONTENT_AFTER_FM = "set_display_content_after_fm";
|
||||
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 int S_NO = 0;
|
||||
static final int S_512KO = 1;
|
||||
public static final int S_1MO = 2;
|
||||
|
|
|
@ -26,6 +26,11 @@
|
|||
android:title="@string/more_action_7"
|
||||
android:icon="@drawable/ic_chat_bubble_outline"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_filter"
|
||||
android:visible="false"
|
||||
android:title="@string/filter_timeline_with_a_tag"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_hide_boost"
|
||||
android:title="@string/hide_boost"
|
||||
|
|
|
@ -899,6 +899,8 @@
|
|||
<string name="submit">Submit</string>
|
||||
<string name="data_base_exported">The data base has been exported!</string>
|
||||
<string name="featured_hashtags">Featured hashtags</string>
|
||||
<string name="filter_timeline_with_a_tag">Filter timeline with tags</string>
|
||||
<string name="no_tags">No tags</string>
|
||||
<!-- end languages -->
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue