Skip to content

Commit 2a6ac7a

Browse files
committed
Layout made screen independent and menu inflated
1 parent 8fc7f79 commit 2a6ac7a

File tree

2 files changed

+96
-62
lines changed

2 files changed

+96
-62
lines changed

app/src/main/java/fr/free/nrw/commons/Achievements.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,47 @@
22

33
import android.support.v7.app.AppCompatActivity;
44
import android.os.Bundle;
5+
import android.util.DisplayMetrics;
56
import android.view.Menu;
67
import android.view.MenuInflater;
78
import android.view.View;
89
import android.widget.ImageView;
10+
import android.widget.LinearLayout;
11+
import android.widget.RelativeLayout;
12+
import android.widget.Toolbar;
13+
14+
import fr.free.nrw.commons.theme.NavigationBaseActivity;
915

1016
public class Achievements extends AppCompatActivity {
1117

18+
private static final double badge_image_ratio_width = 0.5;
19+
private static final double badge_image_ratio_height = 0.5;
20+
1221
@Override
1322
protected void onCreate(Bundle savedInstanceState) {
1423
super.onCreate(savedInstanceState);
1524
setContentView(R.layout.activity_achievements);
1625

26+
DisplayMetrics displayMetrics = new DisplayMetrics();
27+
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
28+
int height = displayMetrics.heightPixels;
29+
int width = displayMetrics.widthPixels;
30+
31+
ImageView imageView = (ImageView)findViewById(R.id.achievement_badge);
32+
33+
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)
34+
imageView.getLayoutParams();
35+
params.height = (int) (height*badge_image_ratio_height);
36+
params.width = (int) (width*badge_image_ratio_width);
37+
imageView.setImageResource(R.drawable.sydney_opera_house);
38+
imageView.requestLayout();
39+
40+
android.support.v7.widget.Toolbar toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
41+
toolbar.inflateMenu(R.menu.menu_about);
1742

1843
}
1944

45+
46+
47+
2048
}

app/src/main/res/layout/activity_achievements.xml

Lines changed: 68 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
android:layout_width="match_parent"
66
android:layout_height="match_parent">
77

8+
<ScrollView
9+
android:layout_width="wrap_content"
10+
android:layout_height="wrap_content">
811
<LinearLayout
912
android:layout_width="match_parent"
1013
android:layout_height="match_parent"
@@ -14,131 +17,133 @@
1417
layout="@layout/toolbar"
1518
android:layout_width="match_parent"
1619
android:layout_height="wrap_content" />
17-
1820
<RelativeLayout
1921
android:layout_width="match_parent"
20-
android:layout_height="0dp"
21-
android:layout_weight="1.8"
22-
android:orientation="vertical"
22+
android:layout_height="wrap_content"
2323
android:layout_below="@+id/toolbar"
24-
android:background="#D6DCE0">
24+
android:background="#D6DCE0"
25+
android:orientation="vertical">
26+
2527
<TextView
28+
style="?android:textAppearanceLarge"
2629
android:layout_width="wrap_content"
2730
android:layout_height="wrap_content"
28-
style="?android:textAppearanceLarge"
29-
android:layout_marginTop="@dimen/activity_margin_horizontal"
30-
android:layout_marginStart="@dimen/activity_margin_horizontal"
3131
android:layout_marginLeft="@dimen/activity_margin_horizontal"
32-
android:text="@string/level"/>
32+
android:layout_marginStart="@dimen/activity_margin_horizontal"
33+
android:layout_marginTop="@dimen/activity_margin_horizontal"
34+
android:text="@string/level"
35+
android:id="@+id/achievement_level"/>
3336

