mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +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" />
|
||||
|
||||
<activity
|
||||
android:name=".Achievements"
|
||||
android:name=".achievements.AchievementsActivity"
|
||||
android:label="@string/Achievements">
|
||||
<intent-filter>
|
||||
<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.graphics.Bitmap;
|
||||
|
|
@ -20,37 +20,42 @@ import android.widget.Toolbar;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
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;
|
||||
|
||||
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
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_achievements);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
int height = displayMetrics.heightPixels;
|
||||
int width = displayMetrics.widthPixels;
|
||||
|
||||
imageView = (ImageView)findViewById(R.id.achievement_badge);
|
||||
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)
|
||||
imageView.getLayoutParams();
|
||||
params.height = (int) (height*badge_image_ratio_height);
|
||||
params.width = (int) (width*badge_image_ratio_width);
|
||||
params.height = (int) (height*BADGE_IMAGE_HEIGHT_RATIO);
|
||||
params.width = (int) (width*BADGE_IMAGE_WIDTH_RATIO);
|
||||
imageView.setImageResource(R.drawable.sydney_opera_house);
|
||||
imageView.requestLayout();
|
||||
|
||||
android.support.v7.widget.Toolbar toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -73,6 +78,11 @@ public class Achievements extends AppCompatActivity {
|
|||
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) {
|
||||
View screenView = view.getRootView();
|
||||
screenView.setDrawingCacheEnabled(true);
|
||||
|
|
@ -81,6 +91,10 @@ public class Achievements extends AppCompatActivity {
|
|||
return bitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* To take bitmap and store it temporary storage and share it
|
||||
* @param bitmap
|
||||
*/
|
||||
void shareScreen ( Bitmap bitmap){
|
||||
try {
|
||||
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.setType("image/png");
|
||||
startActivity(Intent.createChooser(intent, "Share image via"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
//Do Nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -8,20 +8,23 @@
|
|||
<ScrollView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include
|
||||
android:id="@+id/toolbar"
|
||||
layout="@layout/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/toolbar"
|
||||
android:background="#D6DCE0"
|
||||
android:background="@color/layout_light_grey"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
|
|
@ -72,7 +75,6 @@
|
|||
app:progress_text_format_pattern="12/24"
|
||||
app:style="solid_line" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
|
|
@ -105,6 +107,7 @@
|
|||
app:progress_stroke_width="3dp"
|
||||
app:progress_text_format_pattern="12/24"
|
||||
app:style="solid_line" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
|
|
@ -131,15 +134,17 @@
|
|||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
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_start_color="#3A3381"
|
||||
app:progress_stroke_width="2.5dp"
|
||||
app:progress_text_format_pattern="12/24"
|
||||
app:style="solid_line" />
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -152,6 +157,7 @@
|
|||
style="?android:textAppearanceLarge"
|
||||
android:layout_marginLeft="@dimen/activity_margin_horizontal"
|
||||
android:layout_marginTop="@dimen/activity_margin_vertical" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -160,12 +166,13 @@
|
|||
android:layout_marginEnd="@dimen/activity_margin_horizontal"
|
||||
android:layout_marginStart="@dimen/activity_margin_horizontal"
|
||||
android:layout_marginTop="@dimen/activity_margin_horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/overflow_icon_dimen"
|
||||
android:layout_height="@dimen/overflow_icon_dimen"
|
||||
android:id="@+id/featured_image_icon"
|
||||
app:srcCompat="@drawable/featured"
|
||||
/>
|
||||
app:srcCompat="@drawable/featured" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -175,6 +182,7 @@
|
|||
android:layout_marginStart="@dimen/activity_margin_horizontal"
|
||||
android:layout_marginLeft="@dimen/activity_margin_horizontal"
|
||||
android:text="@string/statistics_featured" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -187,6 +195,7 @@
|
|||
android:layout_marginLeft="@dimen/activity_margin_horizontal" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -194,13 +203,14 @@
|
|||
android:layout_marginEnd="@dimen/activity_margin_horizontal"
|
||||
android:layout_marginRight="@dimen/activity_margin_horizontal"
|
||||
android:layout_marginStart="@dimen/activity_margin_horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/overflow_icon_dimen"
|
||||
android:layout_height="@dimen/overflow_icon_dimen"
|
||||
app:srcCompat="@drawable/ic_thanks"
|
||||
android:id="@+id/thanks_image_icon"
|
||||
android:scaleType="centerCrop"
|
||||
/>
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -210,6 +220,7 @@
|
|||
android:layout_marginStart="@dimen/activity_margin_horizontal"
|
||||
android:layout_marginLeft="@dimen/activity_margin_horizontal"
|
||||
android:text="@string/statistics_thanks" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -220,12 +231,12 @@
|
|||
android:layout_marginStart="@dimen/activity_margin_horizontal"
|
||||
android:layout_marginLeft="@dimen/activity_margin_horizontal"
|
||||
android:text="2" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
<android.support.design.widget.NavigationView
|
||||
android:id="@+id/navigation_view"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
@ -233,4 +244,5 @@
|
|||
android:layout_gravity="start"
|
||||
app:headerLayout="@layout/drawer_header"
|
||||
app:menu="@menu/drawer" />
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
|
||||
<color name="bottom_bar_light">#E0E0E0</color>
|
||||
<color name="bottom_bar_dark">#424242</color>
|
||||
<color name="layout_light_grey">#D6DCE0</color>
|
||||
|
||||
<color name="opak_middle_grey">#757575</color>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue