Register form
This commit is contained in:
parent
4c4df0fee7
commit
e9dcc2317d
|
@ -14,25 +14,43 @@
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
package app.fedilab.android.activities;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.UnderlineSpan;
|
||||
import android.transition.Slide;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionManager;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.jaredrummler.materialspinner.MaterialSpinner;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.poi.sl.usermodel.Line;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.asynctasks.RetrieveInstanceRegAsyncTask;
|
||||
import app.fedilab.android.client.APIResponse;
|
||||
|
@ -57,7 +75,6 @@ public class MastodonRegisterActivity extends BaseActivity implements OnRetrieve
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
switch (theme){
|
||||
|
@ -90,13 +107,15 @@ public class MastodonRegisterActivity extends BaseActivity implements OnRetrieve
|
|||
finish();
|
||||
}
|
||||
});
|
||||
toolbar_title.setText(R.string.add_account);
|
||||
toolbar_title.setText(R.string.sign_up);
|
||||
if (theme == Helper.THEME_LIGHT){
|
||||
Toolbar toolbar = actionBar.getCustomView().findViewById(R.id.toolbar);
|
||||
Helper.colorizeToolbar(toolbar, R.color.black, MastodonRegisterActivity.this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
MaterialSpinner reg_category = findViewById(R.id.reg_category);
|
||||
Helper.changeMaterialSpinnerColor(MastodonRegisterActivity.this, reg_category);
|
||||
String[] categoriesA = {
|
||||
|
@ -164,5 +183,70 @@ public class MastodonRegisterActivity extends BaseActivity implements OnRetrieve
|
|||
lv_instances.setAdapter(instanceRegAdapter);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void pickupInstance(String instance){
|
||||
|
||||
|
||||
LinearLayout form_container = findViewById(R.id.form_container);
|
||||
LinearLayout drawer_layout = findViewById(R.id.drawer_layout);
|
||||
|
||||
TextView host_reg = findViewById(R.id.host_reg);
|
||||
host_reg.setText(instance);
|
||||
|
||||
|
||||
drawer_layout.animate()
|
||||
.translationY(0)
|
||||
.alpha(0.0f)
|
||||
.setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
drawer_layout.setVisibility(View.GONE);
|
||||
form_container.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
TextView change_instance = findViewById(R.id.change_instance);
|
||||
final SpannableString change = new SpannableString(String.format("(%s)", getString(R.string.change)));
|
||||
change.setSpan(new UnderlineSpan(), 0, change.length(), 0);
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
if( theme == Helper.THEME_DARK)
|
||||
change.setSpan(new ForegroundColorSpan(ContextCompat.getColor(MastodonRegisterActivity.this, R.color.dark_link_toot)), 0, change.length(),
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
else if( theme == Helper.THEME_BLACK)
|
||||
change.setSpan(new ForegroundColorSpan(ContextCompat.getColor(MastodonRegisterActivity.this, R.color.black_link_toot)), 0, change.length(),
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
else if( theme == Helper.THEME_LIGHT)
|
||||
change.setSpan(new ForegroundColorSpan(ContextCompat.getColor(MastodonRegisterActivity.this, R.color.mastodonC4)), 0, change.length(),
|
||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
change_instance.setText(change);
|
||||
change_instance.setOnClickListener(view -> {
|
||||
drawer_layout.setVisibility(View.VISIBLE);
|
||||
drawer_layout.animate()
|
||||
.translationY(0)
|
||||
.alpha(1.f)
|
||||
.setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
form_container.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
TextView agreement_text = findViewById(R.id.agreement_text);
|
||||
|
||||
String tos = getString(R.string.tos);
|
||||
String serverrules = getString(R.string.server_rules);
|
||||
String content_agreement = getString(R.string.agreement_check,
|
||||
"<a href='https://" + instance + "/about/more' >"+serverrules +"</a>",
|
||||
"<a href='https://" + instance + "/terms' >"+tos +"</a>"
|
||||
);
|
||||
agreement_text.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
agreement_text.setText(Html.fromHtml(content_agreement));
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -34,6 +34,7 @@ import com.bumptech.glide.request.RequestOptions;
|
|||
|
||||
import java.util.List;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.MastodonRegisterActivity;
|
||||
import app.fedilab.android.client.Entities.InstanceReg;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
|
||||
|
@ -75,14 +76,13 @@ public class InstanceRegAdapter extends RecyclerView.Adapter {
|
|||
final InstanceRegAdapter.ViewHolder holder = (InstanceRegAdapter.ViewHolder) viewHolder;
|
||||
|
||||
holder.instance_choose.setOnClickListener(v -> {
|
||||
|
||||
((MastodonRegisterActivity)context).pickupInstance(instanceReg.getDomain());
|
||||
});
|
||||
|
||||
holder.instance_count_user.setText(context.getString(R.string.users,Helper.withSuffix(instanceReg.getTotal_users())));
|
||||
holder.instance_description.setText(instanceReg.getDescription());
|
||||
holder.instance_host.setText(instanceReg.getDomain());
|
||||
holder.instance_version.setText(String.format("%s - %s", instanceReg.getCategory(),instanceReg.getVersion()));
|
||||
Log.v(Helper.TAG,"p: " + instanceReg.getProxied_thumbnail());
|
||||
Glide.with(context)
|
||||
.load(instanceReg.getProxied_thumbnail())
|
||||
.apply(new RequestOptions().transforms(new FitCenter(), new RoundedCorners(10)))
|
||||
|
|
|
@ -15,15 +15,18 @@
|
|||
You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||
see <http://www.gnu.org/licenses>.
|
||||
-->
|
||||
<ScrollView android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
>
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/parent"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:animateLayoutChanges="true"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<!-- category -->
|
||||
<TextView
|
||||
|
@ -41,6 +44,109 @@
|
|||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/reg_category_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="300dp"/>
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
<LinearLayout
|
||||
android:visibility="gone"
|
||||
android:id="@+id/form_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:id="@+id/host_reg"
|
||||
android:textSize="18sp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:layout_marginStart="10dp"
|
||||
android:id="@+id/change_instance"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_marginTop="20dp"
|
||||
android:labelFor="@+id/username"
|
||||
android:text="@string/username"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content" />
|
||||
<EditText
|
||||
android:id="@+id/username"
|
||||
android:inputType="text"
|
||||
android:singleLine="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_marginTop="10dp"
|
||||
android:labelFor="@+id/email"
|
||||
android:text="@string/email"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content" />
|
||||
<EditText
|
||||
android:id="@+id/email"
|
||||
android:inputType="textEmailAddress"
|
||||
android:singleLine="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_marginTop="10dp"
|
||||
android:labelFor="@+id/password"
|
||||
android:text="@string/password"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content" />
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_marginTop="10dp"
|
||||
android:labelFor="@+id/password_confirm"
|
||||
android:text="@string/password_confirm"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content" />
|
||||
<EditText
|
||||
android:id="@+id/password_confirm"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<CheckBox
|
||||
android:id="@+id/agreement"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:id="@+id/agreement_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/signup"
|
||||
android:text="@string/sign_up"
|
||||
style="@style/Base.Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -1004,8 +1004,13 @@
|
|||
<string name="instance_logo">Logo of the instance</string>
|
||||
<string name="toast_error_instance_reg">Something went wrong when checking available instances!</string>
|
||||
<string name="join_mastodon">Join Mastodon</string>
|
||||
<string name="pickup_instance_category">Choose an instance by picking up a category</string>
|
||||
<string name="pickup_instance_category">Choose an instance by picking up a category, then click on a check button.</string>
|
||||
<string name="users">%1$s users</string>
|
||||
<string name="password_confirm">Confirm password</string>
|
||||
<string name="agreement_check">I agree to %1$s and %2$s</string>
|
||||
<string name="server_rules">server rules</string>
|
||||
<string name="tos">terms of service</string>
|
||||
<string name="sign_up">Sign up</string>
|
||||
<plurals name="number_of_vote">
|
||||
<item quantity="one">%d vote</item>
|
||||
<item quantity="other">%d votes</item>
|
||||
|
|
Loading…
Reference in New Issue