Browse Source

AboutActivity improvements, up version

pull/63/head
Ezerous 6 years ago
parent
commit
ef7d88d84b
No known key found for this signature in database GPG Key ID: 262B2954BBA319E3
  1. 4
      app/build.gradle
  2. 85
      app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java
  3. 10
      app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java

4
app/build.gradle

@ -13,8 +13,8 @@ android {
applicationId "gr.thmmy.mthmmy"
minSdkVersion 19
targetSdkVersion 28
versionCode 20
versionName "1.7.2"
versionCode 21
versionName "1.7.3"
archivesBaseName = "mTHMMY-v$versionName"
buildConfigField "String", "CURRENT_BRANCH", "\"" + getCurrentBranch() + "\""
buildConfigField "String", "COMMIT_HASH", "\"" + getCommitHash() + "\""

85
app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java

@ -11,8 +11,10 @@ import android.view.LayoutInflater;
import android.view.View;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
@ -23,6 +25,7 @@ import com.google.android.material.appbar.AppBarLayout;
import gr.thmmy.mthmmy.BuildConfig;
import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.base.BaseActivity;
import gr.thmmy.mthmmy.base.BaseApplication;
public class AboutActivity extends BaseActivity {
private static final int TIME_INTERVAL = 1000;
@ -32,8 +35,9 @@ public class AboutActivity extends BaseActivity {
private AppBarLayout appBar;
private CoordinatorLayout coordinatorLayout;
private ScrollView mainContent;
private AlertDialog alertDialog;
private FrameLayout trollGif;
private FrameLayout easterEggImage;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -70,41 +74,41 @@ public class AboutActivity extends BaseActivity {
createDrawer();
drawer.setSelection(ABOUT_ID);
final ScrollView mainContent = findViewById(R.id.scrollview);
trollGif = findViewById(R.id.trollPicFrame);
mainContent = findViewById(R.id.scrollview);
easterEggImage = findViewById(R.id.trollPicFrame);
// Set Easter egg on logo image
ImageView logoImageView = findViewById(R.id.logoView);
logoImageView.setOnClickListener(view -> {
if (mVersionLastPressedTime + TIME_INTERVAL > System.currentTimeMillis()) {
if (mVersionPressedCounter == TIMES_TO_PRESS)
showEasterEgg();
mVersionLastPressedTime = System.currentTimeMillis();
++mVersionPressedCounter;
} else {
mVersionLastPressedTime = System.currentTimeMillis();
mVersionPressedCounter = 0;
}
});
TextView tv = findViewById(R.id.version);
if (tv != null) {
TextView versionTextView = findViewById(R.id.version);
if (versionTextView != null) {
if (BuildConfig.DEBUG)
tv.setText(getString(R.string.version, versionName + versionInfo));
versionTextView.setText(getString(R.string.version, versionName + versionInfo));
else
tv.setText(getString(R.string.version, versionName));
versionTextView.setText(getString(R.string.version, versionName));
if(BuildConfig.DEBUG && gitExists){
tv.setOnClickListener(view -> {
if(gitExists){
versionTextView.setOnClickListener(view -> {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/ThmmyNoLife/mTHMMY/commit/" + BuildConfig.COMMIT_HASH));
startActivity(intent);
});
}
else{ // Easter Egg
tv.setOnClickListener(view -> {
if (mVersionLastPressedTime + TIME_INTERVAL > System.currentTimeMillis()) {
if (mVersionPressedCounter == TIMES_TO_PRESS) {
appBar.setVisibility(View.INVISIBLE);
mainContent.setVisibility(View.INVISIBLE);
trollGif.setVisibility(View.VISIBLE);
drawer.getDrawerLayout().setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
mVersionLastPressedTime = System.currentTimeMillis();
++mVersionPressedCounter;
} else {
mVersionLastPressedTime = System.currentTimeMillis();
mVersionPressedCounter = 0;
}
});
}
versionTextView.setOnLongClickListener(view -> {
Toast.makeText(getApplicationContext(), BaseApplication.getFirebaseProjectId(), Toast.LENGTH_SHORT).show();
return true;
});
}
TextView privacyPolicy = findViewById(R.id.privacy_policy_header);
@ -122,6 +126,14 @@ public class AboutActivity extends BaseActivity {
super.onResume();
}
@Override
public void onBackPressed() {
if(easterEggImage.getVisibility()==View.INVISIBLE)
super.onBackPressed();
else
hideEasterEgg();
}
public void displayApacheLibraries(View v) {
LayoutInflater inflater = LayoutInflater.from(this);
WebView webView = (WebView) inflater.inflate(R.layout.dialog_licenses, coordinatorLayout, false);
@ -152,4 +164,21 @@ public class AboutActivity extends BaseActivity {
alertDialog.getWindow().setLayout(width, height);
}
private void showEasterEgg(){
if(getResources().getConfiguration().orientation==ActivityInfo.SCREEN_ORIENTATION_PORTRAIT){
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
appBar.setVisibility(View.INVISIBLE);
mainContent.setVisibility(View.INVISIBLE);
easterEggImage.setVisibility(View.VISIBLE);
drawer.getDrawerLayout().setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
}
}
private void hideEasterEgg(){
appBar.setVisibility(View.VISIBLE);
mainContent.setVisibility(View.VISIBLE);
easterEggImage.setVisibility(View.INVISIBLE);
drawer.getDrawerLayout().setDrawerLockMode(DrawerLayout.LOCK_MODE_UNDEFINED);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
}

10
app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java

@ -18,6 +18,7 @@ import com.crashlytics.android.core.CrashlyticsCore;
import com.franmontiel.persistentcookiejar.PersistentCookieJar;
import com.franmontiel.persistentcookiejar.cache.SetCookieCache;
import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor;
import com.google.firebase.FirebaseApp;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.itkacher.okhttpprofiler.OkHttpProfilerInterceptor;
import com.jakewharton.picasso.OkHttp3Downloader;
@ -51,7 +52,8 @@ import timber.log.Timber;
public class BaseApplication extends Application {
private static BaseApplication baseApplication; //BaseApplication singleton
//Firebase Analytics
//Firebase
private static String firebaseProjectId;
private FirebaseAnalytics firebaseAnalytics;
//Client & SessionManager
@ -63,7 +65,6 @@ public class BaseApplication extends Application {
//Display Metrics
private static float dpWidth;
public static BaseApplication getInstance() {
return baseApplication;
}
@ -87,6 +88,7 @@ public class BaseApplication extends Application {
else
Timber.i("Starting app with Crashlytics disabled.");
firebaseProjectId = FirebaseApp.getInstance().getOptions().getProjectId();
firebaseAnalytics = FirebaseAnalytics.getInstance(this);
boolean enableAnalytics = settingsSharedPrefs.getBoolean(getString(R.string.pref_privacy_analytics_enable_key), false);
firebaseAnalytics.setAnalyticsCollectionEnabled(enableAnalytics);
@ -216,4 +218,8 @@ public class BaseApplication extends Application {
} else
Timber.i("Crashlytics were already initialized for this app session.");
}
public static String getFirebaseProjectId(){
return firebaseProjectId;
}
}

Loading…
Cancel
Save