Cleanup obsolete social network registration step.

This commit is contained in:
Andrei 2022-10-26 20:43:43 -07:00
parent 48dad79bab
commit ec331a259b
15 changed files with 31 additions and 473 deletions

View file

@ -47,18 +47,6 @@
android:name=".activity.RegisterProgress"
android:noHistory="true"
android:label="@string/get_started" />
<activity
android:name=".activity.AddTwitter"
android:label="@string/add_twitter" />
<activity
android:name=".activity.AddFacebook"
android:label="@string/add_facebook" />
<activity
android:name=".activity.AddSocial"
android:label="@string/add_friends" />
<activity
android:name=".activity.Main"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/toolbar_newsblur" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/item_background"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<FrameLayout
android:id="@+id/addsocial_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:gravity="center"
android:padding="20dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="right"
android:padding="10dp">
<Button
android:id="@+id/login_addsocial_nextstep"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:text="Start Reading"
android:textSize="14sp" />
</LinearLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,18 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<ViewSwitcher xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/view_switcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:gravity="center"
android:inAnimation="@android:anim/fade_in"
android:outAnimation="@android:anim/fade_out"
android:padding="30dp">
android:orientation="vertical"
android:paddingHorizontal="32dp"
android:paddingVertical="64dp">
<LinearLayout
<ImageView
android:id="@+id/progress_logo"
android:layout_width="180dp"
android:layout_height="180dp"
android:layout_gravity="center_horizontal"
android:src="@drawable/logo" />
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="64dp"
android:gravity="center"
android:orientation="horizontal">
@ -22,43 +27,13 @@
android:layout_height="40dp"
android:layout_marginRight="10dp"
android:indeterminate="true"
app:indicatorSize="32dp"/>
app:indicatorSize="32dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Registering..."
android:textSize="20sp" />
</LinearLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="@+id/progress_logo"
android:layout_width="200dp"
android:layout_height="200dp"
android:src="@drawable/logo" />
</LinearLayout>
<Button
android:id="@+id/button_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:text="@string/login_next"
android:textSize="20sp" />
</RelativeLayout>
</ViewSwitcher>
</androidx.appcompat.widget.LinearLayoutCompat>

View file

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/toolbar_newsblur" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/item_background"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<WebView
android:id="@+id/webcontainer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,93 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp" >
<TextView
android:id="@+id/addsocial_connect_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:text="@string/connect_with_your_friends"
android:textColor="@color/text"
android:textSize="18sp"
android:gravity="center" />
<LinearLayout
android:id="@+id/addsocial_twitter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/addsocial_connect_text"
android:layout_gravity="center_vertical"
android:layout_margin="20dp"
android:background="@drawable/twitter_background"
android:orientation="horizontal"
android:padding="5dp" >
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="15dp"
android:scaleType="centerInside"
android:src="@drawable/twitter_logo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="@string/twitter"
android:id="@+id/addsocial_twitter_text"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/addsocial_facebook"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/addsocial_twitter"
android:layout_gravity="center_vertical"
android:layout_margin="20dp"
android:background="@drawable/facebook_background"
android:orientation="horizontal"
android:padding="5dp" >
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="15dp"
android:scaleType="centerInside"
android:src="@drawable/facebook_logo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="@string/facebook"
android:id="@+id/addsocial_facebook_text"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
<TextView
android:id="@+id/addsocial_autofollow_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/addsocial_facebook"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:textSize="16sp"
android:text="@string/auto_follow_friends"
android:textColor="@color/text" />
<CheckBox
android:id="@+id/addsocial_autofollow_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:layout_below="@id/addsocial_facebook"
android:layout_alignBaseline="@id/addsocial_autofollow_text"
android:layout_toRightOf="@id/addsocial_autofollow_text" />
</RelativeLayout>

View file

@ -254,13 +254,6 @@
<string name="login_registration_register">Register</string>
<string name="register_message_error">There was problem registering for NewsBlur.</string>
<string name="get_started">Let\'s get started</string>
<string name="add_friends">Add your friends</string>
<string name="connect_with_your_friends">Connect with your friends to easily follow the stories that matter to them</string>
<string name="twitter">Twitter</string>
<string name="facebook">Facebook</string>
<string name="auto_follow_friends">Auto-follow friends</string>
<string name="add_twitter">Add Twitter friends</string>
<string name="add_facebook">Add Facebook friends</string>
<string name="need_to_login"><u>I need to log in!</u></string>
<string name="need_to_register"><u>I need to register</u></string>
<string name="public_comment_count">%d public comments</string>

