Browse Source

fix: disable broken Uploads

develop
Ezerous 2 years ago
parent
commit
8711121b11
  1. 44
      app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java
  2. 4
      app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java
  3. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadFieldsBuilderActivity.java
  4. 32
      app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java
  5. 22
      app/src/main/res/layout/activity_downloads.xml
  6. 12
      app/src/main/res/xml-v26/app_preferences_user.xml
  7. 12
      app/src/main/res/xml/app_preferences_user.xml

44
app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java

@ -57,7 +57,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.
private MaterialProgressBar progressBar; private MaterialProgressBar progressBar;
private RecyclerView recyclerView; private RecyclerView recyclerView;
private DownloadsAdapter downloadsAdapter; private DownloadsAdapter downloadsAdapter;
private FloatingActionButton uploadFAB; // private FloatingActionButton uploadFAB;
private ParseDownloadPageTask parseDownloadPageTask; private ParseDownloadPageTask parseDownloadPageTask;
private int numberOfPages = -1; private int numberOfPages = -1;
@ -124,9 +124,9 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.
} }
}); });
uploadFAB = findViewById(R.id.upload_fab); // uploadFAB = findViewById(R.id.upload_fab);
uploadFAB.setEnabled(false); // uploadFAB.setEnabled(false);
uploadFAB.hide(); // uploadFAB.hide();
parseDownloadPageTask = new ParseDownloadPageTask(); parseDownloadPageTask = new ParseDownloadPageTask();
parseDownloadPageTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, downloadsUrl); parseDownloadPageTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, downloadsUrl);
@ -135,26 +135,26 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
// Inflates the menu; this adds items to the action bar if it is present. // Inflates the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.downloads_menu, menu); // getMenuInflater().inflate(R.menu.downloads_menu, menu);
super.onCreateOptionsMenu(menu); super.onCreateOptionsMenu(menu);
return true; return true;
} }
@Override // @Override
public boolean onOptionsItemSelected(MenuItem item) { // public boolean onOptionsItemSelected(MenuItem item) {
// Handle presses on the action bar items // // Handle presses on the action bar items
switch (item.getItemId()) { // switch (item.getItemId()) {
case R.id.menu_upload: // case R.id.menu_upload:
Intent intent = new Intent(DownloadsActivity.this, UploadActivity.class); // Intent intent = new Intent(DownloadsActivity.this, UploadActivity.class);
Bundle extras = new Bundle(); // Bundle extras = new Bundle();
extras.putString(BUNDLE_UPLOAD_CATEGORY, downloadsNav); // extras.putString(BUNDLE_UPLOAD_CATEGORY, downloadsNav);
intent.putExtras(extras); // intent.putExtras(extras);
startActivity(intent); // startActivity(intent);
return true; // return true;
default: // default:
return super.onOptionsItemSelected(item); // return super.onOptionsItemSelected(item);
} // }
} // }
@Override @Override
public void onLoadMore() { public void onLoadMore() {
@ -210,7 +210,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE); if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE);
if (uploadFAB.getVisibility() != View.GONE) uploadFAB.setEnabled(false); // if (uploadFAB.getVisibility() != View.GONE) uploadFAB.setEnabled(false);
} }
@Override @Override
@ -312,7 +312,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.
toolbar.setTitle(downloadsTitle); toolbar.setTitle(downloadsTitle);
++pagesLoaded; ++pagesLoaded;
if (uploadFAB.getVisibility() != View.GONE) uploadFAB.setEnabled(true); // if (uploadFAB.getVisibility() != View.GONE) uploadFAB.setEnabled(true);
progressBar.setVisibility(ProgressBar.INVISIBLE); progressBar.setVisibility(ProgressBar.INVISIBLE);
downloadsAdapter.notifyDataSetChanged(); downloadsAdapter.notifyDataSetChanged();
isLoadingMore = false; isLoadingMore = false;

4
app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java

@ -169,7 +169,7 @@ public class UploadActivity extends BaseActivity {
} }
createDrawer(); createDrawer();
drawer.setSelection(UPLOAD_ID); // drawer.setSelection(UPLOAD_ID);
progressBar = findViewById(R.id.progressBar); progressBar = findViewById(R.id.progressBar);
@ -434,7 +434,7 @@ public class UploadActivity extends BaseActivity {
@Override @Override
protected void onResume() { protected void onResume() {
drawer.setSelection(UPLOAD_ID); // drawer.setSelection(UPLOAD_ID);
super.onResume(); super.onResume();
} }

2
app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadFieldsBuilderActivity.java

@ -99,7 +99,7 @@ public class UploadFieldsBuilderActivity extends BaseActivity {
} }
createDrawer(); createDrawer();
drawer.setSelection(UPLOAD_ID, false); // drawer.setSelection(UPLOAD_ID, false);
semesterChooserLinear = findViewById(R.id.upload_fields_builder_choose_semester); semesterChooserLinear = findViewById(R.id.upload_fields_builder_choose_semester);
semesterRadio = findViewById(R.id.upload_fields_builder_semester_radio_group); semesterRadio = findViewById(R.id.upload_fields_builder_semester_radio_group);

32
app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java

@ -167,7 +167,7 @@ public abstract class BaseActivity extends AppCompatActivity {
//------------------------------------------DRAWER STUFF---------------------------------------- //------------------------------------------DRAWER STUFF----------------------------------------
protected static final int HOME_ID = 0; protected static final int HOME_ID = 0;
protected static final int DOWNLOADS_ID = 1; protected static final int DOWNLOADS_ID = 1;
protected static final int UPLOAD_ID = 2; //protected static final int UPLOAD_ID = 2; //Removed until fixed
protected static final int BOOKMARKS_ID = 3; protected static final int BOOKMARKS_ID = 3;
protected static final int LOG_ID = 4; protected static final int LOG_ID = 4;
protected static final int ABOUT_ID = 5; protected static final int ABOUT_ID = 5;
@ -267,14 +267,14 @@ public abstract class BaseActivity extends AppCompatActivity {
.withIcon(downloadsIcon) .withIcon(downloadsIcon)
.withSelectedIcon(downloadsIconSelected); .withSelectedIcon(downloadsIconSelected);
uploadItem = new PrimaryDrawerItem() // uploadItem = new PrimaryDrawerItem()
.withTextColor(primaryColor) // .withTextColor(primaryColor)
.withSelectedColor(selectedPrimaryColor) // .withSelectedColor(selectedPrimaryColor)
.withSelectedTextColor(selectedSecondaryColor) // .withSelectedTextColor(selectedSecondaryColor)
.withIdentifier(UPLOAD_ID) // .withIdentifier(UPLOAD_ID)
.withName(R.string.upload) // .withName(R.string.upload)
.withIcon(uploadIcon) // .withIcon(uploadIcon)
.withSelectedIcon(uploadIconSelected); // .withSelectedIcon(uploadIconSelected);
shoutboxItem = new PrimaryDrawerItem() shoutboxItem = new PrimaryDrawerItem()
.withTextColor(primaryColor) .withTextColor(primaryColor)
@ -395,12 +395,12 @@ public abstract class BaseActivity extends AppCompatActivity {
startActivity(intent); startActivity(intent);
} }
} }
else if (drawerItem.equals(UPLOAD_ID)) { // else if (drawerItem.equals(UPLOAD_ID)) {
if (!(BaseActivity.this instanceof UploadActivity)) { // if (!(BaseActivity.this instanceof UploadActivity)) {
Intent intent = new Intent(BaseActivity.this, UploadActivity.class); // Intent intent = new Intent(BaseActivity.this, UploadActivity.class);
startActivity(intent); // startActivity(intent);
} // }
} // }
else if (drawerItem.equals(BOOKMARKS_ID)) { else if (drawerItem.equals(BOOKMARKS_ID)) {
if (!(BaseActivity.this instanceof BookmarksActivity)) { if (!(BaseActivity.this instanceof BookmarksActivity)) {
Intent intent = new Intent(BaseActivity.this, BookmarksActivity.class); Intent intent = new Intent(BaseActivity.this, BookmarksActivity.class);
@ -453,7 +453,7 @@ public abstract class BaseActivity extends AppCompatActivity {
if (drawer != null) { if (drawer != null) {
if (!sessionManager.isLoggedIn()) { //When logged out or if user is guest if (!sessionManager.isLoggedIn()) { //When logged out or if user is guest
drawer.removeItem(DOWNLOADS_ID); drawer.removeItem(DOWNLOADS_ID);
drawer.removeItem(UPLOAD_ID); //drawer.removeItem(UPLOAD_ID);
loginLogoutItem.withName(R.string.login).withIcon(loginIcon); //Swap logout with login loginLogoutItem.withName(R.string.login).withIcon(loginIcon); //Swap logout with login
profileDrawerItem.withName(sessionManager.getUsername()); profileDrawerItem.withName(sessionManager.getUsername());
setDefaultAvatar(); setDefaultAvatar();

22
app/src/main/res/layout/activity_downloads.xml

@ -20,7 +20,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" android:background="?attr/colorPrimary"
app:popupTheme="@style/ToolbarTheme"></androidx.appcompat.widget.Toolbar> app:popupTheme="@style/ToolbarTheme" />
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
@ -31,7 +31,7 @@
android:background="@color/background" android:background="@color/background"
android:scrollbars="none" android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior" app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="gr.thmmy.mthmmy.activities.downloads.DownloadsActivity"></androidx.recyclerview.widget.RecyclerView> tools:context="gr.thmmy.mthmmy.activities.downloads.DownloadsActivity" />
<me.zhanghai.android.materialprogressbar.MaterialProgressBar <me.zhanghai.android.materialprogressbar.MaterialProgressBar
android:id="@+id/progressBar" android:id="@+id/progressBar"
@ -45,13 +45,13 @@
app:mpb_indeterminateTint="@color/accent" app:mpb_indeterminateTint="@color/accent"
app:mpb_progressStyle="horizontal" /> app:mpb_progressStyle="horizontal" />
<com.google.android.material.floatingactionbutton.FloatingActionButton <!-- <com.google.android.material.floatingactionbutton.FloatingActionButton-->
android:id="@+id/upload_fab" <!-- android:id="@+id/upload_fab"-->
android:layout_width="wrap_content" <!-- android:layout_width="wrap_content"-->
android:layout_height="wrap_content" <!-- android:layout_height="wrap_content"-->
android:layout_gravity="bottom|end" <!-- android:layout_gravity="bottom|end"-->
android:layout_marginBottom="@dimen/fab_margins" <!-- android:layout_marginBottom="@dimen/fab_margins"-->
android:layout_marginEnd="@dimen/fab_margins" <!-- android:layout_marginEnd="@dimen/fab_margins"-->
app:layout_behavior="gr.thmmy.mthmmy.utils.ui.ScrollAwareFABBehavior" <!-- app:layout_behavior="gr.thmmy.mthmmy.utils.ui.ScrollAwareFABBehavior"-->
app:srcCompat="@drawable/ic_file_upload_white_24dp" /> <!-- app:srcCompat="@drawable/ic_file_upload_white_24dp" />-->
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>

12
app/src/main/res/xml-v26/app_preferences_user.xml

@ -40,18 +40,6 @@
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
</androidx.preference.PreferenceCategory> </androidx.preference.PreferenceCategory>
<androidx.preference.PreferenceCategory
android:key="@string/pref_category_uploading_key"
android:title="@string/pref_category_uploading"
app:iconSpaceReserved="false">
<androidx.preference.SwitchPreferenceCompat
android:defaultValue="true"
android:key="@string/pref_uploading_app_signature_enable_key"
android:title="@string/pref_title_uploading_app_signature_enable"
android:summary="@string/pref_summary_uploading_app_signature_enable"
app:iconSpaceReserved="false" />
</androidx.preference.PreferenceCategory>
<androidx.preference.PreferenceCategory <androidx.preference.PreferenceCategory
android:key="@string/pref_category_privacy_key" android:key="@string/pref_category_privacy_key"
android:title="@string/pref_category_privacy" android:title="@string/pref_category_privacy"

12
app/src/main/res/xml/app_preferences_user.xml

@ -61,18 +61,6 @@
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
</androidx.preference.PreferenceCategory> </androidx.preference.PreferenceCategory>
<androidx.preference.PreferenceCategory
android:key="@string/pref_category_uploading_key"
android:title="@string/pref_category_uploading"
app:iconSpaceReserved="false">
<androidx.preference.SwitchPreferenceCompat
android:defaultValue="true"
android:key="@string/pref_uploading_app_signature_enable_key"
android:title="@string/pref_title_uploading_app_signature_enable"
android:summary="@string/pref_summary_uploading_app_signature_enable"
app:iconSpaceReserved="false" />
</androidx.preference.PreferenceCategory>
<androidx.preference.PreferenceCategory <androidx.preference.PreferenceCategory
android:key="@string/pref_category_privacy_key" android:key="@string/pref_category_privacy_key"
android:title="@string/pref_category_privacy" android:title="@string/pref_category_privacy"

Loading…
Cancel
Save