Skip to content

Commit d965b21

Browse files
committed
A few fixes for the about view
- Button doesn't seem to work on API 31, remove it and replace it with linked URL instead - Fix a few layout bugs - Remove unused imports
1 parent a2af990 commit d965b21

File tree

2 files changed

+6
-40
lines changed

2 files changed

+6
-40
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
package io.spaceapi.community.myhackerspace;
22

3-
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
4-
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
5-
6-
import android.Manifest;
73
import android.content.Context;
8-
import android.content.Intent;
9-
import android.net.Uri;
104
import android.util.AttributeSet;
115
import android.view.LayoutInflater;
12-
import android.view.View;
13-
import android.view.ViewGroup;
14-
import android.widget.Button;
156
import android.widget.LinearLayout;
167
import android.widget.TextView;
178

@@ -36,38 +27,14 @@ public AboutLayout(Context context, AttributeSet attrs, int defStyleAttr, int de
3627
}
3728

3829
public void init() {
39-
Button openRepoButton = findViewById(R.id.about_open_repo_button);
40-
openRepoButton.setOnClickListener(new OnClickListener() {
41-
@Override
42-
public void onClick(View v) {
43-
TextView repository = (TextView)findViewById(R.id.about_repository);
44-
String url = (String) repository.getText();
45-
openWebPage(url);
46-
}
47-
});
4830
TextView version = findViewById(R.id.about_version_text);
4931
version.setText(BuildConfig.VERSION_NAME + " (" + Integer.toString(BuildConfig.VERSION_CODE) + ")");
5032
}
5133

5234
public static AboutLayout create(Context context) {
53-
// use xml layout, see https://stackoverflow.com/a/13889257
5435
LayoutInflater layoutInflater = LayoutInflater.from(context);
5536
AboutLayout about = (AboutLayout) layoutInflater.inflate(R.layout.about, null, false);
5637
about.init();
5738
return about;
5839
}
59-
60-
public void openWebPage(String url) {
61-
// from https://stackoverflow.com/a/43981160
62-
Uri webpage = Uri.parse(url);
63-
64-
Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
65-
66-
if (intent.resolveActivity(getContext().getPackageManager()) != null) {
67-
getContext().startActivity(intent);
68-
}else{
69-
//Page not found
70-
}
71-
}
72-
7340
}

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

+6-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<io.spaceapi.community.myhackerspace.AboutLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent"
44
android:layout_height="match_parent"
5+
android:paddingStart="8dp"
6+
android:paddingTop="8dp"
57
android:orientation="vertical">
68

79
<LinearLayout
@@ -20,7 +22,8 @@
2022
android:layout_width="0dp"
2123
android:layout_height="wrap_content"
2224
android:layout_weight="1"
23-
android:text="1.0.0" />
25+
android:layout_marginStart="2sp"
26+
android:text="{version}" />
2427
</LinearLayout>
2528

2629
<LinearLayout
@@ -39,19 +42,15 @@
3942
android:layout_width="0dp"
4043
android:layout_height="wrap_content"
4144
android:layout_weight="1"
45+
android:layout_marginStart="2sp"
4246
android:text="@string/about_license_text" />
4347
</LinearLayout>
4448

4549
<TextView
4650
android:id="@+id/about_repository"
4751
android:layout_width="match_parent"
4852
android:layout_height="wrap_content"
53+
android:autoLink="web"
4954
android:text="@string/about_repository_url" />
5055

51-
<Button
52-
android:id="@+id/about_open_repo_button"
53-
android:layout_width="match_parent"
54-
android:layout_height="wrap_content"
55-
android:text="@string/about_visit_repository" />
56-
5756
</io.spaceapi.community.myhackerspace.AboutLayout>

0 commit comments

Comments
 (0)