Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Enable reading lists sync with DroidWiki account

  • Loading branch information...
FlorianSW committed May 6, 2018
1 parent 6392b2a commit 220c518837da76d1d4116b100162f9ea87d1075a
@@ -58,7 +58,7 @@ private SharedPreferenceCookieManager() {
// For sites outside the wikipedia.org domain, like wikidata.org,
// transfer the centralauth cookies from wikipedia.org, too, if the user is logged in
if (AccountUtil.isLoggedIn()
&& domain.equals("www.wikidata.org") && domainSpec.endsWith("wikipedia.org")) {
&& domain.equals("www.wikidata.org") && domainSpec.endsWith("droidwiki.org")) {
cookiesList.addAll(makeCookieList(cookieJar.get(domainSpec), CENTRALAUTH_PREFIX));
}

@@ -67,7 +67,7 @@ private SharedPreferenceCookieManager() {
// en.wikipedia.org and *.wikimedia.org
// FIXME: Whitelist the domains we accept cookies from/send cookies to. SECURITY!!!1
if (domain.endsWith(domainSpec)
|| (domain.endsWith(".wikimedia.org") && domainSpec.endsWith("wikipedia.org"))) {
|| (domain.endsWith(".droidwiki.org") && domainSpec.endsWith("droidwiki.org"))) {
cookiesList.addAll(makeCookieList(cookieJar.get(domainSpec)));
}
}
@@ -39,6 +39,17 @@
// cards.add(card);
// }

card = new ReadingListsSyncOnboardingCard(new Announcement(
"readingListssyncCard",
context.getString(R.string.feed_reading_lists_sync_onboarding_text),
"https://upload.wikimedia.org/wikipedia/commons/5/53/Reading_list_sync_image.png",
new Announcement.Action(context.getString(R.string.menu_login), UriUtil.LOCAL_URL_LOGIN),
context.getString(R.string.onboarding_got_it)));

if (card.shouldShow()) {
cards.add(card);
}

card = new CustomizeOnboardingCard(new Announcement(
"customizeOnboardingCard1",
context.getString(R.string.feed_configure_onboarding_text),
@@ -43,6 +43,7 @@
import org.wikipedia.readinglist.sync.ReadingListSyncEvent;
import org.wikipedia.settings.Prefs;
import org.wikipedia.util.FeedbackUtil;
import org.wikipedia.util.StringUtil;
import org.wikipedia.util.log.L;
import org.wikipedia.views.DrawableItemDecoration;
import org.wikipedia.views.SearchEmptyView;
@@ -505,7 +506,30 @@ protected boolean finishActionModeIfKeyboardHiding() {
}

private void maybeShowOnboarding() {
// no-op
onboardingContainer.removeAllViews();

if (AccountUtil.isLoggedIn() && !Prefs.isReadingListSyncEnabled()
&& Prefs.isReadingListSyncReminderEnabled()
&& !ReadingListSyncAdapter.isDisabledByRemoteConfig()) {
OnboardingView onboardingView = new OnboardingView(requireContext());
onboardingView.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.base20));
onboardingView.setTitle(R.string.reading_lists_sync_reminder_title);
onboardingView.setText(StringUtil.fromHtml(getString(R.string.reading_lists_sync_reminder_text)));
onboardingView.setPositiveAction(R.string.reading_lists_sync_reminder_action);
onboardingContainer.addView(onboardingView);
onboardingView.setCallback(new SyncReminderOnboardingCallback());

} else if (!AccountUtil.isLoggedIn() && Prefs.isReadingListLoginReminderEnabled()
&& !ReadingListSyncAdapter.isDisabledByRemoteConfig()) {
OnboardingView onboardingView = new OnboardingView(requireContext());
onboardingView.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.base20));
onboardingView.setTitle(R.string.reading_list_login_reminder_title);
onboardingView.setText(R.string.reading_lists_login_reminder_text);
onboardingView.setNegativeAction(R.string.reading_lists_onboarding_got_it);
onboardingView.setPositiveAction(R.string.menu_login);
onboardingContainer.addView(onboardingView);
onboardingView.setCallback(new LoginReminderOnboardingCallback());
}
}

