use DI for SharedPreferences
This commit is contained in:
parent
62f79242b4
commit
555a4d656f
24 changed files with 115 additions and 228 deletions
|
@ -1,155 +0,0 @@
|
|||
package de.luhmer.owncloudnewsreader;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
* Mock implementation of shared preference, which just saves data in memory using map.
|
||||
*/
|
||||
public class MockSharedPreference implements SharedPreferences {
|
||||
|
||||
private final HashMap<String, Object> preferenceMap;
|
||||
private final MockSharedPreferenceEditor preferenceEditor;
|
||||
|
||||
public MockSharedPreference() {
|
||||
preferenceMap = new HashMap<>();
|
||||
preferenceEditor = new MockSharedPreferenceEditor(preferenceMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ?> getAll() {
|
||||
return preferenceMap;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getString(final String s, @Nullable final String s1) {
|
||||
Object v = preferenceMap.get(s);
|
||||
return v != null ? (String) v : s1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Set<String> getStringSet(final String s, @Nullable final Set<String> set) {
|
||||
Object v = preferenceMap.get(s);
|
||||
return v != null ? (Set<String>) v : set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(final String s, final int i) {
|
||||
Object v = preferenceMap.get(s);
|
||||
return v != null ? (int) v : i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(final String s, final long l) {
|
||||
Object v = preferenceMap.get(s);
|
||||
return v != null ? (long) v : l;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloat(final String s, final float f) {
|
||||
Object v = preferenceMap.get(s);
|
||||
return v != null ? (float) v : f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolean(final String s, final boolean b) {
|
||||
Object v = preferenceMap.get(s);
|
||||
return v != null ? (boolean) v : b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(final String s) {
|
||||
return preferenceMap.containsKey(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor edit() {
|
||||
return preferenceEditor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerOnSharedPreferenceChangeListener(final OnSharedPreferenceChangeListener onSharedPreferenceChangeListener) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterOnSharedPreferenceChangeListener(final OnSharedPreferenceChangeListener onSharedPreferenceChangeListener) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public static class MockSharedPreferenceEditor implements Editor {
|
||||
|
||||
private final HashMap<String, Object> preferenceMap;
|
||||
|
||||
public MockSharedPreferenceEditor(final HashMap<String, Object> preferenceMap) {
|
||||
this.preferenceMap = preferenceMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor putString(final String s, @Nullable final String s1) {
|
||||
preferenceMap.put(s, s1);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor putStringSet(final String s, @Nullable final Set<String> set) {
|
||||
preferenceMap.put(s, set);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor putInt(final String s, final int i) {
|
||||
preferenceMap.put(s, i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor putLong(final String s, final long l) {
|
||||
preferenceMap.put(s, l);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor putFloat(final String s, final float v) {
|
||||
preferenceMap.put(s, v);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor putBoolean(final String s, final boolean b) {
|
||||
preferenceMap.put(s, b);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor remove(final String s) {
|
||||
preferenceMap.remove(s);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor clear() {
|
||||
preferenceMap.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean commit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
// Nothing to do, everything is saved in memory.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,16 +1,19 @@
|
|||
package de.luhmer.owncloudnewsreader.di;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Environment;
|
||||
|
||||
import com.nextcloud.android.sso.AccountImporter;
|
||||
import com.nextcloud.android.sso.model.SingleSignOnAccount;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.MockSharedPreference;
|
||||
import de.luhmer.owncloudnewsreader.NewsReaderListFragment;
|
||||
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||
import de.luhmer.owncloudnewsreader.helper.ThemeChooser;
|
||||
import de.luhmer.owncloudnewsreader.model.UserInfo;
|
||||
import de.luhmer.owncloudnewsreader.ssl.MemorizingTrustManager;
|
||||
|
||||
|
@ -40,9 +43,11 @@ public class TestApiModule extends ApiModule {
|
|||
.setAvatar(null)
|
||||
.build();
|
||||
|
||||
//SharedPreferences sharedPrefs = new MockSharedPreference();
|
||||
SharedPreferences sharedPrefs = application.getSharedPreferences(providesSharedPreferencesFileName(), Context.MODE_PRIVATE);
|
||||
|
||||
|
||||
SharedPreferences sharedPrefs = new MockSharedPreference();
|
||||
// Reset SharedPreferences to make tests reproducible
|
||||
sharedPrefs.edit().clear().commit();
|
||||
|
||||
// Turn on Single-Sign-On
|
||||
sharedPrefs.edit().putBoolean(SettingsActivity.SW_USE_SINGLE_SIGN_ON, true).commit();
|
||||
|
@ -68,6 +73,8 @@ public class TestApiModule extends ApiModule {
|
|||
throw new Error(e);
|
||||
}
|
||||
|
||||
ThemeChooser.init(sharedPrefs);
|
||||
|
||||
return sharedPrefs;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import javax.inject.Singleton;
|
|||
|
||||
import dagger.Component;
|
||||
import de.luhmer.owncloudnewsreader.tests.NewFeedTests;
|
||||
import de.luhmer.owncloudnewsreader.tests.NewsReaderListActivityUiTests;
|
||||
import de.luhmer.owncloudnewsreader.tests.NightModeTest;
|
||||
|
||||
@Singleton
|
||||
|
@ -12,4 +13,6 @@ public interface TestComponent extends AppComponent {
|
|||
|
||||
void inject(NewFeedTests newFeedTest);
|
||||
void inject(NightModeTest nightModeTest);
|
||||
|
||||
void inject(NewsReaderListActivityUiTests newsReaderListActivityUiTests);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ import org.junit.runner.RunWith;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.test.espresso.Espresso;
|
||||
|
@ -25,8 +27,11 @@ import de.luhmer.owncloudnewsreader.Constants;
|
|||
import de.luhmer.owncloudnewsreader.NewsReaderDetailFragment;
|
||||
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
|
||||
import de.luhmer.owncloudnewsreader.R;
|
||||
import de.luhmer.owncloudnewsreader.TestApplication;
|
||||
import de.luhmer.owncloudnewsreader.adapter.NewsListRecyclerAdapter;
|
||||
import de.luhmer.owncloudnewsreader.adapter.ViewHolder;
|
||||
import de.luhmer.owncloudnewsreader.di.ApiProvider;
|
||||
import de.luhmer.owncloudnewsreader.di.TestComponent;
|
||||
import helper.OrientationChangeAction;
|
||||
import helper.RecyclerViewAssertions;
|
||||
|
||||
|
@ -52,6 +57,7 @@ public class NewsReaderListActivityUiTests {
|
|||
@Rule
|
||||
public ActivityTestRule<NewsReaderListActivity> mActivityRule = new ActivityTestRule<>(NewsReaderListActivity.class);
|
||||
|
||||
protected @Inject SharedPreferences mPrefs;
|
||||
|
||||
private NewsReaderListActivity getActivity() {
|
||||
return mActivityRule.getActivity();
|
||||
|
@ -61,6 +67,9 @@ public class NewsReaderListActivityUiTests {
|
|||
public void setUp() {
|
||||
registerInstance(getInstrumentation(), new Bundle());
|
||||
sleep(0.3f);
|
||||
|
||||
TestComponent ac = (TestComponent) ((TestApplication)(getActivity().getApplication())).getAppComponent();
|
||||
ac.inject(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -123,7 +132,6 @@ public class NewsReaderListActivityUiTests {
|
|||
onView(withId(R.id.list)).perform(RecyclerViewActions.scrollToPosition(scrollPosition));
|
||||
}
|
||||
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
mPrefs.edit().putInt(Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING, 5).commit();
|
||||
|
||||
try {
|
||||
|
|
|
@ -85,12 +85,11 @@ public class NightModeTest {
|
|||
public void testOledAutoMode() {
|
||||
openActionBarOverflowOrOptionsMenu(InstrumentationRegistry.getTargetContext());
|
||||
openSettings();
|
||||
|
||||
changeAppTheme(R.string.pref_display_apptheme_auto);
|
||||
sleep();
|
||||
switchOled();
|
||||
navigateUp();
|
||||
assertFalse(isDarkTheme());
|
||||
|
||||
sleep();
|
||||
|
||||
//onView(withId(R.id.sliding_layout)).check(ViewAssertions.matches(CustomMatchers.withBackgroundColor(android.R.color.white, getActivity())));
|
||||
|
@ -104,7 +103,7 @@ public class NightModeTest {
|
|||
|
||||
changeAppTheme(R.string.pref_display_apptheme_light);
|
||||
navigateUp();
|
||||
|
||||
sleep();
|
||||
boolean isDarkTheme = isDarkTheme();
|
||||
assertFalse(ThemeChooser.isOledMode(false));
|
||||
assertFalse(isDarkTheme);
|
||||
|
|
|
@ -18,9 +18,8 @@ public class Constants {
|
|||
protected static final int MIN_NEXTCLOUD_FILES_APP_VERSION_CODE = 30030052;
|
||||
|
||||
|
||||
protected static boolean isNextCloud(Context context) {
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
int[] version = extractVersionNumberFromString(mPrefs.getString(Constants.NEWS_WEB_VERSION_NUMBER_STRING, ""));
|
||||
protected static boolean isNextCloud(SharedPreferences prefs) {
|
||||
int[] version = extractVersionNumberFromString(prefs.getString(Constants.NEWS_WEB_VERSION_NUMBER_STRING, ""));
|
||||
if(version[0] == 0) {
|
||||
// not initialized yet..
|
||||
return true; // let's assume that it is nextcloud..
|
||||
|
|
|
@ -86,6 +86,8 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter
|
|||
private SparseArray<String> unreadCountFolders;
|
||||
private SparseArray<String> unreadCountFeeds;
|
||||
|
||||
private SharedPreferences mPrefs;
|
||||
|
||||
public enum SPECIAL_FOLDERS {
|
||||
ALL_UNREAD_ITEMS(-10), ALL_STARRED_ITEMS(-11), ALL_ITEMS(-12), ITEMS_WITHOUT_FOLDER(-22);
|
||||
|
||||
|
@ -109,8 +111,9 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter
|
|||
}
|
||||
}
|
||||
|
||||
public SubscriptionExpandableListAdapter(Context mContext, DatabaseConnectionOrm dbConn, ListView listView) {
|
||||
favIconHandler = new FavIconHandler(mContext);
|
||||
public SubscriptionExpandableListAdapter(Context mContext, DatabaseConnectionOrm dbConn, ListView listView, SharedPreferences prefs) {
|
||||
this.favIconHandler = new FavIconHandler(mContext);
|
||||
this.mPrefs = prefs;
|
||||
|
||||
this.inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
this.mContext = mContext;
|
||||
|
@ -499,7 +502,6 @@ public class SubscriptionExpandableListAdapter extends BaseExpandableListAdapter
|
|||
|
||||
public Tuple<ArrayList<AbstractItem>, SparseArray<ArrayList<ConcreteFeedItem>>> ReloadAdapter()
|
||||
{
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
showOnlyUnread = mPrefs.getBoolean(SettingsActivity.CB_SHOWONLYUNREAD_STRING, false);
|
||||
|
||||
ArrayList<AbstractItem> mCategoriesArrayListAsync = new ArrayList<>();
|
||||
|
|
|
@ -165,7 +165,6 @@ public class LoginDialogFragment extends DialogFragment {
|
|||
mImageViewShowPwd.setOnClickListener(ImgViewShowPasswordListener);
|
||||
mPasswordView.addTextChangedListener(PasswordTextChangedListener);
|
||||
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
mUsername = mPrefs.getString(SettingsActivity.EDT_USERNAME_STRING, "");
|
||||
mPassword = mPrefs.getString(SettingsActivity.EDT_PASSWORD_STRING, "");
|
||||
mOc_root_path = mPrefs.getString(SettingsActivity.EDT_OWNCLOUDROOTPATH_STRING, "");
|
||||
|
@ -185,7 +184,6 @@ public class LoginDialogFragment extends DialogFragment {
|
|||
mCbDisableHostnameVerificationView.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
mPrefs.edit()
|
||||
.putBoolean(SettingsActivity.CB_DISABLE_HOSTNAME_VERIFICATION_STRING, isChecked)
|
||||
.commit();
|
||||
|
|
|
@ -47,6 +47,8 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
|
@ -90,10 +92,14 @@ public class NewsDetailActivity extends PodcastFragmentActivity {
|
|||
private DatabaseConnectionOrm dbConn;
|
||||
public List<RssItem> rssItems;
|
||||
|
||||
protected @Inject SharedPreferences mPrefs;
|
||||
|
||||
//public static final String DATABASE_IDS_OF_ITEMS = "DATABASE_IDS_OF_ITEMS";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
((NewsReaderApplication) getApplication()).getAppComponent().injectActivity(this);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_news_detail);
|
||||
|
||||
|
@ -185,10 +191,9 @@ public class NewsDetailActivity extends PodcastFragmentActivity {
|
|||
}
|
||||
};
|
||||
|
||||
public static SORT_DIRECTION getSortDirectionFromSettings(Context context) {
|
||||
public static SORT_DIRECTION getSortDirectionFromSettings(SharedPreferences prefs) {
|
||||
SORT_DIRECTION sDirection = SORT_DIRECTION.asc;
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String sortDirection = mPrefs.getString(SettingsActivity.SP_SORT_ORDER, "1");
|
||||
String sortDirection = prefs.getString(SettingsActivity.SP_SORT_ORDER, "1");
|
||||
if (sortDirection.equals("1"))
|
||||
sDirection = SORT_DIRECTION.desc;
|
||||
return sDirection;
|
||||
|
@ -196,7 +201,6 @@ public class NewsDetailActivity extends PodcastFragmentActivity {
|
|||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if(mPrefs.getBoolean(SettingsActivity.CB_NAVIGATE_WITH_VOLUME_BUTTONS_STRING, false))
|
||||
{
|
||||
if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN))
|
||||
|
@ -334,8 +338,7 @@ public class NewsDetailActivity extends PodcastFragmentActivity {
|
|||
menuItem_Read = menu.findItem(R.id.action_read);
|
||||
menuItem_PlayPodcast = menu.findItem(R.id.action_playPodcast);
|
||||
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
|
||||
Set<String> selections = preferences.getStringSet("sp_news_detail_actionbar_icons", new HashSet<String>());
|
||||
Set<String> selections = mPrefs.getStringSet("sp_news_detail_actionbar_icons", new HashSet<String>());
|
||||
String[] selected = selections.toArray(new String[] {});
|
||||
for(String selection : selected) {
|
||||
switch(selection) {
|
||||
|
|
|
@ -268,7 +268,6 @@ public class NewsDetailFragment extends Fragment implements RssItemToHtmlTask.Li
|
|||
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
int selectedBrowser = Integer.parseInt(mPrefs.getString(SettingsActivity.SP_DISPLAY_BROWSER, "0"));
|
||||
|
||||
File webArchiveFile = DownloadWebPageService.getWebPageArchiveFileForUrl(getActivity(), url);
|
||||
|
|
|
@ -32,6 +32,8 @@ import android.os.Bundle;
|
|||
import android.os.Handler;
|
||||
import android.os.Parcelable;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.GestureDetectorCompat;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
@ -50,6 +52,8 @@ import android.widget.Toast;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
@ -104,6 +108,8 @@ public class NewsReaderDetailFragment extends Fragment {
|
|||
private int onResumeCount = 0;
|
||||
private RecyclerView.OnItemTouchListener itemTouchListener;
|
||||
|
||||
protected @Inject SharedPreferences mPrefs;
|
||||
|
||||
protected DisposableObserver<List<RssItem>> SearchResultObserver = new DisposableObserver<List<RssItem>>() {
|
||||
@Override
|
||||
public void onNext(List<RssItem> rssItems) {
|
||||
|
@ -129,8 +135,8 @@ public class NewsReaderDetailFragment extends Fragment {
|
|||
public NewsReaderDetailFragment() {
|
||||
}
|
||||
|
||||
public static SORT_DIRECTION getSortDirection(Context context) {
|
||||
return NewsDetailActivity.getSortDirectionFromSettings(context);
|
||||
public static SORT_DIRECTION getSortDirection(SharedPreferences prefs) {
|
||||
return NewsDetailActivity.getSortDirectionFromSettings(prefs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,8 +179,6 @@ public class NewsReaderDetailFragment extends Fragment {
|
|||
public void onResume() {
|
||||
Log.v(TAG, "onResume called!");
|
||||
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
|
||||
mMarkAsReadWhileScrollingEnabled = mPrefs.getBoolean(SettingsActivity.CB_MARK_AS_READ_WHILE_SCROLLING_STRING, false);
|
||||
|
||||
//When the fragment is instantiated by the xml file, onResume will be called twice
|
||||
|
@ -256,14 +260,14 @@ public class NewsReaderDetailFragment extends Fragment {
|
|||
};
|
||||
mainHandler.post(myRunnable);
|
||||
|
||||
return Search.PerformSearch(getActivity(), idFolder, idFeed, searchString);
|
||||
return Search.PerformSearch(getActivity(), idFolder, idFeed, searchString, mPrefs);
|
||||
}
|
||||
|
||||
void loadRssItemsIntoView(List<RssItem> rssItems) {
|
||||
try {
|
||||
NewsListRecyclerAdapter nra = ((NewsListRecyclerAdapter) recyclerView.getAdapter());
|
||||
if (nra == null) {
|
||||
nra = new NewsListRecyclerAdapter(getActivity(), recyclerView, (PodcastFragmentActivity) getActivity(), ((PodcastFragmentActivity) getActivity()).mPostDelayHandler);
|
||||
nra = new NewsListRecyclerAdapter(getActivity(), recyclerView, (PodcastFragmentActivity) getActivity(), ((PodcastFragmentActivity) getActivity()).mPostDelayHandler, mPrefs);
|
||||
|
||||
recyclerView.setAdapter(nra);
|
||||
}
|
||||
|
@ -400,10 +404,13 @@ public class NewsReaderDetailFragment extends Fragment {
|
|||
@Override
|
||||
public void onInflate(Context context, AttributeSet attrs, Bundle savedInstanceState) {
|
||||
super.onInflate(context, attrs, savedInstanceState);
|
||||
|
||||
((NewsReaderApplication) getActivity().getApplication()).getAppComponent().injectFragment(this);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, new int[]{R.attr.markasreadDrawable, R.attr.starredDrawable, R.attr.colorAccent});
|
||||
markAsReadDrawable = a.getDrawable(0);
|
||||
starredDrawable = a.getDrawable(1);
|
||||
int color = Constants.isNextCloud(getContext()) ? R.color.nextcloudBlue : R.color.owncloudBlue;
|
||||
int color = Constants.isNextCloud(mPrefs) ? R.color.nextcloudBlue : R.color.owncloudBlue;
|
||||
accentColor = a.getColor(2, ContextCompat.getColor(context, color));
|
||||
a.recycle();
|
||||
}
|
||||
|
@ -444,8 +451,7 @@ public class NewsReaderDetailFragment extends Fragment {
|
|||
@Override
|
||||
protected List<RssItem> doInBackground(Void... voids) {
|
||||
DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(context);
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
SORT_DIRECTION sortDirection = getSortDirection(context);
|
||||
SORT_DIRECTION sortDirection = getSortDirection(mPrefs);
|
||||
boolean onlyUnreadItems = mPrefs.getBoolean(SettingsActivity.CB_SHOWONLYUNREAD_STRING, false);
|
||||
boolean onlyStarredItems = false;
|
||||
if (idFolder != null && idFolder == ALL_STARRED_ITEMS.getValue())
|
||||
|
|
|
@ -188,7 +188,6 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
initAccountManager();
|
||||
|
||||
//Init config --> if nothing is configured start the login dialog.
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if (mPrefs.getString(SettingsActivity.EDT_OWNCLOUDROOTPATH_STRING, null) == null) {
|
||||
StartLoginFragment(NewsReaderListActivity.this);
|
||||
}
|
||||
|
@ -317,8 +316,7 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
savedInstanceState.containsKey(IS_FOLDER_BOOLEAN) &&
|
||||
savedInstanceState.containsKey(OPTIONAL_FOLDER_ID)) {
|
||||
|
||||
|
||||
NewsListRecyclerAdapter adapter = new NewsListRecyclerAdapter(this, getNewsReaderDetailFragment().recyclerView, this, mPostDelayHandler);
|
||||
NewsListRecyclerAdapter adapter = new NewsListRecyclerAdapter(this, getNewsReaderDetailFragment().recyclerView, this, mPostDelayHandler, mPrefs);
|
||||
|
||||
adapter.setTotalItemCount(savedInstanceState.getInt(LIST_ADAPTER_TOTAL_COUNT));
|
||||
adapter.setCachedPages(savedInstanceState.getInt(LIST_ADAPTER_PAGE_COUNT));
|
||||
|
@ -403,7 +401,7 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
Account account = new Account(getString(R.string.app_name), AccountGeneral.ACCOUNT_TYPE);
|
||||
mAccountManager.addAccountExplicitly(account, "", new Bundle());
|
||||
|
||||
SyncIntervalSelectorActivity.SetAccountSyncInterval(this);
|
||||
SyncIntervalSelectorActivity.SetAccountSyncInterval(this, mPrefs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -501,7 +499,6 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
getSlidingListFragment().startAsyncTaskGetUserInfo();
|
||||
}
|
||||
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(NewsReaderListActivity.this);
|
||||
int newItemsCount = mPrefs.getInt(Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING, 0);
|
||||
|
||||
if (newItemsCount > 0) {
|
||||
|
@ -657,8 +654,6 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
|
||||
public void startSync()
|
||||
{
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
if(mPrefs.getString(SettingsActivity.EDT_OWNCLOUDROOTPATH_STRING, null) == null) {
|
||||
StartLoginFragment(this);
|
||||
} else {
|
||||
|
@ -873,7 +868,7 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
|
||||
private void DownloadMoreItems()
|
||||
{
|
||||
String username = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("edt_username", null);
|
||||
String username = mPrefs.getString("edt_username", null);
|
||||
|
||||
if(username != null) {
|
||||
final NewsReaderDetailFragment ndf = getNewsReaderDetailFragment();
|
||||
|
@ -994,7 +989,6 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
}
|
||||
|
||||
private void ensureCorrectTheme(Intent data) {
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
String oldListLayout = data.getStringExtra(SettingsActivity.SP_FEED_LIST_LAYOUT);
|
||||
String newListLayout = mPrefs.getString(SettingsActivity.SP_FEED_LIST_LAYOUT,"0");
|
||||
|
||||
|
@ -1043,7 +1037,6 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements
|
|||
@Override
|
||||
public void onClick(ViewHolder vh, int position) {
|
||||
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if (mPrefs.getBoolean(SettingsActivity.CB_SKIP_DETAILVIEW_AND_OPEN_BROWSER_DIRECTLY_STRING, false)) {
|
||||
String currentUrl = vh.getRssItem().getLink();
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ public class NewsReaderListFragment extends Fragment implements OnCreateContextM
|
|||
|
||||
loadOwncloudOrNextcloudBanner();
|
||||
|
||||
lvAdapter = new SubscriptionExpandableListAdapter(getActivity(), new DatabaseConnectionOrm(getActivity()), eListView);
|
||||
lvAdapter = new SubscriptionExpandableListAdapter(getActivity(), new DatabaseConnectionOrm(getActivity()), eListView, mPrefs);
|
||||
lvAdapter.setHandlerListener(expListTextClickedListener);
|
||||
|
||||
eListView.setGroupIndicator(null);
|
||||
|
@ -201,7 +201,7 @@ public class NewsReaderListFragment extends Fragment implements OnCreateContextM
|
|||
}
|
||||
|
||||
protected void loadOwncloudOrNextcloudBanner() {
|
||||
if(!Constants.isNextCloud(getContext())) {
|
||||
if(!Constants.isNextCloud(mPrefs)) {
|
||||
// Set ownCloud view
|
||||
headerView.setBackgroundResource(R.drawable.left_drawer_header_background);
|
||||
}
|
||||
|
|
|
@ -92,7 +92,6 @@ public class SettingsActivity extends AppCompatActivity {
|
|||
|
||||
protected @Inject SharedPreferences mPrefs;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
((NewsReaderApplication) getApplication()).getAppComponent().injectActivity(this);
|
||||
|
|
|
@ -14,6 +14,7 @@ import android.provider.Settings;
|
|||
import android.widget.Toast;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import androidx.preference.CheckBoxPreference;
|
||||
import androidx.preference.DialogPreference;
|
||||
|
@ -50,13 +51,17 @@ import static de.luhmer.owncloudnewsreader.SettingsActivity.SP_SORT_ORDER;
|
|||
|
||||
public class SettingsFragment extends PreferenceFragmentCompat {
|
||||
|
||||
@Inject SharedPreferences mPrefs;
|
||||
protected @Inject SharedPreferences mPrefs;
|
||||
protected @Inject @Named("sharedPreferencesFileName") String sharedPreferencesFileName;
|
||||
private static String version = "<loading>";
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
((NewsReaderApplication) getActivity().getApplication()).getAppComponent().injectFragment(this);
|
||||
|
||||
// Define the settings file to use by this settings fragment
|
||||
getPreferenceManager().setSharedPreferencesName(sharedPreferencesFileName);
|
||||
|
||||
version = VersionInfoDialogFragment.getVersionString(getActivity());
|
||||
|
||||
addPreferencesFromResource(R.xml.pref_general);
|
||||
|
|
|
@ -15,6 +15,9 @@ import android.view.ViewGroup;
|
|||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
@ -26,10 +29,10 @@ import de.luhmer.owncloudnewsreader.helper.ThemeChooser;
|
|||
|
||||
public class SyncIntervalSelectorActivity extends AppCompatActivity {
|
||||
|
||||
SharedPreferences mPrefs;
|
||||
PlaceholderFragment mFragment;
|
||||
String[] items_values;
|
||||
private PlaceholderFragment mFragment;
|
||||
private String[] items_values;
|
||||
protected @BindView(R.id.toolbar) Toolbar toolbar;
|
||||
protected @Inject SharedPreferences mPrefs;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -47,7 +50,6 @@ public class SyncIntervalSelectorActivity extends AppCompatActivity {
|
|||
setSupportActionBar(toolbar);
|
||||
}
|
||||
|
||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
items_values = getResources().getStringArray(R.array.array_sync_interval_values);
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
|
@ -83,7 +85,7 @@ public class SyncIntervalSelectorActivity extends AppCompatActivity {
|
|||
|
||||
mPrefs.edit().putInt(SYNC_INTERVAL_IN_MINUTES_STRING, minutes).commit();
|
||||
|
||||
SetAccountSyncInterval(this);
|
||||
SetAccountSyncInterval(this, mPrefs);
|
||||
|
||||
finish();
|
||||
}
|
||||
|
@ -93,8 +95,7 @@ public class SyncIntervalSelectorActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
|
||||
public static void SetAccountSyncInterval(Context context) {
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
public static void SetAccountSyncInterval(Context context, SharedPreferences mPrefs) {
|
||||
int minutes = mPrefs.getInt(SYNC_INTERVAL_IN_MINUTES_STRING, 0);
|
||||
|
||||
if(minutes != 0) {
|
||||
|
@ -129,11 +130,18 @@ public class SyncIntervalSelectorActivity extends AppCompatActivity {
|
|||
|
||||
public static class PlaceholderFragment extends Fragment {
|
||||
|
||||
public ListView lvItems;
|
||||
private ListView lvItems;
|
||||
@Inject SharedPreferences mPrefs;
|
||||
|
||||
public PlaceholderFragment() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
((NewsReaderApplication) getActivity().getApplication()).getAppComponent().injectFragment(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
@ -141,7 +149,7 @@ public class SyncIntervalSelectorActivity extends AppCompatActivity {
|
|||
|
||||
String[] items = getResources().getStringArray(R.array.array_sync_interval);
|
||||
|
||||
lvItems = (ListView) rootView.findViewById(R.id.lv_sync_interval_items);
|
||||
lvItems = rootView.findViewById(R.id.lv_sync_interval_items);
|
||||
lvItems.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
|
||||
|
||||
|
||||
|
@ -151,7 +159,6 @@ public class SyncIntervalSelectorActivity extends AppCompatActivity {
|
|||
|
||||
lvItems.setAdapter(adapter);
|
||||
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
if(!mPrefs.contains(SYNC_INTERVAL_IN_MINUTES_STRING))
|
||||
lvItems.setItemChecked(items.length - 1, true);//The last item is 24hours. This is the default value!
|
||||
else {
|
||||
|
|
|
@ -69,10 +69,12 @@ public class NewsListRecyclerAdapter extends RecyclerView.Adapter {
|
|||
// The minimum amount of items to have below your current scroll position
|
||||
// before loading more.
|
||||
private int visibleThreshold = 5;
|
||||
private SharedPreferences mPrefs;
|
||||
|
||||
public NewsListRecyclerAdapter(FragmentActivity activity, RecyclerView recyclerView, IPlayPausePodcastClicked playPausePodcastClicked, PostDelayHandler postDelayHandler) {
|
||||
public NewsListRecyclerAdapter(FragmentActivity activity, RecyclerView recyclerView, IPlayPausePodcastClicked playPausePodcastClicked, PostDelayHandler postDelayHandler, SharedPreferences prefs) {
|
||||
this.activity = activity;
|
||||
this.playPausePodcastClicked = playPausePodcastClicked;
|
||||
this.mPrefs = prefs;
|
||||
|
||||
pDelayHandler = postDelayHandler;
|
||||
|
||||
|
@ -153,7 +155,6 @@ public class NewsListRecyclerAdapter extends RecyclerView.Adapter {
|
|||
|
||||
return new ProgressViewHolder(v);
|
||||
} else {
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
Integer layout = 0;
|
||||
switch (Integer.parseInt(mPrefs.getString(SettingsActivity.SP_FEED_LIST_LAYOUT, "0"))) {
|
||||
case 0:
|
||||
|
|
|
@ -280,7 +280,7 @@ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL
|
|||
String body = rssItem.getBody();
|
||||
// Strip html from String
|
||||
if(selectedListLayout == 0) {
|
||||
textViewBody.setMaxLines(scaleTextLines(textViewBody));
|
||||
textViewBody.setMaxLines(scaleTextLines(mPrefs));
|
||||
body = getBodyText(body, false);
|
||||
|
||||
} else if(selectedListLayout == 3) {
|
||||
|
@ -356,12 +356,10 @@ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL
|
|||
* Return the number of rss item body text lines, depending on the currently selected font size/scale;
|
||||
* only meant to be used with thumbnail feed view.
|
||||
*
|
||||
* @param tv TextView object, needed to get context->preferences from
|
||||
* @return number of lines of rss item body text lines to be used in thumbnail feed view
|
||||
*/
|
||||
private static int scaleTextLines(TextView tv) {
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(tv.getContext());
|
||||
float scalingFactor = Float.parseFloat(mPrefs.getString(SettingsActivity.SP_FONT_SIZE, "1.0"));
|
||||
private static int scaleTextLines(SharedPreferences prefs) {
|
||||
float scalingFactor = Float.parseFloat(prefs.getString(SettingsActivity.SP_FONT_SIZE, "1.0"));
|
||||
/* The following formula computes the number of text lines for Simple item view; it simply boils
|
||||
* down to a linear conversion from the font scaling factor from 0.8 -> 6 lines to 1.6 -> 3 lines
|
||||
*/
|
||||
|
|
|
@ -229,8 +229,6 @@ public class OwnCloudSyncAdapter extends AbstractThreadedSyncAdapter {
|
|||
}
|
||||
|
||||
private void updateNotification() {
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
||||
DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(getContext());
|
||||
int newItemsCount = Integer.parseInt(dbConn.getUnreadItemsCountForSpecificFolder(SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_UNREAD_ITEMS));
|
||||
//int newItemsCount = mPrefs.getInt(Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING, 0);
|
||||
|
|
|
@ -6,6 +6,7 @@ import dagger.Component;
|
|||
import de.luhmer.owncloudnewsreader.LoginDialogFragment;
|
||||
import de.luhmer.owncloudnewsreader.NewFeedActivity;
|
||||
import de.luhmer.owncloudnewsreader.NewsDetailFragment;
|
||||
import de.luhmer.owncloudnewsreader.NewsReaderDetailFragment;
|
||||
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
|
||||
import de.luhmer.owncloudnewsreader.NewsReaderListDialogFragment;
|
||||
import de.luhmer.owncloudnewsreader.NewsReaderListFragment;
|
||||
|
@ -15,6 +16,7 @@ import de.luhmer.owncloudnewsreader.SettingsFragment;
|
|||
import de.luhmer.owncloudnewsreader.SyncIntervalSelectorActivity;
|
||||
import de.luhmer.owncloudnewsreader.authentication.OwnCloudSyncAdapter;
|
||||
import de.luhmer.owncloudnewsreader.services.SyncItemStateService;
|
||||
import de.luhmer.owncloudnewsreader.widget.WidgetProvider;
|
||||
|
||||
/**
|
||||
* Created by david on 22.05.17.
|
||||
|
@ -35,8 +37,11 @@ public interface AppComponent {
|
|||
void injectFragment(LoginDialogFragment fragment);
|
||||
void injectFragment(SettingsFragment fragment);
|
||||
void injectFragment(NewsDetailFragment fragment);
|
||||
void injectFragment(NewsReaderDetailFragment fragment);
|
||||
void injectFragment(SyncIntervalSelectorActivity.PlaceholderFragment fragment);
|
||||
|
||||
void injectService(SyncItemStateService service);
|
||||
void injectService(OwnCloudSyncAdapter ownCloudSyncAdapter);
|
||||
|
||||
void injectWidget(WidgetProvider widgetProvider);
|
||||
}
|
||||
|
|
|
@ -18,11 +18,9 @@ public class Search {
|
|||
private static final String SEARCH_IN_TITLE = "0";
|
||||
private static final String SEARCH_IN_BODY = "1";
|
||||
|
||||
public static List<RssItem> PerformSearch(Context context, Long idFolder, Long idFeed, String searchString) {
|
||||
DatabaseConnectionOrm.SORT_DIRECTION sortDirection = NewsDetailActivity.getSortDirectionFromSettings(context);
|
||||
public static List<RssItem> PerformSearch(Context context, Long idFolder, Long idFeed, String searchString, SharedPreferences mPrefs) {
|
||||
DatabaseConnectionOrm.SORT_DIRECTION sortDirection = NewsDetailActivity.getSortDirectionFromSettings(mPrefs);
|
||||
DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(context);
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
String sqlSelectStatement = null;
|
||||
if (idFeed != null) {
|
||||
sqlSelectStatement = getFeedSQLStatement(idFeed, sortDirection, searchString, dbConn, mPrefs);
|
||||
|
|
|
@ -107,6 +107,7 @@ public class ThemeChooser {
|
|||
public static boolean themeRequiresRestartOfUI() {
|
||||
boolean themeChanged = !mSelectedThemeFromPreferences.equals(getSelectedThemeFromPreferences(true));
|
||||
boolean oledChanged = !mOledMode.equals(isOledMode(true));
|
||||
Log.v(TAG, "themeChanged: " + themeChanged + "; oledChanged: " + oledChanged);
|
||||
return themeChanged || oledChanged;
|
||||
}
|
||||
|
||||
|
@ -153,7 +154,7 @@ public class ThemeChooser {
|
|||
|
||||
public static void init(SharedPreferences prefs) {
|
||||
mPrefs = prefs;
|
||||
getSelectedThemeFromPreferences(false); // Init cache
|
||||
isOledMode(false); // Init cache
|
||||
getSelectedThemeFromPreferences(true); // Init cache
|
||||
isOledMode(true); // Init cache
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,6 @@ public class RssItemObservable implements Publisher<Integer> {
|
|||
mDbConn.clearDatabaseOverSize();
|
||||
|
||||
//String authKey = AuthenticationManager.getGoogleAuthKey(username, password);
|
||||
//SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
//int maxItemsInDatabase = Integer.parseInt(mPrefs.getString(SettingsActivity.SP_MAX_ITEMS_SYNC, "200"));
|
||||
|
||||
long lastModified = mDbConn.getLastModified();
|
||||
|
|
|
@ -35,8 +35,11 @@ import android.widget.RemoteViews;
|
|||
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.Constants;
|
||||
import de.luhmer.owncloudnewsreader.NewsDetailActivity;
|
||||
import de.luhmer.owncloudnewsreader.NewsReaderApplication;
|
||||
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
|
||||
import de.luhmer.owncloudnewsreader.R;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnectionOrm;
|
||||
|
@ -55,6 +58,8 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||
public static final String EXTRA_ITEM = null;
|
||||
private static final String TAG = "WidgetProvider";
|
||||
|
||||
protected @Inject SharedPreferences mPrefs;
|
||||
|
||||
|
||||
public static void UpdateWidget(Context context) {
|
||||
int ids[] = AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context, WidgetProvider.class));
|
||||
|
@ -78,6 +83,8 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
inject(context);
|
||||
|
||||
final int appWidgetId[];
|
||||
if(intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS))
|
||||
appWidgetId = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
|
||||
|
@ -142,7 +149,8 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||
|
||||
@Override
|
||||
public void onDeleted(Context context, int[] appWidgetIds) {
|
||||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
inject(context);
|
||||
|
||||
SharedPreferences.Editor mPrefsEditor = mPrefs.edit();
|
||||
|
||||
for(int appWidgetId : appWidgetIds) {
|
||||
|
@ -161,7 +169,7 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||
Log.d(TAG, "DELETE WIDGET - WIDGET_ID: " + appWidgetId);
|
||||
}*/
|
||||
|
||||
mPrefsEditor.commit();
|
||||
mPrefsEditor.commit();
|
||||
|
||||
|
||||
super.onDeleted(context, appWidgetIds);
|
||||
|
@ -169,6 +177,8 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||
|
||||
@Override
|
||||
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
||||
inject(context);
|
||||
|
||||
if(Constants.debugModeWidget)
|
||||
Log.d(TAG, "onUpdate");
|
||||
|
||||
|
@ -221,4 +231,8 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||
if(Constants.debugModeWidget)
|
||||
Log.d(TAG, "updateAppWidget - WidgetID: " + appWidgetId);
|
||||
}
|
||||
|
||||
private void inject(Context context) {
|
||||
((NewsReaderApplication) context.getApplicationContext()).getAppComponent().injectWidget(this);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue