Adds new icon launcher + adds thanks

This commit is contained in:
tom79 2017-10-08 11:54:41 +02:00
parent c4b3b90444
commit dd3ac5394d
17 changed files with 122 additions and 119 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View File

@ -55,14 +55,15 @@ import mastodon.etalab.gouv.fr.mastodon.R;
* About activity
*/
public class AboutActivity extends AppCompatActivity implements OnRetrieveRemoteAccountInterface, OnRetrieveSearchDevelopersAccountshInterface, OnRetrieveRelationshipInterface {
public class AboutActivity extends AppCompatActivity implements OnRetrieveRemoteAccountInterface, OnRetrieveRelationshipInterface {
private List<Account> developers = new ArrayList<>();
private List<Account> contributors = new ArrayList<>();
private List<Account> designers = new ArrayList<>();
private AccountSearchDevAdapter accountSearchWebAdapterDeveloper;
private AccountSearchDevAdapter accountSearchWebAdapterDesigner;
private AccountSearchDevAdapter accountSearchWebAdapterContributors;
@SuppressWarnings("FieldCanBeLocal")
private int DEV_COUNT = 1, CONTRIBUTOR_COUNT = 2;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -85,7 +86,9 @@ public class AboutActivity extends AppCompatActivity implements OnRetrieveRemote
} catch (PackageManager.NameNotFoundException ignored) {}
ExpandableHeightListView lv_developers = (ExpandableHeightListView) findViewById(R.id.lv_developers);
ExpandableHeightListView lv_designers = (ExpandableHeightListView) findViewById(R.id.lv_designers);
ExpandableHeightListView lv_contributors = (ExpandableHeightListView) findViewById(R.id.lv_contributors);
Button about_code = (Button) findViewById(R.id.about_code);
Button about_license = (Button) findViewById(R.id.about_license);
Button about_thekinrar = (Button) findViewById(R.id.about_thekinrar);
@ -138,14 +141,22 @@ public class AboutActivity extends AppCompatActivity implements OnRetrieveRemote
startActivity(browserIntent);
}
});
setTitle(R.string.action_about);
lv_contributors.setExpanded(true);
lv_developers.setExpanded(true);
lv_designers.setExpanded(true);
accountSearchWebAdapterContributors = new AccountSearchDevAdapter(AboutActivity.this, contributors);
lv_contributors.setAdapter(accountSearchWebAdapterContributors);
accountSearchWebAdapterDesigner = new AccountSearchDevAdapter(AboutActivity.this, designers);
lv_designers.setAdapter(accountSearchWebAdapterDesigner);
accountSearchWebAdapterDeveloper = new AccountSearchDevAdapter(AboutActivity.this, developers);
lv_developers.setAdapter(accountSearchWebAdapterDeveloper);
new RetrieveDeveloperAccountsAsyncTask(getApplicationContext(), AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveRemoteAccountsAsyncTask(getApplicationContext(), "tschneider", "mastodon.etalab.gouv.fr", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveRemoteAccountsAsyncTask(getApplicationContext(), "daycode", "mastodon.social", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveRemoteAccountsAsyncTask(getApplicationContext(), "PhotonQyv", "mastodon.xyz", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveRemoteAccountsAsyncTask(getApplicationContext(), "angrytux", "social.tchncs.de", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
@ -174,78 +185,46 @@ public class AboutActivity extends AppCompatActivity implements OnRetrieveRemote
Account account;
if( accounts != null && accounts.size() > 0){
account = accounts.get(0);
account.setFollowing(false);
account.setRemote(true);
if( account.getUsername().equals("@tschneider")) {
developers.add(account);
accountSearchWebAdapterDeveloper.notifyDataSetChanged();
}else {
contributors.add(account);
accountSearchWebAdapterContributors.notifyDataSetChanged();
account.setFollowing(true);
switch (account.getUsername()) {
case "tschneider":
developers.add(account);
accountSearchWebAdapterDeveloper.notifyDataSetChanged();
break;
case "daycode":
designers.add(account);
accountSearchWebAdapterDesigner.notifyDataSetChanged();
break;
default:
contributors.add(account);
accountSearchWebAdapterContributors.notifyDataSetChanged();
break;
}
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(),AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
@Override
public void onRetrieveSearchDevelopersAccounts(ArrayList<Account> accounts) {
if( accounts == null || accounts.size() == 0) {
new RetrieveRemoteAccountsAsyncTask(getApplicationContext(), "tschneider", "mastodon.etalab.gouv.fr", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveRemoteAccountsAsyncTask(getApplicationContext(),"PhotonQyv", "mastodon.xyz", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new RetrieveRemoteAccountsAsyncTask(getApplicationContext(),"angrytux", "social.tchncs.de", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
return;
}
boolean tschneider = false;
boolean PhotonQyv = false;
boolean angrytux = false;
for(Account account: accounts){
if( account.getUsername().equals("tschneider")){
account.setFollowing(false);
account.setRemote(false);
developers.add(account);
accountSearchWebAdapterDeveloper.notifyDataSetChanged();
tschneider = true;
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(),AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
if( account.getUsername().equals("PhotonQyv")){
account.setFollowing(false);
account.setRemote(false);
contributors.add(account);
accountSearchWebAdapterContributors.notifyDataSetChanged();
PhotonQyv = true;
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(),AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
if( account.getUsername().equals("angrytux")){
account.setFollowing(false);
account.setRemote(false);
contributors.add(account);
accountSearchWebAdapterContributors.notifyDataSetChanged();
angrytux = true;
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(),AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
if( !tschneider)
new RetrieveRemoteAccountsAsyncTask(getApplicationContext(), "tschneider", "mastodon.etalab.gouv.fr", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
if( !PhotonQyv)
new RetrieveRemoteAccountsAsyncTask(getApplicationContext(), "PhotonQyv", "mastodon.xyz", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
if( !angrytux)
new RetrieveRemoteAccountsAsyncTask(getApplicationContext(), "angrytux", "social.tchncs.de", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
@Override
public void onResume(){
super.onResume();
if( developers != null && developers.size() == DEV_COUNT){
if( developers != null){
for(Account account: developers){
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(),AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
if( contributors != null && contributors.size() == CONTRIBUTOR_COUNT){
if( designers != null){
for(Account account: designers){
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(),AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
if( contributors != null){
for(Account account: contributors){
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(),AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
}
@Override
public void onRetrieveRelationship(Relationship relationship, Error error) {
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
@ -254,14 +233,24 @@ public class AboutActivity extends AppCompatActivity implements OnRetrieveRemote
return;
}
for( int i = 0 ; i < developers.size() ; i++){
if( contributors.get(i).getId() != null && developers.get(i).getId().equals(relationship.getId())){
if( developers.get(i).getId() != null && developers.get(i).getId().equals(relationship.getId())){
Log.v(Helper.TAG,developers.get(i).getUsername() + " -> " + (relationship.isFollowing() || userId.trim().equals(relationship.getId())));
developers.get(i).setFollowing(relationship.isFollowing() || userId.trim().equals(relationship.getId()));
accountSearchWebAdapterDeveloper.notifyDataSetChanged();
break;
}
}
for( int i = 0 ; i < designers.size() ; i++){
if( designers.get(i).getId() != null && designers.get(i).getId().equals(relationship.getId())){
Log.v(Helper.TAG,designers.get(i).getUsername() + " -> " + (relationship.isFollowing() || userId.trim().equals(relationship.getId())));
designers.get(i).setFollowing(relationship.isFollowing() || userId.trim().equals(relationship.getId()));
accountSearchWebAdapterDesigner.notifyDataSetChanged();
break;
}
}
for( int i = 0 ; i < contributors.size() ; i++){
if( contributors.get(i).getId() != null && contributors.get(i).getId().equals(relationship.getId())){
Log.v(Helper.TAG,contributors.get(i).getUsername() + " -> " + (relationship.isFollowing() || userId.trim().equals(relationship.getId())));
contributors.get(i).setFollowing(relationship.isFollowing() || userId.trim().equals(relationship.getId()));
accountSearchWebAdapterContributors.notifyDataSetChanged();
break;

View File

@ -46,6 +46,9 @@ public class RetrieveDeveloperAccountsAsyncTask extends AsyncTask<Void, Void, Vo
API api = new API(context);
accounts = new ArrayList<>();
APIResponse apiResponse = api.searchAccounts("@tschneider@mastodon.etalab.gouv.fr", 1);
if( apiResponse.getAccounts() != null && apiResponse.getAccounts().size() > 0)
accounts.add(apiResponse.getAccounts().get(0));
apiResponse = api.searchAccounts("@daycode@mastodon.social",1);
if( apiResponse.getAccounts() != null && apiResponse.getAccounts().size() > 0)
accounts.add(apiResponse.getAccounts().get(0));
apiResponse = api.searchAccounts("@PhotonQyv@mastodon.xyz",1);

View File

@ -17,7 +17,6 @@ package fr.gouv.etalab.mastodon.asynctasks;
import android.content.Context;
import android.os.AsyncTask;
import fr.gouv.etalab.mastodon.client.API;
import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.client.Entities.Results;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRemoteAccountInterface;

View File

@ -47,7 +47,6 @@ public class Account implements Parcelable {
private String token;
private String instance;
private boolean isFollowing;
private boolean isRemote;
private followAction followType = followAction.NOTHING;
private boolean isMakingAction = false;
@ -279,14 +278,6 @@ public class Account implements Parcelable {
isFollowing = following;
}
public boolean isRemote() {
return isRemote;
}
public void setRemote(boolean remote) {
isRemote = remote;
}
public String getFollowers_count_str() {
return followers_count_str;
}

View File

@ -132,12 +132,11 @@ public class AccountSearchDevAdapter extends BaseAdapter implements OnPostAction
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
holder.account_dn.setText(Html.fromHtml(Helper.shortnameToUnicode(account.getDisplay_name(), true), Html.FROM_HTML_MODE_LEGACY));
holder.account_un.setText(Html.fromHtml(Helper.shortnameToUnicode(account.getUsername(), true), Html.FROM_HTML_MODE_LEGACY));
holder.account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
holder.account_un.setText(String.format("@%s",account.getAcct()));
}else {
//noinspection deprecation
holder.account_dn.setText(Html.fromHtml(Helper.shortnameToUnicode(account.getDisplay_name(), true)));
holder.account_un.setText(Html.fromHtml(Helper.shortnameToUnicode(account.getUsername(), true)));
holder.account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
holder.account_un.setText(String.format("@%s",account.getAcct()));
}
changeDrawableColor(context, R.drawable.ic_action_lock_closed,R.color.mastodonC4);
//Profile picture
@ -149,33 +148,23 @@ public class AccountSearchDevAdapter extends BaseAdapter implements OnPostAction
holder.account_follow.setVisibility(View.VISIBLE);
}
if( account.isRemote()) {
holder.account_follow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
holder.account_follow.setEnabled(false);
new PostActionAsyncTask(context, API.StatusAction.REMOTE_FOLLOW, account.getAcct(), AccountSearchDevAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
}else {
holder.account_follow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
holder.account_follow.setEnabled(false);
new PostActionAsyncTask(context, API.StatusAction.FOLLOW, account.getId(), AccountSearchDevAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
holder.acccount_container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putString("accountId", account.getId());
intent.putExtras(b);
context.startActivity(intent);
}
});
}
holder.account_follow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
holder.account_follow.setEnabled(false);
new PostActionAsyncTask(context, API.StatusAction.FOLLOW, account.getId(), AccountSearchDevAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
holder.acccount_container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, ShowAccountActivity.class);
Bundle b = new Bundle();
b.putString("accountId", account.getId());
intent.putExtras(b);
context.startActivity(intent);
}
});
return convertView;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -80,6 +80,28 @@
android:layout_height="wrap_content"
tools:ignore="HardcodedText" />
<!-- About logo designer -->
<TextView
android:padding="5dp"
android:layout_marginTop="10dp"
android:id="@+id/about_thanks_logo"
android:layout_width="match_parent"
android:textColor="@color/mastodonC4"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:textSize="16sp"
android:text="@string/thanks_text_logo"/>
<fr.gouv.etalab.mastodon.helper.ExpandableHeightListView
android:id="@+id/lv_designers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:divider="@null"/>
<!-- About contributors -->
<TextView
android:id="@+id/about_thanks_dev"
android:layout_width="wrap_content"

View File

@ -76,6 +76,28 @@
android:layout_height="wrap_content"
tools:ignore="HardcodedText" />
<!-- About logo designer -->
<TextView
android:padding="5dp"
android:layout_marginTop="10dp"
android:id="@+id/about_thanks_logo"
android:layout_width="match_parent"
android:textColor="@color/mastodonC4"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:textSize="16sp"
android:text="@string/thanks_text_logo"/>
<fr.gouv.etalab.mastodon.helper.ExpandableHeightListView
android:id="@+id/lv_designers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:divider="@null"/>
<!-- About contributors -->
<TextView
android:padding="5dp"
android:layout_marginTop="10dp"
@ -200,19 +222,5 @@
android:text="@string/about_yandex_action"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:padding="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/thanks_text"/>
</LinearLayout>
</LinearLayout>
</ScrollView>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -198,7 +198,7 @@
<string name="about_yandex">Übersetzen von toots:</string>
<string name="about_thekinrar">Instanzensuche:</string>
<string name="about_thekinrar_action">instances.social</string>
<string name="thanks_text_logo">Icon designer:</string>
<!-- Conversation -->
<string name="conversation">Unterhaltung</string>

View File

@ -196,6 +196,8 @@
<string name="about_yandex">Traduction des pouets :</string>
<string name="about_thekinrar">Recherche d\'instances :</string>
<string name="about_thekinrar_action">instances.social</string>
<string name="thanks_text_logo">Concepteur de l\'icône : </string>
<!-- Conversation -->
<string name="conversation">Conversation</string>

View File

@ -197,7 +197,7 @@
<string name="about_yandex_action" translatable="false">Powered by Yandex.Translate</string>
<string name="about_thekinrar">Search instances:</string>
<string name="about_thekinrar_action">instances.social</string>
<string name="thanks_text_logo">Icon designer:</string>
<!-- Conversation -->
<string name="conversation">Conversation</string>