refactored credit activtiy

This commit is contained in:
M M Arif 2019-11-14 21:58:38 +05:00
parent 126d1d0896
commit 29fb2631cb
9 changed files with 129 additions and 54 deletions

View File

@ -1,12 +1,18 @@
package org.mian.gitnex.activities;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import org.mian.gitnex.R;
import org.mian.gitnex.adapters.CreditsAdapter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Author M M Arif
@ -22,14 +28,28 @@ public class CreditsActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_credits);
TextView creditKasun = findViewById(R.id.creditKasun);
ImageView closeActivity = findViewById(R.id.close);
creditKasun.setMovementMethod(LinkMovementMethod.getInstance());
initCloseListener();
closeActivity.setOnClickListener(onClickListener);
Resources res = getResources();
CharSequence[] creditsInfo = res.getTextArray(R.array.creditsInfo);
List<CharSequence> creditsList = new ArrayList<>(Arrays.asList(creditsInfo));
RecyclerView mRecyclerView = findViewById(R.id.recyclerView);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mRecyclerView.getContext(),
DividerItemDecoration.VERTICAL);
mRecyclerView.addItemDecoration(dividerItemDecoration);
CreditsAdapter adapter = new CreditsAdapter(creditsList);
mRecyclerView.setAdapter(adapter);
}
private void initCloseListener() {

View File

@ -0,0 +1,59 @@
package org.mian.gitnex.adapters;
import android.text.SpannableStringBuilder;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import org.mian.gitnex.R;
import java.util.List;
/**
* Author M M Arif
*/
public class CreditsAdapter extends RecyclerView.Adapter<CreditsAdapter.CreditsViewHolder> {
private List<CharSequence> creditsList;
static class CreditsViewHolder extends RecyclerView.ViewHolder {
private TextView creditText;
private CreditsViewHolder(View itemView) {
super(itemView);
creditText = itemView.findViewById(R.id.creditText);
}
}
public CreditsAdapter(List<CharSequence> creditsListMain) {
this.creditsList = creditsListMain;
}
@NonNull
@Override
public CreditsAdapter.CreditsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.credits, parent, false);
return new CreditsAdapter.CreditsViewHolder(v);
}
@Override
public void onBindViewHolder(@NonNull CreditsAdapter.CreditsViewHolder holder, int position) {
SpannableStringBuilder strBuilder = new SpannableStringBuilder(creditsList.get(position));
holder.creditText.setText((strBuilder));
holder.creditText.setMovementMethod(LinkMovementMethod.getInstance());
}
@Override
public int getItemCount() {
return creditsList.size();
}
}

View File

@ -31,8 +31,8 @@ public class SponsorsAdapter extends RecyclerView.Adapter<SponsorsAdapter.Sponso
}
}
public SponsorsAdapter(List<CharSequence> myListMain) {
this.sponsorsList = myListMain;
public SponsorsAdapter(List<CharSequence> sponsorsListMain) {
this.sponsorsList = sponsorsListMain;
}
@NonNull

View File

@ -1,4 +1,6 @@
<LinearLayout android:layout_width="match_parent"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
@ -40,45 +42,20 @@
</com.google.android.material.appbar.AppBarLayout>
<ScrollView
<LinearLayout
android:id="@+id/creditsFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/backgroundColor">
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:paddingBottom="30dp"
android:orientation="vertical">
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:padding="4dp"
android:scrollbars="vertical" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/creditsLogoDesign"
android:textColor="@color/colorWhite"
android:textSize="18sp"
/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="@color/divider" />
<TextView
android:id="@+id/creditKasun"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/creditAuthorKasun"
android:textColor="@color/colorWhite"
android:textSize="16sp"
android:textColorLink="@color/lightBlue"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>

View File

@ -42,7 +42,6 @@
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:id="@+id/sponsorsFrame"
android:layout_width="match_parent"

View File

@ -0,0 +1,21 @@
<?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="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:background="@color/backgroundColor" >
<TextView
android:id="@+id/creditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:textColor="@color/white"
android:textColorLink="@color/lightBlue"
android:textSize="16sp" />
</RelativeLayout>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="creditsInfo">
<item>Logo by Kasun <a href="https://mastodon.social/@kasun">@kasun</a></item>
</string-array>
</resources>

View File

@ -1,11 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="creditsInfo">
<item>Logo by <a href="https://mastodon.social/@kasun">Kasun @Mastodon</a></item>
<item>Credit 2</item>
</string-array>
<string-array name="sponsorsInfo">
<item>Fabian Stamm</item>
<item>Thomas Schneider <a href="https://framapiaf.org/@fedilab">@Fedilab</a></item>

View File

@ -285,10 +285,6 @@
<string name="creditsLogoDesign">Design</string>
<!-- credits - this part does not need translation -->
<string name="creditAuthorKasun" translatable="false">Logo by <a href="https://mastodon.social/@kasun">Kasun @Mastodon</a></string>
<!-- credits - this part does not need translation -->
<string name="alertDialogTokenRevokedTitle">Authorization Error</string>
<string name="alertDialogTokenRevokedMessage">It seems that the Access Token is revoked OR your are not allowed to see these contents. In case of revoked Token, please logout and login again</string>
<string name="alertDialogTokenRevokedCopyNegativeButton">Cancel</string>