diff --git a/settings.gradle b/settings.gradle index 8850e4395..5f672933d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ -include ':twidere' +include ':twidere', ':twidere.extension.shortener.gist' include ':twidere.component.common' include ':twidere.library.extension' include ':twidere.component.querybuilder' diff --git a/twidere.extension.shortener.gist/.gitignore b/twidere.extension.shortener.gist/.gitignore new file mode 100644 index 000000000..796b96d1c --- /dev/null +++ b/twidere.extension.shortener.gist/.gitignore @@ -0,0 +1 @@ +/build diff --git a/twidere.extension.shortener.gist/build.gradle b/twidere.extension.shortener.gist/build.gradle new file mode 100644 index 000000000..597404869 --- /dev/null +++ b/twidere.extension.shortener.gist/build.gradle @@ -0,0 +1,47 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2015 Mariotaku Lee + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +apply plugin: 'com.android.application' +apply plugin: 'com.neenbedankt.android-apt' + +android { + compileSdkVersion 22 + buildToolsVersion "22.0.1" + + defaultConfig { + applicationId "org.mariotaku.twidere.extension.shortener.gist" + minSdkVersion 14 + targetSdkVersion 22 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + apt 'com.bluelinelabs:logansquare-compiler:1.1.0' + compile 'com.bluelinelabs:logansquare:1.1.0' + compile project(':twidere.library.extension') + compile fileTree(dir: 'libs', include: ['*.jar']) +} diff --git a/twidere.extension.shortener.gist/proguard-rules.pro b/twidere.extension.shortener.gist/proguard-rules.pro new file mode 100644 index 000000000..a3abb5fc4 --- /dev/null +++ b/twidere.extension.shortener.gist/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/mariotaku/Library/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/twidere.extension.shortener.gist/src/androidTest/java/org/mariotaku/twidere/extension/shortener/gist/ApplicationTest.java b/twidere.extension.shortener.gist/src/androidTest/java/org/mariotaku/twidere/extension/shortener/gist/ApplicationTest.java new file mode 100644 index 000000000..e38c8501e --- /dev/null +++ b/twidere.extension.shortener.gist/src/androidTest/java/org/mariotaku/twidere/extension/shortener/gist/ApplicationTest.java @@ -0,0 +1,32 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2015 Mariotaku Lee + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.mariotaku.twidere.extension.shortener.gist; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/twidere.extension.shortener.gist/src/main/AndroidManifest.xml b/twidere.extension.shortener.gist/src/main/AndroidManifest.xml new file mode 100644 index 000000000..bd4ca71db --- /dev/null +++ b/twidere.extension.shortener.gist/src/main/AndroidManifest.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + diff --git a/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/Gist.java b/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/Gist.java new file mode 100644 index 000000000..bccf8340c --- /dev/null +++ b/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/Gist.java @@ -0,0 +1,37 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2015 Mariotaku Lee + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.mariotaku.twidere.extension.shortener.gist; + +import com.bluelinelabs.logansquare.annotation.JsonField; +import com.bluelinelabs.logansquare.annotation.JsonObject; + +/** + * Created by mariotaku on 15/6/4. + */ +@JsonObject +public class Gist { + + @JsonField(name = "html_url") + String htmlUrl; + + public String getHtmlUrl() { + return htmlUrl; + } +} diff --git a/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/GistStatusShortenerService.java b/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/GistStatusShortenerService.java new file mode 100644 index 000000000..36fdc93ea --- /dev/null +++ b/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/GistStatusShortenerService.java @@ -0,0 +1,92 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2015 Mariotaku Lee + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.mariotaku.twidere.extension.shortener.gist; + +import android.app.Service; +import android.content.Intent; +import android.os.IBinder; +import android.os.RemoteException; + +import org.mariotaku.restfu.RestAPIFactory; +import org.mariotaku.twidere.IStatusShortener; +import org.mariotaku.twidere.model.ParcelableAccount; +import org.mariotaku.twidere.model.ParcelableStatusUpdate; +import org.mariotaku.twidere.model.StatusShortenResult; + +import java.lang.ref.WeakReference; + +/** + * Created by mariotaku on 15/6/4. + */ +public class GistStatusShortenerService extends Service { + + + private final StatusShortenerStub mBinder = new StatusShortenerStub(this); + + @Override + public IBinder onBind(final Intent intent) { + return mBinder; + } + + /** + * @return Shortened tweet. + */ + public StatusShortenResult shorten(final ParcelableStatusUpdate status, final String overrideStatusText) { + final Github github = getGithubInstance(); + try { + final String text = overrideStatusText != null ? overrideStatusText : status.text; + final ParcelableAccount account = status.accounts[0]; + final NewGist newGist = new NewGist(); + final Gist response = github.createGist(newGist); + if (response != null) return StatusShortenResult.getInstance(response.getHtmlUrl()); + } catch (final GithubException e) { + final int errorCode = e.getErrorCode() != 0 ? e.getErrorCode() : -1; + return StatusShortenResult.getInstance(errorCode, e.getMessage()); + } + return StatusShortenResult.getInstance(-1, "Unknown error"); + } + + private Github getGithubInstance() { + RestAPIFactory factory = new RestAPIFactory(); + return factory.build(Github.class); + } + + /* + * By making this a static class with a WeakReference to the Service, we + * ensure that the Service can be GCd even when the system process still has + * a remote reference to the stub. + */ + private static final class StatusShortenerStub extends IStatusShortener.Stub { + + final WeakReference mService; + + public StatusShortenerStub(final GistStatusShortenerService service) { + mService = new WeakReference<>(service); + } + + @Override + public StatusShortenResult shorten(final ParcelableStatusUpdate status, final String overrideStatusText) + throws RemoteException { + return mService.get().shorten(status, overrideStatusText); + } + + } + +} diff --git a/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/Github.java b/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/Github.java new file mode 100644 index 000000000..c795d839a --- /dev/null +++ b/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/Github.java @@ -0,0 +1,35 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2015 Mariotaku Lee + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.mariotaku.twidere.extension.shortener.gist; + +import org.mariotaku.restfu.annotation.method.POST; +import org.mariotaku.restfu.annotation.param.File; + +/** + * Created by mariotaku on 15/6/4. + */ +public interface Github { + + @POST("/gists") + Gist createGist(@File NewGist newGist) throws GithubException; + + + +} diff --git a/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/GithubException.java b/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/GithubException.java new file mode 100644 index 000000000..d46f7b322 --- /dev/null +++ b/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/GithubException.java @@ -0,0 +1,31 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2015 Mariotaku Lee + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.mariotaku.twidere.extension.shortener.gist; + +/** + * Created by mariotaku on 15/6/4. + */ +public class GithubException extends Exception { + private int errorCode; + + public int getErrorCode() { + return errorCode; + } +} diff --git a/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/NewGist.java b/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/NewGist.java new file mode 100644 index 000000000..e54aeda29 --- /dev/null +++ b/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/NewGist.java @@ -0,0 +1,26 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2015 Mariotaku Lee + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.mariotaku.twidere.extension.shortener.gist; + +/** + * Created by mariotaku on 15/6/4. + */ +public class NewGist { +} diff --git a/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/SettingsActivity.java b/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/SettingsActivity.java new file mode 100644 index 000000000..329036311 --- /dev/null +++ b/twidere.extension.shortener.gist/src/main/java/org/mariotaku/twidere/extension/shortener/gist/SettingsActivity.java @@ -0,0 +1,57 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2015 Mariotaku Lee + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.mariotaku.twidere.extension.shortener.gist; + +import android.os.Bundle; +import android.support.v4.app.FragmentActivity; +import android.view.Menu; +import android.view.MenuItem; + + +public class SettingsActivity extends FragmentActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_settings); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_settings, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} diff --git a/twidere.extension.shortener.gist/src/main/res/layout/activity_settings.xml b/twidere.extension.shortener.gist/src/main/res/layout/activity_settings.xml new file mode 100644 index 000000000..e3707c54b --- /dev/null +++ b/twidere.extension.shortener.gist/src/main/res/layout/activity_settings.xml @@ -0,0 +1,35 @@ + + + + + + + diff --git a/twidere.extension.shortener.gist/src/main/res/menu/menu_settings.xml b/twidere.extension.shortener.gist/src/main/res/menu/menu_settings.xml new file mode 100644 index 000000000..943df96e8 --- /dev/null +++ b/twidere.extension.shortener.gist/src/main/res/menu/menu_settings.xml @@ -0,0 +1,28 @@ + + + + + diff --git a/twidere.extension.shortener.gist/src/main/res/mipmap-hdpi/ic_launcher.png b/twidere.extension.shortener.gist/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..cde69bccc Binary files /dev/null and b/twidere.extension.shortener.gist/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/twidere.extension.shortener.gist/src/main/res/mipmap-mdpi/ic_launcher.png b/twidere.extension.shortener.gist/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..c133a0cbd Binary files /dev/null and b/twidere.extension.shortener.gist/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/twidere.extension.shortener.gist/src/main/res/mipmap-xhdpi/ic_launcher.png b/twidere.extension.shortener.gist/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..bfa42f0e7 Binary files /dev/null and b/twidere.extension.shortener.gist/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/twidere.extension.shortener.gist/src/main/res/mipmap-xxhdpi/ic_launcher.png b/twidere.extension.shortener.gist/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..324e72cdd Binary files /dev/null and b/twidere.extension.shortener.gist/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/twidere.extension.shortener.gist/src/main/res/values-w820dp/dimens.xml b/twidere.extension.shortener.gist/src/main/res/values-w820dp/dimens.xml new file mode 100644 index 000000000..214e164c4 --- /dev/null +++ b/twidere.extension.shortener.gist/src/main/res/values-w820dp/dimens.xml @@ -0,0 +1,25 @@ + + + + + 64dp + diff --git a/twidere.extension.shortener.gist/src/main/res/values/dimens.xml b/twidere.extension.shortener.gist/src/main/res/values/dimens.xml new file mode 100644 index 000000000..beec6817b --- /dev/null +++ b/twidere.extension.shortener.gist/src/main/res/values/dimens.xml @@ -0,0 +1,24 @@ + + + + + 16dp + 16dp + diff --git a/twidere.extension.shortener.gist/src/main/res/values/strings.xml b/twidere.extension.shortener.gist/src/main/res/values/strings.xml new file mode 100644 index 000000000..2efcc3233 --- /dev/null +++ b/twidere.extension.shortener.gist/src/main/res/values/strings.xml @@ -0,0 +1,25 @@ + + + + Twidere Gist Shortener Extension + + Hello world! + Settings + diff --git a/twidere.extension.shortener.gist/src/main/res/values/styles.xml b/twidere.extension.shortener.gist/src/main/res/values/styles.xml new file mode 100644 index 000000000..81f7cc913 --- /dev/null +++ b/twidere.extension.shortener.gist/src/main/res/values/styles.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/twidere.extension.twitlonger/src/main/java/org/mariotaku/twidere/extension/twitlonger/TwitLongerService.java b/twidere.extension.twitlonger/src/main/java/org/mariotaku/twidere/extension/twitlonger/TwitLongerService.java index 262dc641f..64c7644be 100644 --- a/twidere.extension.twitlonger/src/main/java/org/mariotaku/twidere/extension/twitlonger/TwitLongerService.java +++ b/twidere.extension.twitlonger/src/main/java/org/mariotaku/twidere/extension/twitlonger/TwitLongerService.java @@ -48,7 +48,7 @@ public class TwitLongerService extends Service implements Constants { final WeakReference mService; public TweetShortenerStub(TwitLongerService service) { - mService = new WeakReference(service); + mService = new WeakReference<>(service); } @Override diff --git a/twidere/src/main/java/org/mariotaku/twidere/activity/support/QuickSearchBarActivity.java b/twidere/src/main/java/org/mariotaku/twidere/activity/support/QuickSearchBarActivity.java index 872f3c67b..cfc7f2264 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/activity/support/QuickSearchBarActivity.java +++ b/twidere/src/main/java/org/mariotaku/twidere/activity/support/QuickSearchBarActivity.java @@ -84,6 +84,8 @@ import org.mariotaku.twidere.view.iface.IExtendedView.OnFitSystemWindowsListener import java.util.ArrayList; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Created by mariotaku on 15/1/6. @@ -516,6 +518,8 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On public static class SuggestionsLoader extends AsyncTaskLoader> { + private static final Pattern PATTERN_SCREEN_NAME = Pattern.compile("(?i)[@\uFF20]?([a-z0-9_]{1,20})"); + private final long mAccountId; private final String mQuery; @@ -553,7 +557,7 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On final OrderBy orderBy = new OrderBy(order, ascending); final Uri uri = Uri.withAppendedPath(CachedUsers.CONTENT_URI_WITH_SCORE, String.valueOf(mAccountId)); final Cursor usersCursor = context.getContentResolver().query(uri, - CachedUsers.COLUMNS, selection != null ? selection.getSQL() : null, + CachedUsers.COLUMNS, selection.getSQL(), selectionArgs, orderBy.getSQL()); final CachedIndices usersIndices = new CachedIndices(usersCursor); final int screenNamePos = result.size(); @@ -567,8 +571,11 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On hasName = true; } } - if (!hasName && mQuery.matches("(?i)[a-z0-9_]{1,20}")) { - result.add(screenNamePos, new UserScreenNameItem(mQuery, mAccountId)); + if (!hasName) { + final Matcher m = PATTERN_SCREEN_NAME.matcher(mQuery); + if (m.matches()) { + result.add(screenNamePos, new UserScreenNameItem(m.group(1), mAccountId)); + } } usersCursor.close(); } else { diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/RetweetQuoteDialogFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/RetweetQuoteDialogFragment.java index edfbc3dd2..c8f497277 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/RetweetQuoteDialogFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/RetweetQuoteDialogFragment.java @@ -107,7 +107,11 @@ public class RetweetQuoteDialogFragment extends BaseSupportDialogFragment implem builder.setView(view); builder.setTitle(R.string.retweet_quote_confirm_title); - builder.setPositiveButton(isMyRetweet(status) ? R.string.cancel_retweet : R.string.retweet, this); + if (isMyRetweet(status)) { + builder.setPositiveButton(R.string.cancel_retweet, this); + } else if (!status.user_is_protected) { + builder.setPositiveButton(R.string.retweet, this); + } builder.setNeutralButton(R.string.quote, this); builder.setNegativeButton(android.R.string.cancel, null); @@ -116,6 +120,7 @@ public class RetweetQuoteDialogFragment extends BaseSupportDialogFragment implem view.findViewById(R.id.item_menu).setVisibility(View.GONE); view.findViewById(R.id.action_buttons).setVisibility(View.GONE); view.findViewById(R.id.item_content).setFocusable(false); + view.findViewById(R.id.comment_container).setVisibility(status.user_is_protected ? View.GONE : View.VISIBLE); mEditComment = (UserHashtagAutoCompleteEditText) view.findViewById(R.id.edit_comment); mEditComment.setAccountId(status.account_id); mEditComment.setLengthChecker(new METLengthChecker() { diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFragment.java index 2e4416460..50b6d8d49 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFragment.java @@ -88,7 +88,6 @@ import com.squareup.otto.Subscribe; import org.mariotaku.querybuilder.Expression; import org.mariotaku.twidere.R; -import org.mariotaku.twidere.activity.iface.IControlBarActivity; import org.mariotaku.twidere.activity.iface.IThemedActivity; import org.mariotaku.twidere.activity.support.AccountSelectorActivity; import org.mariotaku.twidere.activity.support.ColorPickerDialogActivity; @@ -1181,8 +1180,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener @Override protected void fitSystemWindows(Rect insets) { final ThemedAppCompatActivity activity = (ThemedAppCompatActivity) getActivity(); - mHeaderDrawerLayout.setPadding(insets.left, Utils.getInsetsTopWithoutActionBarHeight(activity, insets.top), - insets.right, insets.bottom); + mHeaderDrawerLayout.setPadding(insets.left, insets.top, insets.right, insets.bottom); final String backgroundOption = activity.getCurrentThemeBackgroundOption(); final boolean isTransparentBackground = ThemeUtils.isTransparentBackground(backgroundOption); mHeaderDrawerLayout.setClipToPadding(isTransparentBackground); @@ -1497,8 +1495,6 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener profileBannerContainer.setTranslationY(-offset); profileBannerView.setTranslationY(offset / 2); - final ThemedAppCompatActivity activity = (ThemedAppCompatActivity) getActivity(); - if (mActionBarBackground != null && mTintedStatusContent != null) { mActionBarBackground.setFactor(factor); mTintedStatusContent.setFactor(factor); @@ -1512,6 +1508,8 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener } mActionBarBackground.setOutlineAlphaFactor(tabOutlineAlphaFactor); + final ThemedAppCompatActivity activity = (ThemedAppCompatActivity) getActivity(); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { setCompatToolbarOverlayAlpha(activity, factor * tabOutlineAlphaFactor); }