diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-08-24 08:27:34 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-08-24 08:27:34 +0000 |
commit | 4d4e6165f0e1bcd72c54fa015a9e1112103e9062 (patch) | |
tree | ba276cfc847fd2addc888078784998a2df957554 | |
parent | 4a3266e68994b55bf1fc40256cd65c3ac831d2e8 (diff) | |
download | infinity-for-reddit-4d4e6165f0e1bcd72c54fa015a9e1112103e9062.tar infinity-for-reddit-4d4e6165f0e1bcd72c54fa015a9e1112103e9062.tar.gz infinity-for-reddit-4d4e6165f0e1bcd72c54fa015a9e1112103e9062.tar.bz2 infinity-for-reddit-4d4e6165f0e1bcd72c54fa015a9e1112103e9062.tar.lz infinity-for-reddit-4d4e6165f0e1bcd72c54fa015a9e1112103e9062.tar.xz infinity-for-reddit-4d4e6165f0e1bcd72c54fa015a9e1112103e9062.tar.zst infinity-for-reddit-4d4e6165f0e1bcd72c54fa015a9e1112103e9062.zip |
Add an acknowledgement page in settings.
Diffstat (limited to '')
-rw-r--r-- | .idea/caches/build_file_checksums.ser | bin | 533 -> 533 bytes | |||
-rw-r--r-- | .idea/caches/gradle_models.ser | bin | 270734 -> 315447 bytes | |||
-rw-r--r-- | .idea/codeStyles/Project.xml | 116 | ||||
-rw-r--r-- | .idea/misc.xml | 10 | ||||
-rw-r--r-- | app/src/main/java/Settings/Acknowledgement.java | 27 | ||||
-rw-r--r-- | app/src/main/java/Settings/AcknowledgementFragment.java | 106 | ||||
-rw-r--r-- | app/src/main/java/Settings/AcknowledgementRecyclerViewAdapter.java | 67 | ||||
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java | 38 | ||||
-rw-r--r-- | app/src/main/res/layout/fragment_acknowledgement.xml | 6 | ||||
-rw-r--r-- | app/src/main/res/layout/item_acknowledgement.xml | 23 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 2 | ||||
-rw-r--r-- | app/src/main/res/xml/main_preferences.xml | 5 | ||||
-rw-r--r-- | build.gradle | 2 | ||||
-rw-r--r-- | gradle/wrapper/gradle-wrapper.properties | 4 |
14 files changed, 384 insertions, 22 deletions
diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser Binary files differindex 63209b6a..9ae71cf7 100644 --- a/.idea/caches/build_file_checksums.ser +++ b/.idea/caches/build_file_checksums.ser diff --git a/.idea/caches/gradle_models.ser b/.idea/caches/gradle_models.ser Binary files differindex b1d13576..941f4d61 100644 --- a/.idea/caches/gradle_models.ser +++ b/.idea/caches/gradle_models.ser diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 00000000..681f41ae --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ +<component name="ProjectCodeStyleConfiguration"> + <code_scheme name="Project" version="173"> + <codeStyleSettings language="XML"> + <indentOptions> + <option name="CONTINUATION_INDENT_SIZE" value="4" /> + </indentOptions> + <arrangement> + <rules> + <section> + <rule> + <match> + <AND> + <NAME>xmlns:android</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>^$</XML_NAMESPACE> + </AND> + </match> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>xmlns:.*</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>^$</XML_NAMESPACE> + </AND> + </match> + <order>BY_NAME</order> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*:id</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> + </AND> + </match> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*:name</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> + </AND> + </match> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>name</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>^$</XML_NAMESPACE> + </AND> + </match> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>style</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>^$</XML_NAMESPACE> + </AND> + </match> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>^$</XML_NAMESPACE> + </AND> + </match> + <order>BY_NAME</order> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE> + </AND> + </match> + <order>ANDROID_ATTRIBUTE_ORDER</order> + </rule> + </section> + <section> + <rule> + <match> + <AND> + <NAME>.*</NAME> + <XML_ATTRIBUTE /> + <XML_NAMESPACE>.*</XML_NAMESPACE> + </AND> + </match> + <order>BY_NAME</order> + </rule> + </section> + </rules> + </arrangement> + </codeStyleSettings> + </code_scheme> +</component>
\ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index be2c23c1..11afa9ef 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,7 +5,7 @@ <option name="myDefaultNotNull" value="androidx.annotation.NonNull" /> <option name="myNullables"> <value> - <list size="10"> + <list size="12"> <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> <item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" /> @@ -16,12 +16,14 @@ <item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" /> <item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" /> <item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" /> + <item index="10" class="java.lang.String" itemvalue="android.annotation.Nullable" /> + <item index="11" class="java.lang.String" itemvalue="com.android.annotations.Nullable" /> </list> </value> </option> <option name="myNotNulls"> <value> - <list size="9"> + <list size="11"> <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" /> <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" /> <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" /> @@ -31,11 +33,13 @@ <item index="6" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" /> <item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" /> <item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" /> + <item index="9" class="java.lang.String" itemvalue="android.annotation.NonNull" /> + <item index="10" class="java.lang.String" itemvalue="com.android.annotations.NonNull" /> </list> </value> </option> </component> - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/build/classes" /> </component> <component name="ProjectType"> diff --git a/app/src/main/java/Settings/Acknowledgement.java b/app/src/main/java/Settings/Acknowledgement.java new file mode 100644 index 00000000..26a5a064 --- /dev/null +++ b/app/src/main/java/Settings/Acknowledgement.java @@ -0,0 +1,27 @@ +package Settings; + +import android.net.Uri; + +class Acknowledgement { + private String name; + private String introduction; + private Uri link; + + Acknowledgement(String name, String introduction, Uri link) { + this.name = name; + this.introduction = introduction; + this.link = link; + } + + public String getName() { + return name; + } + + public String getIntroduction() { + return introduction; + } + + public Uri getLink() { + return link; + } +} diff --git a/app/src/main/java/Settings/AcknowledgementFragment.java b/app/src/main/java/Settings/AcknowledgementFragment.java new file mode 100644 index 00000000..7a19a0a5 --- /dev/null +++ b/app/src/main/java/Settings/AcknowledgementFragment.java @@ -0,0 +1,106 @@ +package Settings; + + +import android.app.Activity; +import android.net.Uri; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.ArrayList; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.R; + +/** + * A simple {@link Fragment} subclass. + */ +public class AcknowledgementFragment extends Fragment { + + + public AcknowledgementFragment() { + // Required empty public constructor + } + + @BindView(R.id.recycler_view_acknowledgement_fragment) RecyclerView recyclerView; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_acknowledgement, container, false); + ButterKnife.bind(this, rootView); + + Activity activity = getActivity(); + + ArrayList<Acknowledgement> acknowledgements = new ArrayList<>(); + acknowledgements.add(new Acknowledgement("ExoPlayer", + "An application level media player for Android", + Uri.parse("https://github.com/google/ExoPlayer"))); + acknowledgements.add(new Acknowledgement("GestureViews", + "ImageView and FrameLayout with gestures control and position animation", + Uri.parse("https://github.com/alexvasilkov/GestureViews"))); + acknowledgements.add(new Acknowledgement("Glide", + "A fast and efficient open source media management and image loading framework for Android", + Uri.parse("https://github.com/bumptech/glide"))); + acknowledgements.add(new Acknowledgement("Swipe", + "Detects swipe events on Android with listener and RxJava Observable", + Uri.parse("https://github.com/pwittchen/swipe"))); + acknowledgements.add(new Acknowledgement("RxAndroid", + "Android specific bindings for RxJava 2", + Uri.parse("https://github.com/ReactiveX/RxAndroid"))); + acknowledgements.add(new Acknowledgement("RxJava", + "Reactive extensions for the JVM", + Uri.parse("https://github.com/ReactiveX/RxJava"))); + acknowledgements.add(new Acknowledgement("Retrofit", + "Type-safe HTTP client for Android and Java by Square, Inc.", + Uri.parse("https://github.com/square/retrofit"))); + acknowledgements.add(new Acknowledgement("Dagger", + "A fast dependency injector for Java and Android.", + Uri.parse("https://github.com/google/dagger"))); + acknowledgements.add(new Acknowledgement("Butter Knife", + "Field and method binding for Android views", + Uri.parse("https://github.com/JakeWharton/butterknife"))); + acknowledgements.add(new Acknowledgement("Aspect Ratio ImageView", + "A simple imageview which scales the width or height aspect with the given ratio", + Uri.parse("https://github.com/santalu/aspect-ratio-imageview"))); + acknowledgements.add(new Acknowledgement("MaterialLoadingProgressBar", + "A styled ProgressBar", + Uri.parse("https://github.com/lsjwzh/MaterialLoadingProgressBar"))); + acknowledgements.add(new Acknowledgement("Markwon", + "A markdown library for Android", + Uri.parse("https://github.com/noties/Markwon"))); + acknowledgements.add(new Acknowledgement("android-gif-drawable", + "Views and Drawable for animated GIFs in Android.", + Uri.parse("https://github.com/koral--/android-gif-drawable"))); + acknowledgements.add(new Acknowledgement("SimpleSearchView", + "A simple SearchView for Android based on Material Design", + Uri.parse("https://github.com/Ferfalk/SimpleSearchView"))); + acknowledgements.add(new Acknowledgement("EventBus", + "A publish/subscribe event bus for Android and Java", + Uri.parse("https://github.com/greenrobot/EventBus"))); + acknowledgements.add(new Acknowledgement("Customized and Expandable TextView", + "Simple library to change the Textview as rectangle, circle and square shapes", + Uri.parse("https://github.com/Rajagopalr3/CustomizedTextView"))); + acknowledgements.add(new Acknowledgement("Rounded Bottom Sheet", + "Bottom sheet with rounded corners", + Uri.parse("https://github.com/Deishelon/RoundedBottomSheet"))); + acknowledgements.add(new Acknowledgement("Bridge", + "A library for avoiding TransactionTooLargeException during state saving and restoration", + Uri.parse("https://github.com/livefront/bridge"))); + acknowledgements.add(new Acknowledgement("Android-State", + "A utility library for Android to save objects in a Bundle without any boilerplate", + Uri.parse("https://github.com/evernote/android-state"))); + + AcknowledgementRecyclerViewAdapter adapter = new AcknowledgementRecyclerViewAdapter(activity, acknowledgements); + recyclerView.setLayoutManager(new LinearLayoutManager(activity)); + recyclerView.setAdapter(adapter); + + return rootView; + } +} diff --git a/app/src/main/java/Settings/AcknowledgementRecyclerViewAdapter.java b/app/src/main/java/Settings/AcknowledgementRecyclerViewAdapter.java new file mode 100644 index 00000000..81286903 --- /dev/null +++ b/app/src/main/java/Settings/AcknowledgementRecyclerViewAdapter.java @@ -0,0 +1,67 @@ +package Settings; + +import android.content.Context; +import android.content.Intent; +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 java.util.ArrayList; + +import butterknife.BindView; +import butterknife.ButterKnife; +import ml.docilealligator.infinityforreddit.LinkResolverActivity; +import ml.docilealligator.infinityforreddit.R; + +class AcknowledgementRecyclerViewAdapter extends RecyclerView.Adapter<AcknowledgementRecyclerViewAdapter.AcknowledgementViewHolder> { + private ArrayList<Acknowledgement> acknowledgements; + private Context context; + + AcknowledgementRecyclerViewAdapter(Context context, ArrayList<Acknowledgement> acknowledgements) { + this.context = context; + this.acknowledgements = acknowledgements; + } + + @NonNull + @Override + public AcknowledgementViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new AcknowledgementViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_acknowledgement, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull AcknowledgementViewHolder holder, int position) { + Acknowledgement acknowledgement = acknowledgements.get(holder.getAdapterPosition()); + if(acknowledgement != null) { + holder.nameTextView.setText(acknowledgement.getName()); + holder.introductionTextView.setText(acknowledgement.getIntroduction()); + holder.itemView.setOnClickListener(view -> { + if(context != null) { + Intent intent = new Intent(context, LinkResolverActivity.class); + intent.setData(acknowledgement.getLink()); + context.startActivity(intent); + } + }); + } + } + + @Override + public int getItemCount() { + return acknowledgements == null ? 0 : acknowledgements.size(); + } + + class AcknowledgementViewHolder extends RecyclerView.ViewHolder { + View itemView; + @BindView(R.id.name_text_view_item_acknowledgement) TextView nameTextView; + @BindView(R.id.introduction_text_view_item_acknowledgement) TextView introductionTextView; + + AcknowledgementViewHolder(@NonNull View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + this.itemView = itemView; + } + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java index c7cde780..bfdb0a21 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java @@ -465,24 +465,26 @@ public class PostVideoActivity extends AppCompatActivity implements FlairBottomS super.onActivityResult(requestCode, resultCode, data); if(requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) { if(resultCode == RESULT_OK) { - subredditName = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME); - iconUrl = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL); - subredditSelected = true; - subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER); - - subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); - subredditNameTextView.setText(subredditName); - displaySubredditIcon(); - - flairTextView.setVisibility(View.VISIBLE); - flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); - flairTextView.setText(getString(R.string.flair)); - flair = null; + if(data != null) { + subredditName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME); + iconUrl = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL); + subredditSelected = true; + subredditIsUser = data.getBooleanExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER, false); + + subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); + subredditNameTextView.setText(subredditName); + displaySubredditIcon(); + + flairTextView.setVisibility(View.VISIBLE); + flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); + flairTextView.setText(getString(R.string.flair)); + flair = null; + } } } else if(requestCode == PICK_VIDEO_REQUEST_CODE) { if(resultCode == RESULT_OK) { if(data == null) { - Snackbar.make(coordinatorLayout, R.string.error_getting_image, Snackbar.LENGTH_SHORT).show(); + Snackbar.make(coordinatorLayout, R.string.error_getting_video, Snackbar.LENGTH_SHORT).show(); return; } @@ -490,8 +492,12 @@ public class PostVideoActivity extends AppCompatActivity implements FlairBottomS loadVideo(); } } else if (requestCode == CAPTURE_VIDEO_REQUEST_CODE) { - videoUri = data.getData(); - loadVideo(); + if(data != null) { + videoUri = data.getData(); + loadVideo(); + } else { + Snackbar.make(coordinatorLayout, R.string.error_getting_video, Snackbar.LENGTH_SHORT).show(); + } } } diff --git a/app/src/main/res/layout/fragment_acknowledgement.xml b/app/src/main/res/layout/fragment_acknowledgement.xml new file mode 100644 index 00000000..5f164c83 --- /dev/null +++ b/app/src/main/res/layout/fragment_acknowledgement.xml @@ -0,0 +1,6 @@ +<androidx.recyclerview.widget.RecyclerView 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:id="@+id/recycler_view_acknowledgement_fragment" + tools:context="Settings.AcknowledgementFragment"/> diff --git a/app/src/main/res/layout/item_acknowledgement.xml b/app/src/main/res/layout/item_acknowledgement.xml new file mode 100644 index 00000000..543c6829 --- /dev/null +++ b/app/src/main/res/layout/item_acknowledgement.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground"> + + <TextView + android:id="@+id/name_text_view_item_acknowledgement" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textColor="@color/primaryTextColor" + android:textSize="16sp" /> + + <TextView + android:id="@+id/introduction_text_view_item_acknowledgement" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" /> + +</LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 37a3518f..8a88d944 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -146,6 +146,7 @@ <string name="select_from_gallery">Select a picture</string> <string name="select_again">Select again</string> <string name="error_getting_image">Error getting the image</string> + <string name="error_getting_video">Error getting the video</string> <string name="no_camera_available">No camera app available</string> <string name="error_creating_temp_file">Error creating temp file</string> @@ -258,6 +259,7 @@ <string name="settings_theme_dark_theme_summary">Dark Theme</string> <string name="settings_theme_system_default_summary">Device default</string> <string name="settings_enable_nsfw_title">Enable NSFW</string> + <string name="settings_acknowledgement_master_title">Acknowledgement</string> <string name="no_link_available">Cannot get the link</string> </resources> diff --git a/app/src/main/res/xml/main_preferences.xml b/app/src/main/res/xml/main_preferences.xml index 1578ff63..7ccfa301 100644 --- a/app/src/main/res/xml/main_preferences.xml +++ b/app/src/main/res/xml/main_preferences.xml @@ -21,4 +21,9 @@ app:key="nsfw" app:title="@string/settings_enable_nsfw_title"/> + <Preference + app:key="acknowledgement_master" + app:title="@string/settings_acknowledgement_master_title" + app:fragment="Settings.AcknowledgementFragment" /> + </androidx.preference.PreferenceScreen>
\ No newline at end of file diff --git a/build.gradle b/build.gradle index dc4f01a7..e08c9801 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.4.2' + classpath 'com.android.tools.build:gradle:3.5.0' // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6fbf7e5b..c94a8dad 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Apr 18 18:17:08 HKT 2019 +#Thu Aug 22 20:30:24 HKT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip |