-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from StevenL98/master
Bounty payout voting and payment execution - self-evolving AI-DAO #5986
- Loading branch information
Showing
70 changed files
with
3,876 additions
and
1,533 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
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
92 changes: 92 additions & 0 deletions
92
common/src/main/java/nl/tudelft/trustchain/common/ui/VotesFragmentHelper.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,92 @@ | ||
package nl.tudelft.trustchain.common.ui | ||
|
||
import android.content.Context | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.BaseAdapter | ||
import android.widget.ListView | ||
import android.widget.TextView | ||
import androidx.fragment.app.Fragment | ||
import androidx.viewpager2.adapter.FragmentStateAdapter | ||
import nl.tudelft.trustchain.common.R | ||
|
||
/** | ||
* The adapter for showing the tab fragments in the voting fragment | ||
*/ | ||
class TabsAdapter(fragment: Fragment, private val voters: Array<ArrayList<String>>) : | ||
FragmentStateAdapter(fragment) { | ||
|
||
override fun getItemCount(): Int = 3 | ||
|
||
override fun createFragment(position: Int): Fragment { | ||
// Return a NEW fragment instance in createFragment(int) | ||
val fragment = TabFragment() | ||
fragment.arguments = Bundle().apply { | ||
putInt("tabPosition", position) | ||
putStringArrayList("voters", voters[position]) | ||
} | ||
return fragment | ||
} | ||
} | ||
|
||
/** | ||
* The fragment for showing the votes in a list | ||
*/ | ||
class TabFragment : Fragment() { | ||
|
||
private lateinit var votesAdapter: VotesAdapter | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
return inflater.inflate(R.layout.fragment_votes_tab, container, false) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
arguments?.takeIf { | ||
it.containsKey("voters") | ||
}?.apply { | ||
|
||
val votesList = view.findViewById<ListView>(R.id.votes) | ||
votesAdapter = VotesAdapter( | ||
view.context, | ||
requireArguments().getStringArrayList("voters")!! | ||
) | ||
votesList.adapter = votesAdapter | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* The adapter for showing the vote entries in the TabFragment in the list. | ||
*/ | ||
class VotesAdapter( | ||
private val context: Context, | ||
private val voters: ArrayList<String> | ||
) : BaseAdapter() { | ||
|
||
override fun getCount(): Int { | ||
return voters.size | ||
} | ||
|
||
override fun getItem(position: Int): Any { | ||
return voters[position] | ||
} | ||
|
||
override fun getItemId(position: Int): Long { | ||
return position.toLong() | ||
} | ||
|
||
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View { | ||
val view = | ||
LayoutInflater.from(context).inflate(R.layout.fragment_votes_entry, parent, false) | ||
|
||
view.findViewById<TextView>(R.id.voter_name).text = voters[position] | ||
|
||
return view | ||
} | ||
} |
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,66 @@ | ||
<FrameLayout 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="match_parent"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<com.google.android.material.appbar.AppBarLayout | ||
android:id="@+id/appbar" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> | ||
|
||
<TextView | ||
android:id="@+id/title" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:textAllCaps="true" | ||
android:textSize="24sp" | ||
android:textStyle="bold" /> | ||
|
||
<TextView | ||
android:id="@+id/sub_title" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:textSize="18sp" /> | ||
|
||
<TextView | ||
android:id="@+id/required_votes" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:textSize="18sp" /> | ||
|
||
<com.google.android.material.tabs.TabLayout | ||
android:id="@+id/tab_layout" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" /> | ||
|
||
</com.google.android.material.appbar.AppBarLayout> | ||
|
||
<androidx.viewpager2.widget.ViewPager2 | ||
android:id="@+id/viewpager" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
|
||
</LinearLayout> | ||
|
||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton | ||
android:id="@+id/fab_user" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="end|bottom" | ||
android:layout_margin="20dp" | ||
android:contentDescription="@string/vote" | ||
android:gravity="center" | ||
android:text="@string/voteUser" | ||
android:theme="@style/VoteButton" | ||
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlayExtended" /> | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal"> | ||
|
||
<TextView | ||
android:id="@+id/voter_name" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="8dp" | ||
android:layout_weight="1" | ||
android:textSize="20sp" /> | ||
|
||
</LinearLayout> |
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,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<ListView | ||
android:id="@+id/votes" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" /> | ||
|
||
</LinearLayout> |
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
Oops, something went wrong.