Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Commit

Permalink
Prefix resources
Browse files Browse the repository at this point in the history
And add an overridable toolbar theme. Fixes #31

Signed-off-by: Jonas Kalderstam <[email protected]>
  • Loading branch information
spacecowboy committed Jul 13, 2015
1 parent 0651518 commit 4124e8e
Show file tree
Hide file tree
Showing 28 changed files with 109 additions and 47 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Project-wide Gradle settings.

VERSION_NAME=2.1
VERSION_CODE=16
VERSION_NAME=2.2
VERSION_CODE=17
GROUP=com.nononsenseapps

PROJECT_NAME=com.nononsenseapps:filepicker
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<application
android:allowBackup="true"
android:label="@string/app_name"
android:label="@string/nnf_app_name"
>

</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public abstract class AbstractFilePickerActivity<T> extends AppCompatActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_filepicker);
setContentView(R.layout.nnf_activity_filepicker);

Intent intent = getIntent();
if (intent != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void setArgs(final String startPath, final int mode,
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_filepicker, container, false);
View view = inflater.inflate(R.layout.nnf_fragment_filepicker, container, false);

Toolbar mToolbar = (Toolbar) view.findViewById(R.id.picker_toolbar);
((AppCompatActivity) getActivity()).setSupportActionBar(mToolbar);
Expand Down Expand Up @@ -162,7 +162,7 @@ public void onClick(final View v) {
// Some invalid cases first
if ((allowMultiple || mode == MODE_FILE) && checkedItems.isEmpty()) {
Toast.makeText(getActivity(),
R.string.select_something_first,
R.string.nnf_select_something_first,
Toast.LENGTH_SHORT).show();
return;
}
Expand Down Expand Up @@ -289,13 +289,13 @@ public void onActivityCreated(Bundle savedInstanceState) {
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.picker_actions, menu);

MenuItem item = menu.findItem(R.id.action_createdir);
MenuItem item = menu.findItem(R.id.nnf_action_createdir);
item.setVisible(allowCreateDir);
}

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (R.id.action_createdir == menuItem.getItemId()) {
if (R.id.nnf_action_createdir == menuItem.getItemId()) {
Activity activity = getActivity();
if (activity instanceof AppCompatActivity) {
NewFolderFragment.showDialog(((AppCompatActivity) activity).getSupportFragmentManager(),
Expand Down Expand Up @@ -420,16 +420,16 @@ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType
View v;
switch (viewType) {
case LogicHandler.VIEWTYPE_HEADER:
v = LayoutInflater.from(getActivity()).inflate(R.layout.filepicker_listitem_dir,
v = LayoutInflater.from(getActivity()).inflate(R.layout.nnf_filepicker_listitem_dir,
parent, false);
return new HeaderViewHolder(v);
case LogicHandler.VIEWTYPE_CHECKABLE:
v = LayoutInflater.from(getActivity()).inflate(R.layout.filepicker_listitem_checkable,
v = LayoutInflater.from(getActivity()).inflate(R.layout.nnf_filepicker_listitem_checkable,
parent, false);
return new CheckableViewHolder(v);
case LogicHandler.VIEWTYPE_DIR:
default:
v = LayoutInflater.from(getActivity()).inflate(R.layout.filepicker_listitem_dir,
v = LayoutInflater.from(getActivity()).inflate(R.layout.nnf_filepicker_listitem_dir,
parent, false);
return new DirViewHolder(v);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package com.nononsenseapps.filepicker;

import android.net.Uri;
import android.os.Environment;
import android.os.FileObserver;
import android.support.v4.content.AsyncTaskLoader;
import android.support.v4.content.Loader;
Expand Down Expand Up @@ -227,7 +226,7 @@ public void onNewFolder(final String name) {
currentPath = folder;
refresh();
} else {
Toast.makeText(getActivity(), R.string.create_folder_error,
Toast.makeText(getActivity(), R.string.nnf_create_folder_error,
Toast.LENGTH_SHORT).show();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public void onAttach(Activity activity) {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(R.layout.dialog_folder_name)
.setTitle(R.string.new_folder)
builder.setView(R.layout.nnf_dialog_folder_name)
.setTitle(R.string.nnf_new_folder)
.setNegativeButton(android.R.string.cancel,
null)
.setPositiveButton(android.R.string.ok,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
android:padding="4dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:hint="@string/name"
android:hint="@string/nnf_name"
android:singleLine="true"
android:maxLines="1"
android:gravity="center_vertical"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
android:layout_height="?android:listPreferredItemHeight"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/ic_file_folder"
android:src="@drawable/nnf_ic_file_folder"
android:tint="?attr/colorAccent"
android:visibility="visible"
tools:ignore="ContentDescription" />
Expand All @@ -48,7 +48,7 @@
android:maxLines="1"
android:padding="8dp"
android:singleLine="true"
android:text="@string/name"/>
android:text="@string/nnf_name"/>

<CheckBox
android:id="@+id/checkbox"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
android:layout_height="?android:listPreferredItemHeight"
android:adjustViewBounds="true"
android:scaleType="center"
android:src="@drawable/ic_file_folder"
android:src="@drawable/nnf_ic_file_folder"
android:tint="?attr/colorAccent"
android:visibility="visible"
tools:ignore="ContentDescription" />
Expand All @@ -48,5 +48,5 @@
android:maxLines="1"
android:padding="8dp"
android:singleLine="true"
android:text="@string/name"/>
android:text="@string/nnf_name"/>
</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@
android:layout_alignParentTop="true"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar">
android:theme="?nnf_toolbarTheme">

<TextView
android:id="@+id/current_dir"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="start"
android:singleLine="true"
android:textColor="@android:color/white"
android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" />
</android.support.v7.widget.Toolbar>

Expand Down
6 changes: 3 additions & 3 deletions library/src/main/res/menu/picker_actions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_createdir"
android:title="@string/new_folder"
<item android:id="@+id/nnf_action_createdir"
android:title="@string/nnf_new_folder"
app:showAsAction="always"
android:orderInCategory="1"
android:icon="@drawable/ic_collections_add_collection"
android:icon="@drawable/nnf_ic_collections_add_collection"
/>
</menu>
22 changes: 22 additions & 0 deletions library/src/main/res/values/attr.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2015 Jonas Kalderstam
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU Lesser General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<resources>
<!-- Specifies theme to apply to the toolbar -->
<attr name="nnf_toolbarTheme" format="reference"/>
</resources>
10 changes: 5 additions & 5 deletions library/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
-->

<resources>
<string name="app_name">NoNonsense File Picker</string>
<string name="new_folder">New folder</string>
<string name="create_folder_error">Failed to create folder</string>
<string name="name">Name</string>
<string name="select_something_first">Please select something first</string>
<string name="nnf_app_name">NoNonsense File Picker</string>
<string name="nnf_new_folder">New folder</string>
<string name="nnf_create_folder_error">Failed to create folder</string>
<string name="nnf_name">Name</string>
<string name="nnf_select_something_first">Please select something first</string>
</resources>
37 changes: 37 additions & 0 deletions library/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2015 Jonas Kalderstam
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU Lesser General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<resources>
<style name="NNF_BaseTheme" parent="Theme.AppCompat.DialogWhenLarge">
<!-- You can override this in your sub theme -->
<item name="nnf_toolbarTheme">@style/ThemeOverlay.AppCompat.ActionBar</item>

<!-- These are important. Handled by toolbar. -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<style name="NNF_BaseTheme.Light" parent="Theme.AppCompat.Light.DialogWhenLarge">
<!-- You can override this in your sub theme -->
<item name="nnf_toolbarTheme">@style/ThemeOverlay.AppCompat.ActionBar</item>

<!-- These are important. Handled by toolbar. -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>
6 changes: 6 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 2.2
- All library resources are now prefixed with "nnf_" to avoid conflicts.
- Added two base themes for convenience.
- Now possible to specify a specific Toolbar-theme separate from the rest
of your theme.

# 2.1

- Now easier to override sort-order and filtering in built in SD-card picker
Expand Down
14 changes: 7 additions & 7 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:label="@string/nnf_app_name"
android:theme="@style/SampleTheme" >

<!-- Sample app -->
Expand All @@ -43,7 +43,7 @@
<!-- SD-card pickers -->
<activity
android:name="com.nononsenseapps.filepicker.FilePickerActivity"
android:label="@string/app_name"
android:label="@string/nnf_app_name"
android:theme="@style/SampleTheme">
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
Expand All @@ -53,7 +53,7 @@

<activity
android:name="com.nononsenseapps.filepicker.sample.FilePickerActivity2"
android:label="@string/app_name"
android:label="@string/nnf_app_name"
android:theme="@style/SampleThemeLight">
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
Expand All @@ -63,7 +63,7 @@

<activity
android:name="com.nononsenseapps.filepicker.sample.ImagePickerActivity"
android:label="@string/app_name"
android:label="@string/nnf_app_name"
android:theme="@style/SampleTheme">
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
Expand All @@ -73,7 +73,7 @@

<activity
android:name="com.nononsenseapps.filepicker.sample.ImagePickerActivity2"
android:label="@string/app_name"
android:label="@string/nnf_app_name"
android:theme="@style/SampleThemeLight">
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
Expand All @@ -84,12 +84,12 @@
<!-- Dropbox pickers -->
<activity
android:name="com.nononsenseapps.filepicker.sample.dropbox.DropboxFilePickerActivity"
android:label="@string/app_name"
android:label="@string/nnf_app_name"
android:theme="@style/SampleTheme">
</activity>
<activity
android:name="com.nononsenseapps.filepicker.sample.dropbox.DropboxFilePickerActivity2"
android:label="@string/app_name"
android:label="@string/nnf_app_name"
android:theme="@style/SampleThemeLight">
</activity>
<!-- Dropbox authenticator -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ protected Void doInBackground(final String... paths) {
currentPath = dbApi.metadata(path, 1, null, false, null);
refresh();
} catch (DropboxException e) {
Toast.makeText(getActivity(), R.string.create_folder_error,
Toast.makeText(getActivity(), R.string.nnf_create_folder_error,
Toast.LENGTH_SHORT).show();
}
}
Expand Down
17 changes: 8 additions & 9 deletions sample/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,23 @@

<resources>

<style name="SampleTheme" parent="Theme.AppCompat.DialogWhenLarge">
<style name="SampleTheme" parent="NNF_BaseTheme">
<item name="colorPrimary">@color/primary2</item>
<item name="colorPrimaryDark">@color/primary_dark2</item>
<item name="colorAccent">@color/accent2</item>

<item name="alertDialogTheme">@style/SampleAlertDialogTheme</item>

<!-- These are important. Handled by toolbar -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<style name="SampleThemeLight" parent="Theme.AppCompat.Light.DialogWhenLarge">
<style name="SampleThemeLight" parent="NNF_BaseTheme.Light">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>

<item name="alertDialogTheme">@style/SampleAlertDialogThemeLight</item>

<!-- These are important. Handled by toolbar -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<!-- Make sure toolbar title is white -->
<item name="nnf_toolbarTheme">@style/SampleToolbarTheme</item>
</style>

<style name="SampleAlertDialogTheme" parent="Theme.AppCompat.Dialog.Alert">
Expand All @@ -53,4 +48,8 @@
<item name="colorAccent">@color/accent</item>
</style>

<style name="SampleToolbarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:textColorPrimary">@android:color/white</item>
</style>

</resources>

0 comments on commit 4124e8e

Please sign in to comment.