3437
<ImageView
38+
android:id="@+id/achievement_badge"
3539
android:layout_width="wrap_content"
3640
android:layout_height="wrap_content"
37-
android:layout_marginVertical="@dimen/activity_margin_vertical"
38-
android:id="@+id/achievement_badge"
39-
android:layout_above="@+id/layout_image_uploaded"
40-
android:layout_marginBottom="@dimen/activity_margin_vertical"
41-
android:layout_centerHorizontal="true"/>
41+
android:layout_below="@id/achievement_level"
42+
android:layout_centerHorizontal="true"
43+
android:layout_marginVertical="@dimen/activity_margin_vertical" />
44+
4245
<RelativeLayout
46+
android:id="@+id/layout_image_uploaded"
4347
android:layout_width="match_parent"
4448
android:layout_height="wrap_content"
45-
android:id="@+id/layout_image_uploaded"
46-
android:layout_above="@+id/layout_image_reverts"
49+
android:layout_below="@+id/achievement_badge"
4750
android:layout_marginEnd="@dimen/activity_margin_horizontal"
4851
android:layout_marginLeft="@dimen/activity_margin_horizontal"
4952
android:layout_marginRight="@dimen/activity_margin_horizontal"
5053
android:layout_marginStart="@dimen/activity_margin_horizontal">
54+
5155
<TextView
56+
style="?android:textAppearanceMedium"
5257
android:layout_width="wrap_content"
5358
android:layout_height="wrap_content"
54-
style="?android:textAppearanceMedium"
55-
android:layout_marginTop="@dimen/activity_margin_horizontal"
56-
android:layout_marginStart="@dimen/activity_margin_horizontal"
5759
android:layout_marginLeft="@dimen/activity_margin_horizontal"
58-
android:text="@string/images_uploaded"/>
60+
android:layout_marginStart="@dimen/activity_margin_horizontal"
61+
android:text="@string/images_uploaded" />
62+
5963
<com.dinuscxj.progressbar.CircleProgressBar
60-
android:layout_marginTop="4dp"
61-
android:progress="50"
62-
app:style="solid_line"
64+
android:layout_width="35dp"
65+
android:layout_height="35dp"
6366
android:layout_alignParentRight="true"
64-
android:layout_marginHorizontal="@dimen/activity_margin_horizontal"
65-
app:progress_text_format_pattern="12/24"
66-
app:progress_stroke_width="3dp"
67-
app:progress_start_color="#3A3381"
67+
android:layout_marginRight="32dp"
68+
android:progress="50"
6869
app:progress_end_color="#8C8B98"
69-
android:layout_width="50dp"
70-
android:layout_height="50dp" />
70+
app:progress_start_color="#3A3381"
71+
app:progress_stroke_width="3dp"
72+
app:progress_text_format_pattern="12/24"
73+
app:style="solid_line" />
7174

7275

7376
</RelativeLayout>
77+
7478
<RelativeLayout
79+
android:id="@+id/layout_image_reverts"
7580
android:layout_width="match_parent"
7681
android:layout_height="wrap_content"
77-
android:id="@+id/layout_image_reverts"
78-
android:layout_above="@+id/layout_image_used_by_wiki"
82+
android:layout_marginTop="4dp"
83+
android:layout_below="@+id/layout_image_uploaded"
7984
android:layout_marginEnd="@dimen/activity_margin_horizontal"
8085
android:layout_marginLeft="@dimen/activity_margin_horizontal"
8186
android:layout_marginRight="@dimen/activity_margin_horizontal"
8287
android:layout_marginStart="@dimen/activity_margin_horizontal">
88+
8389
<TextView
90+
style="?android:textAppearanceMedium"
8491
android:layout_width="wrap_content"
8592
android:layout_height="wrap_content"
86-
style="?android:textAppearanceMedium"
87-
android:layout_marginTop="@dimen/activity_margin_horizontal"
88-
android:layout_marginStart="@dimen/activity_margin_horizontal"
8993
android:layout_marginLeft="@dimen/activity_margin_horizontal"
90-
android:text="@string/images_uploaded"/>
94+
android:layout_marginStart="@dimen/activity_margin_horizontal"
95+
android:text="@string/images_uploaded" />
96+
9197
<com.dinuscxj.progressbar.CircleProgressBar
92-
android:layout_marginTop="4dp"
93-
android:progress="50"
94-
app:style="solid_line"
98+
android:layout_width="35dp"
99+
android:layout_height="35dp"
95100
android:layout_alignParentRight="true"
96-
android:layout_marginHorizontal="@dimen/activity_margin_horizontal"
97-
app:progress_text_format_pattern="12/24"
98-
app:progress_stroke_width="3dp"
99-
app:progress_start_color="#3A3381"
101+
android:layout_marginRight="32dp"
102+
android:progress="50"
100103
app:progress_end_color="#8C8B98"
101-
android:layout_width="50dp"
102-
android:layout_height="50dp" />
104+
app:progress_start_color="#3A3381"
105+
app:progress_stroke_width="3dp"
106+
app:progress_text_format_pattern="12/24"
107+
app:style="solid_line" />
103108
</RelativeLayout>
109+
104110
<RelativeLayout
111+
android:id="@+id/layout_image_used_by_wiki"
105112
android:layout_width="match_parent"
106113
android:layout_height="wrap_content"
107-
android:id="@+id/layout_image_used_by_wiki"
114+
android:layout_marginTop="4dp"
115+
android:layout_below="@+id/layout_image_reverts"
108116
android:layout_marginBottom="@dimen/activity_margin_vertical"
109-
android:layout_alignParentBottom="true"
110117
android:layout_marginEnd="@dimen/activity_margin_horizontal"
111118
android:layout_marginLeft="@dimen/activity_margin_horizontal"
112119
android:layout_marginRight="@dimen/activity_margin_horizontal"
113120
android:layout_marginStart="@dimen/activity_margin_horizontal">
121+
114122
<TextView
123+
style="?android:textAppearanceMedium"
115124
android:layout_width="wrap_content"
116125
android:layout_height="wrap_content"
117-
style="?android:textAppearanceMedium"
118-
android:layout_marginTop="@dimen/activity_margin_horizontal"
119-
android:layout_marginStart="@dimen/activity_margin_horizontal"
120126
android:layout_marginLeft="@dimen/activity_margin_horizontal"
121-
android:text="@string/images_uploaded"/>
127+
android:layout_marginStart="@dimen/activity_margin_horizontal"
128+
android:text="@string/images_uploaded" />
129+
122130
<com.dinuscxj.progressbar.CircleProgressBar
123-
android:layout_marginTop="4dp"
124-
android:progress="50"
125-
app:style="solid_line"
131+
android:layout_width="35dp"
132+
android:layout_height="35dp"
126133
android:layout_alignParentRight="true"
127-
android:layout_marginHorizontal="@dimen/activity_margin_horizontal"
128-
app:progress_text_format_pattern="12/24"
129-
app:progress_stroke_width="2.5dp"
130-
app:progress_start_color="#3A3381"
134+
android:layout_marginRight="32dp" android:progress="50"
131135
app:progress_end_color="#8C8B98"
132-
android:layout_width="50dp"
133-
android:layout_height="50dp" />
136+
app:progress_start_color="#3A3381"
137+
app:progress_stroke_width="2.5dp"
138+
app:progress_text_format_pattern="12/24"
139+
app:style="solid_line" />
134140
</RelativeLayout>
135141

136142
</RelativeLayout>
137143
<LinearLayout
138144
android:layout_width="match_parent"
139-
android:layout_height="0dp"
140-
android:orientation="vertical"
141-
android:layout_weight="1">
145+
android:layout_height="wrap_content"
146+
android:orientation="vertical">
142147

143148
<TextView
144149
android:layout_width="wrap_content"
@@ -220,6 +225,7 @@
220225
</LinearLayout>
221226

222227
</LinearLayout>
228+
</ScrollView>
223229
<android.support.design.widget.NavigationView
224230
android:id="@+id/navigation_view"
225231
android:layout_width="wrap_content"

0 commit comments

Comments
 (0)