Merge pull request #3947 from ByteHamster/fixes

Fixed some regressions with the new UI
This commit is contained in:
H. Lehmann 2020-03-20 14:35:18 +01:00 committed by GitHub
commit 0685ae721f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 8 deletions

View File

@ -101,6 +101,8 @@ public class MainActivityTest {
solo.goBack();
solo.goBack();
assertEquals(solo.getString(R.string.subscriptions_label), getActionbarTitle());
solo.goBack();
assertThat(mActivityRule.getActivityResult(), hasResultCode(Activity.RESULT_CANCELED));
}
@Test

View File

@ -367,6 +367,7 @@ public class MainActivity extends CastEnabledActivity {
super.onBackPressed();
} else {
loadFragment(UserPreferences.getBackButtonGoToPage(), null);
NavDrawerFragment.saveLastNavFragment(this, UserPreferences.getBackButtonGoToPage());
}
break;
default: super.onBackPressed();

View File

@ -76,9 +76,9 @@ public class AddFeedFragment extends Fragment {
EditText editText = content.findViewById(R.id.text);
editText.setHint(R.string.add_podcast_by_url_hint);
ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
String clipboardContent = clipboard.getText().toString();
if (clipboardContent.startsWith("http")) {
editText.setText(clipboardContent);
String clipboardContent = clipboard.getText() != null ? clipboard.getText().toString() : "";
if (clipboardContent.trim().startsWith("http")) {
editText.setText(clipboardContent.trim());
}
builder.setView(content);
builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> addUrl(editText.getText().toString()));

View File

@ -192,7 +192,7 @@ public class NavDrawerFragment extends Fragment implements AdapterView.OnItemCli
} else {
showMainActivity(EpisodesFragment.TAG);
}
saveLastNavFragment(EpisodesFragment.TAG);
saveLastNavFragment(getContext(), EpisodesFragment.TAG);
}
}
};
@ -371,7 +371,7 @@ public class NavDrawerFragment extends Fragment implements AdapterView.OnItemCli
} else {
showMainActivity(tag);
}
saveLastNavFragment(tag);
saveLastNavFragment(getContext(), tag);
} else {
int pos = position - navAdapter.getSubscriptionOffset();
long feedId = navDrawerData.feeds.get(pos).getId();
@ -382,7 +382,7 @@ public class NavDrawerFragment extends Fragment implements AdapterView.OnItemCli
intent.putExtra(MainActivity.EXTRA_FEED_ID, feedId);
startActivity(intent);
}
saveLastNavFragment(String.valueOf(feedId));
saveLastNavFragment(getContext(), String.valueOf(feedId));
}
selectedNavListIndex = position;
navAdapter.notifyDataSetChanged();
@ -400,9 +400,9 @@ public class NavDrawerFragment extends Fragment implements AdapterView.OnItemCli
}
}
private void saveLastNavFragment(String tag) {
public static void saveLastNavFragment(Context context, String tag) {
Log.d(TAG, "saveLastNavFragment(tag: " + tag + ")");
SharedPreferences prefs = getContext().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
SharedPreferences prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor edit = prefs.edit();
if (tag != null) {
edit.putString(PREF_LAST_FRAGMENT_TAG, tag);