Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Commit

Permalink
releasing 4.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kosh committed Jul 20, 2017
1 parent 7c050dd commit 63132a6
Show file tree
Hide file tree
Showing 33 changed files with 188 additions and 123 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ android {
applicationId "com.fastaccess.github"
minSdkVersion 21
targetSdkVersion 26
versionCode 402
versionName "4.0.2"
versionCode 403
versionName "4.0.3"
buildConfigString "GITHUB_CLIENT_ID", (buildProperties.secrets['github_client_id'] | buildProperties.notThere['github_client_id']).string
buildConfigString "GITHUB_SECRET", (buildProperties.secrets['github_secret'] | buildProperties.notThere['github_secret']).string
buildConfigString "IMGUR_CLIENT_ID", (buildProperties.secrets['imgur_client_id'] | buildProperties.notThere['imgur_client_id']).string
Expand Down
48 changes: 48 additions & 0 deletions app/src/main/java/com/fastaccess/data/dao/AppLanguageModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.fastaccess.data.dao;

import android.os.Parcel;
import android.os.Parcelable;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

/**
* Created by kosh on 20/07/2017.
*/

@Getter @Setter @AllArgsConstructor public class AppLanguageModel implements Parcelable {
private String value;
private String label;

@Override public int describeContents() { return 0; }

@Override public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.value);
dest.writeString(this.label);
}

protected AppLanguageModel(Parcel in) {
this.value = in.readString();
this.label = in.readString();
}

@Override public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

AppLanguageModel that = (AppLanguageModel) o;

return label != null ? label.equals(that.label) : that.label == null;
}

@Override public int hashCode() {
return label != null ? label.hashCode() : 0;
}

