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

Commit

Permalink
released 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Kosh committed Jun 18, 2017
1 parent 943a126 commit 5e1fcc4
Show file tree
Hide file tree
Showing 17 changed files with 103 additions and 74 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 310
versionName "3.1.0"
versionCode 320
versionName "3.2.0"
signingConfig signingConfigs.signing
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
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@
<activity
android:name=".ui.modules.repos.wiki.WikiActivity"
android:label="@string/gollum"
android:parentActivityName=".ui.modules.main.MainActivity">
android:parentActivityName=".ui.modules.repos.RepoPagerActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.main.MainActivity"/>
android:value=".ui.modules.repos.RepoPagerActivity"/>
</activity>

<activity
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/assets/md/github.css
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ body h1 {
border-bottom: 1px solid #eee
}

.gh-header-meta {
padding-bottom: .3em;
margin-bottom: 6px;
border-bottom: 1px solid #eee
}

body h2 {
padding-bottom: .3em;
font-size: 1.5em;
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/assets/md/github_dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ body h1 {
border-bottom: 1px solid #656d78
}

.gh-header-meta {
padding-bottom: .3em;
margin-bottom: 6px;
border-bottom: 1px solid #656d78
}

body h2 {
padding-bottom: .3em;
font-size: 1.5em;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.os.Environment;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.widget.Toast;

import com.fastaccess.BuildConfig;
import com.fastaccess.R;
Expand Down Expand Up @@ -105,8 +106,12 @@ public static void downloadFile(@NonNull Context context, @NonNull String url) {
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(uri);
File direct = new File(Environment.getExternalStorageDirectory() + File.separator + context.getString(R.string.app_name));
if (!direct.exists()) {
direct.mkdirs();
if (!direct.isDirectory() || !direct.exists()) {
boolean isCreated = direct.mkdirs();
if (!isCreated) {
Toast.makeText(context, "Unable to create directory to download file", Toast.LENGTH_SHORT).show();
return;
}
}
String fileName = "";
NameParser nameParser = new NameParser(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,17 @@ public static PullStatusViewHolder newInstance(@NonNull ViewGroup parent) {
SpannableBuilder builder = SpannableBuilder.builder();
Stream.of(pullRequestStatusModel.getStatuses())
.filter(statusesModel -> statusesModel.getState() != null)
.forEach(statusesModel -> builder
.append(ContextCompat.getDrawable(statuses.getContext(), statusesModel.getState().getDrawableRes()))
.append(" ")
.url(statusesModel.getDescription(), v -> SchemeParser.launchUri(v.getContext(), Uri.parse(statusesModel.getTargetUrl())))
.append("\n"));
.forEach(statusesModel -> {
builder.append(ContextCompat.getDrawable(statuses.getContext(), statusesModel.getState().getDrawableRes()));
if (!InputHelper.isEmpty(statusesModel.getTargetUrl())) {
builder.append(" ")
.url(statusesModel.getDescription(), v -> SchemeParser.launchUri(v.getContext(),
Uri.parse(statusesModel.getTargetUrl())))
.append("\n");
} else {
builder.append("\n");
}
});
if (!InputHelper.isEmpty(builder)) {
statuses.setMovementMethod(LinkMovementMethod.getInstance());
statuses.setText(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ public class ChangelogBottomSheetDialog extends BaseMvpBottomSheetDialogFragment
}

private void showChangelog(String html) {
if (prettifyWebView == null) return;
webProgress.setVisibility(View.GONE);
if (html != null) {
message.setVisibility(View.GONE);
prettifyWebView.setVisibility(View.VISIBLE);
prettifyWebView.setGithubContent(html, null);
prettifyWebView.setGithubContent(html, null, false, false);
prettifyWebView.setNestedScrollingEnabled(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public class EditorActivity extends BaseActivity<EditorMvp.View, EditorPresenter
int end = editText.getSelectionEnd();
editText.getText().replace(inMentionMode, end, complete, 0, complete.length());
inMentionMode = -1;
} catch (IndexOutOfBoundsException ignored) {}
} catch (Exception ignored) {}
mention.setVisibility(GONE);
listDivider.setVisibility(GONE);
}
Expand Down Expand Up @@ -339,9 +339,8 @@ private void updateMentionList(@NonNull String mentioning) {
for (String participant : participants)
if (participant.toLowerCase().startsWith(mentioning.replace("@", "").toLowerCase()))
mentions.add(participant);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, mentions.subList(0, Math.min(mentions.size(), 3)));

ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1,
android.R.id.text1, mentions.subList(0, Math.min(mentions.size(), 3)));
mention.setAdapter(adapter);
Log.d(getLoggingTag(), mentions.toString());
}
Expand Down Expand Up @@ -378,7 +377,7 @@ else if (inMentionMode > -1)
mention.setVisibility(inMentionMode > 0 ? View.VISIBLE : GONE);
listDivider.setVisibility(mention.getVisibility());
}
} catch (ArrayIndexOutOfBoundsException ignored) {}
} catch (Exception ignored) {}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public static void start(@NonNull Activity activity, boolean isBasicAuth) {
@Override public void onBackPressed() {
if (!(this instanceof LoginChooserActivity)) {
startActivity(new Intent(this, LoginChooserActivity.class));
finish();
} else {
finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,17 @@ class DonateActivity : BaseActivity<BaseMvp.FAView, BasePresenter<BaseMvp.FAView
Answers.getInstance().logPurchase(PurchaseEvent().putItemName(productKey))
showMessage(R.string.success, R.string.success_purchase_message)
enableProduct(productKey)
setResult(Activity.RESULT_OK)
val intent = Intent()
intent.putExtra(BundleConstant.ITEM, productKey)
setResult(Activity.RESULT_OK, intent)
} else {
if (throwable is RxBillingServiceException) {
val code = throwable.code
if (code == RxBillingServiceError.ITEM_ALREADY_OWNED) {
enableProduct(productKey)
setResult(Activity.RESULT_OK)
val intent = Intent()
intent.putExtra(BundleConstant.ITEM, productKey)
setResult(Activity.RESULT_OK, intent)
} else {
showErrorMessage(throwable.message!!)
Logger.e(code)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import com.fastaccess.data.dao.wiki.WikiContentModel
import com.fastaccess.helper.BundleConstant
import com.fastaccess.helper.Bundler
import com.fastaccess.ui.base.BaseActivity
import com.fastaccess.ui.modules.main.MainActivity
import com.fastaccess.ui.modules.repos.RepoPagerActivity
import com.fastaccess.ui.widgets.StateLayout
import com.fastaccess.ui.widgets.bindView
import com.prettifier.pretty.PrettifyWebView
Expand Down Expand Up @@ -104,7 +104,9 @@ class WikiActivity : BaseActivity<WikiMvp.View, WikiPresenter>(), WikiMvp.View {
return true
}
android.R.id.home -> {
startActivity(Intent(this, MainActivity::class.java))
if (!presenter.login.isNullOrEmpty() && !presenter.repoId.isNullOrEmpty()) {
startActivity(RepoPagerActivity.createIntent(this, presenter.repoId!!, presenter.login!!))
}
finish()
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Intent
import com.fastaccess.data.dao.wiki.WikiContentModel
import com.fastaccess.data.dao.wiki.WikiSideBarModel
import com.fastaccess.helper.BundleConstant
import com.fastaccess.helper.Logger
import com.fastaccess.helper.RxHelper
import com.fastaccess.provider.rest.jsoup.JsoupProvider
import com.fastaccess.ui.base.mvp.presenter.BasePresenter
Expand Down Expand Up @@ -51,12 +52,12 @@ class WikiPresenter : BasePresenter<WikiMvp.View>(), WikiMvp.Presenter {
if (bottomRightBar.isNotEmpty()) {
bottomRightBar.remove()
}
val headerHtml = wikiWrapper.select(".gh-header")
val headerHtml = wikiWrapper.select(".gh-header .gh-header-meta")
val revision = headerHtml.select("a.history")
if (revision.isNotEmpty()) {
revision.remove()
}
val header = headerHtml.html() + "<h1></h1>"
val header = "<div class='gh-header-meta'>${headerHtml.html()}</div>"
val wikiContent = wikiWrapper.select(".wiki-content")
val content = header + wikiContent.select(".markdown-body").html()
val rightBarList = wikiContent.select(".wiki-pages").select("li")
Expand All @@ -68,6 +69,7 @@ class WikiPresenter : BasePresenter<WikiMvp.View>(), WikiMvp.Presenter {
sidebarList.add(WikiSideBarModel(sidebarTitle, sidebarLink))
}
}
Logger.d(header)
s.onNext(WikiContentModel(content, "", sidebarList))
} else {
s.onNext(WikiContentModel("<h2 align='center'>No Wiki</h4>", "", arrayListOf()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.evernote.android.state.State;
import com.fastaccess.R;
import com.fastaccess.data.dao.FragmentPagerAdapterModel;
import com.fastaccess.data.dao.TabsCountStateModel;
Expand All @@ -34,7 +33,6 @@
import butterknife.OnClick;
import butterknife.OnEditorAction;
import butterknife.OnTextChanged;
import com.evernote.android.state.State;

/**
* Created by Kosh on 08 Dec 2016, 8:22 PM
Expand Down Expand Up @@ -62,13 +60,9 @@ void onTextChange(Editable s) {
}
}

@OnEditorAction(R.id.searchEditText) boolean onEditor(int actionId, KeyEvent keyEvent) {
if (keyEvent != null && keyEvent.getAction() == KeyEvent.KEYCODE_SEARCH) {
getPresenter().onSearchClicked(pager, searchEditText);
} else if (actionId == EditorInfo.IME_ACTION_SEARCH) {
getPresenter().onSearchClicked(pager, searchEditText);
}
return false;
@OnEditorAction(R.id.searchEditText) boolean onEditor() {
getPresenter().onSearchClicked(pager, searchEditText);
return true;
}

@OnClick(value = {R.id.clear}) void onClear(View view) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,14 @@ class ThemeFragment : BaseFragment<ThemeFragmentMvp.View, ThemeFragmentPresenter
if (resultCode == Activity.RESULT_OK) {
if (PrefGetter.isProEnabled() || PrefGetter.isMidNightBlueThemeEnabled()
|| PrefGetter.isAmlodEnabled() || PrefGetter.isBluishEnabled()) {
themeListener?.onThemeApplied()
val productKey = data?.getStringExtra(BundleConstant.ITEM)
productKey?.let {
when (it) {
getString(R.string.amlod_theme_purchase) -> setTheme(getString(R.string.amlod_theme_mode))
getString(R.string.midnight_blue_theme_purchase) -> setTheme(getString(R.string.mid_night_blue_theme_mode))
getString(R.string.theme_bluish_purchase) -> setTheme(getString(R.string.bluish_theme))
}
}
}
}
}
Expand All @@ -101,40 +108,40 @@ class ThemeFragment : BaseFragment<ThemeFragmentMvp.View, ThemeFragmentPresenter
private fun setTheme() {
when (theme) {
R.style.ThemeLight -> {
PrefHelper.set(THEME, getString(R.string.light_theme_mode))
themeListener?.onThemeApplied()
setTheme(getString(R.string.light_theme_mode))
}
R.style.ThemeDark -> {
PrefHelper.set(THEME, getString(R.string.dark_theme_mode))
themeListener?.onThemeApplied()
setTheme(getString(R.string.dark_theme_mode))
}
R.style.ThemeAmlod -> {
if (PrefGetter.isAmlodEnabled() || PrefGetter.isProEnabled()) {
PrefHelper.set(THEME, getString(R.string.amlod_theme_mode))
themeListener?.onThemeApplied()
setTheme(getString(R.string.amlod_theme_mode))
} else {
DonateActivity.start(this, getString(R.string.amlod_theme_purchase))
}
}
R.style.ThemeMidNighBlue -> {
if (PrefGetter.isMidNightBlueThemeEnabled() || PrefGetter.isProEnabled()) {
PrefHelper.set(THEME, getString(R.string.mid_night_blue_theme_mode))
themeListener?.onThemeApplied()
setTheme(getString(R.string.mid_night_blue_theme_mode))
} else {
DonateActivity.start(this, getString(R.string.midnight_blue_theme_purchase))
}
}
R.style.ThemeBluish -> {
if (PrefGetter.isBluishEnabled() || PrefGetter.isProEnabled()) {
PrefHelper.set(THEME, getString(R.string.bluish_theme))
themeListener?.onThemeApplied()
setTheme(getString(R.string.bluish_theme))
} else {
DonateActivity.start(this, getString(R.string.theme_bluish_purchase))
}
}
}
}

private fun setTheme(theme: String) {
PrefHelper.set(THEME, theme)
themeListener?.onThemeApplied()
}

private fun isPremiumTheme(): Boolean = theme != R.style.ThemeLight && theme != R.style.ThemeDark

}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public interface MessageDialogViewActionCallback {
if (msg != null) {
message.setVisibility(View.GONE);
prettifyWebView.setVisibility(View.VISIBLE);
prettifyWebView.setGithubContent(msg, null);
prettifyWebView.setGithubContent(msg, null, false, false);
prettifyWebView.setNestedScrollingEnabled(false);
return;
}
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/com/prettifier/pretty/PrettifyWebView.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ public void setGithubContent(@NonNull String source, @Nullable String baseUrl) {
}

public void setGithubContent(@NonNull String source, @Nullable String baseUrl, boolean toggleNestScrolling) {
addJavascriptInterface(new MarkDownInterceptorInterface(this, toggleNestScrolling), "Android");
setGithubContent(source, baseUrl, toggleNestScrolling, true);
}

public void setGithubContent(@NonNull String source, @Nullable String baseUrl, boolean toggleNestScrolling, boolean enableBridge) {
if (enableBridge) addJavascriptInterface(new MarkDownInterceptorInterface(this, toggleNestScrolling), "Android");
String page = GithubHelper.generateContent(getContext(), source, baseUrl, AppHelper.isNightMode(getResources()));
post(() -> loadDataWithBaseURL("file:///android_asset/md/", page, "text/html", "utf-8", null));
}
Expand Down
Loading

0 comments on commit 5e1fcc4

Please sign in to comment.