Merge branch 'bug_fix' into develop

This commit is contained in:
tom79 2017-10-18 14:32:49 +02:00
commit 1ad15d5e02
5 changed files with 82 additions and 66 deletions

View File

@ -24,6 +24,7 @@ import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -74,6 +75,8 @@ public abstract class BaseLoginActivity extends AppCompatActivity {
private static boolean client_id_for_webview = false; private static boolean client_id_for_webview = false;
private String instance; private String instance;
private AutoCompleteTextView login_instance; private AutoCompleteTextView login_instance;
private EditText login_uid;
private EditText login_passwd;
boolean isLoadingInstance = false; boolean isLoadingInstance = false;
@Override @Override
@ -94,8 +97,11 @@ public abstract class BaseLoginActivity extends AppCompatActivity {
}else { }else {
changeDrawableColor(getApplicationContext(), R.drawable.mastodon_icon, R.color.mastodonC3); changeDrawableColor(getApplicationContext(), R.drawable.mastodon_icon, R.color.mastodonC3);
} }
final Button connectionButton = (Button) findViewById(R.id.login_button); final Button connectionButton = findViewById(R.id.login_button);
login_instance = (AutoCompleteTextView) findViewById(R.id.login_instance); login_instance = findViewById(R.id.login_instance);
login_uid = findViewById(R.id.login_uid);
login_passwd = findViewById(R.id.login_passwd);
if( theme == Helper.THEME_LIGHT) { if( theme == Helper.THEME_LIGHT) {
connectionButton.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.white)); connectionButton.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.white));
@ -153,7 +159,7 @@ public abstract class BaseLoginActivity extends AppCompatActivity {
connectionButton.setEnabled(false); connectionButton.setEnabled(false);
login_two_step = (TextView) findViewById(R.id.login_two_step); login_two_step = findViewById(R.id.login_two_step);
login_two_step.setVisibility(View.GONE); login_two_step.setVisibility(View.GONE);
login_two_step.setPaintFlags(login_two_step.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); login_two_step.setPaintFlags(login_two_step.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
login_two_step.setOnClickListener(new View.OnClickListener() { login_two_step.setOnClickListener(new View.OnClickListener() {
@ -181,7 +187,7 @@ public abstract class BaseLoginActivity extends AppCompatActivity {
@Override @Override
protected void onResume(){ protected void onResume(){
super.onResume(); super.onResume();
Button connectionButton = (Button) findViewById(R.id.login_button); Button connectionButton = findViewById(R.id.login_button);
if (login_instance.getText() != null && login_instance.getText().toString().length() > 0 && client_id_for_webview) { if (login_instance.getText() != null && login_instance.getText().toString().length() > 0 && client_id_for_webview) {
connectionButton.setEnabled(false); connectionButton.setEnabled(false);
client_id_for_webview = false; client_id_for_webview = false;
@ -190,7 +196,7 @@ public abstract class BaseLoginActivity extends AppCompatActivity {
} }
private void retrievesClientId(){ private void retrievesClientId(){
final Button connectionButton = (Button) findViewById(R.id.login_button); final Button connectionButton = findViewById(R.id.login_button);
try { try {
instance = URLEncoder.encode(login_instance.getText().toString().trim(), "utf-8"); instance = URLEncoder.encode(login_instance.getText().toString().trim(), "utf-8");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
@ -254,8 +260,6 @@ public abstract class BaseLoginActivity extends AppCompatActivity {
requestParams.add(Helper.CLIENT_ID, sharedpreferences.getString(Helper.CLIENT_ID, null)); requestParams.add(Helper.CLIENT_ID, sharedpreferences.getString(Helper.CLIENT_ID, null));
requestParams.add(Helper.CLIENT_SECRET, sharedpreferences.getString(Helper.CLIENT_SECRET, null)); requestParams.add(Helper.CLIENT_SECRET, sharedpreferences.getString(Helper.CLIENT_SECRET, null));
requestParams.add("grant_type", "password"); requestParams.add("grant_type", "password");
EditText login_uid = (EditText) findViewById(R.id.login_uid);
EditText login_passwd = (EditText) findViewById(R.id.login_passwd);
requestParams.add("username",login_uid.getText().toString().trim()); requestParams.add("username",login_uid.getText().toString().trim());
requestParams.add("password",login_passwd.getText().toString().trim()); requestParams.add("password",login_passwd.getText().toString().trim());
requestParams.add("scope"," read write follow"); requestParams.add("scope"," read write follow");

View File

@ -1213,37 +1213,39 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
toot_content.setThreshold(1); toot_content.setThreshold(1);
toot_content.setAdapter(accountsListAdapter); toot_content.setAdapter(accountsListAdapter);
final String oldContent = toot_content.getText().toString(); final String oldContent = toot_content.getText().toString();
String[] searchA = oldContent.substring(0,currentCursorPosition).split("@"); if( oldContent.length() >= currentCursorPosition) {
if( searchA.length > 0 ) { String[] searchA = oldContent.substring(0, currentCursorPosition).split("@");
final String search = searchA[searchA.length - 1]; if (searchA.length > 0) {
toot_content.setOnItemClickListener(new AdapterView.OnItemClickListener() { final String search = searchA[searchA.length - 1];
@Override toot_content.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { @Override
Account account = accounts.get(position); public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String deltaSearch = ""; Account account = accounts.get(position);
if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length()) String deltaSearch = "";
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition); if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length())
else { deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition);
if (currentCursorPosition >= oldContent.length()) else {
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, oldContent.length()); if (currentCursorPosition >= oldContent.length())
} deltaSearch = oldContent.substring(currentCursorPosition - searchLength, oldContent.length());
}
if (!search.equals("")) if (!search.equals(""))
deltaSearch = deltaSearch.replace("@" + search, ""); deltaSearch = deltaSearch.replace("@" + search, "");
String newContent = oldContent.substring(0, currentCursorPosition - searchLength); String newContent = oldContent.substring(0, currentCursorPosition - searchLength);
newContent += deltaSearch; newContent += deltaSearch;
newContent += "@" + account.getAcct() + " "; newContent += "@" + account.getAcct() + " ";
int newPosition = newContent.length(); int newPosition = newContent.length();
if (currentCursorPosition < oldContent.length() - 1) if (currentCursorPosition < oldContent.length() - 1)
newContent += oldContent.substring(currentCursorPosition, oldContent.length() - 1); newContent += oldContent.substring(currentCursorPosition, oldContent.length() - 1);
toot_content.setText(newContent); toot_content.setText(newContent);
toot_space_left.setText(String.valueOf(toot_content.length())); toot_space_left.setText(String.valueOf(toot_content.length()));
toot_content.setSelection(newPosition); toot_content.setSelection(newPosition);
AccountsSearchAdapter accountsListAdapter = new AccountsSearchAdapter(TootActivity.this, new ArrayList<Account>()); AccountsSearchAdapter accountsListAdapter = new AccountsSearchAdapter(TootActivity.this, new ArrayList<Account>());
toot_content.setThreshold(1); toot_content.setThreshold(1);
toot_content.setAdapter(accountsListAdapter); toot_content.setAdapter(accountsListAdapter);
} }
}); });
}
} }
} }
} }

View File

@ -767,40 +767,42 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
notifications.removeAll(notificationsToRemove); notifications.removeAll(notificationsToRemove);
notificationsListAdapter.notifyDataSetChanged(); notificationsListAdapter.notifyDataSetChanged();
} }
if (statusAction == API.StatusAction.REBLOG) { if( targetedId != null ) {
for (Notification notification : notifications) { if (statusAction == API.StatusAction.REBLOG) {
if (notification.getStatus().getId().equals(targetedId)) { for (Notification notification : notifications) {
notification.getStatus().setReblogs_count(notification.getStatus().getReblogs_count() + 1); if (notification.getStatus() != null && notification.getStatus().getId().equals(targetedId)) {
break; notification.getStatus().setReblogs_count(notification.getStatus().getReblogs_count() + 1);
break;
}
} }
} notificationsListAdapter.notifyDataSetChanged();
notificationsListAdapter.notifyDataSetChanged(); } else if (statusAction == API.StatusAction.UNREBLOG) {
} else if (statusAction == API.StatusAction.UNREBLOG) { for (Notification notification : notifications) {
for (Notification notification : notifications) { if (notification.getStatus() != null && notification.getStatus().getId().equals(targetedId)) {
if (notification.getStatus().getId().equals(targetedId)) { if (notification.getStatus().getReblogs_count() - 1 >= 0)
if (notification.getStatus().getReblogs_count() - 1 >= 0) notification.getStatus().setReblogs_count(notification.getStatus().getReblogs_count() - 1);
notification.getStatus().setReblogs_count(notification.getStatus().getReblogs_count() - 1); break;
break; }
} }
} notificationsListAdapter.notifyDataSetChanged();
notificationsListAdapter.notifyDataSetChanged(); } else if (statusAction == API.StatusAction.FAVOURITE) {
} else if (statusAction == API.StatusAction.FAVOURITE) { for (Notification notification : notifications) {
for (Notification notification : notifications) { if (notification.getStatus() != null && notification.getStatus().getId().equals(targetedId)) {
if (notification.getStatus().getId().equals(targetedId)) { notification.getStatus().setFavourites_count(notification.getStatus().getFavourites_count() + 1);
notification.getStatus().setFavourites_count(notification.getStatus().getFavourites_count() + 1); break;
break; }
} }
} notificationsListAdapter.notifyDataSetChanged();
notificationsListAdapter.notifyDataSetChanged(); } else if (statusAction == API.StatusAction.UNFAVOURITE) {
} else if (statusAction == API.StatusAction.UNFAVOURITE) { for (Notification notification : notifications) {
for (Notification notification : notifications) { if (notification.getStatus() != null && notification.getStatus().getId().equals(targetedId)) {
if (notification.getStatus().getId().equals(targetedId)) { if (notification.getStatus().getFavourites_count() - 1 >= 0)
if (notification.getStatus().getFavourites_count() - 1 >= 0) notification.getStatus().setFavourites_count(notification.getStatus().getFavourites_count() - 1);
notification.getStatus().setFavourites_count(notification.getStatus().getFavourites_count() - 1); break;
break; }
} }
notificationsListAdapter.notifyDataSetChanged();
} }
notificationsListAdapter.notifyDataSetChanged();
} }
} }

View File

@ -44,12 +44,15 @@
android:id="@+id/login_instance" android:id="@+id/login_instance"
android:layout_width="300dp" android:layout_width="300dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:maxLines="1"
android:inputType="textWebEmailAddress" android:inputType="textWebEmailAddress"
android:hint="@string/instance_example" android:hint="@string/instance_example"
/> />
<EditText <EditText
android:id="@+id/login_uid" android:id="@+id/login_uid"
android:layout_width="300dp" android:layout_width="300dp"
android:maxLines="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="textEmailAddress" android:inputType="textEmailAddress"
android:hint="@string/email" android:hint="@string/email"
@ -57,6 +60,7 @@
<EditText <EditText
android:id = "@+id/login_passwd" android:id = "@+id/login_passwd"
android:inputType="textPassword" android:inputType="textPassword"
android:maxLines="1"
android:hint="@string/password" android:hint="@string/password"
android:layout_width="300dp" android:layout_width="300dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@ -44,13 +44,16 @@
android:id="@+id/login_instance" android:id="@+id/login_instance"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="textWebEmailAddress" android:inputType="textWebEmailAddress"
android:maxLines="1"
android:hint="@string/instance_example" android:hint="@string/instance_example"
/> />
<EditText <EditText
android:id="@+id/login_uid" android:id="@+id/login_uid"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:maxLines="1"
android:inputType="textEmailAddress" android:inputType="textEmailAddress"
android:hint="@string/email" android:hint="@string/email"
/> />
@ -58,6 +61,7 @@
android:id = "@+id/login_passwd" android:id = "@+id/login_passwd"
android:inputType="textPassword" android:inputType="textPassword"
android:hint="@string/password" android:hint="@string/password"
android:maxLines="1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
/> />