View file

@ -1,45 +0,0 @@
package com.newsblur.activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.newsblur.R;
import com.newsblur.network.APIConstants;
import com.newsblur.util.UIUtils;
public class AddFacebook extends NbActivity {
public static final int FACEBOOK_AUTHED = 0x21;
private WebView webview;
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_webcontainer);
UIUtils.setupToolbar(this, R.drawable.logo, getString(R.string.add_facebook), true);
webview = (WebView) findViewById(R.id.webcontainer);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient() {
// this was deprecated in API 24 but the replacement only added in the same release.
// the suppression can be removed when we move past 24
@SuppressWarnings("deprecation")
public boolean shouldOverrideUrlLoading(WebView view, String url){
if (TextUtils.equals(url, APIConstants.buildUrl("/"))) {
AddFacebook.this.setResult(FACEBOOK_AUTHED);
AddFacebook.this.finish();
return true;
}
view.loadUrl(url);
return false;
}
});
webview.loadUrl(APIConstants.buildUrl(APIConstants.PATH_CONNECT_FACEBOOK));
}
}

View file

@ -1,63 +0,0 @@
package com.newsblur.activity;
import android.content.Intent;
import android.os.Bundle;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import com.newsblur.R;
import com.newsblur.fragment.AddSocialFragment;
import com.newsblur.util.UIUtils;
import dagger.hilt.android.AndroidEntryPoint;
@AndroidEntryPoint
public class AddSocial extends NbActivity {
private FragmentManager fragmentManager;
private String currentTag = "addSocialFragment";
private AddSocialFragment addSocialFragment;
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_addsocial);
UIUtils.setupToolbar(this, R.drawable.logo, getString(R.string.add_friends), false);
fragmentManager = getSupportFragmentManager();
if (fragmentManager.findFragmentByTag(currentTag) == null) {
FragmentTransaction transaction = fragmentManager.beginTransaction();
addSocialFragment = new AddSocialFragment();
transaction.add(R.id.addsocial_container, addSocialFragment, currentTag);
transaction.commit();
}
Button nextStep = (Button) findViewById(R.id.login_addsocial_nextstep);
nextStep.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent i = new Intent(AddSocial.this, Main.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
switch (resultCode) {
case AddTwitter.TWITTER_AUTHED:
addSocialFragment.setTwitterAuthed();
case AddFacebook.FACEBOOK_AUTHED:
addSocialFragment.setFacebookAuthed();
}
}
}

View file

@ -1,45 +0,0 @@
package com.newsblur.activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.newsblur.R;
import com.newsblur.network.APIConstants;
import com.newsblur.util.UIUtils;
public class AddTwitter extends NbActivity {
public static final int TWITTER_AUTHED = 0x20;
private WebView webview;
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_webcontainer);
UIUtils.setupToolbar(this, R.drawable.logo, getString(R.string.add_twitter), true);
webview = (WebView) findViewById(R.id.webcontainer);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient() {
// this was deprecated in API 24 but the replacement only added in the same release.
// the suppression can be removed when we move past 24
@SuppressWarnings("deprecation")
public boolean shouldOverrideUrlLoading(WebView view, String url){
if (TextUtils.equals(url, APIConstants.buildUrl("/"))) {
AddTwitter.this.setResult(TWITTER_AUTHED);
AddTwitter.this.finish();
return true;
}
view.loadUrl(url);
return false;
}
});
webview.loadUrl(APIConstants.buildUrl(APIConstants.PATH_CONNECT_TWITTER));
}
}

View file

