Merge remote-tracking branch 'origin/develop' into l10n_crowdin_localization

# Conflicts:
#	app/src/main/res/values-nl/strings.xml
This commit is contained in:
stom79 2017-12-17 11:44:17 +01:00
commit 20be445e2b
47 changed files with 208 additions and 53 deletions

View File

@ -7,8 +7,8 @@ android {
applicationId "fr.gouv.etalab.mastodon"
minSdkVersion 15
targetSdkVersion 27
versionCode 90
versionName "1.6.7-rc-1"
versionCode 93
versionName "1.6.7.2"
}
flavorDimensions "default"

View File

@ -179,6 +179,7 @@
android:theme="@style/Base.V7.Theme.AppCompat.Dialog"
android:excludeFromRecents="true"/>
<activity android:name=".activities.ManageAccountsInListActivity"
android:windowSoftInputMode="adjustPan"
android:theme="@style/Base.V7.Theme.AppCompat.Dialog"
android:excludeFromRecents="true"/>
</application>

View File

@ -34,7 +34,6 @@ import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
@ -197,6 +196,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
return;
}
set_profile_name.setText(account.getDisplay_name());
set_profile_name.setSelection(set_profile_name.getText().length());
final String content;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)

View File

@ -91,6 +91,8 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsAccountInterface;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRelationshipInterface;
import fr.gouv.etalab.mastodon.client.Entities.Relationship;
import static fr.gouv.etalab.mastodon.helper.Helper.THEME_DARK;
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
import static fr.gouv.etalab.mastodon.helper.Helper.withSuffix;
@ -494,6 +496,24 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
startActivity(intent);
}
});
//This account was moved to another one
if( account.getMoved_to_account() != null){
TextView account_moved = findViewById(R.id.account_moved);
account_moved.setVisibility(View.VISIBLE);
if( theme == THEME_DARK)
changeDrawableColor(ShowAccountActivity.this, R.drawable.ic_card_travel,R.color.dark_icon);
else
changeDrawableColor(ShowAccountActivity.this, R.drawable.ic_card_travel,R.color.black);
Drawable imgTravel = ContextCompat.getDrawable(ShowAccountActivity.this, R.drawable.ic_card_travel);
assert imgTravel != null;
imgTravel.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (20 * scale + 0.5f));
account_moved.setCompoundDrawables(imgTravel, null, null, null);
//Retrieves content and make account names clickable
SpannableString spannableString = account.moveToText(ShowAccountActivity.this);
account_moved.setText(spannableString, TextView.BufferType.SPANNABLE);
account_moved.setMovementMethod(LinkMovementMethod.getInstance());
}
if( account.getAcct().contains("@") )
warning_message.setVisibility(View.VISIBLE);
else

View File

@ -134,18 +134,36 @@ public class API {
HashMap<String, String> requestParams = new HashMap<>();
if( display_name != null)
requestParams.put("display_name",display_name);
try {
requestParams.put("display_name",URLEncoder.encode(display_name, "UTF-8"));
} catch (UnsupportedEncodingException e) {
requestParams.put("display_name",display_name);
}
if( note != null)
requestParams.put("note",note);
try {
requestParams.put("note",URLEncoder.encode(note, "UTF-8"));
} catch (UnsupportedEncodingException e) {
requestParams.put("note",note);
}
if( avatar != null)
requestParams.put("avatar",avatar);
try {
requestParams.put("avatar",URLEncoder.encode(avatar, "UTF-8"));
} catch (UnsupportedEncodingException e) {
requestParams.put("avatar",avatar);
}
if( header != null)
requestParams.put("header",header);
try {
requestParams.put("header",URLEncoder.encode(header, "UTF-8"));
} catch (UnsupportedEncodingException e) {
requestParams.put("header",header);
}
try {
new HttpsConnection().patch(getAbsoluteUrl("/accounts/update_credentials"), 60, requestParams, prefKeyOauthTokenT);
} catch (HttpsConnection.HttpsConnectionException e) {
e.printStackTrace();
setError(e.getStatusCode(), e);
}catch (Exception e) {
e.printStackTrace();
setDefaultError();
}
return apiResponse;
@ -1718,6 +1736,7 @@ public class API {
* @param resobj JSONObject
* @return Account
*/
@SuppressWarnings("InfiniteRecursion")
private static Account parseAccountResponse(Context context, JSONObject resobj){
Account account = new Account();
@ -1732,6 +1751,9 @@ public class API {
account.setFollowing_count(Integer.valueOf(resobj.get("following_count").toString()));
account.setStatuses_count(Integer.valueOf(resobj.get("statuses_count").toString()));
account.setNote(resobj.get("note").toString());
try{
account.setMoved_to_account(parseAccountResponse(context, resobj.getJSONObject("moved")));
}catch (Exception ignored){ignored.printStackTrace();}
account.setUrl(resobj.get("url").toString());
account.setAvatar(resobj.get("avatar").toString());
account.setAvatar_static(resobj.get("avatar_static").toString());

View File

@ -14,12 +14,22 @@
* see <http://www.gnu.org/licenses>. */
package fr.gouv.etalab.mastodon.client.Entities;
import android.content.*;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.view.View;
import java.io.Serializable;
import java.util.Date;
import fr.gouv.etalab.mastodon.R;
import fr.gouv.etalab.mastodon.activities.ShowAccountActivity;
/**
* Created by Thomas on 23/04/2017.
* Manage accounts
@ -50,6 +60,8 @@ public class Account implements Parcelable {
private boolean isFollowing;
private followAction followType = followAction.NOTHING;
private boolean isMakingAction = false;
private Account moved_to_account;
public followAction getFollowType() {
return followType;
@ -67,6 +79,14 @@ public class Account implements Parcelable {
isMakingAction = makingAction;
}
public Account getMoved_to_account() {
return moved_to_account;
}
public void setMoved_to_account(Account moved_to_account) {
this.moved_to_account = moved_to_account;
}
public enum followAction{
FOLLOW,
NOT_FOLLOW,
@ -83,6 +103,7 @@ public class Account implements Parcelable {
acct = in.readString();
display_name = in.readString();
locked = in.readByte() != 0;
moved_to_account = in.readParcelable(Account.class.getClassLoader());
followers_count = in.readInt();
following_count = in.readInt();
statuses_count = in.readInt();
@ -257,6 +278,7 @@ public class Account implements Parcelable {
dest.writeString(username);
dest.writeString(acct);
dest.writeString(display_name);
dest.writeParcelable(moved_to_account, flags);
dest.writeByte((byte) (locked ? 1 : 0));
dest.writeInt(followers_count);
dest.writeInt(following_count);
@ -302,4 +324,36 @@ public class Account implements Parcelable {
public void setStatuses_count_str(String statuses_count_str) {
this.statuses_count_str = statuses_count_str;
}
/**
* Makes the move to account clickable
* @param context Context
* @return SpannableString
*/
public SpannableString moveToText(final android.content.Context context){
SpannableString spannableString = null;
if( this.getMoved_to_account() != null) {
spannableString = new SpannableString(context.getString(R.string.account_moved_to, this.getAcct(), "@"+this.getMoved_to_account().getAcct()));
int startPositionTar = spannableString.toString().indexOf("@"+this.getMoved_to_account().getAcct());
int endPositionTar = startPositionTar + ("@"+this.getMoved_to_account().getAcct()).length();
final String idTar = this.getMoved_to_account().getId();
spannableString.setSpan(new ClickableSpan() {
@Override
public void onClick(View textView) {
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putString("accountId", idTar);
intent.putExtras(b);
context.startActivity(intent);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
}
},
startPositionTar, endPositionTar,
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
return spannableString;
}
}

View File

@ -17,10 +17,12 @@ public class Version implements Comparable<Version> {
public Version(String version) {
if(version == null)
version = "2.0";
version = "2.1";
if( version.endsWith("."))
version = version.substring(0, version.length() - 1);
version = version.replaceAll("[^\\d.]", "");
if(!version.matches("[0-9]+(\\.[0-9]+)*"))
version = "2.0";
version = "2.1";
this.version = version;
}

View File

@ -89,13 +89,6 @@ public class AccountsInAListAdapter extends RecyclerView.Adapter implements OnLi
//Profile picture
Helper.loadGiF(context, account.getAvatar(), holder.account_pp);
//Follow button
holder.account_action.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
if( actionType == type.CURRENT){
holder.account_action.setImageResource(R.drawable.ic_close);
}else if(actionType == type.SEARCH){

View File

@ -19,8 +19,10 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
@ -94,6 +96,7 @@ public class ListAdapter extends BaseAdapter implements OnListActionInterface {
}
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
if( theme == Helper.THEME_LIGHT){
holder.search_container.setBackgroundResource(R.color.mastodonC3__);
changeDrawableColor(context, R.drawable.ic_keyboard_arrow_right,R.color.black);
@ -101,7 +104,13 @@ public class ListAdapter extends BaseAdapter implements OnListActionInterface {
holder.search_container.setBackgroundResource(R.color.mastodonC1_);
changeDrawableColor(context, R.drawable.ic_keyboard_arrow_right,R.color.dark_text);
}
Drawable next = ContextCompat.getDrawable(context, R.drawable.ic_keyboard_arrow_right);
holder.search_title.setText(list.getTitle());
assert next != null;
final float scale = context.getResources().getDisplayMetrics().density;
next.setBounds(0,0,(int) (30 * scale + 0.5f),(int) (30 * scale + 0.5f));
holder.search_title.setCompoundDrawables(null, null, next, null);
holder.search_container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View File

@ -247,7 +247,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/DroidSans-Regular.ttf");
holder.notification_status_content.setTypeface(tf);
holder.status_reply.setText("");
if( !status.isClickable())
status.makeClickable(context);
if( !status.isEmojiFound())
@ -301,7 +301,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
holder.status_action_container.setVisibility(View.VISIBLE);
Drawable imgFav, imgReblog;
Drawable imgFav, imgReblog, imgReply;
if( status.isFavourited() || (status.getReblog() != null && status.getReblog().isFavourited())) {
changeDrawableColor(context, R.drawable.ic_star,R.color.marked_icon);
imgFav = ContextCompat.getDrawable(context, R.drawable.ic_star);
@ -323,6 +323,11 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
changeDrawableColor(context, R.drawable.ic_repeat,R.color.black);
imgReblog = ContextCompat.getDrawable(context, R.drawable.ic_repeat);
}
if( theme == THEME_DARK)
changeDrawableColor(context, R.drawable.ic_reply,R.color.dark_icon);
else
changeDrawableColor(context, R.drawable.ic_reply,R.color.black);
imgReply = ContextCompat.getDrawable(context, R.drawable.ic_reply);
if( status.getReblog() == null) {
if (status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0 && !status.isSpoilerShown()) {
@ -364,14 +369,21 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
imgFav.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f));
assert imgReblog != null;
imgReblog.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f));
assert imgReply != null;
imgReply.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f));
holder.status_favorite_count.setCompoundDrawables(imgFav, null, null, null);
holder.status_reblog_count.setCompoundDrawables(imgReblog, null, null, null);
holder.status_reply.setCompoundDrawables(imgReply, null, null, null);
if( theme == THEME_DARK){
holder.status_favorite_count.setTextColor(ContextCompat.getColor(context, R.color.dark_icon));
holder.status_reblog_count.setTextColor(ContextCompat.getColor(context, R.color.dark_icon));
holder.status_reply.setTextColor(ContextCompat.getColor(context, R.color.dark_icon));
}else {
holder.status_favorite_count.setTextColor(ContextCompat.getColor(context, R.color.black));
holder.status_reblog_count.setTextColor(ContextCompat.getColor(context, R.color.black));
holder.status_reply.setTextColor(ContextCompat.getColor(context, R.color.black));
}
if( type.equals("favourite") || type.equals("reblog")){
holder.status_document_container.setVisibility(View.GONE);
@ -981,7 +993,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
TextView status_favorite_count;
TextView status_reblog_count;
TextView status_date;
ImageView status_reply;
TextView status_reply;
LinearLayout status_document_container;
LinearLayout status_action_container;
Button status_show_more;

View File

@ -20,7 +20,9 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
@ -99,7 +101,13 @@ public class SearchTootsListAdapter extends BaseAdapter {
holder.search_container.setBackgroundResource(R.color.mastodonC1_);
changeDrawableColor(context, R.drawable.ic_keyboard_arrow_right,R.color.dark_text);
}
Drawable next = ContextCompat.getDrawable(context, R.drawable.ic_keyboard_arrow_right);
holder.search_title.setText(search);
final float scale = context.getResources().getDisplayMetrics().density;
assert next != null;
next.setBounds(0,0,(int) (30 * scale + 0.5f),(int) (30 * scale + 0.5f));
holder.search_title.setCompoundDrawables(null, null, next, null);
holder.search_container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View File

@ -316,14 +316,18 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
tmpStatuses.add(tmpStatus);
}
}
if (tmpStatuses.size() > 0 && Long.parseLong(tmpStatuses.get(tmpStatuses.size()-1).getId()) > Long.parseLong(bookmark)) {
tmpStatuses.get(tmpStatuses.size()-1).setFetchMore(true);
int tootPerPage = sharedpreferences.getInt(Helper.SET_TOOTS_PER_PAGE, 40);
if( tmpStatuses.size() >= tootPerPage) {
if (tmpStatuses.size() > 0 && Long.parseLong(tmpStatuses.get(tmpStatuses.size() - 1).getId()) > Long.parseLong(bookmark)) {
tmpStatuses.get(tmpStatuses.size() - 1).setFetchMore(true);
}
}
this.statuses.addAll(position, tmpStatuses);
statusListAdapter.notifyItemRangeInserted(position, tmpStatuses.size());
lv_status.scrollToPosition(position+tmpStatuses.size());
if( tmpStatuses.size() < 3) //If new toots are only two
lv_status.scrollToPosition(0);
else
lv_status.scrollToPosition(position+tmpStatuses.size());
}
}else {

View File

@ -1771,7 +1771,7 @@ public class Helper {
}
public static void installProvider(){
Security.addProvider(Conscrypt.newProvider());
Security.insertProviderAt(Conscrypt.newProvider(),1);
}

View File

@ -109,7 +109,7 @@ public class CustomEmojiDAO {
public List<Emojis> getAllEmojis(){
String instance = Helper.getLiveInstance(context);
try {
Cursor c = db.query(Sqlite.TABLE_CUSTOM_EMOJI, null, Sqlite.COL_INSTANCE + " = '" + instance+ "'", null, null, null, Sqlite.COL_SHORTCODE + " ASC", null);
Cursor c = db.query(Sqlite.TABLE_CUSTOM_EMOJI, null, Sqlite.COL_INSTANCE + " = '" + instance+ "'", null, Sqlite.COL_SHORTCODE , null, Sqlite.COL_SHORTCODE + " ASC", null);
return cursorToListEmojis(c);
} catch (Exception e) {
return null;
@ -139,7 +139,7 @@ public class CustomEmojiDAO {
public List<Emojis> getEmojiStartingBy(String shortCode){
try {
String instance = Helper.getLiveInstance(context);
Cursor c = db.query(Sqlite.TABLE_CUSTOM_EMOJI, null, Sqlite.COL_SHORTCODE + " LIKE \"%" + shortCode + "%\" AND " + Sqlite.COL_INSTANCE + " = \"" + instance+ "\"", null, null, null, null, null);
Cursor c = db.query(Sqlite.TABLE_CUSTOM_EMOJI, null, Sqlite.COL_SHORTCODE + " LIKE \"%" + shortCode + "%\" AND " + Sqlite.COL_INSTANCE + " = \"" + instance+ "\"", null, Sqlite.COL_SHORTCODE , null, null, null);
return cursorToListEmojis(c);
} catch (Exception e) {
return null;

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M20,6h-3L17,4c0,-1.11 -0.89,-2 -2,-2L9,2c-1.11,0 -2,0.89 -2,2v2L4,6c-1.11,0 -2,0.89 -2,2v11c0,1.11 0.89,2 2,2h16c1.11,0 2,-0.89 2,-2L22,8c0,-1.11 -0.89,-2 -2,-2zM9,4h6v2L9,6L9,4zM20,19L4,19v-2h16v2zM20,14L4,14L4,8h3v2h2L9,8h6v2h2L17,8h3v6z"/>
</vector>

View File

@ -186,6 +186,16 @@
android:layout_height="wrap_content"
/>
</LinearLayout>
<TextView
android:layout_marginTop="5dp"
android:textSize="16sp"
android:drawablePadding="4dp"
android:visibility="gone"
android:id="@+id/account_moved"
android:gravity="center"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>

View File

@ -8,11 +8,10 @@
android:id="@+id/container"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="300dp">
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/main_account_container"
android:visibility="gone"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -22,7 +21,7 @@
android:textColor="@color/titleb"
android:layout_gravity="center"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
@ -34,6 +33,17 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text" />
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/lv_accounts_current"
android:layout_width="match_parent"
@ -45,20 +55,10 @@
android:visibility="gone"
android:id="@+id/lv_accounts_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="300dp"
android:scrollbars="none"
android:divider="@null"
/>
</LinearLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true" />
</RelativeLayout>
</LinearLayout>

View File

@ -120,14 +120,15 @@
android:gravity="center"
android:orientation="horizontal"
android:layout_height="wrap_content"
>
android:baselineAligned="false">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
tools:ignore="UselessParent">
<TextView
android:id="@+id/account_dn"
android:textColor="@color/mastodonC4"
@ -150,7 +151,6 @@
android:textSize="14sp"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
@ -183,6 +183,16 @@
android:layout_height="wrap_content"
/>
</LinearLayout>
<TextView
android:layout_marginTop="5dp"
android:textSize="16sp"
android:visibility="gone"
android:drawablePadding="4dp"
android:id="@+id/account_moved"
android:gravity="center"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>

View File

@ -282,13 +282,13 @@
android:layout_marginEnd="@dimen/activity_vertical_margin"
android:layout_marginRight="@dimen/activity_vertical_margin"
android:orientation="horizontal">
<ImageView
android:id="@+id/status_reply"
<TextView
android:drawablePadding="2dp"
android:layout_gravity="center_vertical"
android:layout_width="20dp"
android:layout_height="20dp"
app:srcCompat="@drawable/ic_reply"
tools:ignore="ContentDescription" />
android:gravity="center_vertical"
android:id="@+id/status_reply"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"

View File

@ -24,8 +24,6 @@
android:paddingTop="5dp"
android:orientation="vertical">
<TextView
android:drawableRight="@drawable/ic_keyboard_arrow_right"
android:drawableEnd="@drawable/ic_keyboard_arrow_right"
android:id="@+id/search_keyword"
android:textSize="18sp"
android:paddingBottom="10dp"

View File

@ -463,4 +463,7 @@
<string name="action_lists_title_placeholder">New list title</string>
<string name="action_lists_search_users">Search among people you follow</string>
<string name="action_lists_owner">Your lists</string>
<!-- Migration -->
<string name="account_moved_to">%1$s has moved to %2$s</string>
</resources>