diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index e327d9d..1fa86b4 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..56da4a4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,15 @@ +## CHANNGELOG + + +## 0.0.1 + +* if you now click on a link outside the disroot domain it opens in a external browser. +* menu background changed to dark +* Added all icons + +## 0.0.2 + +* Non disroor.org domains open in external browser +* Fixed blank page on board.disroot.org +* Long press on mail icon shows info +* diff --git a/Changelog b/Changelog deleted file mode 100644 index 43c0bf9..0000000 --- a/Changelog +++ /dev/null @@ -1,5 +0,0 @@ -#### changes - -- if you now click on a link outside the disroot domain it opens in a external browser. -- menu background changed to dark -- Added all icons diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5ed1de6..6e063c9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -24,6 +24,10 @@ android:configChanges="orientation|screenSize" android:hardwareAccelerated="true" android:label="@string/app_name" /> + \ No newline at end of file diff --git a/app/src/main/java/org/disroot/disrootapp/AboutActivity.java b/app/src/main/java/org/disroot/disrootapp/AboutActivity.java new file mode 100644 index 0000000..33e1598 --- /dev/null +++ b/app/src/main/java/org/disroot/disrootapp/AboutActivity.java @@ -0,0 +1,153 @@ +package org.disroot.disrootapp; + +import android.support.design.widget.TabLayout; +import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; + +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.view.ViewPager; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; + +import android.widget.TextView; + +import com.example.webview.R; + +public class AboutActivity extends AppCompatActivity { + + /** + * The {@link android.support.v4.view.PagerAdapter} that will provide + * fragments for each of the sections. We use a + * {@link FragmentPagerAdapter} derivative, which will keep every + * loaded fragment in memory. If this becomes too memory intensive, it + * may be best to switch to a + * {@link android.support.v4.app.FragmentStatePagerAdapter}. + */ + private SectionsPagerAdapter mSectionsPagerAdapter; + + /** + * The {@link ViewPager} that will host the section contents. + */ + private ViewPager mViewPager; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_about); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + // Create the adapter that will return a fragment for each of the three + // primary sections of the activity. + mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); + + // Set up the ViewPager with the sections adapter. + mViewPager = (ViewPager) findViewById(R.id.container); + mViewPager.setAdapter(mSectionsPagerAdapter); + + TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); + + mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); + tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager)); + + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_about, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } + + /** + * A placeholder fragment containing a simple view. + */ + public static class PlaceholderFragment extends Fragment { + /** + * The fragment argument representing the section number for this + * fragment. + */ + private static final String ARG_SECTION_NUMBER = "section_number"; + + public PlaceholderFragment() { + } + + /** + * Returns a new instance of this fragment for the given section + * number. + */ + public static PlaceholderFragment newInstance(int sectionNumber) { + PlaceholderFragment fragment = new PlaceholderFragment(); + Bundle args = new Bundle(); + args.putInt(ARG_SECTION_NUMBER, sectionNumber); + fragment.setArguments(args); + return fragment; + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_about, container, false); + TextView textView = (TextView) rootView.findViewById(R.id.section_label); + textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER))); + return rootView; + } + } + + /** + * A {@link FragmentPagerAdapter} that returns a fragment corresponding to + * one of the sections/tabs/pages. + */ + public class SectionsPagerAdapter extends FragmentPagerAdapter { + + public SectionsPagerAdapter(FragmentManager fm) { + super(fm); + } + + @Override + public Fragment getItem(int position) { + // getItem is called to instantiate the fragment for the given page. + // Return a PlaceholderFragment (defined as a static inner class below). + return PlaceholderFragment.newInstance(position + 1); + } + + @Override + public int getCount() { + // Show 3 total pages. + return 3; + } + } +} diff --git a/app/src/main/java/org/disroot/disrootapp/ui/MainActivity.java b/app/src/main/java/org/disroot/disrootapp/ui/MainActivity.java index 676bc91..002c1e1 100644 --- a/app/src/main/java/org/disroot/disrootapp/ui/MainActivity.java +++ b/app/src/main/java/org/disroot/disrootapp/ui/MainActivity.java @@ -3,11 +3,13 @@ package org.disroot.disrootapp.ui; import android.app.AlertDialog; import android.content.Intent; import android.content.pm.PackageManager; +import android.graphics.drawable.BitmapDrawable; import android.net.Uri; import android.os.Bundle; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; +import android.util.DisplayMetrics; import android.util.Log; import android.view.KeyEvent; import android.view.Menu; @@ -16,12 +18,15 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; +import android.widget.Button; import android.widget.FrameLayout; +import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; import com.example.webview.R; +import org.disroot.disrootapp.AboutActivity; import org.disroot.disrootapp.utils.Constants; import org.disroot.disrootapp.utils.DeviceProvider; import org.disroot.disrootapp.webviews.DisWebChromeClient; @@ -34,6 +39,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL private static final String TAG = MainActivity.class.getSimpleName(); private WebView webView; private DisWebChromeClient disWebChromeClient; + Button button; @Override public void onCreate(Bundle savedInstanceState) { @@ -45,7 +51,79 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL setupWebView(savedInstanceState, frameLayoutContainer, viewLoading); // enables the activity icon as a 'home' button. required if "android:targetSdkVersion" > 14 //getActionBar().setHomeButtonEnabled(true); + final RelativeLayout dashboard = (RelativeLayout)findViewById(R.id.dashboard); + + + //Set buttons + // Locate the button in activity_main.xml + button = (Button) findViewById(R.id.MailBtn); + + button.setOnLongClickListener(new View.OnLongClickListener() { + + @Override + public boolean onLongClick(View v) { + showMailInfo(); + return true; + } + }); + // Capture button clicks + button.setOnClickListener(new View.OnClickListener() { + public void onClick(View arg0) { + + // Start NewActivity.class + String k9 = "com.fsck.k9"; + Intent mail = getPackageManager().getLaunchIntentForPackage(k9); + if(mail == null) { + mail = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+k9)); + } + startActivity(mail); + } + + }); + // Locate the button in activity_main.xml + button = (Button) findViewById(R.id.DiasporaBtn); + // Capture button clicks + button.setOnClickListener(new View.OnClickListener() { + public void onClick(View arg0) { + + // Start NewActivity.class + String Diaspora = "com.github.dfa.diaspora_android"; + Intent pod = getPackageManager().getLaunchIntentForPackage(Diaspora); + if(pod == null) { + pod = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+Diaspora)); + } + startActivity(pod); + } + + }); + + // Locate the button in activity_main.xml + button = (Button) findViewById(R.id.PadBtn); + // Capture button clicks + button.setOnClickListener(new View.OnClickListener() { + public void onClick(View arg0) { + + // Start NewActivity.class + webView.loadUrl(Constants.URL_DisApp_PAD); + webView.setVisibility(View.VISIBLE); + dashboard.setVisibility(View.GONE); + } + + }); + + // Locate the button in activity_main.xml + button = (Button) findViewById(R.id.AboudBtn); + // Capture button clicks + button.setOnClickListener(new View.OnClickListener() { + public void onClick(View arg0) { + + // Start NewActivity.class + Intent goAbout = new Intent(MainActivity.this, AboutActivity.class); + MainActivity.this.startActivity(goAbout); + } + + }); } @Override @@ -64,11 +142,13 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL protected void onPause() { super.onPause(); webView.onPause(); + webView.pauseTimers(); } @Override protected void onResume() { super.onResume(); + webView.resumeTimers(); webView.onResume(); } @@ -121,12 +201,15 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL @Override public boolean onOptionsItemSelected(MenuItem item) { + RelativeLayout dashboard = (RelativeLayout)findViewById(R.id.dashboard); switch (item.getItemId()) { case R.id.action_share: shareCurrentPage(); return true; case R.id.action_home: - webView.loadUrl(Constants.URL_DisApp_MAIN_PAGE); + webView.loadUrl(null); + webView.setVisibility(View.GONE); + dashboard.setVisibility(View.VISIBLE); return true; case R.id.action_mail: String k9 = "com.fsck.k9"; @@ -154,6 +237,8 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL return true; case R.id.action_forum: webView.loadUrl(Constants.URL_DisApp_FORUM); + webView.setVisibility(View.VISIBLE); + dashboard.setVisibility(View.GONE); return true; case R.id.action_chat: String Conversations = "eu.siacs.conversations"; @@ -165,30 +250,47 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL return true; case R.id.action_pad: webView.loadUrl(Constants.URL_DisApp_PAD); + webView.setVisibility(View.VISIBLE); + dashboard.setVisibility(View.GONE); return true; case R.id.action_calc: webView.loadUrl(Constants.URL_DisApp_CALC); + webView.setVisibility(View.VISIBLE); + dashboard.setVisibility(View.GONE); return true; case R.id.action_bin: webView.loadUrl(Constants.URL_DisApp_BIN); + webView.setVisibility(View.VISIBLE); + dashboard.setVisibility(View.GONE); return true; case R.id.action_upload: webView.loadUrl(Constants.URL_DisApp_UPLOAD); + webView.setVisibility(View.VISIBLE); + dashboard.setVisibility(View.GONE); return true; case R.id.action_searx: webView.loadUrl(Constants.URL_DisApp_SEARX); + webView.setVisibility(View.VISIBLE); + dashboard.setVisibility(View.GONE); return true; case R.id.action_poll: webView.loadUrl(Constants.URL_DisApp_POLL); + webView.setVisibility(View.VISIBLE); + dashboard.setVisibility(View.GONE); return true; case R.id.action_board: webView.loadUrl(Constants.URL_DisApp_BOARD); + webView.setVisibility(View.VISIBLE); + dashboard.setVisibility(View.GONE); return true; case R.id.action_user: webView.loadUrl(Constants.URL_DisApp_USER); + webView.setVisibility(View.VISIBLE); + dashboard.setVisibility(View.GONE); return true; case R.id.action_about: - showAppInfo(); + Intent goAbout = new Intent(MainActivity.this, AboutActivity.class); + MainActivity.this.startActivity(goAbout); return true; default: return super.onOptionsItemSelected(item); @@ -203,19 +305,20 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL if (actionBar != null) actionBar.setTitle(""); } - private void setupWebView(Bundle savedInstanceState, FrameLayout customViewContainer, ViewGroup viewLoading) { disWebChromeClient = new DisWebChromeClient(this, webView, customViewContainer); webView = (WebView) findViewById(R.id.webView_content); webView.setWebViewClient(new DisWebViewClient(savedInstanceState, viewLoading)); webView.setWebChromeClient(disWebChromeClient); webView.getSettings().setJavaScriptEnabled(true); + webView.getSettings().setDomStorageEnabled(true);//solves taiga board \o/ webView.setVerticalScrollBarEnabled(false); webView.getSettings().setAppCacheEnabled(true); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setSaveFormData(true); - webView.loadUrl(Constants.URL_DisApp_MAIN_PAGE); + // webView.loadUrl(Constants.URL_DisApp_MAIN_PAGE); webView.setOnLongClickListener(this); + webView.setVisibility(View.GONE); } public void shareCurrentPage() { @@ -226,10 +329,11 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL startActivity(intent); } - private void showAppInfo() { + private void showMailInfo() { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); - builder.setTitle(R.string.app_name); - builder.setMessage(getString(R.string.activity_main_manteiners, DeviceProvider.getAppVersion(this))); + builder.setTitle(R.string.MailInfoTitle); + //builder.setMessage(getString(R.string.activity_main_manteiners, DeviceProvider.getAppVersion(this))); + builder.setMessage(getString(R.string.MailInfo)); builder.setPositiveButton(R.string.global_ok, null); builder.show(); } diff --git a/app/src/main/java/org/disroot/disrootapp/utils/Constants.java b/app/src/main/java/org/disroot/disrootapp/utils/Constants.java index 948c669..a37a72c 100644 --- a/app/src/main/java/org/disroot/disrootapp/utils/Constants.java +++ b/app/src/main/java/org/disroot/disrootapp/utils/Constants.java @@ -12,13 +12,13 @@ public class Constants { public static final String URL_DisApp_CLOUD = "https://cloud.disroot.org"; public static final String URL_DisApp_DIASPORA = "https://pod.disroot.org/"; public static final String URL_DisApp_FORUM = "https://forum.disroot.org/"; - public static final String URL_DisApp_CHAT = "http://chat.disroot.org"; - public static final String URL_DisApp_PAD = "http://pad.disroot.org"; - public static final String URL_DisApp_CALC = "http://calc.disroot.org"; - public static final String URL_DisApp_BIN = "http://bin.disroot.org"; - public static final String URL_DisApp_UPLOAD = "http://upload.disroot.org"; - public static final String URL_DisApp_SEARX = "http://search.disroot.org"; - public static final String URL_DisApp_POLL = "http://poll.disroot.org"; - public static final String URL_DisApp_BOARD = "http://board.disroot.org"; - public static final String URL_DisApp_USER = "http://user.disroot.org"; + public static final String URL_DisApp_CHAT = "https://chat.disroot.org"; + public static final String URL_DisApp_PAD = "https://pad.disroot.org"; + public static final String URL_DisApp_CALC = "https://calc.disroot.org"; + public static final String URL_DisApp_BIN = "https://bin.disroot.org"; + public static final String URL_DisApp_UPLOAD = "https://upload.disroot.org"; + public static final String URL_DisApp_SEARX = "https://search.disroot.org"; + public static final String URL_DisApp_POLL = "https://poll.disroot.org"; + public static final String URL_DisApp_BOARD = "https://board.disroot.org"; + public static final String URL_DisApp_USER = "https://user.disroot.org"; } diff --git a/app/src/main/res/drawable/bgimage.jpg b/app/src/main/res/drawable/bgimage.jpg new file mode 100644 index 0000000..c9bbdd1 Binary files /dev/null and b/app/src/main/res/drawable/bgimage.jpg differ diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml new file mode 100644 index 0000000..e68bdba --- /dev/null +++ b/app/src/main/res/layout/activity_about.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index dff436f..9a35a9e 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -21,6 +21,65 @@ + + + +