mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Improved the quality of Pr
This commit is contained in:
parent
3851d37a38
commit
fe82581472
4 changed files with 244 additions and 219 deletions
|
|
@ -89,7 +89,7 @@
|
||||||
android:parentActivityName=".contributions.ContributionsActivity" />
|
android:parentActivityName=".contributions.ContributionsActivity" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".Achievements"
|
android:name=".achievements.AchievementsActivity"
|
||||||
android:label="@string/Achievements">
|
android:label="@string/Achievements">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package fr.free.nrw.commons;
|
package fr.free.nrw.commons.achievements;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
|
@ -20,37 +20,42 @@ import android.widget.Toolbar;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import dagger.Binds;
|
||||||
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.theme.NavigationBaseActivity;
|
import fr.free.nrw.commons.theme.NavigationBaseActivity;
|
||||||
|
|
||||||
public class Achievements extends AppCompatActivity {
|
public class AchievementsActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private static final double BADGE_IMAGE_WIDTH_RATIO = 0.4;
|
||||||
|
private static final double BADGE_IMAGE_HEIGHT_RATIO = 0.36;
|
||||||
|
|
||||||
|
@BindView(R.id.achievement_badge) ImageView imageView;
|
||||||
|
@BindView(R.id.toolbar) android.support.v7.widget.Toolbar toolbar;
|
||||||
|
|
||||||
private static final double badge_image_ratio_width = 0.4;
|
|
||||||
private static final double badge_image_ratio_height = 0.36;
|
|
||||||
private ImageView imageView;
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_achievements);
|
setContentView(R.layout.activity_achievements);
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||||
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||||
int height = displayMetrics.heightPixels;
|
int height = displayMetrics.heightPixels;
|
||||||
int width = displayMetrics.widthPixels;
|
int width = displayMetrics.widthPixels;
|
||||||
|
|
||||||
imageView = (ImageView)findViewById(R.id.achievement_badge);
|
|
||||||
|
|
||||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)
|
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)
|
||||||
imageView.getLayoutParams();
|
imageView.getLayoutParams();
|
||||||
params.height = (int) (height*badge_image_ratio_height);
|
params.height = (int) (height*BADGE_IMAGE_HEIGHT_RATIO);
|
||||||
params.width = (int) (width*badge_image_ratio_width);
|
params.width = (int) (width*BADGE_IMAGE_WIDTH_RATIO);
|
||||||
imageView.setImageResource(R.drawable.sydney_opera_house);
|
imageView.setImageResource(R.drawable.sydney_opera_house);
|
||||||
imageView.requestLayout();
|
imageView.requestLayout();
|
||||||
|
|
||||||
android.support.v7.widget.Toolbar toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
|
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -73,6 +78,11 @@ public class Achievements extends AppCompatActivity {
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To take screenshot of the screen and return it in Bitmap format
|
||||||
|
* @param view
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static Bitmap getScreenShot(View view) {
|
public static Bitmap getScreenShot(View view) {
|
||||||
View screenView = view.getRootView();
|
View screenView = view.getRootView();
|
||||||
screenView.setDrawingCacheEnabled(true);
|
screenView.setDrawingCacheEnabled(true);
|
||||||
|
|
@ -81,6 +91,10 @@ public class Achievements extends AppCompatActivity {
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To take bitmap and store it temporary storage and share it
|
||||||
|
* @param bitmap
|
||||||
|
*/
|
||||||
void shareScreen ( Bitmap bitmap){
|
void shareScreen ( Bitmap bitmap){
|
||||||
try {
|
try {
|
||||||
File file = new File(this.getExternalCacheDir(),"screen.png");
|
File file = new File(this.getExternalCacheDir(),"screen.png");
|
||||||
|
|
@ -94,11 +108,9 @@ public class Achievements extends AppCompatActivity {
|
||||||
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
|
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
|
||||||
intent.setType("image/png");
|
intent.setType("image/png");
|
||||||
startActivity(Intent.createChooser(intent, "Share image via"));
|
startActivity(Intent.createChooser(intent, "Share image via"));
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
//Do Nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -8,20 +8,23 @@
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
layout="@layout/toolbar"
|
layout="@layout/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/toolbar"
|
android:layout_below="@+id/toolbar"
|
||||||
android:background="#D6DCE0"
|
android:background="@color/layout_light_grey"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
@ -72,7 +75,6 @@
|
||||||
app:progress_text_format_pattern="12/24"
|
app:progress_text_format_pattern="12/24"
|
||||||
app:style="solid_line" />
|
app:style="solid_line" />
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
|
|
@ -105,6 +107,7 @@
|
||||||
app:progress_stroke_width="3dp"
|
app:progress_stroke_width="3dp"
|
||||||
app:progress_text_format_pattern="12/24"
|
app:progress_text_format_pattern="12/24"
|
||||||
app:style="solid_line" />
|
app:style="solid_line" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
|
|
@ -131,15 +134,17 @@
|
||||||
android:layout_width="35dp"
|
android:layout_width="35dp"
|
||||||
android:layout_height="35dp"
|
android:layout_height="35dp"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_marginRight="32dp" android:progress="50"
|
android:layout_marginRight="32dp"
|
||||||
|
android:progress="50"
|
||||||
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"
|
||||||
app:progress_text_format_pattern="12/24"
|
app:progress_text_format_pattern="12/24"
|
||||||
app:style="solid_line" />
|
app:style="solid_line" />
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
@ -152,6 +157,7 @@
|
||||||
style="?android:textAppearanceLarge"
|
style="?android:textAppearanceLarge"
|
||||||
android:layout_marginLeft="@dimen/activity_margin_horizontal"
|
android:layout_marginLeft="@dimen/activity_margin_horizontal"
|
||||||
android:layout_marginTop="@dimen/activity_margin_vertical" />
|
android:layout_marginTop="@dimen/activity_margin_vertical" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
@ -160,12 +166,13 @@
|
||||||
android:layout_marginEnd="@dimen/activity_margin_horizontal"
|
android:layout_marginEnd="@dimen/activity_margin_horizontal"
|
||||||
android:layout_marginStart="@dimen/activity_margin_horizontal"
|
android:layout_marginStart="@dimen/activity_margin_horizontal"
|
||||||
android:layout_marginTop="@dimen/activity_margin_horizontal">
|
android:layout_marginTop="@dimen/activity_margin_horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="@dimen/overflow_icon_dimen"
|
android:layout_width="@dimen/overflow_icon_dimen"
|
||||||
android:layout_height="@dimen/overflow_icon_dimen"
|
android:layout_height="@dimen/overflow_icon_dimen"
|
||||||
android:id="@+id/featured_image_icon"
|
android:id="@+id/featured_image_icon"
|
||||||
app:srcCompat="@drawable/featured"
|
app:srcCompat="@drawable/featured" />
|
||||||
/>
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
@ -175,6 +182,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="@string/statistics_featured" />
|
android:text="@string/statistics_featured" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
@ -187,6 +195,7 @@
|
||||||
android:layout_marginLeft="@dimen/activity_margin_horizontal" />
|
android:layout_marginLeft="@dimen/activity_margin_horizontal" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
@ -194,13 +203,14 @@
|
||||||
android:layout_marginEnd="@dimen/activity_margin_horizontal"
|
android:layout_marginEnd="@dimen/activity_margin_horizontal"
|
||||||
android:layout_marginRight="@dimen/activity_margin_horizontal"
|
android:layout_marginRight="@dimen/activity_margin_horizontal"
|
||||||
android:layout_marginStart="@dimen/activity_margin_horizontal">
|
android:layout_marginStart="@dimen/activity_margin_horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="@dimen/overflow_icon_dimen"
|
android:layout_width="@dimen/overflow_icon_dimen"
|
||||||
android:layout_height="@dimen/overflow_icon_dimen"
|
android:layout_height="@dimen/overflow_icon_dimen"
|
||||||
app:srcCompat="@drawable/ic_thanks"
|
app:srcCompat="@drawable/ic_thanks"
|
||||||
android:id="@+id/thanks_image_icon"
|
android:id="@+id/thanks_image_icon"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop" />
|
||||||
/>
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
@ -210,6 +220,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="@string/statistics_thanks" />
|
android:text="@string/statistics_thanks" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
@ -220,12 +231,12 @@
|
||||||
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" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<android.support.design.widget.NavigationView
|
<android.support.design.widget.NavigationView
|
||||||
android:id="@+id/navigation_view"
|
android:id="@+id/navigation_view"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
@ -233,4 +244,5 @@
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
app:headerLayout="@layout/drawer_header"
|
app:headerLayout="@layout/drawer_header"
|
||||||
app:menu="@menu/drawer" />
|
app:menu="@menu/drawer" />
|
||||||
|
|
||||||
</android.support.v4.widget.DrawerLayout>
|
</android.support.v4.widget.DrawerLayout>
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@
|
||||||
|
|
||||||
<color name="bottom_bar_light">#E0E0E0</color>
|
<color name="bottom_bar_light">#E0E0E0</color>
|
||||||
<color name="bottom_bar_dark">#424242</color>
|
<color name="bottom_bar_dark">#424242</color>
|
||||||
|
<color name="layout_light_grey">#D6DCE0</color>
|
||||||
|
|
||||||
<color name="opak_middle_grey">#757575</color>
|
<color name="opak_middle_grey">#757575</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue