Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grid view #688

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android:
components:
- tools
- platform-tools
- build-tools-23.0.2
- android-23
- build-tools-26.0.1
- android-26
- extra-android-support
- extra-android-m2repository

Expand Down
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ android {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
compile "com.android.support:design:${rootProject.ext.supportLibVersion}"
compile "com.android.support:cardview-v7:${rootProject.ext.supportLibVersion}"
// https://github.com/InkApplications/Android-ViewPagerIndicator
compile 'com.inkapplications.viewpageindicator:library:2.4.3'
// https://github.com/kevinsawicki/http-request
Expand Down
292 changes: 292 additions & 0 deletions app/hs_err_pid9592.log

Large diffs are not rendered by default.

822 changes: 822 additions & 0 deletions app/replay_pid9592.log

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@

<provider
android:name="com.seafile.seadroid2.provider.SeafileProvider"
android:authorities="${applicationId}"
android:authorities="com.seafile.seadroid2"
android:exported="true"
android:grantUriPermissions="true"
android:permission="android.permission.MANAGE_DOCUMENTS"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static void initImageLoader(Context context) {
.diskCache(new UnlimitedDiscCache(cacheDir))
.threadPriority(Thread.NORM_PRIORITY - 2)
.denyCacheImageMultipleSizesInMemory()
.threadPoolSize(6)
.diskCacheFileNameGenerator(new Md5FileNameGenerator())
.diskCacheSize(50 * 1024 * 1024) // 50 Mb
.tasksProcessingOrder(QueueProcessingType.LIFO)
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/seafile/seadroid2/SettingsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@

import com.seafile.seadroid2.account.AccountManager;
import com.seafile.seadroid2.gesturelock.LockPatternUtils;
import com.seafile.seadroid2.ui.fragment.ReposFragment;
import com.seafile.seadroid2.util.Utils;

import java.util.Arrays;
import java.util.List;

import static com.seafile.seadroid2.ui.fragment.ReposFragment.ViewMode.LIST;

/**
* Access the app settings
*/
Expand Down Expand Up @@ -90,6 +93,10 @@ private SettingsManager() {
public static final String SORT_FILES_TYPE = "sort_files_type";
public static final String SORT_FILES_ORDER = "sort_files_order";

// Repo view
public static final String REPO_VIEW_GRID_LIST = "repo_view_grid_list";


public static long lock_timestamp = 0;
public static final long LOCK_EXPIRATION_MSECS = 5 * 60 * 1000;

Expand Down Expand Up @@ -232,6 +239,14 @@ public void saveSortFilesPref(int type, int order) {
editor.putInt(SORT_FILES_ORDER, order).commit();
}

public void setRepoViewPref(String type){
editor.putString(REPO_VIEW_GRID_LIST,type).commit();
}

public String getRepoViewPref(){
return sharedPref.getString(REPO_VIEW_GRID_LIST, ReposFragment.ViewMode.LIST.toString());
}

public void setCameraUploadBucketList(List<String> list) {
String s = TextUtils.join(",", list);
sharedPref.edit().putString(SHARED_PREF_CAMERA_UPLOAD_BUCKETS, s).commit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class DataManager {
public static final String PULL_TO_REFRESH_LAST_TIME_FOR_STARRED_FRAGMENT = "starred fragment last update ";
private static SimpleDateFormat ptrDataFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

public static final String THUMBNAIL_LINK = "api2/repos/%s/thumbnail/?p=%s&size=%s";

private static Map<String, PasswordInfo> passwords = Maps.newHashMap();
private static Map<String, Long> direntsRefreshTimeMap = Maps.newHashMap();
public static final long REFRESH_EXPIRATION_MSECS = 10 * 60 * 1000; // 10 mins
Expand Down Expand Up @@ -116,7 +118,7 @@ public String getThumbnailLink(String repoName, String repoID, String filePath,
} else {
try {
String pathEnc = URLEncoder.encode(filePath, "UTF-8");
return account.getServer() + String.format("api2/repos/%s/thumbnail/?p=%s&size=%s", repoID, pathEnc, size);
return account.getServer() + String.format(THUMBNAIL_LINK, repoID, pathEnc, size);
} catch (UnsupportedEncodingException e) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,40 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}

private ReposFragment.ViewMode determineNextViewMode(){
ReposFragment.ViewMode currentMode = ReposFragment.ViewMode.valueOf(
SettingsManager.instance().getRepoViewPref());
switch (currentMode){
case GRID:
return ReposFragment.ViewMode.LIST;
case LIST:
return ReposFragment.ViewMode.GRID;
default:
return ReposFragment.ViewMode.LIST;
}
}

private void setViewModeIcon(MenuItem item,ReposFragment.ViewMode currentMode){

switch (currentMode){
case GRID:
item.setIcon(ContextCompat.getDrawable(this, R.drawable.list_view));
break;
case LIST:
item.setIcon(ContextCompat.getDrawable(this, R.drawable.grid_view));
break;
}
}

@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.switch_view:
ReposFragment.ViewMode nextMode = determineNextViewMode();
SettingsManager.instance().setRepoViewPref(nextMode.toString());
setViewModeIcon(item,nextMode);
getReposFragment().changeLayout(nextMode);
return true;
case R.id.sort:
showSortFilesDialog();
return true;
Expand Down Expand Up @@ -912,6 +943,12 @@ public boolean onCreateOptionsMenu(Menu menu) {
Toolbar toolbar = getActionBarToolbar();
toolbar.inflateMenu(R.menu.browser_menu);
toolbar.setOnMenuItemClickListener(this);
MenuItem item = toolbar.getMenu().findItem(R.id.switch_view);
if(item!=null){
ReposFragment.ViewMode currentMode = ReposFragment.ViewMode.valueOf(
SettingsManager.instance().getRepoViewPref());
setViewModeIcon(item, currentMode);
}
return true;
}

Expand Down
Loading