mirror of
https://github.com/whyorean/AuroraStore.git
synced 2026-06-20 21:50:19 -04:00
Rewrite About Activity
This commit is contained in:
@@ -23,20 +23,20 @@ package com.dragons.aurora.activities;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import com.dragons.aurora.R;
|
||||
import com.dragons.aurora.fragment.AboutFragment;
|
||||
import com.dragons.aurora.view.AdaptiveToolbar;
|
||||
|
||||
public class AboutActivity extends AuroraActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.helper_activity);
|
||||
AdaptiveToolbar dadtb = findViewById(R.id.d_adtb);
|
||||
dadtb.getAction_icon().setOnClickListener((v -> this.onBackPressed()));
|
||||
|
||||
setContentView(R.layout.helper_activity_alt);
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||
getWindow().setStatusBarColor(getResources().getColor(R.color.semi_transparent));
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.content_frame, new AboutFragment())
|
||||
|
||||
@@ -21,26 +21,28 @@
|
||||
|
||||
package com.dragons.aurora.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.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.dragons.aurora.CircleTransform;
|
||||
import com.dragons.aurora.R;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.dragons.aurora.view.LinkCard;
|
||||
|
||||
public class AboutFragment extends UtilFragment {
|
||||
|
||||
private View v;
|
||||
private final int linkIcons[] = {
|
||||
R.drawable.ic_gitlab,
|
||||
R.drawable.ic_xda,
|
||||
R.drawable.ic_telegram
|
||||
};
|
||||
private View view;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -50,65 +52,41 @@ public class AboutFragment extends UtilFragment {
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
if (v != null) {
|
||||
if ((ViewGroup) v.getParent() != null)
|
||||
((ViewGroup) v.getParent()).removeView(v);
|
||||
return v;
|
||||
if (view != null) {
|
||||
if ((ViewGroup) view.getParent() != null)
|
||||
((ViewGroup) view.getParent()).removeView(view);
|
||||
return view;
|
||||
}
|
||||
v = inflater.inflate(R.layout.app_abt_inc, container, false);
|
||||
view = inflater.inflate(R.layout.app_abt_inc, container, false);
|
||||
|
||||
getActivity().setTitle(R.string.action_about);
|
||||
((TextView) view.findViewById(R.id.aurora_title)).setText(R.string.action_about);
|
||||
((ImageView) view.findViewById(R.id.toolbar_back)).setOnClickListener(click -> getActivity().onBackPressed());
|
||||
|
||||
drawVersion();
|
||||
drawActions();
|
||||
drawDevCard(R.string.dev1_imgURL, (ImageView) v.findViewById(R.id.dev1_avatar));
|
||||
drawDevCard(R.string.dev2_imgURL, (ImageView) v.findViewById(R.id.dev2_avatar));
|
||||
drawList(getResources().getStringArray(R.array.contributors), ((TextView) v.findViewById(R.id.contributors)));
|
||||
drawList(getResources().getStringArray(R.array.opensource), ((TextView) v.findViewById(R.id.opensource)));
|
||||
|
||||
return v;
|
||||
drawLinks();
|
||||
return view;
|
||||
}
|
||||
|
||||
private void drawVersion() {
|
||||
try {
|
||||
PackageInfo packageInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
|
||||
((TextView) v.findViewById(R.id.app_version)).setText(packageInfo.versionName + "." + packageInfo.versionCode);
|
||||
((TextView) view.findViewById(R.id.app_version)).setText(packageInfo.versionName + "." + packageInfo.versionCode);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void drawActions() {
|
||||
final Intent browserIntent = new Intent(Intent.ACTION_VIEW);
|
||||
((TextView) v.findViewById(R.id.github)).setOnClickListener(v -> {
|
||||
browserIntent.setData(Uri.parse(getResources().getString(R.string.linkGit)));
|
||||
startActivity(browserIntent);
|
||||
});
|
||||
((TextView) v.findViewById(R.id.xda)).setOnClickListener(v -> {
|
||||
browserIntent.setData(Uri.parse(getResources().getString(R.string.linkXDA)));
|
||||
startActivity(browserIntent);
|
||||
});
|
||||
((TextView) v.findViewById(R.id.telegram)).setOnClickListener(v -> {
|
||||
browserIntent.setData(Uri.parse(getResources().getString(R.string.linkTelegram)));
|
||||
startActivity(browserIntent);
|
||||
});
|
||||
}
|
||||
|
||||
private void drawDevCard(int URL, ImageView imageView) {
|
||||
Picasso.with(this.getActivity())
|
||||
.load(getResources().getString(URL))
|
||||
.placeholder(ContextCompat.getDrawable(getContext(),R.drawable.ic_user_placeholder))
|
||||
.transform(new CircleTransform())
|
||||
.into(imageView);
|
||||
}
|
||||
|
||||
private void drawList(String[] List, TextView tv) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (String s : List) {
|
||||
builder.append("◉ ");
|
||||
builder.append(s);
|
||||
builder.append("\n");
|
||||
}
|
||||
(tv).setText(builder.toString().trim());
|
||||
public void drawLinks() {
|
||||
LinearLayout linkContainer = view.findViewById(R.id.linkContainer);
|
||||
String[] linkURLS = getResources().getStringArray(R.array.linkURLS);
|
||||
String[] linkTitles = getResources().getStringArray(R.array.linkTitles);
|
||||
String[] linkSummary = getResources().getStringArray(R.array.linkSummary);
|
||||
int index = 0;
|
||||
for (String URL : linkURLS)
|
||||
linkContainer.addView(new LinkCard(getContext(),
|
||||
URL,
|
||||
linkTitles[index],
|
||||
linkSummary[index],
|
||||
linkIcons[index++]));
|
||||
}
|
||||
}
|
||||
79
app/src/main/java/com/dragons/aurora/view/LinkCard.java
Normal file
79
app/src/main/java/com/dragons/aurora/view/LinkCard.java
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Aurora Store
|
||||
* Copyright (C) 2018 Rahul Kumar Patel <whyorean@gmail.com>
|
||||
*
|
||||
* Yalp Store
|
||||
* Copyright (C) 2018 Sergey Yeriomin <yeriomin@gmail.com>
|
||||
*
|
||||
* Aurora Store (a fork of Yalp Store )is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Aurora Store is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.dragons.aurora.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.dragons.aurora.R;
|
||||
|
||||
public class LinkCard extends RelativeLayout {
|
||||
|
||||
Context context;
|
||||
CardView link_card;
|
||||
ImageView card_icon;
|
||||
TextView card_title;
|
||||
TextView card_summary;
|
||||
private String title;
|
||||
private String summary;
|
||||
private String linkURL;
|
||||
private int cardIconID;
|
||||
|
||||
public LinkCard(Context context, String linkURL, String title, String summary, int cardIconID) {
|
||||
super(context);
|
||||
this.context = context;
|
||||
this.linkURL = linkURL;
|
||||
this.title = title;
|
||||
this.summary = summary;
|
||||
this.cardIconID = cardIconID;
|
||||
init(context);
|
||||
}
|
||||
|
||||
public LinkCard(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context);
|
||||
}
|
||||
|
||||
private void init(Context context) {
|
||||
View view = inflate(context, R.layout.link_card, this);
|
||||
link_card = view.findViewById(R.id.link_card);
|
||||
card_icon = view.findViewById(R.id.card_icon);
|
||||
card_title = view.findViewById(R.id.card_title);
|
||||
card_summary = view.findViewById(R.id.card_summary);
|
||||
card_title.setText(title);
|
||||
card_summary.setText(summary);
|
||||
card_icon.setImageResource(cardIconID);
|
||||
|
||||
link_card.setOnClickListener(click -> {
|
||||
final Intent browserIntent = new Intent(Intent.ACTION_VIEW);
|
||||
browserIntent.setData(Uri.parse(linkURL));
|
||||
context.startActivity(browserIntent);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user