public static final Parcelable.Creator<AppLanguageModel> CREATOR = new Parcelable.Creator<AppLanguageModel>() {
@Override public AppLanguageModel createFromParcel(Parcel source) {return new AppLanguageModel(source);}

@Override public AppLanguageModel[] newArray(int size) {return new AppLanguageModel[size];}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
private long id;
private String url;
private int total_count;
@SerializedName("+1") private int plusOne; // FIXME check this code
@SerializedName("+1") private int plusOne;
@SerializedName("-1") private int minusOne;
private int laugh;
private int hooray;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public static Disposable save(@android.support.annotation.Nullable List<Notifica
BlockingEntityStore<Persistable> dataStore = App.getInstance().getDataStore().toBlocking();
for (Notification entity : models) {
dataStore.delete(Notification.class).where(Notification.ID.eq(entity.getId())).get().value();
dataStore.insert(entity);
}
dataStore.insert(models);
s.onNext(true);
} catch (Exception e) {
e.printStackTrace();
Expand Down
12 changes: 7 additions & 5 deletions app/src/main/java/com/fastaccess/helper/AppHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,17 @@ public static String getFastHubIssueTemplate(boolean enterprise) {
StringBuilder builder = new StringBuilder()
.append("**FastHub Version: ").append(BuildConfig.VERSION_NAME).append(enterprise ? " Enterprise**" : "**").append(" \n")
.append(!isInstalledFromPlaySore(App.getInstance()) ? "**APK Source: Unknown** \n" : "")
.append("**Android Version: ").append(String.valueOf(Build.VERSION.RELEASE)).append(" (SDK: ")
.append(String.valueOf(Build.VERSION.SDK_INT)).append(")**").append(" \n")
.append("**Android Version: ").append(String.valueOf(Build.VERSION.RELEASE))
.append(" (SDK: ")
.append(String.valueOf(Build.VERSION.SDK_INT)).append(")**").append(" \n")
.append("**Device Information:**").append(" \n")
.append("- " + (!model.equalsIgnoreCase(brand) ? "MANUFACTURER" : "MANUFACTURER&BRAND") + ": ").append(Build.MANUFACTURER).append(" \n");
.append("- " + (!model.equalsIgnoreCase(brand) ? "MANUFACTURER" : "MANUFACTURER&BRAND") + ": ")
.append(Build.MANUFACTURER).append("\n");
if (!model.equalsIgnoreCase(brand)) {
builder.append("- BRAND: ").append(brand).append(" \n");
}
builder.append("- MODEL: ").append(model).append(" \n")
.append("---").append("\n\n");
.append("---").append("\n\n");
return builder.toString();
}

Expand Down Expand Up @@ -136,7 +138,7 @@ public static String getDeviceName() {
return brand.equalsIgnoreCase(model) ? InputHelper.capitalizeFirstLetter(model) : InputHelper.capitalizeFirstLetter(brand) + " " + model;
}

private static boolean isEmulator() {
public static boolean isEmulator() {
return Build.FINGERPRINT.startsWith("generic")
|| Build.FINGERPRINT.startsWith("unknown")
|| Build.MODEL.contains("google_sdk")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object ThemeEngine {
}

private fun applyNavBarColor(activity: Activity) {
if (!PrefGetter.isNavBarTintingDisabled()) {
if (!PrefGetter.isNavBarTintingDisabled() && PrefGetter.getThemeType() != PrefGetter.LIGHT) {
activity.window.navigationBarColor = ViewHelper.getPrimaryColor(activity)
}
}
Expand Down
30 changes: 0 additions & 30 deletions app/src/main/java/com/fastaccess/provider/uil/UILProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,11 @@
import android.support.annotation.NonNull;

import com.fastaccess.BuildConfig;
import com.fastaccess.helper.Logger;
import com.fastaccess.helper.PrefGetter;
import com.nostra13.universalimageloader.cache.disc.impl.LimitedAgeDiskCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.download.BaseImageDownloader;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.HashMap;
import java.util.Map;

/**
* Created by Kosh on 26 Nov 2016, 10:48 AM
Expand All @@ -33,7 +25,6 @@ public static void initUIL(@NonNull Context context) {
ImageLoader imageLoader = ImageLoader.getInstance();
if (!imageLoader.isInited()) {
ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(context)
.imageDownloader(new GithubAuthDownloader(context))
.defaultDisplayImageOptions(getOptions())
.denyCacheImageMultipleSizesInMemory()
.diskCache(new LimitedAgeDiskCache(context.getCacheDir(), ONE_DAY));
Expand All @@ -45,14 +36,8 @@ public static void initUIL(@NonNull Context context) {
}

private static DisplayImageOptions getOptions() {
Map<String, String> headers = new HashMap<>();
if (PrefGetter.isEnterprise()) {
String authToken = PrefGetter.getEnterpriseToken();
headers.put("Authorization", authToken.startsWith("Basic") ? authToken : "token " + authToken);
}
return new DisplayImageOptions.Builder()
.delayBeforeLoading(0)
.extraForDownloader(headers)
.resetViewBeforeLoading(true)
.cacheOnDisk(true)
.cacheInMemory(true)
Expand All @@ -68,19 +53,4 @@ public static void destoryUIL(@NonNull Context context) {
}
}

private static class GithubAuthDownloader extends BaseImageDownloader {
GithubAuthDownloader(Context context) {super(context);}

@SuppressWarnings("unchecked") @Override protected HttpURLConnection createConnection(String url, Object extra) throws IOException {
HttpURLConnection conn = super.createConnection(url, extra);
Map<String, String> headers = (Map<String, String>) extra;
if (headers != null && !headers.isEmpty()) {
Logger.e(headers.keySet(), headers.values());
for (Map.Entry<String, String> header : headers.entrySet()) {
conn.setRequestProperty(header.getKey(), header.getValue());
}
}
return conn;
}
}
}
14 changes: 11 additions & 3 deletions app/src/main/java/com/fastaccess/ui/modules/main/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ public class MainActivity extends BaseActivity<MainMvp.View, MainPresenter> impl

@Override public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.search_menu, menu);
if (isLoggedIn() && Notification.hasUnreadNotifications()) {
ViewHelper.tintDrawable(menu.findItem(R.id.notifications).setIcon(R.drawable.ic_ring).getIcon(), ViewHelper.getAccentColor(this));
}
return super.onCreateOptionsMenu(menu);
}

Expand All @@ -108,6 +105,13 @@ public class MainActivity extends BaseActivity<MainMvp.View, MainPresenter> impl
return super.onOptionsItemSelected(item);
}

@Override public boolean onPrepareOptionsMenu(Menu menu) {
if (isLoggedIn() && Notification.hasUnreadNotifications()) {
ViewHelper.tintDrawable(menu.findItem(R.id.notifications).setIcon(R.drawable.ic_ring).getIcon(), ViewHelper.getAccentColor(this));
}
return super.onPrepareOptionsMenu(menu);
}

@Override public void onNavigationChanged(@MainMvp.NavigationType int navType) {
if (navType == MainMvp.PROFILE) {
getPresenter().onModuleChanged(getSupportFragmentManager(), navType);
Expand All @@ -129,6 +133,10 @@ public class MainActivity extends BaseActivity<MainMvp.View, MainPresenter> impl
UserPagerActivity.startActivity(this, Login.getUser().getLogin(), false, PrefGetter.isEnterprise(), -1);
}

@Override public void onInvalidateNotification() {
invalidateOptionsMenu();
}

@Shortcut(id = "myIssues", icon = R.drawable.ic_app_shortcut_issues, shortLabelRes = R.string.issues, rank = 2, action = "myIssues")
public void myIssues() {}//do nothing

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/fastaccess/ui/modules/main/MainMvp.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ interface View extends BaseMvp.FAView {
void onUpdateDrawerMenuHeader();

void onOpenProfile();

void onInvalidateNotification();
}

interface Presenter extends BaseMvp.FAPresenter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;

import com.annimon.stream.Stream;
import com.fastaccess.R;
import com.fastaccess.data.dao.model.Login;
import com.fastaccess.data.dao.model.Notification;
import com.fastaccess.helper.ParseDateFormat;
import com.fastaccess.helper.PrefGetter;
import com.fastaccess.helper.RxHelper;
import com.fastaccess.provider.rest.RestProvider;
Expand All @@ -17,6 +20,8 @@
import com.fastaccess.ui.modules.main.issues.pager.MyIssuesPagerFragment;
import com.fastaccess.ui.modules.main.pullrequests.pager.MyPullsPagerFragment;

import io.reactivex.Observable;

import static com.fastaccess.helper.ActivityHelper.getVisibleFragment;
import static com.fastaccess.helper.AppHelper.getFragmentByTag;

Expand All @@ -40,9 +45,18 @@ public class MainPresenter extends BasePresenter<MainMvp.View> implements MainMv
current.setCompany(current.getCompany());
return login.update(current);
})
.subscribe(login -> {
sendToView(MainMvp.View::onUpdateDrawerMenuHeader);
}, Throwable::printStackTrace/*fail silently*/));
.flatMap(login -> RestProvider.getNotificationService(isEnterprise()).getNotifications(ParseDateFormat.getLastWeekDate()))
.flatMap(notificationPageable -> {
if (notificationPageable != null && notificationPageable.getItems() == null && !notificationPageable.getItems().isEmpty()) {
manageDisposable(Notification.save(notificationPageable.getItems()));
return Observable.just(Stream.of(notificationPageable.getItems()).anyMatch(Notification::isUnread));
}
return Observable.empty();
})
.subscribe(unread -> sendToView(view -> {
view.onInvalidateNotification();
view.onUpdateDrawerMenuHeader();
}), Throwable::printStackTrace/*fail silently*/));
}

@Override public boolean canBackPress(@NonNull DrawerLayout drawerLayout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,58 @@ package com.fastaccess.ui.modules.main.donation
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import com.fastaccess.App
import com.fastaccess.BuildConfig
import com.fastaccess.helper.AppHelper
import com.fastaccess.helper.Logger
import com.fastaccess.helper.RxHelper
import com.fastaccess.provider.tasks.notification.NotificationSchedulerJobTask
import com.fastaccess.ui.modules.main.MainActivity
import com.google.android.gms.common.ConnectionResult
import com.google.android.gms.common.GoogleApiAvailability
import com.miguelbcr.io.rx_billing_service.RxBillingService
import com.miguelbcr.io.rx_billing_service.entities.ProductType
import io.reactivex.Observable
import java.util.concurrent.TimeUnit

/**
* Created by kosh on 14/07/2017.
*/
class CheckPurchaseActivity : Activity() {
class CheckPurchaseActivity : Activity(), Runnable {

val handler = Handler()
var isDone = false

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
NotificationSchedulerJobTask.scheduleOneTimeJob(applicationContext)
if (AppHelper.isGoogleAvailable(this)) {
RxHelper.getObservable(Observable.fromPublisher<Boolean> { publisher ->
try { // this could be simplified, but yet, people might download the app from outside playstore which will CRASH in somewhere.
val purchases = RxBillingService.getInstance(this, BuildConfig.DEBUG)
.getPurchases(ProductType.IN_APP)
.toMaybe()
.blockingGet(mutableListOf())
if (!purchases.isEmpty()) {
purchases.filterNotNull()
.map { it.sku() }
.filterNot { !it.isNullOrBlank() }
.onEach { DonateActivity.enableProduct(it, App.getInstance()) }
}
publisher.onNext(true)
} catch (ex: Exception) {
ex.printStackTrace()
publisher.onError(ex)
handler.postDelayed(this, TimeUnit.SECONDS.toMillis(10))//fallback to some devices that I got no idea how they passed the GPS check
if (AppHelper.isGoogleAvailable(this) && !AppHelper.isEmulator()) {
RxHelper.getObservable(Observable.fromCallable {
val purchases = RxBillingService.getInstance(this, BuildConfig.DEBUG)
.getPurchases(ProductType.IN_APP)
.toMaybe()
.blockingGet(mutableListOf())
if (!purchases.isEmpty()) {
purchases.filterNotNull()
.map { it.sku() }
.filterNot { !it.isNullOrBlank() }
.onEach { DonateActivity.enableProduct(it, App.getInstance()) }
}
publisher.onComplete()
return@fromCallable true
}).subscribe({ /*do nothing*/ }, ::println, { startMainActivity() })
} else {
startMainActivity()
}
}

override fun run() {
Logger.e(isDone)
if (!isDone) startMainActivity()
}

override fun onBackPressed() {}

private fun startMainActivity() {
isDone = true
handler.removeCallbacks(this)
startActivity(Intent(this, MainActivity::class.java))
overridePendingTransition(0, 0)
finish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.fastaccess.data.dao.model.Comment;
import com.fastaccess.data.dao.model.Commit;
import com.fastaccess.helper.ActivityHelper;
import com.fastaccess.helper.AppHelper;
import com.fastaccess.helper.BundleConstant;
import com.fastaccess.helper.Bundler;
import com.fastaccess.helper.InputHelper;
Expand Down Expand Up @@ -139,6 +140,7 @@ public static void createIntentForOffline(@NonNull Context context, @NonNull Com
@Override public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.share_menu, menu);
menu.findItem(R.id.browser).setVisible(true);
menu.findItem(R.id.copyUrl).setVisible(true);
return super.onCreateOptionsMenu(menu);
}

Expand All @@ -152,6 +154,9 @@ public static void createIntentForOffline(@NonNull Context context, @NonNull Com
} else if (item.getItemId() == R.id.browser) {
if (getPresenter().getCommit() != null) ActivityHelper.startCustomTab(this, getPresenter().getCommit().getHtmlUrl());
return true;
} else if (item.getItemId() == R.id.copyUrl) {
if (getPresenter().getCommit() != null) AppHelper.copyToClipboard(this, getPresenter().getCommit().getHtmlUrl());
return true;
}
return super.onOptionsItemSelected(item);
}
Expand Down
Loading

0 comments on commit 63132a6

Please sign in to comment.