-
-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing info related to the Reddit API changes
- Loading branch information
1 parent
2ae64f6
commit 6eb7f8e
Showing
5 changed files
with
156 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...ilealligator/infinityforreddit/bottomsheetfragments/RedditAPIInfoBottomSheetFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package ml.docilealligator.infinityforreddit.bottomsheetfragments; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.text.SpannableString; | ||
import android.text.util.Linkify; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import me.saket.bettermovementmethod.BetterLinkMovementMethod; | ||
import ml.docilealligator.infinityforreddit.R; | ||
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity; | ||
import ml.docilealligator.infinityforreddit.activities.MainActivity; | ||
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; | ||
import ml.docilealligator.infinityforreddit.databinding.FragmentRedditApiInfoBottomSheetBinding; | ||
import ml.docilealligator.infinityforreddit.utils.Utils; | ||
|
||
public class RedditAPIInfoBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { | ||
|
||
private MainActivity mainActivity; | ||
|
||
public RedditAPIInfoBottomSheetFragment() { | ||
// Required empty public constructor | ||
} | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
Bundle savedInstanceState) { | ||
// Inflate the layout for this fragment | ||
FragmentRedditApiInfoBottomSheetBinding binding = FragmentRedditApiInfoBottomSheetBinding.inflate(inflater, container, false); | ||
|
||
if (mainActivity != null && mainActivity.typeface != null) { | ||
Utils.setFontToAllTextViews(binding.getRoot(), mainActivity.typeface); | ||
} | ||
|
||
SpannableString message = new SpannableString(getString(R.string.reddit_api_info, "https://www.reddit.com/r/reddit/comments/145bram/addressing_the_community_about_changes_to_our_api", "https://www.reddit.com/r/Infinity_For_Reddit/comments/147bhsg/the_future_of_infinity")); | ||
Linkify.addLinks(message, Linkify.WEB_URLS); | ||
binding.messageTextViewRedditApiInfoBottomSheetFragment.setText(message); | ||
binding.messageTextViewRedditApiInfoBottomSheetFragment.setMovementMethod(BetterLinkMovementMethod.newInstance().setOnLinkClickListener((textView, url) -> { | ||
Intent intent = new Intent(mainActivity, LinkResolverActivity.class); | ||
intent.setData(Uri.parse(url)); | ||
startActivity(intent); | ||
return true; | ||
})); | ||
binding.messageTextViewRedditApiInfoBottomSheetFragment.setLinkTextColor(getResources().getColor(R.color.colorAccent)); | ||
|
||
binding.doNotShowThisAgainTextView.setOnClickListener(view -> { | ||
binding.doNotShowThisAgainCheckBox.toggle(); | ||
}); | ||
|
||
binding.continueButtonRedditApiInfoBottomSheetFragment.setOnClickListener(view -> { | ||
if (binding.doNotShowThisAgainCheckBox.isChecked()) { | ||
mainActivity.doNotShowRedditAPIInfoAgain(); | ||
} | ||
dismiss(); | ||
}); | ||
|
||
return binding.getRoot(); | ||
} | ||
|
||
@Override | ||
public void onAttach(@NonNull Context context) { | ||
super.onAttach(context); | ||
mainActivity = (MainActivity) context; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
app/src/main/res/layout/fragment_reddit_api_info_bottom_sheet.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
tools:context=".bottomsheetfragments.RedditAPIInfoBottomSheetFragment"> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:paddingTop="16dp" | ||
android:paddingStart="16dp" | ||
android:paddingEnd="16dp" | ||
android:text="@string/reddit_api_info_title" | ||
android:fontFamily="?attr/font_family" | ||
android:textSize="?attr/font_20" | ||
android:textColor="?attr/primaryTextColor" | ||
android:textStyle="bold" /> | ||
|
||
<TextView | ||
android:id="@+id/message_text_view_reddit_api_info_bottom_sheet_fragment" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="16dp" | ||
android:text="@string/reddit_api_info" | ||
android:fontFamily="?attr/font_family" | ||
android:textSize="?attr/font_16" | ||
android:textColor="?attr/primaryTextColor" /> | ||
|
||
<LinearLayout | ||
android:id="@+id/linear_layout_check_box_wrapper_reddit_api_info_bottom_sheet_fragment" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="10dp" | ||
android:layout_marginEnd="16dp" | ||
android:layout_marginBottom="16dp"> | ||
|
||
<com.google.android.material.checkbox.MaterialCheckBox | ||
android:id="@+id/do_not_show_this_again_check_box" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_vertical" /> | ||
|
||
<TextView | ||
android:id="@+id/do_not_show_this_again_text_view" | ||
android:layout_width="0dp" | ||
android:layout_height="match_parent" | ||
android:layout_weight="1" | ||
android:text="@string/do_not_show_this_again" | ||
android:gravity="center_vertical" | ||
android:fontFamily="?attr/font_family" | ||
android:textSize="?attr/font_default" | ||
android:textColor="?attr/primaryTextColor" /> | ||
|
||
<com.google.android.material.button.MaterialButton | ||
android:id="@+id/continue_button_reddit_api_info_bottom_sheet_fragment" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="end" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginEnd="8dp" | ||
android:backgroundTint="@color/colorPrimary" | ||
android:text="@string/i_understand" /> | ||
|
||
</LinearLayout> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters