Skip to content

Commit b7922d6

Browse files
authored
Merge pull request #58 from kaczmarkiewiczp/dev
Allow setting custom primary and accent colors
2 parents 566e08d + aa21e00 commit b7922d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1888
-155
lines changed

.idea/assetWizardSettings.xml

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/caches/build_file_checksums.ser

0 Bytes
Binary file not shown.

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ Grab the [latest version](https://github.com/kaczmarkiewiczp/rcloneExplorer/rele
3636

3737
Credits/Libraries
3838
-----------------
39-
- [About Libraries](https://github.com/mikepenz/AboutLibraries) - AboutLibraries is a library to offer some information of libraries.
39+
- [Color Picker](https://github.com/jaredrummler/ColorPicker) - A highly customizable color picker for Android.
4040
- [ExFile Picker](https://github.com/bartwell/ExFilePicker) - Open source Android library. Implement choosing files and directories in your application.
41-
- [Floating Action Button SpeedDial](https://github.com/leinardi/FloatingActionButtonSpeedDial) - A Floating Action Button Speed Dial implementation for Android that follows the Material Design specification
42-
- [Font Awesome Icons](https://fontawesome.com/) - The iconic SVG, font, and CSS toolkit
41+
- [Floating Action Button SpeedDial](https://github.com/leinardi/FloatingActionButtonSpeedDial) - A Floating Action Button Speed Dial implementation for Android that follows the Material Design specification.
42+
- [Font Awesome Icons](https://fontawesome.com/) - The iconic SVG, font, and CSS toolkit/
4343
- [Markdown View](https://github.com/falnatsheh/MarkdownView) - MarkdownView is an Android webview with the capablity of loading Markdown text or file and display it as HTML, it uses MarkdownJ and extends Android webview.
44-
- [Material Design Icons](https://github.com/Templarian/MaterialDesign) - 2200+ Material Design Icons from the Community
44+
- [Material Design Icons](https://github.com/Templarian/MaterialDesign) - 2200+ Material Design Icons from the Community.
4545
- [rclone](https://github.com/ncw/rclone) - "rsync for cloud storage"
46-
- [Toasty](https://github.com/GrenderG/Toasty) - The usual Toast, but with steroids
46+
- [Toasty](https://github.com/GrenderG/Toasty) - The usual Toast, but with steroids.
4747
- Icon made by [Smashicons](https://www.flaticon.com/authors/smashicons) from [Flaticon](https://www.flaticon.com)

app/build.gradle

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ android {
66
applicationId "ca.pkay.rcloneexplorer"
77
minSdkVersion 21
88
targetSdkVersion 27
9-
versionCode 8
10-
versionName "1.1.1"
9+
versionCode 9
10+
versionName "1.2.0"
1111
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1212
}
1313
buildTypes {
@@ -32,10 +32,11 @@ dependencies {
3232
implementation 'com.android.support:design:27.1.1'
3333
implementation "com.leinardi.android:speed-dial:1.0-alpha03"
3434
implementation 'ru.bartwell:exfilepicker:2.4'
35-
implementation "com.mikepenz:aboutlibraries:6.0.8"
3635
implementation 'us.feras.mdv:markdownview:1.1.0'
3736
implementation 'jp.wasabeef:recyclerview-animators:2.3.0'
3837
implementation 'com.github.GrenderG:Toasty:1.3.0'
38+
implementation 'com.android.support:support-v4:27.1.1'
39+
implementation 'com.jaredrummler:colorpicker:1.0.2'
3940
testImplementation 'junit:junit:4.12'
4041
androidTestImplementation 'com.android.support.test:runner:1.0.1'
4142
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

app/src/main/AndroidManifest.xml

+11-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
android:theme="@style/AppTheme.NoActionBar">
2020
<intent-filter>
2121
<action android:name="android.intent.action.MAIN" />
22+
2223
<category android:name="android.intent.category.LAUNCHER" />
2324
</intent-filter>
2425
</activity>
@@ -45,14 +46,19 @@
4546
android:name=".AboutActivity"
4647
android:label="@string/title_activity_about"
4748
android:theme="@style/AppTheme.NoActionBar" />
48-
4949
<activity
5050
android:name=".ChangelogActivity"
5151
android:label="@string/title_activity_changelog"
52-
android:theme="@style/AppTheme.NoActionBar"
53-
android:parentActivityName=".AboutActivity"/>
54-
55-
52+
android:parentActivityName=".AboutActivity"
53+
android:theme="@style/AppTheme.NoActionBar" />
54+
<activity
55+
android:name=".SettingsActivity"
56+
android:label="@string/title_activity_settings" />
57+
<activity
58+
android:name=".AboutLibsActivity"
59+
android:label="@string/credits_libraries"
60+
android:parentActivityName=".AboutActivity"
61+
android:theme="@style/AppTheme.NoActionBar" />
5662
</application>
5763

5864
</manifest>

app/src/main/assets/changelog.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
### 1.2.0
2+
* **New:** Settings!
3+
* **New:** Custom primary and accent colors
4+
* **New:** Group notifications together
5+
* **New:** "Open as" option in the menu
6+
7+
***
8+
19
### 1.1.1
210
* **Fix:** Hide hash calculations for crypt remotes
311
* **Fix:** Crash when rclone fails

app/src/main/java/ca/pkay/rcloneexplorer/AboutActivity.java

+21-12
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
package ca.pkay.rcloneexplorer;
22

3+
import android.app.ActivityManager;
34
import android.content.Intent;
5+
import android.content.SharedPreferences;
6+
import android.graphics.Bitmap;
7+
import android.graphics.BitmapFactory;
48
import android.net.Uri;
59
import android.os.Bundle;
6-
import android.support.design.widget.FloatingActionButton;
7-
import android.support.design.widget.Snackbar;
10+
import android.preference.PreferenceManager;
811
import android.support.v7.app.ActionBar;
912
import android.support.v7.app.AppCompatActivity;
1013
import android.support.v7.widget.Toolbar;
1114
import android.view.View;
1215
import android.widget.TextView;
13-
import android.widget.Toast;
1416

15-
import com.mikepenz.aboutlibraries.Libs;
16-
import com.mikepenz.aboutlibraries.LibsBuilder;
1717

1818
public class AboutActivity extends AppCompatActivity {
1919

2020
@Override
2121
protected void onCreate(Bundle savedInstanceState) {
2222
super.onCreate(savedInstanceState);
23+
applyTheme();
2324
setContentView(R.layout.activity_about);
2425
Toolbar toolbar = findViewById(R.id.toolbar);
2526
setSupportActionBar(toolbar);
@@ -66,6 +67,19 @@ public void onClick(View v) {
6667
});
6768
}
6869

70+
private void applyTheme() {
71+
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
72+
int customPrimaryColor = sharedPreferences.getInt("pref_key_color_primary", -1);
73+
int customAccentColor = sharedPreferences.getInt("pref_key_color_accent", -1);
74+
getTheme().applyStyle(CustomColorHelper.getPrimaryColorTheme(this, customPrimaryColor), true);
75+
getTheme().applyStyle(CustomColorHelper.getAccentColorTheme(this, customAccentColor), true);
76+
77+
// set recents app color to the primary color
78+
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_round);
79+
ActivityManager.TaskDescription taskDesc = new ActivityManager.TaskDescription(getString(R.string.app_name), bm, customPrimaryColor);
80+
setTaskDescription(taskDesc);
81+
}
82+
6983
@Override
7084
public boolean onSupportNavigateUp() {
7185
onBackPressed();
@@ -78,13 +92,8 @@ private void showChangelog() {
7892
}
7993

8094
private void showOpenSourceLibraries() {
81-
new LibsBuilder()
82-
.withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR)
83-
.withActivityTitle(getString(R.string.credits_libraries))
84-
.withAutoDetect(false)
85-
.withLibraries()
86-
.withExcludedLibraries()
87-
.start(this);
95+
Intent librariesIntent = new Intent(this, AboutLibsActivity.class);
96+
startActivity(librariesIntent);
8897
}
8998

9099
private void openAppGitHubLink() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
package ca.pkay.rcloneexplorer;
2+
3+
import android.app.ActivityManager;
4+
import android.content.Intent;
5+
import android.content.SharedPreferences;
6+
import android.graphics.Bitmap;
7+
import android.graphics.BitmapFactory;
8+
import android.net.Uri;
9+
import android.os.Bundle;
10+
import android.preference.PreferenceManager;
11+
import android.support.v7.app.ActionBar;
12+
import android.support.v7.app.AppCompatActivity;
13+
import android.support.v7.widget.LinearLayoutManager;
14+
import android.support.v7.widget.RecyclerView;
15+
import android.support.v7.widget.Toolbar;
16+
17+
import java.util.ArrayList;
18+
import java.util.HashMap;
19+
import java.util.List;
20+
import java.util.Map;
21+
22+
import ca.pkay.rcloneexplorer.RecyclerViewAdapters.AboutLibrariesAdapter;
23+
24+
public class AboutLibsActivity extends AppCompatActivity implements AboutLibrariesAdapter.OnClickListener {
25+
26+
private List<String> libraryNames;
27+
private Map<String, String> libraryUrls;
28+
private Map<String, String> libraryLicences;
29+
private Map<String, String> libraryLicenceUrls;
30+
31+
@Override
32+
protected void onCreate(Bundle savedInstanceState) {
33+
super.onCreate(savedInstanceState);
34+
applyTheme();
35+
setContentView(R.layout.activity_about_libs);
36+
Toolbar toolbar = findViewById(R.id.toolbar);
37+
setSupportActionBar(toolbar);
38+
ActionBar actionBar = getSupportActionBar();
39+
if (actionBar != null) {
40+
actionBar.setDisplayHomeAsUpEnabled(true);
41+
actionBar.setDisplayShowHomeEnabled(true);
42+
}
43+
44+
createData();
45+
RecyclerView recyclerView = findViewById(R.id.about_libs_list);
46+
recyclerView.setHasFixedSize(true);
47+
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
48+
recyclerView.setLayoutManager(layoutManager);
49+
AboutLibrariesAdapter aboutLibrariesAdapter = new AboutLibrariesAdapter(libraryNames, libraryUrls, libraryLicences, libraryLicenceUrls, this);
50+
recyclerView.setAdapter(aboutLibrariesAdapter);
51+
}
52+
53+
@Override
54+
public boolean onSupportNavigateUp() {
55+
onBackPressed();
56+
return true;
57+
}
58+
59+
private void applyTheme() {
60+
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
61+
int customPrimaryColor = sharedPreferences.getInt("pref_key_color_primary", -1);
62+
int customAccentColor = sharedPreferences.getInt("pref_key_color_accent", -1);
63+
getTheme().applyStyle(CustomColorHelper.getPrimaryColorTheme(this, customPrimaryColor), true);
64+
getTheme().applyStyle(CustomColorHelper.getAccentColorTheme(this, customAccentColor), true);
65+
66+
// set recents app color to the primary color
67+
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_round);
68+
ActivityManager.TaskDescription taskDesc = new ActivityManager.TaskDescription(getString(R.string.app_name), bm, customPrimaryColor);
69+
setTaskDescription(taskDesc);
70+
}
71+
72+
private void createData() {
73+
libraryNames = new ArrayList<>();
74+
libraryUrls = new HashMap<>();
75+
libraryLicences = new HashMap<>();
76+
libraryLicenceUrls = new HashMap<>();
77+
78+
String androidSupportLibraries = "Android Support Libraries";
79+
libraryNames.add(androidSupportLibraries);
80+
libraryUrls.put(androidSupportLibraries, "https://developer.android.com/topic/libraries/support-library/");
81+
libraryLicences.put(androidSupportLibraries, "Licensed under Apache-2.0");
82+
libraryLicenceUrls.put(androidSupportLibraries, "http://www.apache.org/licenses/LICENSE-2.0");
83+
84+
String colorPicker = "Color Picker";
85+
libraryNames.add(colorPicker);
86+
libraryUrls.put(colorPicker, "https://github.com/jaredrummler/ColorPicker");
87+
libraryLicences.put(colorPicker, "Licensed under Apache-2.0");
88+
libraryLicenceUrls.put(colorPicker, "https://github.com/jaredrummler/ColorPicker/blob/master/LICENSE");
89+
90+
String exFilePicker = "ExFile Picker";
91+
libraryNames.add(exFilePicker);
92+
libraryUrls.put(exFilePicker, "https://github.com/bartwell/ExFilePicker");
93+
libraryLicences.put(exFilePicker, "Licensed under MIT");
94+
libraryLicenceUrls.put(exFilePicker, "https://github.com/bartwell/ExFilePicker/blob/master/LICENSE");
95+
96+
String floatingActionButtonSpeedDial = "Floating Action Button Speed Dial";
97+
libraryNames.add(floatingActionButtonSpeedDial);
98+
libraryUrls.put(floatingActionButtonSpeedDial, "https://github.com/leinardi/FloatingActionButtonSpeedDial");
99+
libraryLicences.put(floatingActionButtonSpeedDial, "Licensed under Apache-2.0");
100+
libraryLicenceUrls.put(floatingActionButtonSpeedDial, "https://github.com/leinardi/FloatingActionButtonSpeedDial/blob/master/LICENSE");
101+
102+
String fontAwesome = "Font Awesome";
103+
libraryNames.add(fontAwesome);
104+
libraryUrls.put(fontAwesome, "https://fontawesome.com/");
105+
libraryLicences.put(fontAwesome, "Licensed under CC BY 4.0");
106+
libraryLicenceUrls.put(fontAwesome, "https://fontawesome.com/license");
107+
108+
String markDownView = "MarkDown View";
109+
libraryNames.add(markDownView);
110+
libraryUrls.put(markDownView, "https://github.com/falnatsheh/MarkdownView");
111+
libraryLicences.put(markDownView, "Licensed under Apache-2.0");
112+
libraryLicenceUrls.put(markDownView, "https://github.com/falnatsheh/MarkdownView/blob/master/license.txt");
113+
114+
String materialDesignIcons = "Material Design";
115+
libraryNames.add(materialDesignIcons);
116+
libraryUrls.put(materialDesignIcons, "https://github.com/Templarian/MaterialDesign");
117+
libraryLicences.put(materialDesignIcons, "Licensed under SIL Open Font 1.1");
118+
libraryLicenceUrls.put(materialDesignIcons, "http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web");
119+
120+
String rclone = "Rclone";
121+
libraryNames.add(rclone);
122+
libraryUrls.put(rclone, "https://github.com/ncw/rclone");
123+
libraryLicences.put(rclone, "Licensed under MIT");
124+
libraryLicenceUrls.put(rclone, "https://github.com/ncw/rclone/blob/master/COPYING");
125+
126+
String toasty = "Toasty";
127+
libraryNames.add(toasty);
128+
libraryUrls.put(toasty, "https://github.com/GrenderG/Toasty");
129+
libraryLicences.put(toasty, "Licensed under LGPL-3.0");
130+
libraryLicenceUrls.put(toasty, "https://github.com/GrenderG/Toasty/blob/master/LICENSE");
131+
}
132+
133+
@Override
134+
public void onLibraryClick(String url) {
135+
Uri uri = Uri.parse(url);
136+
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
137+
if (intent.resolveActivity(getPackageManager()) != null) {
138+
startActivity(intent);
139+
}
140+
}
141+
}

0 commit comments

Comments
 (0)