mirror of
https://github.com/zhanghai/MaterialFiles
synced 2024-07-08 19:45:51 +00:00
[Feautre] Add view on GitHub for about.
This commit is contained in:
parent
f585980c1e
commit
18497e1c0f
|
@ -5,6 +5,7 @@
|
|||
|
||||
package me.zhanghai.android.materialfilemanager.about;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
@ -20,11 +21,18 @@ import butterknife.BindView;
|
|||
import butterknife.ButterKnife;
|
||||
import me.zhanghai.android.materialfilemanager.R;
|
||||
import me.zhanghai.android.materialfilemanager.ui.LicensesDialogFragment;
|
||||
import me.zhanghai.android.materialfilemanager.util.AppUtils;
|
||||
import me.zhanghai.android.materialfilemanager.util.IntentUtils;
|
||||
|
||||
public class AboutFragment extends Fragment {
|
||||
|
||||
private static final Uri GITHUB_URI = Uri.parse(
|
||||
"https://github.com/DreaminginCodeZH/MaterialFileManager");
|
||||
|
||||
@BindView(R.id.toolbar)
|
||||
Toolbar mToolbar;
|
||||
@BindView(R.id.github)
|
||||
ViewGroup mGitHubLayout;
|
||||
@BindView(R.id.licenses)
|
||||
ViewGroup mLicensesLayout;
|
||||
|
||||
|
@ -67,6 +75,8 @@ public class AboutFragment extends Fragment {
|
|||
AppCompatActivity activity = (AppCompatActivity) requireActivity();
|
||||
activity.setSupportActionBar(mToolbar);
|
||||
|
||||
mGitHubLayout.setOnClickListener(view -> AppUtils.startActivity(IntentUtils.makeView(
|
||||
GITHUB_URI), this));
|
||||
mLicensesLayout.setOnClickListener(view -> LicensesDialogFragment.show(this));
|
||||
}
|
||||
|
||||
|
|
|
@ -746,7 +746,7 @@ public class FileListFragment extends Fragment implements BreadcrumbLayout.Liste
|
|||
Uri fileUri = FileProvider.getUriForPath(localFile.getPath());
|
||||
Intent intent = IntentUtils.makeView(fileUri, mimeType)
|
||||
.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
AppUtils.startActivity(intent, requireContext());
|
||||
AppUtils.startActivity(intent, this);
|
||||
} else {
|
||||
// TODO
|
||||
}
|
||||
|
@ -798,7 +798,7 @@ public class FileListFragment extends Fragment implements BreadcrumbLayout.Liste
|
|||
LocalFile localFile = (LocalFile) file;
|
||||
Uri fileUri = FileProvider.getUriForPath(localFile.getPath());
|
||||
Intent intent = IntentUtils.makeSendStream(fileUri, mimeType);
|
||||
AppUtils.startActivityWithChooser(intent, requireContext());
|
||||
AppUtils.startActivityWithChooser(intent, this);
|
||||
} else {
|
||||
// TODO
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import android.os.Looper;
|
|||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.support.v4.app.TaskStackBuilder;
|
||||
|
||||
|
@ -200,6 +201,17 @@ public class AppUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean startActivity(@NonNull Intent intent, @NonNull Fragment fragment) {
|
||||
try {
|
||||
fragment.startActivity(intent);
|
||||
return true;
|
||||
} catch (ActivityNotFoundException | IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
ToastUtils.show(R.string.activity_not_found, fragment.requireContext());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean startActivityForResult(@NonNull Intent intent, int requestCode,
|
||||
@NonNull Activity activity) {
|
||||
try {
|
||||
|
@ -212,12 +224,28 @@ public class AppUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean startActivityForResult(@NonNull Intent intent, int requestCode,
|
||||
@NonNull Fragment fragment) {
|
||||
try {
|
||||
fragment.startActivityForResult(intent, requestCode);
|
||||
return true;
|
||||
} catch (ActivityNotFoundException | IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
ToastUtils.show(R.string.activity_not_found, fragment.requireContext());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void startActivityWithChooser(@NonNull Intent intent, @NonNull Context context) {
|
||||
context.startActivity(IntentUtils.withChooser(intent));
|
||||
}
|
||||
|
||||
public static void startActivityWithChooser(@NonNull Intent intent, @NonNull Fragment fragment) {
|
||||
fragment.startActivity(IntentUtils.withChooser(intent));
|
||||
}
|
||||
|
||||
public static void startActivityForResultWithChooser(@NonNull Intent intent, int requestCode,
|
||||
@NonNull Activity activity) {
|
||||
activity.startActivityForResult(IntentUtils.withChooser(intent), requestCode);
|
||||
@NonNull Fragment fragment) {
|
||||
fragment.startActivityForResult(IntentUtils.withChooser(intent), requestCode);
|
||||
}
|
||||
}
|
||||
|
|
18
app/src/main/res/drawable/github_icon_white_24dp.xml
Normal file
18
app/src/main/res/drawable/github_icon_white_24dp.xml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2018 Zhang Hai <Dreaming.in.Code.ZH@Gmail.com>
|
||||
~ All Rights Reserved.
|
||||
-->
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z" />
|
||||
</vector>
|
|
@ -49,6 +49,34 @@
|
|||
android:paddingTop="@dimen/list_padding_vertical"
|
||||
android:paddingBottom="@dimen/list_padding_vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/github"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?listPreferredItemHeightSmall"
|
||||
android:paddingStart="?android:listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:listPreferredItemPaddingEnd"
|
||||
android:background="?selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/icon_size"
|
||||
android:layout_height="@dimen/icon_size"
|
||||
android:duplicateParentState="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/github_icon_white_24dp"
|
||||
android:tint="?android:textColorSecondary" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/content_start_from_screen_edge_margin_minus_24dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/about_github_title"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/licenses"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -64,7 +92,7 @@
|
|||
android:layout_height="@dimen/icon_size"
|
||||
android:duplicateParentState="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/text_file_icon_24dp"
|
||||
android:src="@drawable/text_file_icon_white_24dp"
|
||||
android:tint="?android:textColorSecondary" />
|
||||
|
||||
<TextView
|
||||
|
@ -74,7 +102,7 @@
|
|||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/about_licenses_title"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2" />
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
|
|
|
@ -162,6 +162,7 @@
|
|||
</string-array>
|
||||
|
||||
<string name="about_title">About</string>
|
||||
<string name="about_github_title">View on GitHub</string>
|
||||
<string name="about_licenses_title">Licenses</string>
|
||||
<string name="about_licenses_html_style_light" translatable="false">
|
||||
body {
|
||||
|
|
Loading…
Reference in New Issue
Block a user