mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Render thanks , images used in articles on screen
This commit is contained in:
parent
1aabc3f687
commit
bdb18575ec
5 changed files with 110 additions and 3 deletions
|
|
@ -68,7 +68,7 @@ dependencies {
|
||||||
testImplementation 'org.robolectric:robolectric:3.7.1'
|
testImplementation 'org.robolectric:robolectric:3.7.1'
|
||||||
testImplementation 'com.nhaarman:mockito-kotlin:1.5.0'
|
testImplementation 'com.nhaarman:mockito-kotlin:1.5.0'
|
||||||
testImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
|
testImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
|
||||||
compile 'com.dinuscxj:circleprogressbar:1.1.1'
|
implementation 'com.dinuscxj:circleprogressbar:1.1.1'
|
||||||
|
|
||||||
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
|
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
|
||||||
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
|
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,83 @@
|
||||||
package fr.free.nrw.commons.achievements;
|
package fr.free.nrw.commons.achievements;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* represnts Achievements
|
||||||
|
*/
|
||||||
public class Achievements {
|
public class Achievements {
|
||||||
|
private int uniqueUsedImages;
|
||||||
|
private int articlesUsingImages;
|
||||||
|
private int thanksReceived;
|
||||||
|
private int imagesEditedBySomeoneElse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the unique images used
|
||||||
|
*
|
||||||
|
* @param uniqueUsedImages
|
||||||
|
*/
|
||||||
|
public void setUniqueUsedImages(int uniqueUsedImages) {
|
||||||
|
this.uniqueUsedImages = uniqueUsedImages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the unique images used
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getUniqueUsedImages() {
|
||||||
|
return uniqueUsedImages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the number of articles using images
|
||||||
|
*
|
||||||
|
* @param articlesUsingImages
|
||||||
|
*/
|
||||||
|
public void setArticlesUsingImages(int articlesUsingImages) {
|
||||||
|
this.articlesUsingImages = articlesUsingImages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the number of articles using images
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getArticlesUsingImages() {
|
||||||
|
return articlesUsingImages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the no of thanks received by user
|
||||||
|
*
|
||||||
|
* @param thanksReceived
|
||||||
|
*/
|
||||||
|
public void setThanksReceived(int thanksReceived) {
|
||||||
|
this.thanksReceived = thanksReceived;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return the no of thanks received by user
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getThanksReceived() {
|
||||||
|
return thanksReceived;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the no of images edited by someone else
|
||||||
|
*
|
||||||
|
* @param imagesEditedBySomeoneElse
|
||||||
|
*/
|
||||||
|
public void setImagesEditedBySomeoneElse(int imagesEditedBySomeoneElse) {
|
||||||
|
this.imagesEditedBySomeoneElse = imagesEditedBySomeoneElse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the no of images edited by someone else
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getImagesEditedBySomeoneElse() {
|
||||||
|
return imagesEditedBySomeoneElse;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,10 @@ import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import com.dinuscxj.progressbar.CircleProgressBar;
|
||||||
|
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -49,6 +52,12 @@ public class AchievementsActivity extends NavigationBaseActivity {
|
||||||
TextView textView;
|
TextView textView;
|
||||||
@BindView(R.id.toolbar)
|
@BindView(R.id.toolbar)
|
||||||
Toolbar toolbar;
|
Toolbar toolbar;
|
||||||
|
@BindView(R.id.thanks_received)
|
||||||
|
TextView thanksReceived;
|
||||||
|
@BindView(R.id.images_uploaded_progressbar)
|
||||||
|
CircleProgressBar imagesUploadedProgressbar;
|
||||||
|
@BindView(R.id.images_used_by_wiki_progressbar)
|
||||||
|
CircleProgressBar imagesUsedByWikiProgessbar;
|
||||||
@Inject
|
@Inject
|
||||||
SessionManager sessionManager;
|
SessionManager sessionManager;
|
||||||
@Inject
|
@Inject
|
||||||
|
|
@ -153,7 +162,23 @@ public class AchievementsActivity extends NavigationBaseActivity {
|
||||||
* @param object
|
* @param object
|
||||||
*/
|
*/
|
||||||
private void parseJson(JSONObject object) {
|
private void parseJson(JSONObject object) {
|
||||||
Log.i("json", object.toString());
|
Achievements achievements = new Achievements();
|
||||||
|
try {
|
||||||
|
achievements.setUniqueUsedImages(object.getInt("uniqueUsedImages"));
|
||||||
|
achievements.setArticlesUsingImages(object.getInt("articlesUsingImages"));
|
||||||
|
achievements.setThanksReceived(object.getInt("thanksReceived"));
|
||||||
|
achievements.setImagesEditedBySomeoneElse(object.getInt("imagesEditedBySomeoneElse"));
|
||||||
|
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
inflateAchievements(achievements);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void inflateAchievements( Achievements achievements){
|
||||||
|
thanksReceived.setText(Integer.toString(achievements.getThanksReceived()));
|
||||||
|
imagesUsedByWikiProgessbar.setProgress(100*achievements.getUniqueUsedImages()/25);
|
||||||
|
imagesUsedByWikiProgessbar.setProgressTextFormatPattern(achievements.getUniqueUsedImages() + "/25");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@
|
||||||
android:layout_height="35dp"
|
android:layout_height="35dp"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_marginRight="32dp"
|
android:layout_marginRight="32dp"
|
||||||
|
android:id="@+id/images_uploaded_progressbar"
|
||||||
android:progress="50"
|
android:progress="50"
|
||||||
app:progress_end_color="#8C8B98"
|
app:progress_end_color="#8C8B98"
|
||||||
app:progress_start_color="#3A3381"
|
app:progress_start_color="#3A3381"
|
||||||
|
|
@ -112,6 +113,7 @@
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_marginRight="32dp"
|
android:layout_marginRight="32dp"
|
||||||
android:progress="50"
|
android:progress="50"
|
||||||
|
android:id="@+id/image_reverts_progressbar"
|
||||||
app:progress_end_color="#8C8B98"
|
app:progress_end_color="#8C8B98"
|
||||||
app:progress_start_color="#3A3381"
|
app:progress_start_color="#3A3381"
|
||||||
app:progress_stroke_width="3dp"
|
app:progress_stroke_width="3dp"
|
||||||
|
|
@ -146,6 +148,7 @@
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_marginRight="32dp"
|
android:layout_marginRight="32dp"
|
||||||
android:progress="50"
|
android:progress="50"
|
||||||
|
android:id="@+id/images_used_by_wiki_progressbar"
|
||||||
app:progress_end_color="#8C8B98"
|
app:progress_end_color="#8C8B98"
|
||||||
app:progress_start_color="#3A3381"
|
app:progress_start_color="#3A3381"
|
||||||
app:progress_stroke_width="2.5dp"
|
app:progress_stroke_width="2.5dp"
|
||||||
|
|
@ -242,6 +245,7 @@
|
||||||
android:layout_marginStart="@dimen/activity_margin_horizontal"
|
android:layout_marginStart="@dimen/activity_margin_horizontal"
|
||||||
android:layout_marginLeft="@dimen/activity_margin_horizontal"
|
android:layout_marginLeft="@dimen/activity_margin_horizontal"
|
||||||
android:text="2"
|
android:text="2"
|
||||||
|
android:id="@+id/thanks_received"
|
||||||
android:layout_marginRight="44dp" />
|
android:layout_marginRight="44dp" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="preference_category_appearance">Appearance</string
|
<string name="preference_category_appearance">Appearance</string>
|
||||||
<string name="preference_category_general">General</string>
|
<string name="preference_category_general">General</string>
|
||||||
<string name="preference_category_feedback">Feedback</string>
|
<string name="preference_category_feedback">Feedback</string>
|
||||||
<string name="preference_category_location">Location</string>
|
<string name="preference_category_location">Location</string>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue