Skip to content
Snippets Groups Projects
Commit 88a0e436 authored by John Carlson's avatar John Carlson
Browse files

Remove app-theme-engine RIP in peace

parent fff11741
No related branches found
No related tags found
No related merge requests found
Pipeline #
Showing
with 44 additions and 886 deletions
Loading
Loading
@@ -89,9 +89,7 @@ dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}
compile('com.github.afollestad:app-theme-engine:1.0.1@aar') {
transitive = true
}
compile('com.github.afollestad.material-dialogs:core:0.8.5.8@aar') {
transitive = true
}
Loading
Loading
Loading
Loading
@@ -48,7 +48,6 @@
<activity android:name=".activity.AddIssueActivity"/>
<activity android:name=".activity.MilestoneActivity"/>
<activity android:name=".activity.AddMilestoneActivity"/>
<activity android:name=".activity.SettingsActivity"/>
<activity android:name=".activity.BuildActivity"/>
<activity android:name=".activity.LoadSomeInfoActivity"
android:theme="@style/Activity.Translucent"/>
Loading
Loading
Loading
Loading
@@ -10,7 +10,6 @@ import android.support.v4.widget.DrawerLayout;
import android.support.v7.widget.Toolbar;
import android.view.View;
 
import com.afollestad.appthemeengine.customizers.ATEActivityThemeCustomizer;
import com.commit451.gitlab.LabCoatApp;
import com.commit451.gitlab.R;
import com.commit451.gitlab.api.GitLabClient;
Loading
Loading
@@ -25,16 +24,10 @@ import timber.log.Timber;
/**
* Displays the current users projects feed
*/
public class ActivityActivity extends BaseActivity implements ATEActivityThemeCustomizer {
public class ActivityActivity extends BaseActivity {
 
private static final String TAG_FEED_FRAGMENT = "feed_fragment";
 
@Override
public int getActivityTheme() {
return PreferenceManager.getDefaultSharedPreferences(this).getBoolean("dark_theme", true) ?
R.style.Activity_Activity : R.style.ActivityLight_Activity;
}
public static Intent newInstance(Context context) {
Intent intent = new Intent(context, ActivityActivity.class);
return intent;
Loading
Loading
Loading
Loading
@@ -3,7 +3,6 @@ package com.commit451.gitlab.activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TextInputLayout;
Loading
Loading
@@ -16,7 +15,6 @@ import android.widget.FrameLayout;
import android.widget.Spinner;
import android.widget.TextView;
 
import com.afollestad.appthemeengine.customizers.ATEActivityThemeCustomizer;
import com.commit451.gitlab.LabCoatApp;
import com.commit451.gitlab.R;
import com.commit451.gitlab.adapter.AddIssueLabelAdapter;
Loading
Loading
@@ -50,13 +48,7 @@ import timber.log.Timber;
/**
* Activity to input new issues, but not really a dialog at all wink wink
*/
public class AddIssueActivity extends MorphActivity implements ATEActivityThemeCustomizer {
@Override
public int getActivityTheme() {
return PreferenceManager.getDefaultSharedPreferences(this).getBoolean("dark_theme", true) ?
R.style.Activity_Translucent : R.style.ActivityLight_Translucent;
}
public class AddIssueActivity extends MorphActivity {
 
private static final String KEY_PROJECT = "project";
private static final String KEY_ISSUE = "issue";
Loading
Loading
Loading
Loading
@@ -4,7 +4,6 @@ package com.commit451.gitlab.activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TextInputLayout;
Loading
Loading
@@ -16,7 +15,7 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
 
import com.afollestad.appthemeengine.customizers.ATEActivityThemeCustomizer;
import com.commit451.easel.Easel;
import com.commit451.gitlab.LabCoatApp;
import com.commit451.gitlab.R;
import com.commit451.gitlab.api.EasyCallback;
Loading
Loading
@@ -24,7 +23,6 @@ import com.commit451.gitlab.api.GitLabClient;
import com.commit451.gitlab.event.MilestoneChangedEvent;
import com.commit451.gitlab.event.MilestoneCreatedEvent;
import com.commit451.gitlab.model.api.Milestone;
import com.commit451.gitlab.util.AppThemeUtil;
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
 
import org.parceler.Parcels;
Loading
Loading
@@ -38,13 +36,7 @@ import butterknife.OnClick;
import retrofit2.Callback;
import timber.log.Timber;
 
public class AddMilestoneActivity extends MorphActivity implements ATEActivityThemeCustomizer {
@Override
public int getActivityTheme() {
return PreferenceManager.getDefaultSharedPreferences(this).getBoolean("dark_theme", true) ?
R.style.Activity_Translucent : R.style.ActivityLight_Translucent;
}
public class AddMilestoneActivity extends MorphActivity {
 
private static final String KEY_PROJECT_ID = "project_id";
private static final String KEY_MILESTONE = "milestone";
Loading
Loading
@@ -89,7 +81,7 @@ public class AddMilestoneActivity extends MorphActivity implements ATEActivityTh
now.get(Calendar.MONTH),
now.get(Calendar.DAY_OF_MONTH)
);
dpd.setAccentColor(AppThemeUtil.resolveAccentColor(this));
dpd.setAccentColor(Easel.getThemeAttrColor(this, R.attr.colorAccent));
dpd.show(getFragmentManager(), "date_picker");
}
 
Loading
Loading
Loading
Loading
@@ -3,22 +3,15 @@ package com.commit451.gitlab.activity;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
 
import com.afollestad.appthemeengine.ATEActivity;
import com.commit451.gitlab.R;
 
/**
* Base activity for others to derive from
*/
public class BaseActivity extends ATEActivity {
@Nullable
@Override
public final String getATEKey() {
return PreferenceManager.getDefaultSharedPreferences(this).getBoolean("dark_theme", true) ?
"dark_theme" : "light_theme";
}
public class BaseActivity extends AppCompatActivity {
 
public boolean hasEmptyFields(TextInputLayout... textInputLayouts) {
boolean hasEmptyField = false;
Loading
Loading
Loading
Loading
@@ -8,7 +8,6 @@ import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.Snackbar;
Loading
Loading
@@ -19,9 +18,6 @@ import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
 
import com.afollestad.appthemeengine.Config;
import com.afollestad.appthemeengine.customizers.ATEActivityThemeCustomizer;
import com.afollestad.appthemeengine.util.ATEUtil;
import com.commit451.easel.Easel;
import com.commit451.gitlab.R;
import com.commit451.gitlab.adapter.GroupPagerAdapter;
Loading
Loading
@@ -30,7 +26,6 @@ import com.commit451.gitlab.api.GitLabClient;
import com.commit451.gitlab.model.api.Group;
import com.commit451.gitlab.model.api.GroupDetail;
import com.commit451.gitlab.transformation.PaletteTransformation;
import com.commit451.gitlab.util.AppThemeUtil;
 
import org.parceler.Parcels;
 
Loading
Loading
@@ -42,13 +37,7 @@ import timber.log.Timber;
/**
* See the things about the group
*/
public class GroupActivity extends BaseActivity implements ATEActivityThemeCustomizer {
@Override
public int getActivityTheme() {
return PreferenceManager.getDefaultSharedPreferences(this).getBoolean("dark_theme", true) ?
R.style.Activity_Group : R.style.ActivityLight_Group;
}
public class GroupActivity extends BaseActivity {
 
private static final String KEY_GROUP = "key_group";
private static final String KEY_GROUP_ID = "key_group_id";
Loading
Loading
@@ -95,10 +84,6 @@ public class GroupActivity extends BaseActivity implements ATEActivityThemeCusto
ButterKnife.bind(this);
 
// Default content and scrim colors
mCollapsingToolbarLayout.setContentScrimColor(
Config.primaryColor(this, AppThemeUtil.resolveThemeKey(this)));
mCollapsingToolbarLayout.setStatusBarScrimColor(
Config.primaryColorDark(this, AppThemeUtil.resolveThemeKey(this)));
 
mToolbar.setNavigationIcon(R.drawable.ic_back_24dp);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
Loading
Loading
@@ -143,8 +128,8 @@ public class GroupActivity extends BaseActivity implements ATEActivityThemeCusto
 
private void bindPalette(Palette palette) {
int animationTime = 1000;
int vibrantColor = palette.getVibrantColor(AppThemeUtil.resolvePrimaryColor(this));
int darkerColor = ATEUtil.darkenColor(vibrantColor);
int vibrantColor = palette.getVibrantColor(Easel.getThemeAttrColor(this, R.attr.colorAccent));
int darkerColor = Easel.getDarkerColor(vibrantColor);
 
if (Build.VERSION.SDK_INT >= 21) {
Easel.getNavigationBarColorAnimator(getWindow(), darkerColor)
Loading
Loading
Loading
Loading
@@ -16,7 +16,6 @@ import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;
 
import com.afollestad.appthemeengine.customizers.ATEActivityThemeCustomizer;
import com.commit451.gitlab.LabCoatApp;
import com.commit451.gitlab.R;
import com.commit451.gitlab.adapter.GroupAdapter;
Loading
Loading
@@ -39,13 +38,7 @@ import timber.log.Timber;
/**
* Displays the groups of the current user
*/
public class GroupsActivity extends BaseActivity implements ATEActivityThemeCustomizer {
@Override
public int getActivityTheme() {
return PreferenceManager.getDefaultSharedPreferences(this).getBoolean("dark_theme", true) ?
R.style.Activity_Groups : R.style.ActivityLight_Groups;
}
public class GroupsActivity extends BaseActivity {
 
public static Intent newInstance(Context context) {
Intent intent = new Intent(context, GroupsActivity.class);
Loading
Loading
Loading
Loading
@@ -10,11 +10,9 @@ import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
 
import com.commit451.gitlab.LabCoatApp;
Loading
Loading
@@ -27,9 +25,10 @@ import com.commit451.gitlab.event.IssueReloadEvent;
import com.commit451.gitlab.model.api.Issue;
import com.commit451.gitlab.model.api.Note;
import com.commit451.gitlab.model.api.Project;
import com.commit451.gitlab.util.IntentUtil;
import com.commit451.gitlab.navigation.NavigationManager;
import com.commit451.gitlab.util.IntentUtil;
import com.commit451.gitlab.util.PaginationUtil;
import com.commit451.gitlab.view.SendMessageView;
import com.commit451.teleprinter.Teleprinter;
import com.squareup.otto.Subscribe;
 
Loading
Loading
@@ -79,16 +78,11 @@ public class IssueActivity extends BaseActivity {
SwipeRefreshLayout mSwipeRefreshLayout;
@BindView(R.id.list)
RecyclerView mNotesRecyclerView;
@BindView(R.id.new_note_edit)
EditText mNewNoteEdit;
@BindView(R.id.send_message_view)
SendMessageView mSendMessageView;
@BindView(R.id.progress)
View mProgress;
 
@OnClick(R.id.new_note_button)
public void onNewNoteClick() {
postNote();
}
@OnClick(R.id.fab_edit_issue)
public void onEditIssueClick(View fab) {
NavigationManager.navigateToEditIssue(IssueActivity.this, fab, mProject, mIssue);
Loading
Loading
@@ -278,11 +272,10 @@ public class IssueActivity extends BaseActivity {
mNotesRecyclerView.setLayoutManager(mNotesLayoutManager);
mNotesRecyclerView.addOnScrollListener(mOnScrollListener);
 
mNewNoteEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
mSendMessageView.setCallbacks(new SendMessageView.Callbacks() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
postNote();
return true;
public void onSendClicked(String message) {
postNote(message);
}
});
 
Loading
Loading
@@ -345,10 +338,9 @@ public class IssueActivity extends BaseActivity {
GitLabClient.instance().getIssueNotes(mNextPageUrl.toString()).enqueue(mMoreNotesCallback);
}
 
private void postNote() {
String body = mNewNoteEdit.getText().toString();
private void postNote(String message) {
 
if (body.length() < 1) {
if (message.length() < 1) {
return;
}
 
Loading
Loading
@@ -357,9 +349,9 @@ public class IssueActivity extends BaseActivity {
mProgress.animate().alpha(1.0f);
// Clear text & collapse keyboard
mTeleprinter.hideKeyboard();
mNewNoteEdit.setText("");
mSendMessageView.clearText();
 
GitLabClient.instance().addIssueNote(mProject.getId(), mIssue.getId(), body).enqueue(mPostNoteCallback);
GitLabClient.instance().addIssueNote(mProject.getId(), mIssue.getId(), message).enqueue(mPostNoteCallback);
}
 
private void closeOrOpenIssue() {
Loading
Loading
Loading
Loading
@@ -6,7 +6,6 @@ import android.os.Bundle;
import com.commit451.gitlab.BuildConfig;
import com.commit451.gitlab.data.Prefs;
import com.commit451.gitlab.model.Account;
import com.commit451.gitlab.util.AppThemeUtil;
import com.commit451.gitlab.ssl.CustomKeyManager;
import com.commit451.gitlab.navigation.NavigationManager;
 
Loading
Loading
@@ -22,7 +21,6 @@ public class LaunchActivity extends Activity {
 
@Override
protected void onCreate(Bundle savedInstanceState) {
AppThemeUtil.setupDefaultConfigs(this);
super.onCreate(savedInstanceState);
 
int savedVersion = Prefs.getSavedVersion(this);
Loading
Loading
Loading
Loading
@@ -10,12 +10,10 @@ import android.view.View;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
 
import com.afollestad.appthemeengine.Config;
import com.commit451.easel.Easel;
import com.commit451.gitlab.R;
import com.commit451.gitlab.transition.MorphDialogToFab;
import com.commit451.gitlab.transition.MorphFabToDialog;
import com.commit451.gitlab.util.AppThemeUtil;
 
/**
* Activity that morphs from a FAB. Make sure the view you want to morph has the view id R.id.mRoot and
Loading
Loading
@@ -29,7 +27,7 @@ public class MorphActivity extends BaseActivity {
throw new IllegalStateException("Cannot pass an empty view");
}
if (Build.VERSION.SDK_INT >= 21) {
int fabColor = Config.accentColor(this, AppThemeUtil.resolveThemeKey(this));
int fabColor = Easel.getThemeAttrColor(this, R.attr.colorAccent);
int dialogColor = Easel.getThemeAttrColor(this, android.R.attr.windowBackground);
setupSharedElementTransitionsFab(this, root,
fabColor,
Loading
Loading
Loading
Loading
@@ -15,6 +15,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
Loading
Loading
@@ -22,7 +23,6 @@ import android.widget.Toast;
import com.commit451.gitlab.LabCoatApp;
import com.commit451.gitlab.R;
import com.commit451.gitlab.adapter.SectionsPagerAdapter;
import com.commit451.gitlab.adapter.ThemedArrayAdapter;
import com.commit451.gitlab.animation.HideRunnable;
import com.commit451.gitlab.api.EasyCallback;
import com.commit451.gitlab.api.GitLabClient;
Loading
Loading
@@ -124,7 +124,7 @@ public class ProjectActivity extends BaseActivity {
mBranchSpinner.setAlpha(0.0f);
mBranchSpinner.animate().alpha(1.0f);
// Set up the dropdown list navigation in the action bar.
mBranchSpinner.setAdapter(new ThemedArrayAdapter<>(ProjectActivity.this, android.R.layout.simple_list_item_1, android.R.id.text1, response));
mBranchSpinner.setAdapter(new ArrayAdapter<>(ProjectActivity.this, android.R.layout.simple_list_item_1, android.R.id.text1, response));
}
for (int i = 0; i < response.size(); i++) {
if (response.get(i).getName().equals(mProject.getDefaultBranch())) {
Loading
Loading
Loading
Loading
@@ -13,7 +13,6 @@ import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
 
import com.afollestad.appthemeengine.customizers.ATEActivityThemeCustomizer;
import com.commit451.gitlab.LabCoatApp;
import com.commit451.gitlab.R;
import com.commit451.gitlab.adapter.ProjectsPagerAdapter;
Loading
Loading
@@ -27,13 +26,7 @@ import butterknife.ButterKnife;
/**
* Shows the projects
*/
public class ProjectsActivity extends BaseActivity implements ATEActivityThemeCustomizer {
@Override
public int getActivityTheme() {
return PreferenceManager.getDefaultSharedPreferences(this).getBoolean("dark_theme", true) ?
R.style.Activity_Projects : R.style.ActivityLight_Projects;
}
public class ProjectsActivity extends BaseActivity {
 
public static Intent newInstance(Context context) {
Intent intent = new Intent(context, ProjectsActivity.class);
Loading
Loading
package com.commit451.gitlab.activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.v7.widget.Toolbar;
import android.view.View;
import com.afollestad.appthemeengine.ATE;
import com.afollestad.appthemeengine.Config;
import com.afollestad.appthemeengine.prefs.ATEColorPreference;
import com.afollestad.materialdialogs.color.ColorChooserDialog;
import com.commit451.gitlab.R;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* Settings screens are fun!
*/
public class SettingsActivity extends BaseActivity
implements ColorChooserDialog.ColorCallback {
public static Intent newInstance(Context context) {
Intent intent = new Intent(context, SettingsActivity.class);
return intent;
}
@BindView(R.id.toolbar) Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
ButterKnife.bind(this);
toolbar.setNavigationIcon(R.drawable.ic_back_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
toolbar.setTitle(R.string.settings);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction().replace(R.id.settings_container, new SettingsFragment()).commit();
} else {
SettingsFragment frag = (SettingsFragment) getFragmentManager().findFragmentById(R.id.settings_container);
if (frag != null) {
frag.invalidateSettings();
}
}
}
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor) {
final Config config = ATE.config(this, getATEKey());
switch (dialog.getTitle()) {
case R.string.primary_color:
config.primaryColor(selectedColor);
break;
case R.string.accent_color:
config.accentColor(selectedColor);
break;
}
config.commit();
recreate(); // recreation needed to reach the checkboxes in the preferences layout
}
public static class SettingsFragment extends PreferenceFragment {
String mAteKey;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
invalidateSettings();
}
public void invalidateSettings() {
mAteKey = ((SettingsActivity) getActivity()).getATEKey();
ATEColorPreference primaryColorPref = (ATEColorPreference) findPreference("primary_color");
primaryColorPref.setColor(Config.primaryColor(getActivity(), mAteKey), Color.BLACK);
primaryColorPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
new ColorChooserDialog.Builder((SettingsActivity) getActivity(), R.string.primary_color)
.preselect(Config.primaryColor(getActivity(), mAteKey))
.show();
return true;
}
});
ATEColorPreference accentColorPref = (ATEColorPreference) findPreference("accent_color");
accentColorPref.setColor(Config.accentColor(getActivity(), mAteKey), Color.BLACK);
accentColorPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
new ColorChooserDialog.Builder((SettingsActivity) getActivity(), R.string.accent_color)
.preselect(Config.accentColor(getActivity(), mAteKey))
.show();
return true;
}
});
findPreference("dark_theme").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// Marks both theme configs as changed so MainActivity restarts itself on return
Config.markChanged(getActivity(), "light_theme");
Config.markChanged(getActivity(), "dark_theme");
// The dark_theme preference value gets saved by Android in the default PreferenceManager.
// It's used in getATEKey() of both the Activities.
getActivity().recreate();
return true;
}
});
}
}
}
Loading
Loading
@@ -9,7 +9,6 @@ import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.graphics.Palette;
Loading
Loading
@@ -17,15 +16,11 @@ import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
 
import com.afollestad.appthemeengine.Config;
import com.afollestad.appthemeengine.customizers.ATEActivityThemeCustomizer;
import com.afollestad.appthemeengine.util.ATEUtil;
import com.commit451.easel.Easel;
import com.commit451.gitlab.R;
import com.commit451.gitlab.api.GitLabClient;
import com.commit451.gitlab.fragment.FeedFragment;
import com.commit451.gitlab.model.api.UserBasic;
import com.commit451.gitlab.util.AppThemeUtil;
import com.commit451.gitlab.transformation.PaletteTransformation;
import com.commit451.gitlab.util.ImageUtil;
 
Loading
Loading
@@ -37,13 +32,7 @@ import butterknife.ButterKnife;
/**
* User activity, which shows the user!
*/
public class UserActivity extends BaseActivity implements ATEActivityThemeCustomizer {
@Override
public int getActivityTheme() {
return PreferenceManager.getDefaultSharedPreferences(this).getBoolean("dark_theme", true) ?
R.style.Activity_User : R.style.ActivityLight_User;
}
public class UserActivity extends BaseActivity {
 
private static final String KEY_USER = "user";
 
Loading
Loading
@@ -67,10 +56,6 @@ public class UserActivity extends BaseActivity implements ATEActivityThemeCustom
mUser = Parcels.unwrap(getIntent().getParcelableExtra(KEY_USER));
 
// Default content and scrim colors
mCollapsingToolbarLayout.setContentScrimColor(
Config.primaryColor(this, AppThemeUtil.resolveThemeKey(this)));
mCollapsingToolbarLayout.setStatusBarScrimColor(
Config.primaryColorDark(this, AppThemeUtil.resolveThemeKey(this)));
mCollapsingToolbarLayout.setCollapsedTitleTextColor(Color.WHITE);
mCollapsingToolbarLayout.setExpandedTitleColor(Color.WHITE);
 
Loading
Loading
@@ -110,8 +95,8 @@ public class UserActivity extends BaseActivity implements ATEActivityThemeCustom
 
private void bindPalette(Palette palette) {
int animationTime = 1000;
int vibrantColor = palette.getVibrantColor(AppThemeUtil.resolvePrimaryColor(this));
int darkerColor = ATEUtil.darkenColor(vibrantColor);
int vibrantColor = palette.getVibrantColor(Easel.getThemeAttrColor(this, R.attr.colorPrimary));
int darkerColor = Easel.getDarkerColor(vibrantColor);
 
if (Build.VERSION.SDK_INT >= 21) {
Easel.getNavigationBarColorAnimator(getWindow(), darkerColor)
Loading
Loading
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.commit451.gitlab.adapter;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.support.annotation.ArrayRes;
import android.support.annotation.IdRes;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.v7.view.ContextThemeWrapper;
import android.support.v7.widget.ThemedSpinnerAdapter;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.TextView;
import com.afollestad.appthemeengine.Config;
import com.afollestad.appthemeengine.util.ATEUtil;
import com.commit451.gitlab.util.AppThemeUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* An Adapter derived from ArrayAdapter that also allows theming with AppThemeEngine
*/
public class ThemedArrayAdapter<T> extends BaseAdapter implements Filterable, ThemedSpinnerAdapter {
/**
* Lock used to modify the content of {@link #mObjects}. Any write operation
* performed on the array should be synchronized on this lock. This lock is also
* used by the filter (see {@link #getFilter()} to make a synchronized copy of
* the original array of data.
*/
private final Object mLock = new Object();
private final LayoutInflater mInflater;
/**
* Contains the list of objects that represent the data of this ThemedArrayAdapter.
* The content of this list is referred to as "the array" in the documentation.
*/
private List<T> mObjects;
/**
* The resource indicating what views to inflate to display the content of this
* array adapter.
*/
private int mResource;
/**
* The resource indicating what views to inflate to display the content of this
* array adapter in a drop down widget.
*/
private int mDropDownResource;
/**
* If the inflated resource is not a TextView, {@link #mFieldId} is used to find
* a TextView inside the inflated views hierarchy. This field must contain the
* identifier that matches the one defined in the resource file.
*/
private int mFieldId = 0;
/**
* Indicates whether or not {@link #notifyDataSetChanged()} must be called whenever
* {@link #mObjects} is modified.
*/
private boolean mNotifyOnChange = true;
private Context mContext;
// A copy of the original mObjects array, initialized from and then used instead as soon as
// the mFilter ArrayFilter is used. mObjects will then only contain the filtered values.
private ArrayList<T> mOriginalValues;
private ArrayFilter mFilter;
/** Layout inflater used for {@link #getDropDownView(int, View, ViewGroup)}. */
private LayoutInflater mDropDownInflater;
/**
* Constructor
*
* @param context The current context.
* @param resource The resource ID for a layout file containing a TextView to use when
* instantiating views.
*/
public ThemedArrayAdapter(Context context, @LayoutRes int resource) {
this(context, resource, 0, new ArrayList<T>());
}
/**
* Constructor
*
* @param context The current context.
* @param resource The resource ID for a layout file containing a layout to use when
* instantiating views.
* @param textViewResourceId The id of the TextView within the layout resource to be populated
*/
public ThemedArrayAdapter(Context context, @LayoutRes int resource, @IdRes int textViewResourceId) {
this(context, resource, textViewResourceId, new ArrayList<T>());
}
/**
* Constructor
*
* @param context The current context.
* @param resource The resource ID for a layout file containing a TextView to use when
* instantiating views.
* @param objects The objects to represent in the ListView.
*/
public ThemedArrayAdapter(Context context, @LayoutRes int resource, @NonNull T[] objects) {
this(context, resource, 0, Arrays.asList(objects));
}
/**
* Constructor
*
* @param context The current context.
* @param resource The resource ID for a layout file containing a layout to use when
* instantiating views.
* @param textViewResourceId The id of the TextView within the layout resource to be populated
* @param objects The objects to represent in the ListView.
*/
public ThemedArrayAdapter(Context context, @LayoutRes int resource, @IdRes int textViewResourceId,
@NonNull T[] objects) {
this(context, resource, textViewResourceId, Arrays.asList(objects));
}
/**
* Constructor
*
* @param context The current context.
* @param resource The resource ID for a layout file containing a TextView to use when
* instantiating views.
* @param objects The objects to represent in the ListView.
*/
public ThemedArrayAdapter(Context context, @LayoutRes int resource, @NonNull List<T> objects) {
this(context, resource, 0, objects);
}
/**
* Constructor
*
* @param context The current context.
* @param resource The resource ID for a layout file containing a layout to use when
* instantiating views.
* @param textViewResourceId The id of the TextView within the layout resource to be populated
* @param objects The objects to represent in the ListView.
*/
public ThemedArrayAdapter(Context context, @LayoutRes int resource, @IdRes int textViewResourceId,
@NonNull List<T> objects) {
mContext = context;
mInflater = LayoutInflater.from(context);
mResource = mDropDownResource = resource;
mObjects = objects;
mFieldId = textViewResourceId;
}
/**
* Adds the specified object at the end of the array.
*
* @param object The object to add at the end of the array.
*/
public void add(T object) {
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.add(object);
} else {
mObjects.add(object);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
}
/**
* Adds the specified Collection at the end of the array.
*
* @param collection The Collection to add at the end of the array.
*/
public void addAll(Collection<? extends T> collection) {
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.addAll(collection);
} else {
mObjects.addAll(collection);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
}
/**
* Adds the specified items at the end of the array.
*
* @param items The items to add at the end of the array.
*/
public void addAll(T ... items) {
synchronized (mLock) {
if (mOriginalValues != null) {
Collections.addAll(mOriginalValues, items);
} else {
Collections.addAll(mObjects, items);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
}
/**
* Inserts the specified object at the specified index in the array.
*
* @param object The object to insert into the array.
* @param index The index at which the object must be inserted.
*/
public void insert(T object, int index) {
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.add(index, object);
} else {
mObjects.add(index, object);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
}
/**
* Removes the specified object from the array.
*
* @param object The object to remove.
*/
public void remove(T object) {
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.remove(object);
} else {
mObjects.remove(object);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
}
/**
* Remove all elements from the list.
*/
public void clear() {
synchronized (mLock) {
if (mOriginalValues != null) {
mOriginalValues.clear();
} else {
mObjects.clear();
}
}
if (mNotifyOnChange) notifyDataSetChanged();
}
/**
* Sorts the content of this adapter using the specified comparator.
*
* @param comparator The comparator used to sort the objects contained
* in this adapter.
*/
public void sort(Comparator<? super T> comparator) {
synchronized (mLock) {
if (mOriginalValues != null) {
Collections.sort(mOriginalValues, comparator);
} else {
Collections.sort(mObjects, comparator);
}
}
if (mNotifyOnChange) notifyDataSetChanged();
}
/**
* {@inheritDoc}
*/
@Override
public void notifyDataSetChanged() {
super.notifyDataSetChanged();
mNotifyOnChange = true;
}
/**
* Control whether methods that change the list ({@link #add},
* {@link #insert}, {@link #remove}, {@link #clear}) automatically call
* {@link #notifyDataSetChanged}. If set to false, caller must
* manually call notifyDataSetChanged() to have the changes
* reflected in the attached view.
*
* The default is true, and calling notifyDataSetChanged()
* resets the flag to true.
*
* @param notifyOnChange if true, modifications to the list will
* automatically call {@link
* #notifyDataSetChanged}
*/
public void setNotifyOnChange(boolean notifyOnChange) {
mNotifyOnChange = notifyOnChange;
}
/**
* Returns the context associated with this array adapter. The context is used
* to create views from the resource passed to the constructor.
*
* @return The Context associated with this adapter.
*/
public Context getContext() {
return mContext;
}
/**
* {@inheritDoc}
*/
public int getCount() {
return mObjects.size();
}
/**
* {@inheritDoc}
*/
public T getItem(int position) {
return mObjects.get(position);
}
/**
* Returns the position of the specified item in the array.
*
* @param item The item to retrieve the position of.
*
* @return The position of the specified item.
*/
public int getPosition(T item) {
return mObjects.indexOf(item);
}
/**
* {@inheritDoc}
*/
public long getItemId(int position) {
return position;
}
/**
* {@inheritDoc}
*/
public View getView(int position, View convertView, ViewGroup parent) {
return createViewFromResource(mInflater, position, convertView, parent, mResource, false);
}
private View createViewFromResource(LayoutInflater inflater, int position, View convertView,
ViewGroup parent, int resource, boolean dropdown) {
View view;
TextView text;
if (convertView == null) {
view = inflater.inflate(resource, parent, false);
} else {
view = convertView;
}
try {
if (mFieldId == 0) {
// If no custom field is assigned, assume the whole resource is a TextView
text = (TextView) view;
} else {
// Otherwise, find the TextView field within the layout
text = (TextView) view.findViewById(mFieldId);
}
} catch (ClassCastException e) {
Log.e("ThemedArrayAdapter", "You must supply a resource ID for a TextView");
throw new IllegalStateException(
"ThemedArrayAdapter requires the resource ID to be a TextView", e);
}
// Theme the TextView with AppThemeEngine values
if (dropdown) {
text.setTextColor(Config.textColorPrimary(view.getContext(),
AppThemeUtil.resolveThemeKey(view.getContext())));
} else {
text.setTextColor(ATEUtil.isColorLight(Config.primaryColor(view.getContext(),
AppThemeUtil.resolveThemeKey(view.getContext()))) ? Color.BLACK : Color.WHITE);
}
T item = getItem(position);
if (item instanceof CharSequence) {
text.setText((CharSequence)item);
} else {
text.setText(item.toString());
}
return view;
}
/**
* <p>Sets the layout resource to create the drop down views.</p>
*
* @param resource the layout resource defining the drop down views
* @see #getDropDownView(int, android.view.View, android.view.ViewGroup)
*/
public void setDropDownViewResource(@LayoutRes int resource) {
this.mDropDownResource = resource;
}
/**
* Sets the {@link Resources.Theme} against which drop-down views are
* inflated.
* <p>
* By default, drop-down views are inflated against the theme of the
* {@link Context} passed to the adapter's constructor.
*
* @param theme the theme against which to inflate drop-down views or
* {@code null} to use the theme from the adapter's context
* @see #getDropDownView(int, View, ViewGroup)
*/
@Override
public void setDropDownViewTheme(Resources.Theme theme) {
if (theme == null) {
mDropDownInflater = null;
} else if (theme == mInflater.getContext().getTheme()) {
mDropDownInflater = mInflater;
} else {
final Context context = new ContextThemeWrapper(mContext, theme);
mDropDownInflater = LayoutInflater.from(context);
}
}
@Override
public Resources.Theme getDropDownViewTheme() {
return mDropDownInflater == null ? null : mDropDownInflater.getContext().getTheme();
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
final LayoutInflater inflater = mDropDownInflater == null ? mInflater : mDropDownInflater;
return createViewFromResource(inflater, position, convertView, parent, mDropDownResource, true);
}
/**
* Creates a new ThemedArrayAdapter from external resources. The content of the array is
* obtained through {@link android.content.res.Resources#getTextArray(int)}.
*
* @param context The application's environment.
* @param textArrayResId The identifier of the array to use as the data source.
* @param textViewResId The identifier of the layout used to create views.
*
* @return An ThemedArrayAdapter<CharSequence>.
*/
public static ThemedArrayAdapter<CharSequence> createFromResource(Context context,
@ArrayRes int textArrayResId, @LayoutRes int textViewResId) {
CharSequence[] strings = context.getResources().getTextArray(textArrayResId);
return new ThemedArrayAdapter<CharSequence>(context, textViewResId, strings);
}
/**
* {@inheritDoc}
*/
public Filter getFilter() {
if (mFilter == null) {
mFilter = new ArrayFilter();
}
return mFilter;
}
/**
* <p>An array filter constrains the content of the array adapter with
* a prefix. Each item that does not start with the supplied prefix
* is removed from the list.</p>
*/
private class ArrayFilter extends Filter {
@Override
protected FilterResults performFiltering(CharSequence prefix) {
FilterResults results = new FilterResults();
if (mOriginalValues == null) {
synchronized (mLock) {
mOriginalValues = new ArrayList<T>(mObjects);
}
}
if (prefix == null || prefix.length() == 0) {
ArrayList<T> list;
synchronized (mLock) {
list = new ArrayList<T>(mOriginalValues);
}
results.values = list;
results.count = list.size();
} else {
String prefixString = prefix.toString().toLowerCase();
ArrayList<T> values;
synchronized (mLock) {
values = new ArrayList<T>(mOriginalValues);
}
final int count = values.size();
final ArrayList<T> newValues = new ArrayList<T>();
for (int i = 0; i < count; i++) {
final T value = values.get(i);
final String valueText = value.toString().toLowerCase();
// First match against the whole, non-splitted value
if (valueText.startsWith(prefixString)) {
newValues.add(value);
} else {
final String[] words = valueText.split(" ");
final int wordCount = words.length;
// Start at index 0, in case valueText starts with space(s)
for (int k = 0; k < wordCount; k++) {
if (words[k].startsWith(prefixString)) {
newValues.add(value);
break;
}
}
}
}
results.values = newValues;
results.count = newValues.size();
}
return results;
}
@Override
protected void publishResults(CharSequence constraint, Filter.FilterResults results) {
//noinspection unchecked
mObjects = (List<T>) results.values;
if (results.count > 0) {
notifyDataSetChanged();
} else {
notifyDataSetInvalidated();
}
}
}
}
\ No newline at end of file
package com.commit451.gitlab.fragment;
 
import com.afollestad.appthemeengine.ATE;
import com.commit451.gitlab.LabCoatApp;
import com.commit451.gitlab.event.ReloadDataEvent;
import com.commit451.gitlab.util.AppThemeUtil;
import com.squareup.otto.Subscribe;
 
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;
 
import com.commit451.gitlab.LabCoatApp;
import com.commit451.gitlab.event.ReloadDataEvent;
import com.squareup.otto.Subscribe;
public class BaseFragment extends Fragment{
 
private EventReceiver mBaseEventReceiever;
Loading
Loading
Loading
Loading
@@ -8,12 +8,9 @@ import android.support.design.widget.Snackbar;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
 
import com.commit451.gitlab.LabCoatApp;
import com.commit451.gitlab.R;
Loading
Loading
@@ -25,6 +22,7 @@ import com.commit451.gitlab.model.api.MergeRequest;
import com.commit451.gitlab.model.api.Note;
import com.commit451.gitlab.model.api.Project;
import com.commit451.gitlab.util.PaginationUtil;
import com.commit451.gitlab.view.SendMessageView;
import com.commit451.teleprinter.Teleprinter;
import com.squareup.otto.Subscribe;
 
Loading
Loading
@@ -33,7 +31,6 @@ import org.parceler.Parcels;
import java.util.List;
 
import butterknife.BindView;
import butterknife.OnClick;
import timber.log.Timber;
 
/**
Loading
Loading
@@ -59,8 +56,8 @@ public class MergeRequestDiscussionFragment extends ButterKnifeFragment {
SwipeRefreshLayout mSwipeRefreshLayout;
@BindView(R.id.list)
RecyclerView mNotesRecyclerView;
@BindView(R.id.new_note_edit)
EditText mNewNoteEdit;
@BindView(R.id.send_message_view)
SendMessageView mSendMessageView;
@BindView(R.id.progress)
View mProgress;
 
Loading
Loading
@@ -75,11 +72,6 @@ public class MergeRequestDiscussionFragment extends ButterKnifeFragment {
 
EventReceiver mEventReceiver;
 
@OnClick(R.id.new_note_button)
public void onNewNoteClick() {
postNote();
}
private final RecyclerView.OnScrollListener mOnScrollListener = new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
Loading
Loading
@@ -192,11 +184,10 @@ public class MergeRequestDiscussionFragment extends ButterKnifeFragment {
mNotesRecyclerView.setAdapter(mMergeRequestDetailAdapter);
mNotesRecyclerView.addOnScrollListener(mOnScrollListener);
 
mNewNoteEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
mSendMessageView.setCallbacks(new SendMessageView.Callbacks() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
postNote();
return true;
public void onSendClicked(String message) {
postNote(message);
}
});
 
Loading
Loading
@@ -235,10 +226,9 @@ public class MergeRequestDiscussionFragment extends ButterKnifeFragment {
GitLabClient.instance().getMergeRequestNotes(mNextPageUrl.toString()).enqueue(mMoreNotesCallback);
}
 
private void postNote() {
String body = mNewNoteEdit.getText().toString();
private void postNote(String message) {
 
if (body.length() < 1) {
if (message.length() < 1) {
return;
}
 
Loading
Loading
@@ -247,9 +237,9 @@ public class MergeRequestDiscussionFragment extends ButterKnifeFragment {
mProgress.animate().alpha(1.0f);
// Clear text & collapse keyboard
mTeleprinter.hideKeyboard();
mNewNoteEdit.setText("");
mSendMessageView.clearText();
 
GitLabClient.instance().addMergeRequestNote(mProject.getId(), mMergeRequest.getId(), body).enqueue(mPostNoteCallback);
GitLabClient.instance().addMergeRequestNote(mProject.getId(), mMergeRequest.getId(), message).enqueue(mPostNoteCallback);
}
 
private class EventReceiver {
Loading
Loading
Loading
Loading
@@ -27,7 +27,6 @@ import com.commit451.gitlab.activity.MilestoneActivity;
import com.commit451.gitlab.activity.ProjectActivity;
import com.commit451.gitlab.activity.ProjectsActivity;
import com.commit451.gitlab.activity.SearchActivity;
import com.commit451.gitlab.activity.SettingsActivity;
import com.commit451.gitlab.activity.UserActivity;
import com.commit451.gitlab.model.Account;
import com.commit451.gitlab.model.api.Group;
Loading
Loading
@@ -50,10 +49,6 @@ public class NavigationManager {
activity.startActivity(AboutActivity.newInstance(activity));
}
 
public static void navigateToSettings(Activity activity) {
activity.startActivity(SettingsActivity.newInstance(activity));
}
public static void navigateToProject(Activity activity, Project project) {
activity.startActivity(ProjectActivity.newInstance(activity, project));
}
Loading
Loading
package com.commit451.gitlab.util;
import android.content.Context;
import android.util.TypedValue;
import com.afollestad.appthemeengine.ATE;
import com.afollestad.appthemeengine.Config;
import com.commit451.gitlab.R;
public class AppThemeUtil {
public static void setupDefaultConfigs(Context context) {
if (!ATE.config(context, "light_theme").isConfigured(0)) {
ATE.config(context, "light_theme")
.activityTheme(R.style.AppThemeLight)
.primaryColorRes(R.color.primary_default)
.accentColorRes(R.color.accent_default)
.coloredNavigationBar(false)
.commit();
}
if (!ATE.config(context, "dark_theme").isConfigured(0)) {
ATE.config(context, "dark_theme")
.activityTheme(R.style.AppTheme)
.primaryColorRes(R.color.primary_default)
.accentColorRes(R.color.accent_default)
.coloredNavigationBar(true)
.commit();
}
}
public static String resolveThemeKey(Context context) {
TypedValue typedValue = new TypedValue();
context.getTheme().resolveAttribute(R.attr.ate_key, typedValue, true);
return (String) typedValue.coerceToString();
}
public static int resolvePrimaryColor(Context context) {
return Config.primaryColor(context, resolveThemeKey(context));
}
public static int resolvePrimaryColorDark(Context context) {
return Config.primaryColorDark(context, resolveThemeKey(context));
}
public static int resolveAccentColor(Context context) {
return Config.accentColor(context, resolveThemeKey(context));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment