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" applicationId "gr.thmmy.mthmmy"
minSdkVersion 19 minSdkVersion 19
targetSdkVersion 28 targetSdkVersion 28
versionCode 20 versionCode 21
versionName "1.7.2" versionName "1.7.3"
archivesBaseName = "mTHMMY-v$versionName" archivesBaseName = "mTHMMY-v$versionName"
buildConfigField "String", "CURRENT_BRANCH", "\"" + getCurrentBranch() + "\"" buildConfigField "String", "CURRENT_BRANCH", "\"" + getCurrentBranch() + "\""
buildConfigField "String", "COMMIT_HASH", "\"" + getCommitHash() + "\"" 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.view.View;
import android.webkit.WebView; import android.webkit.WebView;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.coordinatorlayout.widget.CoordinatorLayout; 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.BuildConfig;
import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.base.BaseActivity; import gr.thmmy.mthmmy.base.BaseActivity;
import gr.thmmy.mthmmy.base.BaseApplication;
public class AboutActivity extends BaseActivity { public class AboutActivity extends BaseActivity {
private static final int TIME_INTERVAL = 1000; private static final int TIME_INTERVAL = 1000;
@ -32,8 +35,9 @@ public class AboutActivity extends BaseActivity {
private AppBarLayout appBar; private AppBarLayout appBar;
private CoordinatorLayout coordinatorLayout; private CoordinatorLayout coordinatorLayout;
private ScrollView mainContent;
private AlertDialog alertDialog; private AlertDialog alertDialog;
private FrameLayout trollGif; private FrameLayout easterEggImage;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -70,41 +74,41 @@ public class AboutActivity extends BaseActivity {
createDrawer(); createDrawer();
drawer.setSelection(ABOUT_ID); drawer.setSelection(ABOUT_ID);
final ScrollView mainContent = findViewById(R.id.scrollview); mainContent = findViewById(R.id.scrollview);
trollGif = findViewById(R.id.trollPicFrame); 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); TextView versionTextView = findViewById(R.id.version);
if (tv != null) { if (versionTextView != null) {
if (BuildConfig.DEBUG) if (BuildConfig.DEBUG)
tv.setText(getString(R.string.version, versionName + versionInfo)); versionTextView.setText(getString(R.string.version, versionName + versionInfo));
else else
tv.setText(getString(R.string.version, versionName)); versionTextView.setText(getString(R.string.version, versionName));
if(BuildConfig.DEBUG && gitExists){ if(gitExists){
tv.setOnClickListener(view -> { versionTextView.setOnClickListener(view -> {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/ThmmyNoLife/mTHMMY/commit/" + BuildConfig.COMMIT_HASH)); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/ThmmyNoLife/mTHMMY/commit/" + BuildConfig.COMMIT_HASH));
startActivity(intent); startActivity(intent);
}); });
} }
else{ // Easter Egg
tv.setOnClickListener(view -> { versionTextView.setOnLongClickListener(view -> {
if (mVersionLastPressedTime + TIME_INTERVAL > System.currentTimeMillis()) { Toast.makeText(getApplicationContext(), BaseApplication.getFirebaseProjectId(), Toast.LENGTH_SHORT).show();
if (mVersionPressedCounter == TIMES_TO_PRESS) { return true;
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;
}
});
}
} }
TextView privacyPolicy = findViewById(R.id.privacy_policy_header); TextView privacyPolicy = findViewById(R.id.privacy_policy_header);
@ -122,6 +126,14 @@ public class AboutActivity extends BaseActivity {
super.onResume(); super.onResume();
} }
@Override
public void onBackPressed() {
if(easterEggImage.getVisibility()==View.INVISIBLE)
super.onBackPressed();
else
hideEasterEgg();
}
public void displayApacheLibraries(View v) { public void displayApacheLibraries(View v) {
LayoutInflater inflater = LayoutInflater.from(this); LayoutInflater inflater = LayoutInflater.from(this);
WebView webView = (WebView) inflater.inflate(R.layout.dialog_licenses, coordinatorLayout, false); 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); 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.PersistentCookieJar;
import com.franmontiel.persistentcookiejar.cache.SetCookieCache; import com.franmontiel.persistentcookiejar.cache.SetCookieCache;
import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor; import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor;
import com.google.firebase.FirebaseApp;
import com.google.firebase.analytics.FirebaseAnalytics; import com.google.firebase.analytics.FirebaseAnalytics;
import com.itkacher.okhttpprofiler.OkHttpProfilerInterceptor; import com.itkacher.okhttpprofiler.OkHttpProfilerInterceptor;
import com.jakewharton.picasso.OkHttp3Downloader; import com.jakewharton.picasso.OkHttp3Downloader;
@ -51,7 +52,8 @@ import timber.log.Timber;
public class BaseApplication extends Application { public class BaseApplication extends Application {
private static BaseApplication baseApplication; //BaseApplication singleton private static BaseApplication baseApplication; //BaseApplication singleton
//Firebase Analytics //Firebase
private static String firebaseProjectId;
private FirebaseAnalytics firebaseAnalytics; private FirebaseAnalytics firebaseAnalytics;
//Client & SessionManager //Client & SessionManager
@ -63,7 +65,6 @@ public class BaseApplication extends Application {
//Display Metrics //Display Metrics
private static float dpWidth; private static float dpWidth;
public static BaseApplication getInstance() { public static BaseApplication getInstance() {
return baseApplication; return baseApplication;
} }
@ -87,6 +88,7 @@ public class BaseApplication extends Application {
else else
Timber.i("Starting app with Crashlytics disabled."); Timber.i("Starting app with Crashlytics disabled.");
firebaseProjectId = FirebaseApp.getInstance().getOptions().getProjectId();
firebaseAnalytics = FirebaseAnalytics.getInstance(this); firebaseAnalytics = FirebaseAnalytics.getInstance(this);
boolean enableAnalytics = settingsSharedPrefs.getBoolean(getString(R.string.pref_privacy_analytics_enable_key), false); boolean enableAnalytics = settingsSharedPrefs.getBoolean(getString(R.string.pref_privacy_analytics_enable_key), false);
firebaseAnalytics.setAnalyticsCollectionEnabled(enableAnalytics); firebaseAnalytics.setAnalyticsCollectionEnabled(enableAnalytics);
@ -216,4 +218,8 @@ public class BaseApplication extends Application {
} else } else
Timber.i("Crashlytics were already initialized for this app session."); Timber.i("Crashlytics were already initialized for this app session.");
} }
public static String getFirebaseProjectId(){
return firebaseProjectId;
}
} }

Loading…
Cancel
Save