mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Re-use same class for all review fragments (#1537)
And try to add pager indicator
This commit is contained in:
parent
e5db79e652
commit
3be184edbe
12 changed files with 80 additions and 299 deletions
|
|
@ -17,9 +17,7 @@ import fr.free.nrw.commons.nearby.NearbyFragment;
|
|||
import fr.free.nrw.commons.nearby.NearbyListFragment;
|
||||
import fr.free.nrw.commons.nearby.NearbyMapFragment;
|
||||
import fr.free.nrw.commons.nearby.NoPermissionsFragment;
|
||||
import fr.free.nrw.commons.review.ReviewCategoryMissuseFragment;
|
||||
import fr.free.nrw.commons.review.ReviewLicenceViolationFragment;
|
||||
import fr.free.nrw.commons.review.ReviewOutOfContextFragment;
|
||||
import fr.free.nrw.commons.review.ReviewImageFragment;
|
||||
import fr.free.nrw.commons.settings.SettingsFragment;
|
||||
|
||||
@Module
|
||||
|
|
@ -72,13 +70,6 @@ public abstract class FragmentBuilderModule {
|
|||
abstract BookmarkLocationsFragment bindBookmarkLocationListFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ReviewOutOfContextFragment bindReviewOutOfContextFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ReviewLicenceViolationFragment bindReviewLicenceViolationFragment();
|
||||
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ReviewCategoryMissuseFragment bindReviewCategoryMissuseFragment();
|
||||
abstract ReviewImageFragment bindReviewOutOfContextFragment();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ import android.view.Menu;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import com.viewpagerindicator.CirclePageIndicator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -55,6 +57,9 @@ public class ReviewActivity extends AuthenticatedActivity {
|
|||
//private ReviewCallback reviewCallback;
|
||||
private ReviewController reviewController;
|
||||
|
||||
@BindView(R.id.reviewPagerIndicator)
|
||||
public CirclePageIndicator pagerIndicator;
|
||||
|
||||
@Override
|
||||
protected void onAuthCookieAcquired(String authCookie) {
|
||||
|
||||
|
|
@ -78,6 +83,7 @@ public class ReviewActivity extends AuthenticatedActivity {
|
|||
reviewPagerAdapter = new ReviewPagerAdapter(getSupportFragmentManager());
|
||||
pager.setAdapter(reviewPagerAdapter);
|
||||
reviewPagerAdapter.getItem(0);
|
||||
pagerIndicator.setViewPager(pager);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -116,9 +122,9 @@ public class ReviewActivity extends AuthenticatedActivity {
|
|||
}
|
||||
|
||||
private void updateImage(Media result) {
|
||||
|
||||
reviewController.onImageRefreshed(result.getFilename()); //file name is updated
|
||||
reviewPagerAdapter.getItem(0); //new fragment with this new filename created
|
||||
reviewPagerAdapter.updateFilename();
|
||||
pager.setCurrentItem(0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
package fr.free.nrw.commons.review;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.Utils;
|
||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||
|
||||
/**
|
||||
* Created by root on 19.05.2018.
|
||||
*/
|
||||
|
||||
public class ReviewCategoryMissuseFragment extends CommonsDaggerSupportFragment {
|
||||
int position;
|
||||
String fileName;
|
||||
private View textView;
|
||||
private SimpleDraweeView simpleDraweeView;
|
||||
|
||||
public void update(int position, String fileName) {
|
||||
this.position = position;
|
||||
this.fileName = fileName;
|
||||
|
||||
if (simpleDraweeView!=null) {
|
||||
simpleDraweeView.setImageURI(Utils.makeThumbBaseUrl(fileName));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
//position = getArguments() != null ? getArguments().getInt("val") : 1;
|
||||
//fileName = getArguments() != null ? getArguments().getString("fileName") : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View layoutView = inflater.inflate(R.layout.review_out_of_context, container,
|
||||
false);
|
||||
textView = layoutView.findViewById(R.id.testingText);
|
||||
simpleDraweeView = layoutView.findViewById(R.id.imageView);
|
||||
|
||||
if (fileName!= null) {
|
||||
simpleDraweeView.setImageURI(Utils.makeThumbBaseUrl(fileName));
|
||||
}
|
||||
|
||||
((TextView) textView).setText("Fragment #" + position);
|
||||
Log.d("deneme","Fragment #" + position);
|
||||
return layoutView;
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ public class ReviewController implements ReviewActivity.ReviewCallback {
|
|||
|
||||
@Override
|
||||
public void onImageRefreshed(String fileName) {
|
||||
this.fileName = fileName;
|
||||
ReviewController.fileName = fileName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package fr.free.nrw.commons.review;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
@ -17,7 +16,11 @@ import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
|||
* Created by root on 19.05.2018.
|
||||
*/
|
||||
|
||||
public class ReviewOutOfContextFragment extends CommonsDaggerSupportFragment {
|
||||
public class ReviewImageFragment extends CommonsDaggerSupportFragment {
|
||||
|
||||
public static final int SPAM = 0;
|
||||
public static final int COPYRIGHT = 1;
|
||||
public static final int CATEGORY = 2;
|
||||
|
||||
private int position;
|
||||
private String fileName;
|
||||
|
|
@ -36,24 +39,31 @@ public class ReviewOutOfContextFragment extends CommonsDaggerSupportFragment {
|
|||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
//position = getArguments() != null ? getArguments().getInt("val") : 1;
|
||||
//fileName = getArguments() != null ? getArguments().getString("fileName") : " ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View layoutView = inflater.inflate(R.layout.review_out_of_context, container,
|
||||
position = getArguments().getInt("position");
|
||||
View layoutView = inflater.inflate(R.layout.fragment_review_image, container,
|
||||
false);
|
||||
textView = layoutView.findViewById(R.id.testingText);
|
||||
|
||||
simpleDraweeView = layoutView.findViewById(R.id.imageView);
|
||||
if (fileName!= null) {
|
||||
simpleDraweeView.setImageURI(Utils.makeThumbBaseUrl(fileName));
|
||||
textView = layoutView.findViewById(R.id.reviewQuestion);
|
||||
String question;
|
||||
switch(position) {
|
||||
case COPYRIGHT:
|
||||
question = getString(R.string.review_copyright);
|
||||
break;
|
||||
case CATEGORY:
|
||||
question = getString(R.string.review_category);
|
||||
break;
|
||||
case SPAM:
|
||||
question = getString(R.string.review_spam);
|
||||
break;
|
||||
default:
|
||||
question = "How did we get here?";
|
||||
}
|
||||
|
||||
((TextView) textView).setText("Fragment #" + position);
|
||||
Log.d("deneme","Fragment #" + position);
|
||||
((TextView) textView).setText(question);
|
||||
simpleDraweeView = layoutView.findViewById(R.id.imageView);
|
||||
return layoutView;
|
||||
}
|
||||
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
package fr.free.nrw.commons.review;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.Utils;
|
||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||
|
||||
/**
|
||||
* Created by nes on 19.05.2018.
|
||||
*/
|
||||
|
||||
public class ReviewLicenceViolationFragment extends CommonsDaggerSupportFragment {
|
||||
int position;
|
||||
String fileName;
|
||||
private View textView;
|
||||
private SimpleDraweeView simpleDraweeView;
|
||||
|
||||
public void update(int position, String fileName) {
|
||||
this.position = position;
|
||||
this.fileName = fileName;
|
||||
|
||||
if (simpleDraweeView!=null) {
|
||||
simpleDraweeView.setImageURI(Utils.makeThumbBaseUrl(fileName));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
//position = getArguments() != null ? getArguments().getInt("val") : 1;
|
||||
//fileName = getArguments() != null ? getArguments().getString("fileName") : "";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View layoutView = inflater.inflate(R.layout.review_out_of_context, container,
|
||||
false);
|
||||
textView = layoutView.findViewById(R.id.testingText);
|
||||
|
||||
simpleDraweeView = layoutView.findViewById(R.id.imageView);
|
||||
if (fileName!= null) {
|
||||
simpleDraweeView.setImageURI(Utils.makeThumbBaseUrl(fileName));
|
||||
}
|
||||
|
||||
((TextView) textView).setText("Fragment #" + position);
|
||||
Log.d("deneme","Fragment #" + position);
|
||||
return layoutView;
|
||||
}
|
||||
}
|
||||
|
|
@ -11,16 +11,16 @@ import android.support.v4.app.FragmentStatePagerAdapter;
|
|||
|
||||
public class ReviewPagerAdapter extends FragmentStatePagerAdapter {
|
||||
private int currentPosition;
|
||||
ReviewOutOfContextFragment reviewOutOfContextFragment;
|
||||
ReviewLicenceViolationFragment reviewLicenceViolationFragment;
|
||||
ReviewCategoryMissuseFragment reviewCategoryMissuseFragment;
|
||||
ReviewImageFragment[] reviewImageFragments;
|
||||
|
||||
|
||||
public ReviewPagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
reviewOutOfContextFragment = new ReviewOutOfContextFragment();
|
||||
reviewLicenceViolationFragment = new ReviewLicenceViolationFragment();
|
||||
reviewCategoryMissuseFragment = new ReviewCategoryMissuseFragment();
|
||||
reviewImageFragments = new ReviewImageFragment[] {
|
||||
new ReviewImageFragment(),
|
||||
new ReviewImageFragment(),
|
||||
new ReviewImageFragment()
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -28,22 +28,19 @@ public class ReviewPagerAdapter extends FragmentStatePagerAdapter {
|
|||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
switch (position) {
|
||||
case 0: // Fragment # 0 - This will show image
|
||||
currentPosition = 0;
|
||||
reviewOutOfContextFragment.update(currentPosition, ReviewController.fileName);
|
||||
return reviewOutOfContextFragment;
|
||||
case 1: // Fragment # 1 - This will show image
|
||||
currentPosition = 1;
|
||||
reviewLicenceViolationFragment.update(currentPosition, ReviewController.fileName);
|
||||
return reviewLicenceViolationFragment;
|
||||
default:// Fragment # 2-9 - Will show list
|
||||
currentPosition = 2;
|
||||
reviewCategoryMissuseFragment.update(currentPosition, ReviewController.fileName);
|
||||
return reviewCategoryMissuseFragment;
|
||||
public void updateFilename() {
|
||||
for (int i = 0; i < getCount(); i++) {
|
||||
ReviewImageFragment fragment = reviewImageFragments[i];
|
||||
fragment.update(i, ReviewController.fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt("position", position);
|
||||
reviewImageFragments[position].setArguments(bundle);
|
||||
return reviewImageFragments[position];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,18 +23,29 @@
|
|||
|
||||
</include>
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/toolbar"
|
||||
android:background="@color/primaryColor">
|
||||
android:background="@color/primaryColor"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/reviewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fadingEdge="none" />
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
<com.viewpagerindicator.CirclePageIndicator
|
||||
android:id="@+id/reviewPagerIndicator"
|
||||
android:layout_height="@dimen/half_standard_height"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_gravity="bottom"
|
||||
android:padding="5dp"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
android:weightSum="5"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/main_background_light"
|
||||
android:gravity="center_horizontal"
|
||||
>
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
|
|
@ -16,17 +17,20 @@
|
|||
android:src="@drawable/commons_logo_large"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/testingText"
|
||||
android:id="@+id/reviewQuestion"
|
||||
android:layout_width="match_parent"
|
||||
android:textColor="@android:color/black"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.7"
|
||||
android:textAlignment="center"
|
||||
android:text="testing1"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/reviewQuestionContext"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.7"
|
||||
android:textAlignment="center"
|
||||
android:text="testing2"
|
||||
/>
|
||||
|
||||
|
|
@ -34,26 +38,22 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.6"
|
||||
android:weightSum="3"
|
||||
android:weightSum="2"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/yesButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
android:layout_weight="1"
|
||||
android:text="@string/yes"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/noButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/notSureButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
android:layout_weight="1"
|
||||
android:text="@string/no"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:weightSum="5"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/main_background_light"
|
||||
>
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="3"
|
||||
android:src="@drawable/commons_logo_large"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/testingText"
|
||||
android:layout_width="match_parent"
|
||||
android:textColor="@android:color/black"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.7"
|
||||
android:text="testing1"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.7"
|
||||
android:text="testing2"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.6"
|
||||
android:weightSum="3"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/yesButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/noButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/notSureButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:weightSum="5"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/main_background_light"
|
||||
>
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="3"
|
||||
android:src="@drawable/commons_logo_large"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/testingText"
|
||||
android:layout_width="match_parent"
|
||||
android:textColor="@android:color/black"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.7"
|
||||
android:text="testing1"
|
||||
/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.7"
|
||||
android:text="testing2"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.6"
|
||||
android:weightSum="3"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/yesButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/noButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/notSureButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -452,4 +452,8 @@ Upload your first media by touching the camera or gallery icon above.</string>
|
|||
<string name="this_function_needs_network_connection">This function requires network connection, please check your connection settings.</string>
|
||||
<string name="bad_token_error_proposed_solution">Upload failed due to issues with edit token. Please try logging out and in again. </string>
|
||||
|
||||
<string name="review_copyright">Is this a copyright violation?</string>
|
||||
<string name="review_category">Is this mis-categorized?</string>
|
||||
<string name="review_spam">Is this spam?</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue