CommunityActivity.java 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Nextcloud Android client application
  3. *
  4. * @author Andy Scherzinger
  5. * @author Tobias Kaminsky
  6. * Copyright (C) 2016 Andy Scherzinger
  7. * Copyright (C) 2016 Nextcloud
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  11. * License as published by the Free Software Foundation; either
  12. * version 3 of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public
  20. * License along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. package com.owncloud.android.ui.activity;
  23. import android.content.Intent;
  24. import android.graphics.PorterDuff;
  25. import android.os.Bundle;
  26. import android.text.Html;
  27. import android.text.method.LinkMovementMethod;
  28. import android.view.MenuItem;
  29. import android.view.View;
  30. import android.widget.TextView;
  31. import com.google.android.material.button.MaterialButton;
  32. import com.owncloud.android.R;
  33. import com.owncloud.android.utils.DisplayUtils;
  34. import com.owncloud.android.utils.ThemeUtils;
  35. /**
  36. * Activity providing information about ways to participate in the app's development.
  37. */
  38. public class CommunityActivity extends FileActivity {
  39. @Override
  40. protected void onCreate(Bundle savedInstanceState) {
  41. super.onCreate(savedInstanceState);
  42. setContentView(R.layout.community_layout);
  43. // setup toolbar
  44. setupToolbar();
  45. // setup drawer
  46. setupDrawer(R.id.nav_community);
  47. ThemeUtils.setColoredTitle(getSupportActionBar(), R.string.drawer_community, this);
  48. setupContent();
  49. }
  50. private void setupContent() {
  51. TextView rcView = findViewById(R.id.community_release_candidate_text);
  52. rcView.setMovementMethod(LinkMovementMethod.getInstance());
  53. TextView contributeIrcView = findViewById(R.id.community_contribute_irc_text);
  54. contributeIrcView.setMovementMethod(LinkMovementMethod.getInstance());
  55. contributeIrcView.setText(Html.fromHtml(getString(R.string.community_contribute_irc_text) + " " +
  56. getString(R.string.community_contribute_irc_text_link,
  57. ThemeUtils.colorToHexString(ThemeUtils.primaryColor(this, true)),
  58. getString(R.string.irc_weblink))));
  59. TextView contributeForumView = findViewById(R.id.community_contribute_forum_text);
  60. contributeForumView.setMovementMethod(LinkMovementMethod.getInstance());
  61. contributeForumView.setText(Html.fromHtml(getString(R.string.community_contribute_forum_text) + " " +
  62. getString(R.string.community_contribute_forum_text_link,
  63. ThemeUtils.colorToHexString(ThemeUtils.primaryColor(this, true)),
  64. getString(R.string.help_link), getString(R.string.community_contribute_forum_forum))));
  65. TextView contributeTranslationView = findViewById(R.id.community_contribute_translate_text);
  66. contributeTranslationView.setMovementMethod(LinkMovementMethod.getInstance());
  67. contributeTranslationView.setText(Html.fromHtml(
  68. getString(R.string.community_contribute_translate_link,
  69. ThemeUtils.colorToHexString(ThemeUtils.primaryColor(this, true)),
  70. getString(R.string.translation_link),
  71. getString(R.string.community_contribute_translate_translate)) + " " +
  72. getString(R.string.community_contribute_translate_text)));
  73. TextView contributeGithubView = findViewById(R.id.community_contribute_github_text);
  74. contributeGithubView.setMovementMethod(LinkMovementMethod.getInstance());
  75. contributeGithubView.setText(Html.fromHtml(
  76. getString(R.string.community_contribute_github_text,
  77. getString(R.string.community_contribute_github_text_link,
  78. ThemeUtils.colorToHexString(ThemeUtils.primaryColor(this, true)),
  79. getString(R.string.contributing_link)))));
  80. MaterialButton reportButton = findViewById(R.id.community_testing_report);
  81. reportButton.getBackground().setColorFilter(ThemeUtils.primaryColor(this, true), PorterDuff.Mode.SRC_ATOP);
  82. reportButton.setOnClickListener(v -> DisplayUtils.startLinkIntent(this, R.string.report_issue_link));
  83. }
  84. public void onGetBetaFDroidClick(View view) {
  85. DisplayUtils.startLinkIntent(this, R.string.fdroid_beta_link);
  86. }
  87. public void onGetRCFDroidClick(View view) {
  88. DisplayUtils.startLinkIntent(this, R.string.fdroid_link);
  89. }
  90. public void onGetRCPlayStoreClick(View view) {
  91. DisplayUtils.startLinkIntent(this, R.string.play_store_register_beta);
  92. }
  93. public void onGetBetaApkClick(View view) {
  94. DisplayUtils.startLinkIntent(this, R.string.beta_apk_link);
  95. }
  96. @Override
  97. public boolean onOptionsItemSelected(MenuItem item) {
  98. boolean retval = true;
  99. switch (item.getItemId()) {
  100. case android.R.id.home: {
  101. if (isDrawerOpen()) {
  102. closeDrawer();
  103. } else {
  104. openDrawer();
  105. }
  106. break;
  107. }
  108. default:
  109. retval = super.onOptionsItemSelected(item);
  110. break;
  111. }
  112. return retval;
  113. }
  114. @Override
  115. public void showFiles(boolean onDeviceOnly) {
  116. super.showFiles(onDeviceOnly);
  117. Intent fileDisplayActivity = new Intent(getApplicationContext(),
  118. FileDisplayActivity.class);
  119. fileDisplayActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  120. startActivity(fileDisplayActivity);
  121. }
  122. @Override
  123. protected void onResume() {
  124. super.onResume();
  125. setDrawerMenuItemChecked(R.id.nav_community);
  126. }
  127. }