Merged in develop (pull request #31)
This commit is contained in:
commit
d9c9f16cde
|
@ -7,8 +7,8 @@ android {
|
|||
applicationId "fr.gouv.etalab.mastodon"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 25
|
||||
versionCode 33
|
||||
versionName "1.3.6"
|
||||
versionCode 34
|
||||
versionName "1.3.7"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
|
Binary file not shown.
|
@ -38,7 +38,7 @@
|
|||
android:name="fr.gouv.etalab.mastodon.activities.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
android:windowSoftInputMode = "adjustResize"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:theme="@style/AppThemeDark_NoActionBar">
|
||||
<intent-filter>
|
||||
|
|
|
@ -29,6 +29,7 @@ import android.support.v4.app.FragmentManager;
|
|||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
|
@ -73,6 +74,7 @@ import fr.gouv.etalab.mastodon.fragments.TabLayoutSettingsFragment;
|
|||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
||||
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.CHANGE_THEME_INTENT;
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.HOME_TIMELINE_INTENT;
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION;
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.NOTIFICATION_INTENT;
|
||||
|
@ -81,6 +83,7 @@ import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
|
|||
import static fr.gouv.etalab.mastodon.helper.Helper.changeUser;
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.loadPPInActionBar;
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.menuAccounts;
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.unCheckAllMenuItems;
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.updateHeaderAccountInfo;
|
||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||
|
||||
|
@ -335,17 +338,7 @@ public class MainActivity extends AppCompatActivity
|
|||
}
|
||||
}
|
||||
|
||||
private void unCheckAllMenuItems(@NonNull final Menu menu) {
|
||||
int size = menu.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
final MenuItem item = menu.getItem(i);
|
||||
if(item.hasSubMenu()) {
|
||||
unCheckAllMenuItems(item.getSubMenu());
|
||||
} else {
|
||||
item.setChecked(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -369,25 +362,23 @@ public class MainActivity extends AppCompatActivity
|
|||
String userIdIntent;
|
||||
boolean matchingIntent = false;
|
||||
if( extras.containsKey(INTENT_ACTION) ){
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); //Id of the authenticated account
|
||||
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
userIdIntent = extras.getString(PREF_KEY_ID); //Id of the account in the intent
|
||||
if (extras.getInt(INTENT_ACTION) == NOTIFICATION_INTENT){
|
||||
if( userId!= null && !userId.equals(userIdIntent)) //Connected account is different from the id in the intent
|
||||
changeUser(MainActivity.this, userIdIntent); //Connects the account which is related to the notification
|
||||
unCheckAllMenuItems(navigationView.getMenu());
|
||||
navigationView.getMenu().performIdentifierAction(R.id.nav_notification, 0);
|
||||
if( navigationView.getMenu().findItem(R.id.nav_notification) != null)
|
||||
navigationView.getMenu().findItem(R.id.nav_notification).setChecked(true);
|
||||
changeUser(MainActivity.this, userIdIntent, false); //Connects the account which is related to the notification
|
||||
tabLayout.getTabAt(3).select();
|
||||
matchingIntent = true;
|
||||
}else if( extras.getInt(INTENT_ACTION) == HOME_TIMELINE_INTENT){
|
||||
if( userId!= null && !userId.equals(userIdIntent)) //Connected account is different from the id in the intent
|
||||
changeUser(MainActivity.this, userIdIntent); //Connects the account which is related to the notification
|
||||
unCheckAllMenuItems(navigationView.getMenu());
|
||||
navigationView.getMenu().performIdentifierAction(R.id.nav_home, 0);
|
||||
if( navigationView.getMenu().findItem(R.id.nav_home) != null)
|
||||
navigationView.getMenu().findItem(R.id.nav_home).setChecked(true);
|
||||
changeUser(MainActivity.this, userIdIntent, false); //Connects the account which is related to the notification
|
||||
tabLayout.getTabAt(0).select();
|
||||
matchingIntent = true;
|
||||
}else if( extras.getInt(INTENT_ACTION) == CHANGE_THEME_INTENT){
|
||||
unCheckAllMenuItems(navigationView.getMenu());
|
||||
navigationView.setCheckedItem(R.id.nav_settings);
|
||||
navigationView.getMenu().performIdentifierAction(R.id.nav_settings, 0);
|
||||
toolbarTitle.setText(R.string.settings);
|
||||
matchingIntent = true;
|
||||
}
|
||||
}else if( Intent.ACTION_SEND.equals(action) && type != null ){
|
||||
|
|
|
@ -298,11 +298,12 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
|||
account_ac.setVisibility(View.GONE);
|
||||
else
|
||||
account_ac.setText(account.getAcct());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
/*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
account_note.setText(Html.fromHtml(Helper.shortnameToUnicode(account.getNote(),true), Html.FROM_HTML_MODE_COMPACT));
|
||||
else
|
||||
//noinspection deprecation
|
||||
account_note.setText(Html.fromHtml(Helper.shortnameToUnicode(account.getNote(), true)));
|
||||
account_note.setText(Html.fromHtml(Helper.shortnameToUnicode(account.getNote(), true)));*/
|
||||
account_note = Helper.clickableElementsDescription(ShowAccountActivity.this, account_note,account.getNote());
|
||||
tabLayout.getTabAt(0).setText(getString(R.string.status_cnt, account.getStatuses_count()));
|
||||
tabLayout.getTabAt(1).setText(getString(R.string.following_cnt, account.getFollowing_count()));
|
||||
tabLayout.getTabAt(2).setText(getString(R.string.followers_cnt, account.getFollowers_count()));
|
||||
|
|
|
@ -43,6 +43,7 @@ import android.util.Log;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
|
@ -56,6 +57,7 @@ import android.widget.ImageButton;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
|
@ -121,7 +123,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
|||
private int maxChar;
|
||||
private String visibility;
|
||||
private final int PICK_IMAGE = 56556;
|
||||
private RelativeLayout loading_picture;
|
||||
private ProgressBar loading_picture;
|
||||
private ImageButton toot_picture;
|
||||
private ImageLoader imageLoader;
|
||||
private DisplayImageOptions options;
|
||||
|
@ -132,7 +134,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
|||
private Button toot_it;
|
||||
private EditText toot_content, toot_cw_content;
|
||||
private TextView toot_reply_content;
|
||||
private LinearLayout toot_reply_content_container;
|
||||
private RelativeLayout toot_reply_content_container;
|
||||
private RelativeLayout toot_show_accounts;
|
||||
private ListView toot_lv_accounts;
|
||||
private BroadcastReceiver search_validate;
|
||||
|
@ -144,8 +146,6 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
|||
private TextView title;
|
||||
private ImageView pp_actionBar;
|
||||
|
||||
private String pattern = "^.*(@([a-zA-Z0-9_]{2,}))$";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -190,12 +190,12 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
|||
final TextView toot_space_left = (TextView) findViewById(R.id.toot_space_left);
|
||||
toot_visibility = (ImageButton) findViewById(R.id.toot_visibility);
|
||||
toot_picture = (ImageButton) findViewById(R.id.toot_picture);
|
||||
loading_picture = (RelativeLayout) findViewById(R.id.loading_picture);
|
||||
loading_picture = (ProgressBar) findViewById(R.id.loading_picture);
|
||||
toot_picture_container = (LinearLayout) findViewById(R.id.toot_picture_container);
|
||||
toot_content = (EditText) findViewById(R.id.toot_content);
|
||||
toot_cw_content = (EditText) findViewById(R.id.toot_cw_content);
|
||||
toot_reply_content = (TextView) findViewById(R.id.toot_reply_content);
|
||||
toot_reply_content_container = (LinearLayout) findViewById(R.id.toot_reply_content_container);
|
||||
toot_reply_content_container = (RelativeLayout) findViewById(R.id.toot_reply_content_container);
|
||||
toot_show_accounts = (RelativeLayout) findViewById(R.id.toot_show_accounts);
|
||||
toot_lv_accounts = (ListView) findViewById(R.id.toot_lv_accounts);
|
||||
toot_sensitive = (CheckBox) findViewById(R.id.toot_sensitive);
|
||||
|
@ -406,7 +406,8 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
|||
|
||||
}
|
||||
});
|
||||
|
||||
String pattern = "^(.|\\s)*(@([a-zA-Z0-9_]{2,}))$";
|
||||
final Pattern sPattern = Pattern.compile(pattern);
|
||||
toot_content.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
|
@ -415,10 +416,16 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
|||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
Pattern sPattern = Pattern.compile(pattern);
|
||||
Matcher m = sPattern.matcher(s.toString());
|
||||
int length;
|
||||
//Only check last 20 characters to avoid lags
|
||||
if( s.toString().length() < 20 ){ //Less than 20 characters are written
|
||||
length = s.toString().length();
|
||||
}else {
|
||||
length = 20;
|
||||
}
|
||||
Matcher m = sPattern.matcher(s.toString().substring(s.toString().length()- length, s.toString().length()));
|
||||
if(m.matches()) {
|
||||
String search = m.group(2);
|
||||
String search = m.group(3);
|
||||
new RetrieveSearchAccountsAsyncTask(getApplicationContext(),search,TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}else{
|
||||
toot_show_accounts.setVisibility(View.GONE);
|
||||
|
@ -434,6 +441,21 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
|||
toot_space_left.setText(String.valueOf((maxChar - totalChar)));
|
||||
}
|
||||
});
|
||||
//Allow scroll of the EditText though it's embedded in a scrollview
|
||||
toot_content.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (v.getId() == R.id.toot_content) {
|
||||
v.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
switch (event.getAction() & MotionEvent.ACTION_MASK) {
|
||||
case MotionEvent.ACTION_UP:
|
||||
v.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
toot_cw_content.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
|
|
|
@ -16,14 +16,17 @@ package fr.gouv.etalab.mastodon.activities;
|
|||
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -119,17 +122,30 @@ public class WebviewActivity extends AppCompatActivity {
|
|||
webView.loadUrl(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.main_webview, menu);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
case R.id.action_go:
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
startActivity(browserIntent);
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void setUrl(String newUrl){
|
||||
this.url = newUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy(){
|
||||
super.onDestroy();
|
||||
|
|
|
@ -210,9 +210,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
public void onClick(View v) {
|
||||
try {
|
||||
if( !status.isTranslated() ){
|
||||
//new YandexQuery(StatusListAdapter.this).getYandexTextview(position, status.getContent(), currentLocale);
|
||||
new YandexQuery(StatusListAdapter.this).getYandexTextview(position, status.getContent(), currentLocale);
|
||||
|
||||
}else {
|
||||
status.setTranslationShown(!status.isTranslationShown());
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
|
@ -272,7 +270,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
changeDrawableColor(context, R.drawable.ic_translate,R.color.black);
|
||||
}
|
||||
|
||||
|
||||
//Redraws top icons (boost/reply)
|
||||
final float scale = context.getResources().getDisplayMetrics().density;
|
||||
if( !status.getIn_reply_to_account_id().equals("null") || !status.getIn_reply_to_id().equals("null") ){
|
||||
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_reply);
|
||||
|
@ -286,7 +284,6 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
holder.status_account_displayname.setCompoundDrawables( null, null, null, null);
|
||||
}
|
||||
|
||||
|
||||
//Click on a conversation
|
||||
if( type != RetrieveFeedsAsyncTask.Type.CONTEXT ){
|
||||
holder.status_content.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -355,13 +352,11 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
|
|||
|
||||
|
||||
holder.status_content = Helper.clickableElements(context, holder.status_content,content,
|
||||
status.getReblog() != null?status.getReblog().getMentions():status.getMentions(),
|
||||
status.getReblog() != null?status.getReblog().getTags():status.getTags());
|
||||
status.getReblog() != null?status.getReblog().getMentions():status.getMentions());
|
||||
|
||||
if( status.getContent_translated() != null && status.getContent_translated().length() > 0){
|
||||
holder.status_content_translated = Helper.clickableElements(context, holder.status_content_translated,status.getContent_translated(),
|
||||
status.getReblog() != null?status.getReblog().getMentions():status.getMentions(),
|
||||
status.getReblog() != null?status.getReblog().getTags():status.getTags());
|
||||
status.getReblog() != null?status.getReblog().getMentions():status.getMentions());
|
||||
}
|
||||
holder.status_favorite_count.setText(String.valueOf(status.getFavourites_count()));
|
||||
holder.status_reblog_count.setText(String.valueOf(status.getReblogs_count()));
|
||||
|
|
|
@ -36,10 +36,15 @@ import android.widget.CheckBox;
|
|||
import android.widget.CompoundButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import fr.gouv.etalab.mastodon.activities.MainActivity;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.CHANGE_THEME_INTENT;
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.HOME_TIMELINE_INTENT;
|
||||
import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -201,6 +206,10 @@ public class SettingsFragment extends Fragment {
|
|||
getActivity().setTheme(R.style.AppTheme);
|
||||
}
|
||||
getActivity().recreate();
|
||||
Intent intent = new Intent(context, MainActivity.class);
|
||||
intent.putExtra(INTENT_ACTION, CHANGE_THEME_INTENT);
|
||||
startActivity(intent);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ import android.os.AsyncTask;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.NotificationManagerCompat;
|
||||
|
@ -56,6 +57,7 @@ import android.text.method.LinkMovementMethod;
|
|||
import android.text.style.ClickableSpan;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.SubMenu;
|
||||
import android.view.View;
|
||||
|
@ -168,7 +170,7 @@ public class Helper {
|
|||
//Notifications
|
||||
public static final int NOTIFICATION_INTENT = 1;
|
||||
public static final int HOME_TIMELINE_INTENT = 2;
|
||||
|
||||
public static final int CHANGE_THEME_INTENT = 3;
|
||||
//Settings
|
||||
public static final String SET_TOOTS_PER_PAGE = "set_toots_per_page";
|
||||
public static final String SET_ACCOUNTS_PER_PAGE = "set_accounts_per_page";
|
||||
|
@ -225,11 +227,10 @@ public class Helper {
|
|||
private static final Pattern SHORTNAME_PATTERN = Pattern.compile(":([-+\\w]+):");
|
||||
|
||||
private static final Pattern urlPattern = Pattern.compile(
|
||||
"(?:^|[\\W])((ht|f)tp(s?):\\/\\/|www\\.)"
|
||||
+ "(([\\w\\-]+\\.){1,}?([\\w\\-.~]+\\/?)*"
|
||||
+ "[\\p{Alnum}.,%_=?&#\\-+()\\[\\]\\*$~@!:/{};']*)",
|
||||
"(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
|
||||
private static final Pattern hashtagPattern = Pattern.compile("(#[\\w_À-ú-]{1,})");
|
||||
/**
|
||||
* Converts emojis in input to unicode
|
||||
* @param input String
|
||||
|
@ -776,7 +777,7 @@ public class Helper {
|
|||
menuAccountsOpened = false;
|
||||
String userId = account.getId();
|
||||
Toast.makeText(activity, activity.getString(R.string.toast_account_changed, "@" + account.getAcct() + "@" + account.getInstance()), Toast.LENGTH_LONG).show();
|
||||
changeUser(activity, userId);
|
||||
changeUser(activity, userId, true);
|
||||
arrow.setImageResource(R.drawable.ic_arrow_drop_down);
|
||||
return true;
|
||||
}
|
||||
|
@ -846,13 +847,15 @@ public class Helper {
|
|||
* @param activity Activity
|
||||
* @param userID String - the new user id
|
||||
*/
|
||||
public static void changeUser(Activity activity, String userID) {
|
||||
public static void changeUser(Activity activity, String userID, boolean checkItem) {
|
||||
|
||||
final NavigationView navigationView = (NavigationView) activity.findViewById(R.id.nav_view);
|
||||
navigationView.getMenu().clear();
|
||||
navigationView.inflateMenu(R.menu.activity_main_drawer);
|
||||
navigationView.setCheckedItem(R.id.nav_home);
|
||||
navigationView.getMenu().performIdentifierAction(R.id.nav_home, 0);
|
||||
if( checkItem ) {
|
||||
navigationView.setCheckedItem(R.id.nav_home);
|
||||
navigationView.getMenu().performIdentifierAction(R.id.nav_home, 0);
|
||||
}
|
||||
SQLiteDatabase db = Sqlite.getInstance(activity, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Account account = new AccountDAO(activity,db).getAccountByID(userID);
|
||||
//Can happen when an account has been deleted and there is a click on an old notification
|
||||
|
@ -1009,7 +1012,7 @@ public class Helper {
|
|||
* @param mentions List<Mention>
|
||||
* @return TextView
|
||||
*/
|
||||
public static TextView clickableElements(final Context context, TextView statusTV, String fullContent, List<Mention> mentions, List<Tag> tags) {
|
||||
public static TextView clickableElements(final Context context, TextView statusTV, String fullContent, List<Mention> mentions) {
|
||||
|
||||
SpannableString spannableString;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
|
@ -1074,36 +1077,94 @@ public class Helper {
|
|||
|
||||
}
|
||||
}
|
||||
//Deals with tags to make them clickable
|
||||
if( tags != null && tags.size() > 0 ) {
|
||||
//Looping through tags which are attached to the toot
|
||||
for (final Tag tag : tags) {
|
||||
String targetedTag = "#" + tag.getName();
|
||||
if (spannableString.toString().contains(targetedTag)) {
|
||||
|
||||
int startPosition = spannableString.toString().indexOf(targetedTag);
|
||||
int endPosition = spannableString.toString().lastIndexOf(targetedTag) + targetedTag.length();
|
||||
spannableString.setSpan(new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(View textView) {
|
||||
Intent intent = new Intent(context, HashTagActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("tag", tag.getName());
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
}
|
||||
},
|
||||
startPosition, endPosition,
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
|
||||
Matcher matcher = hashtagPattern.matcher(spannableString);
|
||||
while (matcher.find()){
|
||||
int matchStart = matcher.start(1);
|
||||
int matchEnd = matcher.end();
|
||||
final String tag = spannableString.toString().substring(matchStart, matchEnd);
|
||||
spannableString.setSpan(new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(View textView) {
|
||||
Intent intent = new Intent(context, HashTagActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("tag", tag.substring(1));
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
}
|
||||
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
statusTV.setText(spannableString, TextView.BufferType.SPANNABLE);
|
||||
statusTV.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
return statusTV;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Check if the account bio contents urls & tags and fills the content with ClickableSpan
|
||||
* Click on url => webview or external app
|
||||
* Click on tag => HashTagActivity
|
||||
* @param context Context
|
||||
* @param statusTV Textview
|
||||
* @param fullContent String, should be the st
|
||||
* @return TextView
|
||||
*/
|
||||
public static TextView clickableElementsDescription(final Context context, TextView statusTV, String fullContent) {
|
||||
|
||||
SpannableString spannableString;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
spannableString = new SpannableString(Html.fromHtml(fullContent, Html.FROM_HTML_MODE_COMPACT));
|
||||
else
|
||||
//noinspection deprecation
|
||||
spannableString = new SpannableString(Html.fromHtml(fullContent));
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
boolean embedded_browser = sharedpreferences.getBoolean(Helper.SET_EMBEDDED_BROWSER, true);
|
||||
if( embedded_browser){
|
||||
Matcher matcher = urlPattern.matcher(spannableString);
|
||||
while (matcher.find()){
|
||||
int matchStart = matcher.start(1);
|
||||
int matchEnd = matcher.end();
|
||||
final String url = spannableString.toString().substring(matchStart, matchEnd);
|
||||
spannableString.setSpan(new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(View textView) {
|
||||
Intent intent = new Intent(context, WebviewActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("url", url);
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
}
|
||||
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
}
|
||||
Matcher matcher = hashtagPattern.matcher(spannableString);
|
||||
while (matcher.find()){
|
||||
int matchStart = matcher.start(1);
|
||||
int matchEnd = matcher.end();
|
||||
final String tag = spannableString.toString().substring(matchStart, matchEnd);
|
||||
spannableString.setSpan(new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(View textView) {
|
||||
Intent intent = new Intent(context, HashTagActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putString("tag", tag.substring(1));
|
||||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
}
|
||||
}, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
statusTV.setText(spannableString, TextView.BufferType.SPANNABLE);
|
||||
statusTV.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
return statusTV;
|
||||
|
@ -1309,4 +1370,16 @@ public class Helper {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void unCheckAllMenuItems(@NonNull final Menu menu) {
|
||||
int size = menu.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
final MenuItem item = menu.getItem(i);
|
||||
if(item.hasSubMenu()) {
|
||||
unCheckAllMenuItems(item.getSubMenu());
|
||||
} else {
|
||||
item.setChecked(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ import android.view.View;
|
|||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.TextView;
|
||||
|
||||
import fr.gouv.etalab.mastodon.activities.WebviewActivity;
|
||||
import mastodon.etalab.gouv.fr.mastodon.R;
|
||||
|
||||
/**
|
||||
|
@ -57,7 +59,12 @@ public class MastalabWebViewClient extends WebViewClient {
|
|||
}else {
|
||||
activity.setTitle(url);
|
||||
}
|
||||
//Changes the url in webview activity so that it can be opened with an external app
|
||||
try{
|
||||
if( activity instanceof WebviewActivity)
|
||||
((WebviewActivity)activity).setUrl(url);
|
||||
}catch (Exception ignore){}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 487 B |
Binary file not shown.
After Width: | Height: | Size: 281 B |
Binary file not shown.
After Width: | Height: | Size: 339 B |
Binary file not shown.
After Width: | Height: | Size: 647 B |
Binary file not shown.
After Width: | Height: | Size: 985 B |
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
|
@ -15,178 +15,170 @@
|
|||
You should have received a copy of the GNU General Public License along with Thomas Schneider; if not,
|
||||
see <http://www.gnu.org/licenses>.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/drawer_layout"
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:fillViewport="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingBottom="20dp"
|
||||
android:paddingLeft="@dimen/toot_padding"
|
||||
android:paddingRight="@dimen/toot_padding"
|
||||
android:orientation="vertical">
|
||||
<EditText
|
||||
android:id="@+id/toot_cw_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:animateLayoutChanges="true"
|
||||
android:visibility="gone"
|
||||
android:maxLines="1"
|
||||
android:hint="@string/toot_cw_placeholder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
>
|
||||
<LinearLayout
|
||||
android:id="@+id/toot_reply_content_container"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingBottom="20dp"
|
||||
android:paddingLeft="@dimen/toot_padding"
|
||||
android:paddingRight="@dimen/toot_padding"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:text="@string/toot_reply_content_title"
|
||||
<EditText
|
||||
android:id="@+id/toot_cw_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:animateLayoutChanges="true"
|
||||
android:visibility="gone"
|
||||
android:maxLines="1"
|
||||
android:hint="@string/toot_cw_placeholder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<LinearLayout
|
||||
<RelativeLayout
|
||||
android:id="@+id/toot_reply_content_container"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/toot_reply_content_title"
|
||||
android:text="@string/toot_reply_content_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:layout_below="@+id/toot_reply_content_title"
|
||||
android:id="@+id/toot_reply_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="top|start"
|
||||
android:maxLines="4"
|
||||
android:textStyle="italic"
|
||||
android:autoLink="web"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:textSize="12sp"
|
||||
android:layout_marginEnd="40dp"
|
||||
android:layout_marginRight="40dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/toot_close_reply"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_gravity="center"
|
||||
app:fabSize="mini"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:layout_margin="5dp"
|
||||
app:srcCompat="@drawable/ic_close" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<EditText
|
||||
android:layout_marginTop="10dp"
|
||||
android:id="@+id/toot_content"
|
||||
android:gravity="top|start"
|
||||
android:hint="@string/toot_placeholder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="0dp" />
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<LinearLayout
|
||||
android:padding="5dp"
|
||||
android:id="@+id/toot_picture_container"
|
||||
android:layout_width="wrap_content"
|
||||
</RelativeLayout>
|
||||
<EditText
|
||||
android:layout_marginTop="10dp"
|
||||
android:id="@+id/toot_content"
|
||||
android:gravity="top|start"
|
||||
android:inputType="textMultiLine"
|
||||
android:hint="@string/toot_placeholder"
|
||||
android:layout_width="match_parent"
|
||||
android:minLines="4"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="0dp" />
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxHeight="100dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
<RelativeLayout
|
||||
android:id="@+id/loading_picture"
|
||||
android:visibility="gone"
|
||||
<LinearLayout
|
||||
android:padding="5dp"
|
||||
android:id="@+id/toot_picture_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:maxHeight="100dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
<ProgressBar
|
||||
android:id="@+id/pbar_inf"
|
||||
android:id="@+id/loading_picture"
|
||||
android:visibility="gone"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:indeterminate="true" />
|
||||
<TextView
|
||||
android:id="@+id/loader_progress"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone"
|
||||
android:layout_marginTop="10dp"
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:layout_below="@+id/pbar_inf"
|
||||
android:layout_width="50dp"
|
||||
android:gravity="center"
|
||||
android:layout_height="wrap_content" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</HorizontalScrollView>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_height="wrap_content">
|
||||
<RelativeLayout
|
||||
android:visibility="gone"
|
||||
android:id="@+id/toot_show_accounts"
|
||||
android:maxHeight="300dp"
|
||||
</LinearLayout>
|
||||
</HorizontalScrollView>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_height="wrap_content">
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/toot_close_accounts"
|
||||
<RelativeLayout
|
||||
android:visibility="gone"
|
||||
android:id="@+id/toot_show_accounts"
|
||||
android:maxHeight="300dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/toot_close_accounts"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_gravity="center"
|
||||
app:fabSize="mini"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
app:srcCompat="@drawable/ic_close" />
|
||||
<ListView
|
||||
android:id="@+id/toot_lv_accounts"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</RelativeLayout>
|
||||
<ImageButton
|
||||
android:id="@+id/toot_picture"
|
||||
android:padding="5dp"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:src="@drawable/ic_action_camera"
|
||||
/>
|
||||
<ImageButton
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:id="@+id/toot_visibility"
|
||||
android:padding="5dp"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:src="@drawable/ic_action_globe"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/toot_cw"
|
||||
android:padding="5dp"
|
||||
android:text="@string/cw"
|
||||
style="@style/Base.Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp" />
|
||||
<TextView
|
||||
android:id="@+id/toot_space_left"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center"
|
||||
app:fabSize="mini"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
app:srcCompat="@drawable/ic_close" />
|
||||
<ListView
|
||||
android:id="@+id/toot_lv_accounts"
|
||||
android:layout_height="40dp" />
|
||||
<Button
|
||||
android:id="@+id/toot_it"
|
||||
android:padding="5dp"
|
||||
android:text="@string/toot_it"
|
||||
android:layout_gravity="end"
|
||||
android:gravity="center"
|
||||
style="@style/Base.Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</RelativeLayout>
|
||||
<ImageButton
|
||||
android:id="@+id/toot_picture"
|
||||
android:padding="5dp"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:src="@drawable/ic_action_camera"
|
||||
/>
|
||||
<ImageButton
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:id="@+id/toot_visibility"
|
||||
android:padding="5dp"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:src="@drawable/ic_action_globe"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/toot_cw"
|
||||
android:padding="5dp"
|
||||
android:text="@string/cw"
|
||||
style="@style/Base.Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp" />
|
||||
<TextView
|
||||
android:id="@+id/toot_space_left"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center"
|
||||
android:layout_height="40dp" />
|
||||
<Button
|
||||
android:id="@+id/toot_it"
|
||||
android:padding="5dp"
|
||||
android:text="@string/toot_it"
|
||||
android:layout_gravity="end"
|
||||
android:gravity="center"
|
||||
style="@style/Base.Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
<CheckBox
|
||||
android:text="@string/toot_sensitive"
|
||||
android:visibility="gone"
|
||||
android:id="@+id/toot_sensitive"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
<CheckBox
|
||||
android:text="@string/toot_sensitive"
|
||||
android:visibility="gone"
|
||||
android:id="@+id/toot_sensitive"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
|
@ -170,6 +170,7 @@
|
|||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:id="@+id/status_content"
|
||||
android:textIsSelectable="true"
|
||||
android:layout_marginTop="10dp"
|
||||
android:autoLink="web"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_go"
|
||||
android:title="@string/open_with"
|
||||
android:icon="@drawable/ic_action_goright"
|
||||
app:showAsAction="always" />
|
||||
</menu>
|
|
@ -46,6 +46,7 @@
|
|||
<string name="schedule">Programmer</string>
|
||||
<string name="next">Suivant</string>
|
||||
<string name="previous">Précédent</string>
|
||||
<string name="open_with">Ouvrir avec</string>
|
||||
<!--- Menu -->
|
||||
<string name="home_menu">Accueil</string>
|
||||
<string name="local_menu">Fil public local</string>
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
|
||||
<string name="next">Next</string>
|
||||
<string name="previous">Previous</string>
|
||||
<string name="open_with">Open with</string>
|
||||
<!--- Menu -->
|
||||
<string name="home_menu">Home</string>
|
||||
<string name="local_menu">Local timeline</string>
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<item name="shapeBorder">@style/Shape.Light</item>
|
||||
<item name="imgbd">@style/Image.Border.Light</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowActionModeOverlay">true</item>
|
||||
<item name="popupOverlay">@style/AppTheme.PopupOverlay</item>
|
||||
</style>
|
||||
|
||||
|
@ -47,6 +48,7 @@
|
|||
<item name="headerbg">@style/Header.Dark</item>
|
||||
<item name="shapeBorder">@style/Shape.Dark</item>
|
||||
<item name="imgbd">@style/Image.Border.Dark</item>
|
||||
<item name="windowActionModeOverlay">true</item>
|
||||
<item name="popupOverlay">@style/AppThemeDark.PopupOverlay</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
</style>
|
||||
|
|
Loading…
Reference in New Issue