-
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
1 parent
5bdb6a2
commit af63790
Showing
12 changed files
with
176 additions
and
35 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
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package moon3.app; | ||
import android.content.Context; | ||
import android.content.pm.ApplicationInfo; | ||
import android.content.pm.PackageInfo; | ||
import android.content.pm.PackageManager; | ||
import android.graphics.Bitmap; | ||
import android.graphics.drawable.Drawable; | ||
import android.graphics.drawable.Icon; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
// 感谢: | ||
// https://github.com/RikkaApps/Shizuku/blob/master/manager/src/main/java/moe/shizuku/manager/home/HomeActivity.kt | ||
// https://github.com/RikkaApps/Shizuku/blob/master/manager/src/main/res/layout/about_dialog.xml | ||
public class AboutDialog extends MaterialDialog { | ||
|
||
public AboutDialog(Context context) { | ||
this(context, 0); | ||
} | ||
|
||
public AboutDialog(Context context, int overrideThemeResId) { | ||
super(context, overrideThemeResId); | ||
|
||
setView(getLayoutInflater().inflate(moon3.R.layout.about_dialog_layout, null)); | ||
} | ||
|
||
public AboutDialog setAppName(CharSequence appName) { | ||
TextView v = getView().findViewById(moon3.R.id.app_name); | ||
v.setText(appName); | ||
return this; | ||
} | ||
|
||
public AboutDialog setAppIcon(Drawable icon) { | ||
ImageView v = getView().findViewById(android.R.id.icon); | ||
v.setImageDrawable(icon); | ||
return this; | ||
} | ||
|
||
// Api:23 | ||
public AboutDialog setAppIcon(Icon icon) { | ||
ImageView v = getView().findViewById(android.R.id.icon); | ||
v.setImageIcon(icon); | ||
return this; | ||
} | ||
|
||
public AboutDialog setAppIcon(Bitmap icon) { | ||
ImageView v = getView().findViewById(android.R.id.icon); | ||
v.setImageBitmap(icon); | ||
return this; | ||
} | ||
|
||
public AboutDialog setVersionName(CharSequence versionName) { | ||
TextView v = getView().findViewById(moon3.R.id.version_name); | ||
v.setText(versionName); | ||
return this; | ||
} | ||
|
||
public AboutDialog setMoreInfo(CharSequence moreInfo) { | ||
TextView v = getMoreInfoView(); | ||
v.setText(moreInfo); | ||
return this; | ||
} | ||
|
||
public TextView getMoreInfoView() { | ||
return getView().findViewById(moon3.R.id.more_info); | ||
} | ||
|
||
public AboutDialog updateInfo(Context c) { | ||
return updateInfo(c, false); | ||
} | ||
|
||
public AboutDialog updateInfo(Context c, boolean includeVersionCode) { | ||
try { | ||
PackageManager pm = c.getPackageManager(); | ||
PackageInfo info = pm.getPackageInfo(c.getPackageName(), 0); | ||
|
||
setAppIcon(info.applicationInfo.loadIcon(pm)); | ||
setAppName(info.applicationInfo.loadLabel(pm)); | ||
setVersionName(info.versionName + (includeVersionCode ? " (" + info.versionCode + ")" : "")); | ||
} catch(Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return this; | ||
} | ||
|
||
} |
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,44 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="horizontal" | ||
android:padding="?android:dialogPreferredPadding"> | ||
|
||
<ImageView | ||
android:id="@android:id/icon" | ||
android:layout_width="40dp" | ||
android:layout_height="40dp" | ||
android:importantForAccessibility="no" /> | ||
|
||
<LinearLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="24dp" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/app_name" | ||
android:textAppearance="@android:style/TextAppearance.Material.Body1" | ||
android:textSize="18sp" /> | ||
|
||
<TextView | ||
android:id="@+id/version_name" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textSize="14sp" /> | ||
|
||
<TextView | ||
android:id="@+id/more_info" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="8dp" | ||
android:textColor="?android:textColorSecondary" | ||
android:textSize="14sp" /> | ||
|
||
</LinearLayout> | ||
|
||
</LinearLayout> |