-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
239 additions
and
8 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
47 changes: 47 additions & 0 deletions
47
app/src/main/java/de/felixnuesse/timedsilence/fragments/BluetoothFragment.kt
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,47 @@ | ||
package de.felixnuesse.timedsilence.fragments | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import de.felixnuesse.timedsilence.databinding.FragmentBluetoothBinding | ||
import de.felixnuesse.timedsilence.handler.calculator.BluetoothHandler | ||
import de.felixnuesse.timedsilence.ui.BluetoothListAdapter | ||
import de.felixnuesse.timedsilence.ui.custom.NestedRecyclerManager | ||
|
||
|
||
class BluetoothFragment : Fragment() { | ||
|
||
private lateinit var viewAdapter: RecyclerView.Adapter<*> | ||
private lateinit var viewManager: RecyclerView.LayoutManager | ||
|
||
private var _binding: FragmentBluetoothBinding? = null | ||
private val binding get() = _binding!! | ||
|
||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
_binding = FragmentBluetoothBinding.inflate(inflater, container, false) | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
viewManager = NestedRecyclerManager(view.context) | ||
viewAdapter = BluetoothListAdapter(BluetoothHandler.getPairedDevices(view.context)) | ||
|
||
binding.bluetoothFragmentRecylcerListView.apply { | ||
setHasFixedSize(true) | ||
layoutManager = viewManager | ||
adapter = viewAdapter | ||
} | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
} |
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
72 changes: 72 additions & 0 deletions
72
app/src/main/java/de/felixnuesse/timedsilence/ui/BluetoothListAdapter.kt
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,72 @@ | ||
package de.felixnuesse.timedsilence.ui; | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import android.widget.ArrayAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import de.felixnuesse.timedsilence.R | ||
import de.felixnuesse.timedsilence.databinding.AdapterBluetoothListBinding | ||
import de.felixnuesse.timedsilence.model.data.BluetoothObject | ||
|
||
|
||
/** | ||
* Copyright (C) 2019 Felix Nüsse | ||
* Created on 14.04.19 - 17:18 | ||
* <p> | ||
* Edited by: Felix Nüsse felix.nuesse(at)t-online.de | ||
* <p> | ||
* <p> | ||
* This program is released under the GPLv3 license | ||
* <p> | ||
* <p> | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* <p> | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* <p> | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
class BluetoothListAdapter(private var myDataset: ArrayList<BluetoothObject>) : RecyclerView.Adapter<BluetoothListAdapter.BluetoothViewHolder>() { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BluetoothViewHolder { | ||
val binding = AdapterBluetoothListBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
return BluetoothViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: BluetoothViewHolder, position: Int) { | ||
val calObject= myDataset[position] | ||
val context = holder.view.root.context | ||
|
||
holder.view.rowTitle.text = calObject.name | ||
|
||
val spinnerArray = listOf( | ||
context.getString(R.string.volume_setting_unset), | ||
context.getString(R.string.volume_setting_silent), | ||
context.getString(R.string.volume_setting_vibrate), | ||
context.getString(R.string.volume_setting_loud) | ||
) | ||
|
||
val spinner = holder.view.volumeSpinner | ||
val adapter = ArrayAdapter( | ||
context, | ||
android.R.layout.simple_spinner_item, | ||
spinnerArray | ||
) | ||
|
||
spinner.adapter = adapter | ||
} | ||
|
||
override fun getItemCount() = myDataset.size | ||
|
||
class BluetoothViewHolder(val view: AdapterBluetoothListBinding) : RecyclerView.ViewHolder(view.root) | ||
|
||
} | ||
|
||
|
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 @@ | ||
<vector android:height="24dp" android:tint="@color/iconColor" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M17,7l-4.29,-4.29c-0.63,-0.63 -1.71,-0.19 -1.71,0.7v6.18L7.11,5.7c-0.39,-0.39 -1.02,-0.39 -1.41,0 -0.39,0.39 -0.39,1.02 0,1.41L10.59,12 5.7,16.89c-0.39,0.39 -0.39,1.02 0,1.41 0.39,0.39 1.02,0.39 1.41,0L11,14.41v6.18c0,0.89 1.08,1.34 1.71,0.71L17,17c0.39,-0.39 0.39,-1.02 0,-1.41L13.41,12 17,8.42c0.39,-0.39 0.39,-1.03 0,-1.42zM13,5.83l1.88,1.88L13,9.59L13,5.83zM14.88,16.29L13,18.17v-3.76l1.88,1.88z"/> | ||
</vector> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<androidx.cardview.widget.CardView | ||
android:id="@+id/cardView" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="@dimen/cardMargin" | ||
android:padding="@dimen/cardPadding" | ||
app:cardBackgroundColor="?attr/colorTertiaryContainer" | ||
app:cardCornerRadius="@dimen/cornerRadius" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent"> | ||
|
||
<LinearLayout | ||
android:id="@+id/layoutWeekdays" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="8dp" | ||
android:gravity="center" | ||
android:orientation="horizontal"> | ||
|
||
<ImageView | ||
android:id="@+id/volumeState" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
app:srcCompat="@android:drawable/btn_dialog" | ||
app:tint="@android:color/white" /> | ||
|
||
<TextView | ||
android:id="@+id/rowTitle" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:paddingStart="12dp" | ||
android:text="title" | ||
android:textColor="@android:color/white" /> | ||
|
||
<Spinner | ||
android:id="@+id/volumeSpinner" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="32dp" /> | ||
</LinearLayout> | ||
|
||
</androidx.cardview.widget.CardView> | ||
|
||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
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,43 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".fragments.BluetoothFragment"> | ||
|
||
|
||
<ScrollView | ||
android:id="@+id/BluetoothListContainer" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:id="@+id/label_bluetooth_fragment" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="24dp" | ||
android:layout_marginEnd="16dp" | ||
android:gravity="center" | ||
android:text="@string/fragment_title_bluetooth" | ||
android:textStyle="bold" /> | ||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/bluetooth_fragment_recylcer_list_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:layout_marginTop="24dp" | ||
android:layout_marginBottom="24dp" | ||
android:layout_marginEnd="8dp" /> | ||
|
||
</LinearLayout> | ||
</ScrollView> | ||
|
||
</FrameLayout> |
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