-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from kaczmarkiewiczp/dev
Allow setting custom primary and accent colors
- Loading branch information
Showing
44 changed files
with
1,888 additions
and
155 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
app/src/main/java/ca/pkay/rcloneexplorer/AboutLibsActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.