mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
commit
2b5b69beae
24 changed files with 666 additions and 645 deletions
|
@ -8,7 +8,7 @@ buildscript {
|
|||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.6.3'
|
||||
classpath 'com.android.tools.build:gradle:4.0.0'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@ dependencies {
|
|||
implementation 'com.android.support:support-core-utils:28.0.0'
|
||||
implementation 'com.android.support:support-fragment:28.0.0'
|
||||
implementation 'com.android.support:support-core-ui:28.0.0'
|
||||
implementation 'com.jakewharton:butterknife:7.0.1'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.12.12'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
implementation 'com.android.support:recyclerview-v7:28.0.0'
|
||||
|
@ -45,9 +44,7 @@ android {
|
|||
compileOptions.with {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
}
|
||||
|
||||
// force old processing behaviour that butterknife 7 depends on, until we can afford to upgrade
|
||||
android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true
|
||||
viewBinding.enabled = true
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
|
|
|
@ -11,16 +11,6 @@
|
|||
-dontwarn okhttp3.**
|
||||
-dontnote okhttp3.**
|
||||
|
||||
-keep class butterknife.** { *; }
|
||||
-dontwarn butterknife.internal.**
|
||||
-keep class **$$ViewBinder { *; }
|
||||
-keepclasseswithmembernames class * {
|
||||
@butterknife.* <fields>;
|
||||
}
|
||||
-keepclasseswithmembernames class * {
|
||||
@butterknife.* <methods>;
|
||||
}
|
||||
|
||||
# these two seem to confuse ProGuard, so force keep them
|
||||
-keep class com.newsblur.util.StateFilter { *; }
|
||||
-keep class com.newsblur.view.StateToggleButton$StateChangedListener { *; }
|
||||
|
|
|
@ -5,32 +5,27 @@ import android.net.Uri;
|
|||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.databinding.ActivityAddfeedexternalBinding;
|
||||
import com.newsblur.fragment.AddFeedFragment;
|
||||
import com.newsblur.util.UIUtils;
|
||||
import com.newsblur.util.ViewUtils;
|
||||
import com.newsblur.view.ProgressThrobber;
|
||||
|
||||
public class AddFeedExternal extends NbActivity implements AddFeedFragment.AddFeedProgressListener {
|
||||
|
||||
@Bind(R.id.loading_throb) ProgressThrobber progressView;
|
||||
@Bind(R.id.progress_text) TextView progressText;
|
||||
private ActivityAddfeedexternalBinding binding;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityAddfeedexternalBinding.inflate(getLayoutInflater());
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
setContentView(R.layout.activity_addfeedexternal);
|
||||
ButterKnife.bind(this);
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
progressView.setEnabled(!ViewUtils.isPowerSaveMode(this));
|
||||
progressView.setColors(UIUtils.getColor(this, R.color.refresh_1),
|
||||
binding.loadingThrob.setEnabled(!ViewUtils.isPowerSaveMode(this));
|
||||
binding.loadingThrob.setColors(UIUtils.getColor(this, R.color.refresh_1),
|
||||
UIUtils.getColor(this, R.color.refresh_2),
|
||||
UIUtils.getColor(this, R.color.refresh_3),
|
||||
UIUtils.getColor(this, R.color.refresh_4));
|
||||
|
@ -48,9 +43,9 @@ public class AddFeedExternal extends NbActivity implements AddFeedFragment.AddFe
|
|||
public void addFeedStarted() {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
progressText.setText(R.string.adding_feed_progress);
|
||||
progressText.setVisibility(View.VISIBLE);
|
||||
progressView.setVisibility(View.VISIBLE);
|
||||
binding.progressText.setText(R.string.adding_feed_progress);
|
||||
binding.progressText.setVisibility(View.VISIBLE);
|
||||
binding.loadingThrob.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -10,15 +10,11 @@ import android.view.MenuInflater;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnKeyListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.databinding.ActivityItemslistBinding;
|
||||
import com.newsblur.fragment.ItemSetFragment;
|
||||
import com.newsblur.fragment.ReadFilterDialogFragment;
|
||||
import com.newsblur.fragment.SaveSearchFragment;
|
||||
|
@ -47,10 +43,9 @@ public abstract class ItemsList extends NbActivity implements StoryOrderChangedL
|
|||
private static final String READ_FILTER = "readFilter";
|
||||
private static final String DEFAULT_FEED_VIEW = "defaultFeedView";
|
||||
private static final String BUNDLE_ACTIVE_SEARCH_QUERY = "activeSearchQuery";
|
||||
private ActivityItemslistBinding binding;
|
||||
|
||||
protected ItemSetFragment itemSetFragment;
|
||||
@Bind(R.id.itemlist_sync_status) TextView overlayStatusText;
|
||||
@Bind(R.id.itemlist_search_query) EditText searchQueryInput;
|
||||
protected StateFilter intelState;
|
||||
|
||||
protected FeedSet fs;
|
||||
|
@ -80,8 +75,8 @@ public abstract class ItemsList extends NbActivity implements StoryOrderChangedL
|
|||
|
||||
getWindow().setBackgroundDrawableResource(android.R.color.transparent);
|
||||
|
||||
setContentView(R.layout.activity_itemslist);
|
||||
ButterKnife.bind(this);
|
||||
binding = ActivityItemslistBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
itemSetFragment = (ItemSetFragment) fragmentManager.findFragmentByTag(ItemSetFragment.class.getName());
|
||||
|
@ -100,16 +95,16 @@ public abstract class ItemsList extends NbActivity implements StoryOrderChangedL
|
|||
activeSearchQuery = fs.getSearchQuery();
|
||||
}
|
||||
if (activeSearchQuery != null) {
|
||||
searchQueryInput.setText(activeSearchQuery);
|
||||
searchQueryInput.setVisibility(View.VISIBLE);
|
||||
binding.itemlistSearchQuery.setText(activeSearchQuery);
|
||||
binding.itemlistSearchQuery.setVisibility(View.VISIBLE);
|
||||
fs.setSearchQuery(activeSearchQuery);
|
||||
}
|
||||
|
||||
searchQueryInput.setOnKeyListener(new OnKeyListener() {
|
||||
binding.itemlistSearchQuery.setOnKeyListener(new OnKeyListener() {
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
if ((keyCode == KeyEvent.KEYCODE_BACK) && (event.getAction() == KeyEvent.ACTION_DOWN)) {
|
||||
searchQueryInput.setVisibility(View.GONE);
|
||||
searchQueryInput.setText("");
|
||||
binding.itemlistSearchQuery.setVisibility(View.GONE);
|
||||
binding.itemlistSearchQuery.setText("");
|
||||
checkSearchQuery();
|
||||
return true;
|
||||
}
|
||||
|
@ -125,8 +120,8 @@ public abstract class ItemsList extends NbActivity implements StoryOrderChangedL
|
|||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
if (searchQueryInput != null) {
|
||||
String q = searchQueryInput.getText().toString().trim();
|
||||
if (binding.itemlistSearchQuery != null) {
|
||||
String q = binding.itemlistSearchQuery.getText().toString().trim();
|
||||
if (q.length() > 0) {
|
||||
outState.putString(BUNDLE_ACTIVE_SEARCH_QUERY, q);
|
||||
}
|
||||
|
@ -229,7 +224,7 @@ public abstract class ItemsList extends NbActivity implements StoryOrderChangedL
|
|||
menu.findItem(R.id.menu_theme_black).setChecked(true);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(searchQueryInput.getText())) {
|
||||
if (!TextUtils.isEmpty(binding.itemlistSearchQuery.getText())) {
|
||||
menu.findItem(R.id.menu_save_search).setVisible(true);
|
||||
} else {
|
||||
menu.findItem(R.id.menu_save_search).setVisible(false);
|
||||
|
@ -261,11 +256,11 @@ public abstract class ItemsList extends NbActivity implements StoryOrderChangedL
|
|||
textSize.show(getSupportFragmentManager(), TextSizeDialogFragment.class.getName());
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_search_stories) {
|
||||
if (searchQueryInput.getVisibility() != View.VISIBLE) {
|
||||
searchQueryInput.setVisibility(View.VISIBLE);
|
||||
searchQueryInput.requestFocus();
|
||||
if (binding.itemlistSearchQuery.getVisibility() != View.VISIBLE) {
|
||||
binding.itemlistSearchQuery.setVisibility(View.VISIBLE);
|
||||
binding.itemlistSearchQuery.requestFocus();
|
||||
} else {
|
||||
searchQueryInput.setVisibility(View.GONE);
|
||||
binding.itemlistSearchQuery.setVisibility(View.GONE);
|
||||
checkSearchQuery();
|
||||
}
|
||||
} else if (item.getItemId() == R.id.menu_theme_light) {
|
||||
|
@ -293,7 +288,7 @@ public abstract class ItemsList extends NbActivity implements StoryOrderChangedL
|
|||
if (item.getItemId() == R.id.menu_save_search) {
|
||||
String feedId = getSaveSearchFeedId();
|
||||
if (feedId != null) {
|
||||
String query = searchQueryInput.getText().toString();
|
||||
String query = binding.itemlistSearchQuery.getText().toString();
|
||||
SaveSearchFragment frag = SaveSearchFragment.newInstance(feedId, query);
|
||||
frag.show(getSupportFragmentManager(), SaveSearchFragment.class.getName());
|
||||
}
|
||||
|
@ -334,23 +329,23 @@ public abstract class ItemsList extends NbActivity implements StoryOrderChangedL
|
|||
}
|
||||
|
||||
private void updateStatusIndicators() {
|
||||
if (overlayStatusText != null) {
|
||||
if (binding.itemlistSyncStatus != null) {
|
||||
String syncStatus = NBSyncService.getSyncStatusMessage(this, true);
|
||||
if (syncStatus != null) {
|
||||
if (AppConstants.VERBOSE_LOG) {
|
||||
syncStatus = syncStatus + UIUtils.getMemoryUsageDebug(this);
|
||||
}
|
||||
overlayStatusText.setText(syncStatus);
|
||||
overlayStatusText.setVisibility(View.VISIBLE);
|
||||
binding.itemlistSyncStatus.setText(syncStatus);
|
||||
binding.itemlistSyncStatus.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
overlayStatusText.setVisibility(View.GONE);
|
||||
binding.itemlistSyncStatus.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkSearchQuery() {
|
||||
String oldQuery = fs.getSearchQuery();
|
||||
String q = searchQueryInput.getText().toString().trim();
|
||||
String q = binding.itemlistSearchQuery.getText().toString().trim();
|
||||
if (q.length() < 1) {
|
||||
q = null;
|
||||
}
|
||||
|
|
|
@ -17,19 +17,12 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.View.OnKeyListener;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.databinding.ActivityMainBinding;
|
||||
import com.newsblur.fragment.FeedIntelligenceSelectorFragment;
|
||||
import com.newsblur.fragment.FolderListFragment;
|
||||
import com.newsblur.fragment.LoginAsDialogFragment;
|
||||
|
@ -54,15 +47,7 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
private FragmentManager fragmentManager;
|
||||
private SwipeRefreshLayout swipeLayout;
|
||||
private boolean wasSwipeEnabled = false;
|
||||
@Bind(R.id.main_sync_status) TextView overlayStatusText;
|
||||
@Bind(R.id.empty_view_image) ImageView emptyViewImage;
|
||||
@Bind(R.id.empty_view_text) TextView emptyViewText;
|
||||
@Bind(R.id.main_menu_button) Button menuButton;
|
||||
@Bind(R.id.main_user_image) ImageView userImage;
|
||||
@Bind(R.id.main_user_name) TextView userName;
|
||||
@Bind(R.id.main_unread_count_neut_text) TextView unreadCountNeutText;
|
||||
@Bind(R.id.main_unread_count_posi_text) TextView unreadCountPosiText;
|
||||
@Bind(R.id.feedlist_search_query) EditText searchQueryInput;
|
||||
private ActivityMainBinding binding;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -70,16 +55,15 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setBackgroundDrawableResource(android.R.color.transparent);
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
ButterKnife.bind(this);
|
||||
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
getActionBar().hide();
|
||||
|
||||
// set the status bar to an generic loading message when the activity is first created so
|
||||
// that something is displayed while the service warms up
|
||||
overlayStatusText.setText(R.string.loading);
|
||||
overlayStatusText.setVisibility(View.VISIBLE);
|
||||
binding.mainSyncStatus.setText(R.string.loading);
|
||||
binding.mainSyncStatus.setVisibility(View.VISIBLE);
|
||||
|
||||
swipeLayout = (SwipeRefreshLayout)findViewById(R.id.swipe_container);
|
||||
swipeLayout.setColorSchemeResources(R.color.refresh_1, R.color.refresh_2, R.color.refresh_3, R.color.refresh_4);
|
||||
|
@ -97,25 +81,25 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
Bitmap userPicture = PrefsUtils.getUserImage(this);
|
||||
if (userPicture != null) {
|
||||
userPicture = UIUtils.clipAndRound(userPicture, 5, false);
|
||||
userImage.setImageBitmap(userPicture);
|
||||
binding.mainUserImage.setImageBitmap(userPicture);
|
||||
}
|
||||
userName.setText(PrefsUtils.getUserDetails(this).username);
|
||||
searchQueryInput.setOnKeyListener(new OnKeyListener() {
|
||||
binding.mainUserName.setText(PrefsUtils.getUserDetails(this).username);
|
||||
binding.feedlistSearchQuery.setOnKeyListener(new OnKeyListener() {
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
if ((keyCode == KeyEvent.KEYCODE_BACK) && (event.getAction() == KeyEvent.ACTION_DOWN)) {
|
||||
searchQueryInput.setVisibility(View.GONE);
|
||||
searchQueryInput.setText("");
|
||||
binding.feedlistSearchQuery.setVisibility(View.GONE);
|
||||
binding.feedlistSearchQuery.setText("");
|
||||
checkSearchQuery();
|
||||
return true;
|
||||
}
|
||||
if ((keyCode == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN)) {
|
||||
checkSearchQuery();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
searchQueryInput.addTextChangedListener(new TextWatcher() {
|
||||
binding.feedlistSearchQuery.addTextChangedListener(new TextWatcher() {
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
checkSearchQuery();
|
||||
}
|
||||
|
@ -124,6 +108,31 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
});
|
||||
|
||||
FeedUtils.currentFolderName = null;
|
||||
|
||||
binding.mainMenuButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onClickMenuButton();
|
||||
}
|
||||
});
|
||||
binding.mainAddButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onClickAddButton();
|
||||
}
|
||||
});
|
||||
binding.mainProfileButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onClickProfileButton();
|
||||
}
|
||||
});
|
||||
binding.mainUserImage.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onClickUserButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -149,8 +158,8 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
}
|
||||
|
||||
if (folderFeedList.getSearchQuery() != null) {
|
||||
searchQueryInput.setText(folderFeedList.getSearchQuery());
|
||||
searchQueryInput.setVisibility(View.VISIBLE);
|
||||
binding.feedlistSearchQuery.setText(folderFeedList.getSearchQuery());
|
||||
binding.feedlistSearchQuery.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
// triggerSync() might not actually do enough to push a UI update if background sync has been
|
||||
|
@ -172,8 +181,8 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
if ( !( (state == StateFilter.ALL) ||
|
||||
(state == StateFilter.SOME) ||
|
||||
(state == StateFilter.BEST) ) ) {
|
||||
searchQueryInput.setText("");
|
||||
searchQueryInput.setVisibility(View.GONE);
|
||||
binding.feedlistSearchQuery.setText("");
|
||||
binding.feedlistSearchQuery.setVisibility(View.GONE);
|
||||
checkSearchQuery();
|
||||
}
|
||||
|
||||
|
@ -201,8 +210,8 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
}
|
||||
|
||||
public void updateUnreadCounts(int neutCount, int posiCount) {
|
||||
unreadCountNeutText.setText(Integer.toString(neutCount));
|
||||
unreadCountPosiText.setText(Integer.toString(posiCount));
|
||||
binding.mainUnreadCountNeutText.setText(Integer.toString(neutCount));
|
||||
binding.mainUnreadCountPosiText.setText(Integer.toString(posiCount));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -213,22 +222,22 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
public void updateFeedCount(int feedCount) {
|
||||
if (feedCount < 1 ) {
|
||||
if (NBSyncService.isFeedCountSyncRunning() || (!folderFeedList.firstCursorSeenYet)) {
|
||||
emptyViewImage.setVisibility(View.INVISIBLE);
|
||||
emptyViewText.setVisibility(View.INVISIBLE);
|
||||
binding.emptyViewImage.setVisibility(View.INVISIBLE);
|
||||
binding.emptyViewText.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
emptyViewImage.setVisibility(View.VISIBLE);
|
||||
binding.emptyViewImage.setVisibility(View.VISIBLE);
|
||||
if (folderFeedList.currentState == StateFilter.BEST) {
|
||||
emptyViewText.setText(R.string.empty_list_view_no_focus_stories);
|
||||
binding.emptyViewText.setText(R.string.empty_list_view_no_focus_stories);
|
||||
} else if (folderFeedList.currentState == StateFilter.SAVED) {
|
||||
emptyViewText.setText(R.string.empty_list_view_no_saved_stories);
|
||||
binding.emptyViewText.setText(R.string.empty_list_view_no_saved_stories);
|
||||
} else {
|
||||
emptyViewText.setText(R.string.empty_list_view_no_unread_stories);
|
||||
binding.emptyViewText.setText(R.string.empty_list_view_no_unread_stories);
|
||||
}
|
||||
emptyViewText.setVisibility(View.VISIBLE);
|
||||
binding.emptyViewText.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
emptyViewImage.setVisibility(View.INVISIBLE);
|
||||
emptyViewText.setVisibility(View.INVISIBLE);
|
||||
binding.emptyViewImage.setVisibility(View.INVISIBLE);
|
||||
binding.emptyViewText.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,16 +248,16 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
swipeLayout.setRefreshing(false);
|
||||
}
|
||||
|
||||
if (overlayStatusText != null) {
|
||||
if (binding.mainSyncStatus != null) {
|
||||
String syncStatus = NBSyncService.getSyncStatusMessage(this, false);
|
||||
if (syncStatus != null) {
|
||||
if (AppConstants.VERBOSE_LOG) {
|
||||
syncStatus = syncStatus + UIUtils.getMemoryUsageDebug(this);
|
||||
}
|
||||
overlayStatusText.setText(syncStatus);
|
||||
overlayStatusText.setVisibility(View.VISIBLE);
|
||||
binding.mainSyncStatus.setText(syncStatus);
|
||||
binding.mainSyncStatus.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
overlayStatusText.setVisibility(View.GONE);
|
||||
binding.mainSyncStatus.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -260,8 +269,8 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
folderFeedList.clearRecents();
|
||||
}
|
||||
|
||||
@OnClick(R.id.main_menu_button) void onClickMenuButton() {
|
||||
PopupMenu pm = new PopupMenu(this, menuButton);
|
||||
private void onClickMenuButton() {
|
||||
PopupMenu pm = new PopupMenu(this, binding.mainMenuButton);
|
||||
Menu menu = pm.getMenu();
|
||||
pm.getMenuInflater().inflate(R.menu.main, menu);
|
||||
|
||||
|
@ -308,12 +317,12 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
onRefresh();
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_search_feeds) {
|
||||
if (searchQueryInput.getVisibility() != View.VISIBLE) {
|
||||
searchQueryInput.setVisibility(View.VISIBLE);
|
||||
searchQueryInput.requestFocus();
|
||||
if (binding.feedlistSearchQuery.getVisibility() != View.VISIBLE) {
|
||||
binding.feedlistSearchQuery.setVisibility(View.VISIBLE);
|
||||
binding.feedlistSearchQuery.requestFocus();
|
||||
} else {
|
||||
searchQueryInput.setText("");
|
||||
searchQueryInput.setVisibility(View.GONE);
|
||||
binding.feedlistSearchQuery.setText("");
|
||||
binding.feedlistSearchQuery.setVisibility(View.GONE);
|
||||
checkSearchQuery();
|
||||
}
|
||||
} else if (item.getItemId() == R.id.menu_add_feed) {
|
||||
|
@ -364,17 +373,17 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
return false;
|
||||
}
|
||||
|
||||
@OnClick(R.id.main_add_button) void onClickAddButton() {
|
||||
private void onClickAddButton() {
|
||||
Intent i = new Intent(this, SearchForFeeds.class);
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
@OnClick(R.id.main_profile_button) void onClickProfileButton() {
|
||||
private void onClickProfileButton() {
|
||||
Intent i = new Intent(this, Profile.class);
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
@OnClick(R.id.main_user_image) void onClickUserButton() {
|
||||
private void onClickUserButton() {
|
||||
Intent i = new Intent(this, Profile.class);
|
||||
startActivity(i);
|
||||
}
|
||||
|
@ -404,7 +413,7 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
}
|
||||
|
||||
private void checkSearchQuery() {
|
||||
String q = searchQueryInput.getText().toString().trim();
|
||||
String q = binding.feedlistSearchQuery.getText().toString().trim();
|
||||
if (q.length() < 1) {
|
||||
q = null;
|
||||
}
|
||||
|
|
|
@ -19,18 +19,14 @@ import android.view.Menu;
|
|||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.database.ReadingAdapter;
|
||||
import com.newsblur.databinding.ActivityReadingBinding;
|
||||
import com.newsblur.domain.Story;
|
||||
import com.newsblur.fragment.ReadingItemFragment;
|
||||
import com.newsblur.fragment.ReadingPagerFragment;
|
||||
|
@ -77,16 +73,7 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
|
|||
protected final Object STORIES_MUTEX = new Object();
|
||||
protected Cursor stories;
|
||||
|
||||
@Bind(android.R.id.content) View contentView; // we use this a ton, so cache it
|
||||
@Bind(R.id.reading_overlay_left) Button overlayLeft;
|
||||
@Bind(R.id.reading_overlay_right) Button overlayRight;
|
||||
@Bind(R.id.reading_overlay_progress) ProgressBar overlayProgress;
|
||||
@Bind(R.id.reading_overlay_progress_right) ProgressBar overlayProgressRight;
|
||||
@Bind(R.id.reading_overlay_progress_left) ProgressBar overlayProgressLeft;
|
||||
@Bind(R.id.reading_overlay_text) Button overlayText;
|
||||
@Bind(R.id.reading_overlay_send) Button overlaySend;
|
||||
@Bind(R.id.reading_empty_view_text) View emptyViewText;
|
||||
@Bind(R.id.reading_sync_status) TextView overlayStatusText;
|
||||
private View contentView; // we use this a ton, so cache it
|
||||
|
||||
ViewPager pager;
|
||||
ReadingPagerFragment readingFragment;
|
||||
|
@ -109,6 +96,8 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
|
|||
|
||||
private VolumeKeyNavigation volumeKeyNavigation;
|
||||
|
||||
private ActivityReadingBinding binding;
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
|
@ -119,8 +108,9 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
|
|||
protected void onCreate(Bundle savedInstanceBundle) {
|
||||
super.onCreate(savedInstanceBundle);
|
||||
|
||||
setContentView(R.layout.activity_reading);
|
||||
ButterKnife.bind(this);
|
||||
binding = ActivityReadingBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
contentView = findViewById(android.R.id.content);
|
||||
|
||||
try {
|
||||
fs = (FeedSet)getIntent().getSerializableExtra(EXTRA_FEEDSET);
|
||||
|
@ -167,17 +157,17 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
|
|||
|
||||
this.pageHistory = new ArrayList<Story>();
|
||||
|
||||
ViewUtils.setViewElevation(overlayLeft, OVERLAY_ELEVATION_DP);
|
||||
ViewUtils.setViewElevation(overlayRight, OVERLAY_ELEVATION_DP);
|
||||
ViewUtils.setViewElevation(overlayText, OVERLAY_ELEVATION_DP);
|
||||
ViewUtils.setViewElevation(overlaySend, OVERLAY_ELEVATION_DP);
|
||||
ViewUtils.setViewElevation(overlayProgress, OVERLAY_ELEVATION_DP);
|
||||
ViewUtils.setViewElevation(overlayProgressLeft, OVERLAY_ELEVATION_DP);
|
||||
ViewUtils.setViewElevation(overlayProgressRight, OVERLAY_ELEVATION_DP);
|
||||
ViewUtils.setViewElevation(binding.readingOverlayLeft, OVERLAY_ELEVATION_DP);
|
||||
ViewUtils.setViewElevation(binding.readingOverlayRight, OVERLAY_ELEVATION_DP);
|
||||
ViewUtils.setViewElevation(binding.readingOverlayText, OVERLAY_ELEVATION_DP);
|
||||
ViewUtils.setViewElevation(binding.readingOverlaySend, OVERLAY_ELEVATION_DP);
|
||||
ViewUtils.setViewElevation(binding.readingOverlayProgress, OVERLAY_ELEVATION_DP);
|
||||
ViewUtils.setViewElevation(binding.readingOverlayProgressLeft, OVERLAY_ELEVATION_DP);
|
||||
ViewUtils.setViewElevation(binding.readingOverlayProgressRight, OVERLAY_ELEVATION_DP);
|
||||
|
||||
// this likes to default to 'on' for some platforms
|
||||
enableProgressCircle(overlayProgressLeft, false);
|
||||
enableProgressCircle(overlayProgressRight, false);
|
||||
enableProgressCircle(binding.readingOverlayProgressLeft, false);
|
||||
enableProgressCircle(binding.readingOverlayProgressRight, false);
|
||||
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
ReadingPagerFragment fragment = (ReadingPagerFragment) fragmentManager.findFragmentByTag(ReadingPagerFragment.class.getName());
|
||||
|
@ -312,7 +302,7 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
|
|||
this.onPageSelected(position);
|
||||
// now that the pager is getting the right story, make it visible
|
||||
pager.setVisibility(View.VISIBLE);
|
||||
emptyViewText.setVisibility(View.INVISIBLE);
|
||||
binding.readingEmptyViewText.setVisibility(View.INVISIBLE);
|
||||
storyHash = null;
|
||||
return;
|
||||
}
|
||||
|
@ -405,16 +395,16 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
|
|||
}
|
||||
if ((updateType & UPDATE_STATUS) != 0) {
|
||||
enableMainProgress(NBSyncService.isFeedSetSyncing(this.fs, this));
|
||||
if (overlayStatusText != null) {
|
||||
if (binding.readingSyncStatus != null) {
|
||||
String syncStatus = NBSyncService.getSyncStatusMessage(this, true);
|
||||
if (syncStatus != null) {
|
||||
if (AppConstants.VERBOSE_LOG) {
|
||||
syncStatus = syncStatus + UIUtils.getMemoryUsageDebug(this);
|
||||
}
|
||||
overlayStatusText.setText(syncStatus);
|
||||
overlayStatusText.setVisibility(View.VISIBLE);
|
||||
binding.readingSyncStatus.setText(syncStatus);
|
||||
binding.readingSyncStatus.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
overlayStatusText.setVisibility(View.GONE);
|
||||
binding.readingSyncStatus.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -516,11 +506,11 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
|
|||
final boolean _overflowExtras = overflowExtras;
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
UIUtils.setViewAlpha(overlayLeft, a, true);
|
||||
UIUtils.setViewAlpha(overlayRight, a, true);
|
||||
UIUtils.setViewAlpha(overlayProgress, a, true);
|
||||
UIUtils.setViewAlpha(overlayText, a, true);
|
||||
UIUtils.setViewAlpha(overlaySend, a, !_overflowExtras);
|
||||
UIUtils.setViewAlpha(binding.readingOverlayLeft, a, true);
|
||||
UIUtils.setViewAlpha(binding.readingOverlayRight, a, true);
|
||||
UIUtils.setViewAlpha(binding.readingOverlayProgress, a, true);
|
||||
UIUtils.setViewAlpha(binding.readingOverlayText, a, true);
|
||||
UIUtils.setViewAlpha(binding.readingOverlaySend, a, !_overflowExtras);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -544,40 +534,40 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
|
|||
if (currentUnreadCount > this.startingUnreadCount ) {
|
||||
this.startingUnreadCount = currentUnreadCount;
|
||||
}
|
||||
this.overlayLeft.setEnabled(this.getLastReadPosition(false) != -1);
|
||||
this.overlayRight.setText((currentUnreadCount > 0) ? R.string.overlay_next : R.string.overlay_done);
|
||||
this.binding.readingOverlayLeft.setEnabled(this.getLastReadPosition(false) != -1);
|
||||
this.binding.readingOverlayRight.setText((currentUnreadCount > 0) ? R.string.overlay_next : R.string.overlay_done);
|
||||
if (currentUnreadCount > 0) {
|
||||
this.overlayRight.setBackgroundResource(UIUtils.getThemedResource(this, R.attr.selectorOverlayBackgroundRight, android.R.attr.background));
|
||||
this.binding.readingOverlayRight.setBackgroundResource(UIUtils.getThemedResource(this, R.attr.selectorOverlayBackgroundRight, android.R.attr.background));
|
||||
} else {
|
||||
this.overlayRight.setBackgroundResource(UIUtils.getThemedResource(this, R.attr.selectorOverlayBackgroundRightDone, android.R.attr.background));
|
||||
this.binding.readingOverlayRight.setBackgroundResource(UIUtils.getThemedResource(this, R.attr.selectorOverlayBackgroundRightDone, android.R.attr.background));
|
||||
}
|
||||
|
||||
if (this.startingUnreadCount == 0 ) {
|
||||
// sessions with no unreads just show a full progress bar
|
||||
this.overlayProgress.setMax(1);
|
||||
this.overlayProgress.setProgress(1);
|
||||
this.binding.readingOverlayProgress.setMax(1);
|
||||
this.binding.readingOverlayProgress.setProgress(1);
|
||||
} else {
|
||||
int unreadProgress = this.startingUnreadCount - currentUnreadCount;
|
||||
this.overlayProgress.setMax(this.startingUnreadCount);
|
||||
this.overlayProgress.setProgress(unreadProgress);
|
||||
this.binding.readingOverlayProgress.setMax(this.startingUnreadCount);
|
||||
this.binding.readingOverlayProgress.setProgress(unreadProgress);
|
||||
}
|
||||
this.overlayProgress.invalidate();
|
||||
this.binding.readingOverlayProgress.invalidate();
|
||||
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
private void updateOverlayText() {
|
||||
if (overlayText == null) return;
|
||||
if (binding.readingOverlayText == null) return;
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
ReadingItemFragment item = getReadingFragment();
|
||||
if (item == null) return;
|
||||
if (item.getSelectedViewMode() == DefaultFeedView.STORY) {
|
||||
overlayText.setBackgroundResource(UIUtils.getThemedResource(Reading.this, R.attr.selectorOverlayBackgroundText, android.R.attr.background));
|
||||
overlayText.setText(R.string.overlay_text);
|
||||
binding.readingOverlayText.setBackgroundResource(UIUtils.getThemedResource(Reading.this, R.attr.selectorOverlayBackgroundText, android.R.attr.background));
|
||||
binding.readingOverlayText.setText(R.string.overlay_text);
|
||||
} else {
|
||||
overlayText.setBackgroundResource(UIUtils.getThemedResource(Reading.this, R.attr.selectorOverlayBackgroundStory, android.R.attr.background));
|
||||
overlayText.setText(R.string.overlay_story);
|
||||
binding.readingOverlayText.setBackgroundResource(UIUtils.getThemedResource(Reading.this, R.attr.selectorOverlayBackgroundStory, android.R.attr.background));
|
||||
binding.readingOverlayText.setText(R.string.overlay_story);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -610,11 +600,11 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
|
|||
}
|
||||
|
||||
protected void enableMainProgress(boolean enabled) {
|
||||
enableProgressCircle(overlayProgressRight, enabled);
|
||||
enableProgressCircle(binding.readingOverlayProgressRight, enabled);
|
||||
}
|
||||
|
||||
public void enableLeftProgressCircle(boolean enabled) {
|
||||
enableProgressCircle(overlayProgressLeft, enabled);
|
||||
enableProgressCircle(binding.readingOverlayProgressLeft, enabled);
|
||||
}
|
||||
|
||||
private void enableProgressCircle(final ProgressBar view, final boolean enabled) {
|
||||
|
|
|
@ -9,10 +9,9 @@ import android.view.Menu;
|
|||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.databinding.ActivityWidgetConfigBinding;
|
||||
import com.newsblur.domain.Feed;
|
||||
import com.newsblur.domain.Folder;
|
||||
import com.newsblur.util.FeedOrderFilter;
|
||||
|
@ -31,28 +30,21 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class WidgetConfig extends NbActivity {
|
||||
|
||||
@Bind(R.id.list_view)
|
||||
ExpandableListView listView;
|
||||
@Bind(R.id.text_no_subscriptions)
|
||||
TextView textNoSubscriptions;
|
||||
|
||||
private WidgetConfigAdapter adapter;
|
||||
private ArrayList<Feed> feeds;
|
||||
private ArrayList<Folder> folders;
|
||||
private Map<String, Feed> feedMap = new HashMap<>();
|
||||
private ArrayList<String> folderNames = new ArrayList<>();
|
||||
private ArrayList<ArrayList<Feed>> folderChildren = new ArrayList<>();
|
||||
private ActivityWidgetConfigBinding binding;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_widget_config);
|
||||
ButterKnife.bind(this);
|
||||
binding = ActivityWidgetConfigBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setupList();
|
||||
loadFeeds();
|
||||
|
@ -164,7 +156,7 @@ public class WidgetConfig extends NbActivity {
|
|||
|
||||
private void setupList() {
|
||||
adapter = new WidgetConfigAdapter(this);
|
||||
listView.setAdapter(adapter);
|
||||
binding.listView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
private void loadFeeds() {
|
||||
|
@ -288,7 +280,7 @@ public class WidgetConfig extends NbActivity {
|
|||
private void setAdapterData() {
|
||||
adapter.setData(this.folderNames, this.folderChildren, this.feeds);
|
||||
|
||||
listView.setVisibility(this.feeds.isEmpty() ? View.GONE : View.VISIBLE);
|
||||
textNoSubscriptions.setVisibility(this.feeds.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
binding.listView.setVisibility(this.feeds.isEmpty() ? View.GONE : View.VISIBLE);
|
||||
binding.textNoSubscriptions.setVisibility(this.feeds.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package com.newsblur.database;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
|
@ -22,18 +21,13 @@ import android.widget.ImageView;
|
|||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.activity.FeedItemsList;
|
||||
import com.newsblur.activity.ItemsList;
|
||||
import com.newsblur.activity.NbActivity;
|
||||
import com.newsblur.domain.Story;
|
||||
import com.newsblur.domain.UserDetails;
|
||||
|
@ -313,16 +307,16 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
MenuItem.OnMenuItemClickListener,
|
||||
View.OnTouchListener {
|
||||
|
||||
@Bind(R.id.story_item_favicon_borderbar_1) View leftBarOne;
|
||||
@Bind(R.id.story_item_favicon_borderbar_2) View leftBarTwo;
|
||||
@Bind(R.id.story_item_inteldot) ImageView intelDot;
|
||||
@Bind(R.id.story_item_thumbnail) ImageView thumbView;
|
||||
@Bind(R.id.story_item_feedicon) ImageView feedIconView;
|
||||
@Bind(R.id.story_item_feedtitle) TextView feedTitleView;
|
||||
@Bind(R.id.story_item_title) TextView storyTitleView;
|
||||
@Bind(R.id.story_item_date) TextView storyDate;
|
||||
@Bind(R.id.story_item_saved_icon) View savedView;
|
||||
@Bind(R.id.story_item_shared_icon) View sharedView;
|
||||
View leftBarOne;
|
||||
View leftBarTwo;
|
||||
ImageView intelDot;
|
||||
ImageView thumbView;
|
||||
ImageView feedIconView;
|
||||
TextView feedTitleView;
|
||||
TextView storyTitleView;
|
||||
TextView storyDate;
|
||||
View savedView;
|
||||
View sharedView;
|
||||
|
||||
Story story;
|
||||
ImageLoader.PhotoToLoad thumbLoader;
|
||||
|
@ -332,9 +326,20 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
boolean gestureL2R = false;
|
||||
boolean gestureDebounce = false;
|
||||
|
||||
|
||||
public StoryViewHolder(View view) {
|
||||
super(view);
|
||||
ButterKnife.bind(StoryViewHolder.this, view);
|
||||
leftBarOne = view.findViewById(R.id.story_item_favicon_borderbar_1);
|
||||
leftBarTwo = view.findViewById(R.id.story_item_favicon_borderbar_2);
|
||||
intelDot = view.findViewById(R.id.story_item_inteldot);
|
||||
thumbView = view.findViewById(R.id.story_item_thumbnail);
|
||||
feedIconView = view.findViewById(R.id.story_item_feedicon);
|
||||
feedTitleView = view.findViewById(R.id.story_item_feedtitle);
|
||||
storyTitleView = view.findViewById(R.id.story_item_title);
|
||||
storyDate = view.findViewById(R.id.story_item_date);
|
||||
savedView = view.findViewById(R.id.story_item_saved_icon);
|
||||
sharedView = view.findViewById(R.id.story_item_shared_icon);
|
||||
|
||||
view.setOnClickListener(StoryViewHolder.this);
|
||||
view.setOnCreateContextMenuListener(StoryViewHolder.this);
|
||||
view.setOnTouchListener(StoryViewHolder.this);
|
||||
|
@ -472,10 +477,12 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
}
|
||||
|
||||
public class StoryRowViewHolder extends StoryViewHolder {
|
||||
@Bind(R.id.story_item_author) TextView storyAuthor;
|
||||
@Bind(R.id.story_item_content) TextView storySnippet;
|
||||
TextView storyAuthor;
|
||||
TextView storySnippet;
|
||||
public StoryRowViewHolder(View view) {
|
||||
super(view);
|
||||
storyAuthor = view.findViewById(R.id.story_item_author);
|
||||
storySnippet = view.findViewById(R.id.story_item_content);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -660,12 +667,13 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
}
|
||||
}
|
||||
|
||||
public class FooterViewHolder extends RecyclerView.ViewHolder {
|
||||
@Bind(R.id.footer_view_inner) FrameLayout innerView;
|
||||
public static class FooterViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
FrameLayout innerView;
|
||||
|
||||
public FooterViewHolder(View view) {
|
||||
super(view);
|
||||
ButterKnife.bind(FooterViewHolder.this, view);
|
||||
innerView = view.findViewById(R.id.footer_view_inner);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,12 +19,9 @@ import android.view.ViewGroup;
|
|||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.databinding.DialogChoosefoldersBinding;
|
||||
import com.newsblur.domain.Feed;
|
||||
import com.newsblur.domain.Folder;
|
||||
import com.newsblur.util.FeedUtils;
|
||||
|
@ -33,8 +30,6 @@ public class ChooseFoldersFragment extends DialogFragment {
|
|||
|
||||
private Feed feed;
|
||||
|
||||
@Bind(R.id.choose_folders_list) ListView listView;
|
||||
|
||||
public static ChooseFoldersFragment newInstance(Feed feed) {
|
||||
ChooseFoldersFragment fragment = new ChooseFoldersFragment();
|
||||
Bundle args = new Bundle();
|
||||
|
@ -62,7 +57,7 @@ public class ChooseFoldersFragment extends DialogFragment {
|
|||
final Activity activity = getActivity();
|
||||
LayoutInflater inflater = LayoutInflater.from(activity);
|
||||
View v = inflater.inflate(R.layout.dialog_choosefolders, null);
|
||||
ButterKnife.bind(this, v);
|
||||
DialogChoosefoldersBinding binding = DialogChoosefoldersBinding.bind(v);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle(String.format(getResources().getString(R.string.title_choose_folders), feed.title));
|
||||
|
@ -107,7 +102,7 @@ public class ChooseFoldersFragment extends DialogFragment {
|
|||
return v;
|
||||
}
|
||||
};
|
||||
listView.setAdapter(adapter);
|
||||
binding.chooseFoldersList.setAdapter(adapter);
|
||||
|
||||
Dialog dialog = builder.create();
|
||||
dialog.getWindow().getAttributes().gravity = Gravity.BOTTOM;
|
||||
|
|
|
@ -12,13 +12,10 @@ import android.support.v4.app.DialogFragment;
|
|||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.databinding.DialogTrainfeedBinding;
|
||||
import com.newsblur.domain.Classifier;
|
||||
import com.newsblur.domain.Feed;
|
||||
import com.newsblur.util.FeedSet;
|
||||
|
@ -30,14 +27,7 @@ public class FeedIntelTrainerFragment extends DialogFragment {
|
|||
private Feed feed;
|
||||
private FeedSet fs;
|
||||
private Classifier classifier;
|
||||
|
||||
@Bind(R.id.intel_title_header) TextView headerTitles;
|
||||
@Bind(R.id.intel_tag_header) TextView headerTags;
|
||||
@Bind(R.id.intel_author_header) TextView headerAuthor;
|
||||
@Bind(R.id.existing_title_intel_container) LinearLayout titleRowsContainer;
|
||||
@Bind(R.id.existing_tag_intel_container) LinearLayout tagRowsContainer;
|
||||
@Bind(R.id.existing_author_intel_container) LinearLayout authorRowsContainer;
|
||||
@Bind(R.id.existing_feed_intel_container) LinearLayout feedRowsContainer;
|
||||
private DialogTrainfeedBinding binding;
|
||||
|
||||
public static FeedIntelTrainerFragment newInstance(Feed feed, FeedSet fs) {
|
||||
FeedIntelTrainerFragment fragment = new FeedIntelTrainerFragment();
|
||||
|
@ -58,7 +48,7 @@ public class FeedIntelTrainerFragment extends DialogFragment {
|
|||
final Activity activity = getActivity();
|
||||
LayoutInflater inflater = LayoutInflater.from(activity);
|
||||
View v = inflater.inflate(R.layout.dialog_trainfeed, null);
|
||||
ButterKnife.bind(this, v);
|
||||
binding = DialogTrainfeedBinding.bind(v);
|
||||
|
||||
// display known title classifiers
|
||||
for (Map.Entry<String, Integer> rule : classifier.title.entrySet()) {
|
||||
|
@ -66,9 +56,9 @@ public class FeedIntelTrainerFragment extends DialogFragment {
|
|||
TextView label = (TextView) row.findViewById(R.id.intel_row_label);
|
||||
label.setText(rule.getKey());
|
||||
UIUtils.setupIntelDialogRow(row, classifier.title, rule.getKey());
|
||||
titleRowsContainer.addView(row);
|
||||
binding.existingTitleIntelContainer.addView(row);
|
||||
}
|
||||
if (classifier.title.size() < 1) headerTitles.setVisibility(View.GONE);
|
||||
if (classifier.title.size() < 1) binding.intelTitleHeader.setVisibility(View.GONE);
|
||||
|
||||
// get the list of suggested tags
|
||||
List<String> allTags = FeedUtils.dbHelper.getTagsForFeed(feed.feedId);
|
||||
|
@ -83,9 +73,9 @@ public class FeedIntelTrainerFragment extends DialogFragment {
|
|||
TextView label = (TextView) row.findViewById(R.id.intel_row_label);
|
||||
label.setText(tag);
|
||||
UIUtils.setupIntelDialogRow(row, classifier.tags, tag);
|
||||
tagRowsContainer.addView(row);
|
||||
binding.existingTagIntelContainer.addView(row);
|
||||
}
|
||||
if (allTags.size() < 1) headerTags.setVisibility(View.GONE);
|
||||
if (allTags.size() < 1) binding.intelTagHeader.setVisibility(View.GONE);
|
||||
|
||||
// get the list of suggested authors
|
||||
List<String> allAuthors = FeedUtils.dbHelper.getAuthorsForFeed(feed.feedId);
|
||||
|
@ -100,16 +90,16 @@ public class FeedIntelTrainerFragment extends DialogFragment {
|
|||
TextView labelAuthor = (TextView) rowAuthor.findViewById(R.id.intel_row_label);
|
||||
labelAuthor.setText(author);
|
||||
UIUtils.setupIntelDialogRow(rowAuthor, classifier.authors, author);
|
||||
authorRowsContainer.addView(rowAuthor);
|
||||
binding.existingAuthorIntelContainer.addView(rowAuthor);
|
||||
}
|
||||
if (allAuthors.size() < 1) headerAuthor.setVisibility(View.GONE);
|
||||
if (allAuthors.size() < 1) binding.intelAuthorHeader.setVisibility(View.GONE);
|
||||
|
||||
// for feel-level intel, the label is the title and the intel identifier is the feed ID
|
||||
View rowFeed = inflater.inflate(R.layout.include_intel_row, null);
|
||||
TextView labelFeed = (TextView) rowFeed.findViewById(R.id.intel_row_label);
|
||||
labelFeed.setText(feed.title);
|
||||
UIUtils.setupIntelDialogRow(rowFeed, classifier.feeds, feed.feedId);
|
||||
feedRowsContainer.addView(rowFeed);
|
||||
binding.existingFeedIntelContainer.addView(rowFeed);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle(R.string.feed_intel_dialog_title);
|
||||
|
|
|
@ -26,9 +26,6 @@ import android.widget.ExpandableListView.OnGroupClickListener;
|
|||
import android.widget.ExpandableListView.OnGroupCollapseListener;
|
||||
import android.widget.ExpandableListView.OnGroupExpandListener;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.activity.AllSharedStoriesItemsList;
|
||||
import com.newsblur.activity.AllStoriesItemsList;
|
||||
|
@ -43,6 +40,7 @@ import com.newsblur.activity.ReadStoriesItemsList;
|
|||
import com.newsblur.activity.SavedStoriesItemsList;
|
||||
import com.newsblur.activity.SocialFeedItemsList;
|
||||
import com.newsblur.database.FolderListAdapter;
|
||||
import com.newsblur.databinding.FragmentFolderfeedlistBinding;
|
||||
import com.newsblur.domain.Feed;
|
||||
import com.newsblur.domain.SavedSearch;
|
||||
import com.newsblur.domain.SocialFeed;
|
||||
|
@ -70,7 +68,7 @@ public class FolderListFragment extends NbFragment implements OnCreateContextMen
|
|||
private FolderListAdapter adapter;
|
||||
public StateFilter currentState = StateFilter.SOME;
|
||||
private SharedPreferences sharedPreferences;
|
||||
@Bind(R.id.folderfeed_list) ExpandableListView list;
|
||||
private FragmentFolderfeedlistBinding binding;
|
||||
public boolean firstCursorSeenYet = false;
|
||||
|
||||
// the two-step context menu for feeds requires us to temp store the feed long-pressed so
|
||||
|
@ -199,20 +197,20 @@ public class FolderListFragment extends NbFragment implements OnCreateContextMen
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.fragment_folderfeedlist, container);
|
||||
ButterKnife.bind(this, v);
|
||||
binding = FragmentFolderfeedlistBinding.bind(v);
|
||||
|
||||
list.setGroupIndicator(UIUtils.getDrawable(getActivity(), R.drawable.transparent));
|
||||
list.setOnCreateContextMenuListener(this);
|
||||
list.setOnChildClickListener(this);
|
||||
list.setOnGroupClickListener(this);
|
||||
list.setOnGroupCollapseListener(this);
|
||||
list.setOnGroupExpandListener(this);
|
||||
binding.folderfeedList.setGroupIndicator(UIUtils.getDrawable(getActivity(), R.drawable.transparent));
|
||||
binding.folderfeedList.setOnCreateContextMenuListener(this);
|
||||
binding.folderfeedList.setOnChildClickListener(this);
|
||||
binding.folderfeedList.setOnGroupClickListener(this);
|
||||
binding.folderfeedList.setOnGroupCollapseListener(this);
|
||||
binding.folderfeedList.setOnGroupExpandListener(this);
|
||||
|
||||
adapter.listBackref = new WeakReference(list); // see note in adapter about backref
|
||||
list.setAdapter(adapter);
|
||||
adapter.listBackref = new WeakReference(binding.folderfeedList); // see note in adapter about backref
|
||||
binding.folderfeedList.setAdapter(adapter);
|
||||
|
||||
// Main activity needs to listen for scrolls to prevent refresh from firing unnecessarily
|
||||
list.setOnScrollListener((android.widget.AbsListView.OnScrollListener) getActivity());
|
||||
binding.folderfeedList.setOnScrollListener((android.widget.AbsListView.OnScrollListener) getActivity());
|
||||
|
||||
return v;
|
||||
}
|
||||
|
@ -224,18 +222,18 @@ public class FolderListFragment extends NbFragment implements OnCreateContextMen
|
|||
*/
|
||||
public void checkOpenFolderPreferences() {
|
||||
// make sure we didn't beat construction
|
||||
if ((this.list == null) || (this.sharedPreferences == null)) return;
|
||||
if ((this.binding.folderfeedList == null) || (this.sharedPreferences == null)) return;
|
||||
|
||||
for (int i = 0; i < adapter.getGroupCount(); i++) {
|
||||
String flatGroupName = adapter.getGroupUniqueName(i);
|
||||
if (sharedPreferences.getBoolean(AppConstants.FOLDER_PRE + "_" + flatGroupName, true)) {
|
||||
if (list.isGroupExpanded(i) == false) {
|
||||
list.expandGroup(i);
|
||||
if (binding.folderfeedList.isGroupExpanded(i) == false) {
|
||||
binding.folderfeedList.expandGroup(i);
|
||||
adapter.setFolderClosed(flatGroupName, false);
|
||||
}
|
||||
} else {
|
||||
if (list.isGroupExpanded(i) == true) {
|
||||
list.collapseGroup(i);
|
||||
if (binding.folderfeedList.isGroupExpanded(i) == true) {
|
||||
binding.folderfeedList.collapseGroup(i);
|
||||
adapter.setFolderClosed(flatGroupName, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,22 @@
|
|||
package com.newsblur.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RadioButton;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.databinding.InfrequentCutoffDialogBinding;
|
||||
|
||||
public class InfrequentCutoffDialogFragment extends DialogFragment {
|
||||
|
||||
private static String CURRENT_CUTOFF = "currentCutoff";
|
||||
private int currentValue;
|
||||
@Bind(R.id.radio_5) RadioButton button5;
|
||||
@Bind(R.id.radio_15) RadioButton button15;
|
||||
@Bind(R.id.radio_30) RadioButton button30;
|
||||
@Bind(R.id.radio_60) RadioButton button60;
|
||||
@Bind(R.id.radio_90) RadioButton button90;
|
||||
private InfrequentCutoffDialogBinding binding;
|
||||
|
||||
public static InfrequentCutoffDialogFragment newInstance(int currentValue) {
|
||||
InfrequentCutoffDialogFragment dialog = new InfrequentCutoffDialogFragment();
|
||||
|
@ -42,13 +36,13 @@ public class InfrequentCutoffDialogFragment extends DialogFragment {
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||
currentValue = getArguments().getInt(CURRENT_CUTOFF);
|
||||
View v = inflater.inflate(R.layout.infrequent_cutoff_dialog, null);
|
||||
ButterKnife.bind(this, v);
|
||||
binding = InfrequentCutoffDialogBinding.bind(v);
|
||||
|
||||
button5.setChecked(currentValue == 5);
|
||||
button15.setChecked(currentValue == 15);
|
||||
button30.setChecked(currentValue == 30);
|
||||
button60.setChecked(currentValue == 60);
|
||||
button90.setChecked(currentValue == 90);
|
||||
binding.radio5.setChecked(currentValue == 5);
|
||||
binding.radio15.setChecked(currentValue == 15);
|
||||
binding.radio30.setChecked(currentValue == 30);
|
||||
binding.radio60.setChecked(currentValue == 60);
|
||||
binding.radio90.setChecked(currentValue == 90);
|
||||
|
||||
getDialog().setTitle(R.string.infrequent_choice_title);
|
||||
getDialog().getWindow().getAttributes().gravity = Gravity.BOTTOM;
|
||||
|
@ -56,31 +50,66 @@ public class InfrequentCutoffDialogFragment extends DialogFragment {
|
|||
return v;
|
||||
}
|
||||
|
||||
@OnClick(R.id.radio_5) void select5() {
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
binding.radio5.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
select5();
|
||||
}
|
||||
});
|
||||
binding.radio15.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
select15();
|
||||
}
|
||||
});
|
||||
binding.radio30.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
select30();
|
||||
}
|
||||
});
|
||||
binding.radio60.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
select60();
|
||||
}
|
||||
});
|
||||
binding.radio90.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
select90();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void select5() {
|
||||
if (currentValue != 5) {
|
||||
((InfrequentCutoffChangedListener) getActivity()).infrequentCutoffChanged(5);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
@OnClick(R.id.radio_15) void select15() {
|
||||
private void select15() {
|
||||
if (currentValue != 15) {
|
||||
((InfrequentCutoffChangedListener) getActivity()).infrequentCutoffChanged(15);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
@OnClick(R.id.radio_30) void select30() {
|
||||
private void select30() {
|
||||
if (currentValue != 30) {
|
||||
((InfrequentCutoffChangedListener) getActivity()).infrequentCutoffChanged(30);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
@OnClick(R.id.radio_60) void select60() {
|
||||
private void select60() {
|
||||
if (currentValue != 60) {
|
||||
((InfrequentCutoffChangedListener) getActivity()).infrequentCutoffChanged(60);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
@OnClick(R.id.radio_90) void select90() {
|
||||
private void select90() {
|
||||
if (currentValue != 90) {
|
||||
((InfrequentCutoffChangedListener) getActivity()).infrequentCutoffChanged(90);
|
||||
}
|
||||
|
|
|
@ -15,17 +15,13 @@ import android.view.MotionEvent;
|
|||
import android.view.View;
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.activity.ItemsList;
|
||||
import com.newsblur.activity.NbActivity;
|
||||
import com.newsblur.database.StoryViewAdapter;
|
||||
import com.newsblur.databinding.FragmentItemgridBinding;
|
||||
import com.newsblur.domain.Story;
|
||||
import com.newsblur.service.NBSyncService;
|
||||
import com.newsblur.util.FeedSet;
|
||||
|
@ -50,21 +46,17 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
private final static int GRID_SPACING_DP = 5;
|
||||
private int gridSpacingPx;
|
||||
|
||||
@Bind(R.id.itemgridfragment_grid) RecyclerView itemGrid;
|
||||
private GridLayoutManager layoutManager;
|
||||
private StoryViewAdapter adapter;
|
||||
// an optional pending scroll state to restore.
|
||||
private Parcelable gridState;
|
||||
|
||||
// loading indicator for when stories are absent or stale (at top of list)
|
||||
@Bind(R.id.top_loading_throb) ProgressThrobber topProgressView;
|
||||
// R.id.top_loading_throb
|
||||
|
||||
// loading indicator for when stories are present and fresh (at bottom of list)
|
||||
protected ProgressThrobber bottomProgressView;
|
||||
|
||||
@Bind(R.id.empty_view) View emptyView;
|
||||
@Bind(R.id.empty_view_text) TextView emptyViewText;
|
||||
@Bind(R.id.empty_view_image) ImageView emptyViewImage;
|
||||
|
||||
private View fleuronFooter;
|
||||
// the fleuron has padding that can't be calculated until after layout, but only changes
|
||||
// rarely thereafter
|
||||
|
@ -76,6 +68,8 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
public int indexOfLastUnread = -1;
|
||||
public boolean fullFlingComplete = false;
|
||||
|
||||
private FragmentItemgridBinding binding;
|
||||
|
||||
public static ItemSetFragment newInstance() {
|
||||
ItemSetFragment fragment = new ItemSetFragment();
|
||||
Bundle arguments = new Bundle();
|
||||
|
@ -123,13 +117,13 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.fragment_itemgrid, null);
|
||||
ButterKnife.bind(this, v);
|
||||
binding = FragmentItemgridBinding.bind(v);
|
||||
|
||||
// disable the throbbers if animations are going to have a zero time scale
|
||||
boolean isDisableAnimations = ViewUtils.isPowerSaveMode(getActivity());
|
||||
|
||||
topProgressView.setEnabled(!isDisableAnimations);
|
||||
topProgressView.setColors(UIUtils.getColor(getActivity(), R.color.refresh_1),
|
||||
binding.topLoadingThrob.setEnabled(!isDisableAnimations);
|
||||
binding.topLoadingThrob.setColors(UIUtils.getColor(getActivity(), R.color.refresh_1),
|
||||
UIUtils.getColor(getActivity(), R.color.refresh_2),
|
||||
UIUtils.getColor(getActivity(), R.color.refresh_3),
|
||||
UIUtils.getColor(getActivity(), R.color.refresh_4));
|
||||
|
@ -145,11 +139,11 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
fleuronFooter = inflater.inflate(R.layout.row_fleuron, null);
|
||||
fleuronFooter.setVisibility(View.INVISIBLE);
|
||||
|
||||
itemGrid.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
|
||||
binding.itemgridfragmentGrid.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
itemGridWidthPx = itemGrid.getMeasuredWidth();
|
||||
itemGrid.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
itemGridWidthPx = binding.itemgridfragmentGrid.getMeasuredWidth();
|
||||
binding.itemgridfragmentGrid.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
updateStyle();
|
||||
}
|
||||
});
|
||||
|
@ -158,11 +152,11 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
|
||||
calcColumnCount(listStyle);
|
||||
layoutManager = new GridLayoutManager(getActivity(), columnCount);
|
||||
itemGrid.setLayoutManager(layoutManager);
|
||||
binding.itemgridfragmentGrid.setLayoutManager(layoutManager);
|
||||
setupAnimSpeeds();
|
||||
|
||||
calcGridSpacing(listStyle);
|
||||
itemGrid.addItemDecoration(new RecyclerView.ItemDecoration() {
|
||||
binding.itemgridfragmentGrid.addItemDecoration(new RecyclerView.ItemDecoration() {
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
||||
outRect.set(gridSpacingPx, gridSpacingPx, gridSpacingPx, gridSpacingPx);
|
||||
|
@ -172,7 +166,7 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
adapter = new StoryViewAdapter(((NbActivity) getActivity()), this, getFeedSet(), listStyle);
|
||||
adapter.addFooterView(footerView);
|
||||
adapter.addFooterView(fleuronFooter);
|
||||
itemGrid.setAdapter(adapter);
|
||||
binding.itemgridfragmentGrid.setAdapter(adapter);
|
||||
|
||||
// the layout manager needs to know that the footer rows span all the way across
|
||||
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||
|
@ -187,14 +181,14 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
}
|
||||
});
|
||||
|
||||
itemGrid.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
binding.itemgridfragmentGrid.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||
ItemSetFragment.this.onScrolled(recyclerView, dx, dy);
|
||||
}
|
||||
});
|
||||
|
||||
setupGestureDetector(itemGrid);
|
||||
setupGestureDetector(binding.itemgridfragmentGrid);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
@ -281,13 +275,13 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
}
|
||||
|
||||
protected void updateAdapter(Cursor cursor) {
|
||||
adapter.swapCursor(cursor, itemGrid, gridState);
|
||||
adapter.swapCursor(cursor, binding.itemgridfragmentGrid, gridState);
|
||||
gridState = null;
|
||||
adapter.updateFeedSet(getFeedSet());
|
||||
if ((cursor != null) && (cursor.getCount() > 0)) {
|
||||
emptyView.setVisibility(View.INVISIBLE);
|
||||
binding.emptyView.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
emptyView.setVisibility(View.VISIBLE);
|
||||
binding.emptyView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
// though we have stories, we might not yet have as many as we want
|
||||
|
@ -305,38 +299,38 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
calcFleuronPadding();
|
||||
|
||||
if (getFeedSet().isMuted()) {
|
||||
emptyViewText.setText(R.string.empty_list_view_muted_feed);
|
||||
emptyViewText.setTypeface(null, Typeface.NORMAL);
|
||||
emptyViewImage.setVisibility(View.VISIBLE);
|
||||
topProgressView.setVisibility(View.INVISIBLE);
|
||||
binding.emptyViewText.setText(R.string.empty_list_view_muted_feed);
|
||||
binding.emptyViewText.setTypeface(null, Typeface.NORMAL);
|
||||
binding.emptyViewImage.setVisibility(View.VISIBLE);
|
||||
binding.topLoadingThrob.setVisibility(View.INVISIBLE);
|
||||
bottomProgressView.setVisibility(View.INVISIBLE);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (!cursorSeenYet) || NBSyncService.isFeedSetSyncing(getFeedSet(), getActivity()) ) {
|
||||
emptyViewText.setText(R.string.empty_list_view_loading);
|
||||
emptyViewText.setTypeface(null, Typeface.ITALIC);
|
||||
emptyViewImage.setVisibility(View.INVISIBLE);
|
||||
binding.emptyViewText.setText(R.string.empty_list_view_loading);
|
||||
binding.emptyViewText.setTypeface(null, Typeface.ITALIC);
|
||||
binding.emptyViewImage.setVisibility(View.INVISIBLE);
|
||||
|
||||
if (NBSyncService.isFeedSetStoriesFresh(getFeedSet())) {
|
||||
topProgressView.setVisibility(View.INVISIBLE);
|
||||
binding.topLoadingThrob.setVisibility(View.INVISIBLE);
|
||||
bottomProgressView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
topProgressView.setVisibility(View.VISIBLE);
|
||||
binding.topLoadingThrob.setVisibility(View.VISIBLE);
|
||||
bottomProgressView.setVisibility(View.GONE);
|
||||
}
|
||||
fleuronFooter.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
ReadFilter readFilter = PrefsUtils.getReadFilter(getActivity(), getFeedSet());
|
||||
if (readFilter == ReadFilter.UNREAD) {
|
||||
emptyViewText.setText(R.string.empty_list_view_no_stories_unread);
|
||||
binding.emptyViewText.setText(R.string.empty_list_view_no_stories_unread);
|
||||
} else {
|
||||
emptyViewText.setText(R.string.empty_list_view_no_stories);
|
||||
binding.emptyViewText.setText(R.string.empty_list_view_no_stories);
|
||||
}
|
||||
emptyViewText.setTypeface(null, Typeface.NORMAL);
|
||||
emptyViewImage.setVisibility(View.VISIBLE);
|
||||
binding.emptyViewText.setTypeface(null, Typeface.NORMAL);
|
||||
binding.emptyViewImage.setVisibility(View.VISIBLE);
|
||||
|
||||
topProgressView.setVisibility(View.INVISIBLE);
|
||||
binding.topLoadingThrob.setVisibility(View.INVISIBLE);
|
||||
bottomProgressView.setVisibility(View.INVISIBLE);
|
||||
if (cursorSeenYet && NBSyncService.isFeedSetExhausted(getFeedSet()) && (adapter.getRawStoryCount() > 0)) {
|
||||
fleuronFooter.setVisibility(View.VISIBLE);
|
||||
|
@ -411,7 +405,7 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
targetMovDuration = 0L;
|
||||
}
|
||||
|
||||
RecyclerView.ItemAnimator anim = itemGrid.getItemAnimator();
|
||||
RecyclerView.ItemAnimator anim = binding.itemgridfragmentGrid.getItemAnimator();
|
||||
anim.setAddDuration((long) ((anim.getAddDuration() + targetAddDuration)/2L));
|
||||
anim.setMoveDuration((long) ((anim.getMoveDuration() + targetMovDuration)/2L));
|
||||
}
|
||||
|
@ -429,7 +423,7 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
// past the last item, which can be confusing to users who don't know about or need the offset
|
||||
if ( (!fullFlingComplete) &&
|
||||
(layoutManager.findLastCompletelyVisibleItemPosition() >= adapter.getStoryCount()) ) {
|
||||
itemGrid.stopScroll();
|
||||
binding.itemgridfragmentGrid.stopScroll();
|
||||
// but after halting at the end once, do allow scrolling past the bottom
|
||||
fullFlingComplete = true;
|
||||
}
|
||||
|
@ -439,7 +433,7 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
(layoutManager.findLastCompletelyVisibleItemPosition() >= indexOfLastUnread) ) {
|
||||
// but don't interrupt if already past the last unread
|
||||
if (indexOfLastUnread >= layoutManager.findFirstCompletelyVisibleItemPosition()) {
|
||||
itemGrid.stopScroll();
|
||||
binding.itemgridfragmentGrid.stopScroll();
|
||||
}
|
||||
indexOfLastUnread = -1;
|
||||
}
|
||||
|
@ -507,7 +501,7 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
*/
|
||||
private void calcFleuronPadding() {
|
||||
if (fleuronResized) return;
|
||||
int listHeight = itemGrid.getMeasuredHeight();
|
||||
int listHeight = binding.itemgridfragmentGrid.getMeasuredHeight();
|
||||
View innerView = fleuronFooter.findViewById(R.id.fleuron);
|
||||
ViewGroup.LayoutParams oldLayout = innerView.getLayoutParams();
|
||||
ViewGroup.MarginLayoutParams newLayout = new LinearLayout.LayoutParams(oldLayout);
|
||||
|
@ -526,7 +520,7 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
@Override
|
||||
public void onSaveInstanceState (Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putParcelable(BUNDLE_GRIDSTATE, itemGrid.getLayoutManager().onSaveInstanceState());
|
||||
outState.putParcelable(BUNDLE_GRIDSTATE, binding.itemgridfragmentGrid.getLayoutManager().onSaveInstanceState());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,17 +11,12 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.activity.Login;
|
||||
import com.newsblur.activity.Main;
|
||||
import com.newsblur.databinding.FragmentLoginprogressBinding;
|
||||
import com.newsblur.network.APIManager;
|
||||
import com.newsblur.network.domain.LoginResponse;
|
||||
import com.newsblur.util.PrefsUtils;
|
||||
|
@ -30,14 +25,10 @@ import com.newsblur.util.UIUtils;
|
|||
public class LoginProgressFragment extends Fragment {
|
||||
|
||||
private APIManager apiManager;
|
||||
@Bind(R.id.login_logging_in) TextView updateStatus;
|
||||
@Bind(R.id.login_retrieving_feeds) TextView retrievingFeeds;
|
||||
@Bind(R.id.login_profile_picture) ImageView loginProfilePicture;
|
||||
@Bind(R.id.login_feed_progress) ProgressBar feedProgress;
|
||||
@Bind(R.id.login_logging_in_progress) ProgressBar loggingInProgress;
|
||||
private LoginTask loginTask;
|
||||
private String username;
|
||||
private String password;
|
||||
private FragmentLoginprogressBinding binding;
|
||||
|
||||
public static LoginProgressFragment getInstance(String username, String password) {
|
||||
LoginProgressFragment fragment = new LoginProgressFragment();
|
||||
|
@ -61,7 +52,7 @@ public class LoginProgressFragment extends Fragment {
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.fragment_loginprogress, null);
|
||||
ButterKnife.bind(this, v);
|
||||
binding = FragmentLoginprogressBinding.bind(v);
|
||||
|
||||
loginTask = new LoginTask();
|
||||
loginTask.execute();
|
||||
|
@ -73,7 +64,7 @@ public class LoginProgressFragment extends Fragment {
|
|||
@Override
|
||||
protected void onPreExecute() {
|
||||
Animation a = AnimationUtils.loadAnimation(getActivity(), R.anim.text_up);
|
||||
updateStatus.startAnimation(a);
|
||||
binding.loginLoggingIn.startAnimation(a);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -90,20 +81,20 @@ public class LoginProgressFragment extends Fragment {
|
|||
if (c == null) return; // we might have run past the lifecycle of the activity
|
||||
if (!result.isError()) {
|
||||
final Animation a = AnimationUtils.loadAnimation(c, R.anim.text_down);
|
||||
updateStatus.setText(R.string.login_logged_in);
|
||||
loggingInProgress.setVisibility(View.GONE);
|
||||
updateStatus.startAnimation(a);
|
||||
binding.loginLoggingIn.setText(R.string.login_logged_in);
|
||||
binding.loginLoggingInProgress.setVisibility(View.GONE);
|
||||
binding.loginLoggingIn.startAnimation(a);
|
||||
|
||||
Bitmap userImage = PrefsUtils.getUserImage(c);
|
||||
if (userImage != null ) {
|
||||
loginProfilePicture.setVisibility(View.VISIBLE);
|
||||
loginProfilePicture.setImageBitmap(UIUtils.clipAndRound(userImage, 10f, false));
|
||||
binding.loginProfilePicture.setVisibility(View.VISIBLE);
|
||||
binding.loginProfilePicture.setImageBitmap(UIUtils.clipAndRound(userImage, 10f, false));
|
||||
}
|
||||
feedProgress.setVisibility(View.VISIBLE);
|
||||
binding.loginFeedProgress.setVisibility(View.VISIBLE);
|
||||
|
||||
final Animation b = AnimationUtils.loadAnimation(c, R.anim.text_up);
|
||||
retrievingFeeds.setText(R.string.login_retrieving_feeds);
|
||||
retrievingFeeds.startAnimation(b);
|
||||
binding.loginRetrievingFeeds.setText(R.string.login_retrieving_feeds);
|
||||
binding.loginFeedProgress.startAnimation(b);
|
||||
|
||||
Intent startMain = new Intent(getActivity(), Main.class);
|
||||
c.startActivity(startMain);
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.newsblur.fragment;
|
|||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
|
@ -10,39 +12,27 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TextView.OnEditorActionListener;
|
||||
import android.widget.ViewSwitcher;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.activity.LoginProgress;
|
||||
import com.newsblur.activity.RegisterProgress;
|
||||
import com.newsblur.databinding.FragmentLoginregisterBinding;
|
||||
import com.newsblur.network.APIConstants;
|
||||
import com.newsblur.util.AppConstants;
|
||||
import com.newsblur.util.PrefsUtils;
|
||||
|
||||
public class LoginRegisterFragment extends Fragment {
|
||||
|
||||
@Bind(R.id.login_username) EditText username;
|
||||
@Bind(R.id.login_password) EditText password;
|
||||
@Bind(R.id.registration_username) EditText register_username;
|
||||
@Bind(R.id.registration_password) EditText register_password;
|
||||
@Bind(R.id.registration_email) EditText register_email;
|
||||
@Bind(R.id.login_viewswitcher) ViewSwitcher viewSwitcher;
|
||||
@Bind(R.id.login_custom_server) View customServer;
|
||||
@Bind(R.id.login_custom_server_value) EditText customServerValue;
|
||||
private FragmentLoginregisterBinding binding;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
final View v = inflater.inflate(R.layout.fragment_loginregister, container, false);
|
||||
ButterKnife.bind(this, v);
|
||||
binding = FragmentLoginregisterBinding.bind(v);
|
||||
|
||||
password.setOnEditorActionListener(new OnEditorActionListener() {
|
||||
binding.loginPassword.setOnEditorActionListener(new OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView arg0, int actionId, KeyEvent event) {
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE ) {
|
||||
|
@ -52,7 +42,7 @@ public class LoginRegisterFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
register_email.setOnEditorActionListener(new OnEditorActionListener() {
|
||||
binding.registrationEmail.setOnEditorActionListener(new OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView arg0, int actionId, KeyEvent event) {
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE ) {
|
||||
|
@ -65,36 +55,77 @@ public class LoginRegisterFragment extends Fragment {
|
|||
return v;
|
||||
}
|
||||
|
||||
@OnClick(R.id.login_button) void logIn() {
|
||||
if (!TextUtils.isEmpty(username.getText().toString())) {
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
binding.loginButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
logIn();
|
||||
}
|
||||
});
|
||||
binding.registrationButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
signUp();
|
||||
}
|
||||
});
|
||||
binding.loginChangeToLogin.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showLogin();
|
||||
}
|
||||
});
|
||||
binding.loginChangeToRegister.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showRegister();
|
||||
}
|
||||
});
|
||||
binding.loginForgotPassword.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
launchForgotPasswordPage();
|
||||
}
|
||||
});
|
||||
binding.loginCustomServer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showCustomServer();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void logIn() {
|
||||
if (!TextUtils.isEmpty(binding.loginUsername.getText().toString())) {
|
||||
// set the custom server endpoint before any API access, even the cookie fetch.
|
||||
APIConstants.setCustomServer(customServerValue.getText().toString());
|
||||
PrefsUtils.saveCustomServer(getActivity(), customServerValue.getText().toString());
|
||||
APIConstants.setCustomServer(binding.loginCustomServerValue.getText().toString());
|
||||
PrefsUtils.saveCustomServer(getActivity(), binding.loginCustomServerValue.getText().toString());
|
||||
|
||||
Intent i = new Intent(getActivity(), LoginProgress.class);
|
||||
i.putExtra("username", username.getText().toString());
|
||||
i.putExtra("password", password.getText().toString());
|
||||
i.putExtra("username", binding.loginUsername.getText().toString());
|
||||
i.putExtra("password", binding.loginUsername.getText().toString());
|
||||
startActivity(i);
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.registration_button) void signUp() {
|
||||
private void signUp() {
|
||||
Intent i = new Intent(getActivity(), RegisterProgress.class);
|
||||
i.putExtra("username", register_username.getText().toString());
|
||||
i.putExtra("password", register_password.getText().toString());
|
||||
i.putExtra("email", register_email.getText().toString());
|
||||
i.putExtra("username", binding.registrationUsername.getText().toString());
|
||||
i.putExtra("password", binding.registrationPassword.getText().toString());
|
||||
i.putExtra("email", binding.registrationEmail.getText().toString());
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
@OnClick(R.id.login_change_to_login) void showLogin() {
|
||||
viewSwitcher.showPrevious();
|
||||
private void showLogin() {
|
||||
binding.loginViewswitcher.showPrevious();
|
||||
}
|
||||
|
||||
@OnClick(R.id.login_change_to_register) void showRegister() {
|
||||
viewSwitcher.showNext();
|
||||
private void showRegister() {
|
||||
binding.loginViewswitcher.showNext();
|
||||
}
|
||||
|
||||
@OnClick(R.id.login_forgot_password) void launchForgotPasswordPage() {
|
||||
private void launchForgotPasswordPage() {
|
||||
try {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse(AppConstants.FORGOT_PASWORD_URL));
|
||||
|
@ -104,9 +135,8 @@ public class LoginRegisterFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.login_custom_server) void showCustomServer() {
|
||||
customServer.setVisibility(View.GONE);
|
||||
customServerValue.setVisibility(View.VISIBLE);
|
||||
private void showCustomServer() {
|
||||
binding.loginCustomServer.setVisibility(View.GONE);
|
||||
binding.loginCustomServerValue.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,19 +1,17 @@
|
|||
package com.newsblur.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.RadioButton;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.databinding.ReadfilterDialogBinding;
|
||||
import com.newsblur.util.ReadFilter;
|
||||
import com.newsblur.util.ReadFilterChangedListener;
|
||||
|
||||
|
@ -21,8 +19,7 @@ public class ReadFilterDialogFragment extends DialogFragment {
|
|||
|
||||
private static String CURRENT_FILTER = "currentFilter";
|
||||
private ReadFilter currentValue;
|
||||
@Bind(R.id.radio_all) RadioButton allButton;
|
||||
@Bind(R.id.radio_unread) RadioButton unreadButton;
|
||||
private ReadfilterDialogBinding binding;
|
||||
|
||||
public static ReadFilterDialogFragment newInstance(ReadFilter currentValue) {
|
||||
ReadFilterDialogFragment dialog = new ReadFilterDialogFragment();
|
||||
|
@ -42,10 +39,10 @@ public class ReadFilterDialogFragment extends DialogFragment {
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||
currentValue = (ReadFilter) getArguments().getSerializable(CURRENT_FILTER);
|
||||
View v = inflater.inflate(R.layout.readfilter_dialog, null);
|
||||
ButterKnife.bind(this, v);
|
||||
binding = ReadfilterDialogBinding.bind(v);
|
||||
|
||||
allButton.setChecked(currentValue == ReadFilter.ALL);
|
||||
unreadButton.setChecked(currentValue == ReadFilter.UNREAD);
|
||||
binding.radioAll.setChecked(currentValue == ReadFilter.ALL);
|
||||
binding.radioUnread.setChecked(currentValue == ReadFilter.UNREAD);
|
||||
|
||||
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
getDialog().getWindow().getAttributes().gravity = Gravity.BOTTOM;
|
||||
|
@ -53,14 +50,31 @@ public class ReadFilterDialogFragment extends DialogFragment {
|
|||
return v;
|
||||
}
|
||||
|
||||
@OnClick(R.id.radio_all) void selectAll() {
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
binding.radioAll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
selectAll();
|
||||
}
|
||||
});
|
||||
binding.radioUnread.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
selectUnread();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void selectAll() {
|
||||
if (currentValue != ReadFilter.ALL) {
|
||||
((ReadFilterChangedListener) getActivity()).readFilterChanged(ReadFilter.ALL);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@OnClick(R.id.radio_unread) void selectUnread() {
|
||||
private void selectUnread() {
|
||||
if (currentValue != ReadFilter.UNREAD) {
|
||||
((ReadFilterChangedListener) getActivity()).readFilterChanged(ReadFilter.UNREAD);
|
||||
}
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
package com.newsblur.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.RadioButton;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.databinding.ReadingfontDialogBinding;
|
||||
import com.newsblur.util.ReadingFontChangedListener;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
/**
|
||||
* Created by mark on 02/05/2017.
|
||||
*/
|
||||
|
@ -26,14 +24,7 @@ public class ReadingFontDialogFragment extends DialogFragment {
|
|||
|
||||
private String currentValue;
|
||||
|
||||
@Bind(R.id.radio_anonymous) RadioButton anonymousButton;
|
||||
@Bind(R.id.radio_chronicle) RadioButton chronicleButton;
|
||||
@Bind(R.id.radio_default) RadioButton defaultButton;
|
||||
@Bind(R.id.radio_gotham) RadioButton gothamButton;
|
||||
@Bind(R.id.radio_noto_sans) RadioButton notoSansButton;
|
||||
@Bind(R.id.radio_noto_serif) RadioButton notoSerifButton;
|
||||
@Bind(R.id.radio_open_sans_condensed) RadioButton openSansCondensedButton;
|
||||
@Bind(R.id.radio_whitney) RadioButton whitneyButton;
|
||||
private ReadingfontDialogBinding binding;
|
||||
|
||||
public static ReadingFontDialogFragment newInstance(String selectedFont) {
|
||||
ReadingFontDialogFragment dialog = new ReadingFontDialogFragment();
|
||||
|
@ -52,16 +43,16 @@ public class ReadingFontDialogFragment extends DialogFragment {
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||
currentValue = getArguments().getString(SELECTED_FONT);
|
||||
View v = inflater.inflate(R.layout.readingfont_dialog, null);
|
||||
ButterKnife.bind(this, v);
|
||||
binding = ReadingfontDialogBinding.bind(v);
|
||||
|
||||
anonymousButton.setChecked(currentValue.equals(getString(R.string.anonymous_pro_font_prefvalue)));
|
||||
chronicleButton.setChecked(currentValue.equals(getString(R.string.chronicle_font_prefvalue)));
|
||||
defaultButton.setChecked(currentValue.equals(getString(R.string.default_font_prefvalue)));
|
||||
gothamButton.setChecked(currentValue.equals(getString(R.string.gotham_narrow_font_prefvalue)));
|
||||
notoSansButton.setChecked(currentValue.equals(getString(R.string.noto_sans_font_prefvalue)));
|
||||
notoSerifButton.setChecked(currentValue.equals(getString(R.string.noto_serif_font_prefvalue)));
|
||||
openSansCondensedButton.setChecked(currentValue.equals(getString(R.string.open_sans_condensed_font_prefvalue)));
|
||||
whitneyButton.setChecked(currentValue.equals(getString(R.string.whitney_font_prefvalue)));
|
||||
binding.radioAnonymous.setChecked(currentValue.equals(getString(R.string.anonymous_pro_font_prefvalue)));
|
||||
binding.radioChronicle.setChecked(currentValue.equals(getString(R.string.chronicle_font_prefvalue)));
|
||||
binding.radioDefault.setChecked(currentValue.equals(getString(R.string.default_font_prefvalue)));
|
||||
binding.radioGotham.setChecked(currentValue.equals(getString(R.string.gotham_narrow_font_prefvalue)));
|
||||
binding.radioNotoSans.setChecked(currentValue.equals(getString(R.string.noto_sans_font_prefvalue)));
|
||||
binding.radioNotoSerif.setChecked(currentValue.equals(getString(R.string.noto_serif_font_prefvalue)));
|
||||
binding.radioOpenSansCondensed.setChecked(currentValue.equals(getString(R.string.open_sans_condensed_font_prefvalue)));
|
||||
binding.radioWhitney.setChecked(currentValue.equals(getString(R.string.whitney_font_prefvalue)));
|
||||
|
||||
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
getDialog().getWindow().getAttributes().gravity = Gravity.BOTTOM;
|
||||
|
@ -69,8 +60,57 @@ public class ReadingFontDialogFragment extends DialogFragment {
|
|||
return v;
|
||||
}
|
||||
|
||||
@OnClick(R.id.radio_anonymous) void selectAnonymousPro() {
|
||||
switchFont(getString(R.string.anonymous_pro_font_prefvalue));
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
binding.radioAnonymous.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switchFont(getString(R.string.anonymous_pro_font_prefvalue));
|
||||
}
|
||||
});
|
||||
binding.radioDefault.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switchFont(getString(R.string.default_font_prefvalue));
|
||||
}
|
||||
});
|
||||
binding.radioChronicle.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switchFont(getString(R.string.chronicle_font_prefvalue));
|
||||
}
|
||||
});
|
||||
binding.radioGotham.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switchFont(getString(R.string.gotham_narrow_font_prefvalue));
|
||||
}
|
||||
});
|
||||
binding.radioNotoSans.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switchFont(getString(R.string.noto_sans_font_prefvalue));
|
||||
}
|
||||
});
|
||||
binding.radioNotoSerif.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switchFont(getString(R.string.noto_serif_font_prefvalue));
|
||||
}
|
||||
});
|
||||
binding.radioOpenSansCondensed.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switchFont(getString(R.string.open_sans_condensed_font_prefvalue));
|
||||
}
|
||||
});
|
||||
binding.radioWhitney.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switchFont(getString(R.string.whitney_font_prefvalue));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void switchFont(String newValue) {
|
||||
|
@ -79,32 +119,4 @@ public class ReadingFontDialogFragment extends DialogFragment {
|
|||
currentValue = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.radio_chronicle) void selectChronicle() {
|
||||
switchFont(getString(R.string.chronicle_font_prefvalue));
|
||||
}
|
||||
|
||||
@OnClick(R.id.radio_default) void selectDefault() {
|
||||
switchFont(getString(R.string.default_font_prefvalue));
|
||||
}
|
||||
|
||||
@OnClick(R.id.radio_gotham) void selectGotham() {
|
||||
switchFont(getString(R.string.gotham_narrow_font_prefvalue));
|
||||
}
|
||||
|
||||
@OnClick(R.id.radio_noto_sans) void selectNotoSans() {
|
||||
switchFont(getString(R.string.noto_sans_font_prefvalue));
|
||||
}
|
||||
|
||||
@OnClick(R.id.radio_noto_serif) void selectNotoSerif() {
|
||||
switchFont(getString(R.string.noto_serif_font_prefvalue));
|
||||
}
|
||||
|
||||
@OnClick(R.id.radio_open_sans_condensed) void selectOpenSansCondensed() {
|
||||
switchFont(getString(R.string.open_sans_condensed_font_prefvalue));
|
||||
}
|
||||
|
||||
@OnClick(R.id.radio_whitney) void selectWhitney() {
|
||||
switchFont(getString(R.string.whitney_font_prefvalue));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,6 +13,8 @@ import android.graphics.drawable.GradientDrawable;
|
|||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
@ -26,22 +28,17 @@ import android.view.View;
|
|||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebView.HitTestResult;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.activity.FeedItemsList;
|
||||
import com.newsblur.activity.NbActivity;
|
||||
import com.newsblur.activity.Reading;
|
||||
import com.newsblur.databinding.FragmentReadingitemBinding;
|
||||
import com.newsblur.databinding.IncludeReadingItemCommentBinding;
|
||||
import com.newsblur.domain.Classifier;
|
||||
import com.newsblur.domain.Feed;
|
||||
import com.newsblur.domain.Story;
|
||||
import com.newsblur.domain.UserDetails;
|
||||
import com.newsblur.service.OriginalTextService;
|
||||
|
@ -54,14 +51,9 @@ import com.newsblur.util.PrefsUtils;
|
|||
import com.newsblur.util.StoryUtils;
|
||||
import com.newsblur.util.UIUtils;
|
||||
import com.newsblur.util.ViewUtils;
|
||||
import com.newsblur.view.FlowLayout;
|
||||
import com.newsblur.view.NewsblurWebview;
|
||||
import com.newsblur.view.ReadingScrollView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -76,24 +68,12 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
private LayoutInflater inflater;
|
||||
private String feedColor, feedTitle, feedFade, feedBorder, feedIconUrl, faviconText;
|
||||
private Classifier classifier;
|
||||
@Bind(R.id.reading_webview) NewsblurWebview web;
|
||||
@Bind(R.id.custom_view_container) ViewGroup webviewCustomViewLayout;
|
||||
@Bind(R.id.reading_scrollview) ScrollView fragmentScrollview;
|
||||
private BroadcastReceiver textSizeReceiver, readingFontReceiver;
|
||||
@Bind(R.id.reading_item_title) TextView itemTitle;
|
||||
@Bind(R.id.reading_item_authors) TextView itemAuthors;
|
||||
@Bind(R.id.reading_feed_title) TextView itemFeed;
|
||||
private boolean displayFeedDetails;
|
||||
@Bind(R.id.reading_item_tags) FlowLayout tagContainer;
|
||||
private View view;
|
||||
private UserDetails user;
|
||||
private DefaultFeedView selectedFeedView;
|
||||
private boolean textViewUnavailable;
|
||||
@Bind(R.id.reading_textloading) TextView textViewLoadingMsg;
|
||||
@Bind(R.id.reading_textmodefailed) TextView textViewLoadingFailedMsg;
|
||||
@Bind(R.id.save_story_button) Button saveButton;
|
||||
@Bind(R.id.share_story_button) Button shareButton;
|
||||
@Bind(R.id.story_context_menu_button) Button menuButton;
|
||||
|
||||
/** The story HTML, as provided by the 'content' element of the stories API. */
|
||||
private String storyContent;
|
||||
|
@ -115,6 +95,9 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
|
||||
private final Object WEBVIEW_CONTENT_MUTEX = new Object();
|
||||
|
||||
private FragmentReadingitemBinding binding;
|
||||
private IncludeReadingItemCommentBinding itemCommentBinding;
|
||||
|
||||
public static ReadingItemFragment newInstance(Story story, String feedTitle, String feedFaviconColor, String feedFaviconFade, String feedFaviconBorder, String faviconText, String faviconUrl, Classifier classifier, boolean displayFeedDetails, String sourceUserId) {
|
||||
ReadingItemFragment readingFragment = new ReadingItemFragment();
|
||||
|
||||
|
@ -168,8 +151,8 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
int heightm = fragmentScrollview.getChildAt(0).getMeasuredHeight();
|
||||
int pos = fragmentScrollview.getScrollY();
|
||||
int heightm = binding.readingScrollview.getChildAt(0).getMeasuredHeight();
|
||||
int pos = binding.readingScrollview.getScrollY();
|
||||
outState.putFloat(BUNDLE_SCROLL_POS_REL, (((float)pos)/heightm));
|
||||
}
|
||||
|
||||
|
@ -177,7 +160,7 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
public void onDestroy() {
|
||||
getActivity().unregisterReceiver(textSizeReceiver);
|
||||
getActivity().unregisterReceiver(readingFontReceiver);
|
||||
web.setOnTouchListener(null);
|
||||
binding.readingWebview.setOnTouchListener(null);
|
||||
view.setOnTouchListener(null);
|
||||
getActivity().getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(null);
|
||||
super.onDestroy();
|
||||
|
@ -187,7 +170,7 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
// state into the webview so it behaves.
|
||||
@Override
|
||||
public void onPause() {
|
||||
if (this.web != null ) { this.web.onPause(); }
|
||||
if (this.binding.readingWebview != null ) { this.binding.readingWebview.onPause(); }
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
|
@ -195,25 +178,26 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
reloadStoryContent();
|
||||
if (this.web != null ) { this.web.onResume(); }
|
||||
if (this.binding.readingWebview != null ) { this.binding.readingWebview.onResume(); }
|
||||
}
|
||||
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
this.inflater = inflater;
|
||||
view = inflater.inflate(R.layout.fragment_readingitem, null);
|
||||
ButterKnife.bind(this, view);
|
||||
binding = FragmentReadingitemBinding.bind(view);
|
||||
itemCommentBinding = IncludeReadingItemCommentBinding.bind(binding.getRoot());
|
||||
|
||||
Reading activity = (Reading) getActivity();
|
||||
fs = activity.getFeedSet();
|
||||
|
||||
selectedFeedView = PrefsUtils.getDefaultViewModeForFeed(activity, story.feedId);
|
||||
|
||||
registerForContextMenu(web);
|
||||
web.setCustomViewLayout(webviewCustomViewLayout);
|
||||
web.setWebviewWrapperLayout(fragmentScrollview);
|
||||
web.setBackgroundColor(Color.TRANSPARENT);
|
||||
web.fragment = this;
|
||||
web.activity = activity;
|
||||
registerForContextMenu(binding.readingWebview);
|
||||
binding.readingWebview.setCustomViewLayout(binding.customViewContainer);
|
||||
binding.readingWebview.setWebviewWrapperLayout(binding.readingScrollview);
|
||||
binding.readingWebview.setBackgroundColor(Color.TRANSPARENT);
|
||||
binding.readingWebview.fragment = this;
|
||||
binding.readingWebview.activity = activity;
|
||||
|
||||
setupItemMetadata();
|
||||
updateShareButton();
|
||||
|
@ -228,6 +212,29 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
binding.storyContextMenuButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onClickMenuButton();
|
||||
}
|
||||
});
|
||||
itemCommentBinding.saveStoryButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
clickSave();
|
||||
}
|
||||
});
|
||||
itemCommentBinding.shareStoryButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
clickShare();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupImmersiveViewGestureDetector() {
|
||||
// Change the system visibility on the decorview from the activity so that the state is maintained as we page through
|
||||
// fragments
|
||||
|
@ -239,7 +246,7 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
return gestureDetector.onTouchEvent(motionEvent);
|
||||
}
|
||||
};
|
||||
web.setOnTouchListener(touchListener);
|
||||
binding.readingWebview.setOnTouchListener(touchListener);
|
||||
view.setOnTouchListener(touchListener);
|
||||
|
||||
getActivity().getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(immersiveViewHandler);
|
||||
|
@ -247,7 +254,7 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
||||
HitTestResult result = web.getHitTestResult();
|
||||
HitTestResult result = binding.readingWebview.getHitTestResult();
|
||||
if (result.getType() == HitTestResult.IMAGE_TYPE ||
|
||||
result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE ) {
|
||||
// if the long-pressed item was an image, see if we can pop up a little dialogue
|
||||
|
@ -298,8 +305,8 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.story_context_menu_button) void onClickMenuButton() {
|
||||
PopupMenu pm = new PopupMenu(getActivity(), menuButton);
|
||||
private void onClickMenuButton() {
|
||||
PopupMenu pm = new PopupMenu(getActivity(), binding.storyContextMenuButton);
|
||||
Menu menu = pm.getMenu();
|
||||
pm.getMenuInflater().inflate(R.menu.story_context, menu);
|
||||
|
||||
|
@ -386,7 +393,7 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.save_story_button) void clickSave() {
|
||||
private void clickSave() {
|
||||
if (story.starred) {
|
||||
FeedUtils.setStorySaved(story.storyHash, false, getActivity());
|
||||
} else {
|
||||
|
@ -395,24 +402,24 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
}
|
||||
|
||||
private void updateSaveButton() {
|
||||
if (saveButton == null) return;
|
||||
saveButton.setText(story.starred ? R.string.unsave_this : R.string.save_this);
|
||||
if (itemCommentBinding.saveStoryButton == null) return;
|
||||
itemCommentBinding.saveStoryButton.setText(story.starred ? R.string.unsave_this : R.string.save_this);
|
||||
}
|
||||
|
||||
@OnClick(R.id.share_story_button) void clickShare() {
|
||||
private void clickShare() {
|
||||
DialogFragment newFragment = ShareDialogFragment.newInstance(story, sourceUserId);
|
||||
newFragment.show(getFragmentManager(), "dialog");
|
||||
}
|
||||
|
||||
private void updateShareButton() {
|
||||
if (shareButton == null) return;
|
||||
if (itemCommentBinding.shareStoryButton == null) return;
|
||||
for (String userId : story.sharedUserIds) {
|
||||
if (TextUtils.equals(userId, user.id)) {
|
||||
shareButton.setText(R.string.already_shared);
|
||||
itemCommentBinding.shareStoryButton.setText(R.string.already_shared);
|
||||
return;
|
||||
}
|
||||
}
|
||||
shareButton.setText(R.string.share_this);
|
||||
itemCommentBinding.shareStoryButton.setText(R.string.share_this);
|
||||
}
|
||||
|
||||
private void setupItemCommentsAndShares() {
|
||||
|
@ -443,28 +450,28 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
feedHeaderBorder.setBackgroundColor(Color.parseColor("#" + feedBorder));
|
||||
|
||||
if (TextUtils.equals(faviconText, "black")) {
|
||||
itemFeed.setTextColor(UIUtils.getColor(getActivity(), R.color.text));
|
||||
itemFeed.setShadowLayer(1, 0, 1, UIUtils.getColor(getActivity(), R.color.half_white));
|
||||
binding.readingFeedTitle.setTextColor(UIUtils.getColor(getActivity(), R.color.text));
|
||||
binding.readingFeedTitle.setShadowLayer(1, 0, 1, UIUtils.getColor(getActivity(), R.color.half_white));
|
||||
} else {
|
||||
itemFeed.setTextColor(UIUtils.getColor(getActivity(), R.color.white));
|
||||
itemFeed.setShadowLayer(1, 0, 1, UIUtils.getColor(getActivity(), R.color.half_black));
|
||||
binding.readingFeedTitle.setTextColor(UIUtils.getColor(getActivity(), R.color.white));
|
||||
binding.readingFeedTitle.setShadowLayer(1, 0, 1, UIUtils.getColor(getActivity(), R.color.half_black));
|
||||
}
|
||||
|
||||
if (!displayFeedDetails) {
|
||||
itemFeed.setVisibility(View.GONE);
|
||||
binding.readingFeedTitle.setVisibility(View.GONE);
|
||||
feedIcon.setVisibility(View.GONE);
|
||||
} else {
|
||||
FeedUtils.iconLoader.displayImage(feedIconUrl, feedIcon, 0, false);
|
||||
itemFeed.setText(feedTitle);
|
||||
binding.readingFeedTitle.setText(feedTitle);
|
||||
}
|
||||
|
||||
itemDate.setText(StoryUtils.formatLongDate(getActivity(), story.timestamp));
|
||||
|
||||
if (story.tags.length <= 0) {
|
||||
tagContainer.setVisibility(View.GONE);
|
||||
binding.readingItemTags.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
itemAuthors.setOnClickListener(new OnClickListener() {
|
||||
binding.readingItemAuthors.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (story.feedId.equals("0")) return; // cannot train on feedless stories
|
||||
|
@ -473,7 +480,7 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
}
|
||||
});
|
||||
|
||||
itemFeed.setOnClickListener(new OnClickListener() {
|
||||
binding.readingFeedTitle.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (story.feedId.equals("0")) return; // cannot train on feedless stories
|
||||
|
@ -482,7 +489,7 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
}
|
||||
});
|
||||
|
||||
itemTitle.setOnClickListener(new OnClickListener() {
|
||||
binding.readingItemTitle.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
|
@ -506,7 +513,7 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
Drawable tag_green_background = UIUtils.getDrawable(getActivity(), R.drawable.tag_background_positive);
|
||||
Drawable tag_red_background = UIUtils.getDrawable(getActivity(), R.drawable.tag_background_negative);
|
||||
|
||||
tagContainer.removeAllViews();
|
||||
binding.readingItemTags.removeAllViews();
|
||||
for (String tag : story.tags) {
|
||||
// TODO: these textviews with compound images are buggy, but stubbed in to let colourblind users
|
||||
// see what is going on. these should be replaced with proper Chips when the v28 Chip lib
|
||||
|
@ -549,21 +556,21 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
});
|
||||
}
|
||||
|
||||
tagContainer.addView(v);
|
||||
binding.readingItemTags.addView(v);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(story.authors)) {
|
||||
itemAuthors.setText("• " + story.authors);
|
||||
binding.readingItemAuthors.setText("• " + story.authors);
|
||||
if (classifier != null && classifier.authors.containsKey(story.authors)) {
|
||||
switch (classifier.authors.get(story.authors)) {
|
||||
case Classifier.LIKE:
|
||||
itemAuthors.setTextColor(UIUtils.getColor(getActivity(), R.color.positive));
|
||||
binding.readingItemAuthors.setTextColor(UIUtils.getColor(getActivity(), R.color.positive));
|
||||
break;
|
||||
case Classifier.DISLIKE:
|
||||
itemAuthors.setTextColor(UIUtils.getColor(getActivity(), R.color.negative));
|
||||
binding.readingItemAuthors.setTextColor(UIUtils.getColor(getActivity(), R.color.negative));
|
||||
break;
|
||||
default:
|
||||
itemAuthors.setTextColor(UIUtils.getThemedColor(getActivity(), R.attr.readingItemMetadata, android.R.attr.textColor));
|
||||
binding.readingItemAuthors.setTextColor(UIUtils.getThemedColor(getActivity(), R.attr.readingItemMetadata, android.R.attr.textColor));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -571,7 +578,7 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
|
||||
String title = story.title;
|
||||
title = UIUtils.colourTitleFromClassifier(title, classifier);
|
||||
itemTitle.setText(UIUtils.fromHtml(title));
|
||||
binding.readingItemTitle.setText(UIUtils.fromHtml(title));
|
||||
}
|
||||
|
||||
public void switchSelectedViewMode() {
|
||||
|
@ -613,8 +620,8 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
|
||||
private void reloadStoryContent() {
|
||||
// reset indicators
|
||||
textViewLoadingMsg.setVisibility(View.GONE);
|
||||
textViewLoadingFailedMsg.setVisibility(View.GONE);
|
||||
binding.readingTextloading.setVisibility(View.GONE);
|
||||
binding.readingTextmodefailed.setVisibility(View.GONE);
|
||||
enableProgress(false);
|
||||
|
||||
boolean needStoryContent = false;
|
||||
|
@ -623,10 +630,10 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
needStoryContent = true;
|
||||
} else {
|
||||
if (textViewUnavailable) {
|
||||
textViewLoadingFailedMsg.setVisibility(View.VISIBLE);
|
||||
binding.readingTextmodefailed.setVisibility(View.VISIBLE);
|
||||
needStoryContent = true;
|
||||
} else if (originalText == null) {
|
||||
textViewLoadingMsg.setVisibility(View.VISIBLE);
|
||||
binding.readingTextloading.setVisibility(View.VISIBLE);
|
||||
enableProgress(true);
|
||||
loadOriginalText();
|
||||
// still show the story mode version, as the text mode one may take some time
|
||||
|
@ -786,7 +793,7 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
builder.append("</head><body><div class=\"NB-story\">");
|
||||
builder.append(storyText);
|
||||
builder.append("</div></body></html>");
|
||||
web.loadDataWithBaseURL("file:///android_asset/", builder.toString(), "text/html", "UTF-8", null);
|
||||
binding.readingWebview.loadDataWithBaseURL("file:///android_asset/", builder.toString(), "text/html", "UTF-8", null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -887,10 +894,10 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
// insufficient time to allow the WebView to actually finish internally computing state and size.
|
||||
// an additional fixed delay is added in a last ditch attempt to give the black-box platform
|
||||
// threads a chance to finish their work.
|
||||
fragmentScrollview.postDelayed(new Runnable() {
|
||||
binding.readingScrollview.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
int relPos = Math.round(fragmentScrollview.getChildAt(0).getMeasuredHeight() * savedScrollPosRel);
|
||||
fragmentScrollview.scrollTo(0, relPos);
|
||||
int relPos = Math.round(binding.readingScrollview.getChildAt(0).getMeasuredHeight() * savedScrollPosRel);
|
||||
binding.readingScrollview.scrollTo(0, relPos);
|
||||
}
|
||||
}, 75L);
|
||||
}
|
||||
|
@ -903,7 +910,7 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
private class TextSizeReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
web.setTextSize(intent.getFloatExtra(TEXT_SIZE_VALUE, 1.0f));
|
||||
binding.readingWebview.setTextSize(intent.getFloatExtra(TEXT_SIZE_VALUE, 1.0f));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -924,7 +931,7 @@ public class ReadingItemFragment extends NbFragment implements PopupMenu.OnMenuI
|
|||
|
||||
@Override
|
||||
public boolean onSingleTapUp(MotionEvent e) {
|
||||
if (web.wasLinkClicked()) {
|
||||
if (binding.readingWebview.wasLinkClicked()) {
|
||||
// Clicked a link so ignore immersive view
|
||||
return super.onSingleTapUp(e);
|
||||
}
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
package com.newsblur.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.activity.Reading;
|
||||
import com.newsblur.databinding.FragmentReadingpagerBinding;
|
||||
|
||||
/*
|
||||
* A fragment to hold the story pager. Eventually this fragment should hold much of the UI and logic
|
||||
|
@ -21,8 +18,6 @@ import com.newsblur.activity.Reading;
|
|||
*/
|
||||
public class ReadingPagerFragment extends NbFragment {
|
||||
|
||||
@Bind(R.id.reading_pager) ViewPager pager;
|
||||
|
||||
public static ReadingPagerFragment newInstance() {
|
||||
ReadingPagerFragment fragment = new ReadingPagerFragment();
|
||||
Bundle arguments = new Bundle();
|
||||
|
@ -33,12 +28,12 @@ public class ReadingPagerFragment extends NbFragment {
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.fragment_readingpager, null);
|
||||
ButterKnife.bind(this, v);
|
||||
FragmentReadingpagerBinding binding = FragmentReadingpagerBinding.bind(v);
|
||||
|
||||
Reading activity = ((Reading) getActivity());
|
||||
|
||||
pager.addOnPageChangeListener(activity);
|
||||
activity.offerPager(pager, getChildFragmentManager());
|
||||
binding.readingPager.addOnPageChangeListener(activity);
|
||||
activity.offerPager(binding.readingPager, getChildFragmentManager());
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,23 +3,19 @@ package com.newsblur.fragment;
|
|||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ViewSwitcher;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.activity.AddSocial;
|
||||
import com.newsblur.activity.Login;
|
||||
import com.newsblur.databinding.FragmentRegisterprogressBinding;
|
||||
import com.newsblur.network.APIManager;
|
||||
import com.newsblur.network.domain.RegisterResponse;
|
||||
|
||||
|
@ -31,9 +27,7 @@ public class RegisterProgressFragment extends Fragment {
|
|||
private String password;
|
||||
private String email;
|
||||
private RegisterTask registerTask;
|
||||
@Bind(R.id.register_viewswitcher) ViewSwitcher switcher;
|
||||
@Bind(R.id.registering_next_1) Button next;
|
||||
@Bind(R.id.registerprogress_logo) ImageView registerProgressLogo;
|
||||
private FragmentRegisterprogressBinding binding;
|
||||
|
||||
public static RegisterProgressFragment getInstance(String username, String password, String email) {
|
||||
RegisterProgressFragment fragment = new RegisterProgressFragment();
|
||||
|
@ -59,12 +53,12 @@ public class RegisterProgressFragment extends Fragment {
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.fragment_registerprogress, null);
|
||||
ButterKnife.bind(this, v);
|
||||
binding = FragmentRegisterprogressBinding.bind(v);
|
||||
|
||||
registerProgressLogo.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.rotate));
|
||||
binding.registerprogressLogo.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.rotate));
|
||||
|
||||
if (registerTask != null) {
|
||||
switcher.showNext();
|
||||
binding.registerViewswitcher.showNext();
|
||||
} else {
|
||||
registerTask = new RegisterTask();
|
||||
registerTask.execute();
|
||||
|
@ -73,7 +67,18 @@ public class RegisterProgressFragment extends Fragment {
|
|||
return v;
|
||||
}
|
||||
|
||||
@OnClick(R.id.registering_next_1) void next() {
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
binding.registeringNext1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
next();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void next() {
|
||||
Intent i = new Intent(getActivity(), AddSocial.class);
|
||||
startActivity(i);
|
||||
}
|
||||
|
@ -88,7 +93,7 @@ public class RegisterProgressFragment extends Fragment {
|
|||
@Override
|
||||
protected void onPostExecute(RegisterResponse response) {
|
||||
if (response.authenticated) {
|
||||
switcher.showNext();
|
||||
binding.registerViewswitcher.showNext();
|
||||
} else {
|
||||
String errorMessage = response.getErrorMessage();
|
||||
if(errorMessage == null) {
|
||||
|
|
|
@ -8,20 +8,16 @@ import android.os.Bundle;
|
|||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.databinding.DialogRenameFeedBinding;
|
||||
import com.newsblur.domain.Feed;
|
||||
import com.newsblur.util.FeedUtils;
|
||||
|
||||
public class RenameFeedFragment extends DialogFragment {
|
||||
|
||||
private Feed feed;
|
||||
|
||||
@Bind(R.id.feed_name_field) EditText feedNameView;
|
||||
private DialogRenameFeedBinding binding;
|
||||
|
||||
public static RenameFeedFragment newInstance(Feed feed) {
|
||||
RenameFeedFragment fragment = new RenameFeedFragment();
|
||||
|
@ -39,13 +35,13 @@ public class RenameFeedFragment extends DialogFragment {
|
|||
final Activity activity = getActivity();
|
||||
LayoutInflater inflater = LayoutInflater.from(activity);
|
||||
View v = inflater.inflate(R.layout.dialog_rename_feed, null);
|
||||
ButterKnife.bind(this, v);
|
||||
binding = DialogRenameFeedBinding.bind(v);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle(String.format(getResources().getString(R.string.title_rename_feed), feed.title));
|
||||
builder.setView(v);
|
||||
|
||||
feedNameView.setText(feed.title);
|
||||
binding.feedNameField.setText(feed.title);
|
||||
|
||||
builder.setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
|
@ -56,7 +52,7 @@ public class RenameFeedFragment extends DialogFragment {
|
|||
builder.setPositiveButton(R.string.feed_name_save, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
FeedUtils.renameFeed(activity, feed.feedId, feedNameView.getText().toString());
|
||||
FeedUtils.renameFeed(activity, feed.feedId, binding.feedNameField.getText().toString());
|
||||
RenameFeedFragment.this.dismiss();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -14,20 +14,15 @@ import android.view.Gravity;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.databinding.DialogTrainstoryBinding;
|
||||
import com.newsblur.domain.Classifier;
|
||||
import com.newsblur.domain.Story;
|
||||
import com.newsblur.util.FeedSet;
|
||||
import com.newsblur.util.FeedUtils;
|
||||
import com.newsblur.util.UIUtils;
|
||||
import com.newsblur.view.SelectOnlyEditText;
|
||||
|
||||
public class StoryIntelTrainerFragment extends DialogFragment {
|
||||
|
||||
|
@ -35,17 +30,7 @@ public class StoryIntelTrainerFragment extends DialogFragment {
|
|||
private FeedSet fs;
|
||||
private Classifier classifier;
|
||||
private Integer newTitleTraining;
|
||||
|
||||
@Bind(R.id.intel_tag_header) TextView headerTags;
|
||||
@Bind(R.id.intel_author_header) TextView headerAuthor;
|
||||
@Bind(R.id.intel_title_selection) SelectOnlyEditText titleSelection;
|
||||
@Bind(R.id.intel_title_like) Button titleLikeButton;
|
||||
@Bind(R.id.intel_title_dislike) Button titleDislikeButton;
|
||||
@Bind(R.id.intel_title_clear) Button titleClearButton;
|
||||
@Bind(R.id.existing_title_intel_container) LinearLayout titleRowsContainer;
|
||||
@Bind(R.id.existing_tag_intel_container) LinearLayout tagRowsContainer;
|
||||
@Bind(R.id.existing_author_intel_container) LinearLayout authorRowsContainer;
|
||||
@Bind(R.id.existing_feed_intel_container) LinearLayout feedRowsContainer;
|
||||
private DialogTrainstoryBinding binding;
|
||||
|
||||
public static StoryIntelTrainerFragment newInstance(Story story, FeedSet fs) {
|
||||
if (story.feedId.equals("0")) {
|
||||
|
@ -69,44 +54,44 @@ public class StoryIntelTrainerFragment extends DialogFragment {
|
|||
final Activity activity = getActivity();
|
||||
LayoutInflater inflater = LayoutInflater.from(activity);
|
||||
View v = inflater.inflate(R.layout.dialog_trainstory, null);
|
||||
ButterKnife.bind(this, v);
|
||||
binding = DialogTrainstoryBinding.bind(v);
|
||||
|
||||
// set up the special title training box for the title from this story and the associated buttons
|
||||
titleSelection.setText(story.title);
|
||||
binding.intelTitleSelection.setText(story.title);
|
||||
// the layout sets inputType="none" on this EditText, but a widespread platform bug requires us
|
||||
// to also set this programmatically to make the field read-only for selection.
|
||||
titleSelection.setInputType(InputType.TYPE_NULL);
|
||||
binding.intelTitleSelection.setInputType(InputType.TYPE_NULL);
|
||||
// the user is selecting for our custom widget, not to copy/paste
|
||||
titleSelection.disableActionMenu();
|
||||
binding.intelTitleSelection.disableActionMenu();
|
||||
// pre-select the whole title to make it easier for the user to manipulate the selection handles
|
||||
titleSelection.selectAll();
|
||||
binding.intelTitleSelection.selectAll();
|
||||
// do this after init and selection to prevent toast spam
|
||||
titleSelection.setForceSelection(true);
|
||||
binding.intelTitleSelection.setForceSelection(true);
|
||||
// the disposition buttons for a new title training don't immediately impact the classifier object,
|
||||
// lest the user want to change selection substring after choosing the disposition. so just store
|
||||
// the training factor in a variable that can be pulled on completion
|
||||
titleLikeButton.setOnClickListener(new OnClickListener() {
|
||||
binding.intelTitleLike.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
newTitleTraining = Classifier.LIKE;
|
||||
titleLikeButton.setBackgroundResource(R.drawable.ic_like_active);
|
||||
titleDislikeButton.setBackgroundResource(R.drawable.ic_dislike_gray55);
|
||||
binding.intelTitleLike.setBackgroundResource(R.drawable.ic_like_active);
|
||||
binding.intelTitleDislike.setBackgroundResource(R.drawable.ic_dislike_gray55);
|
||||
}
|
||||
});
|
||||
titleDislikeButton.setOnClickListener(new OnClickListener() {
|
||||
binding.intelTitleDislike.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
newTitleTraining = Classifier.DISLIKE;
|
||||
titleLikeButton.setBackgroundResource(R.drawable.ic_like_gray55);
|
||||
titleDislikeButton.setBackgroundResource(R.drawable.ic_dislike_active);
|
||||
binding.intelTitleLike.setBackgroundResource(R.drawable.ic_like_gray55);
|
||||
binding.intelTitleDislike.setBackgroundResource(R.drawable.ic_dislike_active);
|
||||
}
|
||||
});
|
||||
titleClearButton.setOnClickListener(new OnClickListener() {
|
||||
binding.intelTitleClear.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
newTitleTraining = null;
|
||||
titleLikeButton.setBackgroundResource(R.drawable.ic_like_gray55);
|
||||
titleDislikeButton.setBackgroundResource(R.drawable.ic_dislike_gray55);
|
||||
binding.intelTitleLike.setBackgroundResource(R.drawable.ic_like_gray55);
|
||||
binding.intelTitleDislike.setBackgroundResource(R.drawable.ic_dislike_gray55);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -117,7 +102,7 @@ public class StoryIntelTrainerFragment extends DialogFragment {
|
|||
TextView label = (TextView) row.findViewById(R.id.intel_row_label);
|
||||
label.setText(rule.getKey());
|
||||
UIUtils.setupIntelDialogRow(row, classifier.title, rule.getKey());
|
||||
titleRowsContainer.addView(row);
|
||||
binding.existingTitleIntelContainer.addView(row);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,9 +112,9 @@ public class StoryIntelTrainerFragment extends DialogFragment {
|
|||
TextView label = (TextView) row.findViewById(R.id.intel_row_label);
|
||||
label.setText(tag);
|
||||
UIUtils.setupIntelDialogRow(row, classifier.tags, tag);
|
||||
tagRowsContainer.addView(row);
|
||||
binding.existingTagIntelContainer.addView(row);
|
||||
}
|
||||
if (story.tags.length < 1) headerTags.setVisibility(View.GONE);
|
||||
if (story.tags.length < 1) binding.intelTagHeader.setVisibility(View.GONE);
|
||||
|
||||
// there is a single author per story
|
||||
if (!TextUtils.isEmpty(story.authors)) {
|
||||
|
@ -137,9 +122,9 @@ public class StoryIntelTrainerFragment extends DialogFragment {
|
|||
TextView labelAuthor = (TextView) rowAuthor.findViewById(R.id.intel_row_label);
|
||||
labelAuthor.setText(story.authors);
|
||||
UIUtils.setupIntelDialogRow(rowAuthor, classifier.authors, story.authors);
|
||||
authorRowsContainer.addView(rowAuthor);
|
||||
binding.existingAuthorIntelContainer.addView(rowAuthor);
|
||||
} else {
|
||||
headerAuthor.setVisibility(View.GONE);
|
||||
binding.intelAuthorHeader.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// there is a single feed to be trained, but it is a bit odd in that the label is the title and
|
||||
|
@ -148,7 +133,7 @@ public class StoryIntelTrainerFragment extends DialogFragment {
|
|||
TextView labelFeed = (TextView) rowFeed.findViewById(R.id.intel_row_label);
|
||||
labelFeed.setText(FeedUtils.getFeedTitle(story.feedId));
|
||||
UIUtils.setupIntelDialogRow(rowFeed, classifier.feeds, story.feedId);
|
||||
feedRowsContainer.addView(rowFeed);
|
||||
binding.existingFeedIntelContainer.addView(rowFeed);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle(R.string.story_intel_dialog_title);
|
||||
|
@ -163,8 +148,8 @@ public class StoryIntelTrainerFragment extends DialogFragment {
|
|||
builder.setPositiveButton(R.string.dialog_story_intel_save, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
if ((newTitleTraining != null) && (!TextUtils.isEmpty(titleSelection.getSelection()))) {
|
||||
classifier.title.put(titleSelection.getSelection(), newTitleTraining);
|
||||
if ((newTitleTraining != null) && (!TextUtils.isEmpty(binding.intelTitleSelection.getSelection()))) {
|
||||
classifier.title.put(binding.intelTitleSelection.getSelection(), newTitleTraining);
|
||||
}
|
||||
FeedUtils.updateClassifier(story.feedId, classifier, fs, activity);
|
||||
StoryIntelTrainerFragment.this.dismiss();
|
||||
|
|
|
@ -7,13 +7,9 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.RadioButton;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.databinding.StoryorderDialogBinding;
|
||||
import com.newsblur.util.StoryOrder;
|
||||
import com.newsblur.util.StoryOrderChangedListener;
|
||||
|
||||
|
@ -21,8 +17,6 @@ public class StoryOrderDialogFragment extends DialogFragment {
|
|||
|
||||
private static String CURRENT_ORDER = "currentOrder";
|
||||
private StoryOrder currentValue;
|
||||
@Bind(R.id.radio_newest) RadioButton newestButton;
|
||||
@Bind(R.id.radio_oldest) RadioButton oldestButton;
|
||||
|
||||
public static StoryOrderDialogFragment newInstance(StoryOrder currentValue) {
|
||||
StoryOrderDialogFragment dialog = new StoryOrderDialogFragment();
|
||||
|
@ -42,25 +36,38 @@ public class StoryOrderDialogFragment extends DialogFragment {
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||
currentValue = (StoryOrder) getArguments().getSerializable(CURRENT_ORDER);
|
||||
View v = inflater.inflate(R.layout.storyorder_dialog, null);
|
||||
ButterKnife.bind(this, v);
|
||||
StoryorderDialogBinding binding = StoryorderDialogBinding.bind(v);
|
||||
|
||||
newestButton.setChecked(currentValue == StoryOrder.NEWEST);
|
||||
oldestButton.setChecked(currentValue == StoryOrder.OLDEST);
|
||||
binding.radioNewest.setChecked(currentValue == StoryOrder.NEWEST);
|
||||
binding.radioOldest.setChecked(currentValue == StoryOrder.OLDEST);
|
||||
|
||||
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
getDialog().getWindow().getAttributes().gravity = Gravity.BOTTOM;
|
||||
|
||||
binding.radioNewest.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
selectNewest();
|
||||
}
|
||||
});
|
||||
binding.radioOldest.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
selectOldest();
|
||||
}
|
||||
});
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@OnClick(R.id.radio_newest) void selectNewest() {
|
||||
private void selectNewest() {
|
||||
if (currentValue != StoryOrder.NEWEST) {
|
||||
((StoryOrderChangedListener) getActivity()).storyOrderChanged(StoryOrder.NEWEST);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@OnClick(R.id.radio_oldest) void selectOldest() {
|
||||
private void selectOldest() {
|
||||
if (currentValue != StoryOrder.OLDEST) {
|
||||
((StoryOrderChangedListener) getActivity()).storyOrderChanged(StoryOrder.OLDEST);
|
||||
}
|
||||
|
|
|
@ -5,14 +5,10 @@ import android.content.Context;
|
|||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Bind;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.databinding.StateToggleBinding;
|
||||
import com.newsblur.util.StateFilter;
|
||||
import com.newsblur.util.UIUtils;
|
||||
|
||||
|
@ -27,52 +23,53 @@ public class StateToggleButton extends LinearLayout {
|
|||
|
||||
private int parentWidthPX = 0;
|
||||
|
||||
@Bind(R.id.toggle_all) ViewGroup allButton;
|
||||
@Bind(R.id.toggle_all_icon) View allButtonIcon;
|
||||
@Bind(R.id.toggle_all_text) View allButtonText;
|
||||
@Bind(R.id.toggle_some) ViewGroup someButton;
|
||||
@Bind(R.id.toggle_some_icon) View someButtonIcon;
|
||||
@Bind(R.id.toggle_some_text) View someButtonText;
|
||||
@Bind(R.id.toggle_focus) ViewGroup focusButton;
|
||||
@Bind(R.id.toggle_focus_icon) View focusButtonIcon;
|
||||
@Bind(R.id.toggle_focus_text) View focusButtonText;
|
||||
@Bind(R.id.toggle_saved) ViewGroup savedButton;
|
||||
@Bind(R.id.toggle_saved_icon) View savedButtonIcon;
|
||||
@Bind(R.id.toggle_saved_text) View savedButtonText;
|
||||
private StateToggleBinding binding;
|
||||
|
||||
public StateToggleButton(Context context, AttributeSet art) {
|
||||
super(context, art);
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View view = inflater.inflate(R.layout.state_toggle, this);
|
||||
ButterKnife.bind(this, view);
|
||||
binding = StateToggleBinding.bind(view);
|
||||
|
||||
// smooth layout transitions are enabled in our layout XML; this smooths out toggle
|
||||
// transitions on newer devices
|
||||
allButton.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
|
||||
someButton.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
|
||||
focusButton.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
|
||||
savedButton.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
|
||||
binding.toggleAll.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
|
||||
binding.toggleSome.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
|
||||
binding.toggleFocus.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
|
||||
binding.toggleSaved.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
|
||||
|
||||
setState(state);
|
||||
|
||||
binding.toggleAll.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
setState(StateFilter.ALL);
|
||||
}
|
||||
});
|
||||
binding.toggleSome.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
setState(StateFilter.SOME);
|
||||
}
|
||||
});
|
||||
binding.toggleFocus.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
setState(StateFilter.BEST);
|
||||
}
|
||||
});
|
||||
binding.toggleSaved.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
setState(StateFilter.SAVED);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setStateListener(final StateChangedListener stateChangedListener) {
|
||||
this.stateChangedListener = stateChangedListener;
|
||||
}
|
||||
|
||||
@OnClick({R.id.toggle_all, R.id.toggle_some, R.id.toggle_focus, R.id.toggle_saved})
|
||||
public void onClickToggle(View v) {
|
||||
if (v.getId() == R.id.toggle_all) {
|
||||
setState(StateFilter.ALL);
|
||||
} else if (v.getId() == R.id.toggle_some) {
|
||||
setState(StateFilter.SOME);
|
||||
} else if (v.getId() == R.id.toggle_focus) {
|
||||
setState(StateFilter.BEST);
|
||||
} else if (v.getId() == R.id.toggle_saved) {
|
||||
setState(StateFilter.SAVED);
|
||||
}
|
||||
}
|
||||
|
||||
public void setState(StateFilter state) {
|
||||
this.state = state;
|
||||
updateButtonStates();
|
||||
|
@ -93,21 +90,21 @@ public class StateToggleButton extends LinearLayout {
|
|||
if (widthDP > COLLAPSE_WIDTH_DP) compactMode = false;
|
||||
}
|
||||
|
||||
allButtonText.setVisibility((!compactMode || state == StateFilter.ALL) ? View.VISIBLE : View.GONE);
|
||||
allButton.setEnabled(state != StateFilter.ALL);
|
||||
allButtonIcon.setAlpha(state == StateFilter.ALL ? 1.0f : 0.6f);
|
||||
binding.toggleAllText.setVisibility((!compactMode || state == StateFilter.ALL) ? View.VISIBLE : View.GONE);
|
||||
binding.toggleAll.setEnabled(state != StateFilter.ALL);
|
||||
binding.toggleAllIcon.setAlpha(state == StateFilter.ALL ? 1.0f : 0.6f);
|
||||
|
||||
someButtonText.setVisibility((!compactMode || state == StateFilter.SOME) ? View.VISIBLE : View.GONE);
|
||||
someButton.setEnabled(state != StateFilter.SOME);
|
||||
someButtonIcon.setAlpha(state == StateFilter.SOME ? 1.0f : 0.6f);
|
||||
binding.toggleSomeText.setVisibility((!compactMode || state == StateFilter.SOME) ? View.VISIBLE : View.GONE);
|
||||
binding.toggleSome.setEnabled(state != StateFilter.SOME);
|
||||
binding.toggleSomeIcon.setAlpha(state == StateFilter.SOME ? 1.0f : 0.6f);
|
||||
|
||||
focusButtonText.setVisibility((!compactMode || state == StateFilter.BEST) ? View.VISIBLE : View.GONE);
|
||||
focusButton.setEnabled(state != StateFilter.BEST);
|
||||
focusButtonIcon.setAlpha(state == StateFilter.BEST ? 1.0f : 0.6f);
|
||||
binding.toggleFocusText.setVisibility((!compactMode || state == StateFilter.BEST) ? View.VISIBLE : View.GONE);
|
||||
binding.toggleFocus.setEnabled(state != StateFilter.BEST);
|
||||
binding.toggleFocusIcon.setAlpha(state == StateFilter.BEST ? 1.0f : 0.6f);
|
||||
|
||||
savedButtonText.setVisibility((!compactMode || state == StateFilter.SAVED) ? View.VISIBLE : View.GONE);
|
||||
savedButton.setEnabled(state != StateFilter.SAVED);
|
||||
savedButtonIcon.setAlpha(state == StateFilter.SAVED ? 1.0f : 0.6f);
|
||||
binding.toggleSavedText.setVisibility((!compactMode || state == StateFilter.SAVED) ? View.VISIBLE : View.GONE);
|
||||
binding.toggleSaved.setEnabled(state != StateFilter.SAVED);
|
||||
binding.toggleSavedIcon.setAlpha(state == StateFilter.SAVED ? 1.0f : 0.6f);
|
||||
}
|
||||
|
||||
public interface StateChangedListener {
|
||||
|
|
Loading…
Add table
Reference in a new issue