@ -9,6 +9,7 @@ import androidx.lifecycle.lifecycleScope
import com.newsblur.R
import com.newsblur.databinding.ActivityRegisterProgressBinding
import com.newsblur.network.APIManager
import com.newsblur.network.domain.RegisterResponse
import com.newsblur.util.PrefsUtils
import com.newsblur.util.executeAsyncTask
import dagger.hilt.android.AndroidEntryPoint
@ -44,24 +45,22 @@ class RegisterProgress : FragmentActivity() {
apiManager.signup(username, password, email)
},
onPostExecute = {
if (it.authenticated) {
binding.viewSwitcher.showNext()
} else {
var errorMessage = it.errorMessage
if (errorMessage == null) {
errorMessage = resources.getString(R.string.register_message_error)
}
Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show()
startActivity(Intent(this, Login::class.java))
}
if (it.authenticated) showAuth()
else showError(it)
}
)
binding.buttonNext.setOnClickListener { next() }
}
private operator fun next() {
val i = Intent(this, AddSocial::class.java)
startActivity(i)
private fun showAuth() {
startActivity(Intent(this, Main::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
})
}
private fun showError(response: RegisterResponse) {
val errorMessage = response.errorMessage
?: resources.getString(R.string.register_message_error)
Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show()
startActivity(Intent(this, Login::class.java))
}
}

View file

@ -1,77 +0,0 @@
package com.newsblur.fragment
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import com.newsblur.R
import com.newsblur.activity.AddFacebook
import com.newsblur.activity.AddTwitter
import com.newsblur.databinding.FragmentAddsocialBinding
import com.newsblur.network.APIManager
import com.newsblur.util.executeAsyncTask
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
@AndroidEntryPoint
class AddSocialFragment : Fragment() {
@Inject
lateinit var apiManager: APIManager
private lateinit var binding: FragmentAddsocialBinding
private var twitterAuthed = false
private var facebookAuthed = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
retainInstance = true
}
fun setTwitterAuthed() {
twitterAuthed = true
authCheck()
}
fun setFacebookAuthed() {
facebookAuthed = true
authCheck()
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_addsocial, null)
binding = FragmentAddsocialBinding.bind(view)
binding.addsocialTwitter.setOnClickListener {
val i = Intent(activity, AddTwitter::class.java)
startActivityForResult(i, 0)
}
binding.addsocialFacebook.setOnClickListener {
val i = Intent(activity, AddFacebook::class.java)
startActivityForResult(i, 0)
}
authCheck()
binding.addsocialAutofollowCheckbox.setOnCheckedChangeListener { _, checked ->
lifecycleScope.executeAsyncTask(
doInBackground = {
apiManager.setAutoFollow(checked)
}
)
}
return view
}
private fun authCheck() {
if (twitterAuthed) {
binding.addsocialTwitterText.text = "Added Twitter friends!"
binding.addsocialTwitter.isEnabled = false
}
if (facebookAuthed) {
binding.addsocialFacebookText.text = "Added Facebook friends!"
binding.addsocialFacebook.isEnabled = false
}
}
}

View file

@ -35,7 +35,6 @@ public class APIConstants {
public static final String PATH_MY_PROFILE = "/social/load_user_profile";
public static final String PATH_FOLLOW = "/social/follow";
public static final String PATH_UNFOLLOW = "/social/unfollow";
public static final String PATH_AUTOFOLLOW_PREF = "/profile/set_preference";
public static final String PATH_USER_ACTIVITIES = "/social/activities";
public static final String PATH_USER_INTERACTIONS = "/social/interactions";
public static final String PATH_RIVER_STORIES = "/reader/river_stories";
@ -72,8 +71,6 @@ public class APIConstants {
public static final String PATH_READ_STORIES = "/reader/read_stories";
public static final String PATH_MOVE_FEED_TO_FOLDERS = "/reader/move_feed_to_folders";
public static final String PATH_SAVE_FEED_CHOOSER = "/reader/save_feed_chooser";
public static final String PATH_CONNECT_FACEBOOK = "/oauth/facebook_connect/";
public static final String PATH_CONNECT_TWITTER = "/oauth/twitter_connect/";
public static final String PATH_SET_NOTIFICATIONS = "/notifications/feed/";
public static final String PATH_INSTA_FETCH = "/rss_feeds/exception_retry";
public static final String PATH_RENAME_FEED = "/reader/rename_feed";

View file

@ -106,13 +106,6 @@ public class APIManager {
return true;
}
public boolean setAutoFollow(boolean autofollow) {
ContentValues values = new ContentValues();
values.put("autofollow_friends", autofollow ? "true" : "false");
final APIResponse response = post(buildUrl(APIConstants.PATH_AUTOFOLLOW_PREF), values);
return (!response.isError());
}
public NewsBlurResponse markFeedsAsRead(FeedSet fs, Long includeOlder, Long includeNewer) {
ValueMultimap values = new ValueMultimap();