Skip to content

Commit

Permalink
Merge pull request #58 from kaczmarkiewiczp/dev
Browse files Browse the repository at this point in the history
Allow setting custom primary and accent colors
  • Loading branch information
patrykcoding authored Apr 26, 2018
2 parents 566e08d + aa21e00 commit b7922d6
Show file tree
Hide file tree
Showing 44 changed files with 1,888 additions and 155 deletions.
5 changes: 2 additions & 3 deletions .idea/assetWizardSettings.xml

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

Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ Grab the [latest version](https://github.com/kaczmarkiewiczp/rcloneExplorer/rele

Credits/Libraries
-----------------
- [About Libraries](https://github.com/mikepenz/AboutLibraries) - AboutLibraries is a library to offer some information of libraries.
- [Color Picker](https://github.com/jaredrummler/ColorPicker) - A highly customizable color picker for Android.
- [ExFile Picker](https://github.com/bartwell/ExFilePicker) - Open source Android library. Implement choosing files and directories in your application.
- [Floating Action Button SpeedDial](https://github.com/leinardi/FloatingActionButtonSpeedDial) - A Floating Action Button Speed Dial implementation for Android that follows the Material Design specification
- [Font Awesome Icons](https://fontawesome.com/) - The iconic SVG, font, and CSS toolkit
- [Floating Action Button SpeedDial](https://github.com/leinardi/FloatingActionButtonSpeedDial) - A Floating Action Button Speed Dial implementation for Android that follows the Material Design specification.
- [Font Awesome Icons](https://fontawesome.com/) - The iconic SVG, font, and CSS toolkit/
- [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.
- [Material Design Icons](https://github.com/Templarian/MaterialDesign) - 2200+ Material Design Icons from the Community
- [Material Design Icons](https://github.com/Templarian/MaterialDesign) - 2200+ Material Design Icons from the Community.
- [rclone](https://github.com/ncw/rclone) - "rsync for cloud storage"
- [Toasty](https://github.com/GrenderG/Toasty) - The usual Toast, but with steroids
- [Toasty](https://github.com/GrenderG/Toasty) - The usual Toast, but with steroids.
- Icon made by [Smashicons](https://www.flaticon.com/authors/smashicons) from [Flaticon](https://www.flaticon.com)
7 changes: 4 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "ca.pkay.rcloneexplorer"
minSdkVersion 21
targetSdkVersion 27
versionCode 8
versionName "1.1.1"
versionCode 9
versionName "1.2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -32,10 +32,11 @@ dependencies {
implementation 'com.android.support:design:27.1.1'
implementation "com.leinardi.android:speed-dial:1.0-alpha03"
implementation 'ru.bartwell:exfilepicker:2.4'
implementation "com.mikepenz:aboutlibraries:6.0.8"
implementation 'us.feras.mdv:markdownview:1.1.0'
implementation 'jp.wasabeef:recyclerview-animators:2.3.0'
implementation 'com.github.GrenderG:Toasty:1.3.0'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.jaredrummler:colorpicker:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
Expand Down
16 changes: 11 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand All @@ -45,14 +46,19 @@
android:name=".AboutActivity"
android:label="@string/title_activity_about"
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:name=".ChangelogActivity"
android:label="@string/title_activity_changelog"
android:theme="@style/AppTheme.NoActionBar"
android:parentActivityName=".AboutActivity"/>


android:parentActivityName=".AboutActivity"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".SettingsActivity"
android:label="@string/title_activity_settings" />
<activity
android:name=".AboutLibsActivity"
android:label="@string/credits_libraries"
android:parentActivityName=".AboutActivity"
android:theme="@style/AppTheme.NoActionBar" />
</application>

</manifest>
8 changes: 8 additions & 0 deletions app/src/main/assets/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### 1.2.0
* **New:** Settings!
* **New:** Custom primary and accent colors
* **New:** Group notifications together
* **New:** "Open as" option in the menu

***

### 1.1.1
* **Fix:** Hide hash calculations for crypt remotes
* **Fix:** Crash when rclone fails
Expand Down
33 changes: 21 additions & 12 deletions app/src/main/java/ca/pkay/rcloneexplorer/AboutActivity.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
package ca.pkay.rcloneexplorer;

import android.app.ActivityManager;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.preference.PreferenceManager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.mikepenz.aboutlibraries.Libs;
import com.mikepenz.aboutlibraries.LibsBuilder;

public class AboutActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
applyTheme();
setContentView(R.layout.activity_about);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Expand Down Expand Up @@ -66,6 +67,19 @@ public void onClick(View v) {
});
}

private void applyTheme() {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
int customPrimaryColor = sharedPreferences.getInt("pref_key_color_primary", -1);
int customAccentColor = sharedPreferences.getInt("pref_key_color_accent", -1);
getTheme().applyStyle(CustomColorHelper.getPrimaryColorTheme(this, customPrimaryColor), true);
getTheme().applyStyle(CustomColorHelper.getAccentColorTheme(this, customAccentColor), true);

// set recents app color to the primary color
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_round);
ActivityManager.TaskDescription taskDesc = new ActivityManager.TaskDescription(getString(R.string.app_name), bm, customPrimaryColor);
setTaskDescription(taskDesc);
}

@Override
public boolean onSupportNavigateUp() {
onBackPressed();
Expand All @@ -78,13 +92,8 @@ private void showChangelog() {
}

private void showOpenSourceLibraries() {
new LibsBuilder()
.withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR)
.withActivityTitle(getString(R.string.credits_libraries))
.withAutoDetect(false)
.withLibraries()
.withExcludedLibraries()
.start(this);
Intent librariesIntent = new Intent(this, AboutLibsActivity.class);
startActivity(librariesIntent);
}

private void openAppGitHubLink() {
Expand Down
141 changes: 141 additions & 0 deletions app/src/main/java/ca/pkay/rcloneexplorer/AboutLibsActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
package ca.pkay.rcloneexplorer;

import android.app.ActivityManager;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import ca.pkay.rcloneexplorer.RecyclerViewAdapters.AboutLibrariesAdapter;

public class AboutLibsActivity extends AppCompatActivity implements AboutLibrariesAdapter.OnClickListener {

private List<String> libraryNames;
private Map<String, String> libraryUrls;
private Map<String, String> libraryLicences;
private Map<String, String> libraryLicenceUrls;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
applyTheme();
setContentView(R.layout.activity_about_libs);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}

createData();
RecyclerView recyclerView = findViewById(R.id.about_libs_list);
recyclerView.setHasFixedSize(true);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
AboutLibrariesAdapter aboutLibrariesAdapter = new AboutLibrariesAdapter(libraryNames, libraryUrls, libraryLicences, libraryLicenceUrls, this);
recyclerView.setAdapter(aboutLibrariesAdapter);
}

@Override
public boolean onSupportNavigateUp() {
onBackPressed();
return true;
}

private void applyTheme() {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
int customPrimaryColor = sharedPreferences.getInt("pref_key_color_primary", -1);
int customAccentColor = sharedPreferences.getInt("pref_key_color_accent", -1);
getTheme().applyStyle(CustomColorHelper.getPrimaryColorTheme(this, customPrimaryColor), true);
getTheme().applyStyle(CustomColorHelper.getAccentColorTheme(this, customAccentColor), true);

// set recents app color to the primary color
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_round);
ActivityManager.TaskDescription taskDesc = new ActivityManager.TaskDescription(getString(R.string.app_name), bm, customPrimaryColor);
setTaskDescription(taskDesc);
}

private void createData() {
libraryNames = new ArrayList<>();
libraryUrls = new HashMap<>();
libraryLicences = new HashMap<>();
libraryLicenceUrls = new HashMap<>();

String androidSupportLibraries = "Android Support Libraries";
libraryNames.add(androidSupportLibraries);
libraryUrls.put(androidSupportLibraries, "https://developer.android.com/topic/libraries/support-library/");
libraryLicences.put(androidSupportLibraries, "Licensed under Apache-2.0");
libraryLicenceUrls.put(androidSupportLibraries, "http://www.apache.org/licenses/LICENSE-2.0");

String colorPicker = "Color Picker";
libraryNames.add(colorPicker);
libraryUrls.put(colorPicker, "https://github.com/jaredrummler/ColorPicker");
libraryLicences.put(colorPicker, "Licensed under Apache-2.0");
libraryLicenceUrls.put(colorPicker, "https://github.com/jaredrummler/ColorPicker/blob/master/LICENSE");

String exFilePicker = "ExFile Picker";
libraryNames.add(exFilePicker);
libraryUrls.put(exFilePicker, "https://github.com/bartwell/ExFilePicker");
libraryLicences.put(exFilePicker, "Licensed under MIT");
libraryLicenceUrls.put(exFilePicker, "https://github.com/bartwell/ExFilePicker/blob/master/LICENSE");

String floatingActionButtonSpeedDial = "Floating Action Button Speed Dial";
libraryNames.add(floatingActionButtonSpeedDial);
libraryUrls.put(floatingActionButtonSpeedDial, "https://github.com/leinardi/FloatingActionButtonSpeedDial");
libraryLicences.put(floatingActionButtonSpeedDial, "Licensed under Apache-2.0");
libraryLicenceUrls.put(floatingActionButtonSpeedDial, "https://github.com/leinardi/FloatingActionButtonSpeedDial/blob/master/LICENSE");

String fontAwesome = "Font Awesome";
libraryNames.add(fontAwesome);
libraryUrls.put(fontAwesome, "https://fontawesome.com/");
libraryLicences.put(fontAwesome, "Licensed under CC BY 4.0");
libraryLicenceUrls.put(fontAwesome, "https://fontawesome.com/license");

String markDownView = "MarkDown View";
libraryNames.add(markDownView);
libraryUrls.put(markDownView, "https://github.com/falnatsheh/MarkdownView");
libraryLicences.put(markDownView, "Licensed under Apache-2.0");
libraryLicenceUrls.put(markDownView, "https://github.com/falnatsheh/MarkdownView/blob/master/license.txt");

String materialDesignIcons = "Material Design";
libraryNames.add(materialDesignIcons);
libraryUrls.put(materialDesignIcons, "https://github.com/Templarian/MaterialDesign");
libraryLicences.put(materialDesignIcons, "Licensed under SIL Open Font 1.1");
libraryLicenceUrls.put(materialDesignIcons, "http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web");

String rclone = "Rclone";
libraryNames.add(rclone);
libraryUrls.put(rclone, "https://github.com/ncw/rclone");
libraryLicences.put(rclone, "Licensed under MIT");
libraryLicenceUrls.put(rclone, "https://github.com/ncw/rclone/blob/master/COPYING");

String toasty = "Toasty";
libraryNames.add(toasty);
libraryUrls.put(toasty, "https://github.com/GrenderG/Toasty");
libraryLicences.put(toasty, "Licensed under LGPL-3.0");
libraryLicenceUrls.put(toasty, "https://github.com/GrenderG/Toasty/blob/master/LICENSE");
}

@Override
public void onLibraryClick(String url) {
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
}
Loading

0 comments on commit b7922d6

Please sign in to comment.