forked from GDXN/bubble
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
296 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
app/src/main/java/com/nkanaev/comics/fragment/AboutFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package com.nkanaev.comics.fragment; | ||
|
||
import android.content.Intent; | ||
import android.content.pm.PackageInfo; | ||
import android.content.pm.PackageManager; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.support.v4.app.Fragment; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.LinearLayout; | ||
import android.widget.TextView; | ||
import com.nkanaev.comics.R; | ||
|
||
public class AboutFragment extends Fragment implements View.OnClickListener { | ||
private class LibraryDescription { | ||
public final String name; | ||
public final String description; | ||
public final String license; | ||
public final String owner; | ||
public final String link; | ||
|
||
LibraryDescription(String name, String description, String license, String owner, String link) { | ||
this.name = name; | ||
this.description = description; | ||
this.license = license; | ||
this.owner = owner; | ||
this.link = link; | ||
} | ||
} | ||
|
||
private LibraryDescription[] mDescriptions = new LibraryDescription[]{ | ||
new LibraryDescription( | ||
"Picasso", | ||
"A powerful image downloading and caching library for Android", | ||
"Apache Version 2.0", | ||
"Square", | ||
"https://github.com/square/picasso" | ||
), | ||
new LibraryDescription( | ||
"Junrar", | ||
"Plain java unrar util", | ||
"Unrar License", | ||
"Edmund Wagner", | ||
"https://github.com/edmund-wagner/junrar" | ||
) | ||
}; | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||
final View view = inflater.inflate(R.layout.fragment_about, container, false); | ||
|
||
LinearLayout libsLayout = (LinearLayout) view.findViewById(R.id.about_libraries); | ||
|
||
((TextView) view.findViewById(R.id.aboutVersion)).setText(getVersionString()); | ||
|
||
for (int i = 0; i < mDescriptions.length; i++) { | ||
View cardView = inflater.inflate(R.layout.card_deps, libsLayout, false); | ||
|
||
((TextView) cardView.findViewById(R.id.libraryName)).setText(mDescriptions[i].name); | ||
((TextView) cardView.findViewById(R.id.libraryCreator)).setText(mDescriptions[i].owner); | ||
((TextView) cardView.findViewById(R.id.libraryDescription)).setText(mDescriptions[i].description); | ||
((TextView) cardView.findViewById(R.id.libraryLicense)).setText(mDescriptions[i].license); | ||
|
||
cardView.setTag(mDescriptions[i].link); | ||
cardView.setOnClickListener(this); | ||
libsLayout.addView(cardView); | ||
} | ||
|
||
return view; | ||
} | ||
|
||
private String getVersionString() { | ||
try { | ||
PackageInfo pi = getActivity() | ||
.getPackageManager() | ||
.getPackageInfo(getActivity().getPackageName(), 0); | ||
return "Version " + pi.versionName + " (" + Integer.toString(pi.versionCode) + ")"; | ||
} | ||
catch (PackageManager.NameNotFoundException e) { | ||
return ""; | ||
} | ||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
String link = (String) v.getTag(); | ||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(link)); | ||
startActivity(browserIntent); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.v7.widget.CardView | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="8dp" | ||
android:layout_marginTop="8dp" | ||
android:clickable="true" | ||
android:foreground="?selectableItemBackground" | ||
android:layoutDirection="ltr"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" | ||
android:padding="6dp"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center_vertical" | ||
android:orientation="horizontal" | ||
android:paddingLeft="8dp" | ||
android:paddingRight="8dp"> | ||
|
||
<TextView | ||
android:id="@+id/libraryName" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="5" | ||
android:ellipsize="end" | ||
android:gravity="start" | ||
android:maxLines="1" | ||
android:textSize="@dimen/textSizeLarge_openSource" | ||
android:textStyle="normal" | ||
tools:text="" /> | ||
|
||
<TextView | ||
android:id="@+id/libraryCreator" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="2dp" | ||
android:layout_weight="2" | ||
android:gravity="end" | ||
android:maxLines="2" | ||
android:textSize="@dimen/textSizeSmall_openSource" | ||
android:textColor="#666" | ||
android:textStyle="normal" | ||
tools:text="" /> | ||
</LinearLayout> | ||
|
||
<View | ||
android:id="@+id/libraryDescriptionDivider" | ||
android:layout_width="match_parent" | ||
android:layout_height="1px" | ||
android:layout_marginTop="4dp" | ||
android:background="#CCC"/> | ||
|
||
<TextView | ||
android:id="@+id/libraryDescription" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:maxLines="20" | ||
android:padding="8dp" | ||
android:textSize="@dimen/textSizeSmall_openSource" | ||
android:textColor="#666" | ||
android:textStyle="normal" | ||
tools:text=""> | ||
</TextView> | ||
|
||
<View | ||
android:id="@+id/libraryBottomDivider" | ||
android:layout_width="match_parent" | ||
android:layout_height="1px" | ||
android:layout_marginTop="4dp" | ||
android:background="#CCC"/> | ||
|
||
<LinearLayout | ||
android:id="@+id/libraryBottomContainer" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center_vertical" | ||
android:orientation="horizontal" | ||
android:paddingLeft="8dp" | ||
android:paddingRight="8dp" | ||
android:paddingTop="4dp"> | ||
|
||
<TextView | ||
android:id="@+id/libraryLicense" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:gravity="end" | ||
android:maxLines="1" | ||
android:textSize="@dimen/textSizeSmall_openSource" | ||
android:textColor="#666" | ||
android:textStyle="normal" | ||
tools:text="License" /> | ||
</LinearLayout> | ||
</LinearLayout> | ||
</android.support.v7.widget.CardView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
<ScrollView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
<LinearLayout | ||
android:orientation="vertical" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="16dp"> | ||
<LinearLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" | ||
android:paddingBottom="8dp" | ||
android:paddingTop="8dp"> | ||
|
||
<ImageView | ||
android:id="@+id/aboutIcon" | ||
android:layout_width="@dimen/aboutImage_openSource" | ||
android:layout_height="@dimen/aboutImage_openSource" | ||
android:layout_gravity="center" | ||
android:src="@drawable/ic_launcher"/> | ||
|
||
<TextView | ||
android:id="@+id/aboutName" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="6dp" | ||
android:gravity="center" | ||
android:textSize="@dimen/textSizeLarge_openSource" | ||
android:text="@string/app_name"/> | ||
|
||
<TextView | ||
android:id="@+id/aboutVersion" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="4dp" | ||
android:gravity="center" | ||
android:textSize="@dimen/textSizeSmall_openSource" | ||
android:textColor="#666" | ||
android:text=""/> | ||
|
||
<View | ||
android:id="@+id/aboutDivider" | ||
android:layout_width="match_parent" | ||
android:layout_height="1px" | ||
android:layout_marginTop="4dp" | ||
android:background="#CCC"/> | ||
|
||
<TextView | ||
android:id="@+id/aboutDescription" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:clickable="true" | ||
android:gravity="center" | ||
android:padding="8dp" | ||
android:textSize="@dimen/textSizeSmall_openSource" | ||
android:textStyle="normal" | ||
android:textColor="#666" | ||
android:text="@string/app_description"/> | ||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:id="@+id/about_libraries" | ||
android:layout_width="match_parent" | ||
android:layout_height="fill_parent" | ||
android:orientation="vertical"> | ||
</LinearLayout> | ||
</LinearLayout> | ||
</ScrollView> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<dimen name="card_padding_openSource">12dp</dimen> | ||
|
||
<dimen name="aboutImage_openSource">72dp</dimen> | ||
|
||
<dimen name="textSizeLarge_openSource">20sp</dimen> | ||
<dimen name="textSizeSmall_openSource">14sp</dimen> | ||
|
||
|
||
<!-- Default screen margins, per the Android Design guidelines. --> | ||
<dimen name="activity_horizontal_margin">16dp</dimen> | ||
<dimen name="activity_vertical_margin">16dp</dimen> | ||
</resources> |