code refactor

This commit is contained in:
h4h13 2018-08-05 22:01:33 +05:30
parent a15d00a80a
commit b4add644b5

View file

@ -1,28 +1,5 @@
package code.name.monkey.retromusic.ui.activities; package code.name.monkey.retromusic.ui.activities;
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.design.widget.AppBarLayout;
import android.support.v4.app.ShareCompat;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.retromusic.Constants;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.RetroApplication;
import code.name.monkey.retromusic.ui.activities.base.AbsBaseActivity;
import code.name.monkey.retromusic.util.NavigationUtil;
import static code.name.monkey.retromusic.Constants.APP_INSTAGRAM_LINK; import static code.name.monkey.retromusic.Constants.APP_INSTAGRAM_LINK;
import static code.name.monkey.retromusic.Constants.APP_TWITTER_LINK; import static code.name.monkey.retromusic.Constants.APP_TWITTER_LINK;
import static code.name.monkey.retromusic.Constants.GITHUB_PROJECT; import static code.name.monkey.retromusic.Constants.GITHUB_PROJECT;
@ -31,18 +8,36 @@ import static code.name.monkey.retromusic.Constants.RATE_ON_GOOGLE_PLAY;
import static code.name.monkey.retromusic.Constants.TELEGRAM_CHANGE_LOG; import static code.name.monkey.retromusic.Constants.TELEGRAM_CHANGE_LOG;
import static code.name.monkey.retromusic.Constants.TRANSLATE; import static code.name.monkey.retromusic.Constants.TRANSLATE;
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.app.ShareCompat;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.retromusic.Constants;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.ui.activities.base.AbsBaseActivity;
import code.name.monkey.retromusic.util.NavigationUtil;
/** /**
* @author Hemanth S (h4h13) * @author Hemanth S (h4h13)
*/ */
public class AboutActivity extends AbsBaseActivity { public class AboutActivity extends AbsBaseActivity {
@BindView(R.id.toolbar) @BindView(R.id.toolbar)
Toolbar toolbar; Toolbar toolbar;
@BindView(R.id.app_bar) @BindView(R.id.app_bar)
AppBarLayout appBar; View background;
@BindView(R.id.buy_pro)
TextView supportText;
@BindView(R.id.app_version) @BindView(R.id.app_version)
TextView appVersion; TextView appVersion;
@ -72,15 +67,13 @@ public class AboutActivity extends AbsBaseActivity {
} }
private void setUpToolbar() { private void setUpToolbar() {
int primaryColor = ThemeStore.primaryColor(this); int primaryColor = ThemeStore.primaryColor(this);
toolbar.setBackgroundColor(primaryColor); toolbar.setBackgroundColor(primaryColor);
appBar.setBackgroundColor(primaryColor); setTitle(null);
setTitle(R.string.action_about);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
//noinspection ConstantConditions //noinspection ConstantConditions
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
supportText.setText(RetroApplication.isProVersion() ? R.string.thank_you : R.string.buy_retromusic_pro);
} }
@ -92,10 +85,8 @@ public class AboutActivity extends AbsBaseActivity {
} }
@OnClick({R.id.app_github, R.id.faq_link, @OnClick({R.id.app_github, R.id.faq_link, R.id.app_google_plus, R.id.app_translation,
R.id.app_google_plus, R.id.app_translation, R.id.app_rate, R.id.app_share, R.id.instagram_link, R.id.twitter_link, R.id.changelog,
R.id.support_container, R.id.app_rate, R.id.app_share, R.id.pro_container,
R.id.instagram_link, R.id.twitter_link, R.id.changelog,
R.id.open_source, R.id.discord_link, R.id.telegram_link}) R.id.open_source, R.id.discord_link, R.id.telegram_link})
public void onViewClicked(View view) { public void onViewClicked(View view) {
switch (view.getId()) { switch (view.getId()) {
@ -114,9 +105,6 @@ public class AboutActivity extends AbsBaseActivity {
case R.id.app_google_plus: case R.id.app_google_plus:
openUrl(GOOGLE_PLUS_COMMUNITY); openUrl(GOOGLE_PLUS_COMMUNITY);
break; break;
case R.id.support_container:
startActivity(new Intent(this, SupportDevelopmentActivity.class));
break;
case R.id.app_translation: case R.id.app_translation:
openUrl(TRANSLATE); openUrl(TRANSLATE);
break; break;
@ -126,10 +114,9 @@ public class AboutActivity extends AbsBaseActivity {
case R.id.app_share: case R.id.app_share:
shareApp(); shareApp();
break; break;
case R.id.pro_container: case R.id.donate_link:
NavigationUtil.goToProVersion(this); NavigationUtil.goToSupportDevelopment(this);
break; break;
case R.id.instagram_link: case R.id.instagram_link:
openUrl(APP_INSTAGRAM_LINK); openUrl(APP_INSTAGRAM_LINK);
break; break;
@ -161,7 +148,8 @@ public class AboutActivity extends AbsBaseActivity {
.setText(String.format(getString(R.string.app_share), getPackageName())) .setText(String.format(getString(R.string.app_share), getPackageName()))
.getIntent(); .getIntent();
if (shareIntent.resolveActivity(getPackageManager()) != null) { if (shareIntent.resolveActivity(getPackageManager()) != null) {
startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.action_share))); startActivity(
Intent.createChooser(shareIntent, getResources().getText(R.string.action_share)));
} }
} }
} }