private class SyncReminderOnboardingCallback implements OnboardingView.Callback {
@@ -336,7 +336,7 @@ public static Level getRetrofitLogLevel() {
@NonNull
public static String getRestbaseUriFormat() {
return defaultIfBlank(getString(R.string.preference_key_restbase_uri_format, null),
"%1$s://%2$s/api/rest_v1/");
"%1$s://%2$s/api/v1/");
}

@NonNull
@@ -486,39 +486,39 @@ public static void incrementTotalAnonDescriptionsEdited() {
}

public static boolean isReadingListSyncEnabled() {
return false;
return getBoolean(R.string.preference_key_sync_reading_lists, false);
}

public static void setReadingListSyncEnabled(boolean enabled) {
setBoolean(R.string.preference_key_sync_reading_lists, enabled);
}

public static boolean isReadingListSyncReminderEnabled() {
return false;
return getBoolean(R.string.preference_key_reading_list_sync_reminder_enabled, true);
}

public static void setReadingListSyncReminderEnabled(boolean enabled) {
setBoolean(R.string.preference_key_reading_list_sync_reminder_enabled, enabled);
}

public static boolean isReadingListLoginReminderEnabled() {
return false;
return getBoolean(R.string.preference_key_reading_list_login_reminder_enabled, true);
}

public static void setReadingListLoginReminderEnabled(boolean enabled) {
setBoolean(R.string.preference_key_reading_list_login_reminder_enabled, enabled);
}

public static boolean isReadingListsRemoteDeletePending() {
return false;
return getBoolean(R.string.preference_key_reading_lists_remote_delete_pending, false);
}

public static void setReadingListsRemoteDeletePending(boolean pending) {
setBoolean(R.string.preference_key_reading_lists_remote_delete_pending, pending);
}

public static boolean isReadingListsRemoteSetupPending() {
return false;
return getBoolean(R.string.preference_key_reading_lists_remote_setup_pending, false);
}

public static void setReadingListsRemoteSetupPending(boolean pending) {
@@ -725,23 +725,23 @@ public static void setReadingListPagesDeletedIds(@NonNull Set<String> set) {
}

public static boolean shouldShowReadingListSyncEnablePrompt() {
return false;
return getBoolean(R.string.preference_key_show_reading_lists_sync_prompt, true);
}

public static void shouldShowReadingListSyncEnablePrompt(boolean enabled) {
setBoolean(R.string.preference_key_show_reading_lists_sync_prompt, enabled);
}

public static boolean shouldShowReadingListSyncMergePrompt() {
return false;
return getBoolean(R.string.preference_key_show_reading_lists_merge_prompt, true);
}

public static void shouldShowReadingListSyncMergePrompt(boolean enabled) {
setBoolean(R.string.preference_key_show_reading_lists_merge_prompt, enabled);
}

public static boolean isReadingListsFirstTimeSync() {
return false;
return getBoolean(R.string.preference_key_reading_lists_first_time_sync, true);
}

public static void setReadingListsFirstTimeSync(boolean value) {
@@ -40,6 +40,9 @@ public void loadPreferences() {
loadPreferences(R.xml.preferences_zero);
}

findPreference(R.string.preference_key_sync_reading_lists)
.setOnPreferenceChangeListener(new SyncReadingListsListener());

if (ReleaseUtil.isPreBetaRelease()) {
loadPreferences(R.xml.preferences_experimental);
Preference offlineLibPref = findPreference(R.string.preference_key_enable_offline_library);
@@ -100,7 +100,7 @@ public static void visitInExternalBrowser(final Context context, Uri uri) {

public static boolean isValidPageLink(@NonNull Uri uri) {
return (!TextUtils.isEmpty(uri.getAuthority())
&& uri.getAuthority().endsWith("wikipedia.org")
&& uri.getAuthority().endsWith("droidwiki.org")
&& !TextUtils.isEmpty(uri.getPath())
&& uri.getPath().startsWith("/wiki"));
}
@@ -111,7 +111,7 @@ public static boolean isValidPageLink(@NonNull Uri uri) {
*/
public static boolean isValidOfflinePageLink(@NonNull Uri uri) {
return (!TextUtils.isEmpty(uri.getAuthority())
&& uri.getAuthority().endsWith("wikipedia.org")
&& uri.getAuthority().endsWith("droidwiki.org")
&& !TextUtils.isEmpty(uri.getPath())
&& uri.getPath().endsWith(".html"));
}
@@ -18,6 +18,14 @@
android:title="@string/preference_title_app_theme"
android:summary="@string/preference_summary_color_theme"/>
</PreferenceCategory>
<PreferenceCategory
android:key="@string/preference_category_sync"
android:title="@string/preferences_heading_syncing">
<org.wikipedia.settings.SwitchPreferenceMultiLine
android:key="@string/preference_key_sync_reading_lists"
android:defaultValue="false"
android:title="@string/preference_title_sync_reading_lists_from_account"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/preferences_heading_data_usage">
<org.wikipedia.settings.SwitchPreferenceMultiLine

0 comments on commit 220c518

Please sign in to comment.
You can’t perform that action at this time.