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.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@ -74,6 +75,8 @@ public abstract class BaseLoginActivity extends AppCompatActivity {
private static boolean client_id_for_webview = false;
private String instance;
private AutoCompleteTextView login_instance;
private EditText login_uid;
private EditText login_passwd;
boolean isLoadingInstance = false;
@Override
@ -94,8 +97,11 @@ public abstract class BaseLoginActivity extends AppCompatActivity {
}else {
changeDrawableColor(getApplicationContext(), R.drawable.mastodon_icon, R.color.mastodonC3);
}
final Button connectionButton = (Button) findViewById(R.id.login_button);
login_instance = (AutoCompleteTextView) findViewById(R.id.login_instance);
final Button connectionButton = findViewById(R.id.login_button);
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) {
connectionButton.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.white));
@ -153,7 +159,7 @@ public abstract class BaseLoginActivity extends AppCompatActivity {
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.setPaintFlags(login_two_step.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
login_two_step.setOnClickListener(new View.OnClickListener() {
@ -181,7 +187,7 @@ public abstract class BaseLoginActivity extends AppCompatActivity {
@Override
protected void 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) {
connectionButton.setEnabled(false);
client_id_for_webview = false;
@ -190,7 +196,7 @@ public abstract class BaseLoginActivity extends AppCompatActivity {
}
private void retrievesClientId(){
final Button connectionButton = (Button) findViewById(R.id.login_button);
final Button connectionButton = findViewById(R.id.login_button);
try {
instance = URLEncoder.encode(login_instance.getText().toString().trim(), "utf-8");
} 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_SECRET, sharedpreferences.getString(Helper.CLIENT_SECRET, null));
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("password",login_passwd.getText().toString().trim());
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.setAdapter(accountsListAdapter);
final String oldContent = toot_content.getText().toString();
String[] searchA = oldContent.substring(0,currentCursorPosition).split("@");
if( searchA.length > 0 ) {
final String search = searchA[searchA.length - 1];
toot_content.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Account account = accounts.get(position);
String deltaSearch = "";
if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length())
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition);
else {
if (currentCursorPosition >= oldContent.length())
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, oldContent.length());
}
if( oldContent.length() >= currentCursorPosition) {
String[] searchA = oldContent.substring(0, currentCursorPosition).split("@");
if (searchA.length > 0) {
final String search = searchA[searchA.length - 1];
toot_content.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Account account = accounts.get(position);
String deltaSearch = "";
if (currentCursorPosition - searchLength > 0 && currentCursorPosition < oldContent.length())
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, currentCursorPosition);
else {
if (currentCursorPosition >= oldContent.length())
deltaSearch = oldContent.substring(currentCursorPosition - searchLength, oldContent.length());
}
if (!search.equals(""))
deltaSearch = deltaSearch.replace("@" + search, "");
String newContent = oldContent.substring(0, currentCursorPosition - searchLength);
newContent += deltaSearch;
newContent += "@" + account.getAcct() + " ";
int newPosition = newContent.length();
if (currentCursorPosition < oldContent.length() - 1)
newContent += oldContent.substring(currentCursorPosition, oldContent.length() - 1);
toot_content.setText(newContent);
toot_space_left.setText(String.valueOf(toot_content.length()));
toot_content.setSelection(newPosition);
AccountsSearchAdapter accountsListAdapter = new AccountsSearchAdapter(TootActivity.this, new ArrayList<Account>());
toot_content.setThreshold(1);
toot_content.setAdapter(accountsListAdapter);
}
});
if (!search.equals(""))
deltaSearch = deltaSearch.replace("@" + search, "");
String newContent = oldContent.substring(0, currentCursorPosition - searchLength);
newContent += deltaSearch;
newContent += "@" + account.getAcct() + " ";
int newPosition = newContent.length();
if (currentCursorPosition < oldContent.length() - 1)
newContent += oldContent.substring(currentCursorPosition, oldContent.length() - 1);
toot_content.setText(newContent);
toot_space_left.setText(String.valueOf(toot_content.length()));
toot_content.setSelection(newPosition);
AccountsSearchAdapter accountsListAdapter = new AccountsSearchAdapter(TootActivity.this, new ArrayList<Account>());
toot_content.setThreshold(1);
toot_content.setAdapter(accountsListAdapter);
}
});
}
}
}
}

View File

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

View File

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

View File

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