This commit is contained in:
tom79 2017-07-07 19:26:26 +02:00
parent 45f3022ebe
commit 00f8f314b7
36 changed files with 100 additions and 96 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 148 KiB

View File

@ -49,6 +49,7 @@ import fr.gouv.etalab.mastodon.helper.Helper;
import mastodon.etalab.gouv.fr.mastodon.R;
import static fr.gouv.etalab.mastodon.helper.Helper.USER_AGENT;
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
/**
@ -63,7 +64,6 @@ public class LoginActivity extends AppCompatActivity {
private TextView login_two_step;
private static boolean client_id_for_webview = false;
private String instance;
private boolean addAccount = false;
private EditText login_instance;
@Override
@ -78,6 +78,11 @@ public class LoginActivity extends AppCompatActivity {
}
setContentView(R.layout.activity_login);
if( theme == Helper.THEME_DARK) {
changeDrawableColor(getApplicationContext(), R.drawable.mastodon_icon, R.color.colorAccentD);
}else {
changeDrawableColor(getApplicationContext(), R.drawable.mastodon_icon, R.color.colorAccent);
}
final Button connectionButton = (Button) findViewById(R.id.login_button);
login_instance = (EditText) findViewById(R.id.login_instance);
connectionButton.setEnabled(false);
@ -92,58 +97,26 @@ public class LoginActivity extends AppCompatActivity {
}
});
//For other instances
TextView other_instance = (TextView) findViewById(R.id.other_instance);
other_instance.setPaintFlags(other_instance.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
other_instance.setOnClickListener(new View.OnClickListener() {
login_instance.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(LoginActivity.this, LoginActivity.class);
intent.putExtra("addAccount", true);
startActivity(intent);
finish();
public void onFocusChange(View v, boolean hasFocus) {
connectionButton.setEnabled(false);
login_two_step.setVisibility(View.INVISIBLE);
if (!hasFocus) {
retrievesClientId();
}
}
});
Bundle b = getIntent().getExtras();
if(b != null)
addAccount = b.getBoolean("addAccount", false);
if( addAccount )
login_instance.setVisibility(View.VISIBLE);
if( addAccount) {
login_instance.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
connectionButton.setEnabled(false);
login_two_step.setVisibility(View.INVISIBLE);
if (!hasFocus) {
retrievesClientId();
}
}
});
}
if( addAccount)
other_instance.setVisibility(View.GONE);
}
@Override
protected void onResume(){
super.onResume();
Button connectionButton = (Button) findViewById(R.id.login_button);
if( !addAccount ) {
if (client_id_for_webview || !connectionButton.isEnabled()) {
connectionButton.setEnabled(false);
client_id_for_webview = false;
retrievesClientId();
}
}else {
if (login_instance.getText() != null && login_instance.getText().toString().length() > 0 && client_id_for_webview) {
connectionButton.setEnabled(false);
client_id_for_webview = false;
retrievesClientId();
}
if (login_instance.getText() != null && login_instance.getText().toString().length() > 0 && client_id_for_webview) {
connectionButton.setEnabled(false);
client_id_for_webview = false;
retrievesClientId();
}
}
@ -156,7 +129,7 @@ public class LoginActivity extends AppCompatActivity {
String action = "/api/v1/apps";
RequestParams parameters = new RequestParams();
parameters.add(Helper.CLIENT_NAME, Helper.OAUTH_REDIRECT_HOST);
parameters.add(Helper.CLIENT_NAME, Helper.CLIENT_NAME_VALUE);
parameters.add(Helper.REDIRECT_URIS, client_id_for_webview?Helper.REDIRECT_CONTENT_WEB:Helper.REDIRECT_CONTENT);
parameters.add(Helper.SCOPES, Helper.OAUTH_SCOPES);
parameters.add(Helper.WEBSITE,"https://" + Helper.getLiveInstance(getApplicationContext()));

View File

@ -28,8 +28,6 @@ import android.os.Build;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -141,6 +139,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
holder.status_account_displayname = (TextView) convertView.findViewById(R.id.status_account_displayname);
holder.status_account_profile = (ImageView) convertView.findViewById(R.id.status_account_profile);
holder.status_account_profile_boost = (ImageView) convertView.findViewById(R.id.status_account_profile_boost);
holder.status_account_profile_boost_by = (ImageView) convertView.findViewById(R.id.status_account_profile_boost_by);
holder.status_favorite_count = (TextView) convertView.findViewById(R.id.status_favorite_count);
holder.status_reblog_count = (TextView) convertView.findViewById(R.id.status_reblog_count);
holder.status_toot_date = (TextView) convertView.findViewById(R.id.status_toot_date);
@ -161,7 +160,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
holder.status_prev4_container = (RelativeLayout) convertView.findViewById(R.id.status_prev4_container);
holder.status_reply = (ImageView) convertView.findViewById(R.id.status_reply);
holder.status_privacy = (ImageView) convertView.findViewById(R.id.status_privacy);
holder.status_translate = (ImageView) convertView.findViewById(R.id.status_translate);
holder.status_translate = (Button) convertView.findViewById(R.id.status_translate);
holder.status_content_translated_container = (LinearLayout) convertView.findViewById(R.id.status_content_translated_container);
holder.main_container = (LinearLayout) convertView.findViewById(R.id.main_container);
holder.status_spoiler_container = (LinearLayout) convertView.findViewById(R.id.status_spoiler_container);
@ -357,12 +356,18 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
holder.status_reblog_count.setText(String.valueOf(status.getReblogs_count()));
holder.status_toot_date.setText(Helper.dateDiff(context, status.getCreated_at()));
imageLoader.displayImage(ppurl, holder.status_account_profile, options);
if( status.getReblog() != null) {
imageLoader.displayImage(status.getAccount().getAvatar(), holder.status_account_profile_boost, options);
imageLoader.displayImage(ppurl, holder.status_account_profile_boost, options);
imageLoader.displayImage(status.getAccount().getAvatar(), holder.status_account_profile_boost_by, options);
holder.status_account_profile_boost.setVisibility(View.VISIBLE);
holder.status_account_profile_boost_by.setVisibility(View.VISIBLE);
holder.status_account_profile.setVisibility(View.GONE);
}else{
imageLoader.displayImage(ppurl, holder.status_account_profile, options);
holder.status_account_profile_boost.setVisibility(View.GONE);
holder.status_account_profile_boost_by.setVisibility(View.GONE);
holder.status_account_profile.setVisibility(View.VISIBLE);
}
if( status.getReblog() == null) {
if (status.getMedia_attachments().size() < 1) {
@ -487,10 +492,18 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
public void onClick(View v) {
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
if( status.getReblog() == null)
b.putString("accountId", status.getAccount().getId());
else
b.putString("accountId", status.getReblog().getAccount().getId());
b.putString("accountId", status.getAccount().getId());
intent.putExtras(b);
context.startActivity(intent);
}
});
holder.status_account_profile_boost.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putString("accountId", status.getReblog().getAccount().getId());
intent.putExtras(b);
context.startActivity(intent);
}
@ -673,6 +686,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
TextView status_account_displayname;
ImageView status_account_profile;
ImageView status_account_profile_boost;
ImageView status_account_profile_boost_by;
TextView status_favorite_count;
TextView status_reblog_count;
TextView status_toot_date;
@ -692,7 +706,7 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
RelativeLayout status_prev4_container;
ImageView status_reply;
ImageView status_privacy;
ImageView status_translate;
Button status_translate;
LinearLayout status_container2;
LinearLayout status_container3;
LinearLayout main_container;

View File

@ -26,7 +26,6 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@ -42,7 +41,6 @@ import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.support.annotation.ColorInt;
import android.support.design.widget.NavigationView;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
@ -54,8 +52,6 @@ import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
@ -132,7 +128,7 @@ public class Helper {
@SuppressWarnings("unused")
public static final String TAG = "mastodon_etalab";
public static final String OAUTH_REDIRECT_HOST = "fr.gouv.etalab.mastodon";
public static final String CLIENT_NAME_VALUE = "Mastalab";
public static final String INSTANCE = "mastodon.etalab.gouv.fr";
public static final String OAUTH_SCOPES = "read write follow";
public static final String PREF_KEY_OAUTH_TOKEN = "oauth_token";

Binary file not shown.

Before

Width:  |  Height:  |  Size: 720 B

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 795 B

After

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 440 B

After

Width:  |  Height:  |  Size: 412 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 491 B

After

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 791 B

After

Width:  |  Height:  |  Size: 704 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 998 B

After

Width:  |  Height:  |  Size: 800 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 802 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 825 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 935 B

View File

@ -18,7 +18,7 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/splashc"/>
android:drawable="?attr/colorPrimary"/>
<item>
<bitmap

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View File

@ -132,4 +132,16 @@
android:layout_width="0dp"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="@string/thanks_text"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>

View File

@ -28,10 +28,10 @@
>
<ImageView
android:layout_marginTop="20dp"
android:layout_width="100dp"
android:layout_width="150dp"
android:layout_gravity="center_horizontal"
android:src="@drawable/mastodonlogo"
android:layout_height="100dp"
android:layout_height="150dp"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="match_parent"
@ -41,7 +41,6 @@
android:orientation="vertical"
android:layout_height="wrap_content">
<EditText
android:visibility="gone"
android:id="@+id/login_instance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -81,19 +80,6 @@
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/login" />
<TextView
android:id="@+id/other_instance"
android:textAllCaps="false"
android:gravity="center"
android:layout_marginTop="20dp"
android:drawablePadding="10dp"
android:padding="20dp"
android:textSize="16sp"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?attr/colorAccent"
android:text="@string/other_instance" />
<TextView
android:id="@+id/login_two_step"
android:textAllCaps="false"

View File

@ -33,31 +33,59 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:orientation="horizontal"
android:baselineAligned="false">
<RelativeLayout
android:layout_height="60dp"
android:layout_height="wrap_content"
android:layout_width="60dp"
android:layout_gravity="center_horizontal|top"
android:gravity="center_horizontal|top">
>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="5dp"
android:layout_centerHorizontal="true"
android:id="@+id/status_account_profile"
tools:ignore="ContentDescription" />
<ImageView
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerHorizontal="true"
android:visibility="gone"
android:id="@+id/status_account_profile_boost"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/status_account_profile_boost_by"
android:layout_height="30dp"
android:layout_width="30dp"
android:layout_marginTop="25dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
style="?attr/shapeBorder"
android:visibility="gone"
tools:ignore="ContentDescription" />
<Button
android:id="@+id/status_translate"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_marginTop="70dp"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:scaleType="center"
android:drawablePadding="0dp"
android:paddingStart="17dp"
android:paddingLeft="17dp"
android:drawableStart="@drawable/ic_translate"
android:drawableLeft="@drawable/ic_translate"
tools:ignore="ContentDescription" />
</RelativeLayout>
<LinearLayout
android:layout_marginStart="5dp"
@ -344,15 +372,6 @@
android:paddingRight="10dp"
android:paddingLeft="10dp"
android:layout_height="wrap_content">
<ImageView
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"
android:id="@+id/status_translate"
android:layout_gravity="center_vertical"
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@drawable/ic_translate"
tools:ignore="ContentDescription" />
<ImageView
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -312,4 +312,6 @@
L\'application offre la possibilité de traduire les pouets en utilisant les paramètres régionaux de l\'appareil et l\'API de Yandex.\n
Yandex a sa propre politique de confidentialité qui peut être consultée à l\'adresse suivante : https://yandex.ru/legal/confidential/?lang=en
</string>
<string name="thanks_text">Merci à Stéphane pour le logo.</string>
</resources>

View File

@ -8,7 +8,7 @@
<!-- DARK -->
<color name="colorPrimaryD">#616161</color>
<color name="colorPrimaryDarkD">#212121</color>
<color name="colorAccentD">#009688</color>
<color name="colorAccentD">#4db6ac</color>
<!-- Header Profile-->
<color name="header1">#0288D1</color>
@ -38,5 +38,4 @@
<color name="red_1">#F44336</color>
<color name="black">#000</color>
</resources>

View File

@ -5,7 +5,7 @@
<dimen name="activity_padding_header">10dp</dimen>
<dimen name="nav_header_vertical_spacing">16dp</dimen>
<dimen name="nav_header_height">160dp</dimen>
<dimen name="fab_margin">16dp</dimen>
<dimen name="fab_margin">5dp</dimen>
<dimen name="drawer_padding">2dp</dimen>
<dimen name="toot_padding">20dp</dimen>
</resources>

View File

@ -318,4 +318,7 @@
The application offers the ability to translate toots using the locale of the device and the Yandex API.\n
Yandex has its proper privacy-policy which can be found here: https://yandex.ru/legal/confidential/?lang=en
</string>
<string name="thanks_text">Thank you to Stéphane for the logo.</string>
</resources>