Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phcoder cherrypicks #238

Merged
merged 46 commits into from
Aug 23, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
45abc0e
Revert "Remove support for editing files."
phcoder Nov 17, 2015
bd7c6d1
Don't use coffeescript for internal editor
maks Aug 4, 2016
f63c813
Add copy whole file to editor
maks Aug 4, 2016
6dbfb8d
Add ssh key generation and exporting
phcoder Oct 29, 2015
d5b5086
Don't rtrim the buffer.
phcoder Aug 5, 2016
8874fa1
Improve commit metadata checks
maks Aug 17, 2016
cbb02af
Change commit view to be more in line with usual android interface
phcoder Nov 5, 2015
ed4e3c0
Add ability to create a branch from any commit
phcoder Nov 6, 2015
070fa35
Save and share a diff
maks Aug 17, 2016
8cdcaaf
Remove SheimiArrayAdapter
phcoder Nov 7, 2015
a29d46a
Make branch picker an activity
phcoder Nov 7, 2015
01e3e16
Add branch menu to create and delete branches
phcoder Nov 8, 2015
608dd86
Prevent NPE using up affordance from BranchChooser
maks Aug 18, 2016
26b83c7
Track item visual selection in actionmode
maks Aug 18, 2016
cb35d53
Show author and not committer in short list
phcoder Nov 8, 2015
e285469
Show the name of key to be deleted.
phcoder Nov 8, 2015
222c8e4
Track item visual selection in actionmodei:SSH Key
maks Aug 18, 2016
af72597
Don't swallow subsequent lines on amend.
phcoder Nov 19, 2015
d2c72ae
Fix commitdiff header
phcoder Nov 21, 2015
afacf8b
Add support for setting commit author.
phcoder Nov 21, 2015
055af6e
Add force pull functionality
phcoder Nov 22, 2015
9785bb4
Allow rebase on non-local branch
phcoder Nov 23, 2015
90c070b
Clear merge and rebase status in force pull
phcoder Nov 23, 2015
3acfa4d
Discard rebases and merges on hard reset.
phcoder Nov 25, 2015
eeaed38
Add staged and unstaged diff functionality
phcoder Nov 25, 2015
07f0af6
Show public key on click on key
phcoder Nov 25, 2015
590e970
Limit author autocomplete to 500 last commits.
phcoder Nov 25, 2015
f7e3af0
Add an Action to edit raw config
phcoder Dec 5, 2015
55ac594
Respect user.name and user.email in config
phcoder Dec 5, 2015
de28f32
Add config dialog.
phcoder Dec 5, 2015
94133dc
Restructure import of local repo for future migration to OPEN_DOCUMEN…
phcoder Dec 6, 2015
368036a
Implement commit search
phcoder Dec 8, 2015
3e3c5e1
Import midnight codemirror theme
phcoder Dec 9, 2015
b0c93e5
Add missing COPYING file.
phcoder Dec 9, 2015
870d78a
Dark theme
phcoder Dec 9, 2015
2163a24
Commits touching a file
phcoder Dec 9, 2015
353276f
Do not include old commit in title when printing a commitdiff
phcoder Dec 9, 2015
ba41622
Optimize commit search
phcoder Dec 9, 2015
a8424c8
tidy up from cherry-picks
maks Aug 23, 2016
899e107
Fix crash on commit tab rotate
phcoder Dec 12, 2015
69519a5
Improve responsiveness to commit search
phcoder Dec 12, 2015
3c24614
Fix bugs with backrounf commit search
phcoder Dec 13, 2015
c3d6c3f
Fix accidental search in parents field
phcoder Dec 13, 2015
17e240c
Fix save icon bug
phcoder Dec 18, 2015
fa8f646
Update codemirror version to HEAD
phcoder Jan 1, 2016
6ea23fc
Fix unit test to match code changes
maks Aug 23, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Dark theme
(cherry picked from commit 26461fe)

With substantial rework to better implement app-wide theme change and pref
setting.

Signed-off-by: Maksim Lin <[email protected]>
  • Loading branch information
phcoder authored and maks committed Aug 22, 2016
commit 870d78acf64286ae9e5cbde5d72db256853b8939
File renamed without changes.
1 change: 1 addition & 0 deletions src/main/assets/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<title>ACE in Action</title>
<link rel="stylesheet" href="css/codemirror.css">
<link rel="stylesheet" href="css/midnight.css">
<script src="js/codemirror-compressed.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.js"></script>
<script src="js/editor.js"></script>
Expand Down
1 change: 1 addition & 0 deletions src/main/assets/js/editor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import java.io.File;

import me.sheimi.android.utils.BasicFunctions;
import me.sheimi.android.utils.Profile;
import me.sheimi.sgit.R;
import me.sheimi.sgit.SGitApplication;
import me.sheimi.sgit.dialogs.DummyDialogListener;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -33,6 +36,7 @@ public static interface OnBackClickListener {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
BasicFunctions.setActiveActivity(this);
setTheme(Profile.getThemeResource(getApplicationContext()));
}

@Override
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/me/sheimi/android/utils/Profile.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.util.Log;

import me.sheimi.sgit.R;
import me.sheimi.sgit.SGitApplication;
Expand All @@ -16,6 +18,7 @@ public class Profile {

private static boolean sHasLastCloneFail = false;
private static Repo sLastFailRepo;
private static int sTheme = -1;

private static SharedPreferences getProfileSharedPreference(Context context) {
if (sSharedPreference == null) {
Expand Down Expand Up @@ -52,6 +55,28 @@ public static void setLastCloneFailed(Repo repo) {
public static void setLastCloneSuccess() {
sHasLastCloneFail = false;
}

public static synchronized int getTheme(Context context) {
// silly, but Android framework want strings as value array for ListPreference
return Integer.parseInt(getProfileSharedPreference(context).getString(context.getString(R.string.pref_key_use_theme_id), "0"));
}

public static int getThemeResource(Context context) {
final int[] themes = { R.style.AppTheme, R.style.DarkAppTheme };
return themes[getTheme(context)];
}

public static String getCodeMirrorTheme(Context context) {
final String[] themes = context.getResources().getStringArray(R.array.codemirror_theme_names);
return themes[getTheme(context)];
}

public static int getStyledResource(Context context, int unstyled) {
TypedArray a = context.getTheme().obtainStyledAttributes(getThemeResource(context), new int[] {unstyled});
int styled = a.getResourceId(0, 0);
a.recycle();
return styled;
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
import me.sheimi.android.activities.SheimiFragmentActivity;
import me.sheimi.android.utils.CodeGuesser;
import me.sheimi.android.utils.FsUtils;
import me.sheimi.android.utils.Profile;
import me.sheimi.sgit.R;
import me.sheimi.sgit.database.models.Repo;
import me.sheimi.sgit.repo.tasks.repo.CommitDiffTask;
import me.sheimi.sgit.repo.tasks.repo.CommitDiffTask.CommitDiffResult;

import org.eclipse.jgit.diff.DiffEntry;

import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
Expand Down Expand Up @@ -88,6 +91,7 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
});
mDiffContent.setBackgroundColor(Color.TRANSPARENT);
}

private void setupActionBar() {
Expand Down Expand Up @@ -257,6 +261,10 @@ public int getDiffSize() {
return mDiffEntries.size();
}

@JavascriptInterface
public String getTheme() {
return Profile.getCodeMirrorTheme(getApplicationContext());
}
}

private static final String HTML_TMPL = "<!doctype html>"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package me.sheimi.sgit.activities;

import android.app.Activity;
import android.os.Bundle;

import me.sheimi.android.activities.SheimiFragmentActivity;
import me.sheimi.sgit.fragments.SettingsFragment;

/**
* Activity for user settings
*/
public class UserSettingsActivity extends Activity {
public class UserSettingsActivity extends SheimiFragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/me/sheimi/sgit/activities/ViewFileActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import me.sheimi.android.utils.BasicFunctions;
import me.sheimi.android.utils.CodeGuesser;
import me.sheimi.android.utils.FsUtils;
import me.sheimi.android.utils.Profile;
import me.sheimi.sgit.R;
import me.sheimi.sgit.dialogs.ChooseLanguageDialog;

Expand All @@ -17,8 +18,10 @@
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
Expand Down Expand Up @@ -68,6 +71,7 @@ private void initViewFile() {
WebSettings webSettings = mFileContent.getSettings();
webSettings.setJavaScriptEnabled(true);
mFileContent.setWebChromeClient(new WebChromeClient() {
@Override
public void onConsoleMessage(String message, int lineNumber,
String sourceID) {
Log.d("MyApplication", message + " -- From line " + lineNumber
Expand All @@ -78,6 +82,7 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
});
mFileContent.setBackgroundColor(Color.TRANSPARENT);
}

@Override
Expand Down Expand Up @@ -249,6 +254,11 @@ public void run() {
thread.start();
}

@JavascriptInterface
public String getTheme() {
return Profile.getCodeMirrorTheme(getApplicationContext());
}

private void display() {
runOnUiThread(new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import me.sheimi.android.utils.Profile;
import me.sheimi.android.views.SheimiDialogFragment;
import me.sheimi.sgit.R;
import me.sheimi.sgit.activities.RepoDetailActivity;
Expand Down Expand Up @@ -123,10 +124,10 @@ public View getView(int position, View convertView, ViewGroup parent) {
switch (commitType) {
case Repo.COMMIT_TYPE_HEAD:
holder.commitIcon
.setImageResource(R.drawable.ic_branch_d);
.setImageResource(Profile.getStyledResource(getContext(), R.drawable.ic_branch_l));
break;
case Repo.COMMIT_TYPE_TAG:
holder.commitIcon.setImageResource(R.drawable.ic_tag_d);
holder.commitIcon.setImageResource(Profile.getStyledResource(getContext(), R.drawable.ic_tag_l));
break;
}
holder.commitTitle.setText(displayName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import me.sheimi.android.utils.Profile;
import me.sheimi.android.views.SheimiDialogFragment;
import me.sheimi.sgit.R;
import me.sheimi.sgit.activities.RepoDetailActivity;
Expand Down Expand Up @@ -126,10 +127,10 @@ public View getView(int position, View convertView, ViewGroup parent) {
switch (commitType) {
case Repo.COMMIT_TYPE_HEAD:
holder.commitIcon
.setImageResource(R.drawable.ic_branch_d);
.setImageResource(Profile.getStyledResource(getContext(), R.drawable.ic_branch_l));
break;
case Repo.COMMIT_TYPE_TAG:
holder.commitIcon.setImageResource(R.drawable.ic_tag_d);
holder.commitIcon.setImageResource(Profile.getStyledResource(getContext(), R.drawable.ic_tag_l));
break;
}
holder.commitTitle.setText(displayName);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/me/sheimi/sgit/adapters/FilesListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Arrays;
import java.util.Comparator;

import me.sheimi.android.utils.Profile;
import me.sheimi.sgit.R;
import android.content.Context;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -47,9 +48,9 @@ public View getView(int position, View convertView, ViewGroup parent) {
File item = getItem(position);
holder.fileTitle.setText(item.getName());
if (item.isDirectory()) {
holder.fileIcon.setImageResource(R.drawable.ic_folder_d);
holder.fileIcon.setImageResource(Profile.getStyledResource(getContext(), R.drawable.ic_folder_fl));
} else {
holder.fileIcon.setImageResource(R.drawable.ic_file_d);
holder.fileIcon.setImageResource(Profile.getStyledResource(getContext(), R.drawable.ic_file_fl));
}
// set if selected
if (convertView.isSelected()) {
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/me/sheimi/sgit/fragments/SettingsFragment.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package me.sheimi.sgit.fragments;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.support.v4.app.TaskStackBuilder;
import android.util.Log;

import me.sheimi.sgit.R;
import me.sheimi.sgit.RepoListActivity;

public class SettingsFragment extends PreferenceFragment {
private SharedPreferences.OnSharedPreferenceChangeListener mListener;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -19,6 +26,35 @@ public void onCreate(Bundle savedInstanceState) {

// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);

final String themePrefKey = getString(R.string.pref_key_use_theme_id);

mListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (themePrefKey.equals(key)) {
// nice trick to recreate the back stack, to ensure existing activities onCreate() are
// called to set new theme, courtesy of: http://stackoverflow.com/a/28799124/85472
TaskStackBuilder.create(getActivity())
.addNextIntent(new Intent(getActivity(), RepoListActivity.class))
.addNextIntent(getActivity().getIntent())
.startActivities();
}
}
};
}


@Override
public void onResume() {
super.onResume();
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(mListener);
}

@Override
public void onPause() {
super.onPause();
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(mListener);
}
}

Binary file added src/main/res/drawable-hdpi/ic_folder_w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-mdpi/ic_folder_w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/res/drawable-xhdpi/ic_folder_w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/main/res/layout/activity_repo_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="#eee" >
android:background="?drawable/drawer_background" >

<ListView
android:id="@+id/repoOperationList"
Expand Down
6 changes: 3 additions & 3 deletions src/main/res/layout/activity_repo_detail_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#33b5e5"
android:background="?drawable/pager_title_strip_background"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:textColor="#fff" />
Expand All @@ -24,7 +24,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/bt_branch_name_bg"
android:background="?drawable/bt_branch_name_bg"
android:gravity="center"
android:padding="@dimen/branch_label_padding"
android:text="@string/default_text"
Expand Down Expand Up @@ -91,4 +91,4 @@
</RelativeLayout>
</LinearLayout>

</RelativeLayout>
</RelativeLayout>
31 changes: 0 additions & 31 deletions src/main/res/layout/dialog_profile.xml

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/res/layout/drawer_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="#333" />
android:textColor="?drawable/drawer_text_color" />

</RelativeLayout>
Loading