fixed multi acc switch & checkpoint WIP for enterprise.

This commit is contained in:
Kosh 2017-07-10 22:18:03 +08:00
parent 71bf733782
commit 6360f03986
171 changed files with 560 additions and 667 deletions

View File

@ -94,7 +94,6 @@ _Ads currently not available._
- [**commonmark**](https://github.com/atlassian/commonmark-java) for _Markdown_ conversion to html
- [**Toasty**](https://github.com/GrenderG/Toasty) for displaying error/success messages
- [**ShapedImageView**](https://github.com/gavinliu/ShapedImageView) for round avatars
- [**MaterialTapTargetPrompt**](https://github.com/sjwall/MaterialTapTargetPrompt) for displaying tips throughout the app
- [**Material-About-Library**](https://github.com/daniel-stoneuk/material-about-library) for the about screen
- **Fabric** analytics & crash reporting.
- **Android Support Libraries**, the almighty ;-)
@ -144,7 +143,9 @@ Read the [**contribution guide**](.github/CONTRIBUTING.md) for more detailed inf
<details>
<summary>I login with Enterprise account but can't interact with anything other than my Enterprise GitHub</summary>
<p>Well, logically, you can't access anything else other than your Enterprise, but FastHub made that possible but can't do much about it,
in most cases since your login credential doesn't exists in GitHub server. But in <b>few</b> cases your Oauth token will do the trick.</p>
in most cases since your login credential doesn't exists in GitHub server. But in <b>few</b>
cases your GitHub account Oauth token will do the trick.</p>
</details>

View File

@ -136,7 +136,6 @@ dependencies {
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
implementation 'com.annimon:stream:1.1.7'
implementation 'com.github.GrenderG:Toasty:1.1.3'
implementation 'com.github.JediBurrell:MaterialTapTargetPrompt:-SNAPSHOT'
implementation 'com.github.k0shk0sh:RetainedDateTimePickers:1.0.2'
implementation 'com.github.daniel-stoneuk:material-about-library:2.1.0'
implementation "io.requery:requery:${requery}"

0
app/src/debug/res/mipmap-hdpi/ic_launcher.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

0
app/src/debug/res/mipmap-mdpi/ic_launcher.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

0
app/src/debug/res/mipmap-xhdpi/ic_launcher.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

0
app/src/debug/res/mipmap-xxhdpi/ic_launcher.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

0
app/src/debug/res/mipmap-xxxhdpi/ic_launcher.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.fastaccess"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.fastaccess">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="com.android.vending.BILLING"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_notification"/>
android:resource="@drawable/ic_notification" />
<application
android:name=".App"
@ -29,9 +29,9 @@
android:name=".ui.modules.main.MainActivity"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
@ -42,14 +42,14 @@
android:screenOrientation="portrait"
android:theme="@style/LoginTheme">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="login"
android:scheme="fasthub"/>
android:scheme="fasthub" />
</intent-filter>
</activity>
<activity
@ -58,14 +58,14 @@
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/LoginTheme"/>
android:theme="@style/LoginTheme" />
<activity
android:name=".ui.modules.user.UserPagerActivity"
android:label="@string/user"
android:parentActivityName=".ui.modules.main.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.main.MainActivity"/>
android:value=".ui.modules.main.MainActivity" />
</activity>
<activity
android:name=".ui.modules.repos.RepoPagerActivity"
@ -73,7 +73,7 @@
android:parentActivityName=".ui.modules.main.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.main.MainActivity"/>
android:value=".ui.modules.main.MainActivity" />
</activity>
<activity
android:name=".ui.modules.repos.issues.issue.details.IssuePagerActivity"
@ -81,19 +81,19 @@
android:parentActivityName=".ui.modules.repos.RepoPagerActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.repos.RepoPagerActivity"/>
android:value=".ui.modules.repos.RepoPagerActivity" />
</activity>
<activity
android:name=".ui.modules.repos.issues.create.CreateIssueActivity"
android:configChanges="keyboard|orientation|screenSize"
android:label="@string/create_issue"/>
android:label="@string/create_issue" />
<activity
android:name=".ui.modules.repos.pull_requests.pull_request.details.PullRequestPagerActivity"
android:label="@string/pull_request"
android:parentActivityName=".ui.modules.repos.RepoPagerActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.repos.RepoPagerActivity"/>
android:value=".ui.modules.repos.RepoPagerActivity" />
</activity>
<activity
android:name=".ui.modules.repos.code.commit.details.CommitPagerActivity"
@ -101,34 +101,34 @@
android:parentActivityName=".ui.modules.repos.RepoPagerActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.repos.RepoPagerActivity"/>
android:value=".ui.modules.repos.RepoPagerActivity" />
</activity>
<activity
android:name=".ui.modules.code.CodeViewerActivity"
android:configChanges="keyboard|orientation|screenSize"
android:label="@string/viewer"/>
android:label="@string/viewer" />
<activity
android:name=".ui.modules.editor.EditorActivity"
android:configChanges="keyboard|orientation|screenSize"
android:label="@string/markdown"/>
android:label="@string/markdown" />
<activity
android:name=".ui.modules.gists.create.CreateGistActivity"
android:configChanges="keyboard|orientation|screenSize"
android:label="@string/create_gist"/>
android:label="@string/create_gist" />
<activity
android:name=".ui.modules.gists.gist.GistActivity"
android:label="@string/gist"
android:parentActivityName=".ui.modules.main.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.main.MainActivity"/>
android:value=".ui.modules.main.MainActivity" />
</activity>
<activity
android:name=".ui.modules.search.SearchActivity"
android:parentActivityName=".ui.modules.main.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.main.MainActivity"/>
android:value=".ui.modules.main.MainActivity" />
</activity>
<activity
android:name=".ui.modules.notification.NotificationActivity"
@ -136,44 +136,44 @@
android:parentActivityName=".ui.modules.main.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.main.MainActivity"/>
android:value=".ui.modules.main.MainActivity" />
</activity>
<activity
android:name=".ui.modules.about.FastHubAboutActivity"
android:theme="@style/AppTheme.AboutActivity.Light"/>
android:theme="@style/AppTheme.AboutActivity.Light" />
<activity
android:name=".ui.modules.pinned.PinnedReposActivity"
android:label="@string/pinned"/>
android:label="@string/pinned" />
<activity
android:name=".ui.modules.gists.GistsListActivity"
android:label="@string/public_gists"/>
<activity android:name=".ui.modules.profile.org.teams.details.TeamPagerActivity"/>
android:label="@string/public_gists" />
<activity android:name=".ui.modules.profile.org.teams.details.TeamPagerActivity" />
<activity
android:name=".ui.modules.repos.code.files.activity.RepoFilesActivity"
android:parentActivityName=".ui.modules.repos.RepoPagerActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.repos.RepoPagerActivity"/>
android:value=".ui.modules.repos.RepoPagerActivity" />
</activity>
<activity android:name=".ui.modules.filter.issues.FilterIssuesActivity"/>
<activity android:name=".ui.modules.main.donation.DonationActivity"/>
<activity android:name=".ui.modules.repos.code.commit.viewer.FullCommitFileActivity"/>
<activity android:name=".ui.modules.filter.issues.FilterIssuesActivity" />
<activity android:name=".ui.modules.main.donation.DonationActivity" />
<activity android:name=".ui.modules.repos.code.commit.viewer.FullCommitFileActivity" />
<activity
android:name=".ui.modules.search.repos.files.SearchFileActivity"
android:parentActivityName=".ui.modules.repos.RepoPagerActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.repos.RepoPagerActivity"/>
android:value=".ui.modules.repos.RepoPagerActivity" />
</activity>
<activity android:name=".ui.modules.settings.SettingsActivity"/>
<activity android:name=".ui.modules.settings.category.SettingsCategoryActivity"/>
<activity android:name=".ui.modules.settings.SettingsActivity" />
<activity android:name=".ui.modules.settings.category.SettingsCategoryActivity" />
<activity
android:name=".ui.modules.repos.code.releases.ReleasesListActivity"
android:label="@string/releases"
android:parentActivityName=".ui.modules.repos.RepoPagerActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.repos.RepoPagerActivity"/>
android:value=".ui.modules.repos.RepoPagerActivity" />
</activity>
<activity
@ -183,25 +183,25 @@
android:windowSoftInputMode="stateAlwaysHidden">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.main.MainActivity"/>
android:value=".ui.modules.main.MainActivity" />
</activity>
<activity android:name=".ui.modules.theme.ThemeActivity"/>
<activity android:name=".ui.modules.theme.ThemeActivity" />
<activity
android:name=".ui.modules.theme.code.ThemeCodeActivity"
android:label="@string/theme_title"/>
android:label="@string/theme_title" />
<activity
android:name=".ui.modules.main.donation.DonateActivity"
android:configChanges="keyboard|orientation|screenSize"
android:theme="@style/ThemeTranslucent"/>
android:theme="@style/ThemeTranslucent" />
<activity
android:name=".ui.modules.reviews.changes.ReviewChangesActivity"
android:configChanges="keyboard|orientation|screenSize"
android:label="@string/review_changes"
android:theme="@style/ThemeTranslucent"/>
android:theme="@style/ThemeTranslucent" />
<activity
android:name=".ui.modules.repos.wiki.WikiActivity"
@ -209,7 +209,7 @@
android:parentActivityName=".ui.modules.repos.RepoPagerActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.repos.RepoPagerActivity"/>
android:value=".ui.modules.repos.RepoPagerActivity" />
</activity>
<activity
@ -218,30 +218,36 @@
android:noHistory="true"
android:theme="@android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<action android:name="android.intent.action.VIEW" />
<data
android:host="github.com"
android:scheme="http"/>
android:scheme="http" />
<data
android:host="github.com"
android:scheme="https"/>
android:scheme="https" />
<data
android:host="gist.github.com"
android:scheme="http"/>
android:scheme="http" />
<data
android:host="gist.github.com"
android:scheme="https"/>
android:scheme="https" />
<data
android:host="raw.githubusercontent.com"
android:scheme="https"/>
android:scheme="https" />
<data
android:host="gist.githubusercontent.com"
android:scheme="https"/>
<data android:pathPattern=".*"/>
android:scheme="https" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:pathPattern=".*" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="text/plain" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
@ -249,26 +255,26 @@
android:name=".provider.tasks.notification.NotificationSchedulerJobTask"
android:exported="false">
<intent-filter>
<action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE"/>
<action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE" />
</intent-filter>
</service>
<service android:name=".provider.tasks.notification.ReadNotificationService"/>
<service android:name=".provider.tasks.git.GithubActionService"/>
<service android:name=".provider.tasks.git.ReactionService"/>
<service android:name=".provider.tasks.slack.SlackInvitationService"/>
<service android:name=".provider.tasks.version.CheckVersionService"/>
<service android:name=".provider.tasks.notification.ReadNotificationService" />
<service android:name=".provider.tasks.git.GithubActionService" />
<service android:name=".provider.tasks.git.ReactionService" />
<service android:name=".provider.tasks.slack.SlackInvitationService" />
<service android:name=".provider.tasks.version.CheckVersionService" />
<service
android:name=".provider.fcm.PushNotificationService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="io.fabric.ApiKey"
android:value="6ed82b6e0756853d7d782a3f547f84f9ecba217e"/>
android:value="6ed82b6e0756853d7d782a3f547f84f9ecba217e" />
</application>

0
app/src/main/assets/colors.json Executable file → Normal file
View File

0
app/src/main/assets/emojis.json Executable file → Normal file
View File

0
app/src/main/assets/fonts/app_font.ttf Executable file → Normal file
View File

0
app/src/main/assets/highlight/styles/themes/agate.css Executable file → Normal file
View File

View File

View File

0
app/src/main/assets/highlight/styles/themes/arta.css Executable file → Normal file
View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

0
app/src/main/assets/highlight/styles/themes/dark.css Executable file → Normal file
View File

View File

View File

0
app/src/main/assets/highlight/styles/themes/docco.css Executable file → Normal file
View File

View File

0
app/src/main/assets/highlight/styles/themes/far.css Executable file → Normal file
View File

0
app/src/main/assets/highlight/styles/themes/foundation.css vendored Executable file → Normal file
View File

View File

0
app/src/main/assets/highlight/styles/themes/github.css Executable file → Normal file
View File

View File

View File

View File

View File

View File

0
app/src/main/assets/highlight/styles/themes/hybrid.css Executable file → Normal file
View File

0
app/src/main/assets/highlight/styles/themes/idea.css Executable file → Normal file
View File

View File

View File

View File

0
app/src/main/assets/highlight/styles/themes/magula.css Executable file → Normal file
View File

View File

View File

View File

View File

0
app/src/main/assets/highlight/styles/themes/ocean.css Executable file → Normal file
View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

0
app/src/main/assets/highlight/styles/themes/vs.css Executable file → Normal file
View File

0
app/src/main/assets/highlight/styles/themes/vs2015.css Executable file → Normal file
View File

0
app/src/main/assets/highlight/styles/themes/xcode.css Executable file → Normal file
View File

0
app/src/main/assets/highlight/styles/themes/xt256.css Executable file → Normal file
View File

View File

0
app/src/main/assets/md/github.css Executable file → Normal file
View File

0
app/src/main/assets/md/github_dark.css Executable file → Normal file
View File

View File

@ -26,8 +26,8 @@ import static com.annimon.stream.Collectors.toList;
@Getter @Setter public class GroupedNotificationModel {
public static final int HEADER = 1;
public static final int ROW = 2;
private int type;
private Repo repo;
private Notification notification;

View File

@ -5,6 +5,8 @@ import android.os.Parcelable;
import android.support.annotation.NonNull;
import com.fastaccess.App;
import com.fastaccess.helper.Logger;
import com.fastaccess.helper.PrefGetter;
import com.fastaccess.helper.RxHelper;
import java.util.Date;
@ -56,24 +58,12 @@ import lombok.NoArgsConstructor;
@Nullable boolean isLoggedIn;
@Nullable boolean isEnterprise;
@Nullable String otpCode;
@Nullable String enterpriseUrl;
public Observable<Login> update(Login login) {
Login current = getUser();
login.setIsEnterprise(current.isIsEnterprise());
login.setToken(current.getToken());
return RxHelper.safeObservable(App.getInstance().getDataStore().update(login).toObservable());
}
public Observable<Login> saveObservable(Login entity) {
return App.getInstance().getDataStore()
.delete(Login.class)
.where(Login.LOGIN.eq(entity.getLogin()))
.get()
.single()
.flatMap(integer -> App.getInstance().getDataStore().insert(entity))
.toObservable();
}
public void save(Login entity) {
App.getInstance().getDataStore()
.delete(Login.class)
@ -127,7 +117,44 @@ import lombok.NoArgsConstructor;
.value() > 0;
}
@Override public int describeContents() { return 0; }
public static Observable<Boolean> onMultipleLogin(@NonNull Login userModel, boolean isEnterprise, boolean isNew) {
return Observable.fromPublisher(s -> {
Login currentUser = Login.getUser();
if (currentUser != null) {
currentUser.setIsLoggedIn(false);
currentUser.save(currentUser);
}
if (!isEnterprise) {
PrefGetter.resetEnterprise();
}
userModel.setIsLoggedIn(true);
if (isNew) {
userModel.setIsEnterprise(isEnterprise);
userModel.setToken(isEnterprise ? PrefGetter.getEnterpriseToken() : PrefGetter.getToken());
userModel.setOtpCode(isEnterprise ? PrefGetter.getEnterpriseOtpCode() : PrefGetter.getOtpCode());
userModel.setEnterpriseUrl(isEnterprise ? PrefGetter.getEnterpriseUrl() : null);
userModel.save(userModel);
} else {
if (isEnterprise) {
PrefGetter.setTokenEnterprise(userModel.token);
PrefGetter.setEnterpriseOtpCode(userModel.otpCode);
PrefGetter.setEnterpriseUrl(userModel.enterpriseUrl);
Logger.e(userModel.enterpriseUrl, PrefGetter.getEnterpriseUrl());
} else {
PrefGetter.resetEnterprise();
PrefGetter.setToken(userModel.token);
PrefGetter.setOtpCode(userModel.otpCode);
}
userModel.save(userModel);
}
s.onNext(true);
s.onComplete();
});
}
@Override public int describeContents() {
return 0;
}
@Override public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(this.id);
@ -165,6 +192,7 @@ import lombok.NoArgsConstructor;
dest.writeByte(this.isLoggedIn ? (byte) 1 : (byte) 0);
dest.writeByte(this.isEnterprise ? (byte) 1 : (byte) 0);
dest.writeString(this.otpCode);
dest.writeString(this.enterpriseUrl);
}
protected AbstractLogin(Parcel in) {
@ -205,11 +233,18 @@ import lombok.NoArgsConstructor;
this.isLoggedIn = in.readByte() != 0;
this.isEnterprise = in.readByte() != 0;
this.otpCode = in.readString();
this.enterpriseUrl = in.readString();
}
public static final Creator<Login> CREATOR = new Creator<Login>() {
@Override public Login createFromParcel(Parcel source) {return new Login(source);}
@Override
public Login createFromParcel(Parcel source) {
return new Login(source);
}
@Override public Login[] newArray(int size) {return new Login[size];}
@Override
public Login[] newArray(int size) {
return new Login[size];
}
};
}

View File

@ -33,6 +33,8 @@ import android.widget.Toast;
import com.fastaccess.App;
import com.fastaccess.R;
import com.fastaccess.ui.modules.main.MainActivity;
import com.fastaccess.ui.modules.parser.LinksParserActivity;
import java.util.ArrayList;
import java.util.List;
@ -46,7 +48,8 @@ public class ActivityHelper {
private static int BUTTON_ID = 32;
@Nullable public static Activity getActivity(@Nullable Context content) {
@Nullable
public static Activity getActivity(@Nullable Context content) {
if (content == null) return null;
else if (content instanceof Activity) return (Activity) content;
else if (content instanceof ContextWrapper) return getActivity(((ContextWrapper) content).getBaseContext());
@ -82,21 +85,24 @@ public class ActivityHelper {
if (finalIntent != null) {
try {
context.startActivity(finalIntent);
} catch (ActivityNotFoundException ignored) {}
} catch (ActivityNotFoundException ignored) {
}
} else {
if (!fromCustomTab) {
Activity activity = ActivityHelper.getActivity(context);
if (activity == null) {
try {
context.startActivity(i);
} catch (ActivityNotFoundException ignored) {}
} catch (ActivityNotFoundException ignored) {
}
return;
}
startCustomTab(activity, url);
} else {
try {
context.startActivity(i);
} catch (ActivityNotFoundException ignored) {}
} catch (ActivityNotFoundException ignored) {
}
}
}
}
@ -105,7 +111,8 @@ public class ActivityHelper {
openChooser(context, Uri.parse(url));
}
@SafeVarargs public static void start(@NonNull Activity activity, Class cl, Pair<View, String>... sharedElements) {
@SafeVarargs
public static void start(@NonNull Activity activity, Class cl, Pair<View, String>... sharedElements) {
Intent intent = new Intent(activity, cl);
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, sharedElements);
activity.startActivity(intent, options.toBundle());
@ -138,7 +145,8 @@ public class ActivityHelper {
activity.startActivity(intent, options.toBundle());
}
@SafeVarargs public static void start(@NonNull Activity activity, @NonNull Intent intent, @NonNull Pair<View, String>... sharedElements) {
@SafeVarargs
public static void start(@NonNull Activity activity, @NonNull Intent intent, @NonNull Pair<View, String>... sharedElements) {
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, sharedElements);
activity.startActivity(intent, options.toBundle());
@ -159,7 +167,8 @@ public class ActivityHelper {
}
@SuppressWarnings("RestrictedApi")
@Nullable public static Fragment getVisibleFragment(@NonNull FragmentManager manager) {
@Nullable
public static Fragment getVisibleFragment(@NonNull FragmentManager manager) {
List<Fragment> fragments = manager.getFragments();
if (fragments != null && !fragments.isEmpty()) {
for (Fragment fragment : fragments) {
@ -233,77 +242,11 @@ public class ActivityHelper {
return chooserIntent;
}
public static void showDismissHints(@NonNull Context context, @NonNull Runnable runnable) {
Activity activity = getActivity(context);
if (activity == null) return;
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.weight = 1;
params.gravity = Gravity.START;
int margin = (int) context.getResources().getDimension(R.dimen.spacing_normal);
params.setMargins(margin, margin, margin, margin);
Button button = new Button(context);
button.setLayoutParams(params);
button.setText(context.getResources().getString(R.string.dismiss_all));
button.setTextColor(context.getResources().getColor(R.color.material_grey_200));
button.setBackgroundTintList(ColorStateList.valueOf(context.getResources().getColor(R.color.material_red_accent_700)));
button.setAllCaps(true);
button.setOnClickListener(v -> {
PrefGetter.isCommentHintShowed();
PrefGetter.isEditorHintShowed();
PrefGetter.isFileOptionHintShow();
PrefGetter.isHomeButoonHintShowed();
PrefGetter.isNavDrawerHintShowed();
PrefGetter.isReleaseHintShow();
PrefGetter.isRepoFabHintShowed();
PrefGetter.isRepoGuideShowed();
runnable.run();
ActivityHelper.hideDismissHints(context);
});
ViewGroup parentView = (ViewGroup) activity.getWindow().getDecorView();
RelativeLayout relativeLayout = new RelativeLayout(context);
relativeLayout.setId(BUTTON_ID);
relativeLayout.setLayoutParams(
new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
relativeLayout.setPadding(0, getNotificationBarHeight(context), 0, 0);
relativeLayout.addView(button);
parentView.addView(relativeLayout);
}
public static void hideDismissHints(@NonNull Context context) {
Activity activity = getActivity(context);
if (activity == null) return;
ViewGroup parentView = (ViewGroup) activity.getWindow().getDecorView();
View button = parentView.findViewById(BUTTON_ID);
if (button != null)
parentView.removeView(button);
}
public static void bringDismissAllToFront(@NonNull Context context) {
Activity activity = getActivity(context);
if (activity == null) return;
ViewGroup parentView = (ViewGroup) activity.getWindow().getDecorView();
View button = parentView.findViewById(BUTTON_ID);
if (button != null)
button.bringToFront();
}
private static int getNotificationBarHeight(@NonNull Context context) {
Rect rectangle = new Rect();
Activity activity = getActivity(context);
if (activity == null) return 0;
Window window = activity.getWindow();
window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
int statusBarHeight = rectangle.top;
int contentViewTop = window.findViewById(Window.ID_ANDROID_CONTENT).getTop();
return Math.abs(contentViewTop - statusBarHeight);
}
public static void activateActivity(Context context, final Class<? extends Activity> activity, final boolean activate) {
public static void activateLinkInterceptorActivity(Context context, boolean activate) {
final PackageManager pm = context.getPackageManager();
final int flag = activate ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
pm.setComponentEnabledSetting(new ComponentName(context, activity), flag, PackageManager.DONT_KILL_APP);
pm.setComponentEnabledSetting(new ComponentName(context, LinksParserActivity.class), flag, PackageManager.DONT_KILL_APP);
}
}

View File

@ -418,4 +418,10 @@ public class PrefGetter {
public static boolean isEnterprise() {
return !InputHelper.isEmpty(getEnterpriseUrl());
}
public static void resetEnterprise() {
PrefGetter.setTokenEnterprise(null);
PrefGetter.setEnterpriseOtpCode(null);
PrefGetter.setEnterpriseUrl(null);
}
}

View File

View File

View File

View File

Some files were not shown because too many files have changed in this diff Show More