This repository has been archived by the owner on Sep 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #8 from mobilejazz/provider/dropbox
Dropbox Provider
- Loading branch information
Showing
58 changed files
with
922 additions
and
92 deletions.
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
document-picker/src/main/java/com/mobilejazz/coltrane/ui/ProviderAdapter.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,33 @@ | ||
package com.mobilejazz.coltrane.ui; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.TextView; | ||
|
||
import com.mobilejazz.coltrane.library.DocumentsProvider; | ||
|
||
public class ProviderAdapter extends ArrayAdapter<DocumentsProvider> { | ||
|
||
public ProviderAdapter(Context context, int resource) { | ||
super(context, resource); | ||
} | ||
|
||
@Override | ||
public View getView(int position, View convertView, ViewGroup parent) { | ||
|
||
if (convertView == null) { | ||
convertView = LayoutInflater.from(getContext()).inflate(R.layout.root, parent, false); | ||
} | ||
|
||
DocumentsProvider provider = getItem(position); | ||
TextView tv = (TextView) convertView; | ||
|
||
tv.setText(getContext().getString(R.string.account_name, provider.getName())); | ||
tv.setCompoundDrawablesWithIntrinsicBounds(provider.getIcon(), 0, 0, 0); | ||
|
||
return convertView; | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
document-picker/src/main/java/com/mobilejazz/coltrane/ui/ProviderChooser.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,87 @@ | ||
package com.mobilejazz.coltrane.ui; | ||
|
||
import android.app.Activity; | ||
import android.app.AlertDialog; | ||
import android.app.Dialog; | ||
import android.app.DialogFragment; | ||
import android.content.DialogInterface; | ||
import android.os.Bundle; | ||
|
||
import com.mobilejazz.coltrane.library.DocumentsProvider; | ||
import com.mobilejazz.coltrane.library.DocumentsProviderRegistry; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class ProviderChooser extends DialogFragment { | ||
|
||
public interface OnProviderSelectedListener { | ||
|
||
public void onProviderSelected(DocumentsProvider provider); | ||
|
||
} | ||
|
||
private static final String ARG_PROVIDERS = "com.mobilejazz.coltrane.ui.ProviderChooser.ARG_PROVIDERS"; | ||
|
||
public static ProviderChooser newInstance(ArrayList<String> providerIds) { | ||
ProviderChooser f = new ProviderChooser(); | ||
|
||
// Supply num input as an argument. | ||
Bundle args = new Bundle(); | ||
args.putStringArrayList(ARG_PROVIDERS, providerIds); | ||
f.setArguments(args); | ||
|
||
return f; | ||
} | ||
|
||
private ArrayList<String> mProviderIds; | ||
private ProviderAdapter mAdapter; | ||
private OnProviderSelectedListener mListener; | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
if (getArguments() == null) { | ||
setArguments(savedInstanceState); | ||
} | ||
|
||
mProviderIds = getArguments().getStringArrayList(ARG_PROVIDERS); | ||
|
||
mAdapter = new ProviderAdapter(getActivity(), R.layout.root); | ||
for (String providerId : mProviderIds) { | ||
mAdapter.add(DocumentsProviderRegistry.get().getProvider(providerId)); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAttach(Activity activity) { | ||
super.onAttach(activity); | ||
try { | ||
mListener = (OnProviderSelectedListener) activity; | ||
} catch (ClassCastException e) { | ||
// The activity doesn't implement the interface, throw exception | ||
throw new ClassCastException(activity.toString() | ||
+ " must implement OnProviderSelectedListener"); | ||
} | ||
} | ||
|
||
@Override | ||
public Dialog onCreateDialog(Bundle savedInstanceState) { | ||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | ||
builder.setTitle(R.string.choose_account) | ||
.setAdapter(mAdapter, new DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialog, int which) { | ||
DocumentsProvider provider = mAdapter.getItem(which); | ||
mListener.onProviderSelected(provider); | ||
dismissAllowingStateLoss(); | ||
} | ||
}); | ||
return builder.create(); | ||
} | ||
|
||
@Override | ||
public void onSaveInstanceState(Bundle outState) { | ||
super.onSaveInstanceState(outState); | ||
outState.putStringArrayList(ARG_PROVIDERS, mProviderIds); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
document-picker/src/main/res/drawable/button_background_square.xml
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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:state_pressed="true" android:drawable="@color/native.lollipop.button.pressed" /> | ||
<item android:drawable="@color/native.lollipop.button.normal" /> | ||
</selector> |
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
Oops, something